Event upgraded to microformats2

This commit is contained in:
Mikael Nordfeldth 2014-06-23 14:18:59 +02:00
parent 658c6ab9a8
commit 703443f152
5 changed files with 45 additions and 41 deletions

View File

@ -311,7 +311,7 @@ class EventPlugin extends MicroappPlugin
function onEndShowScripts($action) function onEndShowScripts($action)
{ {
$action->script($this->path('event.js')); $action->script($this->path('js/event.js'));
} }
function onEndShowStyles($action) function onEndShowStyles($action)

View File

@ -149,16 +149,17 @@ class Happening extends Managed_DataObject
$location, $location,
$description); $description);
// TRANS: Rendered event description. %1$s is a title, %2$s is start time, %3$s is start time, // TRANS: Rendered microformats2 tagged event description.
// TRANS: %1$s is a title, %2$s is start time, %3$s is start time,
// TRANS: %4$s is end time, %5$s is end time, %6$s is location, %7$s is description. // TRANS: %4$s is end time, %5$s is end time, %6$s is location, %7$s is description.
// TRANS: Class names should not be translated. // TRANS: Class names should not be translated.
$rendered = sprintf(_m('<span class="vevent">'. $rendered = sprintf(_m('<div class="h-event">'.
'<span class="summary">%1$s</span> '. '<p class="p-name p-summary">%1$s</p> '.
'<abbr class="dtstart" title="%2$s">%3$s</a> - '. '<time class="dt-start" datetime="%2$s">%3$s</time> - '.
'<abbr class="dtend" title="%4$s">%5$s</a> '. '<time class="dt-end" datetime="%4$s">%5$s</time> '.
'(<span class="location">%6$s</span>): '. '(<span class="p-location">%6$s</span>): '.
'<span class="description">%7$s</span> '. '<div class="p-description">%7$s</div> '.
'</span>'), '</div>'),
htmlspecialchars($title), htmlspecialchars($title),
htmlspecialchars(common_date_iso8601($ev->start_time)), htmlspecialchars(common_date_iso8601($ev->start_time)),
htmlspecialchars(common_exact_date($ev->start_time)), htmlspecialchars(common_exact_date($ev->start_time)),
@ -187,6 +188,20 @@ class Happening extends Managed_DataObject
return $saved; return $saved;
} }
/**
* Returns the profile's canonical url, not necessarily a uri/unique id
*
* @return string $url
*/
public function getUrl()
{
if (empty($this->url) ||
!filter_var($this->url, FILTER_VALIDATE_URL)) {
throw new InvalidUrlException($this->url);
}
return $this->url;
}
function getNotice() function getNotice()
{ {
return Notice::getKV('uri', $this->uri); return Notice::getKV('uri', $this->uri);

View File

@ -6,8 +6,6 @@
.event-notice-count { float: right; } .event-notice-count { float: right; }
.event-info { float: left; } .event-info { float: left; }
.event-title { margin-left: 0px; } .event-title { margin-left: 0px; }
#content .event .h-entry { margin-left: 0px; }
#content .event .e-content { margin-left: 0px; }
.ui-autocomplete { .ui-autocomplete {
max-height: 100px; max-height: 100px;
overflow-y: auto; overflow-y: auto;
@ -37,7 +35,7 @@ li.rsvp-list .entities li .u-photo {
float: none !important; float: none !important;
} }
.notice .vevent div { .notice .h-event div {
margin-bottom: 8px; margin-bottom: 8px;
} }
@ -94,7 +92,7 @@ li.rsvp-list .entities li .u-photo {
background: linear-gradient(top, #fb6104 0%,#fc8035 100%); background: linear-gradient(top, #fb6104 0%,#fc8035 100%);
} }
#wrap .vevent form.processing input.submit { #wrap .h-event form.processing input.submit {
text-indent: 0; text-indent: 0;
background: #ff9d63; background: #ff9d63;
} }

View File

@ -66,16 +66,14 @@ class EventListItem extends NoticeListItemAdapter
return; return;
} }
$out->elementStart('div', 'vevent event e-content'); // VEVENT IN // e-content since we're part of a h-entry
$out->elementStart('div', 'h-event e-content'); // VEVENT IN
$out->elementStart('h3', 'summary'); // VEVENT/H3 IN $out->elementStart('h3', 'p-summary p-name'); // VEVENT/H3 IN
if (!empty($event->url)) { try {
$out->element('a', $out->element('a', array('href' => $event->getUrl()), $event->title);
array('href' => $event->url, } catch (InvalidUrlException $e) {
'class' => 'event-title entry-title summary'),
$event->title);
} else {
$out->text($event->title); $out->text($event->title);
} }
@ -114,19 +112,15 @@ class EventListItem extends NoticeListItemAdapter
// TRANS: Field label for event description. // TRANS: Field label for event description.
$out->element('strong', null, _m('Time:')); $out->element('strong', null, _m('Time:'));
$out->element('abbr', array('class' => 'dtstart', $out->element('time', array('class' => 'dt-start',
'title' => common_date_iso8601($event->start_time)), 'datetime' => common_date_iso8601($event->start_time)),
$startDateStr . ' ' . $startTimeStr); $startDateStr . ' ' . $startTimeStr);
$out->text(' '); $out->text(' ');
if ($startDateStr == $endDateStr) { $out->element('time', array('class' => 'dt-end',
$out->element('span', array('class' => 'dtend', 'datetime' => common_date_iso8601($event->end_time)),
'title' => common_date_iso8601($event->end_time)), $startDateStr == $endDateStr
$endTimeStr); ? "$endDatestr $endTimeStr"
} else { : $endTimeStr);
$out->element('span', array('class' => 'dtend',
'title' => common_date_iso8601($event->end_time)),
$endDateStr . ' ' . $endTimeStr);
}
$out->elementEnd('div'); // VEVENT/EVENT-TIMES OUT $out->elementEnd('div'); // VEVENT/EVENT-TIMES OUT
@ -134,7 +128,7 @@ class EventListItem extends NoticeListItemAdapter
$out->elementStart('div', 'event-location'); $out->elementStart('div', 'event-location');
// TRANS: Field label for event description. // TRANS: Field label for event description.
$out->element('strong', null, _m('Location:')); $out->element('strong', null, _m('Location:'));
$out->element('span', 'location', $event->location); $out->element('span', 'p-location', $event->location);
$out->elementEnd('div'); $out->elementEnd('div');
} }
@ -142,22 +136,21 @@ class EventListItem extends NoticeListItemAdapter
$out->elementStart('div', 'event-description'); $out->elementStart('div', 'event-description');
// TRANS: Field label for event description. // TRANS: Field label for event description.
$out->element('strong', null, _m('Description:')); $out->element('strong', null, _m('Description:'));
$out->element('span', 'description', $event->description); $out->element('div', 'p-description', $event->description);
$out->elementEnd('div'); $out->elementEnd('div');
} }
$rsvps = $event->getRSVPs(); $rsvps = $event->getRSVPs();
$out->elementStart('div', 'event-rsvps'); $out->elementStart('div', 'event-rsvps');
// TRANS: Field label for event description.
$out->text(_('Attending:')); // TRANS: Field label for event description.
$out->element('strong', null, _m('Attending:'));
$out->elementStart('ul', 'attending-list'); $out->elementStart('ul', 'attending-list');
foreach ($rsvps as $verb => $responses) { foreach ($rsvps as $verb => $responses) {
$out->elementStart('li', 'rsvp-list'); $out->elementStart('li', 'rsvp-list');
switch ($verb) switch ($verb) {
{
case RSVP::POSITIVE: case RSVP::POSITIVE:
$out->text(_('Yes:')); $out->text(_('Yes:'));
break; break;
@ -173,9 +166,7 @@ class EventListItem extends NoticeListItemAdapter
$ids[] = $response->profile_id; $ids[] = $response->profile_id;
} }
$ids = array_slice($ids, 0, ProfileMiniList::MAX_PROFILES + 1); $ids = array_slice($ids, 0, ProfileMiniList::MAX_PROFILES + 1);
$profiles = Profile::pivotGet('id', $ids); $minilist = new ProfileMiniList(Profile::multiGet('id', $ids), $out);
$profile = new ArrayWrapper(array_values($profiles));
$minilist = new ProfileMiniList($profile, $out);
$minilist->show(); $minilist->show();
$out->elementEnd('li'); $out->elementEnd('li');