git ssb

0+

cel / dillo-history



Tree: db27d78788c79045c2250b824da6224adf277b6b

Files: db27d78788c79045c2250b824da6224adf277b6b / history.filter.dpi

1119 bytesRaw
1#!/bin/bash
2read -d '>' auth
3read -d '>' cmd
4case "$cmd" in
5 "<cmd='open_url' url='"*);;
6 *) echo $cmd; exit;;
7esac
8url=${cmd#"<cmd='open_url' url='"}
9url=${url%"' '"}
10
11serve_404() {
12 printf "<cmd='start_send_page' url='' '>\n"
13 printf "Content-type: text/plain\r\n\r\n"
14 echo Not found
15}
16
17serve_history() {
18 limit=${1:-35}
19 grep=$2
20 printf "<cmd='start_send_page' url='' '>\n"
21 printf "Content-type: text/html\r\n\r\n"
22 cat <<-EOF
23 <!doctype html>
24 <html>
25 <head>
26 <meta charset=utf-8>
27 <title>History</title>
28 </head>
29 <body>
30 EOF
31 exec 2>&1
32 dillo_dir=${0%/*/*/*}
33 history_file=$dillo_dir/history.txt
34 if [ -n "$grep" ]; then grep "$grep"; else cat
35 fi < "$history_file" | tail -n $limit | tac | awk '
36 {
37 timestamp = $1 " " $2
38 if ($3 != "+0000") {
39 timestamp = timestamp " " $3
40 }
41 printf "<div>%s <a href=\"ssb:%s\"> <code>%s</code></a> <a href=\"%s\">%s</a></div>\n",
42 timestamp, $4, $4, $5, $5
43 }'
44 cat <<-EOF
45 </body>
46 </html>
47 EOF
48}
49
50case "$url" in
51 history:*/*) a="${url#history:}"; serve_history "${a%/*}" "${a#*/}";;
52 history:*) serve_history "${url#history:}";;
53 *) serve_404;;
54esac
55

Built with git-ssb-web