Page MenuHomePhorge

No OneTemporary

diff --git a/src/applications/phame/controller/blog/PhameBlogFeedController.php b/src/applications/phame/controller/blog/PhameBlogFeedController.php
index e72e51edfa..8b42b2928f 100644
--- a/src/applications/phame/controller/blog/PhameBlogFeedController.php
+++ b/src/applications/phame/controller/blog/PhameBlogFeedController.php
@@ -1,99 +1,106 @@
<?php
/**
* @group phame
*/
final class PhameBlogFeedController extends PhameController {
private $id;
public function shouldRequireLogin() {
return false;
}
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$blog = id(new PhameBlogQuery())
->setViewer($user)
->withIDs(array($this->id))
->executeOne();
if (!$blog) {
return new Aphront404Response();
}
$posts = id(new PhamePostQuery())
->setViewer($user)
->withBlogPHIDs(array($blog->getPHID()))
->withVisibility(PhamePost::VISIBILITY_PUBLISHED)
->execute();
+ $blog_uri = PhabricatorEnv::getProductionURI(
+ $this->getApplicationURI('blog/feed/'.$blog->getID().'/'));
$content = array();
$content[] = phutil_tag('title', array(), $blog->getName());
- $content[] = phutil_tag('id', array(), PhabricatorEnv::getProductionURI(
- '/phame/blog/view/'.$blog->getID().'/'));
+ $content[] = phutil_tag('id', array(), $blog_uri);
+ $content[] = phutil_tag('link',
+ array(
+ 'rel' => 'self',
+ 'type' => 'application/atom+xml',
+ 'href' => $blog_uri
+ ));
$updated = $blog->getDateModified();
if ($posts) {
$updated = max($updated, max(mpull($posts, 'getDateModified')));
}
$content[] = phutil_tag('updated', array(), date('c', $updated));
$description = $blog->getDescription();
if ($description != '') {
$content[] = phutil_tag('subtitle', array(), $description);
}
$engine = id(new PhabricatorMarkupEngine())->setViewer($user);
foreach ($posts as $post) {
$engine->addObject($post, PhamePost::MARKUP_FIELD_BODY);
}
$engine->process();
$bloggers = mpull($posts, 'getBloggerPHID');
$bloggers = id(new PhabricatorObjectHandleData($bloggers))
->setViewer($user)
->loadHandles();
foreach ($posts as $post) {
$content[] = hsprintf('<entry>');
$content[] = phutil_tag('title', array(), $post->getTitle());
$content[] = phutil_tag('link', array('href' => $post->getViewURI()));
$content[] = phutil_tag('id', array(), PhabricatorEnv::getProductionURI(
'/phame/post/view/'.$post->getID().'/'));
$content[] = hsprintf(
'<author><name>%s</name></author>',
$bloggers[$post->getBloggerPHID()]->getFullName());
$content[] = phutil_tag(
'updated',
array(),
date('c', $post->getDateModified()));
$content[] = hsprintf(
'<content type="xhtml">'.
'<div xmlns="http://www.w3.org/1999/xhtml">%s</div>'.
'</content>',
$engine->getOutput($post, PhamePost::MARKUP_FIELD_BODY));
$content[] = hsprintf('</entry>');
}
$content = phutil_tag(
'feed',
array('xmlns' => 'http://www.w3.org/2005/Atom'),
$content);
return id(new AphrontFileResponse())
->setMimeType('application/xml')
->setContent($content);
}
}
diff --git a/src/applications/phame/controller/blog/PhameBlogViewController.php b/src/applications/phame/controller/blog/PhameBlogViewController.php
index 8accd39a1c..c6afaaf676 100644
--- a/src/applications/phame/controller/blog/PhameBlogViewController.php
+++ b/src/applications/phame/controller/blog/PhameBlogViewController.php
@@ -1,161 +1,179 @@
<?php
/**
* @group phame
*/
final class PhameBlogViewController extends PhameController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$blog = id(new PhameBlogQuery())
->setViewer($user)
->withIDs(array($this->id))
->executeOne();
if (!$blog) {
return new Aphront404Response();
}
$pager = id(new AphrontCursorPagerView())
->readFromRequest($request);
$posts = id(new PhamePostQuery())
->setViewer($user)
->withBlogPHIDs(array($blog->getPHID()))
->executeWithCursorPager($pager);
$nav = $this->renderSideNavFilterView(null);
$header = id(new PhabricatorHeaderView())
->setHeader($blog->getName());
$handle_phids = array_merge(
mpull($posts, 'getBloggerPHID'),
mpull($posts, 'getBlogPHID'));
$this->loadHandles($handle_phids);
$actions = $this->renderActions($blog, $user);
$properties = $this->renderProperties($blog, $user);
$post_list = $this->renderPostList(
$posts,
$user,
pht('This blog has no visible posts.'));
$nav->appendChild(
array(
$header,
$actions,
$properties,
$post_list,
));
return $this->buildApplicationPage(
$nav,
array(
'device' => true,
'title' => $blog->getName(),
));
}
private function renderProperties(PhameBlog $blog, PhabricatorUser $user) {
+ require_celerity_resource('aphront-tooltip-css');
+ Javelin::initBehavior('phabricator-tooltips');
+
$properties = new PhabricatorPropertyListView();
$properties->addProperty(
pht('Skin'),
$blog->getSkin());
$properties->addProperty(
pht('Domain'),
$blog->getDomain());
+ $feed_uri = PhabricatorEnv::getProductionURI(
+ $this->getApplicationURI('blog/feed/'.$blog->getID().'/'));
+ $properties->addProperty(
+ pht('Atom URI'),
+ javelin_tag('a',
+ array(
+ 'href' => $feed_uri,
+ 'sigil' => 'has-tooltip',
+ 'meta' => array(
+ 'tip' => pht('Atom URI does not support custom domains.'),
+ 'size' => 320,
+ )
+ ),
+ $feed_uri));
+
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions(
$user,
$blog);
$properties->addProperty(
pht('Visible To'),
$descriptions[PhabricatorPolicyCapability::CAN_VIEW]);
$properties->addProperty(
pht('Editable By'),
$descriptions[PhabricatorPolicyCapability::CAN_EDIT]);
$properties->addProperty(
pht('Joinable By'),
$descriptions[PhabricatorPolicyCapability::CAN_JOIN]);
$engine = id(new PhabricatorMarkupEngine())
->setViewer($user)
->addObject($blog, PhameBlog::MARKUP_FIELD_DESCRIPTION)
->process();
$properties->addTextContent(
phutil_tag(
'div',
array(
'class' => 'phabricator-remarkup',
),
$engine->getOutput($blog, PhameBlog::MARKUP_FIELD_DESCRIPTION)));
return $properties;
}
private function renderActions(PhameBlog $blog, PhabricatorUser $user) {
$actions = id(new PhabricatorActionListView())
->setObject($blog)
->setUser($user);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$user,
$blog,
PhabricatorPolicyCapability::CAN_EDIT);
$can_join = PhabricatorPolicyFilter::hasCapability(
$user,
$blog,
PhabricatorPolicyCapability::CAN_JOIN);
$actions->addAction(
id(new PhabricatorActionView())
->setIcon('new')
->setHref($this->getApplicationURI('post/edit/?blog='.$blog->getID()))
->setName(pht('Write Post'))
->setDisabled(!$can_join)
->setWorkflow(!$can_join));
$actions->addAction(
id(new PhabricatorActionView())
->setUser($user)
->setIcon('world')
->setHref($this->getApplicationURI('live/'.$blog->getID().'/'))
->setRenderAsForm(true)
->setName(pht('View Live')));
$actions->addAction(
id(new PhabricatorActionView())
->setIcon('edit')
->setHref($this->getApplicationURI('blog/edit/'.$blog->getID().'/'))
->setName('Edit Blog')
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
$actions->addAction(
id(new PhabricatorActionView())
->setIcon('delete')
->setHref($this->getApplicationURI('blog/delete/'.$blog->getID().'/'))
->setName('Delete Blog')
->setDisabled(!$can_edit)
->setWorkflow(true));
return $actions;
}
}

File Metadata

Mime Type
text/x-diff
Expires
Jan 19 2025, 21:50 (6 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1129110
Default Alt Text
(8 KB)

Event Timeline