Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMike Gerwitz <mike@mikegerwitz.com>2013-06-01 23:23:09 -0400
committerMike Gerwitz <mike@mikegerwitz.com>2013-06-02 12:27:02 -0400
commit876b763a8d26a0eace08b70cfd50d44183a2bdde (patch)
treef74c2054aa0762ff1f3a96771c7785c8215b15a7 /tools
parentd91d0cb7119390650456b06a9accbbab148a91b6 (diff)
downloadthoughts-876b763a8d26a0eace08b70cfd50d44183a2bdde.tar.gz
thoughts-876b763a8d26a0eace08b70cfd50d44183a2bdde.tar.bz2
thoughts-876b763a8d26a0eace08b70cfd50d44183a2bdde.zip
Added intial pages
Diffstat (limited to 'tools')
-rwxr-xr-xtools/doclist39
-rwxr-xr-xtools/extfmt16
2 files changed, 52 insertions, 3 deletions
diff --git a/tools/doclist b/tools/doclist
new file mode 100755
index 0000000..8583f31
--- /dev/null
+++ b/tools/doclist
@@ -0,0 +1,39 @@
+#!/bin/bash
+#
+# Generates HTML fragment for document list
+#
+# Copyright (C) 2013 Mike Gerwitz
+#
+# 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 3 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/>.
+##
+
+# ensure extglob is on for !() syntax
+shopt -s extglob || exit $?
+
+echo '<ol class="docs">'
+
+# paths are expected to be on their own line
+while read f; do
+ [ -f "$f" ] || continue
+
+ # the docs/papers prefix will be stripped from the link and the link title
+ # will be taken from the first line of the source file; the source file is
+ # guessed by simply stripping the html suffix off of the filename and
+ # globbing for any non-html suffix
+ printf '<li><a href="%s">%s</a></li>\n' \
+ "${f#docs/papers/}" \
+ "$( head -n1 "${f%.html}".!(html) )"
+done
+
+echo '</ol>'
diff --git a/tools/extfmt b/tools/extfmt
index a7fa233..be0ae20 100755
--- a/tools/extfmt
+++ b/tools/extfmt
@@ -23,22 +23,32 @@
# messages...if you try to inline an image in a commit message using this
# format, then you should probably pretend the brackets are staples and lodge
# them into your skull)
+#
+# XXX: These do little to prevent against malicious code execution since, well,
+# they are used for my own personal content...you've been warned (they are also
+# strongly bias toward allowing only Unix-like paths)
"$msgfmt_default" "$@" \
| awk -vpath_root="$path_root" '
- match($0, /\[img:([^:]+?)(:(.*?))?\]/, g) {
+ match($0, /\[img:([a-z/.-]+?)(:(.*?))?\]/, g) {
print "<div class=\"inline-img\">"
print " <img src=\"/images/" g[1] "\" alt=\"" g[3] "\" title=\"" g[3] "\" />"
print "</div>"
-
next
}
- match($0, /\[src:(.*?):(.*?)\]/, g) {
+ match($0, /\[src:([a-z/.-]+?):(.*?)\]/, g) {
c = "source-highlight -s" g[2] " -i" path_root "/" g[1]
print "<div class=\"listingblock\">"
while ( c | getline ) print
print "</div>"
+ next
+ }
+
+ match($0, /\[cat:([a-z/.-]+?)\]/, g) {
+ c = "cat -- " path_root "/" g[1]
+ while ( c | getline ) print
+ next
}
{ print }