emin

changeset 26
79167c58c3a5
parent 25
fb778c6b6d4b
child 28
1088bb11189f
equal deleted inserted replaced
25:fb778c6b6d4b 26:79167c58c3a5
23 named after a pretty crappy artist. And, thankfully, e-m-i-n is not many 23 named after a pretty crappy artist. And, thankfully, e-m-i-n is not many
24 characters to type. 24 characters to type.
25 25
26 TODO: 26 TODO:
27 * Make Cheetah templating optional, or use Genshi/Jinja/Mako? 27 * Make Cheetah templating optional, or use Genshi/Jinja/Mako?
28 * Clean up image filenames to avoid/minimise duplicate extensions
28 * Try to validate the HTML output 29 * Try to validate the HTML output
29 * Add all on one page option 30 * Add all on one page option
30 * Resize option 31 * Resize option
31 * Rename option 32 * Rename option
32 * Crop-to-thumb option 33 * Crop-to-thumb option
42 43
43 44
44 import logging 45 import logging
45 from optparse import OptionParser, OptionGroup 46 from optparse import OptionParser, OptionGroup
46 parser = OptionParser(usage=__doc__, version=__version__) 47 parser = OptionParser(usage=__doc__, version=__version__)
47 parser.add_option("-t", "--title", dest="TITLE", default="", 48 parser.add_option("-t", "--title", dest="TITLE", default=None,
48 help="title of this gallery") 49 help="title of this gallery")
49 parser.add_option("--template", dest="TEMPLATE", default=None, 50 parser.add_option("--template", dest="TEMPLATE", default=None,
50 help="specify the template file to be used for the index pages") 51 help="specify the template file to be used for the index pages")
51 parser.add_option("--zipfile", dest="ZIPFILE", default=None, 52 parser.add_option("--zipfile", dest="ZIPFILE", default=None,
52 help="name of zip archive file. Default is based on the title.") 53 help="name of zip archive file. Default is based on the title.")
117 def safeencode(s): 118 def safeencode(s):
118 """Encode a string for use as a filename.""" 119 """Encode a string for use as a filename."""
119 newstr = s.replace(" ", "-").replace(",", "").replace("/", "").replace(".", "") 120 newstr = s.replace(" ", "-").replace(",", "").replace("/", "").replace(".", "")
120 return newstr 121 return newstr
121 122
123 ## Better title autodetection
124 if not opts.TITLE:
125 opts.TITLE = os.path.basename(os.path.abspath(opts.SRCDIR))
122 126
123 logging.debug("Title: %s" % opts.TITLE) 127 logging.debug("Title: %s" % opts.TITLE)
124 logging.debug("Thumb height: %d" % opts.THUMB_HEIGHT) 128 logging.debug("Thumb height: %d" % opts.THUMB_HEIGHT)
125 129
126 130
452 ## Choose and open page file 456 ## Choose and open page file
453 PAGEFILE = getPageFilename(PAGENUM) 457 PAGEFILE = getPageFilename(PAGENUM)
454 PAGEPATH = os.path.join(opts.OUTDIR, PAGEFILE) 458 PAGEPATH = os.path.join(opts.OUTDIR, PAGEFILE)
455 459
456 ## Write the title 460 ## Write the title
457 PAGETITLE = opts.TITLE or os.path.basename(opts.SRCDIR) 461 PAGETITLE = opts.TITLE
458 462
459 ## Write the linked page list 463 ## Write the linked page list
460 LINKSTR = mkPageLinkStr(PAGENUM) 464 LINKSTR = mkPageLinkStr(PAGENUM)
461 465
462 ## Work out the picture offsets for this page 466 ## Work out the picture offsets for this page

mercurial