added parent link, out from the gallery
This commit is contained in:
17
Qalbum.py
17
Qalbum.py
@@ -26,7 +26,7 @@ from datetime import datetime
|
|||||||
|
|
||||||
# (c) ville.rantanen@helsinki.fi
|
# (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)
|
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)
|
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')
|
reader = open(os.path.join(path,'info.txt'),'r')
|
||||||
return unicode(reader.read(),encoding="utf8",errors="ignore").encode('ascii','xmlcharrefreplace')
|
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 '''
|
''' Create the HTML string for crumb trails '''
|
||||||
|
|
||||||
strout='<div id="crumbcontainer">'
|
strout='<div id="crumbcontainer">'
|
||||||
|
if parent:
|
||||||
|
if not parent.startswith('http://'):
|
||||||
|
parent="../"*(len(crumbs))+parent
|
||||||
|
strout+='<a href="'+parent+'">'+'Home'.encode('ascii', 'xmlcharrefreplace')+'</a>: '
|
||||||
i=1
|
i=1
|
||||||
for c in crumbs:
|
for c in crumbs:
|
||||||
cname=os.path.basename(c)
|
cname=os.path.basename(c)
|
||||||
if i==1:
|
if i==1:
|
||||||
cname="Home"
|
cname=title
|
||||||
cdepth=len(crumbs)-i
|
cdepth=len(crumbs)-i
|
||||||
clink="../"*cdepth
|
clink="../"*cdepth
|
||||||
strout+='<a href="'+clink+'index.html">'+unicode(cname,encoding="utf8").encode('ascii', 'xmlcharrefreplace')+'</a>: '
|
strout+='<a href="'+clink+'index.html">'+unicode(cname,encoding="utf8").encode('ascii', 'xmlcharrefreplace')+'</a>: '
|
||||||
@@ -335,14 +340,14 @@ def traverse(path,crumbs,inputs,options):
|
|||||||
header=getheader(path,'../'*(len(crumbs)-1),inputs[0][1])
|
header=getheader(path,'../'*(len(crumbs)-1),inputs[0][1])
|
||||||
else:
|
else:
|
||||||
header=getheader(path,'../'*(len(crumbs)-1))
|
header=getheader(path,'../'*(len(crumbs)-1))
|
||||||
print(len(crumbs))
|
print('Depth: '+str(len(crumbs)))
|
||||||
pathlist=getpathlist(path,options)
|
pathlist=getpathlist(path,options)
|
||||||
imagelist=getimagelist(path,options)
|
imagelist=getimagelist(path,options)
|
||||||
filelist=getnonimagelist(path,options)
|
filelist=getnonimagelist(path,options)
|
||||||
print(str(len(pathlist))+' paths')
|
print(str(len(pathlist))+' paths')
|
||||||
print(str(len(imagelist))+' images')
|
print(str(len(imagelist))+' images')
|
||||||
print(str(len(filelist))+' other files')
|
print(str(len(filelist))+' other files')
|
||||||
crumbstring=crumblinks(crumbs)
|
crumbstring=crumblinks(crumbs,options.gallery,options.parent)
|
||||||
if len(pathlist)>0:
|
if len(pathlist)>0:
|
||||||
pathstring=pathlinks(path,pathlist)
|
pathstring=pathlinks(path,pathlist)
|
||||||
pathjs=pathscript(path,pathlist)
|
pathjs=pathscript(path,pathlist)
|
||||||
@@ -396,6 +401,8 @@ def setupoptions():
|
|||||||
help="Name for the root gallery (Default: %(default)s)")
|
help="Name for the root gallery (Default: %(default)s)")
|
||||||
parser.add_argument("-w",type=int,dest="width",default=850,
|
parser.add_argument("-w",type=int,dest="width",default=850,
|
||||||
help="Medium image size (Default: %(default)s)")
|
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='?',
|
parser.add_argument("startpath",type=str,action="store",default=os.path.abspath('.'),nargs='?',
|
||||||
help="Root path of the gallery")
|
help="Root path of the gallery")
|
||||||
options=parser.parse_args()
|
options=parser.parse_args()
|
||||||
|
|||||||
Reference in New Issue
Block a user