mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 06:42:42 +01:00
Add HTML header for Atom/RSS discovery on Phame blog pages
Summary: Allow easier discovery and subscribing to Atom feeds of Phame blogs. To be extra cautious, also make sure that the added line is a `PhutilSafeHTML`. Original author: @20after4 Closes T15550 Test Plan: Go to `/phame/blog/view/1/` and check the HTML source code. See an additional `<link>` item with `type="application/atom+xml"` in the `<head>` section. Reviewers: O1 Blessed Committers, avivey Reviewed By: O1 Blessed Committers, avivey Subscribers: avivey, speck, tobiaswiese, valerio.bozzolan, Matthew, 20after4, Cigaryno Maniphest Tasks: T15550 Differential Revision: https://we.phorge.it/D25346
This commit is contained in:
parent
9fe2bfebe8
commit
39b576b145
3 changed files with 33 additions and 1 deletions
|
@ -117,6 +117,15 @@ final class PhameBlogViewController extends PhameLiveController {
|
|||
$about,
|
||||
));
|
||||
|
||||
$page->addHeadItem(phutil_tag(
|
||||
'link',
|
||||
array(
|
||||
'rel' => 'alternate',
|
||||
'type' => 'application/atom+xml',
|
||||
'href' => $blog->getFeedURI(),
|
||||
'title' => $blog->getName(),
|
||||
)));
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
|
|
|
@ -200,6 +200,15 @@ final class PhameBlog extends PhameDAO
|
|||
return '/phame/blog/manage/'.$this->getID().'/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get relative URI of Phame blog feed.
|
||||
*
|
||||
* @return string Relative URI of Phame blog feed
|
||||
*/
|
||||
public function getFeedURI() {
|
||||
return '/phame/blog/feed/'.$this->getID().'/';
|
||||
}
|
||||
|
||||
public function getProfileImageURI() {
|
||||
return $this->getProfileImageFile()->getBestURI();
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView
|
|||
private $crumbs;
|
||||
private $navigation;
|
||||
private $footer;
|
||||
private $headItems = array();
|
||||
|
||||
public function setShowFooter($show_footer) {
|
||||
$this->showFooter = $show_footer;
|
||||
|
@ -375,6 +376,18 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert a HTML element into <head> of the page to render.
|
||||
* Used by PhameBlogViewController.
|
||||
*
|
||||
* @param PhutilSafeHTML HTML header to add
|
||||
*/
|
||||
public function addHeadItem($html) {
|
||||
if ($html instanceof PhutilSafeHTML) {
|
||||
$this->headItems[] = $html;
|
||||
}
|
||||
}
|
||||
|
||||
protected function getHead() {
|
||||
$monospaced = null;
|
||||
|
||||
|
@ -407,9 +420,10 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView
|
|||
}
|
||||
|
||||
return hsprintf(
|
||||
'%s%s%s',
|
||||
'%s%s%s%s',
|
||||
parent::getHead(),
|
||||
$font_css,
|
||||
phutil_implode_html('', $this->headItems),
|
||||
$response->renderSingleResource('javelin-magical-init', 'phabricator'));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue