3 final class PhameBlogFeedController
extends PhameBlogController
{
5 public function shouldRequireLogin() {
9 public function handleRequest(AphrontRequest
$request) {
10 $viewer = $request->getViewer();
11 $id = $request->getURIData('id');
13 $blog = id(new PhameBlogQuery())
18 return new Aphront404Response();
21 $posts = id(new PhamePostQuery())
23 ->withBlogPHIDs(array($blog->getPHID()))
24 ->withVisibility(array(PhameConstants
::VISIBILITY_PUBLISHED
))
27 $blog_uri = PhabricatorEnv
::getProductionURI(
28 $this->getApplicationURI('blog/feed/'.$blog->getID().'/'));
30 $content[] = phutil_tag('title', array(), $blog->getName());
31 $content[] = phutil_tag('id', array(), $blog_uri);
32 $content[] = phutil_tag('link',
35 'type' => 'application/atom+xml',
39 $updated = $blog->getDateModified();
41 $updated = max($updated, max(mpull($posts, 'getDateModified')));
43 $content[] = phutil_tag('updated', array(), date('c', $updated));
45 $description = $blog->getDescription();
46 if ($description != '') {
47 $content[] = phutil_tag('subtitle', array(), $description);
50 $engine = id(new PhabricatorMarkupEngine())->setViewer($viewer);
51 foreach ($posts as $post) {
52 $engine->addObject($post, PhamePost
::MARKUP_FIELD_BODY
);
56 $blogger_phids = mpull($posts, 'getBloggerPHID');
57 $bloggers = id(new PhabricatorHandleQuery())
59 ->withPHIDs($blogger_phids)
62 foreach ($posts as $post) {
63 $content[] = hsprintf('<entry>');
64 $content[] = phutil_tag('title', array(), $post->getTitle());
65 $content[] = phutil_tag('link', array('href' => $post->getLiveURI()));
67 $content[] = phutil_tag('id', array(), PhabricatorEnv
::getProductionURI(
68 '/phame/post/view/'.$post->getID().'/'));
70 $content[] = hsprintf(
71 '<author><name>%s</name></author>',
72 $bloggers[$post->getBloggerPHID()]->getFullName());
74 $content[] = phutil_tag(
77 date('c', $post->getDateModified()));
79 $content[] = hsprintf(
80 '<content type="xhtml">'.
81 '<div xmlns="http://www.w3.org/1999/xhtml">%s</div>'.
83 $engine->getOutput($post, PhamePost
::MARKUP_FIELD_BODY
));
85 $content[] = hsprintf('</entry>');
88 $content = phutil_tag(
90 array('xmlns' => 'http://www.w3.org/2005/Atom'),
93 return id(new AphrontFileResponse())
94 ->setMimeType('application/xml')
95 ->setContent($content);