From d07a973377eae6e347483724c96e32c1fa4f4086 Mon Sep 17 00:00:00 2001 From: ville rantanen Date: Thu, 3 May 2012 09:44:13 +0300 Subject: [PATCH] added parent link, out from the gallery --- Qalbum.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Qalbum.py b/Qalbum.py index bdcf4c6..16ab702 100755 --- a/Qalbum.py +++ b/Qalbum.py @@ -26,7 +26,7 @@ from datetime import datetime # (c) ville.rantanen@helsinki.fi -__version__='1.8' +__version__='1.9' webfilesearch=re.compile('.*index.html$|gallerystyle.css$|galleryscript.js$|descriptions.csv$|^info.txt$|\..*',re.I) imagesearch=re.compile('.*\.jpg$|.*\.jpeg$|.*\.gif$|.*\.png$|.*\.svg$|.*\.pdf$',re.I) @@ -293,14 +293,19 @@ def getinfo(path): reader = open(os.path.join(path,'info.txt'),'r') return unicode(reader.read(),encoding="utf8",errors="ignore").encode('ascii','xmlcharrefreplace') -def crumblinks(crumbs): +def crumblinks(crumbs,title,parent): ''' Create the HTML string for crumb trails ''' + strout='
' + if parent: + if not parent.startswith('http://'): + parent="../"*(len(crumbs))+parent + strout+=''+'Home'.encode('ascii', 'xmlcharrefreplace')+': ' i=1 for c in crumbs: cname=os.path.basename(c) if i==1: - cname="Home" + cname=title cdepth=len(crumbs)-i clink="../"*cdepth strout+=''+unicode(cname,encoding="utf8").encode('ascii', 'xmlcharrefreplace')+': ' @@ -335,14 +340,14 @@ def traverse(path,crumbs,inputs,options): header=getheader(path,'../'*(len(crumbs)-1),inputs[0][1]) else: header=getheader(path,'../'*(len(crumbs)-1)) - print(len(crumbs)) + print('Depth: '+str(len(crumbs))) pathlist=getpathlist(path,options) imagelist=getimagelist(path,options) filelist=getnonimagelist(path,options) print(str(len(pathlist))+' paths') print(str(len(imagelist))+' images') print(str(len(filelist))+' other files') - crumbstring=crumblinks(crumbs) + crumbstring=crumblinks(crumbs,options.gallery,options.parent) if len(pathlist)>0: pathstring=pathlinks(path,pathlist) pathjs=pathscript(path,pathlist) @@ -396,6 +401,8 @@ def setupoptions(): help="Name for the root gallery (Default: %(default)s)") parser.add_argument("-w",type=int,dest="width",default=850, help="Medium image size (Default: %(default)s)") + parser.add_argument("-p",type=str,dest="parent", + help="Add a ../[PARENT] link to point out from the gallery. If the string starts with http:// it is considered as a static URL, otherwise the relative parent path is assumed.") parser.add_argument("startpath",type=str,action="store",default=os.path.abspath('.'),nargs='?', help="Root path of the gallery") options=parser.parse_args()