@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 /F123 shortcut

Summary:
I wanted to point someone on a file uploaded to Phabricator and the normal link is just too long.

I guess that this also improves security. Because pointing someone to the file directly reveals the secret key used in /data/ and it can be served without auth?

We already use `{F123}` so there will be no conflicts in future because we wouldn't want to reuse it for something else.

I promote the link on /file/ - it adds one redirect but I think it's worth it. I also considered making the link from the File ID column but there are already too many links (with some duplicity).

Test Plan:
/file/
/F123 (redirect)
/F9999999999 (404)

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

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

vrana 87ff4614 416e4e7b

+58 -1
+2
src/__phutil_library_map__.php
··· 630 630 'PhabricatorFileMacroListController' => 'applications/files/controller/macrolist', 631 631 'PhabricatorFileProxyController' => 'applications/files/controller/proxy', 632 632 'PhabricatorFileProxyImage' => 'applications/files/storage/proxyimage', 633 + 'PhabricatorFileShortcutController' => 'applications/files/controller/shortcut', 633 634 'PhabricatorFileSideNavView' => 'applications/files/view/sidenav', 634 635 'PhabricatorFileStorageBlob' => 'applications/files/storage/storageblob', 635 636 'PhabricatorFileStorageConfigurationException' => 'applications/files/exception/configuration', ··· 1556 1557 'PhabricatorFileMacroListController' => 'PhabricatorFileController', 1557 1558 'PhabricatorFileProxyController' => 'PhabricatorFileController', 1558 1559 'PhabricatorFileProxyImage' => 'PhabricatorFileDAO', 1560 + 'PhabricatorFileShortcutController' => 'PhabricatorFileController', 1559 1561 'PhabricatorFileSideNavView' => 'AphrontView', 1560 1562 'PhabricatorFileStorageBlob' => 'PhabricatorFileDAO', 1561 1563 'PhabricatorFileTransformController' => 'PhabricatorFileController',
+1
src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php
··· 39 39 '(?:(?P<subfilter>[^/]+)/)?' => 40 40 'PhabricatorDirectoryMainController', 41 41 ), 42 + '/F(?P<id>\d+)' => 'PhabricatorFileShortcutController', 42 43 '/file/' => array( 43 44 '' => 'PhabricatorFileListController', 44 45 'filter/(?P<filter>\w+)/' => 'PhabricatorFileListController',
+2 -1
src/applications/files/controller/list/PhabricatorFileListController.php
··· 246 246 phutil_render_tag( 247 247 'a', 248 248 array( 249 - 'href' => $file->getBestURI(), 249 + // Don't use $file->getBestURI() to improve discoverability of /F. 250 + 'href' => '/F'.$file->getID(), 250 251 ), 251 252 ($name != '' ? phutil_escape_html($name) : '<em>no name</em>')), 252 253 phutil_escape_html(number_format($file->getByteSize()).' bytes'),
+36
src/applications/files/controller/shortcut/PhabricatorFileShortcutController.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2012 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + final class PhabricatorFileShortcutController 20 + extends PhabricatorFileController { 21 + 22 + private $id; 23 + 24 + public function willProcessRequest(array $data) { 25 + $this->id = $data['id']; 26 + } 27 + 28 + public function processRequest() { 29 + $file = id(new PhabricatorFile())->load($this->id); 30 + if (!$file) { 31 + return new Aphront404Response(); 32 + } 33 + return id(new AphrontRedirectResponse())->setURI($file->getBestURI()); 34 + } 35 + 36 + }
+17
src/applications/files/controller/shortcut/__init__.php
··· 1 + <?php 2 + /** 3 + * This file is automatically generated. Lint this module to rebuild it. 4 + * @generated 5 + */ 6 + 7 + 8 + 9 + phutil_require_module('phabricator', 'aphront/response/404'); 10 + phutil_require_module('phabricator', 'aphront/response/redirect'); 11 + phutil_require_module('phabricator', 'applications/files/controller/base'); 12 + phutil_require_module('phabricator', 'applications/files/storage/file'); 13 + 14 + phutil_require_module('phutil', 'utils'); 15 + 16 + 17 + phutil_require_source('PhabricatorFileShortcutController.php');