de-cgi-bin/shorturl.py
author terom
Wed, 16 Jan 2008 14:58:03 +0000
changeset 19 8d3ffd87cb0b
parent 18 cgi-bin/shorturl.py@46536daf9e04
child 22 72696ca68c34
permissions -rwxr-xr-x
* move cgi-bin to de-cgi-bin so it doesn't conflict with my default alias... need to come up with a real solution to this
* refactored series/shorturl into the new codebase
12
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 9
diff changeset
     1
#!/usr/bin/env python2.4
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 9
diff changeset
     2
#
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 9
diff changeset
     3
# DeGAL - A pretty simple web image gallery
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 9
diff changeset
     4
# Copyright (C) 2007 Tero Marttila
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 9
diff changeset
     5
# http://marttila.de/~terom/degal/
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 9
diff changeset
     6
#
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 9
diff changeset
     7
# This program is free software; you can redistribute it and/or modify
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 9
diff changeset
     8
# it under the terms of the GNU General Public License as published by
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 9
diff changeset
     9
# the Free Software Foundation; either version 2 of the License, or
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 9
diff changeset
    10
# (at your option) any later version.
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 9
diff changeset
    11
#
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 9
diff changeset
    12
# This program is distributed in the hope that it will be useful,
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 9
diff changeset
    13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 9
diff changeset
    14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 9
diff changeset
    15
# GNU General Public License for more details.
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 9
diff changeset
    16
#
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 9
diff changeset
    17
# You should have received a copy of the GNU General Public License
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 9
diff changeset
    18
# along with this program; if not, write to the
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 9
diff changeset
    19
# Free Software Foundation, Inc.,
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 9
diff changeset
    20
# 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 9
diff changeset
    21
#
c2d8e9a754a1 Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents: 9
diff changeset
    22
1
740133ab6353 initial code, somewhere between 0.2 and 0.5
terom
parents:
diff changeset
    23
import cgi
740133ab6353 initial code, somewhere between 0.2 and 0.5
terom
parents:
diff changeset
    24
18
46536daf9e04 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
terom
parents: 17
diff changeset
    25
import inc
19
8d3ffd87cb0b * move cgi-bin to de-cgi-bin so it doesn't conflict with my default alias... need to come up with a real solution to this
terom
parents: 18
diff changeset
    26
from lib import shorturl
18
46536daf9e04 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
terom
parents: 17
diff changeset
    27
1
740133ab6353 initial code, somewhere between 0.2 and 0.5
terom
parents:
diff changeset
    28
vars = cgi.FieldStorage()
740133ab6353 initial code, somewhere between 0.2 and 0.5
terom
parents:
diff changeset
    29
740133ab6353 initial code, somewhere between 0.2 and 0.5
terom
parents:
diff changeset
    30
key = vars['key'].value
6
d9d1f8e5f384 fix alignment of teh paginator, and make shorturl dirs better (no index.html + pagination)
terom
parents: 5
diff changeset
    31
d9d1f8e5f384 fix alignment of teh paginator, and make shorturl dirs better (no index.html + pagination)
terom
parents: 5
diff changeset
    32
if 'index' in vars :
d9d1f8e5f384 fix alignment of teh paginator, and make shorturl dirs better (no index.html + pagination)
terom
parents: 5
diff changeset
    33
    index = int(vars['index'].value.lstrip('/'))
d9d1f8e5f384 fix alignment of teh paginator, and make shorturl dirs better (no index.html + pagination)
terom
parents: 5
diff changeset
    34
else :
d9d1f8e5f384 fix alignment of teh paginator, and make shorturl dirs better (no index.html + pagination)
terom
parents: 5
diff changeset
    35
    index = None
d9d1f8e5f384 fix alignment of teh paginator, and make shorturl dirs better (no index.html + pagination)
terom
parents: 5
diff changeset
    36
19
8d3ffd87cb0b * move cgi-bin to de-cgi-bin so it doesn't conflict with my default alias... need to come up with a real solution to this
terom
parents: 18
diff changeset
    37
db = shorturl.DB()
9
a0a13d5e406c ShortURLs for dirs without page numbers were broken, as fname was 'index'
terom
parents: 6
diff changeset
    38
19
8d3ffd87cb0b * move cgi-bin to de-cgi-bin so it doesn't conflict with my default alias... need to come up with a real solution to this
terom
parents: 18
diff changeset
    39
path = db.html_path(key, index)
6
d9d1f8e5f384 fix alignment of teh paginator, and make shorturl dirs better (no index.html + pagination)
terom
parents: 5
diff changeset
    40
19
8d3ffd87cb0b * move cgi-bin to de-cgi-bin so it doesn't conflict with my default alias... need to come up with a real solution to this
terom
parents: 18
diff changeset
    41
print "Status: 302"
8d3ffd87cb0b * move cgi-bin to de-cgi-bin so it doesn't conflict with my default alias... need to come up with a real solution to this
terom
parents: 18
diff changeset
    42
print "Location: ../%s" % path
8d3ffd87cb0b * move cgi-bin to de-cgi-bin so it doesn't conflict with my default alias... need to come up with a real solution to this
terom
parents: 18
diff changeset
    43
print
8d3ffd87cb0b * move cgi-bin to de-cgi-bin so it doesn't conflict with my default alias... need to come up with a real solution to this
terom
parents: 18
diff changeset
    44
print "../%s" % path
18
46536daf9e04 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
terom
parents: 17
diff changeset
    45