From 1ecbf23e1e9974facd32b55f8b68ec43ca3f4e06 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 15 Oct 2012 14:51:04 -0700 Subject: [PATCH] Show PhamePost and PhameBlog content/descriptions on detail pages Summary: Currently the new detail pages don't show this information. Show it, and use the remarkup cache for BLAZING OODLES OF PERFOARMSNECES!!~~~ Test Plan: See screenshots. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1373 Differential Revision: https://secure.phabricator.com/D3700 --- .../blog/PhameBlogViewController.php | 10 +++++ .../post/PhamePostViewController.php | 10 +++++ src/applications/phame/storage/PhameBlog.php | 37 ++++++++++++++++++- src/applications/phame/storage/PhamePost.php | 36 +++++++++++++++++- 4 files changed, 91 insertions(+), 2 deletions(-) diff --git a/src/applications/phame/controller/blog/PhameBlogViewController.php b/src/applications/phame/controller/blog/PhameBlogViewController.php index 3ab5e528d2..058b7c0d80 100644 --- a/src/applications/phame/controller/blog/PhameBlogViewController.php +++ b/src/applications/phame/controller/blog/PhameBlogViewController.php @@ -107,6 +107,16 @@ final class PhameBlogViewController extends PhameController { pht('Joinable By'), $descriptions[PhabricatorPolicyCapability::CAN_JOIN]); + $engine = id(new PhabricatorMarkupEngine()) + ->setViewer($user) + ->addObject($blog, PhameBlog::MARKUP_FIELD_DESCRIPTION) + ->process(); + + $properties->addTextContent( + '
'. + $engine->getOutput($blog, PhameBlog::MARKUP_FIELD_DESCRIPTION). + '
'); + return $properties; } diff --git a/src/applications/phame/controller/post/PhamePostViewController.php b/src/applications/phame/controller/post/PhamePostViewController.php index d0a2747a0f..74cf64dff8 100644 --- a/src/applications/phame/controller/post/PhamePostViewController.php +++ b/src/applications/phame/controller/post/PhamePostViewController.php @@ -181,6 +181,16 @@ final class PhamePostViewController extends PhameController { ? pht('Draft') : phabricator_datetime($post->getDatePublished(), $user)); + $engine = id(new PhabricatorMarkupEngine()) + ->setViewer($user) + ->addObject($post, PhamePost::MARKUP_FIELD_BODY) + ->process(); + + $properties->addTextContent( + '
'. + $engine->getOutput($post, PhamePost::MARKUP_FIELD_BODY). + '
'); + return $properties; } } diff --git a/src/applications/phame/storage/PhameBlog.php b/src/applications/phame/storage/PhameBlog.php index 16905a813d..6e4b6e1167 100644 --- a/src/applications/phame/storage/PhameBlog.php +++ b/src/applications/phame/storage/PhameBlog.php @@ -19,7 +19,11 @@ /** * @group phame */ -final class PhameBlog extends PhameDAO implements PhabricatorPolicyInterface { +final class PhameBlog extends PhameDAO + implements PhabricatorPolicyInterface, PhabricatorMarkupInterface { + + const MARKUP_FIELD_DESCRIPTION = 'markup:description'; + const SKIN_DEFAULT = 'PhabricatorBlogSkin'; @@ -259,4 +263,35 @@ final class PhameBlog extends PhameDAO implements PhabricatorPolicyInterface { return false; } + +/* -( PhabricatorMarkupInterface Implementation )-------------------------- */ + + + public function getMarkupFieldKey($field) { + $hash = PhabricatorHash::digest($this->getMarkupText($field)); + return $this->getPHID().':'.$field.':'.$hash; + } + + + public function newMarkupEngine($field) { + return PhabricatorMarkupEngine::newPhameMarkupEngine(); + } + + + public function getMarkupText($field) { + return $this->getDescription(); + } + + + public function didMarkupText( + $field, + $output, + PhutilMarkupEngine $engine) { + return $output; + } + + public function shouldUseMarkupCache($field) { + return (bool)$this->getPHID(); + } + } diff --git a/src/applications/phame/storage/PhamePost.php b/src/applications/phame/storage/PhamePost.php index 66eeef1624..bebce50589 100644 --- a/src/applications/phame/storage/PhamePost.php +++ b/src/applications/phame/storage/PhamePost.php @@ -19,7 +19,10 @@ /** * @group phame */ -final class PhamePost extends PhameDAO implements PhabricatorPolicyInterface { +final class PhamePost extends PhameDAO + implements PhabricatorPolicyInterface, PhabricatorMarkupInterface { + + const MARKUP_FIELD_BODY = 'markup:body'; const VISIBILITY_DRAFT = 0; const VISIBILITY_PUBLISHED = 1; @@ -174,4 +177,35 @@ final class PhamePost extends PhameDAO implements PhabricatorPolicyInterface { } } + +/* -( PhabricatorMarkupInterface Implementation )-------------------------- */ + + + public function getMarkupFieldKey($field) { + return $this->getPHID().':'.$field; + } + + + public function newMarkupEngine($field) { + return PhabricatorMarkupEngine::newPhameMarkupEngine(); + } + + + public function getMarkupText($field) { + return $this->getBody(); + } + + + public function didMarkupText( + $field, + $output, + PhutilMarkupEngine $engine) { + return $output; + } + + + public function shouldUseMarkupCache($field) { + return (bool)$this->getPHID(); + } + }