@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 download link to embedded files

Summary: Ref T3612. Doesn't render correctly, need help please. Adds a download icon into the renderfilelinkview to allow easier downloads.

Test Plan: Click on link, get download, click on file, get lightbox.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T3612

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

+124 -50
+15 -15
resources/celerity/map.php
··· 9 9 'names' => array( 10 10 'conpherence.pkg.css' => '0b64e988', 11 11 'conpherence.pkg.js' => '6249a1cf', 12 - 'core.pkg.css' => '202700e2', 13 - 'core.pkg.js' => '28e8cda8', 12 + 'core.pkg.css' => '9c725fa0', 13 + 'core.pkg.js' => 'f998932d', 14 14 'darkconsole.pkg.js' => 'e7393ebb', 15 15 'differential.pkg.css' => 'a4ba74b5', 16 16 'differential.pkg.js' => '40b18f35', ··· 108 108 'rsrc/css/application/tokens/tokens.css' => '3d0f239e', 109 109 'rsrc/css/application/uiexample/example.css' => '528b19de', 110 110 'rsrc/css/core/core.css' => 'd0801452', 111 - 'rsrc/css/core/remarkup.css' => '43e704eb', 111 + 'rsrc/css/core/remarkup.css' => 'aebc1180', 112 112 'rsrc/css/core/syntax.css' => '769d3498', 113 113 'rsrc/css/core/z-index.css' => '5e72c4e0', 114 114 'rsrc/css/diviner/diviner-shared.css' => 'aa3656aa', ··· 510 510 'rsrc/js/core/behavior-hovercard.js' => 'bcaccd64', 511 511 'rsrc/js/core/behavior-keyboard-pager.js' => 'a8da01f0', 512 512 'rsrc/js/core/behavior-keyboard-shortcuts.js' => '01fca1f0', 513 - 'rsrc/js/core/behavior-lightbox-attachments.js' => 'ddcd41cf', 513 + 'rsrc/js/core/behavior-lightbox-attachments.js' => 'a5c57c24', 514 514 'rsrc/js/core/behavior-line-linker.js' => '1499a8cb', 515 515 'rsrc/js/core/behavior-more.js' => 'a80d0378', 516 516 'rsrc/js/core/behavior-object-selector.js' => 'e0ec7f2f', ··· 657 657 'javelin-behavior-history-install' => '7ee2b591', 658 658 'javelin-behavior-icon-composer' => '8499b6ab', 659 659 'javelin-behavior-launch-icon-composer' => '48086888', 660 - 'javelin-behavior-lightbox-attachments' => 'ddcd41cf', 660 + 'javelin-behavior-lightbox-attachments' => 'a5c57c24', 661 661 'javelin-behavior-line-chart' => 'e4232876', 662 662 'javelin-behavior-load-blame' => '42126667', 663 663 'javelin-behavior-maniphest-batch-editor' => '782ab6e7', ··· 808 808 'phabricator-object-selector-css' => '85ee8ce6', 809 809 'phabricator-phtize' => 'd254d646', 810 810 'phabricator-prefab' => '8d40ae75', 811 - 'phabricator-remarkup-css' => '43e704eb', 811 + 'phabricator-remarkup-css' => 'aebc1180', 812 812 'phabricator-search-results-css' => '64ad079a', 813 813 'phabricator-shaped-request' => '7cbe244b', 814 814 'phabricator-slowvote-css' => 'a94b7230', ··· 1771 1771 'javelin-uri', 1772 1772 'phabricator-notification', 1773 1773 ), 1774 + 'a5c57c24' => array( 1775 + 'javelin-behavior', 1776 + 'javelin-stratcom', 1777 + 'javelin-dom', 1778 + 'javelin-mask', 1779 + 'javelin-util', 1780 + 'phuix-icon-view', 1781 + 'phabricator-busy', 1782 + ), 1774 1783 'a6f7a73b' => array( 1775 1784 'javelin-behavior', 1776 1785 'javelin-stratcom', ··· 2066 2075 'javelin-dom', 2067 2076 'javelin-util', 2068 2077 'phabricator-shaped-request', 2069 - ), 2070 - 'ddcd41cf' => array( 2071 - 'javelin-behavior', 2072 - 'javelin-stratcom', 2073 - 'javelin-dom', 2074 - 'javelin-mask', 2075 - 'javelin-util', 2076 - 'phuix-icon-view', 2077 - 'phabricator-busy', 2078 2078 ), 2079 2079 'de2e896f' => array( 2080 2080 'javelin-behavior',
+1 -1
src/__phutil_library_map__.php
··· 7715 7715 'PhabricatorFileImageTransform' => 'PhabricatorFileTransform', 7716 7716 'PhabricatorFileInfoController' => 'PhabricatorFileController', 7717 7717 'PhabricatorFileLightboxController' => 'PhabricatorFileController', 7718 - 'PhabricatorFileLinkView' => 'AphrontView', 7718 + 'PhabricatorFileLinkView' => 'AphrontTagView', 7719 7719 'PhabricatorFileListController' => 'PhabricatorFileController', 7720 7720 'PhabricatorFileQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 7721 7721 'PhabricatorFileROT13StorageFormat' => 'PhabricatorFileStorageFormat',
+5 -2
src/applications/files/markup/PhabricatorEmbedFileRemarkupRule.php
··· 3 3 final class PhabricatorEmbedFileRemarkupRule 4 4 extends PhabricatorObjectRemarkupRule { 5 5 6 + private $viewer; 7 + 6 8 const KEY_EMBED_FILE_PHIDS = 'phabricator.embedded-file-phids'; 7 9 8 10 protected function getObjectNamePrefix() { ··· 12 14 protected function loadObjects(array $ids) { 13 15 $engine = $this->getEngine(); 14 16 15 - $viewer = $engine->getConfig('viewer'); 17 + $this->viewer = $engine->getConfig('viewer'); 16 18 $objects = id(new PhabricatorFileQuery()) 17 - ->setViewer($viewer) 19 + ->setViewer($this->viewer) 18 20 ->withIDs($ids) 19 21 ->needTransforms( 20 22 array( ··· 282 284 array $options) { 283 285 284 286 return id(new PhabricatorFileLinkView()) 287 + ->setViewer($this->viewer) 285 288 ->setFilePHID($file->getPHID()) 286 289 ->setFileName($this->assertFlatText($options['name'])) 287 290 ->setFileDownloadURI($file->getDownloadURI())
+46 -20
src/view/layout/PhabricatorFileLinkView.php
··· 1 1 <?php 2 2 3 - final class PhabricatorFileLinkView extends AphrontView { 3 + final class PhabricatorFileLinkView extends AphrontTagView { 4 4 5 5 private $fileName; 6 6 private $fileDownloadURI; ··· 87 87 return FileTypeIcon::getFileIcon($this->getFileName()); 88 88 } 89 89 90 - public function getMetadata() { 90 + public function getMeta() { 91 91 return array( 92 92 'phid' => $this->getFilePHID(), 93 93 'viewable' => $this->getFileViewable(), ··· 100 100 ); 101 101 } 102 102 103 - public function render() { 104 - require_celerity_resource('phabricator-remarkup-css'); 105 - require_celerity_resource('phui-lightbox-css'); 103 + protected function getTagName() { 104 + return 'div'; 105 + } 106 106 107 + protected function getTagAttributes() { 107 108 $mustcapture = true; 108 109 $sigil = 'lightboxable'; 109 - $meta = $this->getMetadata(); 110 + $meta = $this->getMeta(); 110 111 111 112 $class = 'phabricator-remarkup-embed-layout-link'; 112 113 if ($this->getCustomClass()) { 113 114 $class = $this->getCustomClass(); 114 115 } 115 116 117 + return array( 118 + 'href' => $this->getFileViewURI(), 119 + 'class' => $class, 120 + 'sigil' => $sigil, 121 + 'meta' => $meta, 122 + 'mustcapture' => $mustcapture, 123 + ); 124 + } 125 + 126 + protected function getTagContent() { 127 + require_celerity_resource('phabricator-remarkup-css'); 128 + require_celerity_resource('phui-lightbox-css'); 129 + 116 130 $icon = id(new PHUIIconView()) 117 - ->setIcon($this->getFileIcon()); 131 + ->setIcon($this->getFileIcon()) 132 + ->addClass('phabricator-remarkup-embed-layout-icon'); 133 + 134 + $dl_icon = id(new PHUIIconView()) 135 + ->setIcon('fa-download'); 136 + 137 + $download_form = phabricator_form( 138 + $this->getViewer(), 139 + array( 140 + 'action' => $this->getFileDownloadURI(), 141 + 'method' => 'POST', 142 + 'class' => 'embed-download-form', 143 + 'sigil' => 'embed-download-form download', 144 + ), 145 + phutil_tag( 146 + 'button', 147 + array( 148 + 'class' => 'phabricator-remarkup-embed-layout-download', 149 + 'type' => 'submit', 150 + ), 151 + pht('Download'))); 118 152 119 153 $info = phutil_tag( 120 154 'span', ··· 140 174 $info, 141 175 )); 142 176 143 - return javelin_tag( 144 - 'a', 145 - array( 146 - 'href' => $this->getFileViewURI(), 147 - 'class' => $class, 148 - 'sigil' => $sigil, 149 - 'meta' => $meta, 150 - 'mustcapture' => $mustcapture, 151 - ), 152 - array( 153 - $icon, 154 - $inner, 155 - )); 177 + return array( 178 + $icon, 179 + $inner, 180 + $download_form, 181 + ); 156 182 } 157 183 }
+45 -11
webroot/rsrc/css/core/remarkup.css
··· 66 66 border-radius: 3px; 67 67 box-shadow: inset 0 -1px 0 rgba({$alphablue},0.08); 68 68 user-select: none; 69 - background: #f7f7f7; 69 + background: {$lightgreybackground}; 70 70 border: 1px solid {$lightgreyborder}; 71 71 } 72 72 ··· 370 370 } 371 371 372 372 .phabricator-remarkup-embed-layout-link { 373 - padding: 8px 8px 8px 32px; 373 + padding: 6px 6px 6px 42px; 374 374 border-radius: 3px; 375 375 margin: 0 0 4px; 376 376 display: inline-block; ··· 379 379 border: 1px solid {$lightblueborder}; 380 380 border-radius: 3px; 381 381 color: #000; 382 - min-width: 240px; 382 + min-width: 256px; 383 383 position: relative; 384 - height: 22px; 384 + /*height: 22px;*/ 385 385 line-height: 20px; 386 386 } 387 387 388 - .phabricator-remarkup-embed-layout-link .phui-icon-view { 389 - margin-right: 8px; 390 - font-size: 20px; 388 + .phabricator-remarkup-embed-layout-icon { 389 + font-size: 28px; 391 390 position: absolute; 392 - top: 8px; 393 - left: 8px; 391 + top: 10px; 392 + left: 10px; 394 393 } 395 394 396 395 .phabricator-remarkup-embed-layout-info { ··· 402 401 403 402 .phabricator-remarkup-embed-layout-link:hover { 404 403 border-color: {$violet}; 404 + cursor: pointer; 405 405 text-decoration: none; 406 406 } 407 407 408 - .phabricator-remarkup-embed-layout-link:hover .phui-icon-view { 409 - color: {$violet}; 408 + .phabricator-remarkup-embed-layout-link:hover 409 + .phabricator-remarkup-embed-layout-icon { 410 + color: {$violet}; 411 + } 412 + 413 + .phabricator-remarkup-embed-layout-info-block { 414 + display: block; 415 + } 416 + 417 + .embed-download-form { 418 + display: inline-block; 419 + padding: 0; 420 + margin: 0; 421 + } 422 + 423 + .phabricator-remarkup-embed-layout-link 424 + .phabricator-remarkup-embed-layout-download { 425 + color: {$lightgreytext}; 426 + border: none; 427 + background: rgba(0, 0, 0, 0); 428 + box-shadow: none; 429 + outline: 0; 430 + padding: 0; 431 + margin: 0; 432 + text-align: left; 433 + text-shadow: none; 434 + border-radius: 0; 435 + font: inherit; 436 + display: inline; 437 + min-width: 0; 438 + font-weight: normal !important; 439 + } 440 + 441 + .phabricator-remarkup-embed-layout-download:hover { 442 + color: {$anchor}; 443 + text-decoration: underline; 410 444 } 411 445 412 446 .phabricator-remarkup-embed-float-left {
+12 -1
webroot/rsrc/js/core/behavior-lightbox-attachments.js
··· 51 51 e.kill(); 52 52 53 53 var mainFrame = JX.$('main-page-frame'); 54 - var links = JX.DOM.scry(mainFrame, 'a', 'lightboxable'); 54 + var links = JX.DOM.scry(mainFrame, '*', 'lightboxable'); 55 55 var phids = {}; 56 56 var data; 57 57 for (var i = 0; i < links.length; i++) { ··· 371 371 form.submit(); 372 372 }; 373 373 374 + var _startPageDownload = function(e) { 375 + e.kill(); 376 + var form = e.getNode('tag:form'); 377 + form.submit(); 378 + }; 379 + 374 380 JX.Stratcom.listen( 375 381 'click', 376 382 'lightbox-download-submit', 377 383 _startDownload); 384 + 385 + JX.Stratcom.listen( 386 + 'click', 387 + 'embed-download-form', 388 + _startPageDownload); 378 389 379 390 });