Ejemplo n.º 1
0
def feed():
    if request.method == 'POST':
        if request.form['action'] == 'save':
            model.parse_form(request.form)
        if request.form['action'] == 'fetch':
            model.get_new_data('feed')
    template_data = {"items": model.get_lineup('feed')}
    return render_template('feed.html', data=template_data)
Ejemplo n.º 2
0
def build_template():
    print("Building template for DNN")
    template_data = {"posts": model.get_lineup()}
    html = Environment().from_string(tmpl.core_template).render(data=template_data)
    html_minified = minify_html(html)
    css = fetch.fetch_css()
    script = Template(tmpl.script_template).substitute(css=css, minified=html_minified)
    script_name = f"{cfg.config['project_name']}_{cfg.config['name']}.js"
    save_file_overwrite(script, script_name)
    page = Template(tmpl.page_template).substitute(css=css, core=html)
    page_name = f"{cfg.config['project_name']}_{cfg.config['name']}_preview.html"
    save_file_overwrite(page, page_name)
    pass
Ejemplo n.º 3
0
def lineup():
    # get data
    if request.method == 'POST':
        if request.form['action'] == 'save':
            model.parse_form(request.form)
        if request.form['action'] == 'deploy':
            model.parse_form(request.form)
            data.build_template()
            fetch.put_S3()
        if request.form['action'] == 'fetch':
            model.get_new_data()
    template_data = {"items": model.get_lineup()}
    return render_template('lineup.html', data=template_data, draft_check=False)
Ejemplo n.º 4
0
def build_template(file_name):
    # NEED TO CREATE BUILD DIRECTORY IF IT DOESN'T EXIST!!!
    print("Building template for DNN")
    template_data = {"posts": model.get_lineup(file_name)}
    template_name = file_name + ".html"
    j2_env = Environment(loader=FileSystemLoader('templates'),
                         trim_blocks=True)
    html = j2_env.get_template(template_name).render(data=template_data)
    html_minified = minify_html(html)
    css = fetch.fetch_css()
    script_template = getattr(tmpl, s_file_name)
    script_name = file_name + ".js"
    script = Template(tmpl.script_template).substitute(css=css,
                                                       minified=html_minified)

    save_file_overwrite(script, script_name)
    pass
Ejemplo n.º 5
0
def build_template():
    # NEED TO CREATE BUILD DIRECTORY IF IT DOESN'T EXIST!!!
    print("Building template for DNN")
    template_data = {"posts": model.get_lineup()}
    # using Jinja2 string was fun, but let's get back to includes and other good stuff
    # html = Environment().from_string(tmpl.core_template).render(data=template_data)
    j2_env = Environment(loader=FileSystemLoader('templates'),
                         trim_blocks=True)
    html = j2_env.get_template('ext_core.html').render(
        data=template_data, data_names=cfg.config["candidates"])
    html_minified = minify_html(html)
    css = fetch.fetch_css()
    script = Template(tmpl.script_template).substitute(css=css,
                                                       minified=html_minified)
    script_name = f"{cfg.config['project_name']}_{cfg.config['name']}.js"
    save_file_overwrite(script, script_name)
    pass
Ejemplo n.º 6
0
def preview():
    template_data = {"posts": model.get_lineup()}
    return render_template('preview.html', data=template_data)
Ejemplo n.º 7
0
def preview():
    template_data = {"posts": model.get_lineup()}
    return render_template('preview.html',
                           data=template_data,
                           data_names=cfg.config["candidates"])