当前位置: 首页>>代码示例>>Python>>正文


Python builder.DIV类代码示例

本文整理汇总了Python中lxml.html.builder.DIV的典型用法代码示例。如果您正苦于以下问题:Python DIV类的具体用法?Python DIV怎么用?Python DIV使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DIV类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _generate

    def _generate(self, bottom, feed, art, number_of_articles_in_feed,
                 two_levels, url, __appname__, prefix='', center=True,
                 extra_css=None, style=None):
        head = HEAD(TITLE('navbar'))
        if style:
            head.append(STYLE(style, type='text/css'))
        if extra_css:
            head.append(STYLE(extra_css, type='text/css'))

        navbar = DIV()
        navbar_t = TABLE(CLASS('touchscreen_navbar'))
        navbar_tr = TR()

        if bottom and not url.startswith('file://'):
            navbar.append(HR())
            text = 'This article was downloaded by '
            p = PT(text, STRONG(__appname__), A(url, href=url, rel='calibre-downloaded-from'),
                    style='text-align:left; max-width: 100%; overflow: hidden;')
            p[0].tail = ' from '
            navbar.append(p)
            navbar.append(BR())
        # | Previous
        if art > 0:
            link = A(CLASS('article_link'),_('Previous'),href='%s../article_%d/index.html'%(prefix, art-1))
            navbar_tr.append(TD(CLASS('article_prev'),link))
        else:
            navbar_tr.append(TD(CLASS('article_prev'),''))

        # | Articles | Sections |
        link = A(CLASS('articles_link'),_('Articles'), href='%s../index.html#article_%d'%(prefix, art))
        navbar_tr.append(TD(CLASS('article_articles_list'),link))

        link = A(CLASS('sections_link'),_('Sections'), href='%s../../index.html#feed_%d'%(prefix, feed))
        navbar_tr.append(TD(CLASS('article_sections_list'),link))

        # | Next
        next_art = 'feed_%d'%(feed+1) if art == number_of_articles_in_feed - 1 \
                else 'article_%d'%(art+1)
        up = '../..' if art == number_of_articles_in_feed - 1 else '..'

        link = A(CLASS('article_link'), _('Next'), href='%s%s/%s/index.html'%(prefix, up, next_art))
        navbar_tr.append(TD(CLASS('article_next'),link))
        navbar_t.append(navbar_tr)
        navbar.append(navbar_t)
        # print "\n%s\n" % etree.tostring(navbar, pretty_print=True)

        self.root = HTML(head, BODY(navbar))
开发者ID:JimmXinu,项目名称:calibre,代码行数:47,代码来源:templates.py

示例2: build_search_box

def build_search_box(num, search, sort, order, prefix): # {{{
    div = DIV(id='search_box')
    form = FORM('Show ', method='get', action=prefix+'/mobile')
    form.set('accept-charset', 'UTF-8')

    div.append(form)

    num_select = SELECT(name='num')
    for option in (5, 10, 25, 100):
        kwargs = {'value':str(option)}
        if option == num:
            kwargs['SELECTED'] = 'SELECTED'
        num_select.append(OPTION(str(option), **kwargs))
    num_select.tail = ' books matching '
    form.append(num_select)

    searchf = INPUT(name='search', id='s', value=search if search else '')
    searchf.tail = ' sorted by '
    form.append(searchf)

    sort_select = SELECT(name='sort')
    for option in ('date','author','title','rating','size','tags','series'):
        kwargs = {'value':option}
        if option == sort:
            kwargs['SELECTED'] = 'SELECTED'
        sort_select.append(OPTION(option, **kwargs))
    form.append(sort_select)

    order_select = SELECT(name='order')
    for option in ('ascending','descending'):
        kwargs = {'value':option}
        if option == order:
            kwargs['SELECTED'] = 'SELECTED'
        order_select.append(OPTION(option, **kwargs))
    form.append(order_select)

    form.append(INPUT(id='go', type='submit', value='Search'))

    return div
开发者ID:BobPyron,项目名称:calibre,代码行数:39,代码来源:mobile.py

示例3: build_search_box

def build_search_box(num, search, sort, order, prefix):  # {{{
    div = DIV(id="search_box")
    form = FORM("Show ", method="get", action=prefix + "/mobile")
    form.set("accept-charset", "UTF-8")

    div.append(form)

    num_select = SELECT(name="num")
    for option in (5, 10, 25, 100):
        kwargs = {"value": str(option)}
        if option == num:
            kwargs["SELECTED"] = "SELECTED"
        num_select.append(OPTION(str(option), **kwargs))
    num_select.tail = " books matching "
    form.append(num_select)

    searchf = INPUT(name="search", id="s", value=search if search else "")
    searchf.tail = " sorted by "
    form.append(searchf)

    sort_select = SELECT(name="sort")
    for option in ("date", "author", "title", "rating", "size", "tags", "series"):
        kwargs = {"value": option}
        if option == sort:
            kwargs["SELECTED"] = "SELECTED"
        sort_select.append(OPTION(option, **kwargs))
    form.append(sort_select)

    order_select = SELECT(name="order")
    for option in ("ascending", "descending"):
        kwargs = {"value": option}
        if option == order:
            kwargs["SELECTED"] = "SELECTED"
        order_select.append(OPTION(option, **kwargs))
    form.append(order_select)

    form.append(INPUT(id="go", type="submit", value="Search"))

    return div
开发者ID:Xliff,项目名称:calibre,代码行数:39,代码来源:mobile.py

示例4: _generate

    def _generate(self, bottom, feed, art, number_of_articles_in_feed,
                 two_levels, url, __appname__, prefix='', center=True,
                 extra_css=None, style=None):
        head = HEAD(TITLE('navbar'))
        if style:
            head.append(STYLE(style, type='text/css'))
        if extra_css:
            head.append(STYLE(extra_css, type='text/css'))

        navbar = DIV()
        navbar_t = TABLE(CLASS('touchscreen_navbar'))
        navbar_tr = TR()

        # | Previous
        if art > 0:
            link = A(CLASS('article_link'),_('Previous'),href='%s../article_%d/index.html'%(prefix, art-1))
            navbar_tr.append(TD(CLASS('article_prev'),link))
        else:
            navbar_tr.append(TD(CLASS('article_prev'),''))

        # | Articles | Sections |
        link = A(CLASS('articles_link'),_('Articles'), href='%s../index.html#article_%d'%(prefix, art))
        navbar_tr.append(TD(CLASS('article_articles_list'),link))

        link = A(CLASS('sections_link'),_('Sections'), href='%s../../index.html#feed_%d'%(prefix, feed))
        navbar_tr.append(TD(CLASS('article_sections_list'),link))

        # | Next
        next = 'feed_%d'%(feed+1) if art == number_of_articles_in_feed - 1 \
                else 'article_%d'%(art+1)
        up = '../..' if art == number_of_articles_in_feed - 1 else '..'

        link = A(CLASS('article_link'), _('Next'), href='%s%s/%s/index.html'%(prefix, up, next))
        navbar_tr.append(TD(CLASS('article_next'),link))
        navbar_t.append(navbar_tr)
        navbar.append(navbar_t)
        #print "\n%s\n" % etree.tostring(navbar, pretty_print=True)

        self.root = HTML(head, BODY(navbar))
开发者ID:BobPyron,项目名称:calibre,代码行数:39,代码来源:templates.py

示例5: set_custom_embed_code

    def set_custom_embed_code(self, data):
        """ Return the code that embed the code. Could be with the
            original size or the custom chosen.
        """
        if 'embed_html' not in data:
            return
        tree = etree.HTML(data['embed_html'])
        sel = cssselect.CSSSelector('body > *')
        el = sel(tree)
        # add a div around if there is more than one element into code
        if len(el) > 1:
            el = DIV(*el)
        else:
            el = el[0]

        # width and height attributes should not be set in a div tag
        if el.tag in ['iframe', 'object']:
            if data.get('width', None):
                el.attrib['width'] = data['width'] and str(data['width']) or el.attrib['width']
            if data.get('height', None):
                el.attrib['height'] = data['height'] and str(data['height']) or el.attrib['height']

        data['embed_html'] = html.tostring(el)
开发者ID:abstract-open-solutions,项目名称:sc.embedder,代码行数:23,代码来源:embedder.py

示例6: _generate

    def _generate(
        self,
        bottom,
        feed,
        art,
        number_of_articles_in_feed,
        two_levels,
        url,
        __appname__,
        prefix="",
        center=True,
        extra_css=None,
        style=None,
    ):
        head = HEAD(TITLE("navbar"))
        if style:
            head.append(STYLE(style, type="text/css"))
        if extra_css:
            head.append(STYLE(extra_css, type="text/css"))

        navbar = DIV()
        navbar_t = TABLE(CLASS("touchscreen_navbar"))
        navbar_tr = TR()

        if bottom and not url.startswith("file://"):
            navbar.append(HR())
            text = "This article was downloaded by "
            p = PT(
                text,
                STRONG(__appname__),
                A(url, href=url, rel="calibre-downloaded-from"),
                style="text-align:left; max-width: 100%; overflow: hidden;",
            )
            p[0].tail = " from "
            navbar.append(p)
            navbar.append(BR())
        # | Previous
        if art > 0:
            link = A(CLASS("article_link"), _("Previous"), href="%s../article_%d/index.html" % (prefix, art - 1))
            navbar_tr.append(TD(CLASS("article_prev"), link))
        else:
            navbar_tr.append(TD(CLASS("article_prev"), ""))

        # | Articles | Sections |
        link = A(CLASS("articles_link"), _("Articles"), href="%s../index.html#article_%d" % (prefix, art))
        navbar_tr.append(TD(CLASS("article_articles_list"), link))

        link = A(CLASS("sections_link"), _("Sections"), href="%s../../index.html#feed_%d" % (prefix, feed))
        navbar_tr.append(TD(CLASS("article_sections_list"), link))

        # | Next
        next = "feed_%d" % (feed + 1) if art == number_of_articles_in_feed - 1 else "article_%d" % (art + 1)
        up = "../.." if art == number_of_articles_in_feed - 1 else ".."

        link = A(CLASS("article_link"), _("Next"), href="%s%s/%s/index.html" % (prefix, up, next))
        navbar_tr.append(TD(CLASS("article_next"), link))
        navbar_t.append(navbar_tr)
        navbar.append(navbar_t)
        # print "\n%s\n" % etree.tostring(navbar, pretty_print=True)

        self.root = HTML(head, BODY(navbar))
开发者ID:JapaChin,项目名称:calibre,代码行数:61,代码来源:templates.py

示例7: get_navbar

    def get_navbar(self, f, feeds, top=True):
        if len(feeds) < 2:
            return DIV()
        navbar = DIV("| ", CLASS("calibre_navbar", "calibre_rescale_70", style="text-align:center"))
        if not top:
            hr = HR()
            navbar.append(hr)
            navbar.text = None
            hr.tail = "| "

        if f + 1 < len(feeds):
            link = A(_("Next section"), href="../feed_%d/index.html" % (f + 1))
            link.tail = " | "
            navbar.append(link)
        link = A(_("Main menu"), href="../index.html")
        link.tail = " | "
        navbar.append(link)
        if f > 0:
            link = A(_("Previous section"), href="../feed_%d/index.html" % (f - 1))
            link.tail = " |"
            navbar.append(link)
        if top:
            navbar.append(HR())
        return navbar
开发者ID:JapaChin,项目名称:calibre,代码行数:24,代码来源:templates.py

示例8: get_navbar

    def get_navbar(self, f, feeds, top=True):
        if len(feeds) < 2:
            return DIV()
        navbar = DIV('| ', CLASS('calibre_navbar', 'calibre_rescale_70',
            style='text-align:center'))
        if not top:
            hr = HR()
            navbar.append(hr)
            navbar.text = None
            hr.tail = '| '

        if f+1 < len(feeds):
            link = A(_('Next section'), href='../feed_%d/index.html'%(f+1))
            link.tail = ' | '
            navbar.append(link)
        link = A(_('Main menu'), href="../index.html")
        link.tail = ' | '
        navbar.append(link)
        if f > 0:
            link = A(_('Previous section'), href='../feed_%d/index.html'%(f-1))
            link.tail = ' |'
            navbar.append(link)
        if top:
            navbar.append(HR())
        return navbar
开发者ID:JimmXinu,项目名称:calibre,代码行数:25,代码来源:templates.py

示例9: build_index

def build_index(books, num, search, sort, order, start, total, url_base, CKEYS,
        prefix):
    logo = DIV(IMG(src=prefix+'/static/calibre.png', alt=__appname__), id='logo')

    search_box = build_search_box(num, search, sort, order, prefix)
    navigation = build_navigation(start, num, total, prefix+url_base)
    navigation2 = build_navigation(start, num, total, prefix+url_base)
    bookt = TABLE(id='listing')

    body = BODY(
        logo,
        search_box,
        navigation,
        HR(CLASS('spacer')),
        bookt,
        HR(CLASS('spacer')),
        navigation2
    )

    # Book list {{{
    for book in books:
        thumbnail = TD(
                IMG(type='image/jpeg', border='0',
                    src=prefix+'/get/thumb/%s' %
                            book['id']),
                CLASS('thumbnail'))

        data = TD()
        for fmt in book['formats'].split(','):
            if not fmt or fmt.lower().startswith('original_'):
                continue
            a = quote(ascii_filename(book['authors']))
            t = quote(ascii_filename(book['title']))
            s = SPAN(
                A(
                    fmt.lower(),
                    href=prefix+'/get/%s/%s-%s_%d.%s' % (fmt, a, t,
                        book['id'], fmt.lower())
                ),
                CLASS('button'))
            s.tail = u''
            data.append(s)

        div = DIV(CLASS('data-container'))
        data.append(div)

        series = u'[%s - %s]'%(book['series'], book['series_index']) \
                if book['series'] else ''
        tags = u'Tags=[%s]'%book['tags'] if book['tags'] else ''

        ctext = ''
        for key in CKEYS:
            val = book.get(key, None)
            if val:
                ctext += '%s=[%s] '%tuple(val.split(':#:'))

        first = SPAN(u'\u202f%s %s by %s' % (book['title'], series,
            book['authors']), CLASS('first-line'))
        div.append(first)
        second = SPAN(u'%s - %s %s %s' % ( book['size'],
            book['timestamp'],
            tags, ctext), CLASS('second-line'))
        div.append(second)

        bookt.append(TR(thumbnail, data))
    # }}}

    body.append(DIV(
        A(_('Switch to the full interface (non-mobile interface)'),
            href=prefix+"/browse",
            style="text-decoration: none; color: blue",
            title=_('The full interface gives you many more features, '
                'but it may not work well on a small screen')),
        style="text-align:center"))
    return HTML(
        HEAD(
            TITLE(__appname__ + ' Library'),
            LINK(rel='icon', href='http://calibre-ebook.com/favicon.ico',
                type='image/x-icon'),
            LINK(rel='stylesheet', type='text/css',
                href=prefix+'/mobile/style.css'),
            LINK(rel='apple-touch-icon', href="/static/calibre.png")
        ), # End head
        body
    ) # End html
开发者ID:BobPyron,项目名称:calibre,代码行数:85,代码来源:mobile.py

示例10: build_index

def build_index(books, num, search, sort, order, start, total, url_base, CKEYS, prefix, have_kobo_browser=False):
    logo = DIV(IMG(src=prefix + "/static/calibre.png", alt=__appname__), id="logo")

    search_box = build_search_box(num, search, sort, order, prefix)
    navigation = build_navigation(start, num, total, prefix + url_base)
    navigation2 = build_navigation(start, num, total, prefix + url_base)
    bookt = TABLE(id="listing")

    body = BODY(logo, search_box, navigation, HR(CLASS("spacer")), bookt, HR(CLASS("spacer")), navigation2)

    # Book list {{{
    for book in books:
        thumbnail = TD(
            IMG(type="image/jpeg", border="0", src=prefix + "/get/thumb/%s" % book["id"]), CLASS("thumbnail")
        )

        data = TD()
        for fmt in book["formats"].split(","):
            if not fmt or fmt.lower().startswith("original_"):
                continue
            file_extension = "kepub.epub" if have_kobo_browser and fmt.lower() == "kepub" else fmt
            a = quote(ascii_filename(book["authors"]))
            t = quote(ascii_filename(book["title"]))
            s = SPAN(
                A(fmt.lower(), href=prefix + "/get/%s/%s-%s_%d.%s" % (fmt, a, t, book["id"], file_extension.lower())),
                CLASS("button"),
            )
            s.tail = u""
            data.append(s)

        div = DIV(CLASS("data-container"))
        data.append(div)

        series = u"[%s - %s]" % (book["series"], book["series_index"]) if book["series"] else ""
        tags = u"Tags=[%s]" % book["tags"] if book["tags"] else ""

        ctext = ""
        for key in CKEYS:
            val = book.get(key, None)
            if val:
                ctext += "%s=[%s] " % tuple(val.split(":#:"))

        first = SPAN(
            u"\u202f%s %s by %s"
            % (clean_xml_chars(book["title"]), clean_xml_chars(series), clean_xml_chars(book["authors"])),
            CLASS("first-line"),
        )
        div.append(first)
        second = SPAN(u"%s - %s %s %s" % (book["size"], book["timestamp"], tags, ctext), CLASS("second-line"))
        div.append(second)

        bookt.append(TR(thumbnail, data))
    # }}}

    body.append(
        DIV(
            A(
                _("Switch to the full interface (non-mobile interface)"),
                href=prefix + "/browse",
                style="text-decoration: none; color: blue",
                title=_(
                    "The full interface gives you many more features, " "but it may not work well on a small screen"
                ),
            ),
            style="text-align:center",
        )
    )
    return HTML(
        HEAD(
            TITLE(__appname__ + " Library"),
            LINK(rel="icon", href="//calibre-ebook.com/favicon.ico", type="image/x-icon"),
            LINK(rel="stylesheet", type="text/css", href=prefix + "/mobile/style.css"),
            LINK(rel="apple-touch-icon", href="/static/calibre.png"),
            META(name="robots", content="noindex"),
        ),  # End head
        body,
    )  # End html
开发者ID:Xliff,项目名称:calibre,代码行数:77,代码来源:mobile.py


注:本文中的lxml.html.builder.DIV类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。