From d7bc58253073767139c8a39e17607e2b02bba29b Mon Sep 17 00:00:00 2001 From: Chad Little Date: Thu, 8 Sep 2016 18:46:19 -0700 Subject: [PATCH] Printable pages for PHUIDocumentViewPro Summary: Fixes T10131. Adds new CSS to better present document pages for printing. Added a print link to Phriction. Test Plan: Tested Phriction, Phame, and Legalpad. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T10131 Differential Revision: https://secure.phabricator.com/D16524 --- resources/celerity/map.php | 10 ++++---- .../PhrictionDocumentController.php | 23 +++++++++++++----- webroot/rsrc/css/phui/phui-crumbs-view.css | 4 ++++ webroot/rsrc/css/phui/phui-document-pro.css | 24 +++++++++++++++++++ 4 files changed, 50 insertions(+), 11 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 831821ab60..607c86f5e9 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -7,7 +7,7 @@ */ return array( 'names' => array( - 'core.pkg.css' => '85a1b79a', + 'core.pkg.css' => 'f7796100', 'core.pkg.js' => '1d376fa9', 'darkconsole.pkg.js' => 'e7393ebb', 'differential.pkg.css' => '3fb7f532', @@ -128,9 +128,9 @@ return array( 'rsrc/css/phui/phui-button.css' => '4a5fbe3d', 'rsrc/css/phui/phui-chart.css' => '6bf6f78e', 'rsrc/css/phui/phui-cms.css' => 'be43c8a8', - 'rsrc/css/phui/phui-crumbs-view.css' => '9dac418c', + 'rsrc/css/phui/phui-crumbs-view.css' => '195ac419', 'rsrc/css/phui/phui-curtain-view.css' => '947bf1a4', - 'rsrc/css/phui/phui-document-pro.css' => 'dc3d46ed', + 'rsrc/css/phui/phui-document-pro.css' => 'ca1fed81', 'rsrc/css/phui/phui-document-summary.css' => '9ca48bdf', 'rsrc/css/phui/phui-document.css' => 'c32e8dec', 'rsrc/css/phui/phui-feed-story.css' => 'aa49845d', @@ -834,11 +834,11 @@ return array( 'phui-calendar-month-css' => '8e10e92c', 'phui-chart-css' => '6bf6f78e', 'phui-cms-css' => 'be43c8a8', - 'phui-crumbs-view-css' => '9dac418c', + 'phui-crumbs-view-css' => '195ac419', 'phui-curtain-view-css' => '947bf1a4', 'phui-document-summary-view-css' => '9ca48bdf', 'phui-document-view-css' => 'c32e8dec', - 'phui-document-view-pro-css' => 'dc3d46ed', + 'phui-document-view-pro-css' => 'ca1fed81', 'phui-feed-story-css' => 'aa49845d', 'phui-font-icon-base-css' => '870a7360', 'phui-fontkit-css' => '9cda225e', diff --git a/src/applications/phriction/controller/PhrictionDocumentController.php b/src/applications/phriction/controller/PhrictionDocumentController.php index 7601888987..e455bd86d1 100644 --- a/src/applications/phriction/controller/PhrictionDocumentController.php +++ b/src/applications/phriction/controller/PhrictionDocumentController.php @@ -306,12 +306,23 @@ final class PhrictionDocumentController ->setWorkflow(true)); } - return - $action_view->addAction( - id(new PhabricatorActionView()) - ->setName(pht('View History')) - ->setIcon('fa-list') - ->setHref(PhrictionDocument::getSlugURI($slug, 'history'))); + $action_view->addAction( + id(new PhabricatorActionView()) + ->setName(pht('View History')) + ->setIcon('fa-list') + ->setHref(PhrictionDocument::getSlugURI($slug, 'history'))); + + $print_uri = PhrictionDocument::getSlugURI($slug).'?__print__=1'; + + $action_view->addAction( + id(new PhabricatorActionView()) + ->setName(pht('Printable Page')) + ->setIcon('fa-print') + ->setOpenInNewWindow(true) + ->setHref($print_uri)); + + return $action_view; + } private function renderDocumentChildren($slug) { diff --git a/webroot/rsrc/css/phui/phui-crumbs-view.css b/webroot/rsrc/css/phui/phui-crumbs-view.css index 486ed1d5d3..3cf8013723 100644 --- a/webroot/rsrc/css/phui/phui-crumbs-view.css +++ b/webroot/rsrc/css/phui/phui-crumbs-view.css @@ -13,6 +13,10 @@ background-color: {$page.background}; } +.printable .phui-crumbs-view { + display: none; +} + .phui-crumbs-view, .phui-crumbs-view a.phui-crumb-view, .phui-crumbs-view a.phui-crumbs-action { diff --git a/webroot/rsrc/css/phui/phui-document-pro.css b/webroot/rsrc/css/phui/phui-document-pro.css index 1027d03a56..4d0dfbdefd 100644 --- a/webroot/rsrc/css/phui/phui-document-pro.css +++ b/webroot/rsrc/css/phui/phui-document-pro.css @@ -20,6 +20,26 @@ margin: 0 auto; } +body.printable { + background-color: #fff; +} + +.printable .phui-document-view-pro-box { + display: none; +} + +.printable .phui-document-container { + border: none; +} + +.printable .phui-document-container .phui-header-view .phui-header-subheader { + display: none; +} + +.printable .phui-document-container .phui-header-view .phui-header-col3 { + display: none; +} + .device .phui-document-view-pro-box { margin: 0 8px; } @@ -47,6 +67,10 @@ left: -36px; } +.printable .phui-document-view-pro a.phui-document-toc { + display: none; +} + a.button.phui-document-toc { display: inline-block; height: 16px;