1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 21:02:41 +01:00

Enable Table of Contents in Phriction

Summary: Use the TOC stuff introduced in D1334.

Test Plan:
https://secure.phabricator.com/file/view/PHID-FILE-lttr6jszx2y2rqjpalr6/

Reviewers: btrahan, jungejason, davidreuss

Reviewed By: btrahan

CC: aran, btrahan

Differential Revision: https://secure.phabricator.com/D1335
This commit is contained in:
epriestley 2012-01-06 09:08:59 -08:00
parent 4579f23f63
commit 5e486db59d
10 changed files with 181 additions and 126 deletions

View file

@ -213,7 +213,7 @@ celerity_register_resource_map(array(
), ),
'differential-revision-comment-css' => 'differential-revision-comment-css' =>
array( array(
'uri' => '/res/9fb8013b/rsrc/css/application/differential/revision-comment.css', 'uri' => '/res/b6e10dee/rsrc/css/application/differential/revision-comment.css',
'type' => 'css', 'type' => 'css',
'requires' => 'requires' =>
array( array(
@ -472,7 +472,7 @@ celerity_register_resource_map(array(
), ),
'javelin-behavior-differential-dropdown-menus' => 'javelin-behavior-differential-dropdown-menus' =>
array( array(
'uri' => '/res/75ba0e7f/rsrc/js/application/differential/behavior-dropdown-menus.js', 'uri' => '/res/5a56f221/rsrc/js/application/differential/behavior-dropdown-menus.js',
'type' => 'js', 'type' => 'js',
'requires' => 'requires' =>
array( array(
@ -555,7 +555,7 @@ celerity_register_resource_map(array(
), ),
'javelin-behavior-differential-show-more' => 'javelin-behavior-differential-show-more' =>
array( array(
'uri' => '/res/eaaccd7a/rsrc/js/application/differential/behavior-show-more.js', 'uri' => '/res/68a8e485/rsrc/js/application/differential/behavior-show-more.js',
'type' => 'js', 'type' => 'js',
'requires' => 'requires' =>
array( array(
@ -1419,7 +1419,7 @@ celerity_register_resource_map(array(
), ),
'phabricator-menu-item' => 'phabricator-menu-item' =>
array( array(
'uri' => '/res/cfd0a620/rsrc/js/application/core/DropdownMenuItem.js', 'uri' => '/res/08d90375/rsrc/js/application/core/DropdownMenuItem.js',
'type' => 'js', 'type' => 'js',
'requires' => 'requires' =>
array( array(
@ -1470,7 +1470,7 @@ celerity_register_resource_map(array(
), ),
'phabricator-remarkup-css' => 'phabricator-remarkup-css' =>
array( array(
'uri' => '/res/78f26382/rsrc/css/core/remarkup.css', 'uri' => '/res/795fa8a9/rsrc/css/core/remarkup.css',
'type' => 'css', 'type' => 'css',
'requires' => 'requires' =>
array( array(
@ -1707,54 +1707,6 @@ celerity_register_resource_map(array(
'uri' => '/res/pkg/03ef179e/diffusion.pkg.css', 'uri' => '/res/pkg/03ef179e/diffusion.pkg.css',
'type' => 'css', 'type' => 'css',
), ),
'11a5c52c' =>
array(
'name' => 'differential.pkg.js',
'symbols' =>
array(
0 => 'phabricator-drag-and-drop-file-upload',
1 => 'phabricator-shaped-request',
2 => 'javelin-behavior-differential-feedback-preview',
3 => 'javelin-behavior-differential-edit-inline-comments',
4 => 'javelin-behavior-differential-populate',
5 => 'javelin-behavior-differential-show-more',
6 => 'javelin-behavior-differential-diff-radios',
7 => 'javelin-behavior-differential-accept-with-errors',
8 => 'javelin-behavior-differential-comment-jump',
9 => 'javelin-behavior-differential-add-reviewers-and-ccs',
10 => 'javelin-behavior-differential-keyboard-navigation',
11 => 'javelin-behavior-aphront-drag-and-drop',
12 => 'javelin-behavior-aphront-drag-and-drop-textarea',
13 => 'javelin-behavior-phabricator-object-selector',
14 => 'differential-inline-comment-editor',
),
'uri' => '/res/pkg/11a5c52c/differential.pkg.js',
'type' => 'js',
),
'11b55a5b' =>
array(
'name' => 'core.pkg.css',
'symbols' =>
array(
0 => 'phabricator-core-css',
1 => 'phabricator-core-buttons-css',
2 => 'phabricator-standard-page-view',
3 => 'aphront-dialog-view-css',
4 => 'aphront-form-view-css',
5 => 'aphront-panel-view-css',
6 => 'aphront-side-nav-view-css',
7 => 'aphront-table-view-css',
8 => 'aphront-crumbs-view-css',
9 => 'aphront-tokenizer-control-css',
10 => 'aphront-typeahead-control-css',
11 => 'aphront-list-filter-view-css',
12 => 'phabricator-directory-css',
13 => 'phabricator-remarkup-css',
14 => 'syntax-highlighting-css',
),
'uri' => '/res/pkg/11b55a5b/core.pkg.css',
'type' => 'css',
),
'46547a92' => '46547a92' =>
array( array(
'name' => 'core.pkg.js', 'name' => 'core.pkg.js',
@ -1789,26 +1741,29 @@ celerity_register_resource_map(array(
'uri' => '/res/pkg/540effd7/typeahead.pkg.js', 'uri' => '/res/pkg/540effd7/typeahead.pkg.js',
'type' => 'js', 'type' => 'js',
), ),
'8b139246' => 'a6562582' =>
array( array(
'name' => 'differential.pkg.css', 'name' => 'differential.pkg.js',
'symbols' => 'symbols' =>
array( array(
0 => 'differential-core-view-css', 0 => 'phabricator-drag-and-drop-file-upload',
1 => 'differential-changeset-view-css', 1 => 'phabricator-shaped-request',
2 => 'differential-revision-detail-css', 2 => 'javelin-behavior-differential-feedback-preview',
3 => 'differential-revision-history-css', 3 => 'javelin-behavior-differential-edit-inline-comments',
4 => 'differential-table-of-contents-css', 4 => 'javelin-behavior-differential-populate',
5 => 'differential-revision-comment-css', 5 => 'javelin-behavior-differential-show-more',
6 => 'differential-revision-add-comment-css', 6 => 'javelin-behavior-differential-diff-radios',
7 => 'differential-revision-comment-list-css', 7 => 'javelin-behavior-differential-accept-with-errors',
8 => 'phabricator-object-selector-css', 8 => 'javelin-behavior-differential-comment-jump',
9 => 'aphront-headsup-action-list-view-css', 9 => 'javelin-behavior-differential-add-reviewers-and-ccs',
10 => 'phabricator-content-source-view-css', 10 => 'javelin-behavior-differential-keyboard-navigation',
11 => 'differential-local-commits-view-css', 11 => 'javelin-behavior-aphront-drag-and-drop',
12 => 'javelin-behavior-aphront-drag-and-drop-textarea',
13 => 'javelin-behavior-phabricator-object-selector',
14 => 'differential-inline-comment-editor',
), ),
'uri' => '/res/pkg/8b139246/differential.pkg.css', 'uri' => '/res/pkg/a6562582/differential.pkg.js',
'type' => 'css', 'type' => 'js',
), ),
'b164acea' => 'b164acea' =>
array( array(
@ -1829,46 +1784,91 @@ celerity_register_resource_map(array(
'uri' => '/res/pkg/b164acea/javelin.pkg.js', 'uri' => '/res/pkg/b164acea/javelin.pkg.js',
'type' => 'js', 'type' => 'js',
), ),
'bbf3d3f2' =>
array(
'name' => 'core.pkg.css',
'symbols' =>
array(
0 => 'phabricator-core-css',
1 => 'phabricator-core-buttons-css',
2 => 'phabricator-standard-page-view',
3 => 'aphront-dialog-view-css',
4 => 'aphront-form-view-css',
5 => 'aphront-panel-view-css',
6 => 'aphront-side-nav-view-css',
7 => 'aphront-table-view-css',
8 => 'aphront-crumbs-view-css',
9 => 'aphront-tokenizer-control-css',
10 => 'aphront-typeahead-control-css',
11 => 'aphront-list-filter-view-css',
12 => 'phabricator-directory-css',
13 => 'phabricator-remarkup-css',
14 => 'syntax-highlighting-css',
),
'uri' => '/res/pkg/bbf3d3f2/core.pkg.css',
'type' => 'css',
),
'c9399497' =>
array(
'name' => 'differential.pkg.css',
'symbols' =>
array(
0 => 'differential-core-view-css',
1 => 'differential-changeset-view-css',
2 => 'differential-revision-detail-css',
3 => 'differential-revision-history-css',
4 => 'differential-table-of-contents-css',
5 => 'differential-revision-comment-css',
6 => 'differential-revision-add-comment-css',
7 => 'differential-revision-comment-list-css',
8 => 'phabricator-object-selector-css',
9 => 'aphront-headsup-action-list-view-css',
10 => 'phabricator-content-source-view-css',
11 => 'differential-local-commits-view-css',
),
'uri' => '/res/pkg/c9399497/differential.pkg.css',
'type' => 'css',
),
), ),
'reverse' => 'reverse' =>
array( array(
'aphront-crumbs-view-css' => '11b55a5b', 'aphront-crumbs-view-css' => 'bbf3d3f2',
'aphront-dialog-view-css' => '11b55a5b', 'aphront-dialog-view-css' => 'bbf3d3f2',
'aphront-form-view-css' => '11b55a5b', 'aphront-form-view-css' => 'bbf3d3f2',
'aphront-headsup-action-list-view-css' => '8b139246', 'aphront-headsup-action-list-view-css' => 'c9399497',
'aphront-list-filter-view-css' => '11b55a5b', 'aphront-list-filter-view-css' => 'bbf3d3f2',
'aphront-panel-view-css' => '11b55a5b', 'aphront-panel-view-css' => 'bbf3d3f2',
'aphront-side-nav-view-css' => '11b55a5b', 'aphront-side-nav-view-css' => 'bbf3d3f2',
'aphront-table-view-css' => '11b55a5b', 'aphront-table-view-css' => 'bbf3d3f2',
'aphront-tokenizer-control-css' => '11b55a5b', 'aphront-tokenizer-control-css' => 'bbf3d3f2',
'aphront-typeahead-control-css' => '11b55a5b', 'aphront-typeahead-control-css' => 'bbf3d3f2',
'differential-changeset-view-css' => '8b139246', 'differential-changeset-view-css' => 'c9399497',
'differential-core-view-css' => '8b139246', 'differential-core-view-css' => 'c9399497',
'differential-inline-comment-editor' => '11a5c52c', 'differential-inline-comment-editor' => 'a6562582',
'differential-local-commits-view-css' => '8b139246', 'differential-local-commits-view-css' => 'c9399497',
'differential-revision-add-comment-css' => '8b139246', 'differential-revision-add-comment-css' => 'c9399497',
'differential-revision-comment-css' => '8b139246', 'differential-revision-comment-css' => 'c9399497',
'differential-revision-comment-list-css' => '8b139246', 'differential-revision-comment-list-css' => 'c9399497',
'differential-revision-detail-css' => '8b139246', 'differential-revision-detail-css' => 'c9399497',
'differential-revision-history-css' => '8b139246', 'differential-revision-history-css' => 'c9399497',
'differential-table-of-contents-css' => '8b139246', 'differential-table-of-contents-css' => 'c9399497',
'diffusion-commit-view-css' => '03ef179e', 'diffusion-commit-view-css' => '03ef179e',
'javelin-behavior' => 'b164acea', 'javelin-behavior' => 'b164acea',
'javelin-behavior-aphront-basic-tokenizer' => '540effd7', 'javelin-behavior-aphront-basic-tokenizer' => '540effd7',
'javelin-behavior-aphront-drag-and-drop' => '11a5c52c', 'javelin-behavior-aphront-drag-and-drop' => 'a6562582',
'javelin-behavior-aphront-drag-and-drop-textarea' => '11a5c52c', 'javelin-behavior-aphront-drag-and-drop-textarea' => 'a6562582',
'javelin-behavior-aphront-form-disable-on-submit' => '46547a92', 'javelin-behavior-aphront-form-disable-on-submit' => '46547a92',
'javelin-behavior-differential-accept-with-errors' => '11a5c52c', 'javelin-behavior-differential-accept-with-errors' => 'a6562582',
'javelin-behavior-differential-add-reviewers-and-ccs' => '11a5c52c', 'javelin-behavior-differential-add-reviewers-and-ccs' => 'a6562582',
'javelin-behavior-differential-comment-jump' => '11a5c52c', 'javelin-behavior-differential-comment-jump' => 'a6562582',
'javelin-behavior-differential-diff-radios' => '11a5c52c', 'javelin-behavior-differential-diff-radios' => 'a6562582',
'javelin-behavior-differential-edit-inline-comments' => '11a5c52c', 'javelin-behavior-differential-edit-inline-comments' => 'a6562582',
'javelin-behavior-differential-feedback-preview' => '11a5c52c', 'javelin-behavior-differential-feedback-preview' => 'a6562582',
'javelin-behavior-differential-keyboard-navigation' => '11a5c52c', 'javelin-behavior-differential-keyboard-navigation' => 'a6562582',
'javelin-behavior-differential-populate' => '11a5c52c', 'javelin-behavior-differential-populate' => 'a6562582',
'javelin-behavior-differential-show-more' => '11a5c52c', 'javelin-behavior-differential-show-more' => 'a6562582',
'javelin-behavior-phabricator-keyboard-shortcuts' => '46547a92', 'javelin-behavior-phabricator-keyboard-shortcuts' => '46547a92',
'javelin-behavior-phabricator-object-selector' => '11a5c52c', 'javelin-behavior-phabricator-object-selector' => 'a6562582',
'javelin-behavior-phabricator-watch-anchor' => '46547a92', 'javelin-behavior-phabricator-watch-anchor' => '46547a92',
'javelin-behavior-refresh-csrf' => '46547a92', 'javelin-behavior-refresh-csrf' => '46547a92',
'javelin-behavior-workflow' => '46547a92', 'javelin-behavior-workflow' => '46547a92',
@ -1889,17 +1889,17 @@ celerity_register_resource_map(array(
'javelin-util' => 'b164acea', 'javelin-util' => 'b164acea',
'javelin-vector' => 'b164acea', 'javelin-vector' => 'b164acea',
'javelin-workflow' => '46547a92', 'javelin-workflow' => '46547a92',
'phabricator-content-source-view-css' => '8b139246', 'phabricator-content-source-view-css' => 'c9399497',
'phabricator-core-buttons-css' => '11b55a5b', 'phabricator-core-buttons-css' => 'bbf3d3f2',
'phabricator-core-css' => '11b55a5b', 'phabricator-core-css' => 'bbf3d3f2',
'phabricator-directory-css' => '11b55a5b', 'phabricator-directory-css' => 'bbf3d3f2',
'phabricator-drag-and-drop-file-upload' => '11a5c52c', 'phabricator-drag-and-drop-file-upload' => 'a6562582',
'phabricator-keyboard-shortcut' => '46547a92', 'phabricator-keyboard-shortcut' => '46547a92',
'phabricator-keyboard-shortcut-manager' => '46547a92', 'phabricator-keyboard-shortcut-manager' => '46547a92',
'phabricator-object-selector-css' => '8b139246', 'phabricator-object-selector-css' => 'c9399497',
'phabricator-remarkup-css' => '11b55a5b', 'phabricator-remarkup-css' => 'bbf3d3f2',
'phabricator-shaped-request' => '11a5c52c', 'phabricator-shaped-request' => 'a6562582',
'phabricator-standard-page-view' => '11b55a5b', 'phabricator-standard-page-view' => 'bbf3d3f2',
'syntax-highlighting-css' => '11b55a5b', 'syntax-highlighting-css' => 'bbf3d3f2',
), ),
)); ));

View file

@ -45,6 +45,7 @@ class PhabricatorMarkupEngine {
// cache documents, and the module is prohibitively expensive for large // cache documents, and the module is prohibitively expensive for large
// documents. // documents.
'macros' => false, 'macros' => false,
'header.generate-toc' => true,
)); ));
} }
@ -95,6 +96,7 @@ class PhabricatorMarkupEngine {
'uri.allowed-protocols', 'uri.allowed-protocols',
$options['uri.allowed-protocols']); $options['uri.allowed-protocols']);
$engine->setConfig('differential.diff', $options['differential.diff']); $engine->setConfig('differential.diff', $options['differential.diff']);
$engine->setConfig('header.generate-toc', $options['header.generate-toc']);
$rules = array(); $rules = array();
$rules[] = new PhutilRemarkupRuleEscapeRemarkup(); $rules[] = new PhutilRemarkupRuleEscapeRemarkup();

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -141,14 +141,10 @@ class PhrictionDocumentController
$project_info. $project_info.
'</div>'; '</div>';
$engine = PhabricatorMarkupEngine::newPhrictionMarkupEngine();
$doc_status = $document->getStatus(); $doc_status = $document->getStatus();
if ($doc_status == PhrictionDocumentStatus::STATUS_EXISTS) { if ($doc_status == PhrictionDocumentStatus::STATUS_EXISTS) {
$core_content = $core_content = $content->renderContent();
'<div class="phabricator-remarkup">'.
$engine->markupText($content->getContent()).
'</div>';
} else if ($doc_status == PhrictionDocumentStatus::STATUS_DELETED) { } else if ($doc_status == PhrictionDocumentStatus::STATUS_DELETED) {
$notice = new AphrontErrorView(); $notice = new AphrontErrorView();
$notice->setSeverity(AphrontErrorView::SEVERITY_NOTICE); $notice->setSeverity(AphrontErrorView::SEVERITY_NOTICE);

View file

@ -8,7 +8,6 @@
phutil_require_module('phabricator', 'aphront/response/404'); phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'aphront/response/redirect'); phutil_require_module('phabricator', 'aphront/response/redirect');
phutil_require_module('phabricator', 'applications/markup/engine');
phutil_require_module('phabricator', 'applications/phid/handle'); phutil_require_module('phabricator', 'applications/phid/handle');
phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'applications/phriction/constants/documentstatus'); phutil_require_module('phabricator', 'applications/phriction/constants/documentstatus');

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,11 +27,11 @@ class PhrictionDocumentPreviewController
$request = $this->getRequest(); $request = $this->getRequest();
$document = $request->getStr('document'); $document = $request->getStr('document');
$content_obj = new PhrictionContent();
$content_obj->setContent($document);
$engine = PhabricatorMarkupEngine::newPhrictionMarkupEngine(); $engine = PhabricatorMarkupEngine::newPhrictionMarkupEngine();
$content = $content = $content_obj->renderContent();
'<div class="phabricator-remarkup">'.
$engine->markupText($document).
'</div>';
return id(new AphrontAjaxResponse())->setContent($content); return id(new AphrontAjaxResponse())->setContent($content);
} }

View file

@ -9,6 +9,7 @@
phutil_require_module('phabricator', 'aphront/response/ajax'); phutil_require_module('phabricator', 'aphront/response/ajax');
phutil_require_module('phabricator', 'applications/markup/engine'); phutil_require_module('phabricator', 'applications/markup/engine');
phutil_require_module('phabricator', 'applications/phriction/controller/base'); phutil_require_module('phabricator', 'applications/phriction/controller/base');
phutil_require_module('phabricator', 'applications/phriction/storage/content');
phutil_require_module('phutil', 'utils'); phutil_require_module('phutil', 'utils');

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -34,4 +34,27 @@ class PhrictionContent extends PhrictionDAO {
protected $changeType; protected $changeType;
protected $changeRef; protected $changeRef;
public function renderContent() {
$engine = PhabricatorMarkupEngine::newPhrictionMarkupEngine();
$markup = $engine->markupText($this->getContent());
$toc = PhutilRemarkupEngineRemarkupHeaderBlockRule::renderTableOfContents(
$engine);
if ($toc) {
$toc =
'<div class="phabricator-remarkup-toc">'.
'<div class="phabricator-remarkup-toc-header">'.
'Table of Contents'.
'</div>'.
$toc.
'</div>';
}
return
'<div class="phabricator-remarkup">'.
$toc.
$markup.
'</div>';
}
} }

View file

@ -6,7 +6,10 @@
phutil_require_module('phabricator', 'applications/markup/engine');
phutil_require_module('phabricator', 'applications/phriction/storage/base'); phutil_require_module('phabricator', 'applications/phriction/storage/base');
phutil_require_module('phutil', 'markup/engine/remarkup/blockrule/remarkupheader');
phutil_require_source('PhrictionContent.php'); phutil_require_source('PhrictionContent.php');

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -155,5 +155,4 @@ class PhrictionDocument extends PhrictionDAO {
return $parts[1].'/'; return $parts[1].'/';
} }
} }

View file

@ -126,3 +126,35 @@
border: 1px solid #ddddff; border: 1px solid #ddddff;
background: #f3f3ff; background: #f3f3ff;
} }
.phabricator-remarkup-toc {
float: right;
border: 1px solid #999999;
background: #f9f9f9;
padding: 4px 12px;
width: 220px;
}
.phabricator-remarkup-toc-header {
font-size: 11px;
color: #444444;
border-bottom: 1px solid #bbbbbb;
margin-bottom: 4px;
}
.phabricator-remarkup-toc ul {
padding: 0;
margin: 0;
list-style: none;
overflow: hidden;
padding-left: 0.25em;
}
.phabricator-remarkup-toc ul ul {
margin-left: 1.25em;
}
.phabricator-remarkup-toc ul li {
padding: 0;
margin: 0;
}