Beispiel #1
0
def home():
    """Index page - without renderer"""
    return render(
        doctype("html"),
        e.html()(
            e.head()(e.title()("htmldoom rendering framework demo")),
            e.body()(
                e.h1()("Home page"),
                e.a(href="/jinja2")("Jinja2"),
                e.br(),
                e.a(href="/htmldoom")("htmldoom"),
            ),
        ),
    )
Beispiel #2
0
def home(request):
    """Index page - without renderer"""
    return Response(
        render(
            doctype("html"),
            e.html()(
                e.head()(e.title()("Pyramid template engine demo")),
                e.body()(
                    e.h1()("Home page"),
                    e.a(href="/jinja2")("Jinja2"),
                    e.br(),
                    e.a(href="/htmldoom")("htmldoom"),
                ),
            ),
        ))
Beispiel #3
0
from htmldoom import elements as e
from htmldoom import renders

from .layout import render_document


@renders(e.body()(
    e.h3()("{contents}"),
    e.a(href="/")("Home"),
    e.br(),
    e.a(href="/jinja2")("jinja2"),
))
def render_body(data):
    return {"contents": data["data"]}


def render(data):
    return render_document(data, body_renderer=render_body)
Beispiel #4
0
 e.body()(e.center()(e.table(
     id_="hnmain",
     border="0",
     cellpadding="0",
     cellspacing="0",
     width="85%",
     bgcolor="#f6f6ef",
 )(
     e.tr()(e.td(bgcolor="#ff6600")(e.table(
         border="0",
         cellpadding="0",
         cellspacing="0",
         width="100%",
         style="padding:2px",
     )(e.tr()(
         e.td(style="width:18px;padding-right:4px")(
             e.a(href="https://news.ycombinator.com")(e.img(
                 src="y18.gif",
                 width="18",
                 height="18",
                 style="border:1px white solid;",
             ))),
         e.td(style="line-height:12pt; height:10px;")(
             e.span(class_="pagetop")(
                 e.b(class_="hnname")(e.a(href="news")("Hacker News ")),
                 e.a(href="newest")("new"),
                 " | ",
                 e.a(href="front")("past"),
                 " | ",
                 e.a(href="newcomments")("comments"),
                 " | ",
                 e.a(href="ask")("ask"),
                 " | ",
                 e.a(href="show")("show"),
                 " | ",
                 e.a(href="jobs")("jobs"),
                 " | ",
                 e.a(href="submit")("submit"),
             )),
         e.td(style="text-align:right;padding-right:4px;")(e.span(
             class_="pagetop")(e.a(href="login?goto=news")("login"))),
     )))),
     e.tr("title", id_="pagespace", style="height:10px"),
     e.tr()(e.td()(e.table(
         border="0",
         cellpadding="0",
         cellspacing="0",
         class_="itemlist",
     )(
         "{newslist}",
         e.tr(class_="morespace", style="height:10px"),
         e.tr()(
             e.td(colspan="2"),
             e.td(class_="title")(e.a(
                 href="news?p=2",
                 class_="morelink",
                 rel="next",
             )("More")),
         ),
     ))),
     e.tr()(e.td()(
         e.img(src="s.gif", height="10", width="0"),
         e.table(width="100%", cellspacing="0",
                 cellpadding="1")(e.tr()(e.td(bgcolor="#ff6600"))),
         e.br(),
         e.center()(e.a(
             href="https://www.startupschool.org"
         )(" Registration is open for Startup School 2019. Classes start July 22nd. "
           )),
         e.br(),
         e.center()(
             e.span(class_="yclinks")(
                 e.a(href="newsguidelines.html")("Guidelines"),
                 " | ",
                 e.a(href="newsfaq.html")("FAQ"),
                 " | ",
                 e.a(href="mailto:[email protected]")("Support"),
                 " | ",
                 e.a(href="https://github.com/HackerNews/API")("API"),
                 " | ",
                 e.a(href="security.html")("Security"),
                 " | ",
                 e.a(href="lists")("Lists"),
                 " | ",
                 e.a(href="bookmarklet.html",
                     rel="nofollow")("Bookmarklet"),
                 " | ",
                 e.a(href="http://www.ycombinator.com/legal/")("Legal"),
                 " | ",
                 e.a(href="http://www.ycombinator.com/apply/")(
                     "Apply to YC"),
                 " | ",
                 e.a(href="mailto:[email protected]")("Contact"),
             ),
             e.br(),
             e.br(),
             e.form(action="//hn.algolia.com/", method="get")(
                 "Search: ",
                 e.input_(
                     "value",
                     type_="text",
                     name="q",
                     size="17",
                     autocorrect="off",
                     spellcheck="false",
                     autocapitalize="off",
                     autocomplete="false",
                 ),
             ),
         ),
     )),
 ))),
Beispiel #5
0
          if(typeof gdprCookieNotice !== 'undefined') {
            gdprCookieNotice({
              statement: 'https://niteo.co/legal/cookies',
              analytics: ['_gat', '_ga', '_gid', '_gat_gtag_UA_116005149_1'],
              providers: {
                essential: "Cloudflare (security)",
                analytics: "Google Analytics",
              }
            });
          }
        });
        """),
)


@renders(e.body()("{contents}"))
def render_body(data):
    return {"contents": contents}


def render(data):
    return render_document(data=data, body_renderer=render_body)


if __name__ == "__main__":
    print(
        render({
            "doctitle":
            "Niteo - Empowering small businesses online since '07"
        }))