closes #21 feat: add calendar stream URL to meetups

This commit adds a calendar stream URL to each meetup. The URL is copied to
the clipboard when the user clicks on a new button added to the UI. The copied
URL can be pasted into a compatible calendar app, allowing the user to easily
add the meetup to their calendar. This feature was added to several views
including 'profile/meetups', 'meetup/landing-page', and
'meetup/landing-page-event'. The associated controller 'DownloadMeetupCalendar'
and livewire components were also updated accordingly.
This commit is contained in:
HolgerHatGarKeineNode
2024-01-07 10:31:39 +01:00
parent 93d3858f30
commit 7b8d32807c
6 changed files with 127 additions and 56 deletions

View File

@@ -19,7 +19,7 @@ class DownloadMeetupCalendar extends Controller
if ($request->has('meetup')) { if ($request->has('meetup')) {
$meetup = Meetup::query() $meetup = Meetup::query()
->with([ ->with([
'meetupEvents', 'meetupEvents.meetup',
]) ])
->findOrFail($request->input('meetup')); ->findOrFail($request->input('meetup'));
$events = $meetup->meetupEvents; $events = $meetup->meetupEvents;

View File

@@ -20,37 +20,41 @@ class LandingPage extends Component
public function mount() public function mount()
{ {
$this->meetup->load([ $this->meetup
'media', ->loadCount([
]); 'meetupEvents'
])
->load([
'media',
]);
} }
public function render() public function render()
{ {
return view('livewire.meetup.landing-page', [ return view('livewire.meetup.landing-page', [
'meetupEvents' => MeetupEvent::query() 'meetupEvents' => MeetupEvent::query()
->with([ ->with([
'meetup.city.country', 'meetup.city.country',
]) ])
->where('meetup_events.meetup_id', $this->meetup->id) ->where('meetup_events.meetup_id', $this->meetup->id)
->where('meetup_events.start', '>=', now()->subDay()) ->where('meetup_events.start', '>=', now()->subDay())
->orderBy('start') ->orderBy('start')
->get(), ->get(),
'events' => MeetupEvent::query() 'events' => MeetupEvent::query()
->with([ ->with([
'meetup.city.country', 'meetup.city.country',
]) ])
->where('meetup_events.meetup_id', $this->meetup->id) ->where('meetup_events.meetup_id', $this->meetup->id)
->where('meetup_events.start', '>=', now()->subDay()) ->where('meetup_events.start', '>=', now()->subDay())
->orderBy('start') ->orderBy('start')
->get() ->get()
->map(fn ($event) => [ ->map(fn($event) => [
'id' => $event->id, 'id' => $event->id,
'startDate' => $event->start, 'startDate' => $event->start,
'endDate' => $event->start->addHours(1), 'endDate' => $event->start->addHours(1),
'location' => $event->location, 'location' => $event->location,
'description' => $event->description, 'description' => $event->description,
]), ]),
]) ])
->layout('layouts.guest', [ ->layout('layouts.guest', [
'SEOData' => new SEOData( 'SEOData' => new SEOData(

View File

@@ -38,13 +38,13 @@ class Meetups extends Component
} }
$this->meetups = Meetup::query() $this->meetups = Meetup::query()
->with([ ->with([
'city', 'city',
]) ])
->where('name', 'ilike', '%'.$this->search.'%') ->where('name', 'ilike', '%' . $this->search . '%')
->orderBy('name') ->orderBy('name')
->limit(10) ->limit(10)
->get(); ->get();
$this->myMeetups = auth() $this->myMeetups = auth()
->user() ->user()
->meetups() ->meetups()
@@ -64,7 +64,11 @@ class Meetups extends Component
'link' => route('meetup.landing', [ 'link' => route('meetup.landing', [
'country' => $meetup->city->country->code, 'country' => $meetup->city->country->code,
'meetup' => $meetup, 'meetup' => $meetup,
]) ]),
'ics' => route('meetup.ics', [
'country' => $meetup->city->country->code,
'meetup' => $meetup,
]),
]) ])
->toArray(); ->toArray();
if (count($this->myMeetups) > 0) { if (count($this->myMeetups) > 0) {
@@ -83,20 +87,20 @@ class Meetups extends Component
public function updatedSearch($value) public function updatedSearch($value)
{ {
$this->meetups = Meetup::query() $this->meetups = Meetup::query()
->with([ ->with([
'city', 'city',
]) ])
->where('name', 'ilike', '%'.$value.'%') ->where('name', 'ilike', '%' . $value . '%')
->orderBy('name') ->orderBy('name')
->limit(10) ->limit(10)
->get(); ->get();
} }
public function signUpForMeetup($id) public function signUpForMeetup($id)
{ {
$user = auth()->user(); $user = auth()->user();
$user->meetups() $user->meetups()
->toggle($id); ->toggle($id);
$this->myMeetups = auth() $this->myMeetups = auth()
->user() ->user()
->meetups() ->meetups()
@@ -121,11 +125,15 @@ class Meetups extends Component
'link' => route('meetup.landing', [ 'link' => route('meetup.landing', [
'country' => $meetup->city->country->code, 'country' => $meetup->city->country->code,
'meetup' => $meetup, 'meetup' => $meetup,
]) ]),
'ics' => route('meetup.ics', [
'country' => $meetup->city->country->code,
'meetup' => $meetup,
]),
]) ])
->toArray(); ->toArray();
$this->notification() $this->notification()
->success(__('Saved.')); ->success(__('Saved.'));
} }
public function render() public function render()

View File

@@ -269,6 +269,27 @@
</div> </div>
@endauth @endauth
</div> </div>
<div class="flex flex-col space-y-2">
<x-button
x-data="{}"
@click.prevent="window.navigator.clipboard.writeText('{{ route('meetup.ics', ['country' => $this->country ?? $meetup->city->country->code, 'meetup' => $meetup]) }}');window.$wireui.notify({title:'{{ __('Calendar Stream Url copied!') }}',description:'{{ __('Paste the calendar stream link into a compatible calendar app.') }}',icon:'success'});"
primary class="mt-4 whitespace-nowrap">
<i class="fa fa-thin fa-calendar-circle-exclamation mr-2"></i>
{{ __('Calendar Stream-Url') }} {{ $meetup->name }}
</x-button>
@if(auth()->check() && auth()->user()->meetups->count() > 0)
<x-button
x-data="{
textToCopy: '{{ route('meetup.ics', ['country' => 'de', 'my' => auth()->user()->meetups->pluck('id')->toArray()]) }}',
}"
@click.prevent="window.navigator.clipboard.writeText(textToCopy);window.$wireui.notify({title:'{{ __('Calendar Stream Url copied!') }}',description:'{{ __('Paste the calendar stream link into a compatible calendar app.') }}',icon:'success'});"
black>
<i class="fa fa-thin fa-calendar-heart mr-2"></i>
{{ __('Calendar Stream-Url for my meetups only') }}
</x-button>
@endif
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -73,11 +73,20 @@
<div class="max-w-screen-2xl mx-auto px-2 sm:px-10 space-y-4"> <div class="max-w-screen-2xl mx-auto px-2 sm:px-10 space-y-4">
<section class="h-auto px-10 py-16"> <section class="h-auto py-16">
<div class="max-w-3xl mx-auto space-y-4 sm:text-center"> <div class="mx-auto space-y-4 sm:text-center">
<h2 class="text-4xl sm:text-5xl font-semibold text-white"> <div class="flex space-x-4 items-baseline">
{{ __('Events') }} <div class="text-4xl sm:text-5xl font-semibold text-white">{{ __('Events') }}</div>
</h2> <div>
<x-button
x-data="{}"
@click.prevent="window.navigator.clipboard.writeText('{{ route('meetup.ics', ['country' => $this->country ?? $meetup->city->country->code, 'meetup' => $meetup]) }}');window.$wireui.notify({title:'{{ __('Calendar Stream Url copied!') }}',description:'{{ __('Paste the calendar stream link into a compatible calendar app.') }}',icon:'success'});"
primary lg class="mt-4 whitespace-nowrap">
<i class="fa fa-thin fa-calendar-circle-exclamation mr-2"></i>
{{ __('Calendar Stream-Url') }}
</x-button>
</div>
</div>
</div> </div>
</section> </section>
@@ -86,7 +95,8 @@
@php @php
$activeClass = $activeEvent === $meetupEvent->id ? 'bg-gradient-to-r from-amber-800 via-amber-600 to-amber-500' : 'bg-amber-500'; $activeClass = $activeEvent === $meetupEvent->id ? 'bg-gradient-to-r from-amber-800 via-amber-600 to-amber-500' : 'bg-amber-500';
@endphp @endphp
<li id="meetupEventId_{{ $meetupEvent->id }}" class="{{ $activeClass }} col-span-1 flex flex-col divide-y divide-gray-200 rounded-lg text-center shadow-2xl"> <li id="meetupEventId_{{ $meetupEvent->id }}"
class="{{ $activeClass }} col-span-1 flex flex-col divide-y divide-gray-200 rounded-lg text-center shadow-2xl">
<div class="flex flex-1 flex-col p-8"> <div class="flex flex-1 flex-col p-8">
{{--<img class="mx-auto h-32 w-32 object-contain flex-shrink-0 rounded" {{--<img class="mx-auto h-32 w-32 object-contain flex-shrink-0 rounded"
src="{{ $meetupEvent->meetup->getFirstMediaUrl('logo') }}" src="{{ $meetupEvent->meetup->getFirstMediaUrl('logo') }}"
@@ -117,7 +127,8 @@
</button> </button>
</h2> </h2>
<div x-show="expanded" x-collapse> <div x-show="expanded" x-collapse>
<div class="px-6 pb-4 text-left">{!! nl2br($meetupEvent->description) !!}</div> <div
class="px-6 pb-4 text-left">{!! nl2br($meetupEvent->description) !!}</div>
</div> </div>
</div> </div>
</div> </div>
@@ -126,7 +137,8 @@
<div> <div>
<div class="-mt-px flex divide-x divide-gray-200"> <div class="-mt-px flex divide-x divide-gray-200">
<div class="-ml-px flex w-0 flex-1"> <div class="-ml-px flex w-0 flex-1">
<a target="_blank" href="{{ route('meetup.event.landing', ['country' => $country, 'meetupEvent' => $meetupEvent]) }}" <a target="_blank"
href="{{ route('meetup.event.landing', ['country' => $country, 'meetupEvent' => $meetupEvent]) }}"
class="relative inline-flex w-0 flex-1 items-center justify-center rounded-br-lg border border-transparent py-4 text-sm font-medium text-gray-700 hover:text-gray-500"> class="relative inline-flex w-0 flex-1 items-center justify-center rounded-br-lg border border-transparent py-4 text-sm font-medium text-gray-700 hover:text-gray-500">
<i class="text-gray-100 text-2xl fa-thin fa-right-to-bracket"></i> <i class="text-gray-100 text-2xl fa-thin fa-right-to-bracket"></i>
<span class="ml-3 text-gray-100 text-2xl">{{ __('Link to participate') }}</span> <span class="ml-3 text-gray-100 text-2xl">{{ __('Link to participate') }}</span>

View File

@@ -13,6 +13,19 @@
{{ __('Select one or more meetup groups so that you can get access to these groups in the backend.') }} {{ __('Select one or more meetup groups so that you can get access to these groups in the backend.') }}
</p> </p>
</div> </div>
<div class="flex flex-col space-y-2">
@if(auth()->check() && auth()->user()->meetups->count() > 0)
<x-button
x-data="{
textToCopy: '{{ route('meetup.ics', ['country' => 'de', 'my' => auth()->user()->meetups->pluck('id')->toArray()]) }}',
}"
@click.prevent="window.navigator.clipboard.writeText(textToCopy);window.$wireui.notify({title:'{{ __('Calendar Stream Url copied!') }}',description:'{{ __('Paste the calendar stream link into a compatible calendar app.') }}',icon:'success'});"
black>
<i class="fa fa-thin fa-calendar-heart mr-2"></i>
{{ __('Calendar Stream-Url for my meetups only') }}
</x-button>
@endif
</div>
</div> </div>
</section> </section>
@@ -24,11 +37,24 @@
</p> </p>
<div class="grid grid-cols-1 gap-2"> <div class="grid grid-cols-1 gap-2">
@foreach($myMeetupNames as $myMeetup) @foreach($myMeetupNames as $myMeetup)
<a href="{{ $myMeetup['link'] }}"> <div class="flex items-center space-x-2">
<x-badge <div>
class="whitespace-nowrap" lg outline white <a href="{{ $myMeetup['link'] }}">
label="{{ $myMeetup['name'] }}"/> <x-badge
</a> class="whitespace-nowrap" lg outline white
label="{{ $myMeetup['name'] }}"/>
</a>
</div>
<div>
<x-badge
x-data="{}"
@click.prevent="window.navigator.clipboard.writeText('{{ $myMeetup['ics'] }}');window.$wireui.notify({title:'{{ __('Calendar Stream Url copied!') }}',description:'{{ __('Paste the calendar stream link into a compatible calendar app.') }}',icon:'success'});"
primary lg class="whitespace-nowrap cursor-pointer">
<i class="fa fa-thin fa-calendar-circle-exclamation mr-2"></i>
{{ __('Calendar') }}
</x-badge>
</div>
</div>
@endforeach @endforeach
</div> </div>
</div> </div>