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

at recaptime-dev/main 93 lines 2.3 kB view raw
1<?php 2 3final class PhabricatorRemarkupCowsayBlockInterpreter 4 extends PhutilRemarkupBlockInterpreter 5 implements RemarkupSyntaxDocumentationProvider { 6 7 public function getInterpreterName() { 8 return 'cowsay'; 9 } 10 11 public function markupContent($content, array $argv) { 12 $action = idx($argv, 'think') ? 'think' : 'say'; 13 $eyes = idx($argv, 'eyes', 'oo'); 14 $tongue = idx($argv, 'tongue', ' '); 15 16 $map = self::getCowMap(); 17 18 $cow = idx($argv, 'cow'); 19 $cow = phutil_utf8_strtolower($cow); 20 if (empty($map[$cow])) { 21 $cow = 'default'; 22 } 23 24 $result = id(new PhutilCowsay()) 25 ->setTemplate($map[$cow]) 26 ->setAction($action) 27 ->setEyes($eyes) 28 ->setTongue($tongue) 29 ->setText($content) 30 ->renderCow(); 31 32 $engine = $this->getEngine(); 33 34 if ($engine->isTextMode()) { 35 return $result; 36 } 37 38 if ($engine->isHTMLMailMode()) { 39 return phutil_tag('pre', array(), $result); 40 } 41 42 return phutil_tag( 43 'div', 44 array( 45 'class' => 'PhabricatorMonospaced remarkup-cowsay', 46 ), 47 $result); 48 } 49 50 private static function getCowMap() { 51 $root = dirname(phutil_get_library_root('phabricator')); 52 53 $directories = array( 54 $root.'/externals/cowsay/cows/', 55 $root.'/resources/cows/builtin/', 56 $root.'/resources/cows/custom/', 57 ); 58 59 $map = array(); 60 foreach ($directories as $directory) { 61 foreach (Filesystem::listDirectory($directory, false) as $cow_file) { 62 $matches = null; 63 if (!preg_match('/^(.*)\.cow\z/', $cow_file, $matches)) { 64 continue; 65 } 66 $cow_name = $matches[1]; 67 $cow_name = phutil_utf8_strtolower($cow_name); 68 $map[$cow_name] = Filesystem::readFile($directory.$cow_file); 69 } 70 } 71 72 return $map; 73 } 74 75 public function getDocumentation() { 76 return <<<EOT 77= Cowsay 78 79Cowsay is an application by Tony Monroe which has been ported over to 80Phabricator/Phorge to allow your comments to be voiced by 81a cow. 82 83A basic example of using cowsay would be to add a comment 84 cowsay{{{Why don't they play poker in the jungle? Too many cheetahs}}} 85which generates: 86 87cowsay{{{Why don't they play poker in the jungle? Too many cheetahs}}} 88 89[[/reference/cowsay/ | More information about Cowsay]] is available. 90EOT; 91 } 92 93}