diff -r 46536daf9e04 -r 8d3ffd87cb0b cgi-bin/taggr.py --- a/cgi-bin/taggr.py Sat Dec 22 21:31:01 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +0,0 @@ -#!/usr/bin/env python2.4 -# -# DeGAL - A pretty simple web image gallery -# Copyright (C) 2007 Tero Marttila -# http://marttila.de/~terom/degal/ -# -# 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 2 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, write to the -# Free Software Foundation, Inc., -# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# - - -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, -) -