Jaidyn Lev authored on 2019-01-20 05:42:07
Showing 8 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,72 @@
1
+===============================================================================
2
+UNICHAT.SH                                       Read Unichat in your terminal!
3
+===============================================================================
4
+
5
+With unichat.sh, you can read Unichat the way gods intended: in your terminal,
6
+in pretty ANSI-formatted text! <3
7
+
8
+unichat.sh supports regular monochrome text, 8-bit ANSI colors, and (if you're
9
+one of those lucky lads who gets them) 255-range ANSI colors!
10
+
11
+https://unichat-comic.com
12
+
13
+
14
+
15
+----------------------------------------
16
+PRE-REQUISITES
17
+----------------------------------------
18
+You'll need:
19
+	* `lynx` installed
20
+	* a POSIX-compatible shell (tested with `pdksh` and `bash`)
21
+	* "gendl" in your $PATH
22
+	* "uclib/" in your CWD or in the dir that "unichat.sh" resides in
23
+
24
+
25
+
26
+----------------------------------------
27
+USAGE
28
+----------------------------------------
29
+
30
+UNICHAT.SH
31
+--------------------
32
+Run unichat.sh in your terminal, like so:
33
+
34
+	unichat.sh id [width] [color]
35
+
36
+id is the only required option.
37
+
38
+id, of course, means the comic ID that you want to read.
39
+width is the width of each line-- default is 80 characters.
40
+color is the color-type you want-- 0, 8, and 255 are the only valid options.
41
+
42
+
43
+UCGEN.SH
44
+--------------------
45
+ucgen.sh will download all unichat comics in the format you provide.
46
+It's for stripping the site, basically. :)
47
+
48
+	ucgen.sh [width] [color]
49
+
50
+The comics will be output into a subdir of your cwd, with a name based on
51
+the width and color values you provided, I.E., "80-255" or something like that.
52
+
53
+
54
+GENDL
55
+--------------------
56
+gendl is just for downloading things, as a frontend for "curl" "wget" etc.
57
+It's here for portability reasons-- you probably don't want to use it yourself.
58
+
59
+But here's usage, if you decide you do:
60
+
61
+	gendl [-o path] url 
62
+
63
+gendl downloads the URL to stdout, unless you specify an output file with "-o".
64
+
65
+
66
+
67
+----------------------------------------
68
+BORING STUFF
69
+----------------------------------------
70
+License is CC-0
71
+Author is Jenga Phoenix <jadedctrl@teknik.io>
72
+Sauce is at https://git.eunichx.us/unichat
0 73
new file mode 100755
... ...
@@ -0,0 +1,155 @@
1
+#!/bin/sh
2
+##############################
3
+# name: gendl
4
+# lisc: gnu gplv3
5
+# desc: download to stdout or
6
+#       file, independent of
7
+#       a specific downloader.
8
+#       ftp/wget/curl support.
9
+# main: jadedctrl
10
+##############################
11
+
12
+# usage: gendl [-o output] url
13
+
14
+
15
+
16
+#---------------------------------------
17
+# backend bits
18
+
19
+# NIL --> STRING
20
+# return the download program you're using
21
+function download_program
22
+{
23
+	programs="ftp curl wget"
24
+	current=""
25
+
26
+	for program in $programs
27
+	do
28
+		if whereis $program > /dev/null
29
+		then
30
+			current=$program
31
+		fi
32
+	done
33
+
34
+	if uname -s | grep -e "LibertyBSD" -e "OpenBSD" > /dev/null
35
+	then
36
+		current="ftp"
37
+	fi
38
+
39
+	echo "$current"
40
+}
41
+
42
+# STRING PATH --> NIL
43
+# download URL $1 to stdout
44
+function download_stdout
45
+{
46
+	program=$(download_program)
47
+	url=$1
48
+
49
+	case "$program" in
50
+		"ftp")
51
+			output="$(ftp -VMo- $url)"
52
+			;;
53
+		"curl")
54
+			output="$(curl $url)"
55
+			;;
56
+		"wget")
57
+			output="$(wget --quiet -O $url)"
58
+			;;
59
+	esac
60
+
61
+	return_code=$?
62
+
63
+	echo "$output"
64
+	return $return_code
65
+}
66
+
67
+# STRING PATH --> NIL
68
+# download URL $1 to path $2
69
+function download_file
70
+{
71
+	program=$(download_program)
72
+	url=$1
73
+	path=$2
74
+
75
+	case "$program" in
76
+		"ftp")
77
+			ftp -VMU "." -o $path $url
78
+			;;
79
+		"curl")
80
+			curl -o $path $url
81
+			;;
82
+		"wget")
83
+			wget --quiet -O $path $url
84
+			;;
85
+	esac
86
+
87
+	return_code=$?
88
+
89
+	if test $return_code -ne 0 2>/dev/null
90
+	then
91
+		rm $path 2> /dev/null
92
+		# for consistency in behavior; wget saves 404s anyway, whereas
93
+		# ftp doesn't save anything from 404s, etc.
94
+	fi
95
+
96
+	return $return_code
97
+}
98
+
99
+
100
+
101
+# --------------------------------------
102
+# front-end string-manip
103
+
104
+# STRING --> STRING
105
+# return the last word in a string
106
+function last_word
107
+{
108
+	string="$1"
109
+
110
+	echo "$string" \
111
+	| rev \
112
+	| sed 's% .*%%' \
113
+	| rev
114
+}
115
+
116
+function usage
117
+{
118
+	echo "usage: gendl [-o output] URL"
119
+}
120
+
121
+
122
+
123
+# --------------------------------------
124
+# invocation
125
+
126
+args="$(getopt o: $*)"
127
+if test -z "$@" 2>/dev/null
128
+then
129
+	usage
130
+	exit 2
131
+fi
132
+
133
+
134
+set -- $args
135
+while test $# -ne 0
136
+do
137
+	case "$1"
138
+	in
139
+		-o)
140
+			download_path="$2"; shift; shift;;
141
+		--)
142
+			shift; break;;
143
+	esac
144
+done
145
+
146
+
147
+url="$(last_word "$@")"
148
+
149
+
150
+if test -n "$download_path" 2> /dev/null
151
+then
152
+	download_file $url $download_path
153
+else
154
+	download_stdout "$url"
155
+fi
0 156
new file mode 100644
... ...
@@ -0,0 +1,27 @@
1
+#!/bin/sh
2
+########################################
3
+# name: gen.sh
4
+# desc: generate txt-versions of all
5
+#       unichat comics, in the given
6
+#       width/color format
7
+########################################
8
+
9
+WIDTH="$1"
10
+COLOR="$2"
11
+
12
+if test -z "$1" -o -z "$2"
13
+then
14
+	echo "usage: ucgen.sh width color"
15
+	exit 2
16
+fi
17
+
18
+dir="$COLOR-$WIDTH"
19
+mkdir "$dir"
20
+
21
+i=1
22
+while test $i -lt 194
23
+do
24
+	echo "Page $i..."
25
+	sh unichat.sh $i $WIDTH $COLOR > "$dir/$i.txt"
26
+	i=$(echo "$i + 1" | bc)
27
+done
0 28
new file mode 100644
... ...
@@ -0,0 +1,65 @@
1
+#!/bin/sh
2
+
3
+# --------------------------------------
4
+# main
5
+
6
+# STRING --> STRING
7
+# return the 255 color of a username
8
+function name_color255 {
9
+	username="$1"
10
+	result_stack=""
11
+
12
+	hex=$(name_color_hex "$username");	result_stack="$result_stack $?"
13
+	hex255=$(hex_to_255 $hex);		result_stack="$result_stack $?"
14
+	color="$(color_255 $hex255)";		result_stack="$result_stack $?"
15
+
16
+
17
+	if echo "$result_stack" | grep 1 > /dev/null
18
+	then
19
+		color="$(name_color8 "$username")"
20
+	fi
21
+
22
+	echo "$color"
23
+}
24
+
25
+
26
+
27
+# --------------------------------------
28
+# helper functions
29
+
30
+# STRING --> STRING
31
+# return the hexcode of a username (from CSS)
32
+function name_color_hex {
33
+	username="$1"
34
+
35
+	if test ! -e /tmp/255.html; then
36
+		gendl -o /tmp/255.html "http://unichat-comic.com/comics/1"
37
+	fi
38
+
39
+	cat /tmp/255.html \
40
+	| grep ".${username} { color:" \
41
+	| sed 's/.*color: #//' \
42
+	| sed 's/ \!important.*//'
43
+}
44
+
45
+# STRING --> NUMBER
46
+# return the 255 number of a color hexcode
47
+# from https://unix.stackexchange.com/a/269085
48
+function hex_to_255 {
49
+	hex=${1#"#"}
50
+	r=$(printf '0x%0.2s' "$hex" 2>/dev/null)
51
+	g=$(printf '0x%0.2s' ${hex#??} 2>/dev/null)
52
+	b=$(printf '0x%0.2s' ${hex#????} 2>/dev/null)
53
+	printf '%03d' "$(( (r<75?0:(r-35)/40)*6*6 + 
54
+			(g<75?0:(g-35)/40)*6   +
55
+			(b<75?0:(b-35)/40)     + 16 ))" 2>/dev/null
56
+}
57
+
58
+# NUMBER --> STRING
59
+# return 255 ANSI escape-code of a color
60
+# frlom https://unix.stackexchange.com/a/269085
61
+function color_255 {
62
+	for c; do
63
+		printf '\e[38;5;%dm' $c  2>/dev/null
64
+	done
65
+}
0 66
new file mode 100755
... ...
@@ -0,0 +1,150 @@
1
+#!/bin/sh
2
+
3
+
4
+function name_color8 {
5
+	username="$1"
6
+
7
+	case "$username" in
8
+		"SonjaOfTheMoon") echo "$MAGENTA";;
9
+		"EntropicPhantom") echo "$YELLOW";;
10
+		"Sidhe_Trickster") echo "$GREEN";;
11
+		"SecundaSonja") echo "$MAGENTA";;
12
+		"CmdrCordovaOfficial") echo "$CYAN";;
13
+		"LieutenantCordova") echo "$YELLOW";;
14
+		"pwnz0rz") echo "$CYAN";;
15
+		"pwnz1ing") echo "$YELLOW";;
16
+		"pwnz2much") echo "$YELLOW";;
17
+		"pwnz3r") echo "$CYAN";;
18
+		"metampsychotic") echo "$YELLOW";;
19
+		"FelisKitty") echo "$GREEN";;
20
+		"CGoddess") echo "$CYAN";;
21
+		"MatttheRA") echo "$MAGENTA";;
22
+		"ReverseTheStreams") echo "$RED";;
23
+		"Reverse_The_Streams") echo "$RED";;
24
+		"dukerex") echo "$ORANGE";;
25
+		"ItsDuckKingKarl") echo "$YELLOW";;
26
+		"bloodshoes") echo "$ORANGE";;
27
+		"AdmiralPancake") echo "$RED";;
28
+		"Admiral_Pancake") echo "$RED";;
29
+		"Admiral.Pancake") echo "$RED";;
30
+		"Pancake_High_Admiral") echo "$RED";;
31
+		"romanceconspirator") echo "$CYAN";;
32
+		"apocalypseconspirator") echo "$CYAN";;
33
+		"aardvarkconspirator") echo "$CYAN";;
34
+		"silentconspirator") echo "$CYAN";;
35
+		"Empress_Of_Silence") echo "$CYAN";;
36
+		"banannaconspirator") echo "$CYAN";;
37
+		"billygoatconspirator") echo "$CYAN";;
38
+		"bobtheconspirator") echo "$CYAN";;
39
+		"quixoticconspirator") echo "$CYAN";;
40
+		"yellowconspirator") echo "$CYAN";;
41
+		"lemmingconspirator") echo "$CYAN";;
42
+		"largeconspirator") echo "$CYAN";;
43
+		"sillyconspirator") echo "$CYAN";;
44
+		"lackadaisicalconspirator") echo "$CYAN";;
45
+		"bouncyconspirator") echo "$CYAN";;
46
+		"wildfireconspirator") echo "$CYAN";;
47
+		"zygoteconspirator") echo "$CYAN";;
48
+		"Pancomputer") echo "$GREEN";;
49
+		"Anarchon") echo "$YELLOW";;
50
+		"DrHorrible") echo "$YELLOW";;
51
+		"venemous") echo "$BLUE";;
52
+		"m1ndh1ve1") echo "$GREEN";;
53
+		"Bulwark") echo "$GREEN";;
54
+		"BULWARK") echo "$GREEN";;
55
+		"GodsOfOlympus") echo "$BLUE";;
56
+		"OITHEOI") echo "$BLUE";;
57
+		"TA_DAIMONIA") echo "$BLUE";;
58
+		"Theodore_Oien") echo "$BLUE";;
59
+		"__RSPTN__") echo "$BLUE";;
60
+		"ThatOneVampChick") echo "$MAGENTA";;
61
+		"MrE") echo "$ORANGE";;
62
+		"CaptainKoreaboo") echo "$CYAN";;
63
+		"Unus_Relicuum") echo "$BLUE";;
64
+		"Unum_Relicuum") echo "$BLUE";;
65
+		"HadesRealmOfficial") echo "$ORANGE";;
66
+		"VladmirOrlovOfficial") echo "$YELLOW";;
67
+		"BBC_Official") echo "$ORANGE";;
68
+		"BuzzfeedOfficial") echo "$BLUE";;
69
+		"algranon") echo "$GREEN";;
70
+		"DOGFOODLID") echo "$YELLOW";;
71
+		"xX_RabbitFan_Xx") echo "$YELLOW";;
72
+		"giant_death_ferret") echo "$BROWN";;
73
+		"WhoRemembers") echo "$BROWN";;
74
+		"RED") echo "$RED";;
75
+		"YELLOW") echo "$YELLOW";;
76
+		"GREEN") echo "$GREEN";;
77
+		"BLUE") echo "$BLUE";;
78
+		"PURPLE") echo "$MAGENTA";;
79
+		"WHITE") echo "$WHITE";;
80
+		"JUPITER") echo "$RED";;
81
+		"HERA") echo "$RED";;
82
+		"NEPTUNE") echo "$RED";;
83
+		"MINERVA") echo "$RED";;
84
+		"ARES") echo "$RED";;
85
+		"APHRODITE") echo "$RED";;
86
+		"TheRealHannah") echo "$GREEN";;
87
+		"not_metampsychotic") echo "$YELLOW";;
88
+		"Do_I_know_this_guy") echo "$CYAN";;
89
+		"EntropicKitten") echo "$YELLOW";;
90
+		"SonjaOfTheMeow") echo "$VIOLET";;
91
+		"purrz0rz") echo "$CYAN";;
92
+		"meowtampsychotic") echo "$YELLOW";;
93
+		"AdogmiralPanbark") echo "$RED";;
94
+		"Adogmiral_Panbark") echo "$RED";;
95
+		"Dellis") echo "$GREEN";;
96
+		"DefinitelyNotAnUmbrella") echo "$MAGENTA";;
97
+		"Seabiscuit") echo "$BLUE";;
98
+		"Arbiter") echo "$BLUE";;
99
+		"TempShoulderAngel") echo "$MAGENTA";;
100
+		"_TempShoulderAngel") echo "$MAGENTA";;
101
+		"HotFuzzFacts") echo "$BLUE";;
102
+		"HotFuzzFacts2") echo "$BLUE";;
103
+		"HotFuzzFacts3") echo "$BLUE";;
104
+		"HotFuzzFacts4") echo "$BLUE";;
105
+		"HotFuzzFacts5") echo "$BLUE";;
106
+		"HotFuzzFacts6") echo "$BLUE";;
107
+		"HotFuzzFacts7") echo "$BLUE";;
108
+		"HotFuzzFacts8") echo "$BLUE";;
109
+		"HotFuzzFacts9") echo "$BLUE";;
110
+		"HotFuzzFacts413") echo "$BLUE";;
111
+		"HotFuzzFacts414") echo "$BLUE";;
112
+		"HotFuzzFacts415") echo "$BLUE";;
113
+		"HotFuzzFacts416") echo "$BLUE";;
114
+		"KittenLicks") echo "$CYAN";;
115
+		"Xenocartographer") echo "$BROWN";;
116
+		"GAIA") echo "$BROWN";;
117
+		"etamnanki") echo "$BROWN";;
118
+		"SansFinalGuardian") echo "$BLUE";;
119
+		"SansOfTheUnderground") echo "$YELLOW";;
120
+		"SansTheComic") echo "$GREEN";;
121
+		"endsoftime") echo "$MAGENTA";;
122
+		"DeepDark") echo "$YELLOW";;
123
+		"BookOfQuantumFlux") echo "$BROWN";;
124
+		"reddragonfall") echo "$GRAY";;
125
+		"Turquoise") echo "$GREEN";;
126
+		"judge_of_character") echo "$BROWN";;
127
+		"Wildcat") echo "$RED";;
128
+		"Wildcat2") echo "$MAGENTA";;
129
+		"__Delta__") echo "$RED";;
130
+		"ppDeltapp") echo "$RED";;
131
+		"Padlock") echo "$GRAY";;
132
+		"Mini_coopa2") echo "$GRAY";;
133
+		"The44th") echo "$MAGENTA";;
134
+		"Ravencorp") echo "$BLUE";;
135
+		"CONNECT_1200") echo "$GRAY";;
136
+		"FallenLeaves") echo "$YELLOW";;
137
+		"Pixelknight") echo "$BLUE";;
138
+		"SteveTheMewHunter") echo "$CYAN";;
139
+		"Stargazer") echo "$BLUE";;
140
+		"TheDerangedOne") echo "$BLUE";;
141
+		"russiansoldier1") echo "$RED";;
142
+		"russiansoldier2") echo "$ORANGE";;
143
+	esac
144
+}
145
+
146
+function colorize_name8 {
147
+	username="$1"
148
+
149
+	echo "$(name_color8 "$username")${username}$RESET"
150
+}
0 151
new file mode 100755
... ...
@@ -0,0 +1,132 @@
1
+#!/bin/sh
2
+
3
+# --------------------------------------
4
+# colors
5
+
6
+BLACK="$(tput setaf 0 2> /dev/null)"
7
+RED="$(tput setaf 1 2> /dev/null)"
8
+GREEN="$(tput setaf 2 2> /dev/null)"
9
+YELLOW="$(tput setaf 3 2> /dev/null)"
10
+BLUE="$(tput setaf 4 2> /dev/null)"
11
+MAGENTA="$(tput setaf 5 2> /dev/null)"
12
+CYAN="$(tput setaf 6 2> /dev/null)"
13
+WHITE="$(tput setaf 7 2> /dev/null)"
14
+ORANGE="$RED"
15
+GRAY="$CYAN"
16
+BROWN="$GREEN"
17
+
18
+BOLD="$(tput bold 2> /dev/null)"
19
+
20
+RESET="$(tput sgr0)"
21
+
22
+
23
+
24
+# --------------------------------------
25
+# generic color functions
26
+
27
+# STRING --> STRING
28
+# return the color-string of a certain username
29
+function name_color {
30
+	username="$1"
31
+
32
+	if test $COLOR -eq 8; then
33
+		name_color8 "$username"
34
+	elif test $COLOR -eq 255; then
35
+		name_color255 "$username"
36
+	fi
37
+}
38
+
39
+# STRING --> STRING
40
+# return a colored username
41
+function colorize_name {
42
+	username="$1"
43
+
44
+	if test $COLOR -eq 8; then
45
+		echo "$(name_color8 "$username")${username}${RESET}"
46
+	elif test $COLOR -eq 255; then
47
+		echo "$(name_color255 "$username")${username}${RESET}"
48
+	fi
49
+}
50
+
51
+# --------------------------------------
52
+
53
+# STRING STRING --> STRING
54
+# colorize all non-message references to a given username (generic)
55
+function colorize_name_instances {
56
+	string="$1"
57
+	username="$2"
58
+
59
+	echo "$string" \
60
+	| sed 's/ '"$username"':/ '"$(colorize_name "$username")"':/g' \
61
+	| sed 's/message '"$username"' /message '"$(colorize_name "$username")"' /g' \
62
+	| sed 's/user '"$username"'/user '"$(colorize_name "$username")"'/g' \
63
+	| sed 's/User '"$username"'/User '"$(colorize_name "$username")"'/g'
64
+}
65
+
66
+# STRING STRING --> STRING
67
+# colorize all lines that are a message of the given username (generic)
68
+function colorize_name_lines {
69
+	string="$1"
70
+	username="$2"
71
+
72
+	echo "$string" \
73
+	| sed 's/'"$username"':/'"$(name_color "$username")$username"':/g'
74
+}
75
+
76
+
77
+
78
+# --------------------------------------
79
+
80
+# STRING --> STRING
81
+# embolden all action-lines
82
+function action_bold {
83
+	txt="$1"
84
+
85
+	echo "$txt" \
86
+	| sed 's/^\*/'"$BOLD"'\*/'
87
+}
88
+
89
+# --------------------------------------
90
+
91
+# STRING --> STRING
92
+# add an ANSI reset escape-code at the end of every line
93
+function reset_ends {
94
+	string="$1"
95
+	
96
+	echo "$string" \
97
+	| sed 's/$/'"$RESET"'/g'
98
+}
99
+
100
+# STRING --> STRING
101
+# apply basic formatting/cleanup actions to an ANSI string
102
+function ansi_process {
103
+	txt="$1"
104
+
105
+	txt="$(reset_ends "$txt")"
106
+	txt="$(action_bold "$txt")"
107
+
108
+	echo "$txt"
109
+}
110
+
111
+
112
+
113
+# --------------------------------------
114
+
115
+# STRING NUMBER --> STRING
116
+# convert regular text to ANSI-formatted text
117
+function txt_to_ansi {
118
+	txt="$1"
119
+	width="$2"
120
+
121
+
122
+	for username in $usernames
123
+	do
124
+		if echo "$txt" | grep "$username" > /dev/null
125
+		then
126
+			txt="$(colorize_name_instances "$txt" "$username")"
127
+			txt="$(colorize_name_lines "$txt" "$username")"
128
+		fi
129
+	done
130
+
131
+	ansi_process "$(txt_process "$txt")" | fold  -sw $width
132
+}
0 133
new file mode 100755
... ...
@@ -0,0 +1,43 @@
1
+#!/bin/sh
2
+
3
+# --------------------------------------
4
+# usernames
5
+
6
+usernames="SonjaOfTheMoon EntropicPhantom Sidhe_Trickster SecundaSonja"
7
+usernames="$usernames CmdrCordovaOfficial LieutenantCordova pwnz0rz pwnz1ing"
8
+usernames="$usernames pwnz2much pwnz3r metampsychotic FelisKitty CGoddess"
9
+usernames="$usernames MatttheRA ReverseTheStreams Reverse_The_Streams dukerex"
10
+usernames="$usernames ItsDuckKingKarl bloodshoes AdmiralPancake"
11
+usernames="$usernames Admiral_Pancake Admiral.Pancake Pancake_High_Admiral"
12
+usernames="$usernames romanceconspirator apocalypseconspirator"
13
+usernames="$usernames aardvarkconspirator silentconspirator Empress_Of_Silence"
14
+usernames="$usernames banannaconspirator billygoatconspirator"
15
+usernames="$usernames bobtheconspirator quixoticconspirator yellowconspirator"
16
+usernames="$usernames yellowconspirator lemmingconspirator largeconspirator"
17
+usernames="$usernames sillyconspirator lackadaisicialconspirator"
18
+usernames="$usernames bouncyconspirator wildfireconspirator zygoteconspirator"
19
+usernames="$usernames Pancomputer Anarchon DrHorrible venemous m1ndh1ve1"
20
+usernames="$usernames Bulwark BULWARK GodsOfOlympus OITHEOI TA_DAIMONIA"
21
+usernames="$usernames Theodore_Oien __RSPTN__ ThatOneVampChick MrE"
22
+usernames="$usernames CaptainKoreaboo Unus_Relicuum Unum_Relicuum"
23
+usernames="$usernames HadesRealmOfficial VladmirOrlovOfficial BBC_Official"
24
+usernames="$usernames BuzzfeedOfficial algranon DOGFOODLID xX_RabbitFan_Xx"
25
+usernames="$usernames giant_death_ferret WhoRemembers"
26
+usernames="$usernames RED YELLOW GREEN BLUE PURPLE WHITE"
27
+usernames="$usernames JUPITER HERA NEPTUNE MINERVA ARES APHRODITE"
28
+usernames="$usernames TheRealHannah not_metampsychotic Do_I_know_this_guy"
29
+usernames="$usernames EntropicKitten SonjaOfTheMeow purrz0rz meowtampsychotic"
30
+usernames="$usernames AdogmiralPanbark Adogmiral_Panbark Dellis"
31
+usernames="$usernames DefinitelyNotAnUmbrella Seabiscuit Arbiter"
32
+usernames="$usernames TempShoulderAngel _TempShoulderAngel"
33
+usernames="$usernames HotFuzzFacts HotFuzzFacts2 HotFuzzFacts3 HotFuzzFacts4"
34
+usernames="$usernames HotFuzzFacts5 HotFuzzFacts6 HotFuzzFacts7 HotFuzzFacts8"
35
+usernames="$usernames HotFuzzFacts9 HotFuzzFacts413 HotFuzzFacts414"
36
+usernames="$usernames HotFuzzFacts415 HotFuzzFacts416"
37
+usernames="$usernames KittenLicks Xenocartographer GAIA etamnanki"
38
+usernames="$usernames SansFinalGuardian SansOfTheUnderground SansTheComic"
39
+usernames="$usernames endsoftime DeepDark BookOfQuantumFlux reddragonfall"
40
+usernames="$usernames Turquoise judge_of_character Wildcat Wildcat2 __Delta__"
41
+usernames="$usernames ppDeltapp Padlock Mini_coopa2 The44th Ravencorp"
42
+usernames="$usernames CONNECT_1200 FallenLeaves Pixelknight SteveTheMewHunter"
43
+usernames="$usernames Stargazer TheDerangedOne russiansoldier1 russiansoldier2"
0 44
new file mode 100755
... ...
@@ -0,0 +1,160 @@
1
+#!/bin/sh
2
+########################################
3
+# name: unichat.sh
4
+# desc: download a unichat page to ansi
5
+#       -formatted, colored text.
6
+#       perfect for reading on terminal!
7
+########################################
8
+
9
+if test -e uclib; then
10
+	prefix="./"
11
+else
12
+	prefix="$(dirname "$(echo "$0")")/"
13
+fi
14
+
15
+. "${prefix}uclib/usernames.sh"
16
+. "${prefix}uclib/ansi.sh"
17
+. "${prefix}uclib/255color.sh"
18
+. "${prefix}/uclib/8color.sh"
19
+	
20
+
21
+# --------------------------------------
22
+# generic 
23
+
24
+# NIL --> STRING
25
+# read from stdin until eof hit; return all input
26
+# good for writing functions that take piped info
27
+function reade {
28
+	local stack=""
29
+
30
+	while read input
31
+	do
32
+		stack="$(printf '%s\n%s' "$stack" "$input")"
33
+	done
34
+
35
+	echo "$stack"
36
+}
37
+
38
+
39
+
40
+# --------------------------------------
41
+# fetch
42
+
43
+# NUMBER --> STRING
44
+# actual download/return HTML of unichat comic of given id
45
+function unichat_fetch {
46
+	id="$1"
47
+
48
+	gendl -o "$TEMP" "http://unichat-comic.com/comics/${id}/"
49
+	cat "$TEMP"
50
+}
51
+
52
+
53
+
54
+# --------------------------------------
55
+# html manipulations
56
+
57
+# |STRING --> STRING
58
+# remove everything from piped unichat html except for
59
+# the actual comic part
60
+function isolate_log {
61
+	html="$(reade)"
62
+
63
+	echo "$html" \
64
+	| sed '1,/Unichat log/d' \
65
+	| sed '/article-foot/,$d'
66
+}
67
+
68
+# |STRING --> STRING
69
+# add tags to the isolated log to make it valid HTML
70
+function isolate_to_html {
71
+	log="$(reade)"
72
+	
73
+	header="<html><head><title>Unichat</title></head><body>"
74
+	footer="</body></html>"
75
+
76
+	printf "%s\n%s\n%s" "$header" "$log" "$footer"
77
+}
78
+
79
+# |STRING --> STRING
80
+# convert piped HTML into plain-text-- via w3m
81
+function html_to_txt {
82
+	html="$(reade)"
83
+
84
+	echo "$html" \
85
+	| echo "$(lynx -stdin -width 1000 -nolist -dump)"
86
+}
87
+
88
+
89
+
90
+function whitespace_trim {
91
+	string="$1"
92
+
93
+	echo "$string" \
94
+	| sed 's/^   //g' \
95
+	| sed 's/^  //g'
96
+}
97
+
98
+function unichat_to_txt {
99
+	id="$1"
100
+
101
+	gendl "http://unichat-comic.com/comics/${id}/" \
102
+	| isolate_log \
103
+	| isolate_to_html \
104
+	| html_to_txt
105
+}
106
+
107
+function txt_process {
108
+	txt="$1"
109
+
110
+	txt="$(whitespace_trim "$txt")"
111
+
112
+	echo "$txt"
113
+}
114
+
115
+function txt_to_txt {
116
+	txt="$1"
117
+	width="$2"
118
+
119
+	txt_process "$txt" | fold -sw $width
120
+}
121
+
122
+
123
+
124
+# --------------------------------------
125
+# invocation
126
+
127
+ID="1"
128
+WIDTH="80"
129
+COLOR=8
130
+TEMP="$(mktemp)"
131
+
132
+if test -n "$1"; then
133
+	ID="$1"
134
+fi
135
+if test -n "$2"; then
136
+	WIDTH="$2"
137
+fi
138
+if test -n "$3"; then
139
+	COLOR=$3
140
+fi
141
+
142
+# --------------------------------------
143
+
144
+function invoke {
145
+	if test $COLOR -eq 0; then
146
+		txt_to_txt "$(unichat_to_txt "$ID")" $WIDTH
147
+	else
148
+		txt_to_ansi "$(unichat_to_txt "$ID")" $WIDTH
149
+	fi
150
+
151
+	rm $TEMP
152
+}
153
+
154
+
155
+if test -z "$1"; then
156
+	echo "usage: unichat.sh id [width] [color]"
157
+	exit 2
158
+fi
159
+
160
+invoke