コード例 #1
0
def mk_package_contents(config):
    packages = Album(config, False)
    build_dir = config.get('album', 'build_directory')
    album_dir = config.get('album', 'album_directory')
    template_dir = "{}/templates".format(build_dir)

    for pkgid in packages.keys():
        package = Package(config, pkgid, build=False)

        env = Environment(loader=PackageLoader("photo_album",
                                               package_path="templates"),
                          autoescape=select_autoescape(['html']))

        template_vars = {
            "pkgid": pkgid,
            "photographs": package,
            "package": packages[pkgid],
        }

        detail_template = env.get_template('detail.html')
        gallery_template = env.get_template('gallery.html')

        logger.info("Writing package {}/detail.html".format(pkgid))
        with open(os.path.join(album_dir, pkgid, 'detail.html'), 'w') as f:
            f.write(detail_template.render(template_vars))

        logger.info("Writing package {}/gallery.html".format(pkgid))
        with open(os.path.join(album_dir, pkgid, 'gallery.html'), 'w') as f:
            f.write(gallery_template.render(template_vars))
コード例 #2
0
def mk_gallery_tiff_album(config, build=True):
    """
    Process all packages in album from work or album directory.
    """
    work_dir = get_work_dir(config, build)
    packages = Album(config, build)

    for pkgid in packages.keys():
        mk_gallery_tiff(config, pkgid, build)
コード例 #3
0
def mk_db_template_album(config, build=True):
    """
    Make DB templates for all packages in scope.
    """
    work_dir = get_work_dir(config, build)
    packages = Album(config, build)

    for pkgid in packages.keys():
        mk_db_template(config, pkgid, build)
コード例 #4
0
def get_package(config, pkgid, build=True):
    """
    Get a single package.
    """
    work_dir = get_work_dir(config, build)
    packages = Album(config, build)
    return packages[pkgid]
コード例 #5
0
def mk_archive_contents(config):
    album = Album(config, False)
    build_dir = config.get('album', 'build_directory')
    album_dir = config.get('album', 'album_directory')
    template_dir = "{}/templates".format(build_dir)
    env = Environment(loader=PackageLoader("photo_album",
                                           package_path="templates"),
                      autoescape=select_autoescape(['html']))

    template_vars = {
        "title": album.title,
        "description": album.description,
        "packages": album
    }

    contents_template = env.get_template('contents.html')
    faq_template = env.get_template('faq.html')

    logger.info("Writing {}/contents.html".format(album_dir))
    with open(os.path.join(album_dir, 'contents.html'), 'w') as f:
        f.write(contents_template.render(template_vars))

    logger.info("Writing {}/faq.html".format(album_dir))
    with open(os.path.join(album_dir, 'faq.html'), 'w') as f:
        f.write(faq_template.render(template_vars))