Skip to content

Commit bf227f7

Browse files
committedNov 22, 2015
Update Phriction for PHUIDocumentViewPro
Summary: Moves Phriction to use PHUIDocumentViewPro Test Plan: Read lots of documents, tablet, mobile, and desktop. Check ToC, non ToC, Edit a Maniphest Task, New Phriction Document, edit Phriction Document. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T9826 Differential Revision: https://secure.phabricator.com/D14399
1 parent 9001d5d commit bf227f7

File tree

10 files changed

+108
-80
lines changed

10 files changed

+108
-80
lines changed
 

‎resources/celerity/map.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
return array(
99
'names' => array(
10-
'core.pkg.css' => 'e4f1ea81',
10+
'core.pkg.css' => '0689cd7e',
1111
'core.pkg.js' => '47dc9ebb',
1212
'darkconsole.pkg.js' => 'e7393ebb',
1313
'differential.pkg.css' => '2de124c9',
@@ -104,7 +104,7 @@
104104
'rsrc/css/application/tokens/tokens.css' => '3d0f239e',
105105
'rsrc/css/application/uiexample/example.css' => '528b19de',
106106
'rsrc/css/core/core.css' => '78e8d7ea',
107-
'rsrc/css/core/remarkup.css' => '2193fc05',
107+
'rsrc/css/core/remarkup.css' => 'ab2396c1',
108108
'rsrc/css/core/syntax.css' => '9fd11da8',
109109
'rsrc/css/core/z-index.css' => '57ddcaa2',
110110
'rsrc/css/diviner/diviner-shared.css' => 'aa3656aa',
@@ -126,10 +126,10 @@
126126
'rsrc/css/phui/phui-box.css' => 'a5bb366d',
127127
'rsrc/css/phui/phui-button.css' => '16020a60',
128128
'rsrc/css/phui/phui-crumbs-view.css' => '414406b5',
129-
'rsrc/css/phui/phui-document-pro.css' => '7f3009ce',
130-
'rsrc/css/phui/phui-document.css' => 'f841ad0a',
129+
'rsrc/css/phui/phui-document-pro.css' => '5f75ed99',
130+
'rsrc/css/phui/phui-document.css' => '765a9dac',
131131
'rsrc/css/phui/phui-feed-story.css' => 'b7b26d23',
132-
'rsrc/css/phui/phui-fontkit.css' => 'c9d63950',
132+
'rsrc/css/phui/phui-fontkit.css' => '9cda225e',
133133
'rsrc/css/phui/phui-form-view.css' => '621b21c5',
134134
'rsrc/css/phui/phui-form.css' => 'afdb2c6e',
135135
'rsrc/css/phui/phui-header-view.css' => '55bb32dd',
@@ -747,7 +747,7 @@
747747
'phabricator-object-selector-css' => '85ee8ce6',
748748
'phabricator-phtize' => 'd254d646',
749749
'phabricator-prefab' => '6920d200',
750-
'phabricator-remarkup-css' => '2193fc05',
750+
'phabricator-remarkup-css' => 'ab2396c1',
751751
'phabricator-search-results-css' => '7dea472c',
752752
'phabricator-shaped-request' => '7cbe244b',
753753
'phabricator-side-menu-view-css' => 'bec2458e',
@@ -787,11 +787,11 @@
787787
'phui-calendar-list-css' => 'c1c7f338',
788788
'phui-calendar-month-css' => '476be7e0',
789789
'phui-crumbs-view-css' => '414406b5',
790-
'phui-document-view-css' => 'f841ad0a',
791-
'phui-document-view-pro-css' => '7f3009ce',
790+
'phui-document-view-css' => '765a9dac',
791+
'phui-document-view-pro-css' => '5f75ed99',
792792
'phui-feed-story-css' => 'b7b26d23',
793793
'phui-font-icon-base-css' => 'ecbbb4c2',
794-
'phui-fontkit-css' => 'c9d63950',
794+
'phui-fontkit-css' => '9cda225e',
795795
'phui-form-css' => 'afdb2c6e',
796796
'phui-form-view-css' => '621b21c5',
797797
'phui-header-view-css' => '55bb32dd',

‎src/applications/phriction/controller/PhrictionDocumentController.php

+26-6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function handleRequest(AphrontRequest $request) {
3232
$move_notice = '';
3333
$properties = null;
3434
$content = null;
35+
$toc = null;
3536

3637
if (!$document) {
3738

@@ -53,6 +54,7 @@ public function handleRequest(AphrontRequest $request) {
5354
$page_title = pht('Page Not Found');
5455
} else {
5556
$version = $request->getInt('v');
57+
5658
if ($version) {
5759
$content = id(new PhrictionContent())->loadOneWhere(
5860
'documentID = %d AND version = %d',
@@ -74,7 +76,6 @@ public function handleRequest(AphrontRequest $request) {
7476
$content = id(new PhrictionContent())->load($document->getContentID());
7577
}
7678
$page_title = $content->getTitle();
77-
7879
$properties = $this
7980
->buildPropertyListView($document, $content, $slug);
8081

@@ -84,6 +85,8 @@ public function handleRequest(AphrontRequest $request) {
8485
$current_status == PhrictionChangeType::CHANGE_MOVE_HERE) {
8586

8687
$core_content = $content->renderContent($viewer);
88+
$toc = $this->getToc($content);
89+
8790
} else if ($current_status == PhrictionChangeType::CHANGE_DELETE) {
8891
$notice = new PHUIInfoView();
8992
$notice->setSeverity(PHUIInfoView::SEVERITY_NOTICE);
@@ -102,7 +105,6 @@ public function handleRequest(AphrontRequest $request) {
102105
$core_content = $notice->render();
103106
} else if ($current_status == PhrictionChangeType::CHANGE_MOVE_AWAY) {
104107
$new_doc_id = $content->getChangeRef();
105-
106108
$slug_uri = null;
107109

108110
// If the new document exists and the viewer can see it, provide a link
@@ -212,11 +214,12 @@ public function handleRequest(AphrontRequest $request) {
212214
$prop_list->addPropertyList($properties);
213215
}
214216

215-
$page_content = id(new PHUIDocumentView())
217+
$page_content = id(new PHUIDocumentViewPro())
216218
->setHeader($header)
219+
->setPropertyList($prop_list)
220+
->setToc($toc)
217221
->appendChild(
218222
array(
219-
$prop_list,
220223
$version_note,
221224
$move_notice,
222225
$core_content,
@@ -230,7 +233,8 @@ public function handleRequest(AphrontRequest $request) {
230233
),
231234
array(
232235
'pageObjects' => array($document->getPHID()),
233-
'title' => $page_title,
236+
'title' => $page_title,
237+
'class' => 'pro-white-background',
234238
));
235239

236240
}
@@ -278,20 +282,23 @@ private function buildActionView(
278282
$action_view->addAction(
279283
id(new PhabricatorActionView())
280284
->setName(pht('Edit Document'))
285+
->setDisabled(!$can_edit)
281286
->setIcon('fa-pencil')
282287
->setHref('/phriction/edit/'.$document->getID().'/'));
283288

284289
if ($document->getStatus() == PhrictionDocumentStatus::STATUS_EXISTS) {
285290
$action_view->addAction(
286291
id(new PhabricatorActionView())
287292
->setName(pht('Move Document'))
293+
->setDisabled(!$can_edit)
288294
->setIcon('fa-arrows')
289295
->setHref('/phriction/move/'.$document->getID().'/')
290296
->setWorkflow(true));
291297

292298
$action_view->addAction(
293299
id(new PhabricatorActionView())
294300
->setName(pht('Delete Document'))
301+
->setDisabled(!$can_edit)
295302
->setIcon('fa-times')
296303
->setHref('/phriction/delete/'.$document->getID().'/')
297304
->setWorkflow(true));
@@ -431,7 +438,7 @@ private function renderDocumentChildren($slug) {
431438
),
432439
$list)));
433440

434-
return phutil_tag_div('phui-document-box', $box);
441+
return phutil_tag_div('phui-document-view-pro-box', $box);
435442
}
436443

437444
private function renderChildDocumentLink(array $info) {
@@ -454,4 +461,17 @@ protected function getDocumentSlug() {
454461
return $this->slug;
455462
}
456463

464+
protected function getToc(PhrictionContent $content) {
465+
$toc = $content->getRenderedTableOfContents();
466+
if ($toc) {
467+
$toc = phutil_tag_div('phui-document-toc-content', array(
468+
phutil_tag_div(
469+
'phui-document-toc-header',
470+
pht('Contents')),
471+
$toc,
472+
));
473+
}
474+
return $toc;
475+
}
476+
457477
}

‎src/applications/phriction/controller/PhrictionEditController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,10 @@ public function handleRequest(AphrontRequest $request) {
268268
->setForm($form);
269269

270270
$preview = id(new PHUIRemarkupPreviewPanel())
271-
->setHeader(pht('Document Preview'))
271+
->setHeader($content->getTitle())
272272
->setPreviewURI('/phriction/preview/')
273273
->setControlID('document-textarea')
274-
->addClass('phui-document-view');
274+
->setPreviewType(PHUIRemarkupPreviewPanel::DOCUMENT);
275275

276276
$crumbs = $this->buildApplicationCrumbs();
277277
if ($document->getID()) {

‎src/applications/phriction/storage/PhrictionContent.php

+15-16
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ final class PhrictionContent extends PhrictionDAO
1717
protected $slug;
1818
protected $content;
1919
protected $description;
20+
protected $renderedTableOfContents;
2021

2122
protected $changeType;
2223
protected $changeRef;
@@ -98,27 +99,25 @@ public function didMarkupText(
9899
$output,
99100
PhutilMarkupEngine $engine) {
100101

101-
$classes = array();
102-
$classes[] = 'phabricator-remarkup';
103-
$toc = PhutilRemarkupHeaderBlockRule::renderTableOfContents(
104-
$engine);
105-
106-
if ($toc) {
107-
$classes[] = 'remarkup-has-toc';
108-
$toc = phutil_tag_div('phabricator-remarkup-toc', array(
109-
phutil_tag_div(
110-
'phabricator-remarkup-toc-header',
111-
pht('Table of Contents')),
112-
$toc,
113-
));
114-
}
102+
$this->renderedTableOfContents =
103+
PhutilRemarkupHeaderBlockRule::renderTableOfContents($engine);
115104

116105
return phutil_tag(
117106
'div',
118107
array(
119-
'class' => implode(' ', $classes),
108+
'class' => 'phabricator-remarkup',
120109
),
121-
array($toc, $output));
110+
$output);
111+
}
112+
113+
/**
114+
* @task markup
115+
*/
116+
public function getRenderedTableOfContents() {
117+
if ($this->renderedTableOfContents === null) {
118+
throw new PhutilInvalidStateException('didMarkupText');
119+
}
120+
return $this->renderedTableOfContents;
122121
}
123122

124123

‎src/view/phui/PHUIDocumentViewPro.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function setPropertyList($view) {
3131
return $this;
3232
}
3333

34-
public function setToc(PHUIListView $toc) {
34+
public function setToc($toc) {
3535
$this->toc = $toc;
3636
return $this;
3737
}

‎src/view/phui/PHUIRemarkupPreviewPanel.php

+28-11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ final class PHUIRemarkupPreviewPanel extends AphrontTagView {
99
private $loadingText;
1010
private $controlID;
1111
private $previewURI;
12+
private $previewType;
13+
14+
const DOCUMENT = 'document';
1215

1316
protected function canAppendChild() {
1417
return false;
@@ -34,6 +37,11 @@ public function setLoadingText($loading_text) {
3437
return $this;
3538
}
3639

40+
public function setPreviewType($type) {
41+
$this->previewType = $type;
42+
return $this;
43+
}
44+
3745
protected function getTagName() {
3846
return 'div';
3947
}
@@ -73,16 +81,6 @@ protected function getTagContent() {
7381
),
7482
nonempty($this->loadingText, pht('Loading preview...')));
7583

76-
$header = null;
77-
if ($this->header) {
78-
$header = phutil_tag(
79-
'div',
80-
array(
81-
'class' => 'phui-preview-header',
82-
),
83-
$this->header);
84-
}
85-
8684
$preview = phutil_tag(
8785
'div',
8886
array(
@@ -91,7 +89,26 @@ protected function getTagContent() {
9189
),
9290
$loading);
9391

94-
$content = array($header, $preview);
92+
if (!$this->previewType) {
93+
$header = null;
94+
if ($this->header) {
95+
$header = phutil_tag(
96+
'div',
97+
array(
98+
'class' => 'phui-preview-header',
99+
),
100+
$this->header);
101+
}
102+
$content = array($header, $preview);
103+
104+
} else if ($this->previewType == self::DOCUMENT) {
105+
$header = id(new PHUIHeaderView())
106+
->setHeader(pht('%s (Document Preview)', $this->header));
107+
108+
$content = id(new PHUIDocumentViewPro())
109+
->setHeader($header)
110+
->appendChild($preview);
111+
}
95112

96113
return id(new PHUIObjectBoxView())
97114
->appendChild($content)

‎webroot/rsrc/css/core/remarkup.css

+8-5
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,11 @@
155155
margin: 4px 0;
156156
}
157157

158-
.phabricator-remarkup .remarkup-header + .remarkup-header {
159-
margin-top: 0px;
158+
.phabricator-remarkup h3.remarkup-header + h4.remarkup-header {
159+
color: {$bluetext};
160+
font-weight: normal;
161+
margin-bottom: 16px;
162+
margin-top: -4px;
160163
}
161164

162165
.phabricator-remarkup blockquote {
@@ -363,12 +366,12 @@ body div.phabricator-remarkup.remarkup-has-toc
363366
padding-top: 0;
364367
}
365368

366-
body .phabricator-remarkup > *:first-child,
367-
body .phabricator-remarkup .remarkup-header + * {
369+
body .phabricator-standard-page div.phabricator-remarkup *:first-child,
370+
body .phabricator-standard-page div.phabricator-remarkup .remarkup-header + * {
368371
margin-top: 0;
369372
}
370373

371-
body .phabricator-remarkup *:last-child {
374+
body div.phabricator-remarkup *:last-child {
372375
margin-bottom: 0;
373376
}
374377

‎webroot/rsrc/css/phui/phui-document-pro.css

+14
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,20 @@ a.button.phui-document-toc {
7373
color: #fff;
7474
}
7575

76+
.phui-document-view-pro .phui-document-toc-content {
77+
margin: 4px 12px;
78+
}
79+
80+
.phui-document-view-pro .phui-document-toc-header {
81+
font-weight: bold;
82+
color: {$bluetext};
83+
margin-bottom: 8px;
84+
}
85+
86+
.phui-document-view-pro .phui-document-toc-content li {
87+
margin: 4px 8px;
88+
}
89+
7690
.phui-document-view-pro .phui-document-content .phabricator-remarkup {
7791
padding: 16px 0;
7892
line-height: 1.7em;

0 commit comments

Comments
 (0)
Failed to load comments.