Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/differential/view/revisioncommentlist/DifferentialRevisionCommentListView.php b/src/applications/differential/view/revisioncommentlist/DifferentialRevisionCommentListView.php
index 7ccbcb66f0..d03486e94f 100644
--- a/src/applications/differential/view/revisioncommentlist/DifferentialRevisionCommentListView.php
+++ b/src/applications/differential/view/revisioncommentlist/DifferentialRevisionCommentListView.php
@@ -1,168 +1,170 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
final class DifferentialRevisionCommentListView extends AphrontView {
private $comments;
private $handles;
private $inlines;
private $changesets;
private $user;
private $target;
public function setComments(array $comments) {
$this->comments = $comments;
return $this;
}
public function setInlineComments(array $inline_comments) {
$this->inlines = $inline_comments;
return $this;
}
public function setHandles(array $handles) {
$this->handles = $handles;
return $this;
}
public function setChangesets(array $changesets) {
$this->changesets = $changesets;
return $this;
}
public function setUser(PhabricatorUser $user) {
$this->user = $user;
return $this;
}
public function setTargetDiff(DifferentialDiff $target) {
$this->target = $target;
}
public function render() {
require_celerity_resource('differential-revision-comment-list-css');
- $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
+ $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine(array(
+ 'differential.diff' => $this->target
+ ));
$inlines = mgroup($this->inlines, 'getCommentID');
$num = 1;
$html = array();
foreach ($this->comments as $comment) {
$view = new DifferentialRevisionCommentView();
$view->setComment($comment);
$view->setUser($this->user);
$view->setHandles($this->handles);
$view->setMarkupEngine($engine);
$view->setInlineComments(idx($inlines, $comment->getID(), array()));
$view->setChangesets($this->changesets);
$view->setTargetDiff($this->target);
$view->setCommentNumber($num++);
$html[] = $view->render();
}
$objs = array_reverse(array_values($this->comments));
$html = array_reverse(array_values($html));
$user = $this->user;
$last_comment = null;
// Find the most recent comment by the viewer.
foreach ($objs as $position => $comment) {
if ($user && ($comment->getAuthorPHID() == $user->getPHID())) {
if ($last_comment === null) {
$last_comment = $position;
} else if ($last_comment == $position - 1) {
// If the viewer made several comments in a row, show them all. This
// is a spaz rule for epriestley.
$last_comment = $position;
}
}
}
$header = array();
$hidden = array();
if ($last_comment !== null) {
foreach ($objs as $position => $comment) {
if (!$comment->getID()) {
// These are synthetic comments with summary/test plan information.
$header[] = $html[$position];
unset($html[$position]);
continue;
}
if ($position <= $last_comment) {
// Always show comments after the viewer's last comment.
continue;
}
if ($position < 3) {
// Always show the 3 most recent comments.
continue;
}
$hidden[] = $position;
}
}
if (count($hidden) <= 3) {
// Don't hide if there's not much to hide.
$hidden = array();
}
$header = array_reverse($header);
$hidden = array_select_keys($html, $hidden);
$visible = array_diff_key($html, $hidden);
$hidden = array_reverse($hidden);
$visible = array_reverse($visible);
if ($hidden) {
Javelin::initBehavior(
'differential-show-all-comments',
array(
'markup' => implode("\n", $hidden),
));
$hidden = javelin_render_tag(
'div',
array(
'sigil' => "differential-all-comments-container",
),
'<div class="differential-older-comments-are-hidden">'.
number_format(count($hidden)).' older comments are hidden. '.
javelin_render_tag(
'a',
array(
'href' => '#',
'mustcapture' => true,
'sigil' => 'differential-show-all-comments',
),
'Show all comments.').
'</div>');
} else {
$hidden = null;
}
return
'<div class="differential-comment-list">'.
implode("\n", $header).
$hidden.
implode("\n", $visible).
'</div>';
}
}
diff --git a/src/applications/markup/engine/PhabricatorMarkupEngine.php b/src/applications/markup/engine/PhabricatorMarkupEngine.php
index 788774bd6b..5a4624653f 100644
--- a/src/applications/markup/engine/PhabricatorMarkupEngine.php
+++ b/src/applications/markup/engine/PhabricatorMarkupEngine.php
@@ -1,164 +1,168 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class PhabricatorMarkupEngine {
public static function extractPHIDsFromMentions(array $content_blocks) {
$mentions = array();
$engine = self::newDifferentialMarkupEngine();
foreach ($content_blocks as $content_block) {
$engine->markupText($content_block);
$phids = $engine->getTextMetadata(
PhabricatorRemarkupRuleMention::KEY_MENTIONED,
array());
$mentions += $phids;
}
return $mentions;
}
public static function newManiphestMarkupEngine() {
return self::newMarkupEngine(array(
));
}
public static function newPhrictionMarkupEngine() {
return self::newMarkupEngine(array(
// Disable image macros on the wiki since they're less useful, we don't
// cache documents, and the module is prohibitively expensive for large
// documents.
'macros' => false,
));
}
- public static function newDifferentialMarkupEngine() {
+ public static function newDifferentialMarkupEngine(array $options = array()) {
return self::newMarkupEngine(array(
'custom-inline' => PhabricatorEnv::getEnvConfig(
'differential.custom-remarkup-rules'),
'custom-block' => PhabricatorEnv::getEnvConfig(
'differential.custom-remarkup-block-rules'),
+ 'differential.diff' => idx($options, 'differential.diff'),
));
}
public static function newProfileMarkupEngine() {
return self::newMarkupEngine(array(
));
}
public static function newSlowvoteMarkupEngine() {
return self::newMarkupEngine(array(
));
}
private static function getMarkupEngineDefaultConfiguration() {
return array(
'pygments' => PhabricatorEnv::getEnvConfig('pygments.enabled'),
'fileproxy' => PhabricatorEnv::getEnvConfig('files.enable-proxy'),
'youtube' => PhabricatorEnv::getEnvConfig(
'remarkup.enable-embedded-youtube'),
'custom-inline' => array(),
'custom-block' => array(),
+ 'differential.diff' => null,
'macros' => true,
'uri.allowed-protocols' => PhabricatorEnv::getEnvConfig(
'uri.allowed-protocols'),
);
}
private static function newMarkupEngine(array $options) {
$options += self::getMarkupEngineDefaultConfiguration();
$engine = new PhutilRemarkupEngine();
$engine->setConfig('preserve-linebreaks', true);
$engine->setConfig('pygments.enabled', $options['pygments']);
$engine->setConfig(
'uri.allowed-protocols',
$options['uri.allowed-protocols']);
+ $engine->setConfig('differential.diff', $options['differential.diff']);
$rules = array();
$rules[] = new PhutilRemarkupRuleEscapeRemarkup();
+
+ $custom_rule_classes = $options['custom-inline'];
+ if ($custom_rule_classes) {
+ foreach ($custom_rule_classes as $custom_rule_class) {
+ PhutilSymbolLoader::loadClass($custom_rule_class);
+ $rules[] = newv($custom_rule_class, array());
+ }
+ }
+
if ($options['fileproxy']) {
$rules[] = new PhabricatorRemarkupRuleProxyImage();
}
if ($options['youtube']) {
$rules[] = new PhabricatorRemarkupRuleYoutube();
}
$rules[] = new PhabricatorRemarkupRulePhriction();
$rules[] = new PhutilRemarkupRuleHyperlink();
$rules[] = new PhabricatorRemarkupRuleDifferentialHandle();
$rules[] = new PhabricatorRemarkupRuleManiphestHandle();
$rules[] = new PhabricatorRemarkupRuleEmbedFile();
$rules[] = new PhabricatorRemarkupRuleDifferential();
$rules[] = new PhabricatorRemarkupRuleDiffusion();
$rules[] = new PhabricatorRemarkupRuleManiphest();
$rules[] = new PhabricatorRemarkupRulePaste();
if ($options['macros']) {
$rules[] = new PhabricatorRemarkupRuleImageMacro();
}
$rules[] = new PhabricatorRemarkupRuleMention();
- $custom_rule_classes = $options['custom-inline'];
- if ($custom_rule_classes) {
- foreach ($custom_rule_classes as $custom_rule_class) {
- PhutilSymbolLoader::loadClass($custom_rule_class);
- $rules[] = newv($custom_rule_class, array());
- }
- }
-
$rules[] = new PhutilRemarkupRuleEscapeHTML();
$rules[] = new PhutilRemarkupRuleMonospace();
$rules[] = new PhutilRemarkupRuleBold();
$rules[] = new PhutilRemarkupRuleItalic();
$blocks = array();
$blocks[] = new PhutilRemarkupEngineRemarkupQuotesBlockRule();
$blocks[] = new PhutilRemarkupEngineRemarkupHeaderBlockRule();
$blocks[] = new PhutilRemarkupEngineRemarkupListBlockRule();
$blocks[] = new PhutilRemarkupEngineRemarkupCodeBlockRule();
$blocks[] = new PhutilRemarkupEngineRemarkupDefaultBlockRule();
$custom_block_rule_classes = $options['custom-block'];
if ($custom_block_rule_classes) {
foreach ($custom_block_rule_classes as $custom_block_rule_class) {
PhutilSymbolLoader::loadClass($custom_block_rule_class);
$blocks[] = newv($custom_block_rule_class, array());
}
}
foreach ($blocks as $block) {
if (!($block instanceof PhutilRemarkupEngineRemarkupCodeBlockRule)) {
$block->setMarkupRules($rules);
}
}
$engine->setBlockRules($blocks);
return $engine;
}
}

File Metadata

Mime Type
text/x-diff
Expires
Wed, May 21, 1:14 PM (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
126296
Default Alt Text
(11 KB)

Event Timeline