Permalink
Browse files

Thumbnails on gallery's index

New settings to allow thumbnails in gallery's index.
  • Loading branch information...
humitos committed Jun 1, 2015
1 parent 4108cde commit afc8a937984dd37d999c83814d5e917153eb9732
View
@@ -645,6 +645,21 @@ COMMENT_SYSTEM_ID = ${COMMENT_SYSTEM_ID}
# Enable comments on picture gallery pages?
# COMMENTS_IN_GALLERIES = False
# Use a thumbnail (defined by ".. previewimage:") in list of galleries
# for each gallery
GALLERIES_USE_THUMBNAIL = True
# Columns of thumbnails list in galleries index
GALLERIES_COLUMNS = 3
# Image to use as thumbnail for those galleries that doesn't have one
# None: show a grey square
# '/url/to/file': show the image in that url
GALLERIES_DEFAULT_THUMBNAIL = None
# HTML title for /GALLERY_FOLDERS/index.html (translatable)
GALLERY_INDEX_TITLE = "galleries"
# What file should be used for directory indexes?
# Defaults to index.html
# Common other alternatives: default.html for IIS, index.php
@@ -15,11 +15,42 @@
</p>
%endif
%if folders:
<ul>
% for folder, ftitle in folders:
<li><a href="${folder}"><i class="icon-folder-open"></i>&nbsp;${ftitle}</a></li>
% if galleries_use_thumbnail:
% for folder, ftitle, fpost in folders:
% if loop.index % galleries_columns == 0:
<div class="row">
% endif
<div class="span4">
<div class="thumbnail">
<a href="${folder}">
% if fpost and getattr(fpost, 'previewimage', None):
<img src="${folder}${fpost.previewimage}" alt="${ftitle}">
% elif galleries_default_thumbnail:
<img src="${galleries_default_thumbnail}" alt="${ftitle}">
% else:
<div style="height: 250px; background-color: #eee;"></div>
% endif
</a>
<div class="caption">
<h3>${ftitle}</h3>
% if fpost and fpost.description():
<p>${fpost.description()}</p>
% endif
</div>
</div>
</div>
% if loop.index % galleries_columns == (galleries_columns - 1):
</div>
% endif
% endfor
</ul>
% else:
<ul>
% for folder, ftitle in folders:
<li><a href="${folder}"><i class="icon-folder-open"></i>&nbsp;${ftitle}</a></li>
% endfor
</ul>
% endif
%endif
<div id="gallery_container"></div>
@@ -15,11 +15,42 @@
</p>
%endif
%if folders:
<ul>
% for folder, ftitle in folders:
<li><a href="${folder}"><i class="glyphicon glyphicon-folder-open"></i>&nbsp;${ftitle}</a></li>
% if galleries_use_thumbnail:
% for folder, ftitle, fpost in folders:
% if loop.index % galleries_columns == 0:
<div class="row">
% endif
<div class="col-sm-6 col-md-4">
<div class="thumbnail">
<a href="${folder}">
% if fpost and getattr(fpost, 'previewimage', None):
<img src="${folder}${fpost.previewimage}" alt="${ftitle}">
% elif galleries_default_thumbnail:
<img src="${galleries_default_thumbnail}" alt="${ftitle}">
% else:
<div style="height: 250px; background-color: #eee;"></div>
% endif
</a>
<div class="caption">
<h3>${ftitle}</h3>
% if fpost and fpost.description():
<p>${fpost.description()}</p>
% endif
</div>
</div>
</div>
% if loop.index % galleries_columns == (galleries_columns - 1):
</div>
% endif
% endfor
</ul>
% else:
<ul>
% for folder, ftitle in folders:
<li><a href="${folder}"><i class="glyphicon glyphicon-folder-open"></i>&nbsp;${ftitle}</a></li>
% endfor
</ul>
% endif
%endif
<div id="gallery_container"></div>
@@ -87,6 +87,10 @@ def set_site(self, site):
'tzinfo': site.tzinfo,
'comments_in_galleries': site.config['COMMENTS_IN_GALLERIES'],
'generate_rss': site.config['GENERATE_RSS'],
'gallery_index_title': site.config['GALLERY_INDEX_TITLE'],
'galleries_use_thumbnail': site.config['GALLERIES_USE_THUMBNAIL'],
'galleries_columns': site.config['GALLERIES_COLUMNS'],
'galleries_default_thumbnail': site.config['GALLERIES_DEFAULT_THUMBNAIL'],
}
# Verify that no folder in GALLERY_FOLDERS appears twice
@@ -208,7 +212,9 @@ def gen_tasks(self):
if post:
context["title"] = post.title(lang)
else:
context["title"] = os.path.basename(gallery)
# TODO: make this translatable
context["title"] = self.kw['gallery_index_title']
context["description"] = None
image_name_list = [os.path.basename(p) for p in image_list]
@@ -237,14 +243,21 @@ def gen_tasks(self):
ft = folder
if not folder.endswith('/'):
folder += '/'
folders.append((folder, ft))
if self.kw['galleries_use_thumbnail']:
folders.append((folder, ft, fpost))
else:
folders.append((folder, ft))
context["folders"] = natsort.natsorted(
folders, alg=natsort.ns.F | natsort.ns.IC)
context["crumbs"] = crumbs
context["permalink"] = self.site.link("gallery", gallery, lang)
context["enable_comments"] = self.kw['comments_in_galleries']
context["thumbnail_size"] = self.kw["thumbnail_size"]
context["galleries_use_thumbnail"] = self.kw["galleries_use_thumbnail"]
context["galleries_columns"] = self.kw["galleries_columns"]
context["galleries_default_thumbnail"] = self.kw["galleries_default_thumbnail"]
context["thumbnail_size"] = self.kw["thumbnail_size"]
if post:
yield {

0 comments on commit afc8a93

Please sign in to comment.