--- a/degal/commands/main.py Thu Jun 11 00:36:33 2009 +0300
+++ b/degal/commands/main.py Thu Jun 11 00:37:01 2009 +0300
@@ -5,7 +5,7 @@
"""
Render the thumbnails and .html for one image
"""
-
+
# log image path
ctx.log_info("%s", image)
@@ -17,15 +17,12 @@
# write output
tpl.render_file(image.html)
-def render_folder (ctx, folder) :
+def render_folder_page (ctx, folder) :
"""
- Render the .html output for one folder, recursively
+ Render the .html output for one folder
"""
- # log folder path
- ctx.log_info("%s", folder)
-
- # render folder index
+ # render each page separately
for page in xrange(folder.page_count) :
# output .html page
html_file = folder.html_file(page)
@@ -37,10 +34,33 @@
# write output
tpl.render_file(html_file)
+
- # render images
- for image in folder.images :
- render_image(ctx, image)
+def render_folder (ctx, folder) :
+ # index images that require updating
+ image_count = len(folder.images)
+ new_images = list(folder.index_images(for_update=(not ctx.config.force_update)))
+
+ if new_images or ctx.config.force_update:
+ # update folder index
+ render_folder_page(ctx, folder)
+
+ ctx.log_info("%s - render %d/%d images", folder, len(new_images), image_count)
+
+ # update images
+ for image in new_images :
+ # update thumbs
+ image.update()
+
+ # render output
+ render_image(ctx, image)
+
+ else :
+ ctx.log_info("%s - up to date", folder)
+
+ # index subfolders
+ for subfolder in folder.subfolders :
+ render_folder(ctx, subfolder)
@command
def main (ctx) :
--- a/degal/config.py Thu Jun 11 00:36:33 2009 +0300
+++ b/degal/config.py Thu Jun 11 00:37:01 2009 +0300
@@ -15,6 +15,9 @@
# the path to the gallery
gallery_path = "."
+
+ # force-update items
+ force_update = False
# minimum logging level
log_level = logging.INFO
@@ -64,8 +67,3 @@
return file.matchext(self.image_exts)
- # XXX: move elsewhere?
- def get_renderer (self) :
- import render
-
- return render.RenderMachine(self)
--- a/degal/main.py Thu Jun 11 00:36:33 2009 +0300
+++ b/degal/main.py Thu Jun 11 00:37:01 2009 +0300
@@ -15,8 +15,14 @@
parser = OptionParser(prog=command_name)
# define options
- parser.add_option('-G', "--gallery-path", dest='gallery_path', help="Use DIR as the Gallery path [default: CWD]", metavar='DIR', default=None)
- parser.add_option('-R', "--read-only", dest='read_only', help="Do not attempt to modify the gallery", action="store_true", default=False)
+ parser.add_option('-G', "--gallery-path", metavar='DIR', dest='gallery_path', default=None,
+ help="Use DIR as the Gallery path [default: CWD]")
+
+ parser.add_option('-R', "--read-only", dest='read_only', action="store_true", default=False,
+ help="Do not attempt to modify the gallery")
+
+ parser.add_option('-F', "--force-update", dest='force_update', action="store_true", default=False,
+ help="Force updates, even for fresh items")
return parser
@@ -35,6 +41,9 @@
if options.read_only :
config.read_only = True
+ if options.force_update :
+ config.force_update = True
+
# XXX: load config file(s)
return config