def render_html_category(listing_url_base, category, subcategories):
    """Render the html for a single category of tags.

    @param listing_url_base: The base url.
    @type listing_url_base: str
    @param category: The URL-safe category the subcategory belongs to.
    @type category: str
    @param subcategories: The category's subcategories.
    @type subcategories: iterable over str
    @return: The HTML for a single category
    @rtype: str
    """
    prep = util.prepare_subcategory
    prep_subcats = [prep(listing_url_base, category, x) for x in subcategories]

    temp_vals = tiny_classified.render_common_template_vals()
    temp_vals.update(temp_vals_extra)

    return flask.render_template(
        "public/index_category_inner.html",
        category=category,
        subcategories=prep_subcats,
        listing_url_base=listing_url_base,
        **temp_vals
    )
def index():
    """List all listings tags.

    @return: HTML with the listing tags index.
    @rtype: str
    """
    config = tiny_classified.get_config()

    tags = services.listing_service.index_tags()
    categories = services.listing_service.collect_index_dict(tags, home_only=True)

    url_base = tiny_classified.get_config()["LISTING_URL_BASE"]

    html_categories = [render_html_category(url_base, cat, subcats) for cat, subcats in categories.iteritems()]

    temp_vals = tiny_classified.render_common_template_vals()
    temp_vals.update(temp_vals_extra)

    parent_template = config.get("PARENT_TEMPLATE", "tinyclassified_base.html")

    return flask.render_template(
        "public/public_index_chrome.html",
        base_url=config["BASE_URL"],
        parent_template=parent_template,
        html_categories=html_categories,
        **temp_vals
    )
def confirm_delete():
    config = tiny_classified.get_config()
    temp_vals = tiny_classified.render_common_template_vals()
    temp_vals.update(temp_vals_extra)

    parent_template = config.get("PARENT_TEMPLATE", "tinyclassified_base.html")

    return flask.render_template(
        "public/deleted_confirmation.html", base_url=config["BASE_URL"], parent_template=parent_template, **temp_vals
    )
def index_listings_by_slug(slug):
    """List all listings of a given slug.

    @param slug: The slug for which to list listings.
    @type slug: str
    @return: HTML with the listings belonging the the given slug.
    @rtype: str
    """
    config = tiny_classified.get_config()
    temp_vals = tiny_classified.render_common_template_vals("resources/" + slug)
    temp_vals.update(temp_vals_extra)

    parent_template = config.get("PARENT_TEMPLATE", "tinyclassified_base.html")

    result = index_listings_by_slug_programmatic(slug, parent_template, temp_vals, True)

    if not result:
        flask.abort(404)

    return result
def show_user_ui():
    """Render the chrome (UI constructs) for user / author controls.

    @return: Rendered HTML template with the author control interface.
    @rtype: str
    """
    config = tiny_classified.get_config()
    temp_vals = tiny_classified.render_common_template_vals()
    parent_template = config.get(
        'PARENT_TEMPLATE',
        'tinyclassified_base.html'
    )

    listing_view_templates = flask.render_template(
        'author/listing_view.html',
        parent_template=parent_template,
        base_url=config['BASE_URL']
    )
    contacts_view_templates = flask.render_template(
        'author/contacts_view.html',
        parent_template=parent_template,
        base_url=config['BASE_URL']
    )
    listing_about_templates = flask.render_template(
        'author/listing_about.html',
        parent_template=parent_template,
        base_url=config['BASE_URL']
    )

    return flask.render_template(
        'author/author_chrome.html',
        parent_template=parent_template,
        listing_view_templates=listing_view_templates,
        contacts_view_templates=contacts_view_templates,
        listing_about_templates=listing_about_templates,
        email=flask.session[util.SESS_EMAIL],
        base_url=config['BASE_URL'],
        **temp_vals
    )
def login():
    """Render the login view with login form.

    @return: The HTML login view.
    @rtype: str
    """
    flask.session[util.SESS_EMAIL] = None
    flask.session[util.SESS_IS_ADMIN] = None

    error = flask.session.get(util.SESS_VALIDATION_ERROR, None)
    if error:
        del flask.session[util.SESS_VALIDATION_ERROR]

    show_reset_password = flask.session.get(
        util.SESS_VALIDATION_SHOW_RESET, None)
    if show_reset_password:
        del flask.session[util.SESS_VALIDATION_SHOW_RESET]

    confirm = flask.session.get(util.SESS_CONFIRMATION_MSG, None)
    if confirm:
        del flask.session[util.SESS_CONFIRMATION_MSG]

    config = tiny_classified.get_config()

    temp_vals = tiny_classified.render_common_template_vals()
    parent_template = config.get(
        'PARENT_TEMPLATE',
        'tinyclassified_base.html'
    )

    return flask.render_template(
        'login/login.html',
        error=error,
        confirm=confirm,
        show_reset_password=show_reset_password,
        base_url=config['BASE_URL'],
        parent_template=parent_template,
        **temp_vals
    )