示例#1
0
def add_head(doc):
    doc_head = doc.add(tags.head())
    with doc_head:
        tags.meta(charset='utf-8')
        tags.title('Man')
        tags.link(rel='stylesheet', href='styles.css')
    return doc
示例#2
0
def site():
    base = Path('website')
    with (base/'content'/'index.toml').open() as toml, \
         (base/'style'/'index.css').open() as css:
        data = loads(toml.read())

        with html(lang='en') as document:

            with head():
                meta(charset='utf-8')
                meta(name='description',
                     content=f'{SHARED.info.person_name} (engineer|designer)')
                meta(name='keywords', content=','.join(SHARED.meta.keywords))
                meta(name='author', content=f'{SHARED.info.person_name}')
                title(SHARED.info.person_name)
                link(rel='shortcut icon',
                     type='image/x-icon',
                     href='favicon.ico')
                link(rel='icon', type='image/x-icon', href='favicon.ico')
                style(raw(css.read()))
                script(src='website/js/anim.js')
                script(src='website/js/index.js')

            with body():
                _block('engineer', data['engineer'])
                _block('designer', data['designer'])
                with div(id='handler'):
                    div(raw('«»'))
                script('main();', type='text/javascript')

    copyright = comment(f'Copyright (C) 2015 - {datetime.now().year} '
                        f'{SHARED.info.person_name}. '
                        'All rights reserved.')
    return f'<!DOCTYPE html>{copyright}{document.render(pretty=False)}'
示例#3
0
def cv():
    base = Path('cv')
    with (base / 'content' / 'data.toml').open() as toml, \
         (base / 'style' / 'index.css').open() as css:
        data = loads(toml.read())
        with html(lang='en') as document:
            with head():
                meta(charset='utf-8')
                meta(name='description',
                     content=f'{SHARED.info.person_name} (engineer|designer)')
                meta(name='keywords', content=','.join(SHARED.meta.keywords))
                meta(name='author', content=f'{SHARED.info.person_name}')
                title(SHARED.info.person_name)
                style(raw(css.read()))
            with body():
                with table(id='content') as content:
                    with tr():
                        with td(id='image', colspan=4):
                            img(src='img/header.png', alt='...')
                            div('Curriculum Vitae')
                for row in chain(
                        Basic(data['basic']).as_rows(),
                        Skills(data['skills']).as_rows(),
                        Experience(data['experience']).as_rows(),
                        Education(data['education']).as_rows()):
                    content.add(row)

    copyright = comment(f'Copyright (C) 2015 - {datetime.now().year} '
                        f'{SHARED.info.person_name}. '
                        'All rights reserved.')
    return f'<!DOCTYPE html>{copyright}{document.render(pretty=False)}'
示例#4
0
def create_mainpage_html(local, url_list, path, web_title):
    _html = dmtags.html(style="background-color:#fcfbeb;")
    _head, _body = _html.add(dmtags.head(dmtags.title(web_title)),
                             dmtags.body(cls="main_page"))
    with _head:
        dmtags.comment("The page is genarated on {} by Ein".format(
            time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())))
        dmtags.meta(charset="utf-8",
                    name="viewport",
                    content="width=device-width, initial-scale=1")
        dmtags.link(
            href="https://fonts.googleapis.com/css?family=Noto+Sans+JP:500",
            rel="stylesheet")
        dmtags.link(
            href=
            "https://cdnjs.cloudflare.com/ajax/libs/milligram/1.3.0/milligram.min.css",
            rel="stylesheet")
        dmtags.link(href="https://rawcdn.githack.com/c892836a/python_for_fun/"
                    "b2fa53022b0ae5a26d6f140c38b860a210c21040/css/custom.css",
                    rel="stylesheet")
        dmtags.link(
            href="https://lh3.googleusercontent.com/S__tM5EYqZDFLuv1uPG" +
            "mlZTTLLyNAbUvljzDH8-S0Pxq2nA9fnFF3SwU0w0wF8PlMu_hv3WhLMdlFodKbQ=s0",
            rel="shortcut icon",
            type="image/vnd.microsoft.icon")
    main_div = _body.add(
        dmtags.div(
            style=
            "text-align:center; font-family: 'Noto Sans JP', sans-serif; font-size:36px;"
        ))

    with main_div:
        _p1 = dmtags.p(style="color:#470000;")
        for url in url_list:
            _p2 = dmtags.p(style="font-size:20px;")
            with _p2:
                dmtags.a(url[0], href="{}".format(url[1]))
        with _p1:
            text("{}".format(web_title))

    # create html file
    if local:
        os.chdir(path)
        os.chdir(os.pardir)
        with open("{}.html".format(web_title), "w", encoding='utf8') as f:
            f.write("<!DOCTYPE html>\n")
            f.write(_html.render())

    else:
        with open("{}\\{}.html".format(path, web_title), "w",
                  encoding='utf8') as f:
            f.write("<!DOCTYPE html>\n")
            f.write(_html.render())
示例#5
0
 def __init__(self, _title, file=None, data=None):
     self.file = file
     self.data = data
     self.html = tags.html(lang='en')
     self.head = self.html.add(tags.head())
     self.head.add(tags.meta(charset='utf-8'))
     self.head.add(tags.title(_title))
     self.head.add(tags.link(rel='stylesheet', href='styles.css'))
     self.body = self.html.add(tags.body())
     self.paragraph = None
     self.div_header = None
     self.div_subheader = None
     self.date = None
     self.program = None
     self.name_page = None
     self.iterator = None
     self.indent = 0
     self.rs = None
示例#6
0
try:
    os.mkdir(pages_dir)
except:
    pass

n = 20

pages = []
for i in range(1, n + 1):
    pages.append("{}.html".format(i))

for j in range(1, n + 1):
    page = tags.html()

    page_title = tags.title("Page " + str(j))
    page_head = tags.head(page_title)

    page_body = tags.body()
    for k in range(1, random.randint(1, n)):
        image = tags.img(src=("image_source" + str(k)))
        page_body.add(image)

    ul_links = tags.ul()
    for r in range(1, random.randint(1, n)):
        li_link = tags.li()
        page_to_link = pages[random.randint(0, n - 1)]
        link = li_link.add(
            tags.a("This is a link to {}".format(page_to_link),
                   href="/{}".format(page_to_link)))
        ul_links.add(li_link)
示例#7
0
def create_singlepage_html(local, is_mainpage, web_title, web_title_next,
                           web_title_pre, file_array, path):
    parent_web_title = ""
    if is_mainpage:
        os.chdir(path)
        os.chdir(os.pardir)
        parent_web_title = str(os.getcwd())[str(os.getcwd()).rindex("\\") + 1:]
    if local:
        web_title_next = special_character_encode(web_title_next)
        web_title_pre = special_character_encode(web_title_pre)
    _html = dmtags.html(style="background-color:black;")
    _head, _body = _html.add(dmtags.head(dmtags.title(web_title)),
                             dmtags.body())
    with _head:
        dmtags.comment("The page is genarated on {} by Ein".format(
            time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())))
        dmtags.meta(charset="utf-8",
                    name="viewport",
                    content="width=device-width, initial-scale=1")
        dmtags.link(
            href="https://fonts.googleapis.com/css?family=Noto+Sans+JP:500",
            rel="stylesheet")
        dmtags.link(
            href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.6/"
            "jquery.fancybox.min.css",
            rel="stylesheet")
        dmtags.link(
            href="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-rc.25/css/"
            "uikit.min.css",
            rel="stylesheet")
        dmtags.link(href="https://rawcdn.githack.com/c892836a/python_for_fun/"
                    "b2fa53022b0ae5a26d6f140c38b860a210c21040/css/custom.css",
                    rel="stylesheet")
        dmtags.link(
            href="https://lh3.googleusercontent.com/S__tM5EYqZDFLuv1uPG" +
            "mlZTTLLyNAbUvljzDH8-S0Pxq2nA9fnFF3SwU0w0wF8PlMu_hv3WhLMdlFodKbQ=s0",
            rel="shortcut icon",
            type="image/vnd.microsoft.icon")
        dmtags.script(
            src=
            "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js")
        dmtags.script(
            src=
            "https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.6/jquery.fancybox.min.js"
        )

    main_div = _body.add(
        dmtags.div(
            style=
            "text-align:center; font-family: 'Noto Sans JP', sans-serif; font-size:32px;"
        ))
    with main_div:
        _p1 = dmtags.p(style="color:#C2FFFC;padding-top: 20px;")
        if web_title_next == "" and web_title_pre == "":
            _button_top_div = dmtags.div(style="display: none;")
        else:
            _button_top_div = dmtags.div(style="padding-bottom: 30px;")
        if local:
            for pic in file_array:
                _a1 = dmtags.a(datafancybox="gallery",
                               href='./{}/{}'.format(
                                   urllib.parse.quote(web_title),
                                   urllib.parse.quote(pic)))
                with _a1:
                    dmtags.img(width="1200px",
                               src='./{}/{}'.format(
                                   urllib.parse.quote(web_title),
                                   urllib.parse.quote(pic)))
        else:
            web_title_temp = restrict_foldername(web_title)
            for pic in file_array:
                _a1 = dmtags.a(datafancybox="gallery",
                               href='./{}/{}'.format(
                                   urllib.parse.quote(web_title_temp),
                                   urllib.parse.quote(pic)))
                with _a1:
                    dmtags.img(width="1200px",
                               src='./{}/{}'.format(
                                   urllib.parse.quote(web_title_temp),
                                   urllib.parse.quote(pic)))
        with _p1:
            text("{} ({}P)".format(web_title, str(len(file_array))))
        _button_bottom_div = dmtags.div(
            style="padding-top: 20px; padding-bottom: 40px;")
        with _button_top_div:
            if web_title_pre != "":
                dmtags.a("Prev",
                         cls="uk-button uk-button-secondary n-bt",
                         href="./{}.html".format(web_title_pre))
            else:
                dmtags.a("Prev",
                         cls="uk-button uk-button-secondary h-bt",
                         href="./{}.html".format(web_title_pre))
            if is_mainpage:
                dmtags.a("Index",
                         cls="uk-button uk-button-secondary n-bt",
                         href="../{}.html".format(parent_web_title))
            if web_title_next != "":
                dmtags.a("Next",
                         cls="uk-button uk-button-secondary n-bt",
                         href="./{}.html".format(web_title_next))
            else:
                dmtags.a("Next",
                         cls="uk-button uk-button-secondary h-bt",
                         href="./{}.html".format(web_title_next))

        with _button_bottom_div:
            if web_title_pre != "":
                dmtags.a("Prev",
                         cls="uk-button uk-button-primary n-bt",
                         href="./{}.html".format(web_title_pre))
            else:
                dmtags.a("Prev",
                         cls="uk-button uk-button-primary h-bt",
                         href="./{}.html".format(web_title_pre))
            if is_mainpage:
                dmtags.a("Index",
                         cls="uk-button uk-button-primary n-bt",
                         href="../{}.html".format(parent_web_title))
            if web_title_next != "":
                dmtags.a("Next",
                         cls="uk-button uk-button-primary n-bt",
                         href="./{}.html".format(web_title_next))
            else:
                dmtags.a("Next",
                         cls="uk-button uk-button-primary h-bt",
                         href="./{}.html".format(web_title_next))

    # create html file
    with open("{}.html".format(special_character_encode(path)),
              "w",
              encoding='utf8') as f:
        f.write("<!DOCTYPE html>\n")
        f.write(_html.render().replace("datafancybox", "data-fancybox"))