fix alignment of teh paginator, and make shorturl dirs better (no index.html + pagination)
authorterom
Thu, 08 Nov 2007 19:26:00 +0000
changeset 6 d9d1f8e5f384
parent 5 156cdfffef8e
child 7 235ae238f694
fix alignment of teh paginator, and make shorturl dirs better (no index.html + pagination)
degal.py
shorturl.cgi
style.css
--- a/degal.py	Thu Nov 08 19:09:05 2007 +0000
+++ b/degal.py	Thu Nov 08 19:26:00 2007 +0000
@@ -449,9 +449,10 @@
                         pagination += '<li><span>Next &raquo;</span></li>'
 
                     pagination += "</ul>"
+                    shorturl = "%s/%s" % (self.shorturl_code, cur_page+1)
                 else :
                     pagination = ''
-
+                    shorturl = self.shorturl_code
 
                 # render to index.html
                 gallery_tpl.renderTo(self.pathFor(self._page_fname(cur_page)), 
@@ -462,8 +463,8 @@
                     PAGINATION=pagination,
                     CONTENT="".join([i.thumbImgTag() for i in page]),
                     DESCR=self.descr,
-                    SHORTURL=self.inRoot('s', self.shorturl_code),
-                    SHORTURL_CODE=self.shorturl_code,
+                    SHORTURL=self.inRoot('s', shorturl),
+                    SHORTURL_CODE=shorturl,
                 )
         
         # render images
--- a/shorturl.cgi	Thu Nov 08 19:09:05 2007 +0000
+++ b/shorturl.cgi	Thu Nov 08 19:26:00 2007 +0000
@@ -7,14 +7,27 @@
 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 == 'dir' : fname = 'index'
+    if index :
+        if index > 1 : 
+            fname += 'index_%s.html' % (index - 1)
 
-    path = os.path.join(dirpath, fname) + '.html'
+        dirpath = '../%s' % dirpath
+    
+    if type == 'img' :
+        fname += '.html'
+
+    path = os.path.join(dirpath, fname)
 finally :
     db.close()
 
--- a/style.css	Thu Nov 08 19:09:05 2007 +0000
+++ b/style.css	Thu Nov 08 19:26:00 2007 +0000
@@ -56,14 +56,16 @@
 }
 
 div.paginate {
+    padding-top: 20px;
     height: 50px;
     width: 100%;
     text-align: center;
 }
 
 div.paginate ul {
-    margin: 0px
+    margin: 0px;
     padding: 0px;
+
     line-height: 30px;
     white-space: nowrap;
 }