diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index b6d48f60fc..ac2fa8cdf1 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3319,6 +3319,7 @@ phutil_register_library_map(array( 'PhameController' => 'applications/phame/controller/PhameController.php', 'PhameCreatePostConduitAPIMethod' => 'applications/phame/conduit/PhameCreatePostConduitAPIMethod.php', 'PhameDAO' => 'applications/phame/storage/PhameDAO.php', + 'PhameDescriptionView' => 'applications/phame/view/PhameDescriptionView.php', 'PhameHomeController' => 'applications/phame/controller/PhameHomeController.php', 'PhamePost' => 'applications/phame/storage/PhamePost.php', 'PhamePostCommentController' => 'applications/phame/controller/post/PhamePostCommentController.php', @@ -7649,6 +7650,7 @@ phutil_register_library_map(array( 'PhameController' => 'PhabricatorController', 'PhameCreatePostConduitAPIMethod' => 'PhameConduitAPIMethod', 'PhameDAO' => 'PhabricatorLiskDAO', + 'PhameDescriptionView' => 'AphrontTagView', 'PhameHomeController' => 'PhamePostController', 'PhamePost' => array( 'PhameDAO', diff --git a/src/applications/phame/controller/blog/PhameBlogViewController.php b/src/applications/phame/controller/blog/PhameBlogViewController.php index 7ac5c08f73..5d6326b5d3 100644 --- a/src/applications/phame/controller/blog/PhameBlogViewController.php +++ b/src/applications/phame/controller/blog/PhameBlogViewController.php @@ -73,24 +73,7 @@ final class PhameBlogViewController extends PhameBlogController { ->setHeader($header) ->appendChild($post_list); - $description = $this->renderDescription($blog, $viewer); - - return $this->newPage() - ->setTitle($blog->getName()) - ->setCrumbs($crumbs) - ->appendChild( - array( - $page, - $description, - )); - } - - private function renderDescription( - PhameBlog $blog, - PhabricatorUser $viewer) { - - require_celerity_resource('phame-css'); - + $description = null; if (strlen($blog->getDescription())) { $description = PhabricatorMarkupEngine::renderOneObject( id(new PhabricatorMarkupOneOff())->setContent($blog->getDescription()), @@ -100,36 +83,19 @@ final class PhameBlogViewController extends PhameBlogController { $description = phutil_tag('em', array(), pht('No description.')); } - $picture = $blog->getProfileImageURI(); - $description = phutil_tag_div( - 'phame-blog-description-content', $description); + $about = id(new PhameDescriptionView()) + ->setTitle($blog->getName()) + ->setDescription($description) + ->setImage($blog->getProfileImageURI()); - $image = phutil_tag( - 'div', - array( - 'class' => 'phame-blog-description-image', - 'style' => 'background-image: url('.$picture.');', + return $this->newPage() + ->setTitle($blog->getName()) + ->setCrumbs($crumbs) + ->appendChild( + array( + $page, + $about, )); - - $header = phutil_tag( - 'div', - array( - 'class' => 'phame-blog-description-name', - ), - pht('About %s', $blog->getName())); - - $view = phutil_tag( - 'div', - array( - 'class' => 'phame-blog-description', - ), - array( - $image, - $header, - $description, - )); - - return $view; } private function renderActions(PhameBlog $blog, PhabricatorUser $viewer) { diff --git a/src/applications/phame/view/PhameDescriptionView.php b/src/applications/phame/view/PhameDescriptionView.php new file mode 100644 index 0000000000..b8c8126918 --- /dev/null +++ b/src/applications/phame/view/PhameDescriptionView.php @@ -0,0 +1,60 @@ +title = $title; + return $this; + } + + public function setDescription($description) { + $this->description = $description; + return $this; + } + + public function setImage($image) { + $this->image = $image; + return $this; + } + + public function setImageHref($href) { + $this->imageHref = $href; + return $this; + } + + protected function getTagAttributes() { + $classes = array(); + $classes[] = 'phame-blog-description'; + return array('class' => implode(' ', $classes)); + } + + protected function getTagContent() { + require_celerity_resource('phame-css'); + + $description = phutil_tag_div( + 'phame-blog-description-content', $this->description); + + $image = phutil_tag( + ($this->imageHref) ? 'a' : 'div', + array( + 'class' => 'phame-blog-description-image', + 'style' => 'background-image: url('.$this->image.');', + 'href' => $this->imageHref, + )); + + $header = phutil_tag( + 'div', + array( + 'class' => 'phame-blog-description-name', + ), + pht('About %s', $this->title)); + + return array($image, $header, $description); + } + +}