diff --git a/format.css b/format.css index 3209374..4d31781 100644 --- a/format.css +++ b/format.css @@ -22,6 +22,8 @@ pre { .figure { float: right; - padding: 0.5em; + padding: 0.25em; + margin: 0.5em; font-size: small; + border: solid black 1px; } \ No newline at end of file diff --git a/tartans/Jamfile b/tartans/Jamfile index 201b5e7..12f6731 100644 --- a/tartans/Jamfile +++ b/tartans/Jamfile @@ -2,11 +2,15 @@ SubDir TOP tartans ; TARTAN_TMPL = $(SUBDIR)/tartan.m4 ; TARTANTOMDWN = $(SUBDIR)/tartantomdwn ; +LSTARTANS = $(SUBDIR)/lstartans ; LOOM = $(SUBDIR)/loom.py ; rule Tartan { local tartans = [ FGristFiles $(1:S=.tartan) ] ; + DIRLIST on [ FGristFiles index.mdwn ] = $(LSTARTANS) ; + AutoIndex index.mdwn : index.head.mdwn : $(1:S=.tartan) ; + for t in $(tartans) { local png = $(t:S=.png:D=img:G=) ; local mdwn = $(t:S=.mdwn) ; @@ -32,8 +36,10 @@ rule TartanToPng { SEARCH on $(2) = $(SEARCH_SOURCE) ; } + + actions TartanToMdwn { - $(TARTANTOMDWN) $(1:S=) < $(2) > $(1) + $(TARTANTOMDWN) $(1:S=.png:D=img) $(TARTAN_TMPL) < $(2) > $(1) } actions TartanToPng { diff --git a/tartans/albuquerque.tartan b/tartans/albuquerque.tartan index a722bb7..210ef52 100644 --- a/tartans/albuquerque.tartan +++ b/tartans/albuquerque.tartan @@ -3,7 +3,7 @@ Sett: R4 G24 B4 G10 B36 W6 R4 W4 Created by Ralph Stevenson Jr and Charles Hargis in 2005 for the city's tricentennial anniversary (1706-2006). It is similar in design to the -[New Mexico tartan](nm), with a little less green, and white instead of +[New Mexico tartan](nm.html), with a little less green, and white instead of yellow, with a thicker center band. -[Bally Dun Celtic Treasures](http://www.ballydun.com/) sells this tartan. \ No newline at end of file +[Bally Dun Celtic Treasures](http://www.ballydun.com/) sells this tartan. diff --git a/tartans/blackwatch.tartan b/tartans/blackwatch.tartan index c49da65..75f8ed0 100644 --- a/tartans/blackwatch.tartan +++ b/tartans/blackwatch.tartan @@ -1,4 +1,4 @@ Name: Black Watch -Sett: B22 BK2 B2 BK2 B2 BK16 G16 BK2 G16 BK16 B16 BK2 B2BK2 G10 BK8 DB9 BK1 DB1 +Sett: B22 BK2 B2 BK2 B2 BK16 G16 BK2 G16 BK16 B16 BK2 B2 BK2 G10 BK8 DB9 BK1 DB1 A standard. diff --git a/tartans/design.cgi b/tartans/design.cgi index cca9b40..da1182d 100755 --- a/tartans/design.cgi +++ b/tartans/design.cgi @@ -1,88 +1,38 @@ #! /usr/bin/python import cgitb; cgitb.enable() -import htmltmpl import loom -import re -import sys import cgi -import os -import rfc822 import urllib -import cStringIO as StringIO - -var_re = re.compile('\$(\w+|{\w+})') -def fill_template(tmpl, **keywds): - def repl(match): - var = match.group(0)[1:] - var = var.strip('{}') - return keywds[var] - return var_re.sub(repl, tmpl) - - -def serve(s, c_t): - o = ('Content-type: %s\r\nContent-length: %d\r\n\r\n%s' % - (c_t, len(s), s)) - sys.stdout.write(o) +import os +import sys f = cgi.FieldStorage() s = f.getfirst('sett') if s: + print('Content-type: image/png') + print('') sett = loom.str_to_sett(s) l = loom.tartan(sett) - p = StringIO.StringIO() - l.png(p) - - serve(p.getvalue(), 'image/png') + l.png(sys.stdout) else: - manager = htmltmpl.TemplateManager(precompile=0) - tmpl = manager.prepare('/home/neale/lib/wiki/templates/page.tmpl') - processor = htmltmpl.TemplateProcessor(html_escape=False) - - t = os.environ.get('PATH_INFO', '').strip('/') - if not t: - t = f.getfirst('t', 'Unknown') + t = f.getfirst('t', 'Unknown') s = f.getfirst('s') - if t and not s: - try: - m = rfc822.Message(file('%s.tartan' % t)) - t = m.get('Title', t) - s = m.get('Sett') - except IOError: - pass if not t or not s: # Default to Black Watch t = 'Black Watch' - s = ('B22 BK2 B2 BK2 B2 BK16 G16 BK2 G16 BK16 B16 BK2 B2' + s = ('B22 BK2 B2 BK2 B2 BK16 G16 BK2 G16 BK16 B16 BK2 B2 ' 'BK2 G10 BK8 DB9 BK1 DB1') - s_st = s.replace(' ', '') - s_st = s_st.replace('\n' ,'') + s_ = s.replace(' ', '').replace('\n', '') - content = ''' - - -

woozle.org tartan designer

-
- -
- -
- -
-
- ''' % {'tartan': t, - 'sett': s, - 'sett_compressed': urllib.quote(s_st)} - - processor.set('title', t) - processor.set('content', content) - page = processor.process(tmpl) - - serve(page, 'text/html') + print('Content-type: text/html') + print('') + sys.stdout.flush() + content = ('Name: %s\nSett: %s\n' % (t, s)) + png = 'design.cgi?sett=%s' % urllib.quote(s_) + cvt = os.popen('./tartantomdwn %s tartan.m4 | ../mdwntohtml ../template.xml' % (png,), + 'w') + cvt.write(content) + cvt.close() diff --git a/tartans/index.mdwn b/tartans/index.head.mdwn similarity index 96% rename from tartans/index.mdwn rename to tartans/index.head.mdwn index 41ce7fa..06fa176 100644 --- a/tartans/index.mdwn +++ b/tartans/index.head.mdwn @@ -6,7 +6,7 @@ description.
tartan image
- + New Mexico Land Of Enchantment
@@ -20,3 +20,4 @@ are some tartans I've made with it. If you have one you'd like to contribute to my database, or would like the code that generates this stuff, feel free to [email me](mailto:neale-tartan@woozle.org). + diff --git a/tartans/lstartans b/tartans/lstartans index 324648b..6abd656 100755 --- a/tartans/lstartans +++ b/tartans/lstartans @@ -1,5 +1,7 @@ #! /bin/sh +cat $1; shift + for i in "$@"; do base=$(basename $i .tartan) name=$(awk -F': ' '(/^Name:/) {print $2; exit;}' $i) diff --git a/tartans/nm-proc.png b/tartans/nm-proc.png new file mode 100644 index 0000000..e4d6896 Binary files /dev/null and b/tartans/nm-proc.png differ diff --git a/tartans/nm.tartan b/tartans/nm.tartan index cb9e6ae..9815b31 100644 --- a/tartans/nm.tartan +++ b/tartans/nm.tartan @@ -1,9 +1,9 @@ Name: New Mexico Sett: R4 G24 B4 G16 B36 Y8 R4 Y4 -Designed by Ralph Stevenson Jr, [officially recognized in 2003](nm-proc) +Designed by Ralph Stevenson Jr, [officially recognized in 2003](nm-proc.png) by the Secretary of State. It is similar in design to the [Albuquerque -tartan](albuquerque). I bought a scarf of this plaid from +tartan](albuquerque.html). I bought a scarf of this plaid from Mr. Stevenson; it came with a photocopy of the tartan registration and a few other documents. diff --git a/tartans/tartan.m4 b/tartans/tartan.m4 index bd0b411..d904b57 100644 --- a/tartans/tartan.m4 +++ b/tartans/tartan.m4 @@ -1,20 +1,21 @@ Title: TARTAN Tartan -divert(1) -
+divert(1) + I place this image in the public domain, in the hope that it will increase interest in tartans and tartan design.
Tartan Designer -
-
+
+
diff --git a/tartans/tartantomdwn b/tartans/tartantomdwn index 0a4f88c..129134a 100755 --- a/tartans/tartantomdwn +++ b/tartans/tartantomdwn @@ -18,5 +18,5 @@ header () { } eval $(header) -m4 -DTARTAN="$TARTAN" -DSETT="$SETT" -DBASE="$1" tartan.m4 - +m4 -DTARTAN="$TARTAN" -DSETT="$SETT" -DIMAGE="$1" $2 - diff --git a/toys/index.mdwn b/toys/index.mdwn index 4a4ca05..7c2e294 100644 --- a/toys/index.mdwn +++ b/toys/index.mdwn @@ -3,6 +3,7 @@ Title: Toys Here is some various junk I've done. Maybe you'll find it amusing. Maybe you'll just wonder why I spend so much time on this garbage. +* I like [tartans](../tartans/). * Play [a fun game](fungame.html)! * If you need to write someone a letter but really don't want to, try my [smalltalk generator](smalltalk.cgi).