diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3319,6 +3319,7 @@ '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 @@ '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 --- a/src/applications/phame/controller/blog/PhameBlogViewController.php +++ b/src/applications/phame/controller/blog/PhameBlogViewController.php @@ -73,24 +73,7 @@ ->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 @@ $description = phutil_tag('em', array(), pht('No description.')); } - $picture = $blog->getProfileImageURI(); - $description = phutil_tag_div( - 'phame-blog-description-content', $description); - - $image = phutil_tag( - 'div', - array( - 'class' => 'phame-blog-description-image', - 'style' => 'background-image: url('.$picture.');', - )); + $about = id(new PhameDescriptionView()) + ->setTitle($blog->getName()) + ->setDescription($description) + ->setImage($blog->getProfileImageURI()); - $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 $this->newPage() + ->setTitle($blog->getName()) + ->setCrumbs($crumbs) + ->appendChild( + array( + $page, + $about, )); - - 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 --- /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); + } + +}