1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 15:22:41 +01:00

render_tag -> tag: phame, remarkup

Summary: Converts various callsites from render_tag variants to tag variants.

Test Plan: See inlines.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Maniphest Tasks: T2432

Differential Revision: https://secure.phabricator.com/D4689
This commit is contained in:
epriestley 2013-01-28 18:44:15 -08:00
parent 820c6279f3
commit edfcd7bd2d
11 changed files with 73 additions and 54 deletions

View file

@ -48,7 +48,7 @@ final class DifferentialBlameRevisionFieldSpecification
return null; return null;
} }
$engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine(); $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
return $engine->markupText($this->value); return phutil_safe_html($engine->markupText($this->value));
} }
public function shouldAppearOnConduitView() { public function shouldAppearOnConduitView() {

View file

@ -113,7 +113,7 @@ final class DifferentialUnitFieldSpecification
$userdata = idx($test, 'userdata'); $userdata = idx($test, 'userdata');
if ($userdata) { if ($userdata) {
$engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine(); $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
$userdata = $engine->markupText($userdata); $userdata = phutil_safe_html($engine->markupText($userdata));
$rows[] = array( $rows[] = array(
'style' => 'details', 'style' => 'details',
'value' => $userdata, 'value' => $userdata,

View file

@ -106,7 +106,7 @@ final class DiffusionBrowseController extends DiffusionController {
private function markupText($text) { private function markupText($text) {
$engine = PhabricatorMarkupEngine::newDiffusionMarkupEngine(); $engine = PhabricatorMarkupEngine::newDiffusionMarkupEngine();
$text = $engine->markupText($text); $text = phutil_safe_html($engine->markupText($text));
$text = phutil_tag( $text = phutil_tag(
'div', 'div',

View file

@ -93,7 +93,8 @@ final class DiffusionCommitController extends DiffusionController {
$property_list->addTextContent( $property_list->addTextContent(
'<div class="diffusion-commit-message phabricator-remarkup">'. '<div class="diffusion-commit-message phabricator-remarkup">'.
$engine->markupText($commit_data->getCommitMessage()). phutil_safe_html(
$engine->markupText($commit_data->getCommitMessage())).
'</div>' '</div>'
); );

View file

@ -127,7 +127,7 @@ abstract class DiffusionBrowseQuery {
} else { } else {
// Markup extensionless files as remarkup so we get links and such. // Markup extensionless files as remarkup so we get links and such.
$engine = PhabricatorMarkupEngine::newDiffusionMarkupEngine(); $engine = PhabricatorMarkupEngine::newDiffusionMarkupEngine();
$readme_content = $engine->markupText($readme_content); $readme_content = phutil_safe_html($engine->markupText($readme_content));
$class = 'phabricator-remarkup'; $class = 'phabricator-remarkup';
} }

View file

@ -165,7 +165,7 @@ final class PhabricatorPeopleProfileController
'//Nothing is known about this rare specimen.//'); '//Nothing is known about this rare specimen.//');
$engine = PhabricatorMarkupEngine::newProfileMarkupEngine(); $engine = PhabricatorMarkupEngine::newProfileMarkupEngine();
$blurb = $engine->markupText($blurb); $blurb = phutil_safe_html($engine->markupText($blurb));
$viewer = $this->getRequest()->getUser(); $viewer = $this->getRequest()->getUser();

View file

@ -70,6 +70,7 @@ abstract class PhameBasicBlogSkin extends PhameBlogSkin {
$view->setFrameable(true); $view->setFrameable(true);
} }
$view->appendChild($content); $view->appendChild($content);
$response = new AphrontWebpageResponse(); $response = new AphrontWebpageResponse();
@ -95,23 +96,30 @@ abstract class PhameBasicBlogSkin extends PhameBlogSkin {
$summaries[] = $post->renderWithSummary(); $summaries[] = $post->renderWithSummary();
} }
$list = phutil_render_tag( $list = phutil_tag(
'div', 'div',
array( array(
'class' => 'phame-post-list', 'class' => 'phame-post-list',
), ),
id(new AphrontNullView())->appendChild($summaries)->render()); id(new AphrontNullView())->appendChild($summaries)->render());
$pager = $this->renderOlderPageLink().$this->renderNewerPageLink(); $pager = null;
if ($pager) { if ($this->renderOlderPageLink() || $this->renderNewerPageLink()) {
$pager = phutil_tag( $pager = phutil_tag(
'div', 'div',
array( array(
'class' => 'phame-pager', 'class' => 'phame-pager',
),
array(
$this->renderOlderPageLink(),
$this->renderNewerPageLink(),
)); ));
} }
return $list.$pager; return array(
$list,
$pager,
);
} }
protected function render404Page() { protected function render404Page() {

View file

@ -87,7 +87,7 @@ final class PhamePostView extends AphrontView {
} }
public function renderBody() { public function renderBody() {
return phutil_render_tag( return phutil_tag(
'div', 'div',
array( array(
'class' => 'phame-post-body', 'class' => 'phame-post-body',
@ -96,7 +96,7 @@ final class PhamePostView extends AphrontView {
} }
public function renderSummary() { public function renderSummary() {
return phutil_render_tag( return phutil_tag(
'div', 'div',
array( array(
'class' => 'phame-post-body', 'class' => 'phame-post-body',
@ -159,11 +159,11 @@ final class PhamePostView extends AphrontView {
array( array(
'id' => 'fb-root', 'id' => 'fb-root',
), ),
'' '');
);
$c_uri = '//connect.facebook.net/en_US/all.js#xfbml=1&appId='.$fb_id; $c_uri = '//connect.facebook.net/en_US/all.js#xfbml=1&appId='.$fb_id;
$fb_js = jsprintf( $fb_js = phutil_safe_html(
jsprintf(
'<script>(function(d, s, id) {'. '<script>(function(d, s, id) {'.
' var js, fjs = d.getElementsByTagName(s)[0];'. ' var js, fjs = d.getElementsByTagName(s)[0];'.
' if (d.getElementById(id)) return;'. ' if (d.getElementById(id)) return;'.
@ -171,8 +171,7 @@ final class PhamePostView extends AphrontView {
' js.src = %s;'. ' js.src = %s;'.
' fjs.parentNode.insertBefore(js, fjs);'. ' fjs.parentNode.insertBefore(js, fjs);'.
'}(document, \'script\', \'facebook-jssdk\'));</script>', '}(document, \'script\', \'facebook-jssdk\'));</script>',
$c_uri $c_uri));
);
$uri = $this->getSkin()->getURI('post/'.$this->getPost()->getPhameTitle()); $uri = $this->getSkin()->getURI('post/'.$this->getPost()->getPhameTitle());
@ -183,17 +182,18 @@ final class PhamePostView extends AphrontView {
'data-href' => $uri, 'data-href' => $uri,
'data-num-posts' => 5, 'data-num-posts' => 5,
), ),
'' '');
);
return phutil_render_tag( return phutil_tag(
'div', 'div',
array( array(
'class' => 'phame-comments-facebook', 'class' => 'phame-comments-facebook',
), ),
$fb_root. array(
$fb_js. $fb_root,
$fb_comments); $fb_js,
$fb_comments,
));
} }
private function renderDisqusComments() { private function renderDisqusComments() {
@ -211,7 +211,8 @@ final class PhamePostView extends AphrontView {
); );
// protip - try some var disqus_developer = 1; action to test locally // protip - try some var disqus_developer = 1; action to test locally
$disqus_js = jsprintf( $disqus_js = phutil_safe_html(
jsprintf(
'<script>'. '<script>'.
' var disqus_shortname = "phabricator";'. ' var disqus_shortname = "phabricator";'.
' var disqus_identifier = %s;'. ' var disqus_identifier = %s;'.
@ -227,16 +228,17 @@ final class PhamePostView extends AphrontView {
'})(); </script>', '})(); </script>',
$post->getPHID(), $post->getPHID(),
$this->getSkin()->getURI('post/'.$this->getPost()->getPhameTitle()), $this->getSkin()->getURI('post/'.$this->getPost()->getPhameTitle()),
$post->getTitle() $post->getTitle()));
);
return phutil_render_tag( return phutil_tag(
'div', 'div',
array( array(
'class' => 'phame-comments-disqus', 'class' => 'phame-comments-disqus',
), ),
$disqus_thread. array(
$disqus_js); $disqus_thread,
$disqus_js,
));
} }
} }

View file

@ -43,8 +43,15 @@ final class ConduitAPI_remarkup_process_Method extends ConduitAPIMethod {
$engine = PhabricatorMarkupEngine::$engine_class(); $engine = PhabricatorMarkupEngine::$engine_class();
$engine->setConfig('viewer', $request->getUser()); $engine->setConfig('viewer', $request->getUser());
$text = $engine->markupText($content);
if ($text) {
$content = phutil_safe_html($text)->getHTMLContent();
} else {
$content = '';
}
$result = array( $result = array(
'content' => $engine->markupText($content), 'content' => $content,
); );
return $result; return $result;

View file

@ -203,7 +203,8 @@ final class PhabricatorSlowvotePollController
foreach ($comments as $comment) { foreach ($comments as $comment) {
$handle = $handles[$comment->getAuthorPHID()]; $handle = $handles[$comment->getAuthorPHID()];
$markup = $engine->markupText($comment->getCommentText()); $markup = phutil_safe_html(
$engine->markupText($comment->getCommentText()));
require_celerity_resource('phabricator-remarkup-css'); require_celerity_resource('phabricator-remarkup-css');

View file

@ -160,7 +160,7 @@ final class PhabricatorMarkupEngine {
"Call process() before getOutput()."); "Call process() before getOutput().");
} }
return $this->objects[$key]['output']; return new PhutilSafeHTML($this->objects[$key]['output']);
} }