string cutting for unicode

This commit is contained in:
ville rantanen
2018-07-31 16:43:16 +03:00
parent 96362b3c82
commit 8d6237bf3c
2 changed files with 17 additions and 4 deletions

View File

@@ -27,7 +27,7 @@ from datetime import datetime
# (c) ville.q.rantanen@gmail.com # (c) ville.q.rantanen@gmail.com
__version__='2.20161005' __version__='2.20180731'
FILECONFIG=".config" FILECONFIG=".config"
FILEDESC="descriptions.csv" FILEDESC="descriptions.csv"
@@ -209,7 +209,13 @@ def pathlinks(path,list):
imgstr='<span class="pathbox" style="background-image:url(\''+urllib.quote(p)+'/.tn/'+urllib.quote(imglist[0])+'.jpg\');">' imgstr='<span class="pathbox" style="background-image:url(\''+urllib.quote(p)+'/.tn/'+urllib.quote(imglist[0])+'.jpg\');">'
else: else:
imgstr='<span class="pathbox">' imgstr='<span class="pathbox">'
pathstr+='<a title="'+unicode(p,encoding="utf8").encode('ascii', 'xmlcharrefreplace')+'" href="'+urllib.quote(p)+'/index.html">'+imgstr+'<span class="pathlink"><span class="pathlinktext">'+unicode(nice,encoding="utf8").encode('ascii', 'xmlcharrefreplace')+' ('+nsum+')</span></span></span></a>'; pathstr += '<a title="%s" href="%s/index.html">%s<span class="pathlink"><span class="pathlinktext">%s (%s)</span></span></span></a>'%(
unicode(p,encoding="utf8").encode('ascii', 'xmlcharrefreplace'),
urllib.quote(p),
imgstr,
nice.encode('ascii', 'xmlcharrefreplace'),
nsum
)
pathstr+='</script>' pathstr+='</script>'
pathstr+='</div>' pathstr+='</div>'
return pathstr return pathstr
@@ -251,7 +257,13 @@ def imagelinks(path,list):
except: except:
desc=doublequotes.sub('',filter(lambda x: x in string.printable, descriptions[n]).encode('ascii', 'xmlcharrefreplace')) desc=doublequotes.sub('',filter(lambda x: x in string.printable, descriptions[n]).encode('ascii', 'xmlcharrefreplace'))
strout+='<span class="imagebox thumbbox" id="n'+str(n)+'"><a href="'+urllib.quote(i)+'"><img class="thumbimage" "title="'+desc+'" src=".tn/'+urllib.quote(i)+'.jpg"><br/>'+unicode(nice,encoding="utf8").encode('ascii', 'xmlcharrefreplace')+'</a></span>' strout += '<span class="imagebox thumbbox" id="n%d"><a href="%s"><img class="thumbimage" "title="%s" src=".tn/%s.jpg"><br/>%s</a></span>'%(
n,
urllib.quote(i),
desc,
urllib.quote(i),
nice.encode('ascii', 'xmlcharrefreplace')
)
n+=1 n+=1
strout+='</noscript></div>' strout+='</noscript></div>'
return strout return strout
@@ -397,6 +409,7 @@ def crumblinks(crumbs,title,parent):
def nicestring(s): def nicestring(s):
''' Returns a nice version of a long string ''' ''' Returns a nice version of a long string '''
s = unicode(s, encoding = "utf8")
if len(s)<20: if len(s)<20:
return s return s
s=s.replace("_"," ") s=s.replace("_"," ")

View File

@@ -7,7 +7,7 @@ setup(
'scripts/Qalbum-descriptor'], 'scripts/Qalbum-descriptor'],
package_data={'':['lib/*']}, package_data={'':['lib/*']},
include_package_data=True, include_package_data=True,
version = '2.20161005', version = '2.20180731',
description = 'A tool to create a web gallery from a folder structure of images / other files.', description = 'A tool to create a web gallery from a folder structure of images / other files.',
author = 'Ville Rantanen', author = 'Ville Rantanen',
author_email = 'ville.q.rantanen@gmail.com', author_email = 'ville.q.rantanen@gmail.com',