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

Generalize URI pattern blacklist for Quicksand

Summary:
Fixes T7060. Removes some hard-coding.

This assumes that "pages with no durable column" and "pages with no Quicksand" are the same, but that's correct today and I can't come up with a use case where they'd be different offhand.

Test Plan:
- Clicked a revision with column open, got Quicksand navigation.
- Clicked into Conpherence with column open, got real navigation.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7060

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

+136 -31
+24 -18
resources/celerity/map.php
··· 44 44 'rsrc/css/application/config/config-welcome.css' => '6abd79be', 45 45 'rsrc/css/application/config/setup-issue.css' => '22270af2', 46 46 'rsrc/css/application/config/unhandled-exception.css' => '37d4f9a2', 47 - 'rsrc/css/application/conpherence/durable-column.css' => '7abcc3f2', 47 + 'rsrc/css/application/conpherence/durable-column.css' => '9207426d', 48 48 'rsrc/css/application/conpherence/menu.css' => 'c6ac5299', 49 49 'rsrc/css/application/conpherence/message-pane.css' => '5930260a', 50 50 'rsrc/css/application/conpherence/notification.css' => '04a6e10a', ··· 202 202 'rsrc/externals/javelin/lib/JSON.js' => '69adf288', 203 203 'rsrc/externals/javelin/lib/Leader.js' => '331b1611', 204 204 'rsrc/externals/javelin/lib/Mask.js' => '8a41885b', 205 - 'rsrc/externals/javelin/lib/Quicksand.js' => 'f960d43d', 205 + 'rsrc/externals/javelin/lib/Quicksand.js' => '2bb920b6', 206 206 'rsrc/externals/javelin/lib/Request.js' => '94b750d2', 207 207 'rsrc/externals/javelin/lib/Resource.js' => '44959b73', 208 208 'rsrc/externals/javelin/lib/Routable.js' => 'b3e7d692', ··· 353 353 'rsrc/js/application/auth/behavior-persona-login.js' => '9414ff18', 354 354 'rsrc/js/application/config/behavior-reorder-fields.js' => '14a827de', 355 355 'rsrc/js/application/conpherence/ConpherenceThreadManager.js' => 'efef202b', 356 - 'rsrc/js/application/conpherence/behavior-durable-column.js' => 'd8dab826', 356 + 'rsrc/js/application/conpherence/behavior-durable-column.js' => '1eef9f26', 357 357 'rsrc/js/application/conpherence/behavior-menu.js' => 'e476c952', 358 358 'rsrc/js/application/conpherence/behavior-pontificate.js' => '21ba5861', 359 + 'rsrc/js/application/conpherence/behavior-quicksand-blacklist.js' => '7927a7d3', 359 360 'rsrc/js/application/conpherence/behavior-widget-pane.js' => '2c1cd7f5', 360 361 'rsrc/js/application/countdown/timer.js' => 'e4cc26b3', 361 362 'rsrc/js/application/dashboard/behavior-dashboard-async-panel.js' => '469c0d9e', ··· 514 515 'changeset-view-manager' => '88be0133', 515 516 'config-options-css' => '7fedf08b', 516 517 'config-welcome-css' => '6abd79be', 517 - 'conpherence-durable-column-view' => '7abcc3f2', 518 + 'conpherence-durable-column-view' => '9207426d', 518 519 'conpherence-menu-css' => 'c6ac5299', 519 520 'conpherence-message-pane-css' => '5930260a', 520 521 'conpherence-notification-css' => '04a6e10a', ··· 585 586 'javelin-behavior-diffusion-locate-file' => '6d3e1947', 586 587 'javelin-behavior-diffusion-pull-lastmodified' => '2b228192', 587 588 'javelin-behavior-doorkeeper-tag' => 'e5822781', 588 - 'javelin-behavior-durable-column' => 'd8dab826', 589 + 'javelin-behavior-durable-column' => '1eef9f26', 589 590 'javelin-behavior-error-log' => '6882e80a', 590 591 'javelin-behavior-fancy-datepicker' => 'c51ae228', 591 592 'javelin-behavior-global-drag-and-drop' => '07f199d8', ··· 640 641 'javelin-behavior-ponder-votebox' => '4e9b766b', 641 642 'javelin-behavior-project-boards' => '87cb6b51', 642 643 'javelin-behavior-project-create' => '065227cc', 644 + 'javelin-behavior-quicksand-blacklist' => '7927a7d3', 643 645 'javelin-behavior-refresh-csrf' => '7814b593', 644 646 'javelin-behavior-releeph-preview-branch' => 'b2b4fbaf', 645 647 'javelin-behavior-releeph-request-state-change' => 'a0b57eb8', ··· 670 672 'javelin-leader' => '331b1611', 671 673 'javelin-magical-init' => '2bd3c675', 672 674 'javelin-mask' => '8a41885b', 673 - 'javelin-quicksand' => 'f960d43d', 675 + 'javelin-quicksand' => '2bb920b6', 674 676 'javelin-reactor' => '2b8de964', 675 677 'javelin-reactor-dom' => 'c90a04fc', 676 678 'javelin-reactor-node-calmer' => '76f4ebed', ··· 954 956 'javelin-dom', 955 957 'javelin-reactor-dom', 956 958 ), 959 + '1eef9f26' => array( 960 + 'javelin-behavior', 961 + 'javelin-dom', 962 + 'javelin-stratcom', 963 + 'javelin-scrollbar', 964 + 'javelin-quicksand', 965 + 'phabricator-keyboard-shortcut', 966 + 'conpherence-thread-manager', 967 + ), 957 968 '1feea462' => array( 958 969 'javelin-install', 959 970 'javelin-dom', ··· 1011 1022 '2b8de964' => array( 1012 1023 'javelin-install', 1013 1024 'javelin-util', 1025 + ), 1026 + '2bb920b6' => array( 1027 + 'javelin-install', 1014 1028 ), 1015 1029 '2be71d56' => array( 1016 1030 'javelin-install', ··· 1359 1373 'javelin-router', 1360 1374 'javelin-util', 1361 1375 'phabricator-busy', 1376 + ), 1377 + '7927a7d3' => array( 1378 + 'javelin-behavior', 1379 + 'javelin-quicksand', 1362 1380 ), 1363 1381 '7a68dda3' => array( 1364 1382 'owners-path-editor', ··· 1786 1804 'javelin-util', 1787 1805 'phabricator-shaped-request', 1788 1806 ), 1789 - 'd8dab826' => array( 1790 - 'javelin-behavior', 1791 - 'javelin-dom', 1792 - 'javelin-stratcom', 1793 - 'javelin-scrollbar', 1794 - 'javelin-quicksand', 1795 - 'phabricator-keyboard-shortcut', 1796 - 'conpherence-thread-manager', 1797 - ), 1798 1807 'dbbf48b6' => array( 1799 1808 'javelin-behavior', 1800 1809 'javelin-stratcom', ··· 1988 1997 'javelin-dom', 1989 1998 'javelin-stratcom', 1990 1999 'javelin-uri', 1991 - ), 1992 - 'f960d43d' => array( 1993 - 'javelin-install', 1994 2000 ), 1995 2001 'fa0f4fc2' => array( 1996 2002 'javelin-behavior',
+4
src/applications/base/PhabricatorApplication.php
··· 185 185 return array(); 186 186 } 187 187 188 + public function getQuicksandURIPatternBlacklist() { 189 + return array(); 190 + } 191 + 188 192 189 193 /* -( URI Routing )-------------------------------------------------------- */ 190 194
+6
src/applications/conpherence/application/PhabricatorConpherenceApplication.php
··· 56 56 return $items; 57 57 } 58 58 59 + public function getQuicksandURIPatternBlacklist() { 60 + return array( 61 + '/conpherence/.*', 62 + ); 63 + } 64 + 59 65 }
+3 -1
src/applications/conpherence/view/ConpherenceLayoutView.php
··· 67 67 68 68 $selected_id = null; 69 69 $selected_thread_id = null; 70 + $selected_thread_phid = null; 70 71 if ($this->thread) { 71 72 $selected_id = $this->thread->getPHID().'-nav-item'; 72 73 $selected_thread_id = $this->thread->getID(); 74 + $selected_thread_phid = $this->thread->getPHID(); 73 75 } 74 76 $this->initBehavior('conpherence-menu', 75 77 array( ··· 77 79 'layoutID' => $layout_id, 78 80 'selectedID' => $selected_id, 79 81 'selectedThreadID' => $selected_thread_id, 80 - 'selectedThreadPHID' => $this->thread->getPHID(), 82 + 'selectedThreadPHID' => $selected_thread_phid, 81 83 'latestTransactionID' => $this->latestTransactionID, 82 84 'role' => $this->role, 83 85 'hasThreadList' => (bool)$this->threadView,
+38 -12
src/view/page/PhabricatorStandardPageView.php
··· 81 81 82 82 public function getShowDurableColumn() { 83 83 $request = $this->getRequest(); 84 - if ($request) { 85 - if (strncmp( 86 - $request->getRequestURI()->getPath(), 87 - '/conpherence', 88 - strlen('/conpherence')) === 0) { 84 + if (!$request) { 85 + return false; 86 + } 87 + 88 + $viewer = $request->getUser(); 89 + if (!$viewer->isLoggedIn()) { 90 + return false; 91 + } 92 + 93 + $conpherence_installed = PhabricatorApplication::isClassInstalledForViewer( 94 + 'PhabricatorConpherenceApplication', 95 + $viewer); 96 + if (!$conpherence_installed) { 97 + return false; 98 + } 99 + 100 + $patterns = $this->getQuicksandURIPatternBlacklist(); 101 + $path = $request->getRequestURI()->getPath(); 102 + foreach ($patterns as $pattern) { 103 + if (preg_match('(^'.$pattern.'$)', $path)) { 89 104 return false; 90 105 } 91 - $viewer = $request->getUser(); 92 - if ($viewer->isLoggedIn()) { 93 - return PhabricatorApplication::isClassInstalledForViewer( 94 - 'PhabricatorConpherenceApplication', 95 - $viewer); 96 - } 97 106 } 98 - return false; 107 + 108 + return true; 99 109 } 100 110 101 111 public function getTitle() { ··· 414 424 array()); 415 425 } 416 426 427 + Javelin::initBehavior('quicksand-blacklist', array( 428 + 'patterns' => $this->getQuicksandURIPatternBlacklist(), 429 + )); 430 + 417 431 return phutil_tag( 418 432 'div', 419 433 array( ··· 585 599 'content' => hsprintf('%s', $response), 586 600 ); 587 601 } 602 + 603 + private function getQuicksandURIPatternBlacklist() { 604 + $applications = PhabricatorApplication::getAllApplications(); 605 + 606 + $blacklist = array(); 607 + foreach ($applications as $application) { 608 + $blacklist[] = $application->getQuicksandURIPatternBlacklist(); 609 + } 610 + 611 + return array_mergev($blacklist); 612 + } 613 + 588 614 }
+52
webroot/rsrc/externals/javelin/lib/Quicksand.js
··· 34 34 _started: false, 35 35 _frameNode: null, 36 36 _contentNode: null, 37 + _uriPatternBlacklist: [], 37 38 38 39 /** 39 40 * Start Quicksand, accepting a fate of eternal torment. ··· 121 122 122 123 // TODO: This technically gets links which change query parameters 123 124 // wrong: they are navigation events but we won't Quicksand them. 125 + return; 126 + } 127 + 128 + if (self._isURIOnBlacklist(uri)) { 129 + // This URI is blacklisted as not navigable via Quicksand. 124 130 return; 125 131 } 126 132 ··· 276 282 .setPort(null) 277 283 .setDomain(null) 278 284 .toString(); 285 + }, 286 + 287 + 288 + /** 289 + * Set a list of regular expressions which blacklist URIs as not navigable 290 + * via Quicksand. 291 + * 292 + * If a user clicks a link to one of these URIs, a normal page navigation 293 + * event will occur instead of a Quicksand navigation. 294 + * 295 + * @param list<string> List of regular expressions. 296 + * @return self 297 + */ 298 + setURIPatternBlacklist: function(items) { 299 + var self = JX.Quicksand; 300 + 301 + var list = []; 302 + for (var ii = 0; ii < items.length; ii++) { 303 + list.push(new RegExp('^' + items[ii] + '$')); 304 + } 305 + 306 + self._uriPatternBlacklist = list; 307 + 308 + return self; 309 + }, 310 + 311 + 312 + /** 313 + * Test if a @{class:JX.URI} is on the URI pattern blacklist. 314 + * 315 + * @param JX.URI URI to test. 316 + * @return bool True if the URI is on the blacklist. 317 + */ 318 + _isURIOnBlacklist: function(uri) { 319 + var self = JX.Quicksand; 320 + var list = self._uriPatternBlacklist; 321 + 322 + var path = uri.getPath(); 323 + for (var ii = 0; ii < list.length; ii++) { 324 + if (list[ii].test(path)) { 325 + return true; 326 + } 327 + } 328 + 329 + return false; 279 330 } 331 + 280 332 } 281 333 282 334 });
+9
webroot/rsrc/js/application/conpherence/behavior-quicksand-blacklist.js
··· 1 + /** 2 + * @provides javelin-behavior-quicksand-blacklist 3 + * @requires javelin-behavior 4 + * javelin-quicksand 5 + */ 6 + 7 + JX.behavior('quicksand-blacklist', function(config) { 8 + JX.Quicksand.setURIPatternBlacklist(config.patterns); 9 + });