def generatePhoto(self, photo, photo_type): fn = self.getAlbumFile(photo.album, self.getPhotoFile(photo, photo_type)) f = File(fn) pre, post = self.ptmpl.body(photo, photo_type) f.write(pre, post) pre, post = self.ptmpl.title(photo, photo_type) f.write(pre) f.write(post) pre, post = self.ptmpl.description(photo, photo_type) f.write(pre) f.write(post) self.processPhotoNavigation(f, photo, photo_type) pre, post = self.ptmpl.photo(photo, photo_type) f.write(pre) f.write(post) f.close() log.info('generated photo page %s.%s' % (photo.name, photo_type))
def generateAlbum(self, album, parent): self.fm.mkdir(self.getDir(album)) fn = self.getAlbumFile(album, 'index.xhtml') f = File(fn) pre, post = self.atmpl.body(album) f.write(pre, post) pre, post = self.atmpl.title(album) f.write(pre) f.write(post) if album.description: pre, post = self.atmpl.description(album) f.write(pre) f.write(post) self.processAlbumNavigation(f, album, parent) self.generateSubalbums(f, album) if album.photos: pre, post = self.atmpl.photos(album) f.write(pre, post) for photo in album.photos: pre, post = self.atmpl.photo(photo) f.write(pre) f.write(post) f.close() for subalbum in album.subalbums: self.generateAlbum(subalbum, album) for photo in album.photos: self.generateAlbumPhotos(photo) log.info('generated album %s' % album.dir)
def generateExif(self, photo): photo.exif = self.fm.getExif(photo.filename, self.exif_headers) if photo.exif: exif_fn = self.getPhotoFile(photo, 'exif') f = File(self.getAlbumFile(photo.album, exif_fn)) pre, post = self.etmpl.body(photo, 'exif') f.write(pre, post) pre, post = self.etmpl.title(photo, 'exif') f.write(pre) f.write(post) pre, post = self.etmpl.photo(photo, 'exif') f.write(pre) f.write(post) f.close() log.info('generated exif page for photo %s' % photo.name) else: log.error('photo %s does not contain exif' % photo.name)
def generate(self): if not os.path.exists(self.outdir): os.makedirs(self.outdir) f = File('%s/index.xhtml' % self.outdir) pre, post = self.gtmpl.body(self.gallery) f.write(pre, post) pre, post = self.gtmpl.title(self.gallery) f.write(pre) f.write(post) pre, post = self.gtmpl.albums(self.gallery) f.write(pre, post) def gen_index(context): for album in context.subalbums: pre, post = self.gtmpl.album(album) f.write(pre) gen_index(album) f.write(post) gen_index(self.gallery) f.close() log.info('generated index page') for album in self.gallery.subalbums: self.generateAlbum(album, self.gallery)