@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

Use PHP implementation of Cowsay for cowsay rule

Summary:
Ref T7785. Convert the Cowsay Remarkup rule to use a PHP implementation so we don't have to execute an external `cowsay` binary.

I removed some of the default ".cow" files that come with Cowsay because they:

- include Perl code which we can not interpret; or
- are primarily in-jokes or standalone visual puns or artwork rather than usable actors on the grand stage of cowsay; or
- offended my delicate sensibilities.

Users can add new cows to `resources/cows/custom/` if they want to make new cows available.

I have included a majestic original artwork depicting the "Companion Cube" character from //Portal//.

Test Plan: {F802535}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9408, T7785

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

+1105 -32
+31
externals/cowsay/ChangeLog
··· 1 + 3.03 28 May 1999 2 + - Added cows/tux.cow, as suggested by xmanoel@i.am 3 + - Compatibility with 5.6.0, due to a change in qw(). 4 + - Renamed devil.cow to daemon.cow, since I know better. :-) 5 + 6 + 3.02 04 November 1999 7 + - Fixed boneheaded code placement so that cowsay -l actually works. 8 + 9 + 3.01 01 November 1999 10 + - Fixed compatibility issues between the Text::Wrap module 11 + that changed between 5.005_02 and 5.005_03. 12 + - Fixed tab expansion issues with Text::Tabs. 13 + 14 + 3.0 13 April 1999, released 14 August 1999 15 + - Rewritten into Perl 5 and presented to the world. 16 + 17 + -- Not present in CVS from here on down -- 18 + 19 + 2.x Date? 20 + - Arbitrary messages. 21 + - Figlet support (-n). 22 + - Line wrap length (-w). 23 + - Multiple pre-set expressions. 24 + - Better arg parsing loop. 25 + - Message from stdin or command line. 26 + 27 + 1.0 Date? 28 + - SUBJECT is VERB OBJECT 29 + 30 + $Id: ChangeLog,v 1.4 2000/05/29 17:55:24 tony Exp $ 31 + This file is part of cowsay. (c) 1999-2000 Tony Monroe.
+15
externals/cowsay/INSTALL
··· 1 + ================= 2 + Installing cowsay 3 + ================= 4 + 5 + If you really want to get things installed a nice and pretty way, 6 + 7 + sh install.sh 8 + 9 + It will ask approximately one question. If you can't answer it, 10 + you need serious help. 11 + 12 + If the install goes well, you can start cowing immediately! Just 13 + be sure to read the manual page first... 14 + 15 + $Id: INSTALL,v 1.1 1999/08/14 08:03:17 tony Exp $
+36
externals/cowsay/LICENSE
··· 1 + ============== 2 + cowsay License 3 + ============== 4 + 5 + cowsay is distributed under the same licensing terms as Perl: the 6 + Artistic License or the GNU General Public License. If you don't 7 + want to track down these licenses and read them for yourself, use 8 + the parts that I'd prefer: 9 + 10 + (0) I wrote it and you didn't. 11 + 12 + (1) Give credit where credit is due if you borrow the code for some 13 + other purpose. 14 + 15 + (2) If you have any bugfixes or suggestions, please notify me so 16 + that I may incorporate them. 17 + 18 + (3) If you try to make money off of cowsay, you suck. 19 + 20 + =============== 21 + cowsay Legalese 22 + =============== 23 + 24 + (0) Copyright (c) 1999 Tony Monroe. All rights reserved. All 25 + lefts may or may not be reversed at my discretion. 26 + 27 + (1) This software package can be freely redistributed or modified 28 + under the terms described above in the "cowsay License" section 29 + of this file. 30 + 31 + (2) cowsay is provided "as is," with no warranties whatsoever, 32 + expressed or implied. If you want some implied warranty about 33 + merchantability and/or fitness for a particular purpose, you will 34 + not find it here, because there is no such thing here. 35 + 36 + (3) I hate legalese.
+11
externals/cowsay/MANIFEST
··· 1 + ChangeLog Changes to recent versions. 2 + INSTALL Instructions for installing cowsay. 3 + LICENSE The license for use and redistribution of cowsay. 4 + MANIFEST This file. 5 + README Read this first. Really. 6 + Wrap.pm.diff Diff for Text/Wrap.pm. 7 + cows/* Support files used by cowsay. 8 + cowsay Main cowsay executable. 9 + cowsay.1 Main cowsay manual page. 10 + install.sh cowsay installation script. 11 + pgp_public_key.txt Verify the signature file with this key.
+38
externals/cowsay/README
··· 1 + =========== 2 + cowsay 3.03 3 + =========== 4 + 5 + cowsay is a configurable talking cow, written in Perl. It operates 6 + much as the figlet program does, and it written in the same spirit 7 + of silliness. 8 + 9 + cowsay is actually a pretty old program. It has not really been 10 + released before, and I am releasing it in the hope that someone 11 + other than myself will be amused by it. 12 + 13 + The first major version of cowsay had one cow and one message 14 + template: $foo is $verb $bar. Not very flexible, but people managed 15 + to do pretty interesting things with it. The second major version 16 + scrapped many of the limitations of the first, by allowing arbitrary 17 + messages, multiple cowfiles, and even support for cows talking in 18 + figlet. The third version was a rewrite of the second into Perl 19 + 5, whereupon the code got a lot smaller and more manageable. :-) 20 + 21 + If you are using Perl 5.004, you may have problems with Text::Wrap. 22 + (Yeesh, this module changes more than it should...) I've included 23 + a diff for the Text::Wrap (version 97.011701) that is shipped with 24 + 5.004_04; the concept is simple enough that even older Perls can 25 + take advantage of this silly little patch; if there is a "sub fill" 26 + in the documentation for the module, copy it to a more useful 27 + section of that file. If not, just take "sub fill" wholesale from 28 + the patch. Oh, and consider upgrading to 5.005_03 or later. 29 + Please. You'll like it, I promise. 30 + 31 + To install cowsay, consult the INSTALL file in this directory. 32 + 33 + For the terms and conditions of use, consult the LICENSE file in 34 + this directory. 35 + 36 + -- Tony Monroe (tony@nog.net) 37 + 38 + $Id: README,v 1.3 2000/05/28 06:24:46 tony Exp $
+47
externals/cowsay/Wrap.pm.diff
··· 1 + *** Wrap.pm.in Thu May 22 00:21:42 1997 2 + --- Wrap.pm Fri Nov 12 10:00:15 1999 3 + *************** 4 + *** 3,9 **** 5 + require Exporter; 6 + 7 + @ISA = (Exporter); 8 + ! @EXPORT = qw(wrap); 9 + @EXPORT_OK = qw($columns); 10 + 11 + $VERSION = 97.011701; 12 + --- 3,9 ---- 13 + require Exporter; 14 + 15 + @ISA = (Exporter); 16 + ! @EXPORT = qw(wrap fill); 17 + @EXPORT_OK = qw($columns); 18 + 19 + $VERSION = 97.011701; 20 + *************** 21 + *** 66,71 **** 22 + --- 66,90 ---- 23 + 24 + print "-----------$r---------\n" if $debug;; 25 + return $r; 26 + + } 27 + + 28 + + ## Copied up from below. 29 + + sub fill 30 + + { 31 + + my ($ip, $xp, @raw) = @_; 32 + + my @para; 33 + + my $pp; 34 + + 35 + + for $pp (split(/\n\s+/, join("\n",@raw))) { 36 + + $pp =~ s/\s+/ /g; 37 + + my $x = wrap($ip, $xp, $pp); 38 + + push(@para, $x); 39 + + } 40 + + 41 + + # if paragraph_indent is the same as line_indent, 42 + + # separate paragraphs with blank lines 43 + + 44 + + return join ($ip eq $xp ? "\n\n" : "\n", @para); 45 + } 46 + 47 + 1;
+10
externals/cowsay/cows/bunny.cow
··· 1 + ## 2 + ## A cute little wabbit 3 + ## 4 + $the_cow = <<EOC; 5 + $thoughts 6 + $thoughts \\ 7 + \\ /\\ 8 + ( ) 9 + .( o ). 10 + EOC
+14
externals/cowsay/cows/cower.cow
··· 1 + ## 2 + ## A cowering cow 3 + ## 4 + $the_cow = <<EOC; 5 + $thoughts 6 + $thoughts 7 + ,__, | | 8 + (oo)\\| |___ 9 + (__)\\| | )\\_ 10 + | |_w | \\ 11 + | | || * 12 + 13 + Cower.... 14 + EOC
+24
externals/cowsay/cows/daemon.cow
··· 1 + ## 2 + ## 4.4 >> 5.4 3 + ## 4 + $the_cow = <<EOC; 5 + $thoughts , , 6 + $thoughts /( )` 7 + $thoughts \\ \\___ / | 8 + /- _ `-/ ' 9 + (/\\/ \\ \\ /\\ 10 + / / | ` \\ 11 + O O ) / | 12 + `-^--'`< ' 13 + (_.) _ ) / 14 + `.___/` / 15 + `-----' / 16 + <----. __ / __ \\ 17 + <----|====O)))==) \\) /==== 18 + <----' `--' `.__,' \\ 19 + | | 20 + \\ / 21 + ______( (_ / \\______ 22 + ,' ,-----' | \\ 23 + `--{__________) \\/ 24 + EOC
+7
externals/cowsay/cows/default.cow
··· 1 + $the_cow = <<"EOC"; 2 + $thoughts ^__^ 3 + $thoughts ($eyes)\\_______ 4 + (__)\\ )\\/\\ 5 + $tongue ||----w | 6 + || || 7 + EOC
+21
externals/cowsay/cows/dragon-and-cow.cow
··· 1 + ## 2 + ## A dragon smiting a cow, possible credit to kube@csua.berkeley.edu 3 + ## 4 + $the_cow = <<EOC; 5 + $thoughts ^ /^ 6 + $thoughts / \\ // \\ 7 + $thoughts |\\___/| / \\// .\\ 8 + $thoughts /O O \\__ / // | \\ \\ *----* 9 + / / \\/_/ // | \\ \\ \\ | 10 + \@___\@` \\/_ // | \\ \\ \\/\\ \\ 11 + 0/0/| \\/_ // | \\ \\ \\ \\ 12 + 0/0/0/0/| \\/// | \\ \\ | | 13 + 0/0/0/0/0/_|_ / ( // | \\ _\\ | / 14 + 0/0/0/0/0/0/`/,_ _ _/ ) ; -. | _ _\\.-~ / / 15 + ,-} _ *-.|.-~-. .~ ~ 16 + \\ \\__/ `/\\ / ~-. _ .-~ / 17 + \\____($eyes) *. } { / 18 + ( (--) .----~-.\\ \\-` .~ 19 + //__\\\\ \\__ Ack! ///.----..< \\ _ -~ 20 + // \\\\ ///-._ _ _ _ _ _ _{^ - - - - ~ 21 + EOC
+21
externals/cowsay/cows/dragon.cow
··· 1 + ## 2 + ## The Whitespace Dragon 3 + ## 4 + $the_cow = <<EOC; 5 + $thoughts / \\ //\\ 6 + $thoughts |\\___/| / \\// \\\\ 7 + /0 0 \\__ / // | \\ \\ 8 + / / \\/_/ // | \\ \\ 9 + \@_^_\@'/ \\/_ // | \\ \\ 10 + //_^_/ \\/_ // | \\ \\ 11 + ( //) | \\/// | \\ \\ 12 + ( / /) _|_ / ) // | \\ _\\ 13 + ( // /) '/,_ _ _/ ( ; -. | _ _\\.-~ .-~~~^-. 14 + (( / / )) ,-{ _ `-.|.-~-. .~ `. 15 + (( // / )) '/\\ / ~-. _ .-~ .-~^-. \\ 16 + (( /// )) `. { } / \\ \\ 17 + (( / )) .----~-.\\ \\-' .~ \\ `. \\^-. 18 + ///.----..> \\ _ -~ `. ^-` ^-_ 19 + ///-._ _ _ _ _ _ _}^ - - - - ~ ~-- ,.-~ 20 + /.-~ 21 + EOC
+15
externals/cowsay/cows/elephant.cow
··· 1 + ## 2 + ## An elephant out and about 3 + ## 4 + $the_cow = <<EOC; 5 + $thoughts /\\ ___ /\\ 6 + $thoughts // \\/ \\/ \\\\ 7 + (( O O )) 8 + \\\\ / \\ // 9 + \\/ | | \\/ 10 + | | | | 11 + | | | | 12 + | o | 13 + | | | | 14 + |m| |m| 15 + EOC
+16
externals/cowsay/cows/eyes.cow
··· 1 + ## 2 + ## Evil-looking eyes 3 + ## 4 + $the_cow = <<EOC; 5 + $thoughts 6 + $thoughts 7 + .::!!!!!!!:. 8 + .!!!!!:. .:!!!!!!!!!!!! 9 + ~~~~!!!!!!. .:!!!!!!!!!UWWW\$\$\$ 10 + :\$\$NWX!!: .:!!!!!!XUWW\$\$\$\$\$\$\$\$\$P 11 + \$\$\$\$\$##WX!: .<!!!!UW\$\$\$\$" \$\$\$\$\$\$\$\$# 12 + \$\$\$\$\$ \$\$\$UX :!!UW\$\$\$\$\$\$\$\$\$ 4\$\$\$\$\$* 13 + ^\$\$\$B \$\$\$\$\\ \$\$\$\$\$\$\$\$\$\$\$\$ d\$\$R" 14 + "*\$bd\$\$\$\$ '*\$\$\$\$\$\$\$\$\$\$\$o+#" 15 + """" """"""" 16 + EOC
+15
externals/cowsay/cows/flaming-sheep.cow
··· 1 + ## 2 + ## The flaming sheep, contributed by Geordan Rosario (geordan@csua.berkeley.edu) 3 + ## 4 + $the_cow = <<EOC; 5 + $thoughts . . . 6 + $thoughts . . . ` , 7 + $thoughts .; . : .' : : : . 8 + $thoughts i..`: i` i.i.,i i . 9 + $thoughts `,--.|i |i|ii|ii|i: 10 + U${eyes}U\\.'\@\@\@\@\@\@`.||' 11 + \\__/(\@\@\@\@\@\@\@\@\@\@)' 12 + (\@\@\@\@\@\@\@\@) 13 + `YY~~~~YY' 14 + || || 15 + EOC
+12
externals/cowsay/cows/head-in.cow
··· 1 + ## 2 + ## Go stick yer head in a cow. 3 + ## 4 + $the_cow = <<EOC; 5 + $thoughts 6 + $thoughts 7 + ^__^ / 8 + ($eyes)\\_______/ _________ 9 + (__)\\ )=( ____|_ \\_____ 10 + $tongue ||----w | \\ \\ \\_____ | 11 + || || || || 12 + EOC
+12
externals/cowsay/cows/kitty.cow
··· 1 + ## 2 + ## A kitten of sorts, I think 3 + ## 4 + $the_cow = <<EOC; 5 + $thoughts 6 + $thoughts 7 + ("`-' '-/") .___..--' ' "`-._ 8 + ` *_ * ) `-. ( ) .`-.__. `) 9 + (_Y_.) ' ._ ) `._` ; `` -. .-' 10 + _.. `--'_..-_/ /--' _ .' ,4 11 + ( i l ),-'' ( l i),' ( ( ! .-' 12 + EOC
+12
externals/cowsay/cows/koala.cow
··· 1 + ## 2 + ## From the canonical koala collection 3 + ## 4 + $the_cow = <<EOC; 5 + $thoughts 6 + $thoughts 7 + ___ 8 + {~._.~} 9 + ( Y ) 10 + ()~*~() 11 + (_)-(_) 12 + EOC
+15
externals/cowsay/cows/meow.cow
··· 1 + ## 2 + ## A meowing tiger? 3 + ## 4 + $the_cow = <<EOC; 5 + $thoughts 6 + $thoughts , _ ___.--'''`--''//-,-_--_. 7 + \\`"' ` || \\\\ \\ \\\\/ / // / ,-\\\\`,_ 8 + /'` \\ \\ || Y | \\|/ / // / - |__ `-, 9 + /\@"\\ ` \\ `\\ | | ||/ // | \\/ \\ `-._`-,_., 10 + / _.-. `.-\\,___/\\ _/|_/_\\_\\/|_/ | `-._._) 11 + `-'``/ / | // \\__/\\__ / \\__/ \\ 12 + `-' /-\\/ | -| \\__ \\ |-' | 13 + __/\\ / _/ \\/ __,-' ) ,' _|' 14 + (((__/(((_.' ((___..-'((__,' 15 + EOC
+14
externals/cowsay/cows/moofasa.cow
··· 1 + ## 2 + ## MOOfasa. 3 + ## 4 + $the_cow = <<EOC; 5 + $thoughts ____ 6 + $thoughts / \\ 7 + | ^__^ | 8 + | ($eyes) |______ 9 + | (__) | )\\/\\ 10 + \\____/|----w | 11 + || || 12 + 13 + Moofasa 14 + EOC
+9
externals/cowsay/cows/moose.cow
··· 1 + $the_cow = <<EOC; 2 + $thoughts 3 + $thoughts \\_\\_ _/_/ 4 + $thoughts \\__/ 5 + ($eyes)\\_______ 6 + (__)\\ )\\/\\ 7 + $tongue ||----w | 8 + || || 9 + EOC
+10
externals/cowsay/cows/mutilated.cow
··· 1 + ## 2 + ## A mutilated cow, from aspolito@csua.berkeley.edu 3 + ## 4 + $the_cow = <<EOC; 5 + $thoughts \\_______ 6 + v__v $thoughts \\ O ) 7 + ($eyes) ||----w | 8 + (__) || || \\/\\ 9 + $tongue 10 + EOC
+12
externals/cowsay/cows/satanic.cow
··· 1 + ## 2 + ## Satanic cow, source unknown. 3 + ## 4 + $the_cow = <<EOC; 5 + $thoughts 6 + $thoughts (__) 7 + (\\/) 8 + /-------\\/ 9 + / | 666 || 10 + * ||----|| 11 + ~~ ~~ 12 + EOC
+13
externals/cowsay/cows/sheep.cow
··· 1 + ## 2 + ## The non-flaming sheep. 3 + ## 4 + $the_cow = <<EOC 5 + $thoughts 6 + $thoughts 7 + __ 8 + U${eyes}U\\.'\@\@\@\@\@\@`. 9 + \\__/(\@\@\@\@\@\@\@\@\@\@) 10 + (\@\@\@\@\@\@\@\@) 11 + `YY~~~~YY' 12 + || || 13 + EOC
+15
externals/cowsay/cows/skeleton.cow
··· 1 + ## 2 + ## This 'Scowleton' brought to you by one of 3 + ## {appel,kube,rowe}@csua.berkeley.edu 4 + ## 5 + $the_cow = <<EOC; 6 + $thoughts (__) 7 + $thoughts /$eyes| 8 + $thoughts (_"_)*+++++++++* 9 + //I#\\\\\\\\\\\\\\\\I\\ 10 + I[I|I|||||I I ` 11 + I`I'///'' I I 12 + I I I I 13 + ~ ~ ~ ~ 14 + Scowleton 15 + EOC
+10
externals/cowsay/cows/small.cow
··· 1 + ## 2 + ## A small cow, artist unknown 3 + ## 4 + $eyes = ".." unless ($eyes); 5 + $the_cow = <<EOC; 6 + $thoughts ,__, 7 + $thoughts ($eyes)____ 8 + (__) )\\ 9 + $tongue||--|| * 10 + EOC
+13
externals/cowsay/cows/squirrel.cow
··· 1 + $the_cow = <<EOC; 2 + $thoughts 3 + $thoughts 4 + _ _ 5 + | \__/| .~ ~. 6 + /$eyes `./ .' 7 + {o__, \ { 8 + / . . ) \ 9 + `-` '-' \ } 10 + .( _( )_.' 11 + '---.~_ _ _| 12 + 13 + EOC
+19
externals/cowsay/cows/stegosaurus.cow
··· 1 + ## 2 + ## A stegosaur with a top hat? 3 + ## 4 + $the_cow = <<EOC; 5 + $thoughts . . 6 + $thoughts / `. .' " 7 + $thoughts .---. < > < > .---. 8 + $thoughts | \\ \\ - ~ ~ - / / | 9 + _____ ..-~ ~-..-~ 10 + | | \\~~~\\.' `./~~~/ 11 + --------- \\__/ \\__/ 12 + .' O \\ / / \\ " 13 + (_____, `._.' | } \\/~~~/ 14 + `----. / } | / \\__/ 15 + `-. | / | / `. ,~~| 16 + ~-.__| /_ - ~ ^| /- _ `..-' 17 + | / | / ~-. `-. _ _ _ 18 + |_____| |_____| ~ - . _ _ _ _ _> 19 + EOC
+10
externals/cowsay/cows/supermilker.cow
··· 1 + ## 2 + ## A cow being milked, probably from Lars Smith (lars@csua.berkeley.edu) 3 + ## 4 + $the_cow = <<EOC; 5 + $thoughts ^__^ 6 + $thoughts ($eyes)\\_______ ________ 7 + (__)\\ )\\/\\ |Super | 8 + $tongue ||----W | |Milker| 9 + || UDDDDDDDDD|______| 10 + EOC
+24
externals/cowsay/cows/surgery.cow
··· 1 + ## 2 + ## A cow operation, artist unknown 3 + ## 4 + $the_cow = <<EOC; 5 + $thoughts \\ / 6 + $thoughts \\/ 7 + (__) /\\ 8 + ($eyes) O O 9 + _\\/_ // 10 + * ( ) // 11 + \\ (\\\\ // 12 + \\( \\\\ ) 13 + ( \\\\ ) /\\ 14 + ___[\\______/^^^^^^^\\__/) o-)__ 15 + |\\__[=======______//________)__\\ 16 + \\|_______________//____________| 17 + ||| || //|| ||| 18 + ||| || @.|| ||| 19 + || \\/ .\\/ || 20 + . . 21 + '.'.` 22 + 23 + COW-OPERATION 24 + EOC
+26
externals/cowsay/cows/turkey.cow
··· 1 + ## 2 + ## Turkey! 3 + ## 4 + $the_cow = <<EOC; 5 + $thoughts ,+*^^*+___+++_ 6 + $thoughts ,*^^^^ ) 7 + $thoughts _+* ^**+_ 8 + $thoughts +^ _ _++*+_+++_, ) 9 + _+^^*+_ ( ,+*^ ^ \\+_ ) 10 + { ) ( ,( ,_+--+--, ^) ^\\ 11 + { (\@) } f ,( ,+-^ __*_*_ ^^\\_ ^\\ ) 12 + {:;-/ (_+*-+^^^^^+*+*<_ _++_)_ ) ) / 13 + ( / ( ( ,___ ^*+_+* ) < < \\ 14 + U _/ ) *--< ) ^\\-----++__) ) ) ) 15 + ( ) _(^)^^)) ) )\\^^^^^))^*+/ / / 16 + ( / (_))_^)) ) ) ))^^^^^))^^^)__/ +^^ 17 + ( ,/ (^))^)) ) ) ))^^^^^^^))^^) _) 18 + *+__+* (_))^) ) ) ))^^^^^^))^^^^^)____*^ 19 + \\ \\_)^)_)) ))^^^^^^^^^^))^^^^) 20 + (_ ^\\__^^^^^^^^^^^^))^^^^^^^) 21 + ^\\___ ^\\__^^^^^^))^^^^^^^^)\\\\ 22 + ^^^^^\\uuu/^^\\uuu/^^^^\\^\\^\\^\\^\\^\\^\\^\\ 23 + ___) >____) >___ ^\\_\\_\\_\\_\\_\\_\\) 24 + ^^^//\\\\_^^//\\\\_^ ^(\\_\\_\\_\\) 25 + ^^^ ^^ ^^^ ^ 26 + EOC
+20
externals/cowsay/cows/turtle.cow
··· 1 + ## 2 + ## A mysterious turtle... 3 + ## 4 + $the_cow = <<EOC; 5 + $thoughts ___-------___ 6 + $thoughts _-~~ ~~-_ 7 + $thoughts _-~ /~-_ 8 + /^\\__/^\\ /~ \\ / \\ 9 + /| O|| O| / \\_______________/ \\ 10 + | |___||__| / / \\ \\ 11 + | \\ / / \\ \\ 12 + | (_______) /______/ \\_________ \\ 13 + | / / \\ / \\ 14 + \\ \\^\\\\ \\ / \\ / 15 + \\ || \\______________/ _-_ //\\__// 16 + \\ ||------_-~~-_ ------------- \\ --/~ ~\\ || __/ 17 + ~-----||====/~ |==================| |/~~~~~ 18 + (_(__/ ./ / \\_\\ \\. 19 + (_(___/ \\_____)_) 20 + EOC
+16
externals/cowsay/cows/tux.cow
··· 1 + ## 2 + ## TuX 3 + ## (c) pborys@p-soft.silesia.linux.org.pl 4 + ## 5 + $the_cow = <<EOC; 6 + $thoughts 7 + $thoughts 8 + .--. 9 + |o_o | 10 + |:_/ | 11 + // \\ \\ 12 + (| | ) 13 + /'\\_ _/`\\ 14 + \\___)=(___/ 15 + 16 + EOC
+10
externals/cowsay/cows/www.cow
··· 1 + ## 2 + ## A cow wadvertising the World Wide Web, from lim@csua.berkeley.edu 3 + ## 4 + $the_cow = <<EOC; 5 + $thoughts ^__^ 6 + $thoughts ($eyes)\\_______ 7 + (__)\\ )\\/\\ 8 + $tongue ||--WWW | 9 + || || 10 + EOC
+187
externals/cowsay/cowsay
··· 1 + #%BANGPERL% 2 + 3 + ## 4 + ## Cowsay 3.03 5 + ## 6 + ## This file is part of cowsay. (c) 1999-2000 Tony Monroe. 7 + ## 8 + 9 + use Text::Tabs qw(expand); 10 + use Text::Wrap qw(wrap fill $columns); 11 + use File::Basename; 12 + use Getopt::Std; 13 + use Cwd; 14 + 15 + $version = "3.03"; 16 + $progname = basename($0); 17 + $eyes = "oo"; 18 + $tongue = " "; 19 + $cowpath = $ENV{'COWPATH'} || '%PREFIX%/share/cows'; 20 + @message = (); 21 + $thoughts = ""; 22 + 23 + ## Yeah, this is rude, I know. But hopefully it gets around a nasty 24 + ## little version dependency. 25 + 26 + $Text::Wrap::initial_tab = 8; 27 + $Text::Wrap::subsequent_tab = 8; 28 + $Text::Wrap::tabstop = 8; 29 + 30 + ## One of these days, we'll get it ported to Windows. Yeah, right. 31 + 32 + if (($^O eq "MSWin32") or ($^O eq "Windows_NT")) { ## Many perls, eek! 33 + $pathsep = ';'; 34 + } else { 35 + $pathsep = ':'; 36 + } 37 + 38 + %opts = ( 39 + 'e' => 'oo', 40 + 'f' => 'default.cow', 41 + 'n' => 0, 42 + 'T' => ' ', 43 + 'W' => 40, 44 + ); 45 + 46 + getopts('bde:f:ghlLnNpstT:wW:y', \%opts); 47 + 48 + &display_usage if $opts{'h'}; 49 + &list_cowfiles if $opts{'l'}; 50 + 51 + $borg = $opts{'b'}; 52 + $dead = $opts{'d'}; 53 + $greedy = $opts{'g'}; 54 + $paranoid = $opts{'p'}; 55 + $stoned = $opts{'s'}; 56 + $tired = $opts{'t'}; 57 + $wired = $opts{'w'}; 58 + $young = $opts{'y'}; 59 + $eyes = substr($opts{'e'}, 0, 2); 60 + $tongue = substr($opts{'T'}, 0, 2); 61 + $the_cow = ""; 62 + 63 + &slurp_input; 64 + $Text::Wrap::columns = $opts{'W'}; 65 + @message = ($opts{'n'} ? expand(@message) : 66 + split("\n", fill("", "", @message))); 67 + &construct_balloon; 68 + &construct_face; 69 + &get_cow; 70 + print @balloon_lines; 71 + print $the_cow; 72 + 73 + sub list_cowfiles { 74 + my $basedir; 75 + my @dirfiles; 76 + chop($basedir = cwd); 77 + for my $d (split(/$pathsep/, $cowpath)) { 78 + print "Cow files in $d:\n"; 79 + opendir(COWDIR, $d) || die "$0: Cannot open $d\n"; 80 + for my $file (readdir COWDIR) { 81 + if ($file =~ s/\.cow$//) { 82 + push(@dirfiles, $file); 83 + } 84 + } 85 + closedir(COWDIR); 86 + print wrap("", "", sort @dirfiles), "\n"; 87 + @dirfiles = (); 88 + chdir($basedir); 89 + } 90 + exit(0); 91 + } 92 + 93 + sub slurp_input { 94 + unless ($ARGV[0]) { 95 + chomp(@message = <STDIN>); 96 + } else { 97 + &display_usage if $opts{'n'}; 98 + @message = join(' ', @ARGV); 99 + } 100 + } 101 + 102 + sub maxlength { 103 + my ($l, $m); 104 + $m = -1; 105 + for my $i (@_) { 106 + $l = length $i; 107 + $m = $l if ($l > $m); 108 + } 109 + return $m; 110 + } 111 + 112 + sub construct_balloon { 113 + my $max = &maxlength(@message); 114 + my $max2 = $max + 2; ## border space fudge. 115 + my $format = "%s %-${max}s %s\n"; 116 + my @border; ## up-left, up-right, down-left, down-right, left, right 117 + if ($0 =~ /think/i) { 118 + $thoughts = 'o'; 119 + @border = qw[ ( ) ( ) ( ) ]; 120 + } elsif (@message < 2) { 121 + $thoughts = '\\'; 122 + @border = qw[ < > ]; 123 + } else { 124 + $thoughts = '\\'; 125 + if ($V and $V gt v5.6.0) { # Thanks, perldelta. 126 + @border = qw[ / \\ \\ / | | ]; 127 + } else { 128 + @border = qw[ / \ \ / | | ]; 129 + } 130 + } 131 + push(@balloon_lines, 132 + " " . ("_" x $max2) . " \n" , 133 + sprintf($format, $border[0], $message[0], $border[1]), 134 + (@message < 2 ? "" : 135 + map { sprintf($format, $border[4], $_, $border[5]) } 136 + @message[1 .. $#message - 1]), 137 + (@message < 2 ? "" : 138 + sprintf($format, $border[2], $message[$#message], $border[3])), 139 + " " . ("-" x $max2) . " \n" 140 + ); 141 + } 142 + 143 + sub construct_face { 144 + if ($borg) { $eyes = "=="; } 145 + if ($dead) { $eyes = "xx"; $tongue = "U "; } 146 + if ($greedy) { $eyes = "\$\$"; } 147 + if ($paranoid) { $eyes = "@@"; } 148 + if ($stoned) { $eyes = "**"; $tongue = "U "; } 149 + if ($tired) { $eyes = "--"; } 150 + if ($wired) { $eyes = "OO"; } 151 + if ($young) { $eyes = ".."; } 152 + } 153 + 154 + sub get_cow { 155 + ## 156 + ## Get a cow from the specified cowfile; otherwise use the default cow 157 + ## which was defined above in $the_cow. 158 + ## 159 + my $f = $opts{'f'}; 160 + my $full = ""; 161 + if ($opts{'f'} =~ m,/,) { 162 + $full = $opts{'f'}; 163 + } else { 164 + for my $d (split(/:/, $cowpath)) { 165 + if (-f "$d/$f") { 166 + $full = "$d/$f"; 167 + last; 168 + } elsif (-f "$d/$f.cow") { 169 + $full = "$d/$f.cow"; 170 + last; 171 + } 172 + } 173 + if ($full eq "") { 174 + die "$progname: Could not find $f cowfile!\n"; 175 + } 176 + } 177 + do $full; 178 + die "$progname: $@\n" if $@; 179 + } 180 + 181 + sub display_usage { 182 + die <<EOF; 183 + cow{say,think} version $version, (c) 1999 Tony Monroe 184 + Usage: $progname [-bdgpstwy] [-h] [-e eyes] [-f cowfile] 185 + [-l] [-n] [-T tongue] [-W wrapcolumn] [message] 186 + EOF 187 + }
+168
externals/cowsay/cowsay.1
··· 1 + .\" 2 + .\" cowsay.1 3 + .\" 4 + .\" $Id: cowsay.1,v 1.4 1999/11/04 19:50:40 tony Exp $ 5 + .\" 6 + .\" This file is part of cowsay. (c) 1999 Tony Monroe. 7 + .\" 8 + .ds Nm Cowsay 9 + .ds nm cowsay 10 + .ds Vn 3.02 11 + .TH \*(nm 1 "$Date: 1999/11/04 19:50:40 $" 12 + .SH NAME 13 + \*(nm/cowthink \- configurable speaking/thinking cow (and a bit more) 14 + .SH SYNOPSIS 15 + cowsay 16 + .RB [ \-e 17 + .IR eye_string ] 18 + .RB [ \-f 19 + .IR cowfile ] 20 + .RB [ \-h ] 21 + .RB [ \-l ] 22 + .RB [ \-n ] 23 + .RB [ \-T 24 + .IR tongue_string ] 25 + .RB [ \-W 26 + .IR column ] 27 + .RB [ \-bdgpstwy ] 28 + .SH DESCRIPTION 29 + .I Cowsay 30 + generates an ASCII picture of a cow saying something provided by the 31 + user. If run with no arguments, it accepts standard input, word-wraps 32 + the message given at about 40 columns, and prints the cow saying the 33 + given message on standard output. 34 + .PP 35 + To aid in the use of arbitrary messages with arbitrary whitespace, 36 + use the 37 + .B \-n 38 + option. If it is specified, the given message will not be 39 + word-wrapped. This is possibly useful if you want to make the cow 40 + think or speak in figlet(6). If 41 + .B \-n 42 + is specified, there must not be any command-line arguments left 43 + after all the switches have been processed. 44 + .PP 45 + The 46 + .B \-W 47 + specifies roughly (where the message should be wrapped. The default 48 + is equivalent to 49 + .B \-W 40 50 + i.e. wrap words at or before the 40th column. 51 + .PP 52 + If any command-line arguments are left over after all switches have 53 + been processed, they become the cow's message. The program will not 54 + accept standard input for a message in this case. 55 + .PP 56 + There are several provided modes which change the appearance of the 57 + cow depending on its particular emotional/physical state. The 58 + .B \-b 59 + option initiates Borg mode; 60 + .B \-d 61 + causes the cow to appear dead; 62 + .B \-g 63 + invokes greedy mode; 64 + .B \-p 65 + causes a state of paranoia to come over the cow; 66 + .B \-s 67 + makes the cow appear thoroughly stoned; 68 + .B \-t 69 + yields a tired cow; 70 + .B \-w 71 + is somewhat the opposite of 72 + .BR \-t , 73 + and initiates wired mode; 74 + .B \-y 75 + brings on the cow's youthful appearance. 76 + .PP 77 + The user may specify the 78 + .B \-e 79 + option to select the appearance of the cow's eyes, in which case 80 + the first two characters of the argument string 81 + .I eye_string 82 + will be used. The default eyes are 'oo'. The tongue is similarly 83 + configurable through 84 + .B \-T 85 + and 86 + .IR tongue_string ; 87 + it must be two characters and does not appear by default. However, 88 + it does appear in the 'dead' and 'stoned' modes. Any configuration 89 + done by 90 + .B \-e 91 + and 92 + .B \-T 93 + will be lost if one of the provided modes is used. 94 + .PP 95 + The 96 + .B \-f 97 + option specifies a particular cow picture file (``cowfile'') to 98 + use. If the cowfile spec contains '/' then it will be interpreted 99 + as a path relative to the current directory. Otherwise, cowsay 100 + will search the path specified in the 101 + .B COWPATH 102 + environment variable. 103 + To list all cowfiles on the current 104 + .BR COWPATH , 105 + invoke 106 + .B \*(nm 107 + with the 108 + .B \-l 109 + switch. 110 + .PP 111 + If the program is invoked as 112 + .B cowthink 113 + then the cow will think its message instead of saying it. 114 + .PP 115 + .SH COWFILE FORMAT 116 + A cowfile is made up of a simple block of 117 + .BR perl (1) 118 + code, which assigns a picture of a cow to the variable 119 + .BR $the_cow . 120 + Should you wish to customize the eyes or the tongue of the cow, 121 + then the variables 122 + .B $eyes 123 + and 124 + .B $tongue 125 + may be used. The trail leading up to the cow's message balloon is 126 + composed of the character(s) in the 127 + .B $thoughts 128 + variable. Any backslashes must be reduplicated to prevent 129 + interpolation. The name of a cowfile should end with 130 + .BR .cow , 131 + otherwise it is assumed not to be a cowfile. Also, at-signs (``@'') 132 + must be backslashed because that is what Perl 5 expects. 133 + .PP 134 + .SH COMPATIBILITY WITH OLDER VERSIONS 135 + .PP 136 + What older versions? :-) 137 + .PP 138 + Version 3.x is fully backward-compatible with 2.x versions. If 139 + you're still using a 1.x version, consider upgrading. And tell me 140 + where you got the older versions, since I didn't exactly put them 141 + up for world-wide access. 142 + .PP 143 + Oh, just so you know, this manual page documents version \*(Vn of 144 + cowsay. 145 + .SH ENVIRONMENT 146 + The COWPATH environment variable, if present, will be used to search 147 + for cowfiles. It contains a colon-separated list of directories, 148 + much like 149 + .B PATH or 150 + .BR MANPATH . 151 + It should always contain the 152 + .B /usr/local/share/cows 153 + directory, or at least a directory with a file called 154 + .B default.cow 155 + in it. 156 + .SH FILES 157 + .B %PREFIX%/share/cows 158 + holds a sample set of cowfiles. If your 159 + .B COWPATH 160 + is not explicitly set, it automatically contains this directory. 161 + .SH BUGS 162 + If there are any, please notify the author at the address below. 163 + .SH AUTHOR 164 + Tony Monroe (tony@nog.net), with suggestions from Shannon 165 + Appel (appel@CSUA.Berkeley.EDU) and contributions from Anthony Polito 166 + (aspolito@CSUA.Berkeley.EDU). 167 + .SH SEE ALSO 168 + perl(1), wall(1), nwrite(1), figlet(6)
+92
externals/cowsay/install.sh
··· 1 + #!/bin/sh 2 + 3 + ## 4 + ## install.sh 5 + ## 6 + ## Installation script for cowsay. 7 + ## 8 + ## $Id: install.sh,v 1.5 1999/11/01 20:19:21 tony Exp $ 9 + ## 10 + ## This file is part of cowsay. (c) 1999 Tony Monroe. 11 + ## 12 + 13 + rcs_id='$Id: install.sh,v 1.5 1999/11/01 20:19:21 tony Exp $' 14 + 15 + filelist='cows' 16 + 17 + cat <<DOG 18 + =================== 19 + cowsay Installation 20 + =================== 21 + 22 + Searching for useful perl executables... 23 + DOG 24 + 25 + backdoor=$1 26 + 27 + pathdirs=`echo $PATH | tr : " "` 28 + for p in $pathdirs; do 29 + set $p/perl $p/perl5* 30 + while [ ! -z "$1" ]; do 31 + if [ -x "$1" ]; then 32 + echo Found perl in $1 33 + perls="$perls $1" 34 + fi 35 + shift 36 + done 37 + done 38 + for perl in $perls; do 39 + if $perl -MText::Wrap -e0 >/dev/null 2>&1; then 40 + echo Found a good perl in $perl 41 + goodperls="$goodperls $perl" 42 + fi 43 + done 44 + echo The following perl executables will run cowsay: 45 + echo $goodperls 46 + echo I recommend the latest stable perl you can find. 47 + set $goodperls 48 + if [ -z "$1" ]; then 49 + echo Ack! You do not have Perl 5 installed correctly! 50 + echo Get thee to CPAN! 51 + exit 1 52 + fi 53 + usethisperl=$1 54 + echo I will be using $1 because I know it will work. 55 + 56 + echo Now I need an installation prefix. I will use /usr/local unless 57 + printf "you give me a better idea here: " 58 + if [ -n "$backdoor" ]; then 59 + prefix=$backdoor 60 + printf "%s (specified on command line)\n" $prefix 61 + else 62 + read prefix 63 + fi 64 + 65 + PREFIX=${prefix:-/usr/local} 66 + 67 + echo Okay, time to install this puppy. 68 + 69 + echo s,%BANGPERL%,!$usethisperl,\; > install.pl 70 + echo s,%PREFIX%,$PREFIX,\; >> install.pl 71 + set -x 72 + mkdir -p $PREFIX/bin || (mkdir $PREFIX; mkdir $PREFIX/bin) 73 + $usethisperl -p install.pl cowsay > $PREFIX/bin/cowsay 74 + chmod a+x $PREFIX/bin/cowsay 75 + ln -s cowsay $PREFIX/bin/cowthink 76 + mkdir -p $PREFIX/man/man1 || ($mkdir $PREFIX; mkdir $PREFIX/man; mkdir $PREFIX/man/man1) 77 + $usethisperl -p install.pl cowsay.1 > $PREFIX/man/man1/cowsay.1 78 + chmod a+r $PREFIX/man/man1/cowsay.1 79 + ln -s cowsay.1 $PREFIX/man/man1/cowthink.1 80 + mkdir -p $PREFIX/share/cows || (mkdir $PREFIX; mkdir $PREFIX/share; mkdir $PREFIX/share/cows) 81 + tar -cf - $filelist | (cd $PREFIX/share && tar -xvf -) 82 + set +x 83 + 84 + echo Okay, let us see if the install actually worked. 85 + 86 + if [ ! -f $PREFIX/share/cows/default.cow ]; then 87 + echo The default cow file did not make it across! 88 + echo Ooops, it failed...sorry! 89 + exit 1 90 + fi 91 + 92 + echo Installation complete! Enjoy the cows!
+14
externals/cowsay/pgp_public_key.txt
··· 1 + -----BEGIN PGP PUBLIC KEY BLOCK----- 2 + Version: 2.6.2 3 + 4 + mQCNAzNS+H4AAAEEAMilCcxLMIqMNXhZoeHjbeJGnHoKP0JpKDejz66qBlDwP+du 5 + FvVBHkyNIuU3orKe7l/aXIR8TcpjrxdcmrjjzwuB1aV48V4swT7v9UXvv9YP41Pd 6 + 1pXYXNelXHmE0eKSfcnkkFmYTJBXPaPNTJ3rpZpZOEW3SfgrrheqQm6w/6IJAAUR 7 + tBpUb255IE1vbnJvZSA8dG9ueUBub2cubmV0PrQdVG9ueSBNb25yb2UgPHRtb25y 8 + b2VAbm9nLm5ldD6JAJUDBRA2bDA5F6pCbrD/ogkBASOZA/9XtYSpcPjpi62MTEZl 9 + l+wV1svtlUlPvKkDE7FB9bwnMbF1FgGhTe/H4/8qDu20m5eGxMX58Ri7HPXWjjJ/ 10 + CrUWMzGVbg1JBkgh+d9QvEywmR0j4WezaifW1nCbxk0GrW1PjJyGb3kx7vrIF1Km 11 + xt6VwxTgfJzjIioBJFb4EiDyaLQnVG9ueSBNb25yb2UgPHRtb25yb2VAQ1NVQS5C 12 + ZXJrZWxleS5FRFU+ 13 + =WpM4 14 + -----END PGP PUBLIC KEY BLOCK-----
+9
resources/cows/builtin/companion.cow
··· 1 + $thoughts 2 + $thoughts 3 + /---\__/---\\ 4 + | / .... \ || 5 + \ ..--.. // 6 + |..($eyes). || 7 + / ..--.. \\ 8 + | \ .... / || 9 + \---/--\---//
+2
resources/cows/custom/README
··· 1 + You can add custom ".cow" files here to make them available to the "cowsay" 2 + interpreter in Remarkup.
+40 -32
src/infrastructure/markup/interpreter/PhabricatorRemarkupCowsayBlockInterpreter.php
··· 8 8 } 9 9 10 10 public function markupContent($content, array $argv) { 11 - if (!Filesystem::binaryExists('cowsay')) { 12 - return $this->markupError( 13 - pht( 14 - 'Unable to locate the `%s` binary. Install cowsay.', 15 - 'cowsay')); 16 - } 17 - 18 - $bin = idx($argv, 'think') ? 'cowthink' : 'cowsay'; 11 + $action = idx($argv, 'think') ? 'think' : 'say'; 19 12 $eyes = idx($argv, 'eyes', 'oo'); 20 13 $tongue = idx($argv, 'tongue', ' '); 21 - $cow = idx($argv, 'cow', 'default'); 22 14 23 - // NOTE: Strip this aggressively to prevent nonsense like 24 - // `cow=/etc/passwd`. We could build a whiltelist with `cowsay -l`. 25 - $cow = preg_replace('/[^a-z.-]+/', '', $cow); 26 - 27 - $future = new ExecFuture( 28 - '%s -e %s -T %s -f %s ', 29 - $bin, 30 - $eyes, 31 - $tongue, 32 - $cow); 15 + $map = self::getCowMap(); 33 16 34 - $future->setTimeout(15); 35 - $future->write($content); 36 - 37 - list($err, $stdout, $stderr) = $future->resolve(); 38 - 39 - if ($err) { 40 - return $this->markupError( 41 - pht( 42 - 'Execution of `%s` failed: %s', 43 - 'cowsay', 44 - $stderr)); 17 + $cow = idx($argv, 'cow'); 18 + $cow = phutil_utf8_strtolower($cow); 19 + if (empty($map[$cow])) { 20 + $cow = 'default'; 45 21 } 46 22 23 + $result = id(new PhutilCowsay()) 24 + ->setTemplate($map[$cow]) 25 + ->setAction($action) 26 + ->setEyes($eyes) 27 + ->setTongue($tongue) 28 + ->setText($content) 29 + ->renderCow(); 47 30 48 31 if ($this->getEngine()->isTextMode()) { 49 - return $stdout; 32 + return $result; 50 33 } 51 34 52 35 return phutil_tag( ··· 54 37 array( 55 38 'class' => 'PhabricatorMonospaced remarkup-cowsay', 56 39 ), 57 - $stdout); 40 + $result); 41 + } 42 + 43 + private static function getCowMap() { 44 + $root = dirname(phutil_get_library_root('phabricator')); 45 + 46 + $directories = array( 47 + $root.'/externals/cowsay/cows/', 48 + $root.'/resources/cows/builtin/', 49 + $root.'/resources/cows/custom/', 50 + ); 51 + 52 + $map = array(); 53 + foreach ($directories as $directory) { 54 + foreach (Filesystem::listDirectory($directory, false) as $cow_file) { 55 + $matches = null; 56 + if (!preg_match('/^(.*)\.cow\z/', $cow_file, $matches)) { 57 + continue; 58 + } 59 + $cow_name = $matches[1]; 60 + $cow_name = phutil_utf8_strtolower($cow_name); 61 + $map[$cow_name] = Filesystem::readFile($directory.$cow_file); 62 + } 63 + } 64 + 65 + return $map; 58 66 } 59 67 60 68 }