From 194e6e363474241950b642b18b030f00aa526a0e Mon Sep 17 00:00:00 2001 From: ville rantanen Date: Sun, 15 Apr 2012 22:41:09 +0300 Subject: [PATCH] Added info.txt feature, a predefined snippet to be added on each page --- Qalbum.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Qalbum.py b/Qalbum.py index d39e5d2..14a3521 100755 --- a/Qalbum.py +++ b/Qalbum.py @@ -28,7 +28,7 @@ from datetime import datetime __version__='1.7' -webfilesearch=re.compile('.*index.html$|.*gallerystyle.css$|.*galleryscript.js$|.*descriptions.csv$|\..*',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) vectorsearch=re.compile('.*\.svg$|.*\.pdf$',re.I) #gifsearch=re.compile('.*gif$',re.I) @@ -285,6 +285,14 @@ def getdescriptions(path,list): desc[i]=stripquotes.sub('',row[1]) return desc +def getinfo(path): + ''' Read info.txt file and returns the content. + Missing info file returns empty string. ''' + if not os.path.exists(os.path.join(path,'info.txt')): + return '' + reader = open(os.path.join(path,'info.txt'),'r') + return unicode(reader.read(),encoding="utf8").encode('ascii','xmlcharrefreplace') + def crumblinks(crumbs): ''' Create the HTML string for crumb trails ''' strout='
' @@ -358,7 +366,7 @@ def traverse(path,crumbs,inputs,options): f.write(filejs) f.write(crumbstring) f.write(pathstring) - f.write('
') + f.write('
'+getinfo(path)+'
') f.write('
') f.write(imagestring) f.write(filestring)