terom@24: #!/usr/bin/env python2.5 terom@1: # terom@1: # DeGAL - A pretty simple web image gallery terom@1: # Copyright (C) 2007 Tero Marttila terom@1: # http://marttila.de/~terom/degal/ terom@1: # terom@1: # This program is free software; you can redistribute it and/or modify terom@1: # it under the terms of the GNU General Public License as published by terom@1: # the Free Software Foundation; either version 2 of the License, or terom@1: # (at your option) any later version. terom@1: # terom@1: # This program is distributed in the hope that it will be useful, terom@1: # but WITHOUT ANY WARRANTY; without even the implied warranty of terom@1: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terom@1: # GNU General Public License for more details. terom@1: # terom@1: # You should have received a copy of the GNU General Public License terom@1: # along with this program; if not, write to the terom@1: # Free Software Foundation, Inc., terom@1: # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. terom@1: # terom@1: terom@1: import os.path, os terom@12: from optparse import OptionParser terom@1: terom@28: from lib import folder, shorturl, log terom@1: terom@12: def main (dir='.', targets=()) : terom@1: root_filter = {} terom@27: terom@1: for target in targets : terom@1: f = root_filter terom@1: for path_part in target.split('/') : terom@1: if path_part : terom@1: if path_part not in f : terom@1: f[path_part] = {} terom@12: terom@1: f = f[path_part] terom@28: terom@28: log.title("Indexing %s...", dir) terom@12: root = folder.Folder(dir) terom@1: root.index(root_filter) terom@28: log.up() terom@28: terom@28: log.title("Syncing ShortURLs...") terom@12: shorturl.updateDB(root) terom@28: log.up() terom@28: terom@28: log.title("Rendering updated dirs...") terom@1: root.render() terom@28: log.up() terom@1: terom@1: if __name__ == '__main__' : terom@12: parser = OptionParser(usage="usage: %prog [options] ... [target ...]") terom@12: terom@12: parser.add_option("-d", "--dir", dest="dir", help="look for images in DIR and write the HTML there", metavar="DIR", default=".") terom@12: terom@12: options, filter_targets = parser.parse_args() terom@12: terom@12: main(options.dir, filter_targets)