@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.

Add printable support to CSS

Summary:
Fixes T2146. This is a really simple approach, you just do:

!print .rule {
whatever: blah;
}

And it transforms it into:

.printable .rule {
whatever: blah;
}

@media print {
.rule {
whatever: blah;
}
}

So we end up with these rules twice, but they should compress well and we shouldn't need that many of them, and this fix is way way simpler than all the nonsense I discussed in T2146.

Test Plan:
- Added a unit test.
- Added a simple rule to throw away the menubar when printing.
- Checked the latter with `/?__print__=1`.

Reviewers: chad, btrahan

Reviewed By: chad

CC: chad, aran

Maniphest Tasks: T2146

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

+92 -51
+46 -46
src/__celerity_resource_map__.php
··· 3342 3342 ), 3343 3343 'phabricator-main-menu-view' => 3344 3344 array( 3345 - 'uri' => '/res/ef11f2fc/rsrc/css/application/base/main-menu-view.css', 3345 + 'uri' => '/res/95ff522a/rsrc/css/application/base/main-menu-view.css', 3346 3346 'type' => 'css', 3347 3347 'requires' => 3348 3348 array( ··· 4309 4309 ), array( 4310 4310 'packages' => 4311 4311 array( 4312 - '71e32b00' => 4312 + 'c35f1eca' => 4313 4313 array( 4314 4314 'name' => 'core.pkg.css', 4315 4315 'symbols' => ··· 4358 4358 41 => 'phabricator-tag-view-css', 4359 4359 42 => 'phui-list-view-css', 4360 4360 ), 4361 - 'uri' => '/res/pkg/71e32b00/core.pkg.css', 4361 + 'uri' => '/res/pkg/c35f1eca/core.pkg.css', 4362 4362 'type' => 'css', 4363 4363 ), 4364 4364 '2c1dba03' => ··· 4550 4550 ), 4551 4551 'reverse' => 4552 4552 array( 4553 - 'aphront-dialog-view-css' => '71e32b00', 4554 - 'aphront-error-view-css' => '71e32b00', 4555 - 'aphront-list-filter-view-css' => '71e32b00', 4556 - 'aphront-pager-view-css' => '71e32b00', 4557 - 'aphront-panel-view-css' => '71e32b00', 4558 - 'aphront-table-view-css' => '71e32b00', 4559 - 'aphront-tokenizer-control-css' => '71e32b00', 4560 - 'aphront-tooltip-css' => '71e32b00', 4561 - 'aphront-typeahead-control-css' => '71e32b00', 4553 + 'aphront-dialog-view-css' => 'c35f1eca', 4554 + 'aphront-error-view-css' => 'c35f1eca', 4555 + 'aphront-list-filter-view-css' => 'c35f1eca', 4556 + 'aphront-pager-view-css' => 'c35f1eca', 4557 + 'aphront-panel-view-css' => 'c35f1eca', 4558 + 'aphront-table-view-css' => 'c35f1eca', 4559 + 'aphront-tokenizer-control-css' => 'c35f1eca', 4560 + 'aphront-tooltip-css' => 'c35f1eca', 4561 + 'aphront-typeahead-control-css' => 'c35f1eca', 4562 4562 'differential-changeset-view-css' => '7cd7e387', 4563 4563 'differential-core-view-css' => '7cd7e387', 4564 4564 'differential-inline-comment-editor' => '5e9e5c4e', ··· 4572 4572 'differential-table-of-contents-css' => '7cd7e387', 4573 4573 'diffusion-commit-view-css' => '270f4eb4', 4574 4574 'diffusion-icons-css' => '270f4eb4', 4575 - 'global-drag-and-drop-css' => '71e32b00', 4575 + 'global-drag-and-drop-css' => 'c35f1eca', 4576 4576 'inline-comment-summary-css' => '7cd7e387', 4577 4577 'javelin-aphlict' => '2c1dba03', 4578 4578 'javelin-behavior' => '3e3be199', ··· 4647 4647 'javelin-util' => '3e3be199', 4648 4648 'javelin-vector' => '3e3be199', 4649 4649 'javelin-workflow' => '3e3be199', 4650 - 'lightbox-attachment-css' => '71e32b00', 4650 + 'lightbox-attachment-css' => 'c35f1eca', 4651 4651 'maniphest-task-summary-css' => '49898640', 4652 - 'phabricator-action-list-view-css' => '71e32b00', 4653 - 'phabricator-application-launch-view-css' => '71e32b00', 4652 + 'phabricator-action-list-view-css' => 'c35f1eca', 4653 + 'phabricator-application-launch-view-css' => 'c35f1eca', 4654 4654 'phabricator-busy' => '2c1dba03', 4655 4655 'phabricator-content-source-view-css' => '7cd7e387', 4656 - 'phabricator-core-css' => '71e32b00', 4657 - 'phabricator-crumbs-view-css' => '71e32b00', 4656 + 'phabricator-core-css' => 'c35f1eca', 4657 + 'phabricator-crumbs-view-css' => 'c35f1eca', 4658 4658 'phabricator-drag-and-drop-file-upload' => '5e9e5c4e', 4659 4659 'phabricator-dropdown-menu' => '2c1dba03', 4660 4660 'phabricator-file-upload' => '2c1dba03', 4661 - 'phabricator-filetree-view-css' => '71e32b00', 4662 - 'phabricator-flag-css' => '71e32b00', 4661 + 'phabricator-filetree-view-css' => 'c35f1eca', 4662 + 'phabricator-flag-css' => 'c35f1eca', 4663 4663 'phabricator-hovercard' => '2c1dba03', 4664 - 'phabricator-jump-nav' => '71e32b00', 4664 + 'phabricator-jump-nav' => 'c35f1eca', 4665 4665 'phabricator-keyboard-shortcut' => '2c1dba03', 4666 4666 'phabricator-keyboard-shortcut-manager' => '2c1dba03', 4667 - 'phabricator-main-menu-view' => '71e32b00', 4667 + 'phabricator-main-menu-view' => 'c35f1eca', 4668 4668 'phabricator-menu-item' => '2c1dba03', 4669 - 'phabricator-nav-view-css' => '71e32b00', 4669 + 'phabricator-nav-view-css' => 'c35f1eca', 4670 4670 'phabricator-notification' => '2c1dba03', 4671 - 'phabricator-notification-css' => '71e32b00', 4672 - 'phabricator-notification-menu-css' => '71e32b00', 4671 + 'phabricator-notification-css' => 'c35f1eca', 4672 + 'phabricator-notification-menu-css' => 'c35f1eca', 4673 4673 'phabricator-object-selector-css' => '7cd7e387', 4674 4674 'phabricator-phtize' => '2c1dba03', 4675 4675 'phabricator-prefab' => '2c1dba03', 4676 4676 'phabricator-project-tag-css' => '49898640', 4677 - 'phabricator-remarkup-css' => '71e32b00', 4677 + 'phabricator-remarkup-css' => 'c35f1eca', 4678 4678 'phabricator-shaped-request' => '5e9e5c4e', 4679 - 'phabricator-side-menu-view-css' => '71e32b00', 4680 - 'phabricator-standard-page-view' => '71e32b00', 4681 - 'phabricator-tag-view-css' => '71e32b00', 4679 + 'phabricator-side-menu-view-css' => 'c35f1eca', 4680 + 'phabricator-standard-page-view' => 'c35f1eca', 4681 + 'phabricator-tag-view-css' => 'c35f1eca', 4682 4682 'phabricator-textareautils' => '2c1dba03', 4683 4683 'phabricator-tooltip' => '2c1dba03', 4684 - 'phabricator-transaction-view-css' => '71e32b00', 4685 - 'phabricator-zindex-css' => '71e32b00', 4686 - 'phui-button-css' => '71e32b00', 4687 - 'phui-form-css' => '71e32b00', 4688 - 'phui-form-view-css' => '71e32b00', 4689 - 'phui-header-view-css' => '71e32b00', 4690 - 'phui-icon-view-css' => '71e32b00', 4691 - 'phui-list-view-css' => '71e32b00', 4692 - 'phui-object-item-list-view-css' => '71e32b00', 4693 - 'phui-property-list-view-css' => '71e32b00', 4694 - 'phui-spacing-css' => '71e32b00', 4695 - 'sprite-apps-large-css' => '71e32b00', 4696 - 'sprite-gradient-css' => '71e32b00', 4697 - 'sprite-icons-css' => '71e32b00', 4698 - 'sprite-menu-css' => '71e32b00', 4699 - 'sprite-status-css' => '71e32b00', 4700 - 'syntax-highlighting-css' => '71e32b00', 4684 + 'phabricator-transaction-view-css' => 'c35f1eca', 4685 + 'phabricator-zindex-css' => 'c35f1eca', 4686 + 'phui-button-css' => 'c35f1eca', 4687 + 'phui-form-css' => 'c35f1eca', 4688 + 'phui-form-view-css' => 'c35f1eca', 4689 + 'phui-header-view-css' => 'c35f1eca', 4690 + 'phui-icon-view-css' => 'c35f1eca', 4691 + 'phui-list-view-css' => 'c35f1eca', 4692 + 'phui-object-item-list-view-css' => 'c35f1eca', 4693 + 'phui-property-list-view-css' => 'c35f1eca', 4694 + 'phui-spacing-css' => 'c35f1eca', 4695 + 'sprite-apps-large-css' => 'c35f1eca', 4696 + 'sprite-gradient-css' => 'c35f1eca', 4697 + 'sprite-icons-css' => 'c35f1eca', 4698 + 'sprite-menu-css' => 'c35f1eca', 4699 + 'sprite-status-css' => 'c35f1eca', 4700 + 'syntax-highlighting-css' => 'c35f1eca', 4701 4701 ), 4702 4702 ));
+1 -5
src/__phutil_library_map__.php
··· 2497 2497 'DifferentialHunk' => 'DifferentialDAO', 2498 2498 'DifferentialHunkParserTestCase' => 'PhabricatorTestCase', 2499 2499 'DifferentialHunkTestCase' => 'ArcanistPhutilTestCase', 2500 - 'DifferentialInlineComment' => 2501 - array( 2502 - 0 => 'DifferentialDAO', 2503 - 1 => 'PhabricatorInlineCommentInterface', 2504 - ), 2500 + 'DifferentialInlineComment' => 'PhabricatorInlineCommentInterface', 2505 2501 'DifferentialInlineCommentEditController' => 'PhabricatorInlineCommentController', 2506 2502 'DifferentialInlineCommentEditView' => 'AphrontView', 2507 2503 'DifferentialInlineCommentPreviewController' => 'PhabricatorInlineCommentPreviewController',
+19
src/infrastructure/celerity/CelerityResourceTransformer.php
··· 39 39 40 40 switch ($type) { 41 41 case 'css': 42 + $data = $this->replaceCSSPrintRules($path, $data); 42 43 $data = $this->replaceCSSVariables($path, $data); 43 44 $data = preg_replace_callback( 44 45 '@url\s*\((\s*[\'"]?.*?)\)@s', ··· 129 130 $data); 130 131 } 131 132 133 + private function replaceCSSPrintRules($path, $data) { 134 + $this->currentPath = $path; 135 + return preg_replace_callback( 136 + '/!print\s+(.+?{.+?})/s', 137 + array($this, 'replaceCSSPrintRule'), 138 + $data); 139 + } 140 + 132 141 public static function getCSSVariableMap() { 133 142 return array( 134 143 // Base Colors ··· 174 183 ); 175 184 } 176 185 186 + 177 187 public function replaceCSSVariable($matches) { 178 188 static $map; 179 189 if (!$map) { ··· 190 200 return $map[$var_name]; 191 201 } 192 202 203 + public function replaceCSSPrintRule($matches) { 204 + $rule = $matches[1]; 205 + 206 + $rules = array(); 207 + $rules[] = '.printable '.$rule; 208 + $rules[] = "@media print {\n ".str_replace("\n", "\n ", $rule)."\n}\n"; 209 + 210 + return implode("\n\n", $rules); 211 + } 193 212 }
+14
src/infrastructure/celerity/__tests__/transformer/print.css
··· 1 + ~~~~~~ 2 + !print .example { 3 + background: #ffffff; 4 + } 5 + ~~~~~~ 6 + .printable .example { 7 + background: #ffffff; 8 + } 9 + 10 + @media print { 11 + .example { 12 + background: #ffffff; 13 + } 14 + }
+4
src/view/page/PhabricatorStandardPageView.php
··· 424 424 $classes[] = 'platform-linux'; 425 425 } 426 426 427 + if ($this->getRequest()->getStr('__print__')) { 428 + $classes[] = 'printable'; 429 + } 430 + 427 431 return implode(' ', $classes); 428 432 } 429 433
+8
webroot/rsrc/css/application/base/main-menu-view.css
··· 400 400 .phabricator-application-menu .phui-list-item-name { 401 401 padding-left: 12px; 402 402 } 403 + 404 + 405 + /* - Print --------------------------------------------------------------------- 406 + */ 407 + 408 + !print .phabricator-main-menu { 409 + display: none; 410 + }