--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/de-cgi-bin/taggr2.py Thu Jan 17 01:56:04 2008 +0000
@@ -0,0 +1,95 @@
+#!/usr/bin/env python2.5
+#
+# 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 os, os.path
+
+import inc
+from lib import db, shorturl, settings, utils, template, req
+
+
+
+tpl = template.Template("taggr")
+
+act = req.get_str("act", None)
+path = req.get_str("path", None)
+
+print "Content-Type: text/html"
+print
+
+def dirlist (path) :
+ if '.' in path[1:] :
+ raise ValueError("invalid path")
+
+ dirs = []
+ imgs = []
+
+ for fname in os.listdir(path) :
+ fpath = os.path.join(path, fname).lstrip('.').lstrip('/')
+
+ if fname.startswith('.') :
+ continue
+
+ if fname in (settings.THUMB_DIR, settings.PREVIEW_DIR) :
+ continue
+
+ if os.path.isdir(fpath) :
+ dirs.append((fname, fpath))
+
+ elif utils.isImage(fname) :
+ key = shorturl.int2key(db.select("""SELECT id FROM images WHERE dirpath=? AND filename=?""", path, fname).fetchone()[0])
+
+ imgs.append((key, os.path.join(path, settings.THUMB_DIR, fname)))
+
+ dirs.sort()
+ imgs.sort()
+
+ return dirs, imgs
+
+if act == "dirlist" :
+ dirs, imgs = dirlist(path)
+
+ print template.Template("taggr_dir").render(
+ subdirs = dirs,
+ images = imgs,
+ )
+
+elif act == None :
+ dirs, imgs = dirlist(".")
+
+ if path :
+ open_dir = path
+ open_dir_contents = dirlist(path)
+ else :
+ open_dir = open_dir_contents = None
+
+ print template.Template("taggr").render(
+ stylesheet_url = utils.url("style.css", up=1),
+ title = "Taggr",
+ breadcrumb = [(utils.url(up=1), "Index"), (utils.url("."), "Taggr")],
+
+ subdirs = dirs,
+ images = imgs,
+
+ open_dir = open_dir,
+ open_dir_contents = open_dir_contents,
+ )
+