From 5e486db59d651dc387035dd773891b9deff7d756 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 6 Jan 2012 09:08:59 -0800 Subject: [PATCH] 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 --- src/__celerity_resource_map__.php | 222 +++++++++--------- .../markup/engine/PhabricatorMarkupEngine.php | 2 + .../document/PhrictionDocumentController.php | 8 +- .../controller/document/__init__.php | 1 - .../PhrictionDocumentPreviewController.php | 10 +- .../controller/documentpreview/__init__.php | 1 + .../storage/content/PhrictionContent.php | 25 +- .../phriction/storage/content/__init__.php | 3 + .../storage/document/PhrictionDocument.php | 3 +- webroot/rsrc/css/core/remarkup.css | 32 +++ 10 files changed, 181 insertions(+), 126 deletions(-) diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index 8e5f53f5b1..29307de8a3 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -213,7 +213,7 @@ celerity_register_resource_map(array( ), 'differential-revision-comment-css' => array( - 'uri' => '/res/9fb8013b/rsrc/css/application/differential/revision-comment.css', + 'uri' => '/res/b6e10dee/rsrc/css/application/differential/revision-comment.css', 'type' => 'css', 'requires' => array( @@ -472,7 +472,7 @@ celerity_register_resource_map(array( ), 'javelin-behavior-differential-dropdown-menus' => 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', 'requires' => array( @@ -555,7 +555,7 @@ celerity_register_resource_map(array( ), 'javelin-behavior-differential-show-more' => 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', 'requires' => array( @@ -1419,7 +1419,7 @@ celerity_register_resource_map(array( ), 'phabricator-menu-item' => array( - 'uri' => '/res/cfd0a620/rsrc/js/application/core/DropdownMenuItem.js', + 'uri' => '/res/08d90375/rsrc/js/application/core/DropdownMenuItem.js', 'type' => 'js', 'requires' => array( @@ -1470,7 +1470,7 @@ celerity_register_resource_map(array( ), 'phabricator-remarkup-css' => array( - 'uri' => '/res/78f26382/rsrc/css/core/remarkup.css', + 'uri' => '/res/795fa8a9/rsrc/css/core/remarkup.css', 'type' => 'css', 'requires' => array( @@ -1707,54 +1707,6 @@ celerity_register_resource_map(array( 'uri' => '/res/pkg/03ef179e/diffusion.pkg.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' => array( 'name' => 'core.pkg.js', @@ -1789,26 +1741,29 @@ celerity_register_resource_map(array( 'uri' => '/res/pkg/540effd7/typeahead.pkg.js', 'type' => 'js', ), - '8b139246' => + 'a6562582' => array( - 'name' => 'differential.pkg.css', + 'name' => 'differential.pkg.js', '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', + 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/8b139246/differential.pkg.css', - 'type' => 'css', + 'uri' => '/res/pkg/a6562582/differential.pkg.js', + 'type' => 'js', ), 'b164acea' => array( @@ -1829,46 +1784,91 @@ celerity_register_resource_map(array( 'uri' => '/res/pkg/b164acea/javelin.pkg.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' => array( - 'aphront-crumbs-view-css' => '11b55a5b', - 'aphront-dialog-view-css' => '11b55a5b', - 'aphront-form-view-css' => '11b55a5b', - 'aphront-headsup-action-list-view-css' => '8b139246', - 'aphront-list-filter-view-css' => '11b55a5b', - 'aphront-panel-view-css' => '11b55a5b', - 'aphront-side-nav-view-css' => '11b55a5b', - 'aphront-table-view-css' => '11b55a5b', - 'aphront-tokenizer-control-css' => '11b55a5b', - 'aphront-typeahead-control-css' => '11b55a5b', - 'differential-changeset-view-css' => '8b139246', - 'differential-core-view-css' => '8b139246', - 'differential-inline-comment-editor' => '11a5c52c', - 'differential-local-commits-view-css' => '8b139246', - 'differential-revision-add-comment-css' => '8b139246', - 'differential-revision-comment-css' => '8b139246', - 'differential-revision-comment-list-css' => '8b139246', - 'differential-revision-detail-css' => '8b139246', - 'differential-revision-history-css' => '8b139246', - 'differential-table-of-contents-css' => '8b139246', + 'aphront-crumbs-view-css' => 'bbf3d3f2', + 'aphront-dialog-view-css' => 'bbf3d3f2', + 'aphront-form-view-css' => 'bbf3d3f2', + 'aphront-headsup-action-list-view-css' => 'c9399497', + 'aphront-list-filter-view-css' => 'bbf3d3f2', + 'aphront-panel-view-css' => 'bbf3d3f2', + 'aphront-side-nav-view-css' => 'bbf3d3f2', + 'aphront-table-view-css' => 'bbf3d3f2', + 'aphront-tokenizer-control-css' => 'bbf3d3f2', + 'aphront-typeahead-control-css' => 'bbf3d3f2', + 'differential-changeset-view-css' => 'c9399497', + 'differential-core-view-css' => 'c9399497', + 'differential-inline-comment-editor' => 'a6562582', + 'differential-local-commits-view-css' => 'c9399497', + 'differential-revision-add-comment-css' => 'c9399497', + 'differential-revision-comment-css' => 'c9399497', + 'differential-revision-comment-list-css' => 'c9399497', + 'differential-revision-detail-css' => 'c9399497', + 'differential-revision-history-css' => 'c9399497', + 'differential-table-of-contents-css' => 'c9399497', 'diffusion-commit-view-css' => '03ef179e', 'javelin-behavior' => 'b164acea', 'javelin-behavior-aphront-basic-tokenizer' => '540effd7', - 'javelin-behavior-aphront-drag-and-drop' => '11a5c52c', - 'javelin-behavior-aphront-drag-and-drop-textarea' => '11a5c52c', + 'javelin-behavior-aphront-drag-and-drop' => 'a6562582', + 'javelin-behavior-aphront-drag-and-drop-textarea' => 'a6562582', 'javelin-behavior-aphront-form-disable-on-submit' => '46547a92', - 'javelin-behavior-differential-accept-with-errors' => '11a5c52c', - 'javelin-behavior-differential-add-reviewers-and-ccs' => '11a5c52c', - 'javelin-behavior-differential-comment-jump' => '11a5c52c', - 'javelin-behavior-differential-diff-radios' => '11a5c52c', - 'javelin-behavior-differential-edit-inline-comments' => '11a5c52c', - 'javelin-behavior-differential-feedback-preview' => '11a5c52c', - 'javelin-behavior-differential-keyboard-navigation' => '11a5c52c', - 'javelin-behavior-differential-populate' => '11a5c52c', - 'javelin-behavior-differential-show-more' => '11a5c52c', + 'javelin-behavior-differential-accept-with-errors' => 'a6562582', + 'javelin-behavior-differential-add-reviewers-and-ccs' => 'a6562582', + 'javelin-behavior-differential-comment-jump' => 'a6562582', + 'javelin-behavior-differential-diff-radios' => 'a6562582', + 'javelin-behavior-differential-edit-inline-comments' => 'a6562582', + 'javelin-behavior-differential-feedback-preview' => 'a6562582', + 'javelin-behavior-differential-keyboard-navigation' => 'a6562582', + 'javelin-behavior-differential-populate' => 'a6562582', + 'javelin-behavior-differential-show-more' => 'a6562582', '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-refresh-csrf' => '46547a92', 'javelin-behavior-workflow' => '46547a92', @@ -1889,17 +1889,17 @@ celerity_register_resource_map(array( 'javelin-util' => 'b164acea', 'javelin-vector' => 'b164acea', 'javelin-workflow' => '46547a92', - 'phabricator-content-source-view-css' => '8b139246', - 'phabricator-core-buttons-css' => '11b55a5b', - 'phabricator-core-css' => '11b55a5b', - 'phabricator-directory-css' => '11b55a5b', - 'phabricator-drag-and-drop-file-upload' => '11a5c52c', + 'phabricator-content-source-view-css' => 'c9399497', + 'phabricator-core-buttons-css' => 'bbf3d3f2', + 'phabricator-core-css' => 'bbf3d3f2', + 'phabricator-directory-css' => 'bbf3d3f2', + 'phabricator-drag-and-drop-file-upload' => 'a6562582', 'phabricator-keyboard-shortcut' => '46547a92', 'phabricator-keyboard-shortcut-manager' => '46547a92', - 'phabricator-object-selector-css' => '8b139246', - 'phabricator-remarkup-css' => '11b55a5b', - 'phabricator-shaped-request' => '11a5c52c', - 'phabricator-standard-page-view' => '11b55a5b', - 'syntax-highlighting-css' => '11b55a5b', + 'phabricator-object-selector-css' => 'c9399497', + 'phabricator-remarkup-css' => 'bbf3d3f2', + 'phabricator-shaped-request' => 'a6562582', + 'phabricator-standard-page-view' => 'bbf3d3f2', + 'syntax-highlighting-css' => 'bbf3d3f2', ), )); diff --git a/src/applications/markup/engine/PhabricatorMarkupEngine.php b/src/applications/markup/engine/PhabricatorMarkupEngine.php index efa01f5a4e..3f1a9f1f13 100644 --- a/src/applications/markup/engine/PhabricatorMarkupEngine.php +++ b/src/applications/markup/engine/PhabricatorMarkupEngine.php @@ -45,6 +45,7 @@ class PhabricatorMarkupEngine { // cache documents, and the module is prohibitively expensive for large // documents. 'macros' => false, + 'header.generate-toc' => true, )); } @@ -95,6 +96,7 @@ class PhabricatorMarkupEngine { 'uri.allowed-protocols', $options['uri.allowed-protocols']); $engine->setConfig('differential.diff', $options['differential.diff']); + $engine->setConfig('header.generate-toc', $options['header.generate-toc']); $rules = array(); $rules[] = new PhutilRemarkupRuleEscapeRemarkup(); diff --git a/src/applications/phriction/controller/document/PhrictionDocumentController.php b/src/applications/phriction/controller/document/PhrictionDocumentController.php index 581a27ff33..c74663d4d1 100644 --- a/src/applications/phriction/controller/document/PhrictionDocumentController.php +++ b/src/applications/phriction/controller/document/PhrictionDocumentController.php @@ -1,7 +1,7 @@ '; - $engine = PhabricatorMarkupEngine::newPhrictionMarkupEngine(); $doc_status = $document->getStatus(); if ($doc_status == PhrictionDocumentStatus::STATUS_EXISTS) { - $core_content = - '
'. - $engine->markupText($content->getContent()). - '
'; + $core_content = $content->renderContent(); } else if ($doc_status == PhrictionDocumentStatus::STATUS_DELETED) { $notice = new AphrontErrorView(); $notice->setSeverity(AphrontErrorView::SEVERITY_NOTICE); diff --git a/src/applications/phriction/controller/document/__init__.php b/src/applications/phriction/controller/document/__init__.php index e1951f08e5..c486bb7f96 100644 --- a/src/applications/phriction/controller/document/__init__.php +++ b/src/applications/phriction/controller/document/__init__.php @@ -8,7 +8,6 @@ phutil_require_module('phabricator', 'aphront/response/404'); 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/data'); phutil_require_module('phabricator', 'applications/phriction/constants/documentstatus'); diff --git a/src/applications/phriction/controller/documentpreview/PhrictionDocumentPreviewController.php b/src/applications/phriction/controller/documentpreview/PhrictionDocumentPreviewController.php index 6fa3243f18..412440eaad 100644 --- a/src/applications/phriction/controller/documentpreview/PhrictionDocumentPreviewController.php +++ b/src/applications/phriction/controller/documentpreview/PhrictionDocumentPreviewController.php @@ -1,7 +1,7 @@ getRequest(); $document = $request->getStr('document'); + $content_obj = new PhrictionContent(); + $content_obj->setContent($document); + $engine = PhabricatorMarkupEngine::newPhrictionMarkupEngine(); - $content = - '
'. - $engine->markupText($document). - '
'; + $content = $content_obj->renderContent(); return id(new AphrontAjaxResponse())->setContent($content); } diff --git a/src/applications/phriction/controller/documentpreview/__init__.php b/src/applications/phriction/controller/documentpreview/__init__.php index 69683874b5..b3287c8d5a 100644 --- a/src/applications/phriction/controller/documentpreview/__init__.php +++ b/src/applications/phriction/controller/documentpreview/__init__.php @@ -9,6 +9,7 @@ phutil_require_module('phabricator', 'aphront/response/ajax'); phutil_require_module('phabricator', 'applications/markup/engine'); phutil_require_module('phabricator', 'applications/phriction/controller/base'); +phutil_require_module('phabricator', 'applications/phriction/storage/content'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/phriction/storage/content/PhrictionContent.php b/src/applications/phriction/storage/content/PhrictionContent.php index 82c4145513..9e1c152fa3 100644 --- a/src/applications/phriction/storage/content/PhrictionContent.php +++ b/src/applications/phriction/storage/content/PhrictionContent.php @@ -1,7 +1,7 @@ markupText($this->getContent()); + + $toc = PhutilRemarkupEngineRemarkupHeaderBlockRule::renderTableOfContents( + $engine); + if ($toc) { + $toc = + '
'. + '
'. + 'Table of Contents'. + '
'. + $toc. + '
'; + } + + return + '
'. + $toc. + $markup. + '
'; + } + } diff --git a/src/applications/phriction/storage/content/__init__.php b/src/applications/phriction/storage/content/__init__.php index d43c31f418..b40b2c4f5c 100644 --- a/src/applications/phriction/storage/content/__init__.php +++ b/src/applications/phriction/storage/content/__init__.php @@ -6,7 +6,10 @@ +phutil_require_module('phabricator', 'applications/markup/engine'); phutil_require_module('phabricator', 'applications/phriction/storage/base'); +phutil_require_module('phutil', 'markup/engine/remarkup/blockrule/remarkupheader'); + phutil_require_source('PhrictionContent.php'); diff --git a/src/applications/phriction/storage/document/PhrictionDocument.php b/src/applications/phriction/storage/document/PhrictionDocument.php index 1ec22e7511..1a3abaf2d3 100644 --- a/src/applications/phriction/storage/document/PhrictionDocument.php +++ b/src/applications/phriction/storage/document/PhrictionDocument.php @@ -1,7 +1,7 @@