1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +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;
}
$engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
return $engine->markupText($this->value);
return phutil_safe_html($engine->markupText($this->value));
}
public function shouldAppearOnConduitView() {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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