remove old scripts/cgi-bin stuff. They wouldn't work as such with the new version, and replacements can be written while referring to the history
1.1 --- a/MANIFEST.in Wed Jul 01 20:03:41 2009 +0300
1.2 +++ b/MANIFEST.in Wed Jul 01 20:15:08 2009 +0300
1.3 @@ -1,2 +1,1 @@
1.4 include degal/static/*
1.5 -include cgi-bin/*
2.1 --- a/cgi-bin/inc.py Wed Jul 01 20:03:41 2009 +0300
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,27 +0,0 @@
2.4 -# config
2.5 -
2.6 -# location of DeGAL itself
2.7 -
2.8 -DEGAL_PATH = "/mnt/photos/public"
2.9 -
2.10 -
2.11 -
2.12 -if __name__ == '__main__' :
2.13 - raise Exception("Don't access inc.py directly")
2.14 -
2.15 -# setup env
2.16 -
2.17 -import sys
2.18 -import os, os.path
2.19 -
2.20 -#def splitn (path, n) :
2.21 -# for i in xrange(0, n) :
2.22 -# path = os.path.split(path)[0]
2.23 -#
2.24 -# return path
2.25 -#
2.26 -#degal_path = splitn(os.path.join(os.getcwd(), __file__), 2)
2.27 -
2.28 -os.chdir(DEGAL_PATH)
2.29 -sys.path.append(DEGAL_PATH)
2.30 -
3.1 --- a/cgi-bin/series.py Wed Jul 01 20:03:41 2009 +0300
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,211 +0,0 @@
3.4 -#!/usr/bin/env python2.4
3.5 -#
3.6 -# DeGAL - A pretty simple web image gallery
3.7 -# Copyright (C) 2007 Tero Marttila
3.8 -# http://marttila.de/~terom/degal/
3.9 -#
3.10 -# This program is free software; you can redistribute it and/or modify
3.11 -# it under the terms of the GNU General Public License as published by
3.12 -# the Free Software Foundation; either version 2 of the License, or
3.13 -# (at your option) any later version.
3.14 -#
3.15 -# This program is distributed in the hope that it will be useful,
3.16 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
3.17 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3.18 -# GNU General Public License for more details.
3.19 -#
3.20 -# You should have received a copy of the GNU General Public License
3.21 -# along with this program; if not, write to the
3.22 -# Free Software Foundation, Inc.,
3.23 -# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3.24 -#
3.25 -
3.26 -import os
3.27 -import cgi
3.28 -import Cookie
3.29 -
3.30 -import inc
3.31 -from lib import shorturl, template, utils, settings
3.32 -
3.33 -#
3.34 -# load request params
3.35 -#
3.36 -vars = cgi.FieldStorage()
3.37 -
3.38 -# these are interpeted different ways, hence the generic naming
3.39 -arg1 = vars["keys"].value
3.40 -if 'index' in vars :
3.41 - arg2 = vars["index"].value
3.42 -else :
3.43 - arg2 = None
3.44 -
3.45 -# the cookie with the user's current series
3.46 -cookie = Cookie.SimpleCookie(os.environ.get('HTTP_COOKIE', None))
3.47 -
3.48 -# a special action?
3.49 -if arg1 and arg1 in ('add', 'del', 'clear', 'view') or arg2 == 'load' :
3.50 - # load the keys from the cookie
3.51 - if 'series' in cookie :
3.52 - keys = cookie["series"].value.split()
3.53 - else :
3.54 - keys = []
3.55 -
3.56 - if arg2 == 'load' :
3.57 - # set the keys in the user's cookie to those in the URL
3.58 - keys = arg1.split()
3.59 -
3.60 - elif arg1 == 'add' and arg2 not in keys :
3.61 - # add a code to the list of keys
3.62 - keys.append(arg2)
3.63 -
3.64 - elif arg1 == 'del' and arg2 in keys :
3.65 - # remove a key from the list of keys
3.66 - keys.remove(arg2)
3.67 -
3.68 - elif arg1 == 'clear' :
3.69 - # clear out the set of keys
3.70 - keys = []
3.71 -
3.72 - elif arg1 == 'view' :
3.73 - # just view them
3.74 - pass
3.75 -
3.76 - # set the series cookie value
3.77 - cookie['series'] = ' '.join(keys)
3.78 - cookie['series']['path'] = '/'
3.79 -
3.80 - # if we have keys, redirect to them, otherwise, back to index we go
3.81 - if keys :
3.82 - redirect_to = "../%s/" % ('+'.join(keys))
3.83 - else :
3.84 - redirect_to = "../.."
3.85 -
3.86 - # do the redirect
3.87 - print "Status: 302"
3.88 - print "Location: %s" % redirect_to
3.89 - print cookie
3.90 - print
3.91 - print "Redirect..."
3.92 -else :
3.93 - # we're just viewing
3.94 - keys = arg1.split()
3.95 -
3.96 - # is this "My Series"?
3.97 - my_series = 'series' in cookie and cookie['series'].value.split() == keys
3.98 -
3.99 - index = fname = None
3.100 -
3.101 - if arg2 :
3.102 - try :
3.103 - index = int(arg2)
3.104 - except ValueError :
3.105 - fname = arg2
3.106 -
3.107 - # our custom Series/Image classes, because they do act slightly differently
3.108 -
3.109 - class Series (object) :
3.110 - def __init__ (self, keys) :
3.111 - self.images = []
3.112 - prev = None
3.113 -
3.114 - self.image_dict = dict()
3.115 -
3.116 - images = shorturl.get_images(keys)
3.117 -
3.118 - for index, (key, (dir, fname)) in enumerate(zip(keys, images)) :
3.119 - img = Image(self, key, dir, fname, index)
3.120 - self.images.append(img)
3.121 - self.image_dict[fname] = img
3.122 -
3.123 - img.prev = prev
3.124 -
3.125 - if prev :
3.126 - prev.next = img
3.127 -
3.128 - prev = img
3.129 -
3.130 - def render (self) :
3.131 - if my_series :
3.132 - descr = '<a href="../clear/" rel="nofollow">Clear your series</a>'
3.133 - else :
3.134 - descr = '<a href="load" rel="nofollow">Load as your series</a>'
3.135 -
3.136 - return template.gallery.render(
3.137 - stylesheet_url = utils.url("style.css", up=2),
3.138 -
3.139 - breadcrumb = [(utils.url(up=1), "Index"), (utils.url(), "Series")],
3.140 -
3.141 - dirs = None,
3.142 - title = "Series",
3.143 -
3.144 - num_pages = 1,
3.145 - cur_page = 0,
3.146 -
3.147 - images = self.images,
3.148 -
3.149 - description = descr,
3.150 -
3.151 - shorturl = None,
3.152 - shorturl_code = None,
3.153 - )
3.154 -
3.155 - class Image (object) :
3.156 - def __init__ (self, series, key, dir, fname, index) :
3.157 - self.fname = fname
3.158 - self.name = utils.url_join(dir, fname, abs=True)
3.159 - self.html_name = utils.url(fname)
3.160 - self.real_html_name = utils.url_join(dir, fname + ".html", abs=True)
3.161 -
3.162 - self.thumb_name = utils.url_join(dir, settings.THUMB_DIR, fname, abs=True)
3.163 - self.preview_name = utils.url_join(dir, settings.PREVIEW_DIR, fname, abs=True)
3.164 -
3.165 - self.shorturl = key
3.166 -
3.167 - self.prev = self.next = None
3.168 -
3.169 - def render (self) :
3.170 - descr = '<span style="font-size: x-small"><a href="%s.html">Standalone image</a></span>' % self.real_html_name
3.171 -
3.172 - if my_series :
3.173 - series_url = utils.url_join("del", self.shorturl, up=1)
3.174 - series_verb = "Remove from"
3.175 - else :
3.176 - series_url = series_verb = ""
3.177 -
3.178 - return template.image.render(
3.179 - stylesheet_url = utils.url("style.css", up=3),
3.180 -
3.181 - breadcrumb = [(utils.url(up=2), "Index"), (utils.url("."), "Series"), (self.html_name, self.fname)],
3.182 -
3.183 - title = self.fname,
3.184 -
3.185 - prev = self.prev,
3.186 - img = self,
3.187 - next = self.next,
3.188 -
3.189 - description = descr,
3.190 -
3.191 - img_size = None,
3.192 - file_size = None,
3.193 - timestamp = None,
3.194 -
3.195 - shorturl = utils.url_join("s", self.shorturl, abs=True),
3.196 - shorturl_code = self.shorturl,
3.197 -
3.198 - series_url = series_url,
3.199 - series_verb = series_verb,
3.200 - )
3.201 -
3.202 - series = Series(keys)
3.203 -
3.204 - if fname :
3.205 - html = series.image_dict[fname].render()
3.206 - elif index :
3.207 - html = series.images[index - 1].render()
3.208 - else :
3.209 - html = series.render()
3.210 -
3.211 - print "Content-Type: text/html"
3.212 - print
3.213 - print html
3.214 -
4.1 --- a/cgi-bin/shorturl.py Wed Jul 01 20:03:41 2009 +0300
4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
4.3 @@ -1,41 +0,0 @@
4.4 -#!/usr/bin/env python2.5
4.5 -#
4.6 -# DeGAL - A pretty simple web image gallery
4.7 -# Copyright (C) 2007 Tero Marttila
4.8 -# http://marttila.de/~terom/degal/
4.9 -#
4.10 -# This program is free software; you can redistribute it and/or modify
4.11 -# it under the terms of the GNU General Public License as published by
4.12 -# the Free Software Foundation; either version 2 of the License, or
4.13 -# (at your option) any later version.
4.14 -#
4.15 -# This program is distributed in the hope that it will be useful,
4.16 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
4.17 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4.18 -# GNU General Public License for more details.
4.19 -#
4.20 -# You should have received a copy of the GNU General Public License
4.21 -# along with this program; if not, write to the
4.22 -# Free Software Foundation, Inc.,
4.23 -# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
4.24 -#
4.25 -
4.26 -import inc
4.27 -from lib import shorturl, req
4.28 -
4.29 -key = req.get_str('key')
4.30 -index = req.get_int('index', None)
4.31 -
4.32 -path = shorturl.html_path(key)
4.33 -
4.34 -if path :
4.35 - print "Status: 302"
4.36 - print "Location: ../%s" % path
4.37 - print
4.38 - print "../%s" % path
4.39 -
4.40 -else :
4.41 - print "Status: 404"
4.42 - print
4.43 - print "404"
4.44 -
5.1 --- a/degal/filesystem.py Wed Jul 01 20:03:41 2009 +0300
5.2 +++ b/degal/filesystem.py Wed Jul 01 20:15:08 2009 +0300
5.3 @@ -397,6 +397,7 @@
5.4 The first and last nodes may be Files, but all other objects must be Directories.
5.5
5.6 XXX: better to keep Paths symbolic/relative?
5.7 + XXX: welcome to Circular Reference Hell, a place has been reserved for you
5.8 """
5.9
5.10 def __init__ (self, *nodes) :
6.1 --- a/degal/utils.py Wed Jul 01 20:03:41 2009 +0300
6.2 +++ b/degal/utils.py Wed Jul 01 20:15:08 2009 +0300
6.3 @@ -84,6 +84,7 @@
6.4
6.5 for attr in attrs :
6.6 if attr in obj.__dict__ :
6.7 + # this will drop refcounts and free resources, so it may take some execution time
6.8 del obj.__dict__[attr]
6.9
6.10 def first (iterable) :
7.1 --- a/scripts/detool Wed Jul 01 20:03:41 2009 +0300
7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
7.3 @@ -1,106 +0,0 @@
7.4 -#!/usr/bin/env python2.4
7.5 -#
7.6 -# DeGAL - A pretty simple web image gallery
7.7 -# Copyright (C) 2007 Tero Marttila
7.8 -# http://marttila.de/~terom/degal/
7.9 -#
7.10 -# This program is free software; you can redistribute it and/or modify
7.11 -# it under the terms of the GNU General Public License as published by
7.12 -# the Free Software Foundation; either version 2 of the License, or
7.13 -# (at your option) any later version.
7.14 -#
7.15 -# This program is distributed in the hope that it will be useful,
7.16 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
7.17 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7.18 -# GNU General Public License for more details.
7.19 -#
7.20 -# You should have received a copy of the GNU General Public License
7.21 -# along with this program; if not, write to the
7.22 -# Free Software Foundation, Inc.,
7.23 -# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
7.24 -#
7.25 -
7.26 -from lib import settings
7.27 -from lib.log import misc as log
7.28 -from lib.utils import path_join
7.29 -import os, os.path, logging
7.30 -
7.31 -def move (options, args) :
7.32 - if len(args) < 2 :
7.33 - raise Exception("Must give one or more source files, and a destination dir")
7.34 -
7.35 - dest = args.pop(-1)
7.36 - srcs = args
7.37 -
7.38 - if not os.path.isdir(dest) :
7.39 - raise Exception("Given destination '%s' is not a directory" % dest)
7.40 -
7.41 - for subdir in (settings.THUMB_DIR, settings.PREVIEW_DIR) :
7.42 - path = os.path.join(dest, subdir)
7.43 -
7.44 - if not os.path.exists(path) :
7.45 - log.info("mkdir %s" % path)
7.46 - os.mkdir(path)
7.47 -
7.48 - for src in srcs :
7.49 - if not os.path.isfile(src) :
7.50 - raise Exception("Given source file '%s' is not a valid file" % src)
7.51 -
7.52 - for (pre, post) in (
7.53 - (None, None),
7.54 - (settings.THUMB_DIR, None),
7.55 - (settings.PREVIEW_DIR, None),
7.56 - (None, '.html'),
7.57 - ) :
7.58 - dir, fname = os.path.split(src)
7.59 -
7.60 - if post :
7.61 - fname += post
7.62 -
7.63 - src_path = path_join(dir, pre, fname)
7.64 - dst_path = path_join(dest, pre, fname)
7.65 -
7.66 - if os.path.isfile(src_path) :
7.67 - if not options.overwite and os.path.exists(dst_path) :
7.68 - log.warning("%s exists; skipping %s" % (dst_path, src_path))
7.69 - log.info("%s -> %s" % (src_path, dst_path))
7.70 - os.rename(src_path, dst_path)
7.71 -
7.72 -def help (options, args) :
7.73 - print "Available commands:"
7.74 -
7.75 - for name, func in COMMANDS.iteritems() :
7.76 - print "\t%s" % name
7.77 -
7.78 -COMMANDS = dict(
7.79 - move = move,
7.80 - mv = move,
7.81 - help = help,
7.82 -)
7.83 -
7.84 -if __name__ == '__main__' :
7.85 - from optparse import OptionParser
7.86 -
7.87 - parser = OptionParser(usage="usage: %prog <command> [options] [args ...]", version=settings.VERSION)
7.88 -
7.89 - parser.add_option("-q", "--quiet", dest="verbose", default=True)
7.90 - parser.add_option("-i", "--careful", dest="overwrite", help="Do not overwrite files", default=True)
7.91 -
7.92 - options, args = parser.parse_args()
7.93 -
7.94 - if options.verbose :
7.95 - log.setLevel(logging.INFO)
7.96 - else :
7.97 - log.setLevel(logging.ERROR)
7.98 -
7.99 - if not args :
7.100 - parser.error("Must supply a command. See `detool.py help` for a list of commands")
7.101 -
7.102 - command = args.pop(0).lower()
7.103 -
7.104 - if command not in COMMANDS :
7.105 - parser.error("Unknown command '%s'. Try `detool.py help`" % command)
7.106 -
7.107 - func = COMMANDS[command]
7.108 -
7.109 - func(options, args)
7.110 \ No newline at end of file
8.1 --- a/scripts/fix_duplicate_shorturls.py Wed Jul 01 20:03:41 2009 +0300
8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
8.3 @@ -1,33 +0,0 @@
8.4 -from lib import shorturl
8.5 -
8.6 -db = shorturl.DB(read_only=False)
8.7 -
8.8 -ids = dict()
8.9 -
8.10 -newid = db.db['_id']
8.11 -
8.12 -for key in db.db.keys() :
8.13 - if key.startswith('_') :
8.14 - continue
8.15 -
8.16 - if len(key) == 1 :
8.17 - print "key %s is too short!?" % key
8.18 - del db.db[key]
8.19 -
8.20 - continue
8.21 -
8.22 - print "%s:" % key,
8.23 - id = shorturl.key2int(key)
8.24 -
8.25 - if id in ids :
8.26 - newkey = shorturl.int2key(newid)
8.27 - newid += 1
8.28 -
8.29 - print "%d -> %s, -> %s" % (id, ids[id], newkey)
8.30 -
8.31 - db.db[newkey] = db.db[key]
8.32 - del db.db[key]
8.33 - else :
8.34 - print "ok"
8.35 - ids[id] = key
8.36 -
9.1 --- a/scripts/migrate_shorturls.py Wed Jul 01 20:03:41 2009 +0300
9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
9.3 @@ -1,53 +0,0 @@
9.4 -from lib import shorturl, db
9.5 -
9.6 -sdb = shorturl.DB()
9.7 -
9.8 -def gen () :
9.9 - count = 0
9.10 -
9.11 - for key in sdb.db.keys() :
9.12 - if key.startswith("_") :
9.13 - continue
9.14 -
9.15 - print "%6s" % key,
9.16 -
9.17 - value = sdb.db[key]
9.18 -
9.19 - if not isinstance(value, tuple) or len(value) != 3 :
9.20 - print "CORRUPT VALUE!!!"
9.21 - continue
9.22 -
9.23 - type, dirpath, fname = value
9.24 -
9.25 - id = shorturl.key2int(key)
9.26 - dirpath = dirpath.lstrip('.').lstrip('/')
9.27 -
9.28 - if type == "img" :
9.29 - print "img"
9.30 - continue # already imported images
9.31 -
9.32 - print "img %6d %50s %10s" % (id, dirpath, fname)
9.33 -
9.34 - yield id, dirpath, fname
9.35 -
9.36 - else :
9.37 -
9.38 - print "dir %6d %50s" % (id, dirpath)
9.39 -
9.40 - yield id, dirpath, ''
9.41 -
9.42 - count += 1
9.43 -
9.44 - if count % 500 == 0 :
9.45 - print count
9.46 -
9.47 -
9.48 -print "Starting import..."
9.49 -
9.50 -c = db.insert_many("""
9.51 - INSERT OR IGNORE INTO nodes VALUES (?, ?, ?)
9.52 -""", gen())
9.53 -
9.54 -print "Done!"
9.55 -
9.56 -print "%d rows affected" % c
10.1 --- a/setup.py Wed Jul 01 20:03:41 2009 +0300
10.2 +++ b/setup.py Wed Jul 01 20:15:08 2009 +0300
10.3 @@ -29,7 +29,5 @@
10.4
10.5 scripts = [
10.6 'bin/degal',
10.7 - 'scripts/fix_duplicate_shorturls.py', 'scripts/migrate_shorturls.py',
10.8 - 'cgi-bin/series.py', 'cgi-bin/shorturl.py',
10.9 ],
10.10 )