From 8ea5c8c74ea25b1599427ba946624761d423fe1c Mon Sep 17 00:00:00 2001 From: Chad Little Date: Sun, 14 Apr 2013 08:02:29 -0700 Subject: [PATCH] Modernize Phame Summary: Adds crumbs, mobile layouts, mobile navs, phts Test Plan: Tested Phame in iOS and Chrome Reviewers: epriestley, btrahan Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D5684 --- src/__celerity_resource_map__.php | 2 +- .../phame/controller/PhameController.php | 40 +++++++++++++----- .../blog/PhameBlogDeleteController.php | 1 + .../blog/PhameBlogEditController.php | 34 +++++++++------ .../blog/PhameBlogListController.php | 16 ++++--- .../blog/PhameBlogViewController.php | 12 +++++- .../post/PhamePostDeleteController.php | 1 + .../post/PhamePostEditController.php | 42 +++++++++++-------- .../post/PhamePostListController.php | 12 ++++-- .../post/PhamePostNewController.php | 12 +++++- .../post/PhamePostPublishController.php | 11 ++++- .../post/PhamePostViewController.php | 36 +++++++++------- 12 files changed, 149 insertions(+), 70 deletions(-) diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index 6905bb027f..57b94f4ddf 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -2980,7 +2980,7 @@ celerity_register_resource_map(array( ), 'phabricator-feed-css' => array( - 'uri' => '/res/52015916/rsrc/css/application/feed/feed.css', + 'uri' => '/res/bb92244a/rsrc/css/application/feed/feed.css', 'type' => 'css', 'requires' => array( diff --git a/src/applications/phame/controller/PhameController.php b/src/applications/phame/controller/PhameController.php index 2c6685a500..002f987a11 100644 --- a/src/applications/phame/controller/PhameController.php +++ b/src/applications/phame/controller/PhameController.php @@ -12,18 +12,18 @@ abstract class PhameController extends PhabricatorController { $nav = new AphrontSideNavFilterView(); $nav->setBaseURI($base_uri); - $nav->addLabel('Create'); - $nav->addFilter('post/new', 'New Post'); - $nav->addFilter('blog/new', 'New Blog'); + $nav->addLabel(pht('Create')); + $nav->addFilter('post/new', pht('New Post')); + $nav->addFilter('blog/new', pht('New Blog')); - $nav->addLabel('Posts'); - $nav->addFilter('post/draft', 'My Drafts'); - $nav->addFilter('post', 'My Posts'); - $nav->addFilter('post/all', 'All Posts'); + $nav->addLabel(pht('Posts')); + $nav->addFilter('post/draft', pht('My Drafts')); + $nav->addFilter('post', pht('My Posts')); + $nav->addFilter('post/all', pht('All Posts')); - $nav->addLabel('Blogs'); - $nav->addFilter('blog/user', 'Joinable Blogs'); - $nav->addFilter('blog/all', 'All Blogs'); + $nav->addLabel(pht('Blogs')); + $nav->addFilter('blog/user', pht('Joinable Blogs')); + $nav->addFilter('blog/all', pht('All Blogs')); $nav->selectFilter(null); @@ -70,10 +70,28 @@ abstract class PhameController extends PhabricatorController { $desc = pht('Published on %s by %s', $published, $blogger); } $item->addAttribute($desc); - $list->addItem($item); } return $list; } + + public function buildApplicationMenu() { + return $this->renderSideNavFilterView()->getMenu(); + } + + protected function buildApplicationCrumbs() { + $crumbs = parent::buildApplicationCrumbs(); + $crumbs->addAction( + id(new PhabricatorMenuItemView()) + ->setName(pht('New Blog')) + ->setHref($this->getApplicationURI('/blog/new')) + ->setIcon('create')); + $crumbs->addAction( + id(new PhabricatorMenuItemView()) + ->setName(pht('New Post')) + ->setHref($this->getApplicationURI('/post/new')) + ->setIcon('new')); + return $crumbs; + } } diff --git a/src/applications/phame/controller/blog/PhameBlogDeleteController.php b/src/applications/phame/controller/blog/PhameBlogDeleteController.php index e6d9b4dff6..4290681085 100644 --- a/src/applications/phame/controller/blog/PhameBlogDeleteController.php +++ b/src/applications/phame/controller/blog/PhameBlogDeleteController.php @@ -38,6 +38,7 @@ final class PhameBlogDeleteController extends PhameController { $dialog = id(new AphrontDialogView()) ->setUser($user) ->setTitle(pht('Delete Blog?')) + ->setHeaderColor(PhabricatorActionHeaderView::HEADER_RED) ->appendChild( pht( 'Really delete the blog "%s"? It will be gone forever.', diff --git a/src/applications/phame/controller/blog/PhameBlogEditController.php b/src/applications/phame/controller/blog/PhameBlogEditController.php index 42e34e0a02..987ffe63e0 100644 --- a/src/applications/phame/controller/blog/PhameBlogEditController.php +++ b/src/applications/phame/controller/blog/PhameBlogEditController.php @@ -56,8 +56,8 @@ final class PhameBlogEditController $skin = $request->getStr('skin'); if (empty($name)) { - $errors[] = 'You must give the blog a name.'; - $e_name = 'Required'; + $errors[] = pht('You must give the blog a name.'); + $e_name = pht('Required'); } else { $e_name = null; } @@ -71,7 +71,7 @@ final class PhameBlogEditController $error = $blog->validateCustomDomain($custom_domain); if ($error) { $errors[] = $error; - $e_custom_domain = 'Invalid'; + $e_custom_domain = pht('Invalid'); } } @@ -91,8 +91,8 @@ final class PhameBlogEditController return id(new AphrontRedirectResponse()) ->setURI($this->getApplicationURI('blog/view/'.$blog->getID().'/')); } catch (AphrontQueryDuplicateKeyException $ex) { - $errors[] = 'Domain must be unique.'; - $e_custom_domain = 'Not Unique'; + $errors[] = pht('Domain must be unique.'); + $e_custom_domain = pht('Not Unique'); } } } @@ -110,14 +110,14 @@ final class PhameBlogEditController ->setFlexible(true) ->appendChild( id(new AphrontFormTextControl()) - ->setLabel('Name') + ->setLabel(pht('Name')) ->setName('name') ->setValue($blog->getName()) ->setID('blog-name') ->setError($e_name)) ->appendChild( id(new PhabricatorRemarkupControl()) - ->setLabel('Description') + ->setLabel(pht('Description')) ->setName('description') ->setValue($blog->getDescription()) ->setID('blog-description') @@ -146,14 +146,15 @@ final class PhameBlogEditController ->setName('can_join')) ->appendChild( id(new AphrontFormTextControl()) - ->setLabel('Custom Domain') + ->setLabel(pht('Custom Domain')) ->setName('custom_domain') ->setValue($blog->getDomain()) - ->setCaption('Must include at least one dot (.), e.g. blog.example.com') + ->setCaption( + pht('Must include at least one dot (.), e.g. blog.example.com')) ->setError($e_custom_domain)) ->appendChild( id(new AphrontFormSelectControl()) - ->setLabel('Skin') + ->setLabel(pht('Skin')) ->setName('skin') ->setValue($blog->getSkin()) ->setOptions($skins)) @@ -164,7 +165,7 @@ final class PhameBlogEditController if ($errors) { $error_view = id(new AphrontErrorView()) - ->setTitle('Form Errors') + ->setTitle(pht('Form Errors')) ->setErrors($errors); } else { $error_view = null; @@ -173,10 +174,17 @@ final class PhameBlogEditController $header = id(new PhabricatorHeaderView()) ->setHeader($page_title); + $crumbs = $this->buildApplicationCrumbs(); + $crumbs->addCrumb( + id(new PhabricatorCrumbView()) + ->setName($page_title) + ->setHref($this->getApplicationURI('blog/new'))); + $nav = $this->renderSideNavFilterView(); $nav->selectFilter($this->id ? null : 'blog/new'); $nav->appendChild( array( + $crumbs, $header, $error_view, $form, @@ -185,7 +193,9 @@ final class PhameBlogEditController return $this->buildApplicationPage( $nav, array( - 'title' => $page_title, + 'title' => $page_title, + 'device' => true, + 'dust' => true, )); } } diff --git a/src/applications/phame/controller/blog/PhameBlogListController.php b/src/applications/phame/controller/blog/PhameBlogListController.php index 21a00d6c35..4a1f5b7da8 100644 --- a/src/applications/phame/controller/blog/PhameBlogListController.php +++ b/src/applications/phame/controller/blog/PhameBlogListController.php @@ -44,23 +44,27 @@ final class PhameBlogListController extends PhameController { $blogs = $query->executeWithOffsetPager($pager); - $header = id(new PhabricatorHeaderView()) - ->setHeader($title); - $blog_list = $this->renderBlogList($blogs, $user, $nodata); $blog_list->setPager($pager); + $crumbs = $this->buildApplicationCrumbs(); + $crumbs->addCrumb( + id(new PhabricatorCrumbView()) + ->setName($title) + ->setHref($this->getApplicationURI())); + $nav->appendChild( array( - $header, + $crumbs, $blog_list, )); return $this->buildApplicationPage( $nav, array( - 'title' => $title, - 'device' => true, + 'title' => $title, + 'device' => true, + 'dust' => true, )); } diff --git a/src/applications/phame/controller/blog/PhameBlogViewController.php b/src/applications/phame/controller/blog/PhameBlogViewController.php index c6afaaf676..a7bac16ccb 100644 --- a/src/applications/phame/controller/blog/PhameBlogViewController.php +++ b/src/applications/phame/controller/blog/PhameBlogViewController.php @@ -48,8 +48,15 @@ final class PhameBlogViewController extends PhameController { $user, pht('This blog has no visible posts.')); + $crumbs = $this->buildApplicationCrumbs(); + $crumbs->addCrumb( + id(new PhabricatorCrumbView()) + ->setName($blog->getName()) + ->setHref($this->getApplicationURI())); + $nav->appendChild( array( + $crumbs, $header, $actions, $properties, @@ -59,8 +66,9 @@ final class PhameBlogViewController extends PhameController { return $this->buildApplicationPage( $nav, array( - 'device' => true, - 'title' => $blog->getName(), + 'device' => true, + 'title' => $blog->getName(), + 'dust' => true, )); } diff --git a/src/applications/phame/controller/post/PhamePostDeleteController.php b/src/applications/phame/controller/post/PhamePostDeleteController.php index 8faa715a5e..6baa5fe8e1 100644 --- a/src/applications/phame/controller/post/PhamePostDeleteController.php +++ b/src/applications/phame/controller/post/PhamePostDeleteController.php @@ -38,6 +38,7 @@ final class PhamePostDeleteController extends PhameController { $dialog = id(new AphrontDialogView()) ->setUser($user) ->setTitle(pht('Delete Post?')) + ->setHeaderColor(PhabricatorActionHeaderView::HEADER_RED) ->appendChild( pht( 'Really delete the post "%s"? It will be gone forever.', diff --git a/src/applications/phame/controller/post/PhamePostEditController.php b/src/applications/phame/controller/post/PhamePostEditController.php index deb1b4a548..eddc903604 100644 --- a/src/applications/phame/controller/post/PhamePostEditController.php +++ b/src/applications/phame/controller/post/PhamePostEditController.php @@ -69,13 +69,13 @@ final class PhamePostEditController $post->setConfigData($data); if ($phame_title == '/') { - $errors[] = 'Phame title must be nonempty.'; - $e_phame_title = 'Required'; + $errors[] = pht('Phame title must be nonempty.'); + $e_phame_title = pht('Required'); } if (!strlen($title)) { - $errors[] = 'Title must be nonempty.'; - $e_title = 'Required'; + $errors[] = pht('Title must be nonempty.'); + $e_title = pht('Required'); } else { $e_title = null; } @@ -87,9 +87,9 @@ final class PhamePostEditController $uri = $this->getApplicationURI('/post/view/'.$post->getID().'/'); return id(new AphrontRedirectResponse())->setURI($uri); } catch (AphrontQueryDuplicateKeyException $e) { - $e_phame_title = 'Not Unique'; - $errors[] = 'Another post already uses this slug. '. - 'Each post must have a unique slug.'; + $e_phame_title = pht('Not Unique'); + $errors[] = pht('Another post already uses this slug. '. + 'Each post must have a unique slug.'); } } } @@ -104,28 +104,28 @@ final class PhamePostEditController ->addHiddenInput('blog', $request->getInt('blog')) ->appendChild( id(new AphrontFormMarkupControl()) - ->setLabel('Blog') + ->setLabel(pht('Blog')) ->setValue($handle->renderLink())) ->appendChild( id(new AphrontFormTextControl()) - ->setLabel('Title') + ->setLabel(pht('Title')) ->setName('title') ->setValue($post->getTitle()) ->setID('post-title') ->setError($e_title)) ->appendChild( id(new AphrontFormTextControl()) - ->setLabel('Phame Title') + ->setLabel(pht('Phame Title')) ->setName('phame_title') ->setValue(rtrim($post->getPhameTitle(), '/')) ->setID('post-phame-title') - ->setCaption('Up to 64 alphanumeric characters '. + ->setCaption(pht('Up to 64 alphanumeric characters '. 'with underscores for spaces. '. - 'Formatting is enforced.') + 'Formatting is enforced.')) ->setError($e_phame_title)) ->appendChild( id(new PhabricatorRemarkupControl()) - ->setLabel('Body') + ->setLabel(pht('Body')) ->setName('body') ->setValue($post->getBody()) ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) @@ -134,7 +134,7 @@ final class PhamePostEditController ->setDisableMacros(true)) ->appendChild( id(new AphrontFormSelectControl()) - ->setLabel('Comments Widget') + ->setLabel(pht('Comments Widget')) ->setName('comments_widget') ->setvalue($post->getCommentsWidget()) ->setOptions($post->getCommentsWidgetOptionsForSelect())) @@ -170,15 +170,22 @@ final class PhamePostEditController if ($errors) { $error_view = id(new AphrontErrorView()) - ->setTitle('Errors saving post.') + ->setTitle(pht('Errors saving post.')) ->setErrors($errors); } else { $error_view = null; } + $crumbs = $this->buildApplicationCrumbs(); + $crumbs->addCrumb( + id(new PhabricatorCrumbView()) + ->setName($page_title) + ->setHref($this->getApplicationURI('/post/view/'.$this->id.'/'))); + $nav = $this->renderSideNavFilterView(null); $nav->appendChild( array( + $crumbs, $header, $error_view, $form, @@ -188,8 +195,9 @@ final class PhamePostEditController return $this->buildApplicationPage( $nav, array( - 'title' => $page_title, - 'device' => true, + 'title' => $page_title, + 'device' => true, + 'dust' => true, )); } diff --git a/src/applications/phame/controller/post/PhamePostListController.php b/src/applications/phame/controller/post/PhamePostListController.php index 0d2d3e9f7b..4fda6ca5f2 100644 --- a/src/applications/phame/controller/post/PhamePostListController.php +++ b/src/applications/phame/controller/post/PhamePostListController.php @@ -70,14 +70,17 @@ final class PhamePostListController extends PhameController { mpull($posts, 'getBlogPHID')); $this->loadHandles($handle_phids); - - $header = id(new PhabricatorHeaderView()) - ->setHeader($title); $post_list = $this->renderPostList($posts, $user, $nodata); + $crumbs = $this->buildApplicationCrumbs(); + $crumbs->addCrumb( + id(new PhabricatorCrumbView()) + ->setName($title) + ->setHref($this->getApplicationURI())); + $nav->appendChild( array( - $header, + $crumbs, $post_list, )); @@ -86,6 +89,7 @@ final class PhamePostListController extends PhameController { array( 'title' => $title, 'device' => true, + 'dust' => true, )); } diff --git a/src/applications/phame/controller/post/PhamePostNewController.php b/src/applications/phame/controller/post/PhamePostNewController.php index 592fcf7674..1d43448748 100644 --- a/src/applications/phame/controller/post/PhamePostNewController.php +++ b/src/applications/phame/controller/post/PhamePostNewController.php @@ -54,6 +54,7 @@ final class PhamePostNewController extends PhameController { $title = pht('Move Post'); } else { $title = pht('Create Post'); + $view_uri = $this->getApplicationURI('/post/new'); } $blogs = id(new PhameBlogQuery()) @@ -66,6 +67,14 @@ final class PhamePostNewController extends PhameController { $nav = $this->renderSideNavFilterView(); $nav->selectFilter('post/new'); + + $crumbs = $this->buildApplicationCrumbs(); + $crumbs->addCrumb( + id(new PhabricatorCrumbView()) + ->setName($title) + ->setHref($view_uri)); + $nav->appendChild($crumbs); + $nav->appendChild( id(new PhabricatorHeaderView())->setHeader($title)); @@ -91,7 +100,7 @@ final class PhamePostNewController extends PhameController { ->setFlexible(true) ->appendChild( id(new AphrontFormSelectControl()) - ->setLabel('Blog') + ->setLabel(pht('Blog')) ->setName('blog') ->setOptions($options) ->setValue($selected_value)); @@ -119,6 +128,7 @@ final class PhamePostNewController extends PhameController { array( 'title' => $title, 'device' => true, + 'dust' => true, )); } } diff --git a/src/applications/phame/controller/post/PhamePostPublishController.php b/src/applications/phame/controller/post/PhamePostPublishController.php index 2a456fe394..dc657e3b75 100644 --- a/src/applications/phame/controller/post/PhamePostPublishController.php +++ b/src/applications/phame/controller/post/PhamePostPublishController.php @@ -38,7 +38,7 @@ final class PhamePostPublishController extends PhameController { } $header = id(new PhabricatorHeaderView()) - ->setHeader('Preview Post'); + ->setHeader(pht('Preview Post')); $form = id(new AphrontFormView()) ->setUser($user) @@ -50,9 +50,16 @@ final class PhamePostPublishController extends PhameController { $frame = $this->renderPreviewFrame($post); + $crumbs = $this->buildApplicationCrumbs(); + $crumbs->addCrumb( + id(new PhabricatorCrumbView()) + ->setName(pht('Preview')) + ->setHref($view_uri)); + $nav = $this->renderSideNavFilterView(null); $nav->appendChild( array( + $crumbs, $header, $form, $frame, @@ -79,7 +86,7 @@ final class PhamePostPublishController extends PhameController { 'iframe', array( 'style' => 'width: 100%; height: 600px; '. - 'border: 1px solid #303030; background: #303030;', + 'border: 1px solid #303030;', 'src' => $this->getApplicationURI('/post/framed/'.$post->getID().'/'), ), '')); diff --git a/src/applications/phame/controller/post/PhamePostViewController.php b/src/applications/phame/controller/post/PhamePostViewController.php index d7edfeb172..e39176955a 100644 --- a/src/applications/phame/controller/post/PhamePostViewController.php +++ b/src/applications/phame/controller/post/PhamePostViewController.php @@ -26,6 +26,22 @@ final class PhamePostViewController extends PhameController { $nav = $this->renderSideNavFilterView(); + $this->loadHandles( + array( + $post->getBlogPHID(), + $post->getBloggerPHID(), + )); + $actions = $this->renderActions($post, $user); + $properties = $this->renderProperties($post, $user); + + $crumbs = $this->buildApplicationCrumbs(); + $crumbs->setActionList($actions); + $crumbs->addCrumb( + id(new PhabricatorCrumbView()) + ->setName($post->getTitle()) + ->setHref($this->getApplicationURI('post/view/'.$post->getID().'/'))); + + $nav->appendChild($crumbs); $nav->appendChild( id(new PhabricatorHeaderView()) ->setHeader($post->getTitle())); @@ -50,15 +66,6 @@ final class PhamePostViewController extends PhameController { 'been deleted). Use "Move Post" to move it to a new blog.'))); } - $this->loadHandles( - array( - $post->getBlogPHID(), - $post->getBloggerPHID(), - )); - - $actions = $this->renderActions($post, $user); - $properties = $this->renderProperties($post, $user); - $nav->appendChild( array( $actions, @@ -68,8 +75,9 @@ final class PhamePostViewController extends PhameController { return $this->buildApplicationPage( $nav, array( - 'title' => $post->getTitle(), - 'device' => true, + 'title' => $post->getTitle(), + 'device' => true, + 'dust' => true, )); } @@ -92,7 +100,7 @@ final class PhamePostViewController extends PhameController { id(new PhabricatorActionView()) ->setIcon('edit') ->setHref($this->getApplicationURI('post/edit/'.$id.'/')) - ->setName('Edit Post') + ->setName(pht('Edit Post')) ->setDisabled(!$can_edit) ->setWorkflow(!$can_edit)); @@ -100,7 +108,7 @@ final class PhamePostViewController extends PhameController { id(new PhabricatorActionView()) ->setIcon('move') ->setHref($this->getApplicationURI('post/move/'.$id.'/')) - ->setName('Move Post') + ->setName(pht('Move Post')) ->setDisabled(!$can_edit) ->setWorkflow(!$can_edit)); @@ -123,7 +131,7 @@ final class PhamePostViewController extends PhameController { id(new PhabricatorActionView()) ->setIcon('delete') ->setHref($this->getApplicationURI('post/delete/'.$id.'/')) - ->setName('Delete Post') + ->setName(pht('Delete Post')) ->setDisabled(!$can_edit) ->setWorkflow(true));