diff --git a/resources/celerity/map.php b/resources/celerity/map.php --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -9,8 +9,8 @@ 'names' => array( 'conpherence.pkg.css' => '0b64e988', 'conpherence.pkg.js' => '6249a1cf', - 'core.pkg.css' => '202700e2', - 'core.pkg.js' => '28e8cda8', + 'core.pkg.css' => '9c725fa0', + 'core.pkg.js' => 'f998932d', 'darkconsole.pkg.js' => 'e7393ebb', 'differential.pkg.css' => 'a4ba74b5', 'differential.pkg.js' => '40b18f35', @@ -108,7 +108,7 @@ 'rsrc/css/application/tokens/tokens.css' => '3d0f239e', 'rsrc/css/application/uiexample/example.css' => '528b19de', 'rsrc/css/core/core.css' => 'd0801452', - 'rsrc/css/core/remarkup.css' => '43e704eb', + 'rsrc/css/core/remarkup.css' => 'aebc1180', 'rsrc/css/core/syntax.css' => '769d3498', 'rsrc/css/core/z-index.css' => '5e72c4e0', 'rsrc/css/diviner/diviner-shared.css' => 'aa3656aa', @@ -510,7 +510,7 @@ 'rsrc/js/core/behavior-hovercard.js' => 'bcaccd64', 'rsrc/js/core/behavior-keyboard-pager.js' => 'a8da01f0', 'rsrc/js/core/behavior-keyboard-shortcuts.js' => '01fca1f0', - 'rsrc/js/core/behavior-lightbox-attachments.js' => 'ddcd41cf', + 'rsrc/js/core/behavior-lightbox-attachments.js' => 'a5c57c24', 'rsrc/js/core/behavior-line-linker.js' => '1499a8cb', 'rsrc/js/core/behavior-more.js' => 'a80d0378', 'rsrc/js/core/behavior-object-selector.js' => 'e0ec7f2f', @@ -657,7 +657,7 @@ 'javelin-behavior-history-install' => '7ee2b591', 'javelin-behavior-icon-composer' => '8499b6ab', 'javelin-behavior-launch-icon-composer' => '48086888', - 'javelin-behavior-lightbox-attachments' => 'ddcd41cf', + 'javelin-behavior-lightbox-attachments' => 'a5c57c24', 'javelin-behavior-line-chart' => 'e4232876', 'javelin-behavior-load-blame' => '42126667', 'javelin-behavior-maniphest-batch-editor' => '782ab6e7', @@ -808,7 +808,7 @@ 'phabricator-object-selector-css' => '85ee8ce6', 'phabricator-phtize' => 'd254d646', 'phabricator-prefab' => '8d40ae75', - 'phabricator-remarkup-css' => '43e704eb', + 'phabricator-remarkup-css' => 'aebc1180', 'phabricator-search-results-css' => '64ad079a', 'phabricator-shaped-request' => '7cbe244b', 'phabricator-slowvote-css' => 'a94b7230', @@ -1771,6 +1771,15 @@ 'javelin-uri', 'phabricator-notification', ), + 'a5c57c24' => array( + 'javelin-behavior', + 'javelin-stratcom', + 'javelin-dom', + 'javelin-mask', + 'javelin-util', + 'phuix-icon-view', + 'phabricator-busy', + ), 'a6f7a73b' => array( 'javelin-behavior', 'javelin-stratcom', @@ -2067,15 +2076,6 @@ 'javelin-util', 'phabricator-shaped-request', ), - 'ddcd41cf' => array( - 'javelin-behavior', - 'javelin-stratcom', - 'javelin-dom', - 'javelin-mask', - 'javelin-util', - 'phuix-icon-view', - 'phabricator-busy', - ), 'de2e896f' => array( 'javelin-behavior', 'javelin-dom', diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -7715,7 +7715,7 @@ 'PhabricatorFileImageTransform' => 'PhabricatorFileTransform', 'PhabricatorFileInfoController' => 'PhabricatorFileController', 'PhabricatorFileLightboxController' => 'PhabricatorFileController', - 'PhabricatorFileLinkView' => 'AphrontView', + 'PhabricatorFileLinkView' => 'AphrontTagView', 'PhabricatorFileListController' => 'PhabricatorFileController', 'PhabricatorFileQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorFileROT13StorageFormat' => 'PhabricatorFileStorageFormat', diff --git a/src/applications/files/markup/PhabricatorEmbedFileRemarkupRule.php b/src/applications/files/markup/PhabricatorEmbedFileRemarkupRule.php --- a/src/applications/files/markup/PhabricatorEmbedFileRemarkupRule.php +++ b/src/applications/files/markup/PhabricatorEmbedFileRemarkupRule.php @@ -3,6 +3,8 @@ final class PhabricatorEmbedFileRemarkupRule extends PhabricatorObjectRemarkupRule { + private $viewer; + const KEY_EMBED_FILE_PHIDS = 'phabricator.embedded-file-phids'; protected function getObjectNamePrefix() { @@ -12,9 +14,9 @@ protected function loadObjects(array $ids) { $engine = $this->getEngine(); - $viewer = $engine->getConfig('viewer'); + $this->viewer = $engine->getConfig('viewer'); $objects = id(new PhabricatorFileQuery()) - ->setViewer($viewer) + ->setViewer($this->viewer) ->withIDs($ids) ->needTransforms( array( @@ -282,6 +284,7 @@ array $options) { return id(new PhabricatorFileLinkView()) + ->setViewer($this->viewer) ->setFilePHID($file->getPHID()) ->setFileName($this->assertFlatText($options['name'])) ->setFileDownloadURI($file->getDownloadURI()) diff --git a/src/view/layout/PhabricatorFileLinkView.php b/src/view/layout/PhabricatorFileLinkView.php --- a/src/view/layout/PhabricatorFileLinkView.php +++ b/src/view/layout/PhabricatorFileLinkView.php @@ -1,6 +1,6 @@ getFileName()); } - public function getMetadata() { + public function getMeta() { return array( 'phid' => $this->getFilePHID(), 'viewable' => $this->getFileViewable(), @@ -100,21 +100,55 @@ ); } - public function render() { - require_celerity_resource('phabricator-remarkup-css'); - require_celerity_resource('phui-lightbox-css'); + protected function getTagName() { + return 'div'; + } + protected function getTagAttributes() { $mustcapture = true; $sigil = 'lightboxable'; - $meta = $this->getMetadata(); + $meta = $this->getMeta(); $class = 'phabricator-remarkup-embed-layout-link'; if ($this->getCustomClass()) { $class = $this->getCustomClass(); } + return array( + 'href' => $this->getFileViewURI(), + 'class' => $class, + 'sigil' => $sigil, + 'meta' => $meta, + 'mustcapture' => $mustcapture, + ); + } + + protected function getTagContent() { + require_celerity_resource('phabricator-remarkup-css'); + require_celerity_resource('phui-lightbox-css'); + $icon = id(new PHUIIconView()) - ->setIcon($this->getFileIcon()); + ->setIcon($this->getFileIcon()) + ->addClass('phabricator-remarkup-embed-layout-icon'); + + $dl_icon = id(new PHUIIconView()) + ->setIcon('fa-download'); + + $download_form = phabricator_form( + $this->getViewer(), + array( + 'action' => $this->getFileDownloadURI(), + 'method' => 'POST', + 'class' => 'embed-download-form', + 'sigil' => 'embed-download-form download', + ), + phutil_tag( + 'button', + array( + 'class' => 'phabricator-remarkup-embed-layout-download', + 'type' => 'submit', + ), + pht('Download'))); $info = phutil_tag( 'span', @@ -140,18 +174,10 @@ $info, )); - return javelin_tag( - 'a', - array( - 'href' => $this->getFileViewURI(), - 'class' => $class, - 'sigil' => $sigil, - 'meta' => $meta, - 'mustcapture' => $mustcapture, - ), - array( - $icon, - $inner, - )); + return array( + $icon, + $inner, + $download_form, + ); } } diff --git a/webroot/rsrc/css/core/remarkup.css b/webroot/rsrc/css/core/remarkup.css --- a/webroot/rsrc/css/core/remarkup.css +++ b/webroot/rsrc/css/core/remarkup.css @@ -66,7 +66,7 @@ border-radius: 3px; box-shadow: inset 0 -1px 0 rgba({$alphablue},0.08); user-select: none; - background: #f7f7f7; + background: {$lightgreybackground}; border: 1px solid {$lightgreyborder}; } @@ -370,7 +370,7 @@ } .phabricator-remarkup-embed-layout-link { - padding: 8px 8px 8px 32px; + padding: 6px 6px 6px 42px; border-radius: 3px; margin: 0 0 4px; display: inline-block; @@ -379,18 +379,17 @@ border: 1px solid {$lightblueborder}; border-radius: 3px; color: #000; - min-width: 240px; + min-width: 256px; position: relative; - height: 22px; + /*height: 22px;*/ line-height: 20px; } -.phabricator-remarkup-embed-layout-link .phui-icon-view { - margin-right: 8px; - font-size: 20px; +.phabricator-remarkup-embed-layout-icon { + font-size: 28px; position: absolute; - top: 8px; - left: 8px; + top: 10px; + left: 10px; } .phabricator-remarkup-embed-layout-info { @@ -402,11 +401,46 @@ .phabricator-remarkup-embed-layout-link:hover { border-color: {$violet}; + cursor: pointer; text-decoration: none; } -.phabricator-remarkup-embed-layout-link:hover .phui-icon-view { - color: {$violet}; +.phabricator-remarkup-embed-layout-link:hover + .phabricator-remarkup-embed-layout-icon { + color: {$violet}; +} + +.phabricator-remarkup-embed-layout-info-block { + display: block; +} + +.embed-download-form { + display: inline-block; + padding: 0; + margin: 0; +} + +.phabricator-remarkup-embed-layout-link + .phabricator-remarkup-embed-layout-download { + color: {$lightgreytext}; + border: none; + background: rgba(0, 0, 0, 0); + box-shadow: none; + outline: 0; + padding: 0; + margin: 0; + text-align: left; + text-shadow: none; + border-radius: 0; + font: inherit; + display: inline; + min-width: 0; + font-weight: normal !important; +} + +.phabricator-remarkup-embed-layout-download:hover { + color: {$anchor}; + text-decoration: underline; } .phabricator-remarkup-embed-float-left { diff --git a/webroot/rsrc/js/core/behavior-lightbox-attachments.js b/webroot/rsrc/js/core/behavior-lightbox-attachments.js --- a/webroot/rsrc/js/core/behavior-lightbox-attachments.js +++ b/webroot/rsrc/js/core/behavior-lightbox-attachments.js @@ -51,7 +51,7 @@ e.kill(); var mainFrame = JX.$('main-page-frame'); - var links = JX.DOM.scry(mainFrame, 'a', 'lightboxable'); + var links = JX.DOM.scry(mainFrame, '*', 'lightboxable'); var phids = {}; var data; for (var i = 0; i < links.length; i++) { @@ -371,9 +371,20 @@ form.submit(); }; + var _startPageDownload = function(e) { + e.kill(); + var form = e.getNode('tag:form'); + form.submit(); + }; + JX.Stratcom.listen( 'click', 'lightbox-download-submit', _startDownload); + JX.Stratcom.listen( + 'click', + 'embed-download-form', + _startPageDownload); + });