From 75408d1381f0bc4929a4520549c333f5c019d1a7 Mon Sep 17 00:00:00 2001 From: lkassianik Date: Mon, 27 Apr 2015 14:27:34 -0700 Subject: [PATCH] Calendar event monograms, part 3. Remarkup for calendar event monograms. Summary: Ref T7928, Calendar event monograms, part 3. Remarkup for calendar event monograms. Test Plan: Create calendar event, open a maniphest task, add 'E{id}' and preview should show a hovertag for event that links to event. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Maniphest Tasks: T7928 Differential Revision: https://secure.phabricator.com/D12580 --- src/__phutil_library_map__.php | 3 + .../PhabricatorCalendarApplication.php | 6 ++ .../phid/PhabricatorCalendarEventPHIDType.php | 6 +- .../PhabricatorCalendarRemarkupRule.php | 19 +++++++ .../storage/PhabricatorCalendarEvent.php | 56 ++++++++++++++++++- .../markup/PhabricatorMarkupEngine.php | 8 +++ 6 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 src/applications/calendar/remarkup/PhabricatorCalendarRemarkupRule.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 2e56722345..17b51f75b4 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1492,6 +1492,7 @@ phutil_register_library_map(array( 'PhabricatorCalendarEventViewController' => 'applications/calendar/controller/PhabricatorCalendarEventViewController.php', 'PhabricatorCalendarHoliday' => 'applications/calendar/storage/PhabricatorCalendarHoliday.php', 'PhabricatorCalendarHolidayTestCase' => 'applications/calendar/storage/__tests__/PhabricatorCalendarHolidayTestCase.php', + 'PhabricatorCalendarRemarkupRule' => 'applications/calendar/remarkup/PhabricatorCalendarRemarkupRule.php', 'PhabricatorCalendarViewController' => 'applications/calendar/controller/PhabricatorCalendarViewController.php', 'PhabricatorCampfireProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorCampfireProtocolAdapter.php', 'PhabricatorCelerityApplication' => 'applications/celerity/application/PhabricatorCelerityApplication.php', @@ -4799,6 +4800,7 @@ phutil_register_library_map(array( 'PhabricatorCalendarEvent' => array( 'PhabricatorCalendarDAO', 'PhabricatorPolicyInterface', + 'PhabricatorMarkupInterface', ), 'PhabricatorCalendarEventDeleteController' => 'PhabricatorCalendarController', 'PhabricatorCalendarEventEditController' => 'PhabricatorCalendarController', @@ -4810,6 +4812,7 @@ phutil_register_library_map(array( 'PhabricatorCalendarEventViewController' => 'PhabricatorCalendarController', 'PhabricatorCalendarHoliday' => 'PhabricatorCalendarDAO', 'PhabricatorCalendarHolidayTestCase' => 'PhabricatorTestCase', + 'PhabricatorCalendarRemarkupRule' => 'PhabricatorObjectRemarkupRule', 'PhabricatorCalendarViewController' => 'PhabricatorCalendarController', 'PhabricatorCampfireProtocolAdapter' => 'PhabricatorBotBaseStreamingProtocolAdapter', 'PhabricatorCelerityApplication' => 'PhabricatorApplication', diff --git a/src/applications/calendar/application/PhabricatorCalendarApplication.php b/src/applications/calendar/application/PhabricatorCalendarApplication.php index 229bf03353..2eeb4f0fbe 100644 --- a/src/applications/calendar/application/PhabricatorCalendarApplication.php +++ b/src/applications/calendar/application/PhabricatorCalendarApplication.php @@ -32,6 +32,12 @@ final class PhabricatorCalendarApplication extends PhabricatorApplication { return true; } + public function getRemarkupRules() { + return array( + new PhabricatorCalendarRemarkupRule(), + ); + } + public function getRoutes() { return array( '/E(?P[1-9]\d*)' => 'PhabricatorCalendarEventViewController', diff --git a/src/applications/calendar/phid/PhabricatorCalendarEventPHIDType.php b/src/applications/calendar/phid/PhabricatorCalendarEventPHIDType.php index 29486e95ee..68ae85cf65 100644 --- a/src/applications/calendar/phid/PhabricatorCalendarEventPHIDType.php +++ b/src/applications/calendar/phid/PhabricatorCalendarEventPHIDType.php @@ -29,8 +29,12 @@ final class PhabricatorCalendarEventPHIDType extends PhabricatorPHIDType { $event = $objects[$phid]; $id = $event->getID(); + $name = pht('Event %d', $id); - $handle->setName(pht('Event %d', $id)); + $handle + ->setName(pht('Event %d', $id)) + ->setFullName(pht('E%d: %s', $id, $name)) + ->setURI('/E'.$id); } } diff --git a/src/applications/calendar/remarkup/PhabricatorCalendarRemarkupRule.php b/src/applications/calendar/remarkup/PhabricatorCalendarRemarkupRule.php new file mode 100644 index 0000000000..7da580e019 --- /dev/null +++ b/src/applications/calendar/remarkup/PhabricatorCalendarRemarkupRule.php @@ -0,0 +1,19 @@ +getEngine()->getConfig('viewer'); + + return id(new PhabricatorCalendarEventQuery()) + ->setViewer($viewer) + ->withIDs($ids) + ->execute(); + } + +} diff --git a/src/applications/calendar/storage/PhabricatorCalendarEvent.php b/src/applications/calendar/storage/PhabricatorCalendarEvent.php index 1e94041f5b..93871daaa3 100644 --- a/src/applications/calendar/storage/PhabricatorCalendarEvent.php +++ b/src/applications/calendar/storage/PhabricatorCalendarEvent.php @@ -1,8 +1,8 @@ getID(); + } + public function getTerseSummary(PhabricatorUser $viewer) { $until = phabricator_date($this->dateTo, $viewer); if ($this->status == PhabricatorCalendarEvent::STATUS_SPORADIC) { @@ -95,6 +99,52 @@ final class PhabricatorCalendarEvent return parent::save(); } +/* -( Markup Interface )--------------------------------------------------- */ + + + /** + * @task markup + */ + public function getMarkupFieldKey($field) { + $hash = PhabricatorHash::digest($this->getMarkupText($field)); + $id = $this->getID(); + return "calendar:T{$id}:{$field}:{$hash}"; + } + + + /** + * @task markup + */ + public function getMarkupText($field) { + return $this->getDescription(); + } + + + /** + * @task markup + */ + public function newMarkupEngine($field) { + return PhabricatorMarkupEngine::newCalendarMarkupEngine(); + } + + + /** + * @task markup + */ + public function didMarkupText( + $field, + $output, + PhutilMarkupEngine $engine) { + return $output; + } + + + /** + * @task markup + */ + public function shouldUseMarkupCache($field) { + return (bool)$this->getID(); + } /* -( PhabricatorPolicyInterface )----------------------------------------- */ diff --git a/src/infrastructure/markup/PhabricatorMarkupEngine.php b/src/infrastructure/markup/PhabricatorMarkupEngine.php index 590301ae29..491940d23f 100644 --- a/src/infrastructure/markup/PhabricatorMarkupEngine.php +++ b/src/infrastructure/markup/PhabricatorMarkupEngine.php @@ -353,6 +353,14 @@ final class PhabricatorMarkupEngine { )); } + /** + * @task engine + */ + public static function newCalendarMarkupEngine() { + return self::newMarkupEngine(array( + )); + } + /** * @task engine