mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 06:42:42 +01:00
Remarkup for Differential comments.
This commit is contained in:
parent
9c3d00de03
commit
a34f946b8e
13 changed files with 192 additions and 6 deletions
|
@ -118,7 +118,7 @@ celerity_register_resource_map(array(
|
|||
),
|
||||
'differential-revision-comment-css' =>
|
||||
array(
|
||||
'uri' => '/res/d9924857/rsrc/css/application/differential/revision-comment.css',
|
||||
'uri' => '/res/21572195/rsrc/css/application/differential/revision-comment.css',
|
||||
'type' => 'css',
|
||||
'requires' =>
|
||||
array(
|
||||
|
@ -179,6 +179,15 @@ celerity_register_resource_map(array(
|
|||
),
|
||||
'disk' => '/rsrc/css/core/core.css',
|
||||
),
|
||||
'phabricator-remarkup-css' =>
|
||||
array(
|
||||
'uri' => '/res/786989c3/rsrc/css/core/remarkup.css',
|
||||
'type' => 'css',
|
||||
'requires' =>
|
||||
array(
|
||||
),
|
||||
'disk' => '/rsrc/css/core/remarkup.css',
|
||||
),
|
||||
'syntax-highlighting-css' =>
|
||||
array(
|
||||
'uri' => '/res/fb673ece/rsrc/css/core/syntax.css',
|
||||
|
|
|
@ -88,6 +88,7 @@ phutil_register_library_map(array(
|
|||
'DifferentialHunk' => 'applications/differential/storage/hunk',
|
||||
'DifferentialLintStatus' => 'applications/differential/constants/lintstatus',
|
||||
'DifferentialMail' => 'applications/differential/mail/base',
|
||||
'DifferentialMarkupEngineFactory' => 'applications/differential/parser/markup',
|
||||
'DifferentialNewDiffMail' => 'applications/differential/mail/newdiff',
|
||||
'DifferentialReviewRequestMail' => 'applications/differential/mail/reviewrequest',
|
||||
'DifferentialRevision' => 'applications/differential/storage/revision',
|
||||
|
|
|
@ -86,7 +86,7 @@ class DifferentialRevisionEditController extends DifferentialController {
|
|||
$editor->setReviewers($request->getArr('reviewers'));
|
||||
$editor->save();
|
||||
|
||||
$response = id(new AphrontRedirectResponse())
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI('/D'.$revision->getID());
|
||||
}
|
||||
|
||||
|
|
|
@ -365,9 +365,9 @@ class DifferentialRevisionEditor {
|
|||
}
|
||||
|
||||
} else {
|
||||
$diff = $revision->getActiveDiff();
|
||||
$diff = $revision->loadActiveDiff();
|
||||
if ($diff) {
|
||||
$changesets = id(new DifferentialChangeset())->loadAllWithDiff($diff);
|
||||
$changesets = $diff->loadChangesets();
|
||||
} else {
|
||||
$changesets = array();
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus');
|
||||
phutil_require_module('phabricator', 'applications/differential/mail/ccwelcome');
|
||||
phutil_require_module('phabricator', 'applications/differential/mail/newdiff');
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/changeset');
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/revision');
|
||||
phutil_require_module('phabricator', 'storage/qsprintf');
|
||||
phutil_require_module('phabricator', 'storage/queryfx');
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
<?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 DifferentialMarkupEngineFactory {
|
||||
|
||||
public function newDifferentialCommentMarkupEngine() {
|
||||
$engine = new PhutilRemarkupEngine();
|
||||
|
||||
$rules = array();
|
||||
$rules[] = new PhutilRemarkupRuleEscapeRemarkup();
|
||||
$rules[] = new PhutilRemarkupRuleHyperlink();
|
||||
$rules[] = new PhutilRemarkupRuleEscapeHTML();
|
||||
$rules[] = new PhutilRemarkupRuleMonospace();
|
||||
$rules[] = new PhutilRemarkupRuleBold();
|
||||
$rules[] = new PhutilRemarkupRuleItalic();
|
||||
|
||||
$blocks = array();
|
||||
$blocks[] = new PhutilRemarkupEngineRemarkupHeaderBlockRule();
|
||||
$blocks[] = new PhutilRemarkupEngineRemarkupListBlockRule();
|
||||
$blocks[] = new PhutilRemarkupEngineRemarkupCodeBlockRule();
|
||||
$blocks[] = new PhutilRemarkupEngineRemarkupDefaultBlockRule();
|
||||
|
||||
foreach ($blocks as $block) {
|
||||
if (!($block instanceof PhutilRemarkupEngineRemarkupCodeBlockRule)) {
|
||||
$block->setMarkupRules($rules);
|
||||
}
|
||||
}
|
||||
|
||||
$engine->setBlockRules($blocks);
|
||||
|
||||
return $engine;
|
||||
}
|
||||
|
||||
}
|
22
src/applications/differential/parser/markup/__init__.php
Normal file
22
src/applications/differential/parser/markup/__init__.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phutil', 'markup/engine/remarkup');
|
||||
phutil_require_module('phutil', 'markup/engine/remarkup/blockrule/remarkupcode');
|
||||
phutil_require_module('phutil', 'markup/engine/remarkup/blockrule/remarkupdefault');
|
||||
phutil_require_module('phutil', 'markup/engine/remarkup/blockrule/remarkupheader');
|
||||
phutil_require_module('phutil', 'markup/engine/remarkup/blockrule/remarkuplist');
|
||||
phutil_require_module('phutil', 'markup/engine/remarkup/markuprule/bold');
|
||||
phutil_require_module('phutil', 'markup/engine/remarkup/markuprule/escapehtml');
|
||||
phutil_require_module('phutil', 'markup/engine/remarkup/markuprule/escaperemarkup');
|
||||
phutil_require_module('phutil', 'markup/engine/remarkup/markuprule/hyperlink');
|
||||
phutil_require_module('phutil', 'markup/engine/remarkup/markuprule/italics');
|
||||
phutil_require_module('phutil', 'markup/engine/remarkup/markuprule/monospace');
|
||||
|
||||
|
||||
phutil_require_source('DifferentialMarkupEngineFactory.php');
|
|
@ -69,6 +69,12 @@ class DifferentialRevision extends DifferentialDAO {
|
|||
$this->getID());
|
||||
}
|
||||
|
||||
public function loadActiveDiff() {
|
||||
return id(new DifferentialDiff())->loadOneWhere(
|
||||
'revisionID = %d ORDER BY id DESC LIMIT 1',
|
||||
$this->getID());
|
||||
}
|
||||
|
||||
public function loadRelationships() {
|
||||
if (!$this->getID()) {
|
||||
$this->relationships = array();
|
||||
|
|
|
@ -20,6 +20,7 @@ final class DifferentialRevisionCommentView extends AphrontView {
|
|||
|
||||
private $comment;
|
||||
private $handles;
|
||||
private $markupEngine;
|
||||
|
||||
public function setComment($comment) {
|
||||
$this->comment = $comment;
|
||||
|
@ -31,8 +32,14 @@ final class DifferentialRevisionCommentView extends AphrontView {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function setMarkupEngine($markup_engine) {
|
||||
$this->markupEngine = $markup_engine;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
require_celerity_resource('phabricator-remarkup-css');
|
||||
require_celerity_resource('differential-revision-comment-css');
|
||||
|
||||
$comment = $this->comment;
|
||||
|
@ -52,7 +59,10 @@ final class DifferentialRevisionCommentView extends AphrontView {
|
|||
$content = $comment->getContent();
|
||||
if (strlen(rtrim($content))) {
|
||||
$title = "{$author} {$verb} this revision:";
|
||||
$content = phutil_escape_html($content);
|
||||
$content =
|
||||
'<div class="phabricator-remarkup">'.
|
||||
$this->markupEngine->markupText($content).
|
||||
'</div>';
|
||||
} else {
|
||||
$title = null;
|
||||
$content =
|
||||
|
|
|
@ -35,11 +35,15 @@ final class DifferentialRevisionCommentListView extends AphrontView {
|
|||
|
||||
require_celerity_resource('differential-revision-comment-list-css');
|
||||
|
||||
$factory = new DifferentialMarkupEngineFactory();
|
||||
$engine = $factory->newDifferentialCommentMarkupEngine();
|
||||
|
||||
$comments = array();
|
||||
foreach ($this->comments as $comment) {
|
||||
$view = new DifferentialRevisionCommentView();
|
||||
$view->setComment($comment);
|
||||
$view->setHandles($this->handles);
|
||||
$view->setMarkupEngine($engine);
|
||||
|
||||
$comments[] = $view->render();
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/differential/parser/markup');
|
||||
phutil_require_module('phabricator', 'applications/differential/view/revisioncomment');
|
||||
phutil_require_module('phabricator', 'infratructure/celerity/api');
|
||||
phutil_require_module('phabricator', 'view/base');
|
||||
|
|
|
@ -37,3 +37,58 @@
|
|||
margin: 0em;
|
||||
padding: .3em 5px .4em 1.25em;
|
||||
}
|
||||
|
||||
.differential-comment-content code {
|
||||
width: 88ex;
|
||||
width: 81ch;
|
||||
}
|
||||
|
||||
.differential-comment-nocontent {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.differential-comment-action-testplan .differential-comment-content {
|
||||
border-color: #660099;
|
||||
background: #f6f3ff;
|
||||
}
|
||||
|
||||
.differential-comment-action-abandon .differential-comment-content {
|
||||
border-color: #222222;
|
||||
background: #f3f3f3;
|
||||
}
|
||||
|
||||
.differential-comment-action-accept .differential-comment-content {
|
||||
border-color: #009966;
|
||||
background: #f3fff3;
|
||||
}
|
||||
|
||||
.differential-comment-action-reject .differential-comment-content {
|
||||
border-color: #aa0000;
|
||||
background: #fff3f3;
|
||||
}
|
||||
|
||||
.differential-comment-action-commit .differential-comment-content {
|
||||
border-color: #006699;
|
||||
background: #f3f3ff;
|
||||
}
|
||||
|
||||
|
||||
.differential-comment-action-reclaim .differential-comment-content {
|
||||
border-color: #0099aa;
|
||||
background: #f3fff9;
|
||||
}
|
||||
|
||||
.differential-comment-action-update .differential-comment-content {
|
||||
border-color: #6699cc;
|
||||
background: #f3f9ff;
|
||||
}
|
||||
|
||||
.differential-comment-action-add_reviewers .differential-comment-content {
|
||||
border-color: #aa99cc;
|
||||
background: #f9f3ff;
|
||||
}
|
||||
|
||||
.differential-comment-action-request_review .differential-comment-content {
|
||||
border-color: #cc9966;
|
||||
background: #fff9f3;
|
||||
}
|
||||
|
|
30
webroot/rsrc/css/core/remarkup.css
Normal file
30
webroot/rsrc/css/core/remarkup.css
Normal file
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* @provides phabricator-remarkup-css
|
||||
*/
|
||||
|
||||
.phabricator-remarkup p {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
.phabricator-remarkup code {
|
||||
background: #fdfae7;
|
||||
border: 1px solid #f5e178;
|
||||
display: block;
|
||||
white-space: pre;
|
||||
font-family: "Monaco", monospace;
|
||||
font-size: 10px;
|
||||
color: #000000;
|
||||
margin: 1em 2em;
|
||||
padding: .5em 1.5em;
|
||||
}
|
||||
|
||||
.phabricator-remarkup code.remarkup-counterexample {
|
||||
border: 1px solid #aa0000;
|
||||
background-color: #ffaaaa;
|
||||
}
|
||||
|
||||
.phabricator-remarkup ul {
|
||||
list-style: disc;
|
||||
margin: 1em 0 1em 3em;
|
||||
}
|
||||
|
Loading…
Reference in a new issue