diff -r 235ae238f694 -r 4e71e1b670bc taggr.cgi --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/taggr.cgi Thu Nov 08 21:25:01 2007 +0000 @@ -0,0 +1,84 @@ +#!/usr/bin/env python2.4 + +import cgi +import shelve +import os, os.path + +import degal + +images = shelve.open('images', 'c') +tag_images = shelve.open('tag_images', 'c') +tag_tags = shelve.open('tag_tags', 'c') + +# request params +vars = cgi.FieldStorage() + +if 'path' in vars : + path = vars['path'].value +else : + path = '.' + +image_list = [] + +if 'bulk_tag' in vars : + bulk_tags = vars['bulk_tag'].value.split() +else : + bulk_tags = None + +for fname in os.listdir(path) : + if degal.isImage(fname) : + image_path = os.path.join(path, fname) + thumb_path = os.path.join(path, degal.THUMB_DIR, fname) + html_path = image_path + '.html' + + title, descr, tags = images.get(image_path, (None, None, [])) + + if 'img_%s_title' % fname in vars : + title = vars['img_%s_title' % fname].value + + if 'img_%s_descr' % fname in vars : + descr = vars['img_%s_descr' % fname].value + + if 'img_%s_tags' % fname in vars : + tags = vars['img_%s_tags' % fname].value.split() + + if bulk_tags and 'img_%s_chk' % fname in vars : + tags.extend(bulk_tags) + + if title or descr or tags : + images[image_path] = (title, descr, tags) + + html = """ +
  • + +
    +
    +
    +
    + + + + +
  • + """ % dict( + html_path = html_path, + thumb_path = thumb_path, + fname = fname, + title = title and title or '', + descr = descr and descr or '', + tags = tags and ' '.join(tags) or '', + ) + + image_list.append((fname, html)) + +image_list.sort() + +print "Content-Type: text/html" +print +print degal.Template('taggr').render( + TITLE = "Taggr - %s" % path, + BREADCRUMB = "TODO", + CONTENT = "", + PATH = path, +) +