示例#1
0
 def extendWithHTML(html, elementToExtend):
     initialSpan = Tag('span')
     elementToExtend.append(initialSpan)
     head, contents, tail = parseAnonymousHTML(html)
     if head is not None:
         initialSpan.tail = head
     if tail is not None:
         contents[-1].tail += tail
     elementToExtend.extend(contents)
 def extendWithHTML(html, elementToExtend):    
     initialSpan = Tag('span')
     elementToExtend.append(initialSpan)
     head, contents, tail = parseAnonymousHTML(html)
     if head is not None:
         initialSpan.tail = head
     if tail is not None:
         contents[-1].tail += tail
     elementToExtend.extend(contents)
示例#3
0
def Html(head=None, body=None, **kwargs):
    html = Tag('html', **kwargs)
    if head is None:
        head = Head()
    if body is None:
        body = Tag('body')
    
    html.append(head)
    html.append(body)
    return html
示例#4
0
def cardTask(title,
             text=None,
             img=None,
             shadowLevel=2,
             indent=1,
             color=None,
             primary=False,
             accent=False,
             spanStyle=''):
    assert shadowLevel in [2, 3, 4, 6, 8, 16]
    out = []
    if img is not None:
        out.append('''<div class="mdl-card__media">
                        <img src="%s" width="173" height="157" border="0" alt="%s" style="padding:10px;">
                    </div>''' % img)

    cls = "mdl-card__title"
    if accent:
        cls += ' mdl-color-text--accent-contrast'
    elif primary:
        cls += ' mdl-color-text--primary-contrast'
    out.append(Div(cls=cls, tagText=title))
    if text is not None:
        cls = "mdl-card__supporting-text"
        if accent:
            cls += ' mdl-color-text--accent-contrast'
        elif primary:
            cls += ' mdl-color-text--primary-contrast'
        div = Div(cls=cls, tagText=text)
        out.append(div)

    if color is not None:
        colorstyle = 'background-color: %s;' % color
    else:
        colorstyle = ''
    cls = 'mdl-card mdl-shadow--%ddp' % (shadowLevel, )
    if accent:
        cls += ' mdl-color--accent'
    elif primary:
        cls += ' mdl-color--primary'
    style = 'width: 90%%;%s' % colorstyle
    div = Div(cls=cls, style=style)
    for o in out:
        div.append(o)
    span = Tag('span',
               style='padding: 20px; margin-left: %dpx; %s' %
               ((indent - 1) * 4, spanStyle))
    span.append(div)
    return span
def index(cards=[]):
    html = Html(lang='en')
    head = child(html, 'head')
    body = child(html, 'body')

    head.append(Tag('title', tagText='Tom Bertalan'))
    head.append(Tag('link', rel='stylesheet', href='styles.css'))
    head.append(Tag('link', rel='stylesheet', href='colorful.css'))
    head.append(
        Tag('script',
            type="text/javascript",
            async='1',
            src=
            "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"
            ))
def portfolioCard(title,
                  supportingText,
                  linkDest=None,
                  imgSrc=None,
                  imgAlt=''):
    if linkDest is not None:
        out = Div(
            cls=
            'mdl-cell mdl-card mdl-shadow--4dp portfolio-card mdl-cell--3-col anim-card mdl-cell--12-col-phone mdl-cell--3-col-tablet',
            onclick="location.href='%s'" % linkDest)
    else:
        out = Div(
            cls=
            'mdl-cell mdl-card mdl-shadow--4dp portfolio-card mdl-cell--3-col anim-card mdl-cell--12-col-phone mdl-cell--3-col-tablet',
        )
    if imgSrc is not None:
        out.append(
            Div(cls='mdl-card__media',
                toAppend=[
                    Div(cls='card-img-heightcrop',
                        style=
                        "background-color:white; background-image: url('%s');"
                        % imgSrc),
                ]))
    out.append(
        Div(cls='mdl-card__title',
            toAppend=[Tag('h2', cls='mdl-card__title-text', tagText=title)]))
    out.append(Div(cls='mdl-card__supporting-text', tagText=supportingText))
    return out
示例#7
0
def article(title,
            content,
            heading=None,
            breadcrumbs=None,
            sourceLink=None,
            entries=[],
            sourceLinkText='Project Files'):

    html = Html()
    head = child(html, 'head')
    head.append(Tag('style', tagText=articleStyle(), parseTagText=False))
    head.append(
        Tag('script',
            type="text/javascript",
            async='1',
            src=
            "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"
            ))
示例#8
0
def button(text, raised=True, primary=True, accent=False, **kwargs):
    cls = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--accent"
    if raised:
        cls += ' mdl-button--raised'
    if primary:
        cls += ' mdl-button--primary'
    elif accent:
        cls += ' mdl-button--accent'
    tag = Tag('button', cls=cls, tagText=text, **kwargs)
    return tag
def cardTask(title, text=None, img=None, shadowLevel=2, indent=1, color=None, primary=False, accent=False, spanStyle=''):
    assert shadowLevel in [2, 3, 4, 6, 8, 16]
    out = []
    if img is not None:
        out.append('''<div class="mdl-card__media">
                        <img src="%s" width="173" height="157" border="0" alt="%s" style="padding:10px;">
                    </div>''' % img)
       
    cls = "mdl-card__title"
    if accent:
        cls +=' mdl-color-text--accent-contrast'
    elif primary:
        cls += ' mdl-color-text--primary-contrast'
    out.append(Div(cls=cls, tagText=title))
    if text is not None:
        cls = "mdl-card__supporting-text"
        if accent:
            cls += ' mdl-color-text--accent-contrast'
        elif primary:
            cls += ' mdl-color-text--primary-contrast'
        div = Div(cls=cls, tagText=text)
        out.append(div)
        
    if color is not None:
        colorstyle = 'background-color: %s;' % color
    else:
        colorstyle = ''
    cls = 'mdl-card mdl-shadow--%ddp' % (shadowLevel,)
    if accent:
        cls += ' mdl-color--accent'
    elif primary:
        cls += ' mdl-color--primary'
    style = 'width: 90%%;%s' % colorstyle
    div = Div(cls=cls, style=style)
    for o in out:
        div.append(o)
    span = Tag('span', style='padding: 20px; margin-left: %dpx; %s' % ((indent-1)*4, spanStyle) )
    span.append(div)
    return span
示例#10
0
            breadcrumbs=None,
            sourceLink=None,
            entries=[],
            sourceLinkText='Project Files'):

    html = Html()
    head = child(html, 'head')
    head.append(Tag('style', tagText=articleStyle(), parseTagText=False))
    head.append(
        Tag('script',
            type="text/javascript",
            async='1',
            src=
            "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"
            ))
    head.append(Tag('link', rel='stylesheet', href='../styles.css'))
    head.append(Tag('link', rel='stylesheet', href='../colorful.css'))

    # Add script for expanding entries.
    head.append(
        Tag(
            'script',
            tagText='''
                    function show(toExpand)
                    {
                    if(
                       document.getElementById(toExpand).style.display == 'none'
                       ||
                       document.getElementById(toExpand).style.display == ''
                       )
                        document.getElementById(toExpand).style.display = 'block';
示例#11
0
def Head():
    head = Tag('head')
    head.append(Tag('link', rel='stylesheet', href="https://fonts.googleapis.com/icon?family=Material+Icons"))
    head.append(Tag('link', rel='stylesheet', href='https://code.getmdl.io/1.2.1/material.deep_orange-blue.min.css'))
    script = Tag('script', src="https://code.getmdl.io/1.2.1/material.min.js", defer='true')
    head.append(script)
    head.append(Tag('meta', name='viewport', content="width=device-width, initial-scale=1.0"))
    return head
                    )
                     document.getElementById(toExpand).style.display = 'block';
                 else
                     document.getElementById(toExpand).style.display = 'none';
                 }
                 ''',
                 parseTagText=False,
                 ))
 
 body = child(html, 'body')
 
 container = Div(cls='demo-layout mdl-layout mdl-layout--fixed-header mdl-js-layout mdl-color--grey-100')
 body.append(container)
 
 if title is not None:
     header = Tag('header', cls='demo-header mdl-layout__header mdl-layout__header--scroll mdl-color--grey-100 mdl-color-text--grey-800')
     container.append(header)
     headerRow = Div(cls='mdl-layout__header-row')
     header.append(headerRow)
     if isinstance(title, _Element):
         headerRow.append(Tag('span', cls='mdl-layout-title', toAppend=[title]))
     else:
         headerRow.append(Tag('span', cls='mdl-layout-title', tagText=title))
     headerRow.append(Div(cls='mdl-layout-spacer'))
 
 container.append(Div(cls='demo-ribbon'))
 
 mainDiv = Tag('main', cls='demo-main mdl-layout__content')
 container.append(mainDiv)
 
 grid = Div(cls='demo-container mdl-grid')
示例#13
0
from utils import Tag, Div, tostring

viewport = Div(id="viewport")
layout = Div(
    cls=
    "mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--fixed-tabs")
header = Tag('header', cls="mdl-layout__header")
headerRow = Div(cls="mdl-layout__header-row")
tabBar = Div(cls="mdl-layout__tab-bar mdl-js-ripple-effect")
drawer = Div(cls="mdl-layout__drawer")
mainLayout = Tag('main', cls="mdl-layout__content")
secCams = Tag('section',
              cls="mdl-layout__tab-panel is-active",
              id="fixed-tab-1")
grid = Div(cls='mdl-grid')
# These columns are as parts of 12. I.e., 4-col means even thirds (4/12 units).
gridThird = Div(cls='mdl-cell mdl-cell--4-col')
gridOneth = Div(cls='mdl-cell mdl-cell--12-col')
card = Div(cls='mdl-card mdl-shadow--4dp')


def cardTask(title,
             text=None,
             img=None,
             shadowLevel=2,
             indent=1,
             color=None,
             primary=False,
             accent=False,
             spanStyle=''):
    assert shadowLevel in [2, 3, 4, 6, 8, 16]
示例#14
0

def index(cards=[]):
    html = Html(lang='en')
    head = child(html, 'head')
    body = child(html, 'body')
    
    head.append(Tag('title', tagText='Tom Bertalan'))
    head.append(Tag('link', rel='stylesheet', href='styles.css'))
    head.append(Tag('link', rel='stylesheet', href='colorful.css'))
    head.append(Tag('script', type="text/javascript", async='1', src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"))

    layout = Div(cls='mdl-layout mdl-js-layout')
    body.append(layout)
    
    mainContent = Tag('main', cls='mdl-layout__content')
    layout.append(mainContent)
    
    grid = Div(cls='mdl-grid portfolio-max-width')
    mainContent.append(grid)
    
    bioCell = Div(cls='mdl-cell mdl-cell--4-col mdl-cell--12-col-phone')
    grid.append(bioCell)
    
    bioCell.append(Tag('br'))  # tiny vertical filler
    bioCell.append(Div(cls='portfolio-logo'))
    bioCell.append(Tag('center', toAppend=[Tag('h1', cls='mdl-typography--display-3 h1-mainpage', tagText='Tom Bertalan')]))
    bioCellSubcell = Div(cls='mdl-cell mdl-cell--12-col')
    bioCell.append(bioCellSubcell)
    bioCellSubcell.append(Tag('p', tagText='''
    I am a Postdoctoral Associate in the Mechanical Engineering department
示例#15
0
    head.append(Tag('title', tagText='Tom Bertalan'))
    head.append(Tag('link', rel='stylesheet', href='styles.css'))
    head.append(Tag('link', rel='stylesheet', href='colorful.css'))
    head.append(
        Tag('script',
            type="text/javascript",
            async='1',
            src=
            "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"
            ))

    layout = Div(cls='mdl-layout mdl-js-layout')
    body.append(layout)

    mainContent = Tag('main', cls='mdl-layout__content')
    layout.append(mainContent)

    grid = Div(cls='mdl-grid portfolio-max-width')
    mainContent.append(grid)

    bioCell = Div(cls='mdl-cell mdl-cell--4-col mdl-cell--12-col-phone')
    grid.append(bioCell)

    bioCell.append(Tag('br'))  # tiny vertical filler
    bioCell.append(Div(cls='portfolio-logo'))
    bioCell.append(
        Tag('center',
            toAppend=[
                Tag('h1',
                    cls='mdl-typography--display-3 h1-mainpage',