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

Merge branch 'preferences'

+311 -4
+6
resources/sql/patches/015.preferences.sql
··· 1 + CREATE TABLE phabricator_user.user_preferences ( 2 + id int unsigned not null auto_increment primary key, 3 + userPHID varchar(64) binary not null, 4 + preferences longblob not null, 5 + unique key (userPHID) 6 + );
+6
src/__phutil_library_map__.php
··· 270 270 'PhabricatorDirectoryMainController' => 'applications/directory/controller/main', 271 271 'PhabricatorDraft' => 'applications/draft/storage/draft', 272 272 'PhabricatorDraftDAO' => 'applications/draft/storage/base', 273 + 'PhabricatorEditPreferencesController' => 'applications/preferences/controller/edit', 273 274 'PhabricatorEmailLoginController' => 'applications/auth/controller/email', 274 275 'PhabricatorEmailTokenController' => 'applications/auth/controller/emailtoken', 275 276 'PhabricatorEnv' => 'infrastructure/env', ··· 323 324 'PhabricatorPeopleListController' => 'applications/people/controller/list', 324 325 'PhabricatorPeopleProfileController' => 'applications/people/controller/profile', 325 326 'PhabricatorPeopleProfileEditController' => 'applications/people/controller/profileedit', 327 + 'PhabricatorPreferencesController' => 'applications/preferences/controller/base', 326 328 'PhabricatorProject' => 'applications/project/storage/project', 327 329 'PhabricatorProjectAffiliation' => 'applications/project/storage/affiliation', 328 330 'PhabricatorProjectAffiliationEditController' => 'applications/project/controller/editaffiliation', ··· 386 388 'PhabricatorUser' => 'applications/people/storage/user', 387 389 'PhabricatorUserDAO' => 'applications/people/storage/base', 388 390 'PhabricatorUserOAuthInfo' => 'applications/people/storage/useroauthinfo', 391 + 'PhabricatorUserPreferences' => 'applications/people/storage/preferences', 389 392 'PhabricatorUserProfile' => 'applications/people/storage/profile', 390 393 'PhabricatorUserSettingsController' => 'applications/people/controller/settings', 391 394 'PhabricatorWorker' => 'infrastructure/daemon/workers/worker', ··· 612 615 'PhabricatorDirectoryMainController' => 'PhabricatorDirectoryController', 613 616 'PhabricatorDraft' => 'PhabricatorDraftDAO', 614 617 'PhabricatorDraftDAO' => 'PhabricatorLiskDAO', 618 + 'PhabricatorEditPreferencesController' => 'PhabricatorPreferencesController', 615 619 'PhabricatorEmailLoginController' => 'PhabricatorAuthController', 616 620 'PhabricatorEmailTokenController' => 'PhabricatorAuthController', 617 621 'PhabricatorFile' => 'PhabricatorFileDAO', ··· 656 660 'PhabricatorPeopleListController' => 'PhabricatorPeopleController', 657 661 'PhabricatorPeopleProfileController' => 'PhabricatorPeopleController', 658 662 'PhabricatorPeopleProfileEditController' => 'PhabricatorPeopleController', 663 + 'PhabricatorPreferencesController' => 'PhabricatorController', 659 664 'PhabricatorProject' => 'PhabricatorProjectDAO', 660 665 'PhabricatorProjectAffiliation' => 'PhabricatorProjectDAO', 661 666 'PhabricatorProjectAffiliationEditController' => 'PhabricatorProjectController', ··· 712 717 'PhabricatorUser' => 'PhabricatorUserDAO', 713 718 'PhabricatorUserDAO' => 'PhabricatorLiskDAO', 714 719 'PhabricatorUserOAuthInfo' => 'PhabricatorUserDAO', 720 + 'PhabricatorUserPreferences' => 'PhabricatorUserDAO', 715 721 'PhabricatorUserProfile' => 'PhabricatorUserDAO', 716 722 'PhabricatorUserSettingsController' => 'PhabricatorPeopleController', 717 723 'PhabricatorWorkerDAO' => 'PhabricatorLiskDAO',
+3
src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php
··· 242 242 => 'HeraldTranscriptController', 243 243 ), 244 244 245 + '/preferences/' => array( 246 + '$' => 'PhabricatorEditPreferencesController' 247 + ), 245 248 ); 246 249 } 247 250
+1 -1
src/applications/differential/parser/changeset/DifferentialChangesetParser.php
··· 1199 1199 $table = null; 1200 1200 if ($contents) { 1201 1201 $table = 1202 - '<table class="differential-diff remarkup-code">'. 1202 + '<table class="differential-diff remarkup-code PhabricatorMonospaced">'. 1203 1203 $contents. 1204 1204 '</table>'; 1205 1205 }
+1 -1
src/applications/diffusion/controller/file/DiffusionBrowseFileController.php
··· 142 142 $corpus_table = phutil_render_tag( 143 143 'table', 144 144 array( 145 - 'class' => "diffusion-source remarkup-code", 145 + 'class' => "diffusion-source remarkup-code PhabricatorMonospaced", 146 146 ), 147 147 implode("\n", $rows)); 148 148 $corpus = phutil_render_tag(
+39
src/applications/people/storage/preferences/PhabricatorUserPreferences.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2011 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 + class PhabricatorUserPreferences extends PhabricatorUserDAO { 20 + 21 + const PREFERENCE_MONOSPACED = 'monospaced'; 22 + const PREFERENCE_TITLES = 'titles'; 23 + 24 + protected $userPHID; 25 + protected $preferences; 26 + 27 + public function getConfiguration() { 28 + return array( 29 + self::CONFIG_SERIALIZATION => array( 30 + 'preferences' => self::SERIALIZATION_JSON, 31 + ), 32 + self::CONFIG_TIMESTAMPS => false, 33 + ) + parent::getConfiguration(); 34 + } 35 + 36 + public function getPreference($key) { 37 + return $this->getPreferences()[$key]; 38 + } 39 + }
+12
src/applications/people/storage/preferences/__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', 'applications/people/storage/base'); 10 + 11 + 12 + phutil_require_source('PhabricatorUserPreferences.php');
+26
src/applications/people/storage/user/PhabricatorUser.php
··· 34 34 35 35 protected $conduitCertificate; 36 36 37 + protected $preferences = null; 38 + 37 39 public function getProfileImagePHID() { 38 40 return nonempty( 39 41 $this->profileImagePHID, ··· 159 161 } 160 162 } 161 163 return false; 164 + } 165 + 166 + public function loadPreferences() { 167 + if ($this->preferences) { 168 + return $this->preferences; 169 + } 170 + 171 + $preferences = id(new PhabricatorUserPreferences())->loadOneWhere( 172 + 'userPHID = %s', 173 + $this->getPHID()); 174 + 175 + if (!$preferences) { 176 + $preferences = new PhabricatorUserPreferences(); 177 + $preferences->setUserPHID($this->getPHID()); 178 + 179 + $default_dict = array( 180 + PhabricatorUserPreferences::PREFERENCE_TITLES => 'glyph', 181 + PhabricatorUserPreferences::PREFERENCE_MONOSPACED => ''); 182 + 183 + $preferences->setPreferences($default_dict); 184 + } 185 + 186 + $this->preferences = $preferences; 187 + return $preferences; 162 188 } 163 189 164 190 }
+1
src/applications/people/storage/user/__init__.php
··· 7 7 8 8 9 9 phutil_require_module('phabricator', 'applications/people/storage/base'); 10 + phutil_require_module('phabricator', 'applications/people/storage/preferences'); 10 11 phutil_require_module('phabricator', 'applications/phid/constants'); 11 12 phutil_require_module('phabricator', 'applications/phid/storage/phid'); 12 13 phutil_require_module('phabricator', 'infrastructure/env');
+34
src/applications/preferences/controller/base/PhabricatorPreferencesController.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2011 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 + abstract class PhabricatorPreferencesController extends PhabricatorController { 20 + 21 + public function buildStandardPageResponse($view, array $data) { 22 + 23 + $page = $this->buildStandardPageView(); 24 + 25 + $page->setApplicationName('Preferences'); 26 + $page->setBaseURI('/preferences/'); 27 + $page->setTitle(idx($data, 'title')); 28 + $page->setGlyph("\xE2\x9A\x92"); 29 + $page->appendChild($view); 30 + 31 + $response = new AphrontWebpageResponse(); 32 + return $response->setContent($page->render()); 33 + } 34 + }
+15
src/applications/preferences/controller/base/__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/webpage'); 10 + phutil_require_module('phabricator', 'applications/base/controller/base'); 11 + 12 + phutil_require_module('phutil', 'utils'); 13 + 14 + 15 + phutil_require_source('PhabricatorPreferencesController.php');
+111
src/applications/preferences/controller/edit/PhabricatorEditPreferencesController.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2011 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 + class PhabricatorEditPreferencesController 19 + extends PhabricatorPreferencesController { 20 + 21 + public function processRequest() { 22 + 23 + $request = $this->getRequest(); 24 + $user = $request->getUser(); 25 + $preferences = $user->loadPreferences(); 26 + 27 + if ($request->isFormPost()) { 28 + $monospaced = $request->getStr( 29 + PhabricatorUserPreferences::PREFERENCE_MONOSPACED); 30 + 31 + // Prevent the user from doing stupid things. 32 + $monospaced = preg_replace('/[^a-z0-9 ,"]+/i', '', $monospaced); 33 + 34 + $pref_dict = array( 35 + PhabricatorUserPreferences::PREFERENCE_TITLES => 36 + $request->getStr(PhabricatorUserPreferences::PREFERENCE_TITLES), 37 + PhabricatorUserPreferences::PREFERENCE_MONOSPACED => 38 + $monospaced); 39 + 40 + $preferences->setPreferences($pref_dict); 41 + $preferences->save(); 42 + return id(new AphrontRedirectResponse()) 43 + ->setURI('/preferences/?saved=true'); 44 + } 45 + 46 + $example_string = <<<EXAMPLE 47 + // This is what your monospaced font currently looks like. 48 + function helloWorld() { 49 + alert("Hello world!"); 50 + } 51 + EXAMPLE; 52 + 53 + $form = id(new AphrontFormView()) 54 + ->setAction('/preferences/') 55 + ->setUser($user) 56 + ->appendChild( 57 + id(new AphrontFormSelectControl()) 58 + ->setLabel('Page Titles') 59 + ->setName(PhabricatorUserPreferences::PREFERENCE_TITLES) 60 + ->setValue($preferences->getPreference( 61 + PhabricatorUserPreferences::PREFERENCE_TITLES)) 62 + ->setOptions( 63 + array( 64 + 'glyph' => 65 + "In page titles, show Tool names as unicode glyphs: \xE2\x9A\x99", 66 + 'text' => 67 + 'In page titles, show Tool names as plain text: [Differential]', 68 + ))) 69 + ->appendChild( 70 + id(new AphrontFormTextControl()) 71 + ->setLabel('Monospaced Font') 72 + ->setName(PhabricatorUserPreferences::PREFERENCE_MONOSPACED) 73 + ->setCaption( 74 + 'Overrides default fonts in tools like Differential. '. 75 + '(Default: 10px "Menlo", "Consolas", "Monaco", '. 76 + 'monospace)') 77 + ->setValue($preferences->getPreference( 78 + PhabricatorUserPreferences::PREFERENCE_MONOSPACED))) 79 + ->appendChild( 80 + id(new AphrontFormMarkupControl()) 81 + ->setValue( 82 + '<pre class="PhabricatorMonospaced">'. 83 + phutil_escape_html($example_string). 84 + '</pre>')) 85 + ->appendChild( 86 + id(new AphrontFormSubmitControl()) 87 + ->setValue('Save Preferences')); 88 + 89 + $panel = new AphrontPanelView(); 90 + $panel->appendChild($form); 91 + 92 + $error_view = null; 93 + if ($request->getStr('saved') === 'true') { 94 + $error_view = id(new AphrontErrorView()) 95 + ->setTitle('Preferences Saved') 96 + ->setSeverity(AphrontErrorView::SEVERITY_NOTICE) 97 + ->setErrors(array('Your preferences have been saved.')); 98 + } 99 + 100 + return $this->buildStandardPageResponse( 101 + array( 102 + $error_view, 103 + $panel, 104 + ), 105 + array( 106 + 'title' => 'Edit Preferences', 107 + )); 108 + 109 + } 110 + } 111 +
+20
src/applications/preferences/controller/edit/__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/redirect'); 10 + phutil_require_module('phabricator', 'applications/people/storage/preferences'); 11 + phutil_require_module('phabricator', 'applications/preferences/controller/base'); 12 + phutil_require_module('phabricator', 'view/form/base'); 13 + phutil_require_module('phabricator', 'view/form/control/submit'); 14 + phutil_require_module('phabricator', 'view/form/error'); 15 + phutil_require_module('phabricator', 'view/layout/panel'); 16 + 17 + phutil_require_module('phutil', 'utils'); 18 + 19 + 20 + phutil_require_source('PhabricatorEditPreferencesController.php');
+35 -2
src/view/page/standard/PhabricatorStandardPageView.php
··· 60 60 } 61 61 62 62 public function getTitle() { 63 - return $this->getGlyph().' '.parent::getTitle(); 63 + $use_glyph = true; 64 + $request = $this->getRequest(); 65 + if ($request) { 66 + $user = $request->getUser(); 67 + if ($user && $user->loadPreferences()->getPreference( 68 + PhabricatorUserPreferences::PREFERENCE_TITLES) !== 'glyph') { 69 + $use_glyph = false; 70 + } 71 + } 72 + 73 + return ($use_glyph ? 74 + $this->getGlyph() : '['.$this->getApplicationName().']'). 75 + ' '.parent::getTitle(); 64 76 } 65 77 66 78 ··· 97 109 98 110 protected function getHead() { 99 111 $response = CelerityAPI::getStaticResourceResponse(); 100 - return 112 + $head = 101 113 '<script type="text/javascript">'. 102 114 '(top != self) && top.location.replace(self.location.href);'. 103 115 'window.__DEV__=1;'. ··· 105 117 $response->renderResourcesOfType('css'). 106 118 '<script type="text/javascript" src="/rsrc/js/javelin/init.dev.js">'. 107 119 '</script>'; 120 + 121 + $request = $this->getRequest(); 122 + if ($request) { 123 + $user = $request->getUser(); 124 + if ($user) { 125 + $monospaced = $user->loadPreferences()->getPreference( 126 + PhabricatorUserPreferences::PREFERENCE_MONOSPACED 127 + ); 128 + 129 + if (strlen($monospaced)) { 130 + $head .= 131 + '<style type="text/css">'. 132 + '.PhabricatorMonospaced { font: '. 133 + $monospaced. 134 + ' !important; }'. 135 + '</style>'; 136 + } 137 + } 138 + } 139 + 140 + return $head; 108 141 } 109 142 110 143 public function setGlyph($glyph) {
+1
src/view/page/standard/__init__.php
··· 6 6 7 7 8 8 9 + phutil_require_module('phabricator', 'applications/people/storage/preferences'); 9 10 phutil_require_module('phabricator', 'infrastructure/celerity/api'); 10 11 phutil_require_module('phabricator', 'infrastructure/env'); 11 12 phutil_require_module('phabricator', 'infrastructure/javelin/api');