Skip to content

Commit

Permalink
Events: support for non-meetups
Browse files Browse the repository at this point in the history
  • Loading branch information
distantnative committed Oct 10, 2024
1 parent 7645c90 commit 24ae8f2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
36 changes: 30 additions & 6 deletions site/models/event.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,55 @@ public function date(): Field
return parent::date()->value($this->num() . ' ' . $this->start()->or('18:00:00'));
}

public function icon(): string
{
if ($this->isMeetup() === true) {
return '📍';
}

return '🗓️';
}

public function isMeetup(): bool
{
return $this->city()->isNotEmpty() === true;
}

public function isUpcoming(): bool
{
return $this->date()->toTimestamp() >= time();
}

public function shortTitle(): Field
{
$title = [
(string)$this->city()
];
$title = [];

if ($this->content()->get('title')->isNotEmpty()) {
$title[] = (string)parent::title();
}

if ($this->city()->isNotEmpty()) {
$title[] = 'Kirby Meetup ' . $this->city();
}

if ($this->conference()->isNotEmpty()) {
$title[] = '@ ' . $this->conference();
}

if ($this->issue()->isNotEmpty()) {
$title[] = '' . $this->issue();
$title[] = '' . $this->issue();
}

return parent::shortTitle()->value(implode(' ', $title));
return parent::shortTitle()->value(implode(' ', $title));
}

public function title(): Field
{
return parent::title()->value('Kirby Community Meetup • ' . $this->shortTitle());
if ($this->isMeetup() === true) {
return parent::title()->value('Kirby Community Meetup • ' . $this->shortTitle());
}

return parent::title();
}

}
2 changes: 1 addition & 1 deletion site/snippets/templates/meet/event.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<a target="_blank" href="<?= $event->link() ?>" class="event">
<h3>📍 Kirby Meetup <?= $event->shortTitle() ?></h3>
<h3><?= $event->icon() ?> <?= $event->shortTitle() ?></h3>

<?php if ($event->isUpcoming() === true): ?>
<localized-datetime date="<?= $event->date()->toDate('Y-m-d H:i:s') ?>"><?= $event->date()->toDate('D, j M Y, H:i T') ?></localized-datetime>
Expand Down

0 comments on commit 24ae8f2

Please sign in to comment.