--- a/series.cgi Fri Dec 21 22:14:01 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/shorturl.cgi Fri Dec 21 22:14:01 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/style.css Fri Dec 21 22:14:01 2007 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,143 +0,0 @@
-body {
- background-color: #333333;
- color: #cccccc;
- font-family: "Arial", sans-serif;
- font-size: small;
-}
-
-a {
- color: #ff8800;
- text-decoration: none;
-}
-
-a:hover {
- text-decoration: underline;
-}
-
-#thumbnails, #image, #description, h1 {
- text-align: center;
-}
-
-#thumbnails img {
- margin: 0.2em;
-}
-
-img {
- border: 1px solid #666666;
-}
-
-a:focus img {
- border: 1px solid #cccccc;
-}
-
-img:hover, a:focus img:hover {
- border: 1px solid #ff8800;
-}
-
-div#breadcrumb {
-
-}
-
-div#info {
- font-size: x-small;
- color: #666666;
-}
-
-div#info p {
- padding: 0px;
- margin: 0px;
-}
-
-p#about {
- padding-top: 50px;
- font-size: xx-small;
- text-align: center;
-
-}
-
-div.paginate {
- padding-top: 20px;
- height: 50px;
- width: 100%;
- text-align: center;
-}
-
-div.paginate ul {
- margin: 0px;
- padding: 0px;
-
- line-height: 30px;
- white-space: nowrap;
-}
-
-div.paginate li {
- list-style-type: none;
- display: inline;
-}
-
-div.paginate li *,
-div.paginate li strong,
-div.paginate li span {
- padding: 7px 10px;
-}
-
-div.paginate li span {
- color: #444444;
-}
-
-div.paginate li a:hover {
- text-decoration: none;
- 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;
-}
-
-
--- a/taggr.cgi Fri Dec 21 22:14: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 = """
-<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/www/series.cgi Sat Dec 22 19:19:05 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/www/shorturl.cgi Sat Dec 22 19:19:05 2007 +0000
@@ -0,0 +1,61 @@
+#!/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
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/www/style.css Sat Dec 22 19:19:05 2007 +0000
@@ -0,0 +1,143 @@
+body {
+ background-color: #333333;
+ color: #cccccc;
+ font-family: "Arial", sans-serif;
+ font-size: small;
+}
+
+a {
+ color: #ff8800;
+ text-decoration: none;
+}
+
+a:hover {
+ text-decoration: underline;
+}
+
+#thumbnails, #image, #description, h1 {
+ text-align: center;
+}
+
+#thumbnails img {
+ margin: 0.2em;
+}
+
+img {
+ border: 1px solid #666666;
+}
+
+a:focus img {
+ border: 1px solid #cccccc;
+}
+
+img:hover, a:focus img:hover {
+ border: 1px solid #ff8800;
+}
+
+div#breadcrumb {
+
+}
+
+div#info {
+ font-size: x-small;
+ color: #666666;
+}
+
+div#info p {
+ padding: 0px;
+ margin: 0px;
+}
+
+p#about {
+ padding-top: 50px;
+ font-size: xx-small;
+ text-align: center;
+
+}
+
+div.paginate {
+ padding-top: 20px;
+ height: 50px;
+ width: 100%;
+ text-align: center;
+}
+
+div.paginate ul {
+ margin: 0px;
+ padding: 0px;
+
+ line-height: 30px;
+ white-space: nowrap;
+}
+
+div.paginate li {
+ list-style-type: none;
+ display: inline;
+}
+
+div.paginate li *,
+div.paginate li strong,
+div.paginate li span {
+ padding: 7px 10px;
+}
+
+div.paginate li span {
+ color: #444444;
+}
+
+div.paginate li a:hover {
+ text-decoration: none;
+ 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;
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/www/taggr.cgi Sat Dec 22 19:19:05 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,
+)
+