aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/export.py44
-rw-r--r--src/issue-entry.awk21
-rw-r--r--src/issue.awk73
-rwxr-xr-xsrc/mkindex.sh25
-rwxr-xr-xsrc/mkissue.sh5
-rwxr-xr-xsrc/mknew.sh18
-rwxr-xr-xsrc/mkrow.sh10
-rw-r--r--src/style.css91
8 files changed, 287 insertions, 0 deletions
diff --git a/src/export.py b/src/export.py
new file mode 100644
index 0000000..b453bc4
--- /dev/null
+++ b/src/export.py
@@ -0,0 +1,44 @@
+from github import Github
+from github import Auth
+import os
+
+token = None
+with open(os.path.expanduser('~') + "/.config/github/token", "r") as f:
+ token = str(f.readline().strip())
+
+auth = Auth.Token(token)
+
+g = Github(auth=auth)
+
+root = "."
+datefmt = '%a, %d %b %Y %H:%M:%S %z'
+
+repo = g.get_repo("dillo-browser/dillo")
+open_issues = repo.get_issues(state="all")
+for issue in open_issues:
+ print(issue)
+ n = issue.number
+ title = issue.title
+ body = issue.body
+ os.makedirs("%s/%d" % (root, n), exist_ok=True)
+ issue_file = "%s/%d/index.md" % (root, n)
+ if body is None:
+ body = ''
+
+ body = body.replace('\r\n', '\n')
+
+ with open(issue_file, "w") as f:
+ f.write("Title: " + issue.title + '\n')
+ f.write("Author: " + issue.user.login + '\n')
+ f.write("Created: " + issue.created_at.strftime(datefmt) + '\n')
+ f.write("State: " + issue.state + '\n')
+ f.write('\n')
+ f.write(body)
+ for comment in issue.get_comments():
+ f.write('\n\n--%--\n')
+ f.write('From: ' + comment.user.login + '\n')
+ f.write('Date: ' + comment.created_at.strftime(datefmt) + '\n')
+ f.write('\n')
+ f.write(comment.body.replace('\r\n', '\n'))
+
+g.close()
diff --git a/src/issue-entry.awk b/src/issue-entry.awk
new file mode 100644
index 0000000..bc0278d
--- /dev/null
+++ b/src/issue-entry.awk
@@ -0,0 +1,21 @@
+BEGIN { FS=": "; c=0 }
+
+c == 0 && /^Title: / { sub("Title: ", ""); title=$0 }
+c == 0 && /^Author: / { sub("Author: ", ""); author=$0 }
+c == 0 && /^Created: / { sub("Created: ", ""); date=$0 }
+c == 0 && /^State: / { sub("State: ", ""); state=$0 }
+#/^--%--$/ { c++ }
+/^--%--$/ { exit }
+END {
+ if (s == "" || state == s) {
+ printf "<tr>\n"
+ printf " <td><a href='%d/'>#%d</a></td>\n", n, n
+ printf " <td>%s</td>\n", title
+ #printf " <td>%d</td>\n", c
+ printf " <td>%s</td>\n", modif
+ printf " <td><span class='issue-state state-%s'>%s</span></td>\n", state, state
+ printf "</tr>\n"
+ printf "\n"
+ }
+ exit
+}
diff --git a/src/issue.awk b/src/issue.awk
new file mode 100644
index 0000000..69fb889
--- /dev/null
+++ b/src/issue.awk
@@ -0,0 +1,73 @@
+BEGIN { FS=": "; s=1; c=0 }
+
+s==1 && /^Title: / { sub("Title: ", ""); title=$0 }
+s==1 && /^Author: / { sub("Author: ", ""); author=$0 }
+s==1 && /^Created: / { sub("Created: ", ""); date=$0 }
+s==1 && /^State: / { sub("State: ", ""); state=$0 }
+s==1 && $0 == "" {
+ printf "<!doctype html>\n"
+ printf "<html>\n"
+ printf "<head>\n"
+ printf " <title>%s</title>\n", title
+ printf " <link rel='stylesheet' href='/style.css' type='text/css' />\n"
+ printf "</head>\n"
+ printf "<body>\n"
+ printf " <table class='issue-meta'>\n"
+ printf " <tr><th>Title</th><td>%s</td></tr>\n", title
+ printf " <tr><th>Author</th><td>%s</td></tr>\n", author
+ printf " <tr><th>Created</th><td>%s</td></tr>\n", date
+ printf " <tr><th>State</th>"
+ printf " <td><span class='issue-state state-%s'>%s</span></td>", state, state
+ printf " </tr>\n"
+ printf " </table>\n"
+ printf "\n"
+ s = 2
+ next
+}
+
+# Description
+s==2 && $0 == "--%--" {
+ com_author = ""
+ com_date = ""
+ s = 3
+ c++
+ next
+}
+s==2 { print }
+
+# Comment header
+s==3 && /^From: / { sub("From: ", ""); com_author=$0 }
+s==3 && /^Date: / { sub("Date: ", ""); com_date=$0 }
+s==3 && $0 == "" {
+ printf "\n"
+ printf "<div id='c%d' class='comment'>\n", c
+ printf " <a href='#c%d'>%s</a> on <i>%s</i>:<br>\n", c, com_author, com_date
+ printf "\n"
+ s = 4
+ next
+}
+
+# Comment body
+s==4 && $0 == "--%--" {
+ # Close previous comment
+ printf "</div>\n\n"
+ com_author = ""
+ com_date = ""
+ s = 3
+ c++
+ next
+}
+s==4 { print }
+
+END {
+ if (s == 4) {
+ printf "</div>\n"
+ }
+ printf "\n\n"
+ printf "</body>"
+ printf "</html>"
+
+# printf "title=\"%s\"\n", title;
+# printf "author=%s\n", author;
+# printf "author=%s\n", author;
+}
diff --git a/src/mkindex.sh b/src/mkindex.sh
new file mode 100755
index 0000000..a81e033
--- /dev/null
+++ b/src/mkindex.sh
@@ -0,0 +1,25 @@
+#!/bin/sh -e
+
+cat <<EOF
+<!doctype html>
+<head>
+ <title>Dillo Bug Tracker</title>
+ <link rel='stylesheet' href='/style.css' type='text/css' />
+</head>
+<body>
+ <h1>Dillo Bug Tracker</h1>
+ <p>State: <a href="/">open</a> | <a href="/any.html">any</a></p>
+ <table class='issue-index'>
+ <tr>
+ <th>Bug</th>
+ <th style='width: 70%'>Title</th>
+ <th>Updated</th>
+ <th>State</th>
+ </tr>
+EOF
+
+cat "$@"
+
+printf '\n'
+printf ' </table>\n'
+printf '</body>\n'
diff --git a/src/mkissue.sh b/src/mkissue.sh
new file mode 100755
index 0000000..cf03273
--- /dev/null
+++ b/src/mkissue.sh
@@ -0,0 +1,5 @@
+#!/bin/sh -e
+
+sed 's/ #\([0-9]\+\)/ [#\1](\/\1)/g' $1 | \
+ awk -f src/issue.awk | \
+ md2html --github
diff --git a/src/mknew.sh b/src/mknew.sh
new file mode 100755
index 0000000..880838b
--- /dev/null
+++ b/src/mknew.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+n=$(printf '%s\n' [0-9]* | sort -nr | head -1)
+if [ -z "$n" ]; then
+ n=1
+else
+ let n=n+1
+fi
+
+mkdir $n
+p=$n/index.md
+
+echo "Title: " >> $p
+echo "Author: $(git config get user.name)" >> $p
+echo "Created: $(date -R)" >> $p
+echo "State: open" >> $p
+
+echo "\$EDITOR $n/index.md"
diff --git a/src/mkrow.sh b/src/mkrow.sh
new file mode 100755
index 0000000..7581979
--- /dev/null
+++ b/src/mkrow.sh
@@ -0,0 +1,10 @@
+#!/bin/sh -e
+
+n=$1
+f=$2
+s=$3
+
+title=$(head -1 $f | sed 's/^Title: //')
+modif=$(stat -c %y $f | cut -d ' ' -f 1)
+
+awk -v n=$n -v s="$s" -v modif="$modif" -f src/issue-entry.awk < $f
diff --git a/src/style.css b/src/style.css
new file mode 100644
index 0000000..35a322d
--- /dev/null
+++ b/src/style.css
@@ -0,0 +1,91 @@
+body {
+ background: white;
+ line-height: 1.5;
+ margin: 3em auto;
+ padding: 0 3em; /* Fix for Dillo */
+ font-family: sans-serif;
+ max-width: 80ch;
+}
+h1 {
+ margin-top: 0.25em;
+ margin-bottom: 0.25em;
+ font-size: 22px;
+}
+img {
+ border: 0;
+ max-width: 100%;
+ margin-top: 1em;
+ margin-bottom: 1em;
+}
+figure {
+ text-align: center;
+ margin: 1em;
+}
+footer {
+ text-align: center;
+ margin-top: 2em;
+ clear: both;
+}
+pre {
+ padding: 0.25em;
+ background: #f7f7f7;
+ border-left: solid 2px #ccc;
+}
+.date {
+ font-style: italic;
+ float: right;
+}
+
+/* Issue state label */
+span.issue-state {
+ display: inline-block;
+ text-align: center;
+ color: #000;
+ padding: 0px 0.25em;
+ border: solid 1px #777;
+}
+span.state-open {
+ background-color: #8f8;
+}
+span.state-closed {
+ background-color: #eee;
+}
+
+/* Issue index view */
+table.issue-index {
+ width: 100%;
+ border-spacing: 0;
+}
+table.issue-index td {
+ border-collapse: collapse;
+ border-bottom: solid 1px #ddd;
+ border-top: solid 1px #ddd;
+ padding: 0.25em;
+}
+table.issue-index th {
+ text-align: left;
+ background-color: #eee;
+ padding: 0.25em;
+}
+
+/* Issue view */
+table.issue-meta {
+ width: 100%;
+ padding: 0.25em;
+ border: solid 1px #777;
+ margin-bottom: 1em;
+}
+table.issue-meta th {
+ padding: 0.1em 0.25em;
+ text-align: left;
+ vertical-align: top;
+}
+table.issue-meta td {
+ width: 100%;
+ padding: 0.1em 0.25em;
+}
+div.comment {
+ margin: 0.5em 0;
+ padding: 0.5em;
+ border: solid 1px #777;
+}