コード例 #1
0
def password_change_menu():
    html = E.HTML(
        E.HEAD(
            E.LINK(rel="stylesheet", href="/css/deeplight.css", type="text/css"),
            E.TITLE("Administration and moderation")
            ),
        E.BODY(
            E.H1(E.CLASS("heading"), "Farlight Engine Imageboard"),
            E.P(E.CLASS("loginmessage"), "Change your password"),
            E.FORM(E.CLASS("loginform"),
                   E.INPUT(type = 'hidden', name = 'action', value = 'change'),
                   E.INPUT(type = 'hidden', name = 'instance', value = 'password'),
                   E.TABLE(
                       E.TR(E.TD('OLD PASSWORD'),
                            E.TD(E.INPUT(type = 'password', name = 'old_passwd', value = ''))
                            ),
                       E.TR(E.TD('NEW PASSWORD'),
                            E.TD(E.INPUT(type = 'password', name = 'new_passwd', value = ''))
                            ),
                       E.TR(E.TD('NEW PASSWORD AGAIN'),
                            E.TD(E.INPUT(type = 'password', name = 'new_passwd_again', value = ''))
                            ),
                       ),
                   E.INPUT(type = 'submit', value = 'LOGIN'),
                   method = 'POST',
                   action = '/admin'
                   )
            )
        )
    return lxml.html.tostring(html)
コード例 #2
0
def list_bans_menu(ban_list, purpose):
    """need to put bans and boards table creating to a joint function in future"""
    tablerows = [E.TR(E.TD(str(b.id)),
                      E.TD(b.ip),
                      E.TD(b.initiator),
                      E.TD(time.strftime('%d/%m/%Y %H:%M', time.localtime(b.date))),
                      E.TD(str(b.level)),
                      E.TD(E.BUTTON('Снять', type = 'button', onclick = 'remove_ban(this);'))
                      )for b in ban_list]
    #purpose will be applyed later
    html = E.HTML(
        E.HEAD(
            E.LINK(rel="stylesheet", href="/css/deeplight.css", type="text/css"), 
            E.TITLE("Creating board"),
            E.SCRIPT(type = 'text/javascript', src = '/adminscript.js') #js
            ),
        E.BODY(
            E.DIV(E.CLASS('adminupdiv'),
                E.DIV(E.CLASS('logout'), E.A('Logout', href='/admin/logout')),
                E.H2(E.CLASS("heading"), "Listing bans"),
                ),
            E.TABLE(
                E.CLASS("boardstable"),
                E.TR(E.TH('ID'),
                     E.TH('IP'),
                     E.TH('Забанивший'),
                     E.TH('Дата'),
                     E.TH('Уровень'),
                     E.TH('')
                     ),
                *tablerows
                )
            )
        )
    return lxml.html.tostring(html)
コード例 #3
0
ファイル: SendEmail.py プロジェクト: 67au/GDUTNews2Mail
def mailgen():
    d = DataCmp().cmp_result()
    news_topic = {'hot_news': '热点新闻', 'hot_inform': '最新公告', 'hot_msg': '最新简讯'}

    def test():
        for key, value in d.items():
            yield E.H2(news_topic[key])
            if any(value):
                for i in value:
                    yield lxml.html.fromstring(
                        '<a href="http://news.gdut.edu.cn/viewarticle.aspx?articleid={id}">{title}[{loc}]</a><br></br>'
                        .format_map(i))
            else:
                del news_topic[key]
                yield E.P('无')
        yield E.P('Sent at {}'.format(
            time.strftime("%y-%m-%d %H:%M", time.localtime())))

    sub = [i for i in test()]
    if not any(news_topic):
        sub = [E.H2('今日无事可做')]
    html = E.HTML(
        E.HEAD(
            E.META(charset='UTF-8'),
            E.META(name='viewport',
                   content='width=device-width, initial-scale=1.0'),
            E.TITLE("GDUTNews Stream")), E.BODY(*sub))
    return lxml.html.tostring(html)
コード例 #4
0
def template(name, contents):

    cpu_class = 'active' if name == 'cpu' else ''
    wc_class = 'active' if name == 'wc' else ''
    help_class = 'active' if name == 'help' else ''

    return E.HTML(
        E.HEAD(
            E.LINK(rel='stylesheet',
                   type='text/css',
                   href='bootstrap/css/bootstrap.css'),
            E.LINK(rel='stylesheet', type='text/css', href='profile.css'),
            E.SCRIPT(src='bootstrap/js/bootstrap.min.js'),
            E.TITLE('RUM Job Profile')),
        E.BODY(
            E.DIV(E.DIV(E.DIV(E.A(E.SPAN(CLASS='icon-bar'),
                                  E.SPAN(CLASS='icon-bar'),
                                  E.SPAN(CLASS='icon-bar'),
                                  CLASS='btn btn-navbar'),
                              E.A('RUM Profile', CLASS='brand', href='#'),
                              E.DIV(E.UL(E.LI(E.A('CPU time', href='cpu.html'),
                                              CLASS=cpu_class),
                                         E.LI(E.A('Wallclock time',
                                                  href='wc.html'),
                                              CLASS=wc_class),
                                         E.LI(E.A('Help', href='help.html'),
                                              CLASS=help_class),
                                         CLASS='nav'),
                                    CLASS='nav-collapse collapse'),
                              CLASS='container'),
                        CLASS='navbar-inner'),
                  CLASS='navbar navbar-inverse navbar-fixed-top'), E.BR(),
            E.BR(), E.BR(), E.DIV(contents, CLASS='container')))
コード例 #5
0
def login_page_gen():
    html = E.HTML(
        E.HEAD(
            E.LINK(rel="stylesheet", href="/css/deeplight.css", type="text/css"),
            E.TITLE("Administration and moderation")
            ),
        E.BODY(
            E.H1(E.CLASS("heading"), "Farlight Engine Imageboard"),
            E.P(E.CLASS("loginmessage"), "You need to login"),
            E.FORM(E.CLASS("loginform"),
                   E.TABLE(
                       E.TR(E.TD('LOGIN'),
                            E.TD(E.INPUT(type = 'text', name = 'login', value = ''))
                            ),
                       E.TR(E.TD('PASSWORD'),
                            E.TD(E.INPUT(type = 'text', name = 'password', value = ''))
                            ),
                       ),
                   E.INPUT(type = 'submit', value = 'LOGIN'),
                   method = 'POST',
                   action = '/admin/login'
                   )
            )
        )
    return lxml.html.tostring(html)
コード例 #6
0
ファイル: parser.py プロジェクト: mcnultyc/summarize-document
def parse_wiki(tree, title):
    root = tree.getroot()
    parser_div = root.xpath("//div[@class='mw-parser-output']")[0]
    headers = ["h1","h2","h3","h4","h5","h6"]
    children = parser_div.getchildren()
    text = ""
    header = ""
    html = ""
    for child in children:
        if child.tag == "p":
            text += child.text_content().lstrip().rstrip()
        elif child.tag in headers:
            if len(text) > 0:
                summary = summarize(text, limit=2)
                html += "<h2>"+header+"</h2><p>"+summary+"</p>"
            text = ""
            header = child.text_content().split("[")[0]
            print(header)
    
    # TODO - add style sheet
    # TODO - format text
    html_out = E.HTML(
        E.HEAD(
            E.TITLE(title)
            ),
        E.BODY(
            E.H1(E.CLASS("heading"), title),
            lxml.html.fromstring(html)
            )
        )

    html_out.getroottree().write(file="summarized-roanoke.html", method="html")
コード例 #7
0
    def _generate_meadata_elements(self):
        yield E.META(charset="UTF-8")

        for name, content in self.metadata.items():
            if name == 'title':
                yield E.TITLE(content)
            else:
                yield E.META(name=name, content=content)
コード例 #8
0
ファイル: DOMImplementation.py プロジェクト: xandfury/thug
    def _createHTMLDocument(self, title = None):
        body  = E.BODY()
        title = E.TITLE(title) if title else ""
        head  = E.HEAD(title)
        html  = E.HTML(head, body)

        soup = bs4.BeautifulSoup(tostring(html, doctype = '<!doctype html>'), "lxml")
        return DOMImplementation(soup)
コード例 #9
0
def make_summary_doc(tests_w_results):
    tbody = B.TBODY(
        B.TR(B.TH('Test Name'), B.TH('Inserted (in # of blocks)'),
             B.TH('Deleted (in # of blocks)'), B.TH('Links'), B.TH('Notes')))
    for (test, result) in tests_w_results:
        row = make_summary_row(test, result)
        tbody.append(row)
    return B.HTML(
        B.HEAD(B.TITLE('Readability Test Summary'),
               B.STYLE(SUMMARY_CSS, type='text/css')), B.BODY(B.TABLE(tbody)))
コード例 #10
0
 def __init__(self, datas, lang, freeze, title, css_path):
     super().__init__(datas, lang, freeze)
     self._html = builder.HTML(
         builder.HEAD(
             builder.META(charset="utf-8"),
             builder.TITLE(title),
             builder.LINK(rel="stylesheet", href=css_path),
         ),
         builder.BODY(builder.DIV(id="text_area")),
     )
コード例 #11
0
ファイル: HTMLDocument.py プロジェクト: hazedic/thug
    def setTitle(self, value):
        title = self.head.tag.find('title')

        if title:
            title.string = value
            return

        title = E.TITLE(value)
        tag = bs4.BeautifulSoup(tostring(title), "html.parser")
        self.head.tag.append(tag)
コード例 #12
0
    def visit_Component(self, node):
        inst = getattr(self, 'inst', None)
        if inst:
            title = 'Instance {} of {} Register Map'.format(inst, node.name)
        else:
            title = 'Base {} Register Map'.format(node.name)
        self.title = title

        # Create the main content by sweeping the tree.
        bc = E.DIV(id='breadcrumbs')
        try:
            if self.breadcrumbs is not None:
                bc.append(self.breadcrumbs)
        except AttributeError:
            pass

        ww = node.width // 8
        an = ((node.size - 1).bit_length() + 3) // 4
        with self.tempvars(wordwidth=ww, address_nibbles=an, hlev=2):
            nodes = ([E.H1(title, id='title'), bc] +
                     [E.P(d) for d in node.description] +
                     [c
                      for c in self.visitchildren(node)] + [self.footer(node)])
            contentnode = E.DIV(*nodes, id='content')

        # Add a table of contents sidebar.  We'll assume that everything that
        # wants to be in the TOC is already a heading and just work from there.
        h2list = E.UL()
        for elem in contentnode.iter('h2', 'h3'):
            id = escape(elem.text)
            elem.attrib['id'] = id
            if elem.tag == 'h2':
                h2node = E.LI(E.A(elem.text, href='#' + id))
                h2list.append(h2node)
                h3list = None
            else:
                if h3list is None:
                    h3list = E.UL()
                    h2list.append(h3list)
                h3list.append(E.LI(E.A(elem.text, href='#' + id)))

        # Put it all together.
        return E.HTML(
            E.HEAD(
                E.TITLE(title),
                E.LINK(rel='stylesheet',
                       type='text/css',
                       href=htmlpathjoin(self.styledir, 'reg.css'))),
            E.BODY(
                E.DIV(E.DIV(E.P(E.A(title, href='#title')),
                            h2list,
                            id='sidebar'),
                      contentnode,
                      id='wrapper')),
        )
コード例 #13
0
ファイル: genHTML.py プロジェクト: bitwiserob/aProgramAday364
def generateHTML(city_info):
    html = E.HTML(
        E.HEAD(E.TITLE("Weather for:{}".format(city_info['city']))),
        E.BODY(E.H1("Weather for:{}".format(city_info['city'])),
               E.P("{}".format(city_info['city_temp'])),
               E.P("{}".format(city_info['city_forecast'])),
               E.P("{}".format(city_info['city_min'])),
               E.P("{}".format(city_info['city_max'])),
               E.P("{}".format(city_info['city_time']))))
    byteString = lxml.html.tostring(html)
    string = byteString.decode('utf-8')
    return string
コード例 #14
0
ファイル: genHTML.py プロジェクト: bitwiserob/aProgramAday364
def getCity(city):
    weatherStuff = weatherHandler(city)
    weatherStuff.get_weather()
    html = E.HTML(
        E.HEAD(E.TITLE("Weather for:{}".format(weatherStuff.city))),
        E.BODY(E.H1("Weather for:{}".format(weatherStuff.city)),
               E.P("{}".format(weatherStuff.formatted_temp)),
               E.P("{}".format(weatherStuff.formatted_weather)),
               E.P("{}".format(weatherStuff.formatted_minMax)),
               E.P("{}".format(weatherStuff.formatted_time))))
    byteString = lxml.html.tostring(html)
    string = byteString.decode('utf-8')
    return string
コード例 #15
0
def board_creation_menu(): #here is the html board creation menu
    html = E.HTML(
        E.HEAD(
            E.LINK(rel="stylesheet", href="/css/deeplight.css", type="text/css"),
            E.TITLE("Creating board")
            ),
        E.BODY(
            E.DIV(E.CLASS('adminupdiv'),
                E.DIV(E.CLASS('logout'), E.A('Logout', href='/admin/logout')),
                E.H2(E.CLASS("heading"), "Create new board"),
                ),
            E.DIV(E.CLASS("boardcreateform"),
            E.FORM(
                   E.INPUT(type = 'hidden', name = 'action', value = 'create'),
                   E.INPUT(type = 'hidden', name = 'instance', value = 'board'),
                   E.TABLE(
                       E.TR(E.TD('Address'),
                            E.TD(E.INPUT(type = 'text', name = 'address', value = ''))
                            ),
                       E.TR(E.TD('Tablename'),
                            E.TD(E.INPUT(type = 'text', name = 'tablename', value = ''))
                            ),
                       E.TR(E.TD('Name'),
                            E.TD(E.INPUT(type = 'text', name = 'name', value = ''))
                            ),
                       E.TR(E.TD('Fullname'),
                            E.TD(E.INPUT(type = 'text', name = 'fullname', value = ''))
                            ),
                       E.TR(E.TD('Description'),
                            E.TD(E.INPUT(type = 'text', name = 'description', value = ''))
                            ),
                       E.TR(E.TD('Pics number'),
                            E.TD(E.INPUT(type = 'number', name = 'picsnum', value = '', min = '0', max = '10'))
                            ),
                       E.TR(E.TD('Bumplimit'),
                            E.TD(E.INPUT(type = 'number', name = 'bumplimit', value = '', min = '0'))
                            ),
                       E.TR(E.TD('Max threads'),
                            E.TD(E.INPUT(type = 'number', name = 'maxthreads', value = '', min = '-1'))
                            ),
                       E.TR(E.TD(E.INPUT(type='checkbox', name='delposts', value='1', checked='checked'), 'Удаление постов', colspan='2', style='text-align:center;')),
                       E.TR(E.TD(E.INPUT(type='checkbox', name='delopposts', value='1', checked='checked'), 'Удаление тредов', colspan='2', style='text-align:center;')),
                       ),
                   E.INPUT(type = 'submit', value = 'Create'),
                   method='POST',
                   action='/admin/'
                   )
            )
            )
        )
    return lxml.html.tostring(html)
コード例 #16
0
def html_page_return(board, thread, default_style):
    html = E.HTML(
        E.HEAD(
            E.META(**{'http-equiv':"Default-Style", 'content':default_style, 'id':'stylemetatag'}),
            E.TITLE("/"+board+"/ - №"+str(thread)), #title
            E.SCRIPT(type = 'text/javascript', src = '/mainscript.js'), #js
            *initiate.style_cache
            ),
        E.BODY(
            E.P(E.CLASS("board"), board, id = 'board'),
            E.P(E.CLASS("thread"), str(thread), id = 'thread'),
            E.TABLE(
                E.CLASS("maintable"),
                E.THEAD(E.TR(E.TD(
                    E.TABLE(E.TR(E.TD(E.CLASS('left'), copy.copy(initiate.board_cache_navigation)),
                                 E.TD(E.CLASS('right'), utilfunctions.generate_right_up_corner_menu()),
                                 ),
                            id='headblock'),
                    E.HR(E.CLASS("delimeter")),
                    )), id = 'header'),
                E.TBODY(E.TR(E.TD(
                    E.H2(E.CLASS("boardname"),
                         E.A('/' + board + '/ - '+ initiate.board_cache[board].name, href = '/' + board),
                         ),
                    E.HR(E.CLASS("delimeter")),
                    initiate.board_cache[board].post_form, #need to make it depending on post_form_type
                    E.SCRIPT('function open_form() {document.getElementById("postform").style.display = "block"; document.getElementById("closeform").style.display = "block"; document.getElementById("threadcreate").style.display = "none";}'),
                    E.SCRIPT('function close_form() {document.getElementById("postform").style.display = "none"; document.getElementById("closeform").style.display = "none"; document.getElementById("threadcreate").style.display = "block";}'),
                    E.H3(E.A('Ответить в тред', href = "javascript:open_form();"), id = 'threadcreate'),
                    E.H4(E.A('Скрыть форму', href = "javascript:close_form();"), id = 'closeform'),
                    E.HR(E.CLASS("delimeter")),
                    EM('main', '', id = 'mainframe'),
                    E.DIV('', id = 'optionsdiv'),
                    )), id = 'mainpart'),
                E.TFOOT(E.TR(E.TD(
                       E.DIV(
                           E.HR(E.CLASS("delimeter"), id = 'end')
                           ),
                       initiate.board_cache_navigation,
                       E.DIV('powered by ',
                             E.A('Farlight Imageboard Engine',
                                 href='https://github.com/Alpherie/farlight_board_engine',
                                 target='_blank',
                                 ),
                             id='credentials'),
                    )), id = 'footer'),#we make it a footer
                ),
            onload = 'threadfunc()'
            )
        )
    return lxml.html.tostring(html)
コード例 #17
0
def list_boards_menu(board_list, purpose):
    """need to put boards table creating to a separate function in future"""
    posts_num_cell = E.DIV(E.SPAN('????', style = 'display:inline-block; width:4em; text-align:center;'),
                           E.INPUT(type='number', size='6', min='0', value='1', style = 'width: 6em;'),
                           E.SELECT(E.OPTION('Секунды', value='1'),
                                    E.OPTION('Минуты', value='60'),
                                    E.OPTION('Часы', value='3600'),
                                    E.OPTION('Дни', value='86400', selected='')
                                    ),
                           E.BUTTON('GET', onclick='get_posts_num_from_time(this)', type = 'button'))
    tablerows = [E.TR(E.TD(E.A(b.address, href = '/'+b.address)),
                      E.TD(b.tablename),
                      E.TD(str(b.name)),
                      E.TD(str(b.fullname)),
                      E.TD(str(b.description)),
                      E.TD(str(b.category)),
                      E.TD(str(b.pictures)),
                      E.TD(str(b.bumplimit)),
                      E.TD(str(b.maxthreads)),
                      E.TD(copy.copy(posts_num_cell))
                      )for b in board_list]
    #purpose will be applyed later
    html = E.HTML(
        E.HEAD(
            E.LINK(rel="stylesheet", href="/css/deeplight.css", type="text/css"), 
            E.TITLE("Creating board"),
            E.SCRIPT(type = 'text/javascript', src = '/adminscript.js') #js
            ),
        E.BODY(
            E.DIV(E.CLASS('adminupdiv'),
                E.DIV(E.CLASS('logout'), E.A('Logout', href='/admin/logout')),
                E.H2(E.CLASS("heading"), "Listing boards"),
                ),
            E.TABLE(
                E.CLASS("boardstable"),
                E.TR(E.TH('Адрес'),
                     E.TH('Таблица'),
                     E.TH('Название'),
                     E.TH('Полное название'),
                     E.TH('Описание'),
                     E.TH('Категория'),
                     E.TH('Максимум картинок'),
                     E.TH('Бамплимит'),
                     E.TH('Максимум тредов'),
                     E.TH('Постов за последнее время')
                     ),
                *tablerows
                )
            )
        )
    return lxml.html.tostring(html)
コード例 #18
0
def main(results_file):
    summary = {}
    with open(results_file, 'r') as f:
        summary = json.loads(f.read())
        summary['directory'] = os.path.dirname(results_file)

    date = datetime.datetime.fromtimestamp(
        summary['timestamp']).strftime('%Y-%m-%d-%H:%M:%S')

    token_create_rps = summary['token_creation']['requests_per_second']
    token_create_tps = summary['token_creation']['time_per_request']
    token_validate_rps = summary['token_validation']['requests_per_second']
    token_validate_tps = summary['token_validation']['time_per_request']

    index = e.HTML(
        e.HEAD(e.LINK(rel='stylesheet', type='text/css', href='theme.css'),
               e.TITLE('OpenStack Keystone Performance')),
        e.BODY(
            e.DIV(e.H1('OpenStack Keystone Performance'),
                  e.P('Published reports after each merged patch.',
                      CLASS('subtitle')),
                  id='header'),
            e.DIV(
                e.P('Last run date: ' + date, ),
                e.P(
                    'keystone SHA: ',
                    e.A(summary['sha'],
                        target='_blank',
                        href=KEYSTONE_LINK + summary['sha'])),
                e.P(
                    'os_keystone SHA: ',
                    e.A(summary['osa_sha'],
                        target='_blank',
                        href=OSA_LINK + summary['osa_sha'])),
                e.P(e.A('Performance Data', href=PERF_LINK, target='_blank')),
                e.DIV(CLASS('left'), e.H2('Create Token'),
                      e.P(e.STRONG(token_create_rps), ' requests per second'),
                      e.P(e.STRONG(token_create_tps), ' ms per request')),
                e.DIV(
                    CLASS('right'), e.H2('Validate Token'),
                    e.P(e.STRONG(token_validate_rps), ' requests per second'),
                    e.P(e.STRONG(token_validate_tps), ' ms per request')),
                id='content'),
            e.DIV(e.P(
                'Results provided by the ',
                e.A('OSIC Performance Bot', target='_blank', href=BOT_LINK)),
                  id='footer')))

    with open(os.path.join(summary['directory'], 'index.html'), 'w') as f:
        f.write(et.tostring(index))
コード例 #19
0
 def head(self):
     """The HEAD of the html document"""
     head = E.HEAD(
         E.META({
             'http-equiv': 'Content-Type',
             'content': 'text/html; charset=utf-8'
         }),
         E.TITLE('%s -- GCC Python Plugin' % self.data['filename']),
     )
     head.extend(
         E.STYLE(
             file_contents(css + '.css'), media='screen', type='text/css')
         for css in ('extlib/reset-20110126.min', 'pygments_c', 'style'))
     return head
コード例 #20
0
 def head(self):
     """The HEAD of the html document"""
     head = E.HEAD(
         E.META({
             'http-equiv': 'Content-Type',
             'content': 'text/html; charset=utf-8'
         }),
         E.TITLE('%s -- GCC Python Plugin' % self.data['filename']),
     )
     head.extend(
         E.LINK(rel='stylesheet', href=css + '.css', type='text/css')
         for css in ('extlib/reset-20110126', 'pygments_c', 'style'))
     head.extend(
         E.SCRIPT(src=js + '.js')
         for js in ('extlib/prefixfree-1.0.4.min',
                    'extlib/jquery-1.7.1.min', 'script'))
     return head
コード例 #21
0
def main_page_gen(default_style):
    html = E.HTML(
        E.HEAD(
            E.META(**{'http-equiv':"Default-Style", 'content':default_style, 'id':'stylemetatag'}),
            E.TITLE("U2ch - Main Page"),
            E.SCRIPT(type = 'text/javascript', src = '/mainscript.js'), #js
	    *initiate.style_cache
            ),
        E.BODY(
            E.UL(initiate.stats_cache,
                 style = "display: none;",
                 id = "mblstatscache"),
	    E.TABLE(
                E.CLASS("maintable"),
                E.THEAD(E.TR(E.TD(E.DIV(E.CLASS("mainslogandiv"),
                                        E.SPAN("U2CH"),
                                        E.SPAN("",
                                               style="display: inline-block; width: 5em;"),
                                        E.SPAN("Viewing above imageboards"),
                                        ),
                                  E.DIV(E.CLASS("mainimagediv"),
                                        E.IMG(src="u-2.jpg", style="width:496px;height:334px;"),
                                        ),
                                  )), id = 'header'),
                E.TBODY(E.TR(E.TD(
                    E.HR(E.CLASS("delimeter")),
                    E.DIV(E.CLASS("mblcontainer"),
                          E.DIV(E.CLASS("mblcentering"),
                                initiate.board_cache_main_page,
                                ),
                          ),
                    E.HR(E.CLASS("delimeter")),
                    )), id = 'mainpart'),
                E.TFOOT(E.TR(E.TD(
                    E.DIV('powered by ',
                        E.A('Farlight Imageboard Engine',
                            href='https://github.com/Alpherie/farlight_board_engine',
                            target='_blank',
                            ),
                        id='credentials'),
                    )), id = 'footer'),
                ),
            onload = 'mainpagefunc()'
            )
        )
    return lxml.html.tostring(html)
コード例 #22
0
    def visit_MemoryMap(self, node):
        """Create an HTML file for a MemoryMap."""
        self.title = title = node.name + ' Peripheral Map'
        an = ((node.size - 1).bit_length() + 3) // 4

        # Sweep the document tree to build up the main content
        with self.tempvars(wordwidth=1,
                           address_nibbles=an,
                           base=node.base,
                           subdir=node.name + '_instances',
                           hlev=2):
            children = list(self.visitchildren(node))
            table = E.TABLE(
                E.TR(E.TH('Peripheral'), E.TH('Base Address'), E.TH('Size'),
                     E.TH('Description'), *children), CLASS('component_list'))
            nodes = ([E.H1(title, id='title')] +
                     [E.P(d) for d in node.description] +
                     [E.HR(), table, self.footer(node)])
            contentnode = E.DIV(*nodes, id='content')

        # Add a table of contents sidebar for each table row.
        instlist = E.UL()
        for elem in contentnode.xpath("//td[contains(@class, 'peripheral')]"):
            text = tostring(elem, method="text", encoding="unicode")
            id = escape(text)
            elem.attrib['id'] = id
            node = E.LI(E.A(text, href='#' + id))
            instlist.append(node)

        # And put it all together.
        return E.HTML(
            E.HEAD(
                E.TITLE(title),
                E.LINK(rel='stylesheet',
                       type='text/css',
                       href=htmlpathjoin(self.styledir, 'reg.css'))),
            E.BODY(
                E.DIV(E.DIV(E.P(E.A(title, href='#title')),
                            instlist,
                            id='sidebar'),
                      contentnode,
                      id='wrapper')),
        )
コード例 #23
0
def make_head():
    head = [
        #builder.BASE(href="https://dakovalev1.github.io/my_site/"),
        #builder.BASE(href="http://localhost/my_site/docs/"), # ONLY FOR DEBUG!!!
        #builder.BASE(href=sys.argv[1]),
        builder.META(charset="utf-8"),
        builder.TITLE("Dmitry Kovalev"),
        builder.META(name="viewport",
                     content="width=device-width, initial-scale=1"),
        builder.SCRIPT(
            "",
            type="text/javascript",
            src=
            "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js",
            async="async"),
        builder.SCRIPT(open("src/js/mathjax.js").read(),
                       type="text/x-mathjax-config"),
        builder.SCRIPT(
            "",
            src=
            "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"
        ),
        #builder.SCRIPT("", src="js/jquery.waypoints.min.js"),
        #builder.SCRIPT("", src="js/jquery.scrollTo.min.js"),
        builder.LINK(
            rel="stylesheet",
            href="https://use.fontawesome.com/releases/v5.8.1/css/all.css",
            integrity=
            "sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf",
            crossorigin="anonymous"),
        builder.LINK(
            rel="stylesheet",
            href=
            "https://cdn.rawgit.com/jpswalsh/academicons/master/css/academicons.min.css"
        ),
        builder.LINK(rel="stylesheet", href=base_url + "css/menu.css"),
        builder.LINK(rel="stylesheet", href=base_url + "css/common.css"),
        builder.SCRIPT("", src=base_url + "js/menu.js"),
        builder.SCRIPT("", src=base_url + "js/scroll.js"),
    ]

    return head
コード例 #24
0
ファイル: GetXsltParams.py プロジェクト: NCIOCPL/cdr-admin
def main():
    cursor = db.connect(user="******").cursor()
    query = db.Query("document d", "d.id", "d.title", "d.xml").order(2)
    query.join("doc_type t", "t.id = d.doc_type")
    query.where("t.name = 'Filter'")
    filters = []
    for doc_id, doc_title, doc_xml in query.execute(cursor).fetchall():
        filters.append(Filter(doc_id, doc_title, doc_xml))
    tbody = builder.TBODY()
    caption = builder.CAPTION(TITLE)
    for name in sorted(Parameter.parameters, key=str.lower):
        parm = Parameter.parameters[name]
        parm.add_rows(tbody)
    page = builder.HTML(
        builder.HEAD(
            builder.TITLE(TITLE),
            builder.LINK(rel="stylesheet", href="/stylesheets/cdr.css"),
            builder.STYLE("th { text-align: right; vertical-align: top; }")),
        builder.BODY(builder.TABLE(caption, tbody), builder.CLASS("report")))
    print("Content-type: text/html\n")
    print(etree.tostring(page, pretty_print=True).decode("ascii"))
コード例 #25
0
ファイル: webserver.py プロジェクト: omniti-labs/slim_source
 def manifest_html(self):
     """
     This is manifest.html the human useable form of the manifest.xml
     special object to list needed criteria or return a manifest given a
     set of criteria
     """
     web_page = \
             E.HTML(
                    E.HEAD(
                           E.TITLE(_("%s A/I Webserver -- "
                                     "Maninfest Criteria Test") %
                                     _DISTRIBUTION)
                    ),
                    E.BODY(
                           E.H1(_("Welcome to the %s A/I "
                                  "webserver") % _DISTRIBUTION),
                           E.H2(_("Manifest criteria tester")),
                           E.P(_("To test a system's criteria, all "
                                 "criteria listed are necessary. The "
                                 "format used should be:"),
                               E.BR(),
                               E.TT("criteria1=value1;criteria2=value2"),
                               E.BR(), _("For example:"),
                               E.BR(),
                               E.TT("arch=sun4u;mac=EEE0C0FFEE00;"
                                    "ipv4=172020025012;"
                                    "manufacturer=sun microsystems")
                           ),
                           E.H1(_("Criteria:")),
                           E.P(str(list(AIdb.getCriteria(
                               self.AISQL.getQueue(), strip=True)))),
                           E.FORM(E.INPUT(type="text", name="postData"),
                                  E.INPUT(type="submit"),
                                  action="manifest.xml",
                                  method="POST"
                           )
                    )
             )
     return lxml.etree.tostring(web_page, pretty_print=True)
コード例 #26
0
def main_page_gen():
    html = E.HTML(
        E.HEAD(
            E.LINK(rel="stylesheet", href="/css/deeplight.css", type="text/css"),
            E.TITLE("Administration and moderation")
            ),
        E.BODY(
            E.DIV(
            E.DIV(E.CLASS('logout'), E.A('Logout', href='/admin/logout')),
            E.H2(E.CLASS("heading"), "Admin menu"),
            ),
            E.P(E.CLASS("loginmessage"), "You are logged in"),
            E.DIV(E.CLASS('adminmainmenu'),
                  E.A("create board", href = '?action=create&instance=board'),
                  E.A("manage boards", href = '?action=list&list=boards&purpose=admin'),
                  E.A("manage bans", href = '?action=list&list=bans&purpose=moderator'),
                  E.A("manage users", href = '?action=list&list=users&purpose=admin'),
                  E.A("change password", href = '?action=change&instance=password'),
                  )
            )
        )
    return lxml.html.tostring(html)
コード例 #27
0
async def feeds_html(redis, lid):
    timeline = int(datetime.now().timestamp()) - fv.FEED_NEWS_TIMELINE
    df = await get_latest_news(redis,
                               lid,
                               top=fv.FEED_NEWS_TOP,
                               timeline=timeline)
    html = E.HTML(
        E.HEAD(
            E.META(content='text/html', charset='utf-8'),
            E.LINK(rel='stylesheet', href='../css/style.css', type='text/css'),
            E.TITLE(E.CLASS('title'), f'{ct.GLOBAL_CHANNELS[lid]}实时新闻摘要')))
    body = etree.SubElement(html, 'body')
    logger.debug(
        f'html: {lxml.html.tostring(html, pretty_print=True, encoding="utf-8").decode("utf-8")}'
    )

    news_count = 0
    for row in df.iterrows():
        row = row[1]
        div = etree.SubElement(body, 'div')
        h1 = etree.SubElement(div, 'h1', attrib={'class': 'heading'})
        a = etree.SubElement(h1, 'a', attrib={'href': row['url']})
        a.text = row['title']
        p1 = etree.SubElement(div, 'p', attrib={'class': 'time'})
        p1.text = row['time']
        p2 = etree.SubElement(div, 'p', attrib={'class': 'summary'})
        p2.text = row['summary']
        logger.debug(
            f'Append one news to html body, news: {etree.tostring(div, pretty_print=True, encoding="utf-8").decode("utf-8")}'
        )
        news_count = news_count + 1

    html_file = os.path.join(ct.DAT_DIR, f'{ct.GLOBAL_CHANNELS[lid]}.html')
    logger.info(f'Writing html to file: {html_file}, news count: {news_count}')
    with open(html_file, 'w', encoding='utf-8') as f:
        f.write(
            lxml.html.tostring(html, pretty_print=True,
                               encoding='utf-8').decode('utf-8'))
コード例 #28
0
def feeds_html():
    for lid in ct.GLOBAL_CHANNELS:
        df = get_latest_news(lid)
        html = E.HTML(
            E.HEAD(
                E.META(content='text/html', charset='utf-8'),
                E.LINK(rel='stylesheet', href='../css/style.css', type='text/css'),
                E.TITLE(E.CLASS('title'), f'{ct.GLOBAL_CHANNELS[lid]}实时新闻摘要')
            )
        )
        body = etree.SubElement(html, 'body')
        for row in df.iterrows():
            row = row[1]
            div = etree.SubElement(body, 'div')
            h1 = etree.SubElement(div, 'h1', attrib={'class': 'heading'})
            a = etree.SubElement(h1, 'a', attrib={'href': row['url']})
            a.text = row['title']
            p1 = etree.SubElement(div, 'p', attrib={'class': 'time'})
            p1.text = row['time']
            p2 = etree.SubElement(div, 'p', attrib={'class': 'summary'})
            p2.text = row['summary']
        with open(os.path.join(ct.DAT_DIR, f'{ct.GLOBAL_CHANNELS[lid]}.html'), 'w', encoding='utf-8') as f:
            f.write(lxml.html.tostring(html, pretty_print=True, encoding='utf-8').decode('utf-8'))
コード例 #29
0
ファイル: eatiht_trees.py プロジェクト: yetone/eatiht
    def __make_tree(self):
        """Build a tree using lxml.html.builder and our subtrees"""

        # create div with "container" class
        div = E.DIV(E.CLASS("container"))

        # append header with title
        div.append(E.H2(self.__title))

        # next, iterate through subtrees appending each tree to div
        for subtree in self.__subtrees:
            div.append(subtree.get_html())

        # Connect div to body
        body = E.BODY(div)

        # attach body to html
        self.__htmltree = E.HTML(
            E.HEAD(
                E.TITLE(self.__title)
                ),
            body
            )
コード例 #30
0
 def __init__(self,
              datas,
              title="",
              log_level="ERROR",
              css_path="css/styles.css",
              lang="fr",
              freeze=False):
     """
     Initializing thanks to a JSON (datas)
     HTML document head and body created
     """
     self.__lang = lang
     self.__freeze = freeze
     self.datas = datas
     self.log_level = log_level
     self.__sections = []
     self._html = builder.HTML(
         builder.HEAD(
             builder.META(charset="utf-8"),
             builder.TITLE(title),
             builder.LINK(rel="stylesheet", href=css_path),
         ),
         builder.BODY(builder.DIV(id="text_area")),
     )