cleanup and start with nostr

This commit is contained in:
HolgerHatGarKeineNode
2023-11-20 18:10:33 +01:00
parent df1eb750b7
commit a392e6fee0
218 changed files with 31 additions and 17474 deletions

View File

@@ -1,46 +0,0 @@
<?php
namespace App\Http\Livewire\Meetup\Embed;
use App\Models\Country;
use App\Models\Meetup;
use Livewire\Component;
use RalphJSmit\Laravel\SEO\Support\SEOData;
class CountryMap extends Component
{
public Country $country;
public bool $darkMode = false;
protected $queryString = ['darkMode' => ['except' => false]];
public function render()
{
return view('livewire.meetup.embed.country-map', [
'markers' => Meetup::query()
->with([
'city.country',
])
->whereHas('city.country',
fn($query) => $query->where('countries.code', $this->country->code))
->get()
->map(fn($meetup) => [
'id' => $meetup->id,
'name' => $meetup->name,
'coords' => [$meetup->city->latitude, $meetup->city->longitude],
'url' => url()->route('meetup.landing', [
'country' => $meetup->city->country->code,
'meetup' => $meetup,
]),
]),
])->layout('layouts.app', [
'darkModeDisabled' => !$this->darkMode,
'SEOData' => new SEOData(
title: __('Meetups'),
description: __('Bitcoiner Meetups are a great way to meet other Bitcoiners in your area. You can learn from each other, share ideas, and have fun!'),
image: asset('img/screenshot.png')
),
]);
}
}

View File

@@ -1,174 +0,0 @@
<?php
namespace App\Http\Livewire\Meetup\Form;
use App\Models\MeetupEvent;
use App\Support\Carbon;
use Livewire\Component;
use WireUi\Traits\Actions;
class MeetupEventForm extends Component
{
use Actions;
public string $country;
public ?MeetupEvent $meetupEvent = null;
public bool $recurring = false;
public int $repetitions = 12;
public array $series = [];
public ?string $fromUrl = '';
protected $queryString = ['fromUrl' => ['except' => '']];
public function rules()
{
return [
'meetupEvent.meetup_id' => 'required',
'meetupEvent.start' => 'required',
'meetupEvent.location' => 'string|max:255|nullable',
'meetupEvent.description' => 'string|nullable',
'meetupEvent.link' => 'url|max:255|nullable',
'series' => 'array',
'series.*.start' => 'required',
'recurring' => 'bool',
'repetitions' => 'numeric|min:1',
];
}
public function mount()
{
if (!$this->meetupEvent) {
$this->meetupEvent = new MeetupEvent(
[
'start' => now()
->startOfDay()
->addHours(17),
]
);
} elseif (!auth()
->user()
->can('update', $this->meetupEvent)) {
abort(403);
}
if (!$this->fromUrl) {
$this->fromUrl = url()->previous();
}
}
public function updatedMeetupEventStart($value)
{
$this->validateOnly('meetupEvent.start');
if ($this->recurring) {
$this->updatedRecurring(true);
}
}
public function updatedRecurring($value)
{
$this->validateOnly('recurring');
$series = [];
if ($value && $this->meetupEvent->start) {
for ($i = 0; $i < $this->repetitions; $i++) {
$series[] = [
'start' => $this->meetupEvent->start->addMonths($i + 1)
->toDateTimeString(),
];
}
}
$this->series = $series;
}
public function updatedRepetitions($value)
{
$this->validateOnly('repetitions');
if ($this->recurring) {
$this->updatedRecurring(true, $value);
}
}
public function deleteMe()
{
$this->dialog()
->confirm(
[
'title' => __('Delete event'),
'description' => __('Are you sure you want to delete this event? This action cannot be undone.'),
'icon' => 'warning',
'accept' => [
'label' => __('Yes, delete'),
'method' => 'deleteEvent',
],
'reject' => [
'label' => __('No, cancel'),
'method' => 'cancel',
],
]
);
}
public function deleteEvent()
{
$this->meetupEvent->delete();
return to_route('meetup.table.meetupEvent', ['country' => $this->country]);
}
public function submit()
{
$this->validate();
if (!$this->meetupEvent->id) {
$hasAppointmentsOnThisDate = MeetupEvent::query()
->where('meetup_id', $this->meetupEvent->meetup_id)
->where('start', '>', Carbon::parse($this->meetupEvent->start)
->startOfDay())
->where('start', '<', Carbon::parse($this->meetupEvent->start)
->endOfDay())
->exists();
if ($hasAppointmentsOnThisDate) {
$this->notification()
->warning(__('There is already an event on this date. Please choose another date or delete the existing events.'));
return;
}
}
$this->meetupEvent->save();
if ($this->recurring) {
foreach ($this->series as $event) {
$hasAppointmentsOnThisDate = MeetupEvent::query()
->where('meetup_id', $this->meetupEvent->meetup_id)
->where('start', '>', Carbon::parse($event['start'])
->startOfDay())
->where('start', '<', Carbon::parse($event['start'])
->endOfDay())
->exists();
if ($hasAppointmentsOnThisDate) {
continue;
}
$this->meetupEvent->replicate()
->fill($event)
->saveQuietly();
}
}
$this->notification()
->success(__('Event saved successfully.'));
return to_route('meetup.table.meetupEvent', ['country' => $this->country]);
}
public function render()
{
return view('livewire.meetup.form.meetup-event-form');
}
}

View File

@@ -1,93 +0,0 @@
<?php
namespace App\Http\Livewire\Meetup\Form;
use App\Models\Meetup;
use Illuminate\Validation\Rule;
use Livewire\Component;
use Livewire\WithFileUploads;
use WireUi\Traits\Actions;
class MeetupForm extends Component
{
use WithFileUploads;
use Actions;
public string $country;
public ?Meetup $meetup = null;
public ?string $fromUrl = '';
public $image;
protected $queryString = [
'fromUrl' => [
'except' => null,
],
];
public function rules()
{
return [
'image' => [Rule::requiredIf(!$this->meetup->id), 'nullable', 'mimes:jpeg,png,jpg,gif', 'max:10240'],
'meetup.city_id' => 'required',
'meetup.name' => [
'required',
Rule::unique('meetups', 'name')
->ignore($this->meetup),
],
'meetup.community' => 'required',
'meetup.telegram_link' => 'string|nullable|required_without_all:meetup.webpage,meetup.nostr,meetup.twitter_username,meetup.matrix_group',
'meetup.intro' => 'string|nullable',
'meetup.webpage' => 'string|url|nullable|required_without_all:meetup.telegram_link,meetup.nostr,meetup.twitter_username,meetup.matrix_group',
'meetup.nostr' => 'string|nullable|required_without_all:meetup.webpage,meetup.telegram_link,meetup.twitter_username,meetup.matrix_group',
'meetup.twitter_username' => 'string|regex:/^[A-z0-9!@]+$/|nullable|required_without_all:meetup.webpage,meetup.telegram_link,meetup.nostr,meetup.matrix_group',
'meetup.matrix_group' => 'string|nullable|required_without_all:meetup.webpage,meetup.telegram_link,meetup.nostr,meetup.twitter_username',
'meetup.simplex' => 'string|nullable',
];
}
public function mount()
{
if (!$this->meetup) {
$this->meetup = new Meetup([
'community' => 'einundzwanzig',
]);
} elseif (
!auth()
->user()
->can('update', $this->meetup)
) {
abort(403);
}
if (!$this->fromUrl) {
$this->fromUrl = url()->previous();
}
}
public function submit()
{
$this->validate();
$this->meetup->save();
if ($this->image) {
$this->meetup->addMedia($this->image)
->usingFileName(md5($this->image->getClientOriginalName()) . '.' . $this->image->getClientOriginalExtension())
->toMediaCollection('logo');
}
auth()
->user()
->meetups()
->syncWithoutDetaching($this->meetup->id);
return redirect($this->fromUrl);
}
public function render()
{
return view('livewire.meetup.form.meetup-form');
}
}

View File

@@ -1,68 +0,0 @@
<?php
namespace App\Http\Livewire\Meetup;
use App\Models\Country;
use App\Models\Meetup;
use App\Models\MeetupEvent;
use Livewire\Component;
use RalphJSmit\Laravel\SEO\Support\SEOData;
class LandingPage extends Component
{
public Meetup $meetup;
public Country $country;
public ?int $activeEvent = null;
public ?int $year = null;
public function mount()
{
$this->meetup->load([
'media',
]);
}
public function render()
{
return view('livewire.meetup.landing-page', [
'meetupEvents' => MeetupEvent::query()
->with([
'meetup.city.country',
])
->where('meetup_events.meetup_id', $this->meetup->id)
->where('meetup_events.start', '>=', now()->subDay())
->orderBy('start')
->get(),
'events' => MeetupEvent::query()
->with([
'meetup.city.country',
])
->where('meetup_events.meetup_id', $this->meetup->id)
->where('meetup_events.start', '>=', now()->subDay())
->orderBy('start')
->get()
->map(fn ($event) => [
'id' => $event->id,
'startDate' => $event->start,
'endDate' => $event->start->addHours(1),
'location' => $event->location,
'description' => $event->description,
]),
])
->layout('layouts.guest', [
'SEOData' => new SEOData(
title: $this->meetup->name,
description: __('Bitcoiner Meetups are a great way to meet other Bitcoiners in your area. You can learn from each other, share ideas, and have fun!'),
image: $this->meetup->getFirstMediaUrl('logo'),
),
]);
}
public function showEvent($id)
{
$this->activeEvent = $id;
}
}

View File

@@ -1,209 +0,0 @@
<?php
namespace App\Http\Livewire\Meetup;
use App\Models\Country;
use App\Models\Meetup;
use App\Models\MeetupEvent;
use App\Models\User;
use App\Rules\UniqueAttendeeName;
use Livewire\Component;
use RalphJSmit\Laravel\SEO\Support\SEOData;
class LandingPageEvent extends Component
{
public MeetupEvent $meetupEvent;
public Country $country;
public ?Meetup $meetup = null;
public bool $willShowUp = false;
public bool $perhapsShowUp = false;
public string $name = '';
public array $attendees = [];
public array $mightAttendees = [];
public function rules()
{
return [
'name' => [
'required',
new UniqueAttendeeName($this->meetupEvent),
],
];
}
public function mount()
{
$this->meetupEvent->load('meetup.users');
$this->meetup = $this->meetupEvent->meetup;
$this->name = auth()->check() ? auth()->user()->name : '';
$this->checkShowUp();
}
public function checkShowUp()
{
$attendees = collect($this->meetupEvent->attendees);
$mightAttendees = collect($this->meetupEvent->might_attendees);
if (auth()->check() && $attendees->contains(fn($value) => str($value)->contains('id_'.auth()->id()))) {
$this->name = str($attendees->filter(fn($value) => str($value)->contains('id_'.auth()->id()))
->first())
->after('|')
->toString();
$this->willShowUp = true;
}
if (!auth()->check() && $attendees->contains(fn($value) => str($value)->contains('anon_'.session()->getId()))) {
$this->name = str($attendees->filter(fn($value) => str($value)->contains('anon_'.session()->getId()))
->first())
->after('|')
->toString();
$this->willShowUp = true;
}
if (auth()->check() && $mightAttendees->contains(fn($value) => str($value)->contains('id_'.auth()->id()))) {
$this->name = str($mightAttendees->filter(fn($value) => str($value)->contains('id_'.auth()->id()))
->first())
->after('|')
->toString();
$this->perhapsShowUp = true;
}
if (!auth()->check() && $mightAttendees->contains(fn($value
) => str($value)->contains('anon_'.session()->getId()))) {
$this->name = str($mightAttendees->filter(fn($value) => str($value)->contains('anon_'.session()->getId()))
->first())
->after('|')
->toString();
$this->perhapsShowUp = true;
}
$this->attendees = $this->mapAttendees($attendees);
$this->mightAttendees = $this->mapAttendees($mightAttendees);
}
private function mapAttendees($collection) {
return $collection->map(function ($value) {
if (str($value)->contains('anon_')) {
$id = -1;
} else {
$id = str($value)
->before('|')
->after('id_')
->toString();
}
return [
'id' => $id,
'user' => $id > 0 ? User::withoutEvents(static fn() => User::query()
->select([
'id',
'name',
'profile_photo_path',
])
->find($id)
?->append('profile_photo_url')
->toArray())
: null,
'name' => str($value)
->after('|')
->toString(),
];
})
->toArray();
}
public function cannotCome()
{
$attendees = collect($this->meetupEvent->attendees);
$mightAttendees = collect($this->meetupEvent->might_attendees);
if (auth()->check() && $attendees->contains(fn($value) => str($value)->contains('id_'.auth()->id()))) {
$attendees = $attendees->filter(fn($value) => !str($value)->contains('id_'.auth()->id()));
$this->willShowUp = false;
}
if (!auth()->check() && $attendees->contains(fn($value) => str($value)->contains('anon_'.session()->getId()))) {
$attendees = $attendees->filter(fn($value) => !str($value)->contains('anon_'.session()->getId()));
$this->willShowUp = false;
}
if (auth()->check() && $mightAttendees->contains(fn($value) => str($value)->contains('id_'.auth()->id()))) {
$mightAttendees = $mightAttendees->filter(fn($value) => !str($value)->contains('id_'.auth()->id()));
$this->perhapsShowUp = false;
}
if (!auth()->check() && $mightAttendees->contains(fn($value
) => str($value)->contains('anon_'.session()->getId()))) {
$mightAttendees = $mightAttendees->filter(fn($value) => !str($value)->contains('anon_'.session()->getId()));
$this->perhapsShowUp = false;
}
$this->meetupEvent->update([
'attendees' => $attendees->toArray(),
'might_attendees' => $mightAttendees->toArray(),
]);
$this->checkShowUp();
}
public function attend()
{
$this->validate();
$attendees = collect($this->meetupEvent->attendees);
if (auth()->check() && !$attendees->contains('id_'.auth()->id().'|'.$this->name)) {
$attendees->push('id_'.auth()->id().'|'.$this->name);
$this->willShowUp = true;
}
if (!auth()->check() && !$attendees->contains('anon_'.session()->getId().'|'.$this->name)) {
$attendees->push('anon_'.session()->getId().'|'.$this->name);
$this->willShowUp = true;
}
$this->meetupEvent->update([
'attendees' => $attendees->toArray(),
]);
$this->checkShowUp();
}
public function mightAttend()
{
$this->validate();
$mightAttendees = collect($this->meetupEvent->might_attendees);
if (auth()->check() && !$mightAttendees->contains('id_'.auth()->id().'|'.$this->name)) {
$mightAttendees->push('id_'.auth()->id().'|'.$this->name);
$this->perhapsShowUp = true;
}
if (!auth()->check() && !$mightAttendees->contains('anon_'.session()->getId().'|'.$this->name)) {
$mightAttendees->push('anon_'.session()->getId().'|'.$this->name);
$this->perhapsShowUp = true;
}
$this->meetupEvent->update([
'might_attendees' => $mightAttendees->toArray(),
]);
$this->checkShowUp();
}
public function render()
{
return view('livewire.meetup.landing-page-event')->layout('layouts.guest', [
'SEOData' => new SEOData(
title: $this->meetupEvent->start->asDateTime().' - '.$this->meetup->name,
description: __('Here you can confirm your participation and find more information about the Meetup.').' - '.$this->meetupEvent->description,
image: $this->meetup->getFirstMediaUrl('logo'),
),
]);
}
}

View File

@@ -1,97 +0,0 @@
<?php
namespace App\Http\Livewire\Meetup;
use App\Models\Country;
use App\Models\MeetupEvent;
use App\Traits\HasMapEmbedCodeTrait;
use Livewire\Component;
use RalphJSmit\Laravel\SEO\Support\SEOData;
use WireUi\Traits\Actions;
class MeetupEventTable extends Component
{
use Actions;
use HasMapEmbedCodeTrait;
public Country $country;
public ?int $year = null;
protected $queryString = ['year'];
public function mount()
{
if (!$this->year) {
$this->year = now()->year;
}
}
public function render()
{
return view('livewire.meetup.meetup-event-table', [
'markers' => MeetupEvent::query()
->with([
'meetup.city.country',
])
->where('meetup_events.start', '>=', now()->subDay())
->whereHas('meetup.city.country',
fn($query) => $query->where('countries.code', $this->country->code))
->get()
->map(fn($event) => [
'id' => $event->id,
'name' => $event->meetup->name . ': ' . $event->location,
'coords' => [$event->meetup->city->latitude, $event->meetup->city->longitude],
]),
'events' => MeetupEvent::query()
->with([
'meetup.city.country',
])
->where('meetup_events.start', '>=', now()->subDay())
->whereHas('meetup.city.country',
fn($query) => $query->where('countries.code', $this->country->code))
->get()
->map(fn($event) => [
'id' => $event->id,
'startDate' => $event->start,
'endDate' => $event->start->addHours(1),
'location' => $event->location,
'description' => $event->description,
]),
])->layout('layouts.app', [
'SEOData' => new SEOData(
title: __('Meetup dates'),
description: __('List of all meetup dates'),
image: asset('img/screenshot.png')
),
]);
}
public function filterByMarker($id)
{
return to_route('meetup.table.meetupEvent', [
'#table',
'country' => $this->country->code,
'year' => $this->year,
'meetup_events' => [
'filters' => [
'byid' => $id,
],
],
]);
}
public function popover($content, $ids)
{
return to_route('meetup.table.meetupEvent', [
'#table',
'year' => $this->year,
'country' => $this->country->code,
'meetup_events' => [
'filters' => [
'byid' => $ids,
],
],
]);
}
}

View File

@@ -1,54 +0,0 @@
<?php
namespace App\Http\Livewire\Meetup;
use App\Models\Country;
use App\Models\Meetup;
use App\Traits\HasMapEmbedCodeTrait;
use Livewire\Component;
use RalphJSmit\Laravel\SEO\Support\SEOData;
class MeetupTable extends Component
{
use HasMapEmbedCodeTrait;
public Country $country;
public function filterByMarker($id)
{
$meetup = Meetup::with(['city.country'])
->find($id);
return to_route('meetup.landing', [
'country' => $meetup->city->country->code,
'meetup' => $meetup,
]);
}
public function render()
{
// let markers = [{name: 'VAK', coords: [50.0091294, 9.0371812], status: 'closed', offsets: [0, 2]}];
return view('livewire.meetup.meetup-table', [
'markers' => Meetup::query()
->where('visible_on_map', true)
->with([
'city.country',
])
->whereHas('city.country',
fn($query) => $query->where('countries.code', $this->country->code))
->get()
->map(fn($meetup) => [
'id' => $meetup->id,
'name' => $meetup->name,
'coords' => [$meetup->city->latitude, $meetup->city->longitude],
]),
])->layout('layouts.app', [
'SEOData' => new SEOData(
title: __('Meetups'),
description: __('Bitcoiner Meetups are a great way to meet other Bitcoiners in your area. You can learn from each other, share ideas, and have fun!'),
image: asset('img/screenshot.png')
),
]);
}
}

View File

@@ -1,46 +0,0 @@
<?php
namespace App\Http\Livewire\Meetup;
use App\Models\Country;
use App\Models\Meetup;
use Livewire\Component;
use RalphJSmit\Laravel\SEO\Support\SEOData;
class WorldMap extends Component
{
public Country $country;
public function filterByMarker($id)
{
$meetup = Meetup::with(['city.country'])
->find($id);
return to_route('meetup.landing', [
'country' => $meetup->city->country->code,
'meetup' => $meetup,
]);
}
public function render()
{
return view('livewire.meetup.world-map', [
'allMarkers' => Meetup::query()
->where('visible_on_map', true)
->with([
'city.country',
])
->get()
->map(fn($meetup) => [
'id' => $meetup->id,
'name' => $meetup->name,
'coords' => [$meetup->city->latitude, $meetup->city->longitude],
]),
])->layout('layouts.app', [
'SEOData' => new SEOData(
title: __('World map of meetups'),
image: asset('img/screenshot.png')
),
]);
}
}