fix bug with shorturls in gallery.html, and some horrible, horrible crap for the CGI stuff - I need to drop everything now and take a fresh look tomorrow before it gets even worse
authorterom
Sat, 22 Dec 2007 21:31:01 +0000
changeset 18 46536daf9e04
parent 17 adde6ad8731e
child 19 8d3ffd87cb0b
fix bug with shorturls in gallery.html, and some horrible, horrible crap for the CGI stuff - I need to drop everything now and take a fresh look tomorrow before it gets even worse
cgi-bin/inc.py
cgi-bin/inc.py
cgi-bin/series.py
cgi-bin/series.py
cgi-bin/shorturl.py
cgi-bin/shorturl.py
cgi-bin/taggr.py
cgi-bin/taggr.py
degal-lighttpd.conf
lib/settings.py
lib/utils.py
templates/gallery.html
www/series.cgi
www/shorturl.cgi
www/taggr.cgi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/inc.py	Sat Dec 22 21:31:01 2007 +0000
@@ -0,0 +1,18 @@
+if __name__ == '__main__' :
+    raise Exception("Don't access inc.py directly")
+
+# setup env
+
+import sys
+import os, os.path
+
+def splitn (path, n) :
+    for i in xrange(0, n) :
+        path = os.path.split(path)[0]      
+    
+    return path
+        
+degal_path = splitn(os.path.join(os.getcwd(), __file__), 2)
+
+os.chdir(degal_path)
+sys.path.append(degal_path)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/series.py	Sat Dec 22 21:31:01 2007 +0000
@@ -0,0 +1,215 @@
+#!/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 shelve
+import cgi
+import Cookie
+import os, os.path
+
+import degal
+
+#
+# load request params
+#
+vars = cgi.FieldStorage()
+
+# these are interpeted different ways, hence the generic naming
+arg1 = vars["keys"].value
+if 'index' in vars :
+    arg2 = vars["index"].value
+else :
+    arg2 = None
+
+# the cookie with the user's current series
+cookie = Cookie.SimpleCookie(os.environ.get('HTTP_COOKIE', None))
+
+# a special action?
+if arg1 and arg1 in ('add', 'del', 'clear', 'view') or arg2 == 'load' :
+    # load the keys from the cookie
+    if 'series' in cookie :
+        keys = cookie["series"].value.split()
+    else :
+        keys = []
+    
+    if arg2 == 'load' :
+        # set the keys in the user's cookie to those in the URL
+        keys = arg1.split()
+
+    elif arg1 == 'add' and arg2 not in keys :
+        # add a code to the list of keys
+        keys.append(arg2)
+
+    elif arg1 == 'del' and arg2 in keys :
+        # remove a key from the list of keys
+        keys.remove(arg2)
+
+    elif arg1 == 'clear' :
+        # clear out the set of keys
+        keys = []
+
+    elif arg1 == 'view' :
+        # just view them
+        pass
+   
+    # set the series cookie value
+    cookie['series'] = ' '.join(keys)
+    cookie['series']['path'] = '/'
+    
+    # if we have keys, redirect to them, otherwise, back to index we go
+    if keys :
+        redirect_to = "../%s/" % ('+'.join(keys))
+    else :
+        redirect_to = "../.."
+    
+    # do the redirect
+    print "Status: 302"
+    print "Location: %s" % redirect_to
+    print cookie
+    print
+    print "Redirect..."
+else :
+    # we're just viewing
+    keys = arg1.split()
+    
+    # is this "My Series"?
+    my_series = 'series' in cookie and cookie['series'].value.split() == keys
+        
+    if arg2 :
+        index = int(arg2)
+    else :
+        index = None
+
+    # load DB
+    db = shelve.open('shorturls2', 'r')
+
+    # get the Image objects
+    photos = []
+    
+    #
+    # Start ugly code-misreuse
+    #
+
+    # monkey-patch the templates
+    rendered_templates = []
+
+    def _myRenderTo (self, path, **vars) :
+        rendered_templates.append(self.render(**vars))
+
+    # lalalalala... ooh, look;
+
+    degal.Template.renderTo = _myRenderTo
+    #
+    #         vvvvvvvvvvvvvvvvvvvv
+    #         vvvvvvvvvvvvvvvvvvvv
+    #
+    #    >>>> SHINY PINK ELEPHANT! <<<<
+    #
+    #         ^^^^^^^^^^^^^^^^^^^^
+    #         ^^^^^^^^^^^^^^^^^^^^
+
+    # our own version of Folder
+    class Series (degal.Folder) :
+        def __init__ (self) :
+            super(Series, self).__init__()
+            
+            self.alive = True
+            self.filtered = False
+            self.subdirs = {}
+            self.images = {}
+            self.sorted_images = []
+            self.title = "Series"
+
+            if my_series :
+                self.descr = '<a href="../clear/" rel="nofollow">Clear your series</a>'
+            else :
+                self.descr = '<a href="load" rel="nofollow">Load as your series</a>'
+
+            self.shorturl_code = ''
+        
+        def breadcrumb (self) :
+            return [('../..', 'Gallery'), ('.', 'Series')]
+
+        def inRoot (self, *fnames) :
+            return os.path.join('../..', *fnames)
+
+    class Image (degal.Image) :
+        def __init__ (self, series, key, i) :
+            type, self.dir_name, self.image_name = db[key]
+
+            super(Image, self).__init__(series, self.image_name)
+            
+            self.path = self._path()
+            self.shorturl_code = key
+            self.html_path = self.html_name = str(i + 1)
+            self.title = 'Image %d' % (i + 1, )
+            self.descr = '<span style="font-size: x-small">Standalone image: <a href="%s.html">%s</a></span>' % (self._path(), self._path().lstrip('./'))
+            self.img_size = (-1, -1)
+            self.filesize = 0
+            self.timestamp = 0
+
+            if my_series :
+                self.series_act = "del"
+                self.series_verb = "Remove from"
+            else :
+                self.series_act = self.series_verb = ""
+
+        def breadcrumb (self) :
+            return [('../..', 'Gallery'), ('.', 'Series'), (self.html_name, self.title)]
+
+        def _path (self, blaa='') :
+            return os.path.join('../..', self.dir_name, blaa, self.image_name)
+
+        def thumbImgTag (self) :
+            return degal.link(self.html_name, "<img src='%s' alt='%s' title='%s'>" % (self._path(degal.THUMB_DIR), '', self.title))
+
+        def previewImgTag (self) :
+            return degal.link(self._path(), "<img src='%s' alt='%s' title='%s'>" % (self._path(degal.PREVIEW_DIR), '', self.title))
+
+    series = Series()
+
+    try :
+        prev = None
+
+        for i, key in enumerate(keys) :
+            img = Image(series, key, i)
+
+            if prev :
+                prev.next = img
+
+            img.prev = prev
+            prev = img
+
+            series.sorted_images.append(img)
+    finally :
+        db.close()
+
+    if index :
+        img = series.sorted_images[index - 1]
+
+        img.render()
+    else :
+        series.render()
+
+    print "Content-Type: text/html"
+    print
+    print rendered_templates[0]
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/shorturl.py	Sat Dec 22 21:31:01 2007 +0000
@@ -0,0 +1,62 @@
+#!/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 shelve
+import cgi
+import os, os.path
+
+import inc
+
+vars = cgi.FieldStorage()
+
+key = vars['key'].value
+
+if 'index' in vars :
+    index = int(vars['index'].value.lstrip('/'))
+else :
+    index = None
+
+db = shelve.open('shorturls2', 'r')
+
+try :
+    type, dirpath, fname = db[key]
+
+    if type == 'img' :
+        fname += '.html'
+    elif type == 'dir' :
+        fname = ''
+
+    if index :
+        if index > 1 : 
+            fname = 'index_%s.html' % (index - 1)
+
+        dirpath = '../%s' % dirpath
+
+    path = os.path.join(dirpath, fname)
+
+    print "Status: 302"
+    print "Location: ../%s" % path
+    print
+    print "../%s" % path
+
+finally :
+    db.close()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/taggr.py	Sat Dec 22 21:31:01 2007 +0000
@@ -0,0 +1,105 @@
+#!/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 = """
+<li>
+    <span class="inputs">
+        <label for="img_%(fname)s_title">Title</label> <input type="text" name="img_%(fname)s_title" size="60" value="%(title)s" /> <br/>
+        <label for="img_%(fname)s_descr">Description</label> <input type="text" name="img_%(fname)s_descr" size="60" value="%(descr)s" /> <br/>
+        <label for="img_%(fname)s_tags">Tags</label> <input type="text" name="img_%(fname)s_tags" size="60" value="%(tags)s" /> <br/>
+    </span>
+    
+    <input type="checkbox" name="img_%(fname)s_chk" class="chk" />
+    
+    <span class="thumb"><a href="%(html_path)s"><img src="%(thumb_path)s" /></a></span>
+</li>
+        """ % 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     = "<ul>" + ''.join([h for fname, h in image_list]) + "</ul>",
+    PATH        = path,
+)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/degal-lighttpd.conf	Sat Dec 22 21:31:01 2007 +0000
@@ -0,0 +1,16 @@
+# prefix for degal's URLs, no trailing slash
+var.degal-url = "/photos"
+
+# filesystem path to degal, no trailing slash
+var.degal-path = "C:/Dokumente und Einstellungen/me/Eigene Dateien/python/degal"
+
+url.rewrite-once = (
+#    "^" + var.degal-url + "/s/([^/]+)(/.*)?$" => var.degal-path + "/shorturl.py?key=$1&index=$2",
+    "/this" => "/photos/index.html"
+#    "^/photos/s/([^/]+)(/.*)?$" => "/photos/index.html", # "/shorturl.py?key=$1&index=$2",
+#    "^" + var.degal-url + "/series/([^/]+)/(.*)$" => var.degal-path + "/series.py?keys=$1&index=$2"
+)
+
+cgi.assign = (
+    ".py" => "python"
+)
--- a/lib/settings.py	Sat Dec 22 19:19:05 2007 +0000
+++ b/lib/settings.py	Sat Dec 22 21:31:01 2007 +0000
@@ -17,3 +17,6 @@
 
 VERSION = "0.5"
 ROOT_IGNORE = ('lib', 'templates')
+
+if __name__ == '__main__' :
+    print __file__
--- a/lib/utils.py	Sat Dec 22 19:19:05 2007 +0000
+++ b/lib/utils.py	Sat Dec 22 21:31:01 2007 +0000
@@ -49,13 +49,3 @@
     
 def path_join (*parts) :
     return os.path.join(*[part for part in parts if part is not None])
- 
-from optparse import OptionParser
-    
-def optparse (options) :
-    parser = OptionParser()
-    
-    
-    parser.add_option    
-    
-    
\ No newline at end of file
--- a/templates/gallery.html	Sat Dec 22 19:19:05 2007 +0000
+++ b/templates/gallery.html	Sat Dec 22 21:31:01 2007 +0000
@@ -52,5 +52,5 @@
 ${description}
     </p>
     <div id="info">
-        <p>ShortURL: <a href="${shorturl}>" rel="nofollow">${shorturl_code}</a></p>
+        <p>ShortURL: <a href="${shorturl}" rel="nofollow">${shorturl_code}</a></p>
     </div>
--- a/www/series.cgi	Sat Dec 22 19:19:05 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,215 +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 shelve
-import cgi
-import Cookie
-import os, os.path
-
-import degal
-
-#
-# load request params
-#
-vars = cgi.FieldStorage()
-
-# these are interpeted different ways, hence the generic naming
-arg1 = vars["keys"].value
-if 'index' in vars :
-    arg2 = vars["index"].value
-else :
-    arg2 = None
-
-# the cookie with the user's current series
-cookie = Cookie.SimpleCookie(os.environ.get('HTTP_COOKIE', None))
-
-# a special action?
-if arg1 and arg1 in ('add', 'del', 'clear', 'view') or arg2 == 'load' :
-    # load the keys from the cookie
-    if 'series' in cookie :
-        keys = cookie["series"].value.split()
-    else :
-        keys = []
-    
-    if arg2 == 'load' :
-        # set the keys in the user's cookie to those in the URL
-        keys = arg1.split()
-
-    elif arg1 == 'add' and arg2 not in keys :
-        # add a code to the list of keys
-        keys.append(arg2)
-
-    elif arg1 == 'del' and arg2 in keys :
-        # remove a key from the list of keys
-        keys.remove(arg2)
-
-    elif arg1 == 'clear' :
-        # clear out the set of keys
-        keys = []
-
-    elif arg1 == 'view' :
-        # just view them
-        pass
-   
-    # set the series cookie value
-    cookie['series'] = ' '.join(keys)
-    cookie['series']['path'] = '/'
-    
-    # if we have keys, redirect to them, otherwise, back to index we go
-    if keys :
-        redirect_to = "../%s/" % ('+'.join(keys))
-    else :
-        redirect_to = "../.."
-    
-    # do the redirect
-    print "Status: 302"
-    print "Location: %s" % redirect_to
-    print cookie
-    print
-    print "Redirect..."
-else :
-    # we're just viewing
-    keys = arg1.split()
-    
-    # is this "My Series"?
-    my_series = 'series' in cookie and cookie['series'].value.split() == keys
-        
-    if arg2 :
-        index = int(arg2)
-    else :
-        index = None
-
-    # load DB
-    db = shelve.open('shorturls2', 'r')
-
-    # get the Image objects
-    photos = []
-    
-    #
-    # Start ugly code-misreuse
-    #
-
-    # monkey-patch the templates
-    rendered_templates = []
-
-    def _myRenderTo (self, path, **vars) :
-        rendered_templates.append(self.render(**vars))
-
-    # lalalalala... ooh, look;
-
-    degal.Template.renderTo = _myRenderTo
-    #
-    #         vvvvvvvvvvvvvvvvvvvv
-    #         vvvvvvvvvvvvvvvvvvvv
-    #
-    #    >>>> SHINY PINK ELEPHANT! <<<<
-    #
-    #         ^^^^^^^^^^^^^^^^^^^^
-    #         ^^^^^^^^^^^^^^^^^^^^
-
-    # our own version of Folder
-    class Series (degal.Folder) :
-        def __init__ (self) :
-            super(Series, self).__init__()
-            
-            self.alive = True
-            self.filtered = False
-            self.subdirs = {}
-            self.images = {}
-            self.sorted_images = []
-            self.title = "Series"
-
-            if my_series :
-                self.descr = '<a href="../clear/" rel="nofollow">Clear your series</a>'
-            else :
-                self.descr = '<a href="load" rel="nofollow">Load as your series</a>'
-
-            self.shorturl_code = ''
-        
-        def breadcrumb (self) :
-            return [('../..', 'Gallery'), ('.', 'Series')]
-
-        def inRoot (self, *fnames) :
-            return os.path.join('../..', *fnames)
-
-    class Image (degal.Image) :
-        def __init__ (self, series, key, i) :
-            type, self.dir_name, self.image_name = db[key]
-
-            super(Image, self).__init__(series, self.image_name)
-            
-            self.path = self._path()
-            self.shorturl_code = key
-            self.html_path = self.html_name = str(i + 1)
-            self.title = 'Image %d' % (i + 1, )
-            self.descr = '<span style="font-size: x-small">Standalone image: <a href="%s.html">%s</a></span>' % (self._path(), self._path().lstrip('./'))
-            self.img_size = (-1, -1)
-            self.filesize = 0
-            self.timestamp = 0
-
-            if my_series :
-                self.series_act = "del"
-                self.series_verb = "Remove from"
-            else :
-                self.series_act = self.series_verb = ""
-
-        def breadcrumb (self) :
-            return [('../..', 'Gallery'), ('.', 'Series'), (self.html_name, self.title)]
-
-        def _path (self, blaa='') :
-            return os.path.join('../..', self.dir_name, blaa, self.image_name)
-
-        def thumbImgTag (self) :
-            return degal.link(self.html_name, "<img src='%s' alt='%s' title='%s'>" % (self._path(degal.THUMB_DIR), '', self.title))
-
-        def previewImgTag (self) :
-            return degal.link(self._path(), "<img src='%s' alt='%s' title='%s'>" % (self._path(degal.PREVIEW_DIR), '', self.title))
-
-    series = Series()
-
-    try :
-        prev = None
-
-        for i, key in enumerate(keys) :
-            img = Image(series, key, i)
-
-            if prev :
-                prev.next = img
-
-            img.prev = prev
-            prev = img
-
-            series.sorted_images.append(img)
-    finally :
-        db.close()
-
-    if index :
-        img = series.sorted_images[index - 1]
-
-        img.render()
-    else :
-        series.render()
-
-    print "Content-Type: text/html"
-    print
-    print rendered_templates[0]
-
--- a/www/shorturl.cgi	Sat Dec 22 19:19:05 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +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 shelve
-import cgi
-import os, os.path
-
-vars = cgi.FieldStorage()
-
-key = vars['key'].value
-
-if 'index' in vars :
-    index = int(vars['index'].value.lstrip('/'))
-else :
-    index = None
-
-db = shelve.open('shorturls2', 'r')
-
-try :
-    type, dirpath, fname = db[key]
-
-    if type == 'img' :
-        fname += '.html'
-    elif type == 'dir' :
-        fname = ''
-
-    if index :
-        if index > 1 : 
-            fname = 'index_%s.html' % (index - 1)
-
-        dirpath = '../%s' % dirpath
-
-    path = os.path.join(dirpath, fname)
-finally :
-    db.close()
-
-print "Status: 302"
-print "Location: ../%s" % path
-print
-print "../%s" % path
-
--- a/www/taggr.cgi	Sat Dec 22 19:19:05 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 = """
-<li>
-    <span class="inputs">
-        <label for="img_%(fname)s_title">Title</label> <input type="text" name="img_%(fname)s_title" size="60" value="%(title)s" /> <br/>
-        <label for="img_%(fname)s_descr">Description</label> <input type="text" name="img_%(fname)s_descr" size="60" value="%(descr)s" /> <br/>
-        <label for="img_%(fname)s_tags">Tags</label> <input type="text" name="img_%(fname)s_tags" size="60" value="%(tags)s" /> <br/>
-    </span>
-    
-    <input type="checkbox" name="img_%(fname)s_chk" class="chk" />
-    
-    <span class="thumb"><a href="%(html_path)s"><img src="%(thumb_path)s" /></a></span>
-</li>
-        """ % 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     = "<ul>" + ''.join([h for fname, h in image_list]) + "</ul>",
-    PATH        = path,
-)
-