@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 an avatar builtin file generator

Summary: Ref T10319. This builds out a reasonably decent avatar generator. 256 colors x 74 images x 2 borders, 38k options. Not completely sure though how names disburse though, so likely half that number. I can add lowercase lettering to double the footprint if needed though.

Test Plan:
UIExamples. Color generator here: http://tools.medialab.sciences-po.fr/iwanthue/

{F3416622}

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T10319

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

+432 -2
resources/builtin/alphanumeric/0.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/0d.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/1.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/1d.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/2.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/2d.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/3.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/3d.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/4.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/4d.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/5.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/5d.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/6.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/6d.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/7.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/7d.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/8.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/8d.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/9.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/9d.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/A.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Ad.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/B.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Bd.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/C.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Cd.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/D.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Dd.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/E.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Ed.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/F.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Fd.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/G.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Gd.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/H.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Hd.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/I.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Id.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/J.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Jd.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/K.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Kd.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/L.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Ld.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/M.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Md.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/N.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Nd.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/O.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Od.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/P.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Pd.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Q.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Qd.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/R.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Rd.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/S.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Sd.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Shrug.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Shrug2.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/T.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Td.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/U.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Ud.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/V.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Vd.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/W.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Wd.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/X.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Xd.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Y.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Yd.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Z.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/Zd.png

This is a binary file and will not be displayed.

resources/builtin/alphanumeric/shrug.png

This is a binary file and will not be displayed.

+4
src/__phutil_library_map__.php
··· 2770 2770 'PhabricatorFilesApplication' => 'applications/files/application/PhabricatorFilesApplication.php', 2771 2771 'PhabricatorFilesApplicationStorageEnginePanel' => 'applications/files/applicationpanel/PhabricatorFilesApplicationStorageEnginePanel.php', 2772 2772 'PhabricatorFilesBuiltinFile' => 'applications/files/builtin/PhabricatorFilesBuiltinFile.php', 2773 + 'PhabricatorFilesComposeAvatarBuiltinFile' => 'applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php', 2774 + 'PhabricatorFilesComposeAvatarExample' => 'applications/uiexample/examples/PhabricatorFilesComposeAvatarExample.php', 2773 2775 'PhabricatorFilesComposeIconBuiltinFile' => 'applications/files/builtin/PhabricatorFilesComposeIconBuiltinFile.php', 2774 2776 'PhabricatorFilesConfigOptions' => 'applications/files/config/PhabricatorFilesConfigOptions.php', 2775 2777 'PhabricatorFilesManagementCatWorkflow' => 'applications/files/management/PhabricatorFilesManagementCatWorkflow.php', ··· 7853 7855 'PhabricatorFilesApplication' => 'PhabricatorApplication', 7854 7856 'PhabricatorFilesApplicationStorageEnginePanel' => 'PhabricatorApplicationConfigurationPanel', 7855 7857 'PhabricatorFilesBuiltinFile' => 'Phobject', 7858 + 'PhabricatorFilesComposeAvatarBuiltinFile' => 'PhabricatorFilesBuiltinFile', 7859 + 'PhabricatorFilesComposeAvatarExample' => 'PhabricatorUIExample', 7856 7860 'PhabricatorFilesComposeIconBuiltinFile' => 'PhabricatorFilesBuiltinFile', 7857 7861 'PhabricatorFilesConfigOptions' => 'PhabricatorApplicationConfigOptions', 7858 7862 'PhabricatorFilesManagementCatWorkflow' => 'PhabricatorFilesManagementWorkflow',
+346
src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php
··· 1 + <?php 2 + 3 + final class PhabricatorFilesComposeAvatarBuiltinFile 4 + extends PhabricatorFilesBuiltinFile { 5 + 6 + private $icon; 7 + private $color; 8 + private $border; 9 + 10 + public function setIcon($icon) { 11 + $this->icon = $icon; 12 + return $this; 13 + } 14 + 15 + public function getIcon() { 16 + return $this->icon; 17 + } 18 + 19 + public function setColor($color) { 20 + $this->color = $color; 21 + return $this; 22 + } 23 + 24 + public function getColor() { 25 + return $this->color; 26 + } 27 + 28 + public function setBorder($border) { 29 + $this->border = $border; 30 + return $this; 31 + } 32 + 33 + public function getBorder() { 34 + return $this->border; 35 + } 36 + 37 + public function getBuiltinFileKey() { 38 + $icon = $this->getIcon(); 39 + $color = $this->getColor(); 40 + $border = $this->getBorder(); 41 + $desc = "compose(icon={$icon}, color={$color}, border={$border}"; 42 + $hash = PhabricatorHash::digestToLength($desc, 40); 43 + return "builtin:{$hash}"; 44 + } 45 + 46 + public function getBuiltinDisplayName() { 47 + $icon = $this->getIcon(); 48 + $color = $this->getColor(); 49 + $border = $this->getBorder(); 50 + return "{$icon}-{$color}-{$border}.png"; 51 + } 52 + 53 + public function loadBuiltinFileData() { 54 + return $this->composeImage( 55 + $this->getColor(), $this->getIcon(), $this->getBorder()); 56 + } 57 + 58 + private function composeImage($color, $icon, $border) { 59 + // TODO 60 + } 61 + 62 + public static function getImageMap() { 63 + $root = dirname(phutil_get_library_root('phabricator')); 64 + $root = $root.'/resources/builtin/alphanumeric/'; 65 + 66 + $map = array(); 67 + $list = Filesystem::listDirectory($root, $include_hidden = false); 68 + foreach ($list as $file) { 69 + $key = 'alphanumeric/'.$file; 70 + $map[$key] = $root.$file; 71 + } 72 + 73 + return $map; 74 + } 75 + 76 + public static function getColorMap() { 77 + $map = array( 78 + '#335862', 79 + '#dfc47b', 80 + '#2d5192', 81 + '#c0bc6e', 82 + '#3c5da0', 83 + '#99cd86', 84 + '#704889', 85 + '#5ac59e', 86 + '#984060', 87 + '#33d4d1', 88 + '#9c4050', 89 + '#20d8fd', 90 + '#944937', 91 + '#4bd0e3', 92 + '#a25542', 93 + '#4eb4f3', 94 + '#705412', 95 + '#6da8ec', 96 + '#545608', 97 + '#829ce5', 98 + '#68681d', 99 + '#607bc2', 100 + '#d1b66e', 101 + '#4b69ad', 102 + '#a4a154', 103 + '#236ead', 104 + '#daa969', 105 + '#31a0de', 106 + '#996f31', 107 + '#4f8ed0', 108 + '#846f2a', 109 + '#bdb0f0', 110 + '#518342', 111 + '#9166aa', 112 + '#5e904e', 113 + '#f79dcc', 114 + '#158e6b', 115 + '#e189b7', 116 + '#3ba984', 117 + '#a85582', 118 + '#4cccb7', 119 + '#863d67', 120 + '#84c08c', 121 + '#7f4c7f', 122 + '#a1bb7a', 123 + '#65558f', 124 + '#c2a962', 125 + '#445082', 126 + '#c9ca8e', 127 + '#265582', 128 + '#f4b189', 129 + '#265582', 130 + '#bd8f50', 131 + '#40b8e1', 132 + '#814a28', 133 + '#80c8f6', 134 + '#cf7b5d', 135 + '#1db5c7', 136 + '#c0606e', 137 + '#299a89', 138 + '#ef8ead', 139 + '#296437', 140 + '#d39edb', 141 + '#507436', 142 + '#b888c9', 143 + '#476025', 144 + '#9987c5', 145 + '#828136', 146 + '#7867a3', 147 + '#769b5a', 148 + '#c46e9d', 149 + '#437d4e', 150 + '#d17492', 151 + '#115e41', 152 + '#ec8794', 153 + '#297153', 154 + '#d67381', 155 + '#57c2c3', 156 + '#bc607f', 157 + '#86ceac', 158 + '#7e3e53', 159 + '#72c8b8', 160 + '#884349', 161 + '#45a998', 162 + '#faa38c', 163 + '#265582', 164 + '#ad954f', 165 + '#265582', 166 + '#e4b788', 167 + '#265582', 168 + '#bbbc81', 169 + '#265582', 170 + '#ccb781', 171 + '#265582', 172 + '#eb957f', 173 + '#15729c', 174 + '#cf996f', 175 + '#369bc5', 176 + '#b6685d', 177 + '#2da0a1', 178 + '#d38275', 179 + '#217e70', 180 + '#ec9da1', 181 + '#146268', 182 + '#e8aa95', 183 + '#3c6796', 184 + '#8da667', 185 + '#935f93', 186 + '#69a573', 187 + '#ae78ad', 188 + '#569160', 189 + '#d898be', 190 + '#525620', 191 + '#8eb4e8', 192 + '#5e622c', 193 + '#929ad3', 194 + '#6c8548', 195 + '#576196', 196 + '#aed0a0', 197 + '#694e79', 198 + '#9abb8d', 199 + '#8c5175', 200 + '#6bb391', 201 + '#8b4a5f', 202 + '#519878', 203 + '#ae7196', 204 + '#3d8465', 205 + '#e69eb3', 206 + '#48663d', 207 + '#cdaede', 208 + '#71743d', 209 + '#63acda', 210 + '#7b5d30', 211 + '#66bed6', 212 + '#a66c4e', 213 + '#3585b0', 214 + '#ba865c', 215 + '#5880b0', 216 + '#9b864d', 217 + '#739acc', 218 + '#9d764a', 219 + '#48a3ba', 220 + '#9d565b', 221 + '#7fc4ca', 222 + '#99566b', 223 + '#94cabf', 224 + '#7b4b49', 225 + '#b1c8eb', 226 + '#4e5632', 227 + '#ecb2c3', 228 + '#2d6158', 229 + '#cf8287', 230 + '#25889f', 231 + '#b2696d', 232 + '#6bafb6', 233 + '#8c5744', 234 + '#84b9d6', 235 + '#725238', 236 + '#9db3d6', 237 + '#816f3e', 238 + '#777cad', 239 + '#a6a86e', 240 + '#826693', 241 + '#86a779', 242 + '#9d7fad', 243 + '#8b8e55', 244 + '#b193c2', 245 + '#547348', 246 + '#d5adcb', 247 + '#3f674d', 248 + '#c98398', 249 + '#66865a', 250 + '#b2add6', 251 + '#5a623d', 252 + '#9793bb', 253 + '#bea975', 254 + '#3c5472', 255 + '#d5c5a1', 256 + '#5e5a7f', 257 + '#b09c68', 258 + '#2c647e', 259 + '#d8b194', 260 + '#49607f', 261 + '#c7b794', 262 + '#335862', 263 + '#e3aba7', 264 + '#335862', 265 + '#d9b9ad', 266 + '#335862', 267 + '#c48975', 268 + '#347b81', 269 + '#ad697e', 270 + '#799a6d', 271 + '#916b88', 272 + '#aeb68d', 273 + '#69536b', 274 + '#b4c4ad', 275 + '#845865', 276 + '#96b89d', 277 + '#706d92', 278 + '#9aa27a', 279 + '#5b7292', 280 + '#bc967b', 281 + '#417792', 282 + '#ce9793', 283 + '#335862', 284 + '#c898a5', 285 + '#527a5f', 286 + '#b38ba9', 287 + '#648d72', 288 + '#986b78', 289 + '#79afa4', 290 + '#966461', 291 + '#50959b', 292 + '#b27d7a', 293 + '#335862', 294 + '#b2a381', 295 + '#335862', 296 + '#bcadc4', 297 + '#706343', 298 + '#749ebc', 299 + '#8c6a50', 300 + '#92b8c4', 301 + '#a07d62', 302 + '#758cad', 303 + '#868e67', 304 + '#335862', 305 + '#b6978c', 306 + '#335862', 307 + '#9e8f6e', 308 + '#335862', 309 + '#ac7e8b', 310 + '#77a185', 311 + '#807288', 312 + '#636f51', 313 + '#a192a9', 314 + '#467a70', 315 + '#9b7d73', 316 + '#335862', 317 + '#8a7c5b', 318 + '#335862', 319 + '#8c9c85', 320 + '#335862', 321 + '#81645a', 322 + '#5f9489', 323 + '#335862', 324 + '#789da8', 325 + '#335862', 326 + '#72826c', 327 + '#335862', 328 + '#5c8596', 329 + '#335862', 330 + '#456a74', 331 + '#335862', 332 + '#335862', 333 + '#335862', 334 + ); 335 + return $map; 336 + } 337 + 338 + public static function getBorderMap() { 339 + $map = array( 340 + 'rgba(0,0,0,.3);', // Darker 341 + 'rgba(255,255,255,.5);', // Lighter 342 + ); 343 + return $map; 344 + } 345 + 346 + }
+5 -2
src/applications/files/builtin/PhabricatorFilesOnDiskBuiltinFile.php
··· 45 45 $root = $root.'/resources/builtin/'; 46 46 47 47 $map = array(); 48 - $list = Filesystem::listDirectory($root, $include_hidden = false); 48 + $list = id(new FileFinder($root)) 49 + ->withType('f') 50 + ->withFollowSymlinks(true) 51 + ->find(); 52 + 49 53 foreach ($list as $file) { 50 54 $map[$file] = $root.$file; 51 55 } 52 - 53 56 return $map; 54 57 } 55 58
+77
src/applications/uiexample/examples/PhabricatorFilesComposeAvatarExample.php
··· 1 + <?php 2 + 3 + final class PhabricatorFilesComposeAvatarExample extends PhabricatorUIExample { 4 + 5 + public function getName() { 6 + return pht('Generate Avatar Images'); 7 + } 8 + 9 + public function getDescription() { 10 + return pht('Tests various color palettes and sizes.'); 11 + } 12 + 13 + public function renderExample() { 14 + $request = $this->getRequest(); 15 + $viewer = $request->getUser(); 16 + 17 + $colors = PhabricatorFilesComposeAvatarBuiltinFile::getColorMap(); 18 + $builtins = PhabricatorFilesComposeAvatarBuiltinFile::getImageMap(); 19 + $borders = PhabricatorFilesComposeAvatarBuiltinFile::getBorderMap(); 20 + 21 + shuffle($colors); 22 + $images = array(); 23 + foreach ($builtins as $builtin => $raw_file) { 24 + $file = PhabricatorFile::loadBuiltin($viewer, $builtin); 25 + $images[] = $file->getBestURI(); 26 + } 27 + 28 + $content = array(); 29 + foreach ($colors as $color) { 30 + shuffle($borders); 31 + $border = head($borders); 32 + 33 + $styles = array(); 34 + $styles[] = 'background-color: '.$color.';'; 35 + $styles[] = 'display: inline-block;'; 36 + $styles[] = 'height: 46px;'; 37 + $styles[] = 'width: 46px;'; 38 + $styles[] = 'border-radius: 3px;'; 39 + $styles[] = 'border: 4px solid '.$border.';'; 40 + 41 + shuffle($images); 42 + $png = head($images); 43 + 44 + $image = phutil_tag( 45 + 'img', 46 + array( 47 + 'src' => $png, 48 + 'height' => 46, 49 + 'width' => 46, 50 + )); 51 + 52 + $tag = phutil_tag( 53 + 'div', 54 + array( 55 + 'style' => implode(' ', $styles), 56 + ), 57 + $image); 58 + 59 + $content[] = phutil_tag( 60 + 'div', 61 + array( 62 + 'class' => 'mlr mlb', 63 + 'style' => 'float: left;', 64 + ), 65 + $tag); 66 + } 67 + 68 + $view = phutil_tag_div('ml', $content); 69 + 70 + return phutil_tag( 71 + 'div', 72 + array(), 73 + array( 74 + $view, 75 + )); 76 + } 77 + }