# HG changeset patch # User terom # Date 1194557101 0 # Node ID 4e71e1b670bc22a99217e7176c3f8f7ee3324951 # Parent 235ae238f69413d5e393301e522d842142e0eef6 an unfinished taggr.py, prototype/testing code diff -r 235ae238f694 -r 4e71e1b670bc style.css --- a/style.css Thu Nov 08 19:41:03 2007 +0000 +++ b/style.css Thu Nov 08 21:25:01 2007 +0000 @@ -90,3 +90,54 @@ background-color: #666666; } +div#taggr { + border: 1px solid #666666; + + padding: 20px; +} + +div#taggr ul { + margin: 0px; + padding: 0px; +} + +div#taggr li { + border-bottom: 1px solid #444444; + + padding: 10px; + + list-style-type: none; + + text-align: center; +} + +div#tagger span.thumb { + clear: both; +} + +div#taggr span.inputs { + float: right; +} + +div#taggr input { + margin: 5px; +} + +div#taggr label { + float: left; + + width: 150px; +} + +div#taggr input.chk { + float: left; + + width: 30px; + height: 30px; + + border: 1px solid #000000; + + margin: auto; +} + + 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, +) +