aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV.Krishn <vkrishn4@gmail.com>2019-03-28 18:00:21 +0530
committerV.Krishn <vkrishn4@gmail.com>2019-03-28 18:00:21 +0530
commitdb94460988411aa8a9d2d35e967b236863fcc229 (patch)
tree47a29e7a6ef9c2c14f82daea097b98f89b787001
parent9d5b9466f29afef692e1d4c6eb07c3133f5c4d19 (diff)
downloadscripts-db94460988411aa8a9d2d35e967b236863fcc229.tar.bz2
slightly different logic, improved performance
-rw-r--r--alpine/irc/log/get-irclog.sh43
1 files changed, 16 insertions, 27 deletions
diff --git a/alpine/irc/log/get-irclog.sh b/alpine/irc/log/get-irclog.sh
index cfea8f8..e2460d8 100644
--- a/alpine/irc/log/get-irclog.sh
+++ b/alpine/irc/log/get-irclog.sh
@@ -100,43 +100,32 @@ al_get_irclog() {
}
_al_irclog2html() {
- num=0
- lnames=$(awk '{print $3}' ${_CURRLF} | sort | uniq )
- for name in ${lnames}; do
- _name=${name}
- name=$(echo $name | sed -E 's|\[|\\[|g') # sed > v4.4 or busybox > v1.27
- name=$(echo $name | sed -E 's|\]|\\]|g') # ? # TODO
- name=$(echo $name | sed -E 's|\^|\\^|g')
- name=$(echo $name | sed -E 's/\|/\\|/g')
- sed -E -i "s|^(2[0-9\-]+{9}) ([0-9\:]+{8}) (${name})|\1 \2 __${num}\3|" \
- ${_tmpf}
- num=$(($num+1))
- done
-
sed -i \
-e 's|&|\&amp;|g' \
-e 's|>|\&gt;|g' \
-e 's|<|\&lt;|g' \
-e 's|^|<li><span>|' \
- -e 's|gt\; |gt;</span><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}
-
+ num=1
+ lnames=$(awk '{print $3}' ${_tmpf} | sort | uniq )
+ maxname=$(echo $lnames | wc -w)
# handle populous chatty channel
- if [ $num -gt 120 ]; then SVGColors="${SVGColors} ${SVGColors}"; fi
- if [ $num -gt 240 ]; then SVGColors="${SVGColors} ${SVGColors}"; fi
- if [ $num -gt 480 ]; then SVGColors="${SVGColors} ${SVGColors}"; fi
-
- num=0
- for color in ${SVGColors}; do
- str="style=__${num}"
- num=$(($num+1))
- sed -E -i -e "s|${str}&lt|style=\'color\:${color}\'\>\&lt|" \
+ if [ $maxname -gt 120 ]; then SVGColors="${SVGColors} ${SVGColors}"; fi
+ if [ $maxname -gt 240 ]; then SVGColors="${SVGColors} ${SVGColors}"; fi
+ if [ $maxname -gt 480 ]; then SVGColors="${SVGColors} ${SVGColors}"; fi
+ for name in ${lnames}; do
+ _name=${name}
+ name=$(echo $name | sed -E 's|\[|\\[|g') # sed > v4.4 or busybox > v1.27
+ name=$(echo $name | sed -E 's|\^|\\^|g')
+ name=$(echo $name | sed -E 's/\|/\\|/g')
+ color=$(echo $SVGColors | awk -v num=$num '{print $num}')
+ _colorstr="</span><span style='color:${color}'>"
+ sed -E -i "s|^(<li><span>2[0-9\-]+{9}) ([0-9\:]+{8}) (${name})|\1 \2 ${_colorstr}\3|" \
${_tmpf}
+ num=$(($num+1))
done
}