blob: 3b157335463e842223d357bf31cffa93cc234f86 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
#!/bin/sh
##
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# @category sh, sed, awk, grep
# @author V.Krishn <vkrishn4@gmail.com>
# @copyright Copyright (c) 2019 V.Krishn <vkrishn4@gmail.com>
# @license GPL
# @link http://github.com/insteps/scripts
#
##
# NOTE:
# 1.
#
. ../../../bash/inc/color.inc
# . ../../../bash/inc/date.inc
PROGRAM=get-irclog
VERSION=0.0.1
NOW=$(date +%Y%m%d-%H%M%S-%s)
MONTHLY=$(date +%Y-%m)
URL=https://dev.alpinelinux.org/irclogs/
LOGTYPE='devel linux commits docs'
_tmpf='/tmp/_tmp_alpine.log'
SVGColors="aliceblue antiquewhite aqua aquamarine beige bisque
blanchedalmond blue blueviolet brown burlywood cadetblue
chartreuse chocolate coral cornflowerblue crimson cyan
darkcyan darkgoldenrod darkgrey darkgreen darkkhaki darkmagenta
darkolivegreen darkorange darkorchid darkred darksalmon
darkseagreen darkslateblue darkturquoise darkviolet deeppink
deepskyblue dimgray dodgerblue firebrick floralwhite forestgreen
fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow
honeydew hotpink indianred khaki lavenderblush lawngreen
lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow
lightgreen lightgrey lightpink lightsalmon lightseagreen
lightskyblue lightslategray lightsteelblue lime limegreen magenta
maroon mediumaquamarine mediumblue mediumorchid mediumpurple
mediumseagreen mediumslateblue mediumspringgreen mediumturquoise
mediumvioletred mintcream mistyrose moccasin navajowhite
oldlace olive olivedrab orange orangered orchid palegoldenrod
palegreen paleturquoise palevioletred papayawhip peachbuff peru
pink plum powderblue purple red rosybrown royalblue saddlebrown
salmon sandybrown seagreen seashell sienna silver skyblue slateblue
slategray snow springgreen steelblue tan teal thistle tomato
turquoise violet wheat white whitesmoke yellow yellowgreen
"
header='
<!DOCTYPE html><html><head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
';
title='<title>alpine-irclog</title>';
style=$(cat <<EOT
<style type="text/css">
body { font-family:Arial,Helvetica,sans-serif;
font-size: 1em; background-color: black; }
ul { width: 98%; margin: 0px; padding: 0px; }
ul li { padding: 3px; list-style: none; list-style-type: none;
margin: 0px; padding: 0px; border: 1px solid black; clear: both; }
ul li span:first-child,
ul li span:nth-child(2) {
white-space: nowrap; font-weight: bold; font-size: .8em;
color: yellowgreen; text-align: center; height: 1.2em;
float: left; padding: 2px; width: 100pt;
}
ul li span:nth-child(2) { width: 90pt; }
li:nth-child(even) { background-color: #282828; }
ul li span:last-child { color: beige; display: block; margin: 0px 0px; }
</style>
</head>
EOT
);
body='
<body>
<ul>
';
footer='</ul></body></html>';
al_get_irclog() {
file=${URL}"%23alpine-$log-$MONTHLY.log";
echo -ne "${cLIGHTGRAY}${cbBROWN}>>>${cNORMAL} "
echo "------------------------------"
wget -c $file
}
al_irclog2html() {
num=0
lnames=$(awk '{print $3}' ${_CURRLF} | sort | uniq )
for name in ${lnames}; do
_name=${name}
name=$(echo $name | sed 's|\[|\\[|g') # sed > v4.4 or busybox > v1.27
name=$(echo $name | sed 's|\]|\\]|g') # ? # TODO
# sed -E -i -e "s|${name}|__${num}${_name}|" ${_tmpf}
sed -E -i "s|^(2[0-9\-]+{9}) ([0-9\:]+{8}) ${name}|\1 \2 __${num}${_name}|" \
${_tmpf}
num=$(($num+1))
done
sed -i \
-e 's|&|\&|g' \
-e 's|>|\>|g' \
-e 's|<|\<|g' \
-e 's|^|<li><span>|' \
-e 's|gt\; |gt;</span><span>|' \
-e 's|$|</span></li>|' \
${_tmpf}
_colorstr="<span style="
sed -E -i -e "s|([0-9]) (__[0-9])|\1</span>${_colorstr}\2|" \
${_tmpf}
# handle populous chatty channel
if [ $num -gt 120 ]; then SVGColors="${SVGColors} ${SVGColors}"; fi
if [ $num -gt 240 ]; then SVGColors="${SVGColors} ${SVGColors}"; fi
num=0
for color in ${SVGColors}; do
str="style=__${num}"
num=$(($num+1))
sed -E -i -e "s|${str}<|style=\'color\:${color}\'\>\<|" \
${_tmpf}
done
_outf=$(echo ${_CURRLF} | cut -b2-).html
# _outf=/path/to/htdocs/${_outf}
echo -e "${cGREEN}>>> creating ... ${cRED}$_outf${cNORMAL}"
rm -f ${_outf}; touch $_outf
echo ${header} > ${_outf}
echo ${title} >> ${_outf}
echo ${style} >> ${_outf}
echo ${body} >> ${_outf}
cat ${_tmpf} >> ${_outf}
echo $footer >> ${_outf}
}
usage() {
echo -e ${cGREEN}
cat <<-__EOF__
usage: get-irclogs [yyyy-mm]
Download IRC logs from Alpine Linux, and
create a html format of the log
yyyy-mm - format eg. 2019-01
__EOF__
echo -e ${cNORMAL}
exit 1
}
if [ "$1" ]; then #format eg. 2019-01
_m=$(echo "$1" | grep -E '^[0-9\-]{7}')
if [ ! "$_m" = '' ]; then MONTHLY=$_m; fi
fi
if [ "$1" = "help" ]; then
usage
else
echo -e ${cbCYAN}${cYELLOW}${NOW}' '${cNORMAL}
for log in ${LOGTYPE}; do
_CURRLF="#alpine-$log-$MONTHLY.log"
al_get_irclog
if [ ! -f ${_CURRLF} ]; then continue; fi
echo -e "${cGREEN}>>> processing temp log:${cNORMAL} ${_tmpf}"
echo '' > ${_tmpf}
cp ${_CURRLF} ${_tmpf}
al_irclog2html
done;
fi
|