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')) {
$meetup = Meetup::query()
->with([
'meetupEvents',
'meetupEvents.meetup',
])
->findOrFail($request->input('meetup'));
$events = $meetup->meetupEvents;

View File

@@ -20,37 +20,41 @@ class LandingPage extends Component
public function mount()
{
$this->meetup->load([
'media',
]);
$this->meetup
->loadCount([
'meetupEvents'
])
->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(),
->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,
]),
->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(

View File

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

View File

@@ -269,6 +269,27 @@
</div>
@endauth
</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>

View File

@@ -73,11 +73,20 @@
<div class="max-w-screen-2xl mx-auto px-2 sm:px-10 space-y-4">
<section class="h-auto px-10 py-16">
<div class="max-w-3xl mx-auto space-y-4 sm:text-center">
<h2 class="text-4xl sm:text-5xl font-semibold text-white">
{{ __('Events') }}
</h2>
<section class="h-auto py-16">
<div class="mx-auto space-y-4 sm:text-center">
<div class="flex space-x-4 items-baseline">
<div class="text-4xl sm:text-5xl font-semibold text-white">{{ __('Events') }}</div>
<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>
</section>
@@ -86,7 +95,8 @@
@php
$activeClass = $activeEvent === $meetupEvent->id ? 'bg-gradient-to-r from-amber-800 via-amber-600 to-amber-500' : 'bg-amber-500';
@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">
{{--<img class="mx-auto h-32 w-32 object-contain flex-shrink-0 rounded"
src="{{ $meetupEvent->meetup->getFirstMediaUrl('logo') }}"
@@ -117,7 +127,8 @@
</button>
</h2>
<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>
@@ -126,7 +137,8 @@
<div>
<div class="-mt-px flex divide-x divide-gray-200">
<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">
<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>

View File

@@ -13,6 +13,19 @@
{{ __('Select one or more meetup groups so that you can get access to these groups in the backend.') }}
</p>
</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>
</section>
@@ -24,11 +37,24 @@
</p>
<div class="grid grid-cols-1 gap-2">
@foreach($myMeetupNames as $myMeetup)
<a href="{{ $myMeetup['link'] }}">
<x-badge
class="whitespace-nowrap" lg outline white
label="{{ $myMeetup['name'] }}"/>
</a>
<div class="flex items-center space-x-2">
<div>
<a href="{{ $myMeetup['link'] }}">
<x-badge
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
</div>
</div>