@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Legalpad - add a preview to document create / edit

Summary: 'cuz legal documents be long! Fixes T4382.

Test Plan: created / edited a document and got working preview

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T3482

Differential Revision: https://secure.phabricator.com/D6386

+101
+13
src/__celerity_resource_map__.php
··· 1765 1765 ), 1766 1766 'disk' => '/rsrc/js/core/behavior-konami.js', 1767 1767 ), 1768 + 'javelin-behavior-legalpad-document-preview' => 1769 + array( 1770 + 'uri' => '/res/d0ce5a8c/rsrc/js/application/legalpad/legalpad-document-preview.js', 1771 + 'type' => 'js', 1772 + 'requires' => 1773 + array( 1774 + 0 => 'javelin-behavior', 1775 + 1 => 'javelin-dom', 1776 + 2 => 'javelin-util', 1777 + 3 => 'phabricator-shaped-request', 1778 + ), 1779 + 'disk' => '/rsrc/js/application/legalpad/legalpad-document-preview.js', 1780 + ), 1768 1781 'javelin-behavior-lightbox-attachments' => 1769 1782 array( 1770 1783 'uri' => '/res/72b4d3a8/rsrc/js/core/behavior-lightbox-attachments.js',
+2
src/__phutil_library_map__.php
··· 640 640 'LegalpadDocumentEditController' => 'applications/legalpad/controller/LegalpadDocumentEditController.php', 641 641 'LegalpadDocumentEditor' => 'applications/legalpad/editor/LegalpadDocumentEditor.php', 642 642 'LegalpadDocumentListController' => 'applications/legalpad/controller/LegalpadDocumentListController.php', 643 + 'LegalpadDocumentPreviewController' => 'applications/legalpad/controller/LegalpadDocumentPreviewController.php', 643 644 'LegalpadDocumentQuery' => 'applications/legalpad/query/LegalpadDocumentQuery.php', 644 645 'LegalpadDocumentSearchEngine' => 'applications/legalpad/query/LegalpadDocumentSearchEngine.php', 645 646 'LegalpadDocumentSignature' => 'applications/legalpad/storage/LegalpadDocumentSignature.php', ··· 2572 2573 0 => 'LegalpadController', 2573 2574 1 => 'PhabricatorApplicationSearchResultsControllerInterface', 2574 2575 ), 2576 + 'LegalpadDocumentPreviewController' => 'LegalpadController', 2575 2577 'LegalpadDocumentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 2576 2578 'LegalpadDocumentSearchEngine' => 'PhabricatorApplicationSearchEngine', 2577 2579 'LegalpadDocumentSignature' => 'LegalpadDAO',
+2
src/applications/legalpad/application/PhabricatorApplicationLegalpad.php
··· 48 48 'edit/(?P<id>\d+)/' => 'LegalpadDocumentEditController', 49 49 'comment/(?P<id>\d+)/' => 'LegalpadDocumentCommentController', 50 50 'view/(?P<id>\d+)/' => 'LegalpadDocumentViewController', 51 + 'document/' => array( 52 + 'preview/' => 'LegalpadDocumentPreviewController'), 51 53 )); 52 54 } 53 55
+25
src/applications/legalpad/controller/LegalpadDocumentEditController.php
··· 115 115 ->setUser($user) 116 116 ->appendChild( 117 117 id(new AphrontFormTextControl()) 118 + ->setID('document-title') 118 119 ->setLabel(pht('Title')) 119 120 ->setError($e_title) 120 121 ->setValue($title) 121 122 ->setName('title')) 122 123 ->appendChild( 123 124 id(new PhabricatorRemarkupControl()) 125 + ->setID('document-text') 124 126 ->setLabel(pht('Text')) 125 127 ->setError($e_text) 126 128 ->setValue($text) ··· 168 170 $crumbs->addCrumb( 169 171 id(new PhabricatorCrumbView())->setName($short)); 170 172 173 + $preview_header = id(new PhabricatorHeaderView()) 174 + ->setHeader(pht('Document Preview')); 175 + $preview_view = phutil_tag( 176 + 'div', 177 + array( 178 + 'id' => 'document-preview'), 179 + phutil_tag( 180 + 'div', 181 + array( 182 + 'class' => 'aphront-panel-preview-loading-text'), 183 + pht('Loading preview...'))); 184 + $preview_panel = id(new PHUIDocumentView()) 185 + ->appendChild($preview_header) 186 + ->appendChild($preview_view); 187 + Javelin::initBehavior( 188 + 'legalpad-document-preview', 189 + array( 190 + 'preview' => 'document-preview', 191 + 'title' => 'document-title', 192 + 'text' => 'document-text', 193 + 'uri' => $this->getApplicationURI('document/preview/'))); 194 + 171 195 return $this->buildApplicationPage( 172 196 array( 173 197 $crumbs, 174 198 $error_view, 175 199 $form, 200 + $preview_panel 176 201 ), 177 202 array( 178 203 'title' => $title,
+26
src/applications/legalpad/controller/LegalpadDocumentPreviewController.php
··· 1 + <?php 2 + 3 + /** 4 + * @group legalpad 5 + */ 6 + final class LegalpadDocumentPreviewController 7 + extends LegalpadController { 8 + 9 + public function processRequest() { 10 + $request = $this->getRequest(); 11 + $user = $request->getUser(); 12 + $text = $request->getStr('text'); 13 + 14 + $body = id(new LegalpadDocumentBody()) 15 + ->setText($text); 16 + 17 + $content = PhabricatorMarkupEngine::renderOneObject( 18 + $body, 19 + LegalpadDocumentBody::MARKUP_FIELD_TEXT, 20 + $user); 21 + 22 + $content = hsprintf('<div class="phabricator-remarkup">%s</div>', $content); 23 + 24 + return id(new AphrontAjaxResponse())->setContent($content); 25 + } 26 + }
+33
webroot/rsrc/js/application/legalpad/legalpad-document-preview.js
··· 1 + /** 2 + * @provides javelin-behavior-legalpad-document-preview 3 + * @requires javelin-behavior 4 + * javelin-dom 5 + * javelin-util 6 + * phabricator-shaped-request 7 + */ 8 + 9 + JX.behavior('legalpad-document-preview', function(config) { 10 + 11 + var preview = JX.$(config.preview); 12 + var title = JX.$(config.title); 13 + var text = JX.$(config.text); 14 + 15 + var callback = function(r) { 16 + JX.DOM.setContent(JX.$(config.preview), JX.$H(r)); 17 + }; 18 + 19 + var getdata = function() { 20 + return { 21 + title : title.value, 22 + text : text.value 23 + }; 24 + }; 25 + 26 + var request = new JX.PhabricatorShapedRequest(config.uri, callback, getdata); 27 + var trigger = JX.bind(request, request.trigger); 28 + 29 + JX.DOM.listen(title, 'keydown', null, trigger); 30 + JX.DOM.listen(text, 'keydown', null, trigger); 31 + request.start(); 32 + 33 + });