1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-17 10:11:10 +01:00

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
This commit is contained in:
Chad Little 2013-04-14 08:02:29 -07:00
parent 1b4f03b5a8
commit 8ea5c8c74e
12 changed files with 149 additions and 70 deletions

View file

@ -2980,7 +2980,7 @@ celerity_register_resource_map(array(
), ),
'phabricator-feed-css' => 'phabricator-feed-css' =>
array( array(
'uri' => '/res/52015916/rsrc/css/application/feed/feed.css', 'uri' => '/res/bb92244a/rsrc/css/application/feed/feed.css',
'type' => 'css', 'type' => 'css',
'requires' => 'requires' =>
array( array(

View file

@ -12,18 +12,18 @@ abstract class PhameController extends PhabricatorController {
$nav = new AphrontSideNavFilterView(); $nav = new AphrontSideNavFilterView();
$nav->setBaseURI($base_uri); $nav->setBaseURI($base_uri);
$nav->addLabel('Create'); $nav->addLabel(pht('Create'));
$nav->addFilter('post/new', 'New Post'); $nav->addFilter('post/new', pht('New Post'));
$nav->addFilter('blog/new', 'New Blog'); $nav->addFilter('blog/new', pht('New Blog'));
$nav->addLabel('Posts'); $nav->addLabel(pht('Posts'));
$nav->addFilter('post/draft', 'My Drafts'); $nav->addFilter('post/draft', pht('My Drafts'));
$nav->addFilter('post', 'My Posts'); $nav->addFilter('post', pht('My Posts'));
$nav->addFilter('post/all', 'All Posts'); $nav->addFilter('post/all', pht('All Posts'));
$nav->addLabel('Blogs'); $nav->addLabel(pht('Blogs'));
$nav->addFilter('blog/user', 'Joinable Blogs'); $nav->addFilter('blog/user', pht('Joinable Blogs'));
$nav->addFilter('blog/all', 'All Blogs'); $nav->addFilter('blog/all', pht('All Blogs'));
$nav->selectFilter(null); $nav->selectFilter(null);
@ -70,10 +70,28 @@ abstract class PhameController extends PhabricatorController {
$desc = pht('Published on %s by %s', $published, $blogger); $desc = pht('Published on %s by %s', $published, $blogger);
} }
$item->addAttribute($desc); $item->addAttribute($desc);
$list->addItem($item); $list->addItem($item);
} }
return $list; 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;
}
} }

View file

@ -38,6 +38,7 @@ final class PhameBlogDeleteController extends PhameController {
$dialog = id(new AphrontDialogView()) $dialog = id(new AphrontDialogView())
->setUser($user) ->setUser($user)
->setTitle(pht('Delete Blog?')) ->setTitle(pht('Delete Blog?'))
->setHeaderColor(PhabricatorActionHeaderView::HEADER_RED)
->appendChild( ->appendChild(
pht( pht(
'Really delete the blog "%s"? It will be gone forever.', 'Really delete the blog "%s"? It will be gone forever.',

View file

@ -56,8 +56,8 @@ final class PhameBlogEditController
$skin = $request->getStr('skin'); $skin = $request->getStr('skin');
if (empty($name)) { if (empty($name)) {
$errors[] = 'You must give the blog a name.'; $errors[] = pht('You must give the blog a name.');
$e_name = 'Required'; $e_name = pht('Required');
} else { } else {
$e_name = null; $e_name = null;
} }
@ -71,7 +71,7 @@ final class PhameBlogEditController
$error = $blog->validateCustomDomain($custom_domain); $error = $blog->validateCustomDomain($custom_domain);
if ($error) { if ($error) {
$errors[] = $error; $errors[] = $error;
$e_custom_domain = 'Invalid'; $e_custom_domain = pht('Invalid');
} }
} }
@ -91,8 +91,8 @@ final class PhameBlogEditController
return id(new AphrontRedirectResponse()) return id(new AphrontRedirectResponse())
->setURI($this->getApplicationURI('blog/view/'.$blog->getID().'/')); ->setURI($this->getApplicationURI('blog/view/'.$blog->getID().'/'));
} catch (AphrontQueryDuplicateKeyException $ex) { } catch (AphrontQueryDuplicateKeyException $ex) {
$errors[] = 'Domain must be unique.'; $errors[] = pht('Domain must be unique.');
$e_custom_domain = 'Not Unique'; $e_custom_domain = pht('Not Unique');
} }
} }
} }
@ -110,14 +110,14 @@ final class PhameBlogEditController
->setFlexible(true) ->setFlexible(true)
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setLabel('Name') ->setLabel(pht('Name'))
->setName('name') ->setName('name')
->setValue($blog->getName()) ->setValue($blog->getName())
->setID('blog-name') ->setID('blog-name')
->setError($e_name)) ->setError($e_name))
->appendChild( ->appendChild(
id(new PhabricatorRemarkupControl()) id(new PhabricatorRemarkupControl())
->setLabel('Description') ->setLabel(pht('Description'))
->setName('description') ->setName('description')
->setValue($blog->getDescription()) ->setValue($blog->getDescription())
->setID('blog-description') ->setID('blog-description')
@ -146,14 +146,15 @@ final class PhameBlogEditController
->setName('can_join')) ->setName('can_join'))
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setLabel('Custom Domain') ->setLabel(pht('Custom Domain'))
->setName('custom_domain') ->setName('custom_domain')
->setValue($blog->getDomain()) ->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)) ->setError($e_custom_domain))
->appendChild( ->appendChild(
id(new AphrontFormSelectControl()) id(new AphrontFormSelectControl())
->setLabel('Skin') ->setLabel(pht('Skin'))
->setName('skin') ->setName('skin')
->setValue($blog->getSkin()) ->setValue($blog->getSkin())
->setOptions($skins)) ->setOptions($skins))
@ -164,7 +165,7 @@ final class PhameBlogEditController
if ($errors) { if ($errors) {
$error_view = id(new AphrontErrorView()) $error_view = id(new AphrontErrorView())
->setTitle('Form Errors') ->setTitle(pht('Form Errors'))
->setErrors($errors); ->setErrors($errors);
} else { } else {
$error_view = null; $error_view = null;
@ -173,10 +174,17 @@ final class PhameBlogEditController
$header = id(new PhabricatorHeaderView()) $header = id(new PhabricatorHeaderView())
->setHeader($page_title); ->setHeader($page_title);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setName($page_title)
->setHref($this->getApplicationURI('blog/new')));
$nav = $this->renderSideNavFilterView(); $nav = $this->renderSideNavFilterView();
$nav->selectFilter($this->id ? null : 'blog/new'); $nav->selectFilter($this->id ? null : 'blog/new');
$nav->appendChild( $nav->appendChild(
array( array(
$crumbs,
$header, $header,
$error_view, $error_view,
$form, $form,
@ -185,7 +193,9 @@ final class PhameBlogEditController
return $this->buildApplicationPage( return $this->buildApplicationPage(
$nav, $nav,
array( array(
'title' => $page_title, 'title' => $page_title,
'device' => true,
'dust' => true,
)); ));
} }
} }

View file

@ -44,23 +44,27 @@ final class PhameBlogListController extends PhameController {
$blogs = $query->executeWithOffsetPager($pager); $blogs = $query->executeWithOffsetPager($pager);
$header = id(new PhabricatorHeaderView())
->setHeader($title);
$blog_list = $this->renderBlogList($blogs, $user, $nodata); $blog_list = $this->renderBlogList($blogs, $user, $nodata);
$blog_list->setPager($pager); $blog_list->setPager($pager);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setName($title)
->setHref($this->getApplicationURI()));
$nav->appendChild( $nav->appendChild(
array( array(
$header, $crumbs,
$blog_list, $blog_list,
)); ));
return $this->buildApplicationPage( return $this->buildApplicationPage(
$nav, $nav,
array( array(
'title' => $title, 'title' => $title,
'device' => true, 'device' => true,
'dust' => true,
)); ));
} }

View file

@ -48,8 +48,15 @@ final class PhameBlogViewController extends PhameController {
$user, $user,
pht('This blog has no visible posts.')); pht('This blog has no visible posts.'));
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setName($blog->getName())
->setHref($this->getApplicationURI()));
$nav->appendChild( $nav->appendChild(
array( array(
$crumbs,
$header, $header,
$actions, $actions,
$properties, $properties,
@ -59,8 +66,9 @@ final class PhameBlogViewController extends PhameController {
return $this->buildApplicationPage( return $this->buildApplicationPage(
$nav, $nav,
array( array(
'device' => true, 'device' => true,
'title' => $blog->getName(), 'title' => $blog->getName(),
'dust' => true,
)); ));
} }

View file

@ -38,6 +38,7 @@ final class PhamePostDeleteController extends PhameController {
$dialog = id(new AphrontDialogView()) $dialog = id(new AphrontDialogView())
->setUser($user) ->setUser($user)
->setTitle(pht('Delete Post?')) ->setTitle(pht('Delete Post?'))
->setHeaderColor(PhabricatorActionHeaderView::HEADER_RED)
->appendChild( ->appendChild(
pht( pht(
'Really delete the post "%s"? It will be gone forever.', 'Really delete the post "%s"? It will be gone forever.',

View file

@ -69,13 +69,13 @@ final class PhamePostEditController
$post->setConfigData($data); $post->setConfigData($data);
if ($phame_title == '/') { if ($phame_title == '/') {
$errors[] = 'Phame title must be nonempty.'; $errors[] = pht('Phame title must be nonempty.');
$e_phame_title = 'Required'; $e_phame_title = pht('Required');
} }
if (!strlen($title)) { if (!strlen($title)) {
$errors[] = 'Title must be nonempty.'; $errors[] = pht('Title must be nonempty.');
$e_title = 'Required'; $e_title = pht('Required');
} else { } else {
$e_title = null; $e_title = null;
} }
@ -87,9 +87,9 @@ final class PhamePostEditController
$uri = $this->getApplicationURI('/post/view/'.$post->getID().'/'); $uri = $this->getApplicationURI('/post/view/'.$post->getID().'/');
return id(new AphrontRedirectResponse())->setURI($uri); return id(new AphrontRedirectResponse())->setURI($uri);
} catch (AphrontQueryDuplicateKeyException $e) { } catch (AphrontQueryDuplicateKeyException $e) {
$e_phame_title = 'Not Unique'; $e_phame_title = pht('Not Unique');
$errors[] = 'Another post already uses this slug. '. $errors[] = pht('Another post already uses this slug. '.
'Each post must have a unique slug.'; 'Each post must have a unique slug.');
} }
} }
} }
@ -104,28 +104,28 @@ final class PhamePostEditController
->addHiddenInput('blog', $request->getInt('blog')) ->addHiddenInput('blog', $request->getInt('blog'))
->appendChild( ->appendChild(
id(new AphrontFormMarkupControl()) id(new AphrontFormMarkupControl())
->setLabel('Blog') ->setLabel(pht('Blog'))
->setValue($handle->renderLink())) ->setValue($handle->renderLink()))
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setLabel('Title') ->setLabel(pht('Title'))
->setName('title') ->setName('title')
->setValue($post->getTitle()) ->setValue($post->getTitle())
->setID('post-title') ->setID('post-title')
->setError($e_title)) ->setError($e_title))
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setLabel('Phame Title') ->setLabel(pht('Phame Title'))
->setName('phame_title') ->setName('phame_title')
->setValue(rtrim($post->getPhameTitle(), '/')) ->setValue(rtrim($post->getPhameTitle(), '/'))
->setID('post-phame-title') ->setID('post-phame-title')
->setCaption('Up to 64 alphanumeric characters '. ->setCaption(pht('Up to 64 alphanumeric characters '.
'with underscores for spaces. '. 'with underscores for spaces. '.
'Formatting is enforced.') 'Formatting is enforced.'))
->setError($e_phame_title)) ->setError($e_phame_title))
->appendChild( ->appendChild(
id(new PhabricatorRemarkupControl()) id(new PhabricatorRemarkupControl())
->setLabel('Body') ->setLabel(pht('Body'))
->setName('body') ->setName('body')
->setValue($post->getBody()) ->setValue($post->getBody())
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
@ -134,7 +134,7 @@ final class PhamePostEditController
->setDisableMacros(true)) ->setDisableMacros(true))
->appendChild( ->appendChild(
id(new AphrontFormSelectControl()) id(new AphrontFormSelectControl())
->setLabel('Comments Widget') ->setLabel(pht('Comments Widget'))
->setName('comments_widget') ->setName('comments_widget')
->setvalue($post->getCommentsWidget()) ->setvalue($post->getCommentsWidget())
->setOptions($post->getCommentsWidgetOptionsForSelect())) ->setOptions($post->getCommentsWidgetOptionsForSelect()))
@ -170,15 +170,22 @@ final class PhamePostEditController
if ($errors) { if ($errors) {
$error_view = id(new AphrontErrorView()) $error_view = id(new AphrontErrorView())
->setTitle('Errors saving post.') ->setTitle(pht('Errors saving post.'))
->setErrors($errors); ->setErrors($errors);
} else { } else {
$error_view = null; $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 = $this->renderSideNavFilterView(null);
$nav->appendChild( $nav->appendChild(
array( array(
$crumbs,
$header, $header,
$error_view, $error_view,
$form, $form,
@ -188,8 +195,9 @@ final class PhamePostEditController
return $this->buildApplicationPage( return $this->buildApplicationPage(
$nav, $nav,
array( array(
'title' => $page_title, 'title' => $page_title,
'device' => true, 'device' => true,
'dust' => true,
)); ));
} }

View file

@ -70,14 +70,17 @@ final class PhamePostListController extends PhameController {
mpull($posts, 'getBlogPHID')); mpull($posts, 'getBlogPHID'));
$this->loadHandles($handle_phids); $this->loadHandles($handle_phids);
$header = id(new PhabricatorHeaderView())
->setHeader($title);
$post_list = $this->renderPostList($posts, $user, $nodata); $post_list = $this->renderPostList($posts, $user, $nodata);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setName($title)
->setHref($this->getApplicationURI()));
$nav->appendChild( $nav->appendChild(
array( array(
$header, $crumbs,
$post_list, $post_list,
)); ));
@ -86,6 +89,7 @@ final class PhamePostListController extends PhameController {
array( array(
'title' => $title, 'title' => $title,
'device' => true, 'device' => true,
'dust' => true,
)); ));
} }

View file

@ -54,6 +54,7 @@ final class PhamePostNewController extends PhameController {
$title = pht('Move Post'); $title = pht('Move Post');
} else { } else {
$title = pht('Create Post'); $title = pht('Create Post');
$view_uri = $this->getApplicationURI('/post/new');
} }
$blogs = id(new PhameBlogQuery()) $blogs = id(new PhameBlogQuery())
@ -66,6 +67,14 @@ final class PhamePostNewController extends PhameController {
$nav = $this->renderSideNavFilterView(); $nav = $this->renderSideNavFilterView();
$nav->selectFilter('post/new'); $nav->selectFilter('post/new');
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setName($title)
->setHref($view_uri));
$nav->appendChild($crumbs);
$nav->appendChild( $nav->appendChild(
id(new PhabricatorHeaderView())->setHeader($title)); id(new PhabricatorHeaderView())->setHeader($title));
@ -91,7 +100,7 @@ final class PhamePostNewController extends PhameController {
->setFlexible(true) ->setFlexible(true)
->appendChild( ->appendChild(
id(new AphrontFormSelectControl()) id(new AphrontFormSelectControl())
->setLabel('Blog') ->setLabel(pht('Blog'))
->setName('blog') ->setName('blog')
->setOptions($options) ->setOptions($options)
->setValue($selected_value)); ->setValue($selected_value));
@ -119,6 +128,7 @@ final class PhamePostNewController extends PhameController {
array( array(
'title' => $title, 'title' => $title,
'device' => true, 'device' => true,
'dust' => true,
)); ));
} }
} }

View file

@ -38,7 +38,7 @@ final class PhamePostPublishController extends PhameController {
} }
$header = id(new PhabricatorHeaderView()) $header = id(new PhabricatorHeaderView())
->setHeader('Preview Post'); ->setHeader(pht('Preview Post'));
$form = id(new AphrontFormView()) $form = id(new AphrontFormView())
->setUser($user) ->setUser($user)
@ -50,9 +50,16 @@ final class PhamePostPublishController extends PhameController {
$frame = $this->renderPreviewFrame($post); $frame = $this->renderPreviewFrame($post);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setName(pht('Preview'))
->setHref($view_uri));
$nav = $this->renderSideNavFilterView(null); $nav = $this->renderSideNavFilterView(null);
$nav->appendChild( $nav->appendChild(
array( array(
$crumbs,
$header, $header,
$form, $form,
$frame, $frame,
@ -79,7 +86,7 @@ final class PhamePostPublishController extends PhameController {
'iframe', 'iframe',
array( array(
'style' => 'width: 100%; height: 600px; '. 'style' => 'width: 100%; height: 600px; '.
'border: 1px solid #303030; background: #303030;', 'border: 1px solid #303030;',
'src' => $this->getApplicationURI('/post/framed/'.$post->getID().'/'), 'src' => $this->getApplicationURI('/post/framed/'.$post->getID().'/'),
), ),
'')); ''));

View file

@ -26,6 +26,22 @@ final class PhamePostViewController extends PhameController {
$nav = $this->renderSideNavFilterView(); $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( $nav->appendChild(
id(new PhabricatorHeaderView()) id(new PhabricatorHeaderView())
->setHeader($post->getTitle())); ->setHeader($post->getTitle()));
@ -50,15 +66,6 @@ final class PhamePostViewController extends PhameController {
'been deleted). Use "Move Post" to move it to a new blog.'))); '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( $nav->appendChild(
array( array(
$actions, $actions,
@ -68,8 +75,9 @@ final class PhamePostViewController extends PhameController {
return $this->buildApplicationPage( return $this->buildApplicationPage(
$nav, $nav,
array( array(
'title' => $post->getTitle(), 'title' => $post->getTitle(),
'device' => true, 'device' => true,
'dust' => true,
)); ));
} }
@ -92,7 +100,7 @@ final class PhamePostViewController extends PhameController {
id(new PhabricatorActionView()) id(new PhabricatorActionView())
->setIcon('edit') ->setIcon('edit')
->setHref($this->getApplicationURI('post/edit/'.$id.'/')) ->setHref($this->getApplicationURI('post/edit/'.$id.'/'))
->setName('Edit Post') ->setName(pht('Edit Post'))
->setDisabled(!$can_edit) ->setDisabled(!$can_edit)
->setWorkflow(!$can_edit)); ->setWorkflow(!$can_edit));
@ -100,7 +108,7 @@ final class PhamePostViewController extends PhameController {
id(new PhabricatorActionView()) id(new PhabricatorActionView())
->setIcon('move') ->setIcon('move')
->setHref($this->getApplicationURI('post/move/'.$id.'/')) ->setHref($this->getApplicationURI('post/move/'.$id.'/'))
->setName('Move Post') ->setName(pht('Move Post'))
->setDisabled(!$can_edit) ->setDisabled(!$can_edit)
->setWorkflow(!$can_edit)); ->setWorkflow(!$can_edit));
@ -123,7 +131,7 @@ final class PhamePostViewController extends PhameController {
id(new PhabricatorActionView()) id(new PhabricatorActionView())
->setIcon('delete') ->setIcon('delete')
->setHref($this->getApplicationURI('post/delete/'.$id.'/')) ->setHref($this->getApplicationURI('post/delete/'.$id.'/'))
->setName('Delete Post') ->setName(pht('Delete Post'))
->setDisabled(!$can_edit) ->setDisabled(!$can_edit)
->setWorkflow(true)); ->setWorkflow(true));