From 5f02ed5bbb7d4b651017307e6c2cfcb742a7e8e9 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Wed, 30 Apr 2014 13:19:14 -0700 Subject: [PATCH] Phame - add some application polish. Summary: Fixes T4880. More specifically - adds an "edit" pencil to post lists iff you can edit the post - style change so this has no text-decoration - adds a "no data" box if you have no posts in a given view - style change to crush some margins so it formats like posts do - adds some validation that your configuration is correct if you are specifying a custom domain - updates docs about custom domains Test Plan: clicked around and it was better! (see screenshots) read doc changes carefully Reviewers: epriestley, chad Reviewed By: epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T4880 Differential Revision: https://secure.phabricator.com/D8918 --- resources/celerity/map.php | 4 +- .../phame/controller/PhameController.php | 25 ++++++-- .../blog/PhameBlogEditController.php | 30 ++++++---- src/applications/phame/storage/PhameBlog.php | 60 ++++++++++++------- src/applications/phame/storage/PhamePost.php | 7 ++- src/docs/user/userguide/phame.diviner | 16 +++-- webroot/rsrc/css/application/phame/phame.css | 8 +++ 7 files changed, 102 insertions(+), 48 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 14bde7b596..6e61315fca 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -79,7 +79,7 @@ return array( 'rsrc/css/application/owners/owners-path-editor.css' => '2f00933b', 'rsrc/css/application/paste/paste.css' => 'aa1767d1', 'rsrc/css/application/people/people-profile.css' => 'ba7b2762', - 'rsrc/css/application/phame/phame.css' => '450826e1', + 'rsrc/css/application/phame/phame.css' => '19ecc703', 'rsrc/css/application/pholio/pholio-edit.css' => 'b9e59b6d', 'rsrc/css/application/pholio/pholio-inline-comments.css' => '52be33f0', 'rsrc/css/application/pholio/pholio.css' => '2fa97dbe', @@ -734,7 +734,7 @@ return array( 'phabricator-uiexample-reactor-sendclass' => 'bf97561d', 'phabricator-uiexample-reactor-sendproperties' => '551add57', 'phabricator-zindex-css' => '0d89d53c', - 'phame-css' => '450826e1', + 'phame-css' => '19ecc703', 'pholio-css' => '2fa97dbe', 'pholio-edit-css' => 'b9e59b6d', 'pholio-inline-comments-css' => '52be33f0', diff --git a/src/applications/phame/controller/PhameController.php b/src/applications/phame/controller/PhameController.php index 231557a7e7..71fd3e9738 100644 --- a/src/applications/phame/controller/PhameController.php +++ b/src/applications/phame/controller/PhameController.php @@ -1,8 +1,5 @@ setImage($bloggerImage) ->setImageHref($bloggerURI) ->setAppIcon('phame-dark') - ->setUser($user) + ->setUser($viewer) ->setPontification($phame_post, $phame_title); + if (PhabricatorPolicyFilter::hasCapability( + $viewer, + $post, + PhabricatorPolicyCapability::CAN_EDIT)) { + + $story->addAction(id(new PHUIIconView()) + ->setHref($this->getApplicationURI('post/edit/'.$post->getID().'/')) + ->setText(pht('Edit')) + ->setIconFont('fa-pencil')); + } + if ($post->getDatePublished()) { $story->setEpoch($post->getDatePublished()); } + $stories[] = $story; } + if (empty($stories)) { + return id(new AphrontErrorView()) + ->setSeverity(AphrontErrorView::SEVERITY_NODATA) + ->appendChild($nodata); + } + return $stories; } diff --git a/src/applications/phame/controller/blog/PhameBlogEditController.php b/src/applications/phame/controller/blog/PhameBlogEditController.php index b8d4f87ccd..0f0d333ebb 100644 --- a/src/applications/phame/controller/blog/PhameBlogEditController.php +++ b/src/applications/phame/controller/blog/PhameBlogEditController.php @@ -1,8 +1,5 @@ setDescription($description); $blog->setDomain(nonempty($custom_domain, null)); $blog->setSkin($skin); - - if (!empty($custom_domain)) { - $error = $blog->validateCustomDomain($custom_domain); - if ($error) { - $errors[] = $error; - $e_custom_domain = pht('Invalid'); - } - } - $blog->setViewPolicy($request->getStr('can_view')); $blog->setEditPolicy($request->getStr('can_edit')); $blog->setJoinPolicy($request->getStr('can_join')); + if (!empty($custom_domain)) { + list($error_label, $error_text) = + $blog->validateCustomDomain($custom_domain); + if ($error_label) { + $errors[] = $error_text; + $e_custom_domain = $error_label; + } + if ($blog->getJoinPolicy() != PhabricatorPolicies::POLICY_PUBLIC) { + $errors[] = pht( + 'For custom domains to work, the blog must have a view policy of '. + 'public.'); + // Prefer earlier labels for the multiple error scenario. + if (!$e_custom_domain) { + $e_custom_domain = pht('Invalid Policy'); + } + } + } + // Don't let users remove their ability to edit blogs. PhabricatorPolicyFilter::mustRetainCapability( $user, diff --git a/src/applications/phame/storage/PhameBlog.php b/src/applications/phame/storage/PhameBlog.php index b59fefd62b..d3fb89ef51 100644 --- a/src/applications/phame/storage/PhameBlog.php +++ b/src/applications/phame/storage/PhameBlog.php @@ -1,8 +1,5 @@ getProtocol()) { - return pht( - 'The custom domain should not include a protocol. Just provide '. - 'the bare domain name (for example, "%s").', - $example_domain); + return array($label, + pht( + 'The custom domain should not include a protocol. Just provide '. + 'the bare domain name (for example, "%s").', + $example_domain)); } if ($uri->getPort()) { - return pht( - 'The custom domain should not include a port number. Just provide '. - 'the bare domain name (for example, "%s").', - $example_domain); + return array($label, + pht( + 'The custom domain should not include a port number. Just provide '. + 'the bare domain name (for example, "%s").', + $example_domain)); } if (strpos($custom_domain, '/') !== false) { - return pht( - 'The custom domain should not specify a path (hosting a Phame '. - 'blog at a path is currently not supported). Instead, just provide '. - 'the bare domain name (for example, "%s").', - $example_domain); + return array($label, + pht( + 'The custom domain should not specify a path (hosting a Phame '. + 'blog at a path is currently not supported). Instead, just provide '. + 'the bare domain name (for example, "%s").', + $example_domain)); } if (strpos($custom_domain, '.') === false) { - return pht( - 'The custom domain should contain at least one dot (.) because '. - 'some browsers fail to set cookies on domains without a dot. Instead, '. - 'use a normal looking domain name like "%s".', - $example_domain); + return array($label, + pht( + 'The custom domain should contain at least one dot (.) because '. + 'some browsers fail to set cookies on domains without a dot. '. + 'Instead, use a normal looking domain name like "%s".', + $example_domain)); + } + + if (!PhabricatorEnv::getEnvConfig('policy.allow-public')) { + $href = PhabricatorEnv::getProductionURI( + '/config/edit/policy.allow-public/'); + return array(pht('Fix Configuration'), + pht( + 'For custom domains to work, this Phabricator instance must be '. + 'configured to allow the public access policy. Configure this '. + 'setting %s, or ask an administrator to configure this setting. '. + 'The domain can be specified later once this setting has been '. + 'changed.', + phutil_tag( + 'a', + array('href' => $href), + pht('here')))); } return null; diff --git a/src/applications/phame/storage/PhamePost.php b/src/applications/phame/storage/PhamePost.php index 009e6ccb46..c142b1da6c 100644 --- a/src/applications/phame/storage/PhamePost.php +++ b/src/applications/phame/storage/PhamePost.php @@ -1,8 +1,5 @@ getID().'/'; + } + public function isDraft() { return $this->getVisibility() == self::VISIBILITY_DRAFT; } diff --git a/src/docs/user/userguide/phame.diviner b/src/docs/user/userguide/phame.diviner index 64e17d421f..8422a8e8c7 100644 --- a/src/docs/user/userguide/phame.diviner +++ b/src/docs/user/userguide/phame.diviner @@ -29,16 +29,22 @@ a name, description, and set of bloggers who can add posts to the blog. Each blogger can also edit metadata about the blog and delete the blog outright. -Soon, blogs will be useful for powering external websites, like +NOTE: removing a blogger from a given blog does not remove their posts that +are already associated with the blog. Rather, it removes their ability to edit +metadata about and add posts to the blog. + +Blogs can be useful for powering external websites, like blog.yourcompany.com by making pertinent configuration changes with your DNS authority and -Phabricator instance. +Phabricator instance. For the Phabricator instance, you must -NOTE: removing a blogger from a given blog does not remove their posts that -are already associated with the blog. Rather, it removes their ability to edit -metadata about and add posts to the blog. + - Enable `policy.allow-public` in Phabricator configuration. + - Configure the blog to have the view policy `public`. + +For your DNS authority, simply point the pertinent domain name at your +Phabricator instance. e.g. by IP address. = Comment Widgets = diff --git a/webroot/rsrc/css/application/phame/phame.css b/webroot/rsrc/css/application/phame/phame.css index 3c6e59a3d3..625c3ff186 100644 --- a/webroot/rsrc/css/application/phame/phame.css +++ b/webroot/rsrc/css/application/phame/phame.css @@ -25,6 +25,14 @@ max-width: 600px; } +.phame-post-list .aphront-error-view { + margin: 0; +} + +.phame-post-list .phui-icon-view:hover { + text-decoration: none; +} + .blog-post-list { clear: left; float: left;