From 025b868a916db4df391e6db933be6c9ac41d9180 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 18 Feb 2013 00:33:47 +0100 Subject: [PATCH] Change "representative" to "thumbnail". --- docs/index.rst | 4 ++-- sigal/gallery.py | 22 ++++++++++------------ sigal/writer.py | 4 ++-- tests/sample/dir1/index.md | 2 +- tests/test_gallery.py | 10 +++++----- 5 files changed, 20 insertions(+), 22 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index c7569ed..19c7fb8 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -116,12 +116,12 @@ named ``index.md`` : :: Title: Another example gallery - Representative: test2.jpg + Thumbnail: test2.jpg And a *cool* description. If this file does not exist the directory's name is used for the title, and -the first image of the directory is used as representative. +the first image of the directory is used as thumbnail. Changelog diff --git a/sigal/gallery.py b/sigal/gallery.py index 0250d69..c2a3fb5 100644 --- a/sigal/gallery.py +++ b/sigal/gallery.py @@ -74,21 +74,19 @@ class PathsDb(object): path_noim = [path for path in self.db['paths_list'] if not self.db[path]['img'] and path != '.'] - # directories with images: find the representative + # directories with images: find the thumbnail if it is not set for path in path_im: - alb_thumb = self.db[path].setdefault('representative', '') + alb_thumb = self.db[path].setdefault('thumbnail', '') if (not alb_thumb) or \ (not os.path.isfile(join(path, alb_thumb))): - alb_thumb = self.find_representative(path) - self.db[path]['representative'] = alb_thumb + self.db[path]['thumbnail'] = self.get_thumbnail(path) # directories without images. Start with the deepest ones. for path in reversed(sorted(path_noim, key=lambda x: x.count('/'))): if self.db[path]['subdir']: - # use the representative of their sub-directories + # use the thumbnail of their sub-directories subdir = self.db[path]['subdir'][0] - subrepr = self.db[subdir]['representative'] - self.db[path]['representative'] = subrepr + self.db[path]['thumbnail'] = self.db[subdir]['thumbnail'] else: # else remove all info about this directory self.logger.info("Directory '%s' is empty", path) @@ -98,8 +96,8 @@ class PathsDb(object): parent = os.path.normpath(join(path, '..')) self.db[parent]['subdir'].remove(path) - def find_representative(self, path): - "Find the representative image for a given path" + def get_thumbnail(self, path): + "Find the thumbnail image for a given path" for f in self.db[path]['img']: # find and return the first landscape image @@ -216,7 +214,7 @@ def get_metadata(path): """ Get album metadata from DESCRIPTION_FILE: - title - - representative image + - thumbnail image - description """ @@ -228,7 +226,7 @@ def get_metadata(path): 'title': os.path.basename(path).replace('_', ' ') .replace('-', ' ').capitalize(), 'description': '', - 'representative': '' + 'thumbnail': '' } else: md = markdown.Markdown(extensions=['meta']) @@ -241,7 +239,7 @@ def get_metadata(path): meta = { 'title': md.Meta.get('title', [''])[0], 'description': html, - 'representative': md.Meta.get('representative', [''])[0] + 'thumbnail': md.Meta.get('thumbnail', [''])[0] } return meta diff --git a/sigal/writer.py b/sigal/writer.py index 50be438..3619303 100644 --- a/sigal/writer.py +++ b/sigal/writer.py @@ -141,10 +141,10 @@ class Writer(object): for d in paths[relpath]['subdir']: dpath = os.path.normpath(os.path.join(relpath, d)) - alb_thumb = paths[dpath]['representative'] + alb_thumb = paths[dpath]['thumbnail'] thumb_name = get_thumb(self.settings, alb_thumb) thumb_path = os.path.join(self.output_dir, dpath, thumb_name) - self.logger.debug("Representative path : %s", thumb_path) + self.logger.debug("Thumbnail path : %s", thumb_path) # generate the thumbnail if it is missing (if # settings['make_thumbs'] is False) diff --git a/tests/sample/dir1/index.md b/tests/sample/dir1/index.md index d80b4bc..a449c9a 100644 --- a/tests/sample/dir1/index.md +++ b/tests/sample/dir1/index.md @@ -1,5 +1,5 @@ Title: An example gallery -Representative: test1.jpg +Thumbnail: test1.jpg ## Hello world ! diff --git a/tests/test_gallery.py b/tests/test_gallery.py index 18f0704..b55c71b 100644 --- a/tests/test_gallery.py +++ b/tests/test_gallery.py @@ -41,12 +41,12 @@ class TestPaths(unittest.TestCase): self.assertItemsEqual(paths['.']['subdir'], ['dir1', 'dir2']) self.assertItemsEqual(paths['dir1']['img'], ['test1.jpg', 'test2.jpg']) - self.assertEqual(paths['dir1']['representative'], u'test1.jpg') + self.assertEqual(paths['dir1']['thumbnail'], u'test1.jpg') self.assertEqual(paths['dir1']['title'], u'An example gallery') - def test_find_representative(self): - self.assertEqual(self.paths.find_representative('dir1'), u'test1.jpg') - self.assertEqual(self.paths.find_representative('dir1/test'), + def test_get_thumbnail(self): + self.assertEqual(self.paths.get_thumbnail('dir1'), u'test1.jpg') + self.assertEqual(self.paths.get_thumbnail('dir1/test'), u'test2.jpg') @@ -56,7 +56,7 @@ class TestMetadata(unittest.TestCase): def test_get_metadata(self): m = get_metadata(os.path.join(SAMPLE_DIR, 'dir1')) self.assertEqual(m['title'], 'An example gallery') - self.assertEqual(m['representative'], 'test1.jpg') + self.assertEqual(m['thumbnail'], 'test1.jpg') m = get_metadata(os.path.join(SAMPLE_DIR, 'dir1', 'test')) self.assertEqual(m['title'], 'Test')