including HTML as images. creates an IFRAME for them..

This commit is contained in:
ville rantanen
2012-06-28 12:58:43 +03:00
parent 0ad99353f2
commit 7417e76587
2 changed files with 36 additions and 5 deletions

View File

@@ -31,6 +31,7 @@ __version__='1.10'
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)
vectorsearch=re.compile('.*\.svg$|.*\.pdf$',re.I) vectorsearch=re.compile('.*\.svg$|.*\.pdf$',re.I)
nonconvertiblesearch=re.compile('.*\.html$|.*\.htm$|.*\.php$',re.I)
#gifsearch=re.compile('.*gif$',re.I) #gifsearch=re.compile('.*gif$',re.I)
excludepaths=re.compile('_med|_tn|\..*') excludepaths=re.compile('_med|_tn|\..*')
doublequotes=re.compile('"') doublequotes=re.compile('"')
@@ -74,6 +75,22 @@ def getimagelist(path,options=False):
imgs.sort() imgs.sort()
return imgs return imgs
def getnonconvertiblelist(path,options=False):
''' Returns a list of files matching the nonconvertible regex '''
list=os.listdir(path)
files=[]
for f in list:
if (nonconvertiblesearch.match(f)) and (os.path.isfile(os.path.join(path,f))) and not (webfilesearch.match(f)):
files.append(f)
if options:
if options.timesort:
files.sort(key=lambda f: os.path.getmtime(os.path.join(path, f)),reverse=options.reverse)
else:
files.sort(reverse=options.reverse)
else:
files.sort()
return files
def getfiletimes(path,list): def getfiletimes(path,list):
''' Returns a list of modification times ''' ''' Returns a list of modification times '''
times=[] times=[]
@@ -343,6 +360,8 @@ def traverse(path,crumbs,inputs,options):
print('Depth: '+str(len(crumbs))) print('Depth: '+str(len(crumbs)))
pathlist=getpathlist(path,options) pathlist=getpathlist(path,options)
imagelist=getimagelist(path,options) imagelist=getimagelist(path,options)
createthumbs(path,imagelist,options)
imagelist.extend(getnonconvertiblelist(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')
@@ -378,7 +397,7 @@ def traverse(path,crumbs,inputs,options):
f.write('<div id="listcontainer"></div>') f.write('<div id="listcontainer"></div>')
f.write(getfooter()) f.write(getfooter())
f.close() f.close()
createthumbs(path,imagelist,options)
for p in pathlist: for p in pathlist:
nextcrumbs=[i for i in crumbs] nextcrumbs=[i for i in crumbs]
nextcrumbs.append(os.path.join(path,p)) nextcrumbs.append(os.path.join(path,p))

View File

@@ -984,14 +984,22 @@ function showbigimage(i) {
if (fullscreen) { height=height+200; } if (fullscreen) { height=height+200; }
if (originals) { mediumstr=encodeURIComponent(imagelist[i]); } if (originals) { mediumstr=encodeURIComponent(imagelist[i]); }
else { mediumstr='_med/med_'+encodeURIComponent(imagelist[i])+'.jpg'; } else { mediumstr='_med/med_'+encodeURIComponent(imagelist[i])+'.jpg'; }
$('#imagecontainer').html('<div id="imagebig"><a class="linktobig" href="'+encodeURIComponent(imagelist[i])+'" target="_blank">'+ if (isHTML(imagelist[i])) {
$('#imagecontainer').html('<div id="imagebig"><a class="linktobig" href="'+encodeURIComponent(imagelist[i])+'" target="_blank">'+
'<iframe id="imagesingle" src="'+encodeURIComponent(imagelist[i])+'"></a></div>');
$('#imagesingle').css('width',width);
$('#imagesingle').css('height',height);
} else { // is image
$('#imagecontainer').html('<div id="imagebig"><a class="linktobig" href="'+encodeURIComponent(imagelist[i])+'" target="_blank">'+
'<img id="imagesingle" src="'+mediumstr+'"></a></div>'); '<img id="imagesingle" src="'+mediumstr+'"></a></div>');
$('#imagesingle').css('max-width',width); $('#imagesingle').css('max-width',width);
$('#imagesingle').css('max-height',height);
}
$('#imagecontainer').css('height',height); $('#imagecontainer').css('height',height);
$('#imagesingle').css('max-height',height);
$('#desccontainer').html(getProgressEl()+currentlink(i)+imagedesc[i]); $('#desccontainer').html(getProgressEl()+currentlink(i)+imagedesc[i]);
$('#desccontainer').css('display','block'); $('#desccontainer').css('display','block');
if (zoom) { if (zoom & !isHTML(imagelist[i])) {
$(document).ready(function() { $(document).ready(function() {
var options = { var options = {
@@ -1450,6 +1458,10 @@ function getmaxthumbs() {
return Math.floor((document.body.clientWidth-30)/100)-2; return Math.floor((document.body.clientWidth-30)/100)-2;
} }
function isHTML(s) {
return s.match(/html$/i);
}
function hidethumbs() { function hidethumbs() {
// hide all thumbnails (obsolete) // hide all thumbnails (obsolete)
if (notsupported()) { if (notsupported()) {