aboutsummaryrefslogtreecommitdiffstats
path: root/nikola/plugins/task/galleries.py
diff options
context:
space:
mode:
authorLibravatarAgustin Henze <tin@sluc.org.ar>2014-10-21 10:33:17 -0300
committerLibravatarAgustin Henze <tin@sluc.org.ar>2014-10-21 10:33:17 -0300
commit2d14c4b384c7000e264674a92b16e010a510ac05 (patch)
tree7676db09f338e46e053170b1c9f7594120b9d434 /nikola/plugins/task/galleries.py
parent2d2e97ac540c94e15ac5eccc7d32f3dfb3eea1bc (diff)
parent5ec02211214350ee558fd9f6bb052264fd24f75e (diff)
Merge tag 'upstream/7.1.0'
Upstream version 7.1.0
Diffstat (limited to 'nikola/plugins/task/galleries.py')
-rw-r--r--nikola/plugins/task/galleries.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/nikola/plugins/task/galleries.py b/nikola/plugins/task/galleries.py
index 366374b..f835444 100644
--- a/nikola/plugins/task/galleries.py
+++ b/nikola/plugins/task/galleries.py
@@ -25,7 +25,7 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import unicode_literals
-import codecs
+import io
import datetime
import glob
import json
@@ -55,6 +55,8 @@ from nikola import utils
from nikola.post import Post
from nikola.utils import req_missing
+_image_size_cache = {}
+
class Galleries(Task):
"""Render image galleries."""
@@ -153,6 +155,9 @@ class Galleries(Task):
# Create index.html for each language
for lang in self.kw['translations']:
+ # save navigation links as dependencies
+ self.kw['navigation_links|{0}'.format(lang)] = self.kw['global_context']['navigation_links'](lang)
+
dst = os.path.join(
self.kw['output_folder'],
self.site.path(
@@ -460,8 +465,11 @@ class Galleries(Task):
photo_array = []
for img, thumb, title in zip(img_list, thumbs, img_titles):
- im = Image.open(thumb)
- w, h = im.size
+ w, h = _image_size_cache.get(thumb, (None, None))
+ if w is None:
+ im = Image.open(thumb)
+ w, h = im.size
+ _image_size_cache[thumb] = w, h
# Thumbs are files in output, we need URLs
photo_array.append({
'url': url_from_path(img),
@@ -515,7 +523,7 @@ class Galleries(Task):
rss_obj.rss_attrs["xmlns:dc"] = "http://purl.org/dc/elements/1.1/"
dst_dir = os.path.dirname(output_path)
utils.makedirs(dst_dir)
- with codecs.open(output_path, "wb+", "utf-8") as rss_file:
+ with io.open(output_path, "w+", encoding="utf-8") as rss_file:
data = rss_obj.to_xml(encoding='utf-8')
if isinstance(data, utils.bytes_str):
data = data.decode('utf-8')