Esempio n. 1
0
def _cite_elem_to_html(elem, ctx):
    _piece_to_html(elem.info, ctx)
    quote = elem.content
    if quote:
        H.span(u': ')
        with H.q():
            _piece_to_html(quote, ctx)
Esempio n. 2
0
    def visit_Navbar(self, node):
        node_id = self.id or sha1(str(id(node)).encode()).hexdigest()

        root = tags.nav() if self.html5 else tags.div(role='navigation')
        root['class'] = 'navbar navbar-inverse navbar-fixed-top'

        cont = root.add(tags.div(_class='container'))

        # collapse button
        header = cont.add(tags.div(_class='navbar-header'))
        btn = header.add(tags.button(**{'type': 'button', 'class': 'navbar-toggle collapsed', 'data-toggle': 'collapse',
                                        'data-target': '#' + node_id, 'aria-expanded': 'false',
                                        'aria-controls': 'navbar'}))

        btn.add(tags.span('Toggle navigation', _class='sr-only'))
        btn.add(tags.span(_class='icon-bar'))
        btn.add(tags.span(_class='icon-bar'))
        btn.add(tags.span(_class='icon-bar'))

        # title may also have a 'get_url()' method, in which case we render
        # a brand-link
        if node.title is not None:
            if hasattr(node.title, 'get_url'):
                header.add(tags.a(node.title.text, _class='navbar-brand', href=node.title.get_url()))
            else:
                header.add(tags.span(node.title, _class='navbar-brand'))

        bar = cont.add(tags.div(_class='navbar-collapse collapse', id=node_id))

        for item in node.items:
            bar.add(self.visit(item))

        return root
Esempio n. 3
0
def Page():
    doc = document()
    with doc.head:
        link_("https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css")
        link_("https://extra-uru1z3cxu.now.sh/css/extra.css")
        link_(
            "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.css"
        )
        script_(
            'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js'
        )
        script_('http://intercoolerjs.org/release/intercooler-1.2.2.js')
    with doc.body:
        with dom.div(cls=CENTER_FRAME) as CenterFrame:
            with dom.div(cls=CARD) as Card:
                with dom.form(UPLOAD_FORM_ATTRS) as UploadForm:
                    dom.i(cls=UPLOAD_ICON,
                          onclick='''$('#fileupload').click()''')
                    dom.p("Find File", id=1, cls="text-gray-500 mt-4")
                    dom.button("Upload", type="submit", cls=BUTTON)
                    dom.input(
                        cls="hidden",
                        type="file",
                        name="image",
                        id="fileupload",
                        onchange=
                        '''$('#1').text(this.value.split("\\\\").pop(-1))''')
            with dom.div(id="there", cls=RESULT_CONTAINER) as ResultContainer:
                dom.span(id="here")  #新增
    return doc.render()
Esempio n. 4
0
    def visit_Subgroup(self, node):
        if not self._in_dropdown:
            li = tags.li(_class='dropdown')
            if node.active:
                li['class'] = 'active'
            a = li.add(tags.a(href='#', _class='dropdown-toggle'))
            if node.icon is not None:
                a.add(tags.i(_class=str(node.icon)))
                a.add(tags.span(node.title))
            else:
                a.add_raw_string(node.title)
            a['data-toggle'] = 'dropdown'
            a['role'] = 'button'
            a['aria-haspopup'] = 'true'
            a['aria-expanded'] = 'false'
            a.add(tags.span(_class='caret'))

            ul = li.add(tags.ul(_class='dropdown-menu'))

            self._in_dropdown = True
            for item in node.items:
                ul.add(self.visit(item))
            self._in_dropdown = False

            return li
        else:
            raise RuntimeError('Cannot render nested Subgroups')
Esempio n. 5
0
def _render_annotated(pieces):
    for piece in pieces:
        if isinstance(piece, bytes):
            H.span(printable(piece.decode('iso-8859-1')))
        else:
            with H.span(**_for_object(piece)):
                _render_known(piece)
Esempio n. 6
0
    def __get__(self, obj: Table, objtype: Any = None) -> html_tag:
        total = span(obj.total_rows, data_table_target="total")
        desc = div(total, span(" results"), _class="text-gray-500")

        button_class = (
            "relative inline-flex items-center px-2 py-1 border border-gray-200"
            " bg-white text-gray-500 hover:bg-gray-50 focus:outline-none"
        )
        first_button = button(
            IconFirstPage().to_tag(),
            data_action="click->table#firstPage",
            _class=button_class + " rounded-l",
        )
        prev_button = button(
            IconPreviousPage().to_tag(),
            data_action="click->table#previousPage",
            _class=button_class,
        )
        next_button = button(
            IconNextPage().to_tag(),
            data_action="click->table#nextPage",
            _class=button_class,
        )
        last_button = button(
            IconLastPage().to_tag(),
            data_action="click->table#lastPage",
            _class=button_class + " rounded-r",
        )
        class_ = "relative z-0 inline-flex shadow-sm -space-x-px"
        buttons = nav(first_button, prev_button, next_button, last_button, _class=class_)

        class_ = "flex justify-between items-center px-2 py-2"
        div_ = div(desc, buttons, _class=class_)
        return div_
Esempio n. 7
0
def _cite_elem_to_html(elem, ctx):
    _piece_to_html(elem.info, ctx)
    quote = elem.content
    if quote:
        H.span(u': ', __inline=True)
        with H.q(__inline=True):
            _piece_to_html(quote, ctx)
def get_alg_filter_buttons_div(r, tab_names):
    alg_filter_buttons_div = div(cls="container")

    alg_input_tag = input(id="ground_truth_CB", cls="badgebox")
    alg_input_tag.attributes['type'] = "checkbox"
    alg_span_tag = span("✓", cls="badge", id="ground_truth_CB_Span")

    alg_filter_button = label("Ground Truth",
                              cls="btn",
                              id="ground_truth_CB_Label")
    alg_filter_button.appendChild(alg_input_tag)
    alg_filter_button.appendChild(alg_span_tag)
    alg_filter_buttons_div.appendChild(alg_filter_button)

    for count in range(len(tab_names)):
        alg_input_tag = input(id=tab_names[count] + "_CB", cls="badgebox")
        alg_input_tag.attributes['type'] = "checkbox"
        alg_span_tag = span("✓", cls="badge", id=tab_names[count] + "_CB_Span")

        alg_filter_button = label(tab_names[count],
                                  cls="btn",
                                  id=tab_names[count] + "_CB_Label")
        alg_filter_button.appendChild(alg_input_tag)
        alg_filter_button.appendChild(alg_span_tag)

        alg_filter_buttons_div.appendChild(alg_filter_button)
    return alg_filter_buttons_div.render()
Esempio n. 9
0
def _render_header_entries(annotated_entries):
    for entry, annotated in annotated_entries:
        with H.pre(**_for_object(entry, 'header-entry')), H.code():
            # Dominate defaults to ``__pretty=False`` for ``pre``.
            _render_known(entry.name)
            H.span(u': ')
            _render_annotated(annotated)
Esempio n. 10
0
def _cite_elem_to_html(elem, ctx):
    _piece_to_html(elem.info, ctx)
    quote = elem.content
    if quote:
        H.span(u': ')
        with H.q():
            _piece_to_html(quote, ctx)
Esempio n. 11
0
    def get_html_forms(self, datatset_name_form=True):
        """generates html forms for all the metadata elements associated with this logical file
        type
        :param datatset_name_form If True then a form for editing dataset_name (title) attribute is
        included
        """
        root_div = div()

        with root_div:
            if datatset_name_form:
                self._get_dataset_name_form()

            keywords_div = div(cls="col-sm-12 content-block",
                               id="filetype-keywords")
            action = "/hsapi/_internal/{0}/{1}/add-file-keyword-metadata/"
            action = action.format(self.logical_file.__class__.__name__,
                                   self.logical_file.id)
            delete_action = "/hsapi/_internal/{0}/{1}/delete-file-keyword-metadata/"
            delete_action = delete_action.format(
                self.logical_file.__class__.__name__, self.logical_file.id)
            with keywords_div:
                legend("Keywords")
                with form(id="id-keywords-filetype",
                          action=action,
                          method="post",
                          enctype="multipart/form-data"):

                    input(id="id-delete-keyword-filetype-action",
                          type="hidden",
                          value=delete_action)
                    with div(cls="tags"):
                        with div(id="add-keyword-wrapper", cls="input-group"):
                            input(id="txt-keyword-filetype",
                                  cls="form-control",
                                  placeholder="keyword",
                                  type="text",
                                  name="keywords")
                            with span(cls="input-group-btn"):
                                a("Add",
                                  id="btn-add-keyword-filetype",
                                  cls="btn btn-success",
                                  type="button")
                    with ul(id="lst-tags-filetype",
                            cls="custom-well tag-list"):
                        for kw in self.keywords:
                            with li(cls="tag"):
                                span(kw)
                                with a():
                                    span(
                                        cls=
                                        "glyphicon glyphicon-remove-circle icon-remove"
                                    )
                p("Duplicate. Keywords not added.",
                  id="id-keywords-filetype-msg",
                  cls="text-danger small",
                  style="display: none;")

            self.get_extra_metadata_html_form()
            self.get_temporal_coverage_html_form()
        return root_div
Esempio n. 12
0
    def format(trait, objs, *args, **kwargs) -> Htmlish:
        # TODO would be nice to have spinboard imported here for type checking..
        res = T.div(cls='pinboard')

        title = trait.title(objs)
        link = trait.link(objs)
        res.add(T.div(T.a(title, href=link)))

        with adhoc_html('pinboard', cb=lambda children: res.add(*children)):
            with T.table():
                for _, obj in objs:
                    if not isempty(obj.description):
                        with T.tr():
                            with T.td(colspan=3):
                                T.span(obj.description, cls='description')
                    with T.tr():
                        # TODO wtf is min??
                        with T.td(cls='min'):
                            T.a(f'{fdate(obj.when)}',
                                href=obj.blink,
                                cls='permalink timestamp')
                        with T.td(cls='min'):
                            text('by ')
                            trait.user_link(user=obj.user)
                        with T.td():
                            for t in obj.ntags:
                                trait.tag_link(tag=t, user=obj.user)
        # TODO userstats
        return res
Esempio n. 13
0
def _render_header_entries(annotated_entries):
    for entry, annotated in annotated_entries:
        with H.pre(**_for_object(entry, 'header-entry')), H.code():
            # Dominate defaults to ``__pretty=False`` for ``pre``.
            _render_known(entry.name)
            H.span(u': ')
            _render_annotated(annotated)
Esempio n. 14
0
def page():
    doc = document()
    with doc.head:
        link_("https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css")
        link_("https://extra-uru1z3cxu.now.sh/css/extra.css")
        link_("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.css")
        script_("https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js")
        script_("http://intercoolerjs.org/release/intercooler-1.2.2.js")

    with doc.body:
        with dom.div(cls=CENTER_FRAME) as CenterFrame:
            with dom.form(FORM_ATTR):
                with dom.div(cls=LABEL_CARD):
                    dom.label('Write down your mark here',
                              cls="text-white text-xl")
                    dom.input(
                        cls=LABEL_INPUT, type='text', placeholder='your watermark text here', name='mk-text')
                with dom.div(cls=IMG_CARD):
                    with dom.div(cls=IMG_FORM):
                        dom.i(cls=UPLOAD_ICON,
                              onclick='''$('#fileupload').click()''')
                        dom.p("Find File", id="file", cls="text-gray-500 mt-4")
                        dom.input(cls="hidden", type="file", name='bg-img', id="fileupload",
                                  onchange='''$('#file').text(this.value.split("\\\\").pop(-1))''')
                        dom.button('Upload', cls=BUTTON, type='submit')

            with dom.div(cls=RESULT_CONTAINER, id="there") as ResultContainer:
                dom.span(id="here")
    return doc.render()
Esempio n. 15
0
def open_html_doc(name, letter=None):
    html_doc = dominate.document(title=u"מילון הראיה")
    html_doc['dir'] = 'rtl'
    with html_doc.head:
        with tags.meta():
            tags.attr(charset="utf-8")
        with tags.meta():
            tags.attr(name="viewport", content="width=device-width, initial-scale=1")

        tags.script(src="jquery/dist/jquery.min.js")
        tags.link(rel='stylesheet', href='bootstrap-3.3.6-dist/css/bootstrap.min.css')
        tags.link(rel='stylesheet', href='style.css')
        tags.script(src="bootstrap-3.3.6-dist/js/bootstrap.min.js")
        tags.link(rel='stylesheet', href="bootstrap-rtl-3.3.4/dist/css/bootstrap-rtl.css")
        tags.link(rel='stylesheet', href='html_demos-gh-pages/footnotes.css')
        tags.script(src="milon.js")
        tags.script(src="html_demos-gh-pages/footnotes.js")
        tags.script(src="subjects_db.json")




    html_doc.footnote_ids_of_this_html_doc = []
    html_doc.name = name
    if letter:
        html_doc.letter = letter
        html_doc.section = html_docs_l[-1].section
    else:
        html_doc.section = name

    html_doc.index = len(html_docs_l) + 1
    with html_doc.body:
        with tags.div():
            tags.attr(cls="container-fluid")
            # TODO: call page_loaded to update saved URL also in other links
            tags.script("page_loaded('%s.html')" % html_doc.index)

            with tags.div():
                tags.attr(cls="fixed_top_left", id="menu_bar")
                with tags.div():
                    with tags.button(type="button"):
                        tags.attr(id="search_icon_button", type="button", cls="btn btn-default")
                        with tags.span():
                            tags.attr(cls="glyphicon glyphicon-search")
                    with tags.span():
                        tags.attr(cls="dropdown")
                        with tags.button(type="button", cls="btn btn-primary") as b:
                            tags.attr(href="#") #, cls="dropdown-toggle")
                            with tags.span():
                                tags.attr(cls="glyphicon glyphicon-menu-hamburger")
                                # b['data-toggle'] = "dropdown"
                        with tags.ul():
                            tags.attr(cls="dropdown-menu dropdown-menu-left scrollable-menu")





    return html_doc
Esempio n. 16
0
def _render_annotated(pieces):
    """Render an annotated string as produced by :mod:`httpolice.parse`."""
    for piece in pieces:
        if isinstance(piece, bytes):
            H.span(printable(piece.decode('iso-8859-1')))
        else:
            with H.span(**_for_object(piece)):
                _render_known(piece)
Esempio n. 17
0
            def visit_Navbar(self, node):
                # create a navbar id that is somewhat fixed, but do not leak any
                # information about memory contents to the outside
                node_id = self.id or sha1(str(id(node)).encode()).hexdigest()

                root = tags.nav() if self.html5 else tags.div(
                    role='navigation')
                root['class'] = 'navbar navbar-default'

                cont = root.add(tags.div(_class='container-fluid'))

                # collapse button
                header = cont.add(tags.div(_class='navbar-header'))
                btn = header.add(tags.button())
                btn['type'] = 'button'
                btn['class'] = 'navbar-toggle collapsed'
                btn['data-toggle'] = 'collapse'
                btn['data-target'] = '#' + node_id
                btn['aria-expanded'] = 'false'
                btn['aria-controls'] = 'navbar'

                btn.add(tags.span('Toggle navigation', _class='sr-only'))
                btn.add(tags.span(_class='icon-bar'))
                btn.add(tags.span(_class='icon-bar'))
                btn.add(tags.span(_class='icon-bar'))

                # title may also have a 'get_url()' method, in which case we render
                # a brand-link
                if node.title is not None:
                    if hasattr(node.title, 'get_url'):
                        header.add(
                            tags.a(node.title.text,
                                   _class='navbar-brand',
                                   href=node.title.get_url()))
                    else:
                        header.add(tags.span(node.title,
                                             _class='navbar-brand'))

                bar = cont.add(
                    tags.div(
                        _class='navbar-collapse collapse',
                        id=node_id,
                    ))
                bar_list = bar.add(tags.ul(_class='nav navbar-nav'))
                bar_list_right = bar.add(
                    tags.ul(_class='nav navbar-nav navbar-right'))

                to_right = False
                for item in node.items:
                    if isinstance(item, SeparatorAlign):
                        to_right = True
                        continue
                    if not to_right:
                        bar_list.add(self.visit(item))
                    else:
                        bar_list_right.add(self.visit(item))

                return root
Esempio n. 18
0
 def visitRepeat(self, ctx: TacticNotationsParser.RepeatContext):
     with tags.span(_class="repeat-wrapper"):
         with tags.span(_class="repeat"):
             self.visitChildren(ctx)
         repeat_marker = ctx.LGROUP().getText()[1]
         separator = ctx.ATOM()
         tags.sup(repeat_marker)
         if separator:
             tags.sub(separator.getText())
Esempio n. 19
0
def memberships_pretablehtml():
    pretablehtml = div()
    with pretablehtml:
        # hide / show hidden rows
        with filtercontainerdiv(style='margin-bottom: 4px;'):
            cachetime = TableUpdateTime.query.filter_by(
                interest=localinterest(), tablename='member').one().lastchecked
            span(f'(last update time {cachet.dt2asc(cachetime)})')
    return pretablehtml.render()
Esempio n. 20
0
 def visitRepeat(self, ctx:TacticNotationsParser.RepeatContext):
     with tags.span(_class="repeat-wrapper"):
         with tags.span(_class="repeat"):
             self.visitChildren(ctx)
         repeat_marker = ctx.LGROUP().getText()[1]
         separator = ctx.ATOM()
         tags.sup(repeat_marker)
         if separator:
             tags.sub(separator.getText())
Esempio n. 21
0
 def visit_Navbar(self, node):
     nav = tags.nav(cls="navbar navbar-expand-lg navbar-dark bg-primary")
     with nav:
         tags.span(node.title, cls="navbar-brand")
         with tags.div(id='navbarColor01', cls="collapse navbar-collapse"):
             with tags.ul(cls='navbar-nav mr-auto'):
                 for item in node.items:
                     tags.li(self.visit(item))
     return nav
Esempio n. 22
0
def _render_header_entries(annotated_entries):
    for entry, annotated in annotated_entries:
        with H.pre(**_for_object(entry, 'header-entry')), H.code():
            # Dominate (at least as of 2.2.0)
            # automatically inlines all descendants of ``pre``.
            # https://github.com/Knio/dominate/issues/68
            _render_known(entry.name)
            H.span(u': ')
            _render_annotated(annotated)
Esempio n. 23
0
    def visit_Navbar(self, node):
        # create a navbar id that is somewhat fixed, but do not leak any
        # information about memory contents to the outside
        node_id = self.id or sha1(str(id(node)).encode()).hexdigest()

        root = tags.nav() if self.html5 else tags.div(role='navigation')
        root_class = 'navbar navbar-inverse' if node.navbar_inverse else 'navbar navbar-default'
        if node.navbar_fixed == 'top':
            root_class += ' navbar-fixed-top'
        elif node.navbar_fixed == 'bottom':
            root_class += ' navbar-fixed-bottom'
        root['class'] = root_class

        cont = root.add(tags.div(_class='container-fluid'))

        # collapse button
        header = cont.add(tags.div(_class='navbar-header'))
        btn = header.add(tags.button())
        btn['type'] = 'button'
        btn['class'] = 'navbar-toggle collapsed'
        btn['data-toggle'] = 'collapse'
        btn['data-target'] = '#' + node_id
        btn['aria-expanded'] = 'false'
        btn['aria-controls'] = 'navbar'

        btn.add(tags.span('Toggle navigation', _class='sr-only'))
        btn.add(tags.span(_class='icon-bar'))
        btn.add(tags.span(_class='icon-bar'))
        btn.add(tags.span(_class='icon-bar'))

        # add a custom _class `navbar-logo` to adjust logo image
        if node.logo_filename is not None:
            logo_a = tags.a(_class='navbar-left navbar-logo')
            logo_a.add(tags.img(src=node.get_logo_file_url()))
            header.add(logo_a)

        # title may also have a 'get_url()' method, in which case we render
        # a brand-link
        if node.title is not None:
            if hasattr(node.title, 'get_url'):
                header.add(
                    tags.a(node.title.text,
                           _class='navbar-brand',
                           href=node.title.get_url()))
            else:
                header.add(tags.span(node.title, _class='navbar-brand'))

        bar = cont.add(
            tags.div(
                _class='navbar-collapse collapse',
                id=node_id,
            ))

        for item in node.items:
            bar.add(self.visit(item))

        return root
Esempio n. 24
0
    def visit_Navbar(self, node):
        node_id = self.id or sha1(str(id(node)).encode()).hexdigest()

        root = tags.nav(
            _class='navbar navbar-expand-md navbar-dark bg-dark fixed-top')

        # title may also have a 'get_url()' method, in which case we render
        # a brand-link
        if node.title is not None:
            if hasattr(node.title, 'get_url'):
                root.add(
                    tags.a(node.title.text,
                           _class='navbar-brand',
                           href=node.title.get_url()))
            else:
                root.add(tags.span(node.title, _class='navbar-brand'))

        btn = root.add(tags.button())
        btn['type'] = 'button'
        btn['class'] = 'navbar-toggler'
        btn['data-toggle'] = 'collapse'
        btn['data-target'] = '#' + node_id
        btn['aria-controls'] = 'navbarCollapse'
        btn['aria-expanded'] = 'false'
        btn['aria-label'] = "Toggle navigation"

        btn.add(tags.span('', _class='navbar-toggler-icon'))

        bar = root.add(
            tags.div(
                _class='navbar-collapse collapse',
                id=node_id,
            ))

        bar_list = bar.add(tags.ul(_class='navbar-nav mr-auto'))

        for item in node.items:
            bar_list.add(self.visit(item))

        search_form = bar.add(tags.form(_class="form-inline mt-2 mt-md-0"))
        # search_input = search_form.add(tags.input(_class="form-control mr-sm-2"))
        # search_input['type'] = "text"
        # search_input['placeholder'] = "Search"
        # search_input['aria-label'] = "Search"

        search_btn = search_form.add(
            tags.button(_class="btn btn-success my-2 my-sm-0"))
        search_btn['type'] = "submit"
        search_btn.add_raw_string('+')

        search_btn = search_form.add(
            tags.button(_class="btn btn-success my-2 my-sm-0"))
        search_btn['type'] = "submit"
        search_btn.add_raw_string('Login')

        return root
def text_or_ptr(s):
    if s.startswith("0x7"):
        sp = t.span()
        sp.add(t.a(s, href=f"#{s}"))
        sp.add(" (")
        sp.add(t.a("M", href=f"#mapentry-{s}"))
        sp.add(")")
        return sp
    else:
        return t.span(s)
Esempio n. 26
0
 def get_add_keyvalue_button():
     add_key_value_btn = a(cls="btn btn-success",
                           type="button",
                           data_toggle="modal",
                           data_target="#add-keyvalue-filetype-modal",
                           style="margin-bottom:20px;")
     with add_key_value_btn:
         with span(cls="glyphicon glyphicon-plus"):
             span("Add Key/Value", cls="button-label")
     return add_key_value_btn
Esempio n. 27
0
def str_to_span(content: str):
    paragraph = p()
    for word in content.split():
        # non alphanumeric and alphanumeric will be in different spans
        if not word[-1:].isalnum():
            paragraph.add(span(word[:-1]))
            paragraph.add(span(word[-1:]))
        else:
            paragraph.add(span(word))
        paragraph.add(span(' '))
    return paragraph
Esempio n. 28
0
    def visit_Navbar(self, node):
        # create a navbar id that is somewhat fixed, but do not leak any
        # information about memory contents to the outside
        node_id = self.id or sha1(str(id(node)).encode()).hexdigest()

        root = tags.nav(
            _class='navbar navbar-expand-lg navbar-dark bg-dark'
        ) if self.html5 else tags.div(role='navigation', _class='navbar')
        if hasattr(node, 'kwargs') and node.kwargs.get('class_'):
            root['class'] += (' ' + node.kwargs['class_'])
        if hasattr(node, 'kwargs') and node.kwargs.get('id'):
            root['id'] = node.kwargs['id']

        # title may also have a 'get_url()' method, in which case we render
        # a brand-link
        if node.title is not None:
            if hasattr(node.title, 'img'):
                root.add(self.visit(node.title))
            elif hasattr(node.title, 'get_url'):
                root.add(
                    tags.a(node.title.text,
                           _class='navbar-brand',
                           href=node.title.get_url()))
            else:
                root.add(tags.span(node.title, _class='navbar-brand'))

        # collapse button
        if hasattr(node,
                   'kwargs') and node.kwargs.get('responsive') in (None, True):
            btn = root.add(tags.button())
            btn['type'] = 'button'
            btn['class'] = 'navbar-toggler navbar-toggler-right'
            btn['data-toggle'] = 'collapse'
            btn['data-target'] = '#' + node_id
            btn['aria-expanded'] = 'false'
            btn['aria-controls'] = 'navbar'
            btn['aria-label'] = 'Toggle navigation'
            btn.add(tags.span(_class='navbar-toggler-icon'))

        bar = root.add(
            tags.div(
                _class='collapse navbar-collapse',
                id=node_id,
            ))
        item_list = bar.add(tags.div(_class='navbar-nav mr-auto'))
        item_list_right = bar.add(tags.div(_class='navbar-nav'))

        for item in node.items:
            if hasattr(item, 'kwargs') and item.kwargs.get('align') == 'right':
                item_list_right.add(self.visit(item))
            else:
                item_list.add(self.visit(item))

        return root
Esempio n. 29
0
def _notice_to_html(the_notice, ctx, with_anchor=False):
    anchor = {'id': six.text_type(the_notice.id)} if with_anchor else {}
    with H.div(_class=u'notice %s' % the_notice.severity, **anchor):
        with H.h3():
            # See above regarding spaces.
            H.abbr(the_notice.severity_short, _class=u'severity',
                   title=the_notice.severity)
            H.span(six.text_type(the_notice.id), _class=u'ident')
            with H.span():
                _piece_to_html(the_notice.title, ctx)
        for piece in the_notice.explanation:
            _piece_to_html(piece, ctx)
Esempio n. 30
0
def add_footnote_to_output(paragraphs):
    with tags.li():
        for (para) in paragraphs:
            for (run) in para.runs:
                style = footer.get_style(run)
                if style == "bolded":
                    with tags.span(run.text):
                        tags.attr(cls="sub-subject_small")
                else:
                    with tags.span(run.text):
                        tags.attr(cls="definition_small")
            tags.br()
Esempio n. 31
0
            def visit_Navbar(self, node):
                # create a navbar id that is somewhat fixed, but do not leak any
                # information about memory contents to the outside
                node_id = self.id or sha1(str(id(node)).encode()).hexdigest()

                root = tags.nav() if self.html5 else tags.div(role='navigation')
                root['class'] = 'navbar navbar-default'

                cont = root.add(tags.div(_class='container-fluid'))

                # collapse button
                header = cont.add(tags.div(_class='navbar-header'))
                btn = header.add(tags.button())
                btn['type'] = 'button'
                btn['class'] = 'navbar-toggle collapsed'
                btn['data-toggle'] = 'collapse'
                btn['data-target'] = '#' + node_id
                btn['aria-expanded'] = 'false'
                btn['aria-controls'] = 'navbar'

                btn.add(tags.span('Toggle navigation', _class='sr-only'))
                btn.add(tags.span(_class='icon-bar'))
                btn.add(tags.span(_class='icon-bar'))
                btn.add(tags.span(_class='icon-bar'))

                # title may also have a 'get_url()' method, in which case we render
                # a brand-link
                if node.title is not None:
                    if hasattr(node.title, 'get_url'):
                        header.add(tags.a(node.title.text, _class='navbar-brand',
                                          href=node.title.get_url()))
                    else:
                        header.add(tags.span(node.title, _class='navbar-brand'))

                bar = cont.add(tags.div(
                    _class='navbar-collapse collapse',
                    id=node_id,
                ))
                bar_list = bar.add(tags.ul(_class='nav navbar-nav'))
                bar_list_right = bar.add(tags.ul(_class='nav navbar-nav navbar-right'))

                to_right = False
                for item in node.items:
                    if isinstance(item, SeparatorAlign):
                        to_right = True
                        continue
                    if not to_right:
                        bar_list.add(self.visit(item))
                    else:
                        bar_list_right.add(self.visit(item))

                return root
Esempio n. 32
0
def build_html(parsed_tokens, css_style):
    with document(title="Code") as doc:
        style(css_style)
        for token in parsed_tokens:
            if token.type == line_break:
                br()
            else:
                lines = token.content.split('\n')
                for j in range(len(lines)):
                    if j != 0:
                        br()
                    span(lines[j], cls=token.type)
    return doc.render(pretty=False)
Esempio n. 33
0
    def _delimited_text(self):
        assert isinstance(self._value, list)
        if not self._value:
            return

        values = iter(self._value)
        with td(colspan=1, class_name='value') as column:
            text(next(values))
            for value in values:
                span('/', class_name='delimeter')
                text(value)

        return column
Esempio n. 34
0
def _render_response(resp):
    with H.section():
        with H.div(_class=u'message-display'):
            with H.h2(), H.code():      # Status line
                # See above regarding spaces.
                if resp.version:
                    H.span(printable(resp.version),
                           **_for_object(resp.version))
                with H.span(**_for_object(resp.status)):
                    _render_known(resp.status)
                    H.span(printable(find_reason_phrase(resp)))
            _render_message(resp)       # Headers, body and all that
        _render_complaints(resp)
Esempio n. 35
0
def _notice_to_html(the_notice, ctx, with_anchor=False):
    anchor = {'id': str(the_notice.id)} if with_anchor else {}
    with H.div(_class=u'notice %s' % the_notice.severity.name, **anchor):
        with H.h3():
            # See above regarding spaces.
            H.abbr(the_notice.severity_short,
                   _class=u'severity',
                   title=the_notice.severity.name)
            H.span(str(the_notice.id), _class=u'ident')
            with H.span(__pretty=False):
                _piece_to_html(the_notice.title, ctx)
        for piece in the_notice.explanation:
            _piece_to_html(piece, ctx)
Esempio n. 36
0
def _block(profession, toml):
    with div(id=profession):
        with div(class_name='content'):
            with div(id=f'{profession}-logo'):
                for style, token in toml['logo']['tokens']:
                    span(raw(token), class_name=style)
            with div(class_name='text'):
                with div(class_name='biography'):
                    for paragraph in toml['biography']['paragraphs']:
                        p(paragraph)
                with div(class_name='links'):
                    for link in toml['links']:
                        a(link['label'], href=link['url'], target='_blank')
                        p(link['summary'])
Esempio n. 37
0
def _render_request(req):
    with H.section():
        with H.div(_class=u'message-display'):
            with H.h2(), H.code():      # Request line
                # We don't insert spaces here because,
                # without ``__pretty=False``,
                # Dominate renders each element on its own line,
                # thus implicitly creating whitespace.
                with H.span(**_for_object(req.method)):
                    _render_known(req.method)
                H.span(printable(req.target), **_for_object(req.target))
                if req.version:
                    H.span(printable(req.version), **_for_object(req.version))
            _render_message(req)        # Headers, body and all that
        _render_complaints(req)
Esempio n. 38
0
def _render_request(req):
    with H.section():
        with H.div(_class=u'message-display'):
            with H.h2(), H.code():      # Request line
                # We don't insert spaces here because we assume that
                # Dominate will render each element on its own line,
                # thus implicitly creating whitespace.
                # https://github.com/Knio/dominate/issues/68
                with H.span(**_for_object(req.method)):
                    _render_known(req.method)
                H.span(printable(req.target), **_for_object(req.target))
                if req.version:
                    H.span(printable(req.version), **_for_object(req.version))
            _render_message(req)        # Headers, body and all that
        _render_complaints(req)
Esempio n. 39
0
def regular(type, text):
    if type in ['footnote', 'footnote_recurrence']:
        with tags.a("(%s)" % text.strip()):
            tags.attr(cls="ptr")
    else:
        if "\n" in text:
            print "New:", text
        if u"°" in text:
            href = re.sub(u"°", "", text)
            href = re.sub(u"־", " ", href)
            with tags.span(tags.a(text, href="#"+href)):
                tags.attr(cls=type)
        else:
            with tags.span(text):
                tags.attr(cls=type)
Esempio n. 40
0
def regular(type, text):
    if type in ['footnote', 'footnote_recurrence']:
        with tags.a("(%s)" % text.strip()):
            tags.attr(cls="ptr")
    else:
        if "\n" in text:
            print "New:", text
        if u"°" in text:
            href = re.sub(u"°", "", text)
            href = re.sub(u"־", " ", href)
            with tags.span(tags.a(text, href="#" + href)):
                tags.attr(cls=type)
        else:
            with tags.span(text):
                tags.attr(cls=type)
Esempio n. 41
0
def _render_response(resp):
    with H.section():
        with H.div(_class=u'message-display'):
            if resp.remark:
                H.p(printable(resp.remark), _class=u'message-remark')
            with H.h2(), H.code():  # Status line
                # See above regarding spaces.
                if resp.version:
                    H.span(printable(resp.version),
                           **_for_object(resp.version))
                with H.span(**_for_object(resp.status)):
                    _render_known(resp.status)
                    H.span(printable(find_reason_phrase(resp)))
            _render_message(resp)  # Headers, body and all that
        _render_complaints(resp)
Esempio n. 42
0
    def visit_Navbar(self, node):
        # create a navbar id that is somewhat fixed, but do not leak any
        # information about memory contents to the outside
        node_id = self.id or sha1(str(id(node)).encode()).hexdigest()

        root = tags.nav(_class='navbar') if self.html5 else tags.div(role='navigation',  _class='navbar')
        if node.kwargs.get('class_'):
            root['class'] += (' ' + node.kwargs['class_'])
        if node.kwargs.get('id'):
            root['id'] = node.kwargs['id']

        # title may also have a 'get_url()' method, in which case we render
        # a brand-link
        if node.title is not None:
            if hasattr(node.title, 'img'):
                root.add(self.visit(node.title))
            elif hasattr(node.title, 'get_url'):
                root.add(tags.a(node.title.text, _class='navbar-brand',
                                href=node.title.get_url()))
            else:
                root.add(tags.span(node.title, _class='navbar-brand'))

        # collapse button
        if node.kwargs.get('responsive') in (None, True):
            btn = root.add(tags.button())
            btn['type'] = 'button'
            btn['class'] = 'navbar-toggler navbar-toggler-right'
            btn['data-toggle'] = 'collapse'
            btn['data-target'] = '#' + node_id
            btn['aria-expanded'] = 'false'
            btn['aria-controls'] = 'navbar'
            btn['aria-label'] = 'Toggle navigation'
            btn.add(tags.span(_class='navbar-toggler-icon'))

        bar = root.add(tags.div(
            _class='collapse navbar-collapse',
            id=node_id,
        ))
        item_list = bar.add(tags.div(_class='navbar-nav mr-auto'))
        item_list_right = bar.add(tags.div(_class='navbar-nav'))

        for item in node.items:
            if item.kwargs.get('align') == 'right':
                item_list_right.add(self.visit(item))
            else:
                item_list.add(self.visit(item))

        return root
Esempio n. 43
0
    def visit_Navbar(self, node):
        cont = tags.nav(
            _class='navbar fixed-top navbar-expand-sm navbar-dark bg-secondary'
        )

        if current_user.is_authenticated:  # navbar is empty if not logged in, therefore no toggle button needed
            btn_toggle_kwargs = {
                'class': 'navbar-toggler',
                'type': 'button',
                'data-toggle': 'collapse',
                'data-target': '#navbarCollapseDiv',
                'aria-controls': 'navbarCollapseDiv',
                'aria-expanded': 'false',
                'aria-label': 'Toggle navigation'
            }
            btn_toggle = cont.add(tags.button(**btn_toggle_kwargs))
            btn_toggle.add(tags.span(_class='navbar-toggler-icon'))
        else:
            cont[
                'class'] += ' display-flex justify-content-end'  # so that the sign in button is always on the right

        div_coll = cont.add(
            tags.div(_class='collapse navbar-collapse',
                     id='navbarCollapseDiv'))
        div_nav = div_coll.add(tags.div(_class='navbar-nav'))

        for item in node.items:
            div_nav.add(self.visit(item))

        cont.add(create_login_logout_btn(current_user.is_authenticated))

        return cont
Esempio n. 44
0
def Item(file_name):
    with dom.div(cls=RESULT_ITEM) as ResultItem:
        dom.p(f"{ file_name }.jpg", cls="text-xl text-gray-400")
        with dom.a(href=f"/download?filename={file_name}"):
            dom.i(cls="fas fa-download text-xl text-gray-400")

    return ResultItem.render() + dom.span(id="here").render()
Esempio n. 45
0
    def __init__(self, text=None, glyph=None, caret=True, **kwargs):
        self.kclass_dep = KClassDep('dropdown-toggle')
        self.kdata_toggle = KDep('dropdown', key='data-toggle')
        self.khref = KDep('#', key='href')
        
        items = span()
        if text is not None:
            items.add(text)
        if glyph is not None:
            if isinstance(glyph, Glyphicon):
                items.add(glyph)
            else:
                items.add(Glyphicon(icon_name=glyph))
        if caret is True:
            items.add(span(_class='caret'))

        super().__init__(items, **self.update_kwargs(kwargs))
Esempio n. 46
0
def subject(html_doc, type, text):
    clean_text = clean_name(text.strip())
    new_subject_l = subjects_db.get(clean_text, [])
    subject_id = calc_subject_id(text.strip(), len(new_subject_l))
    new_subject_l.append((text.strip(), html_doc.section, "%s.html#%s" % (html_doc.index, subject_id)))
    subjects_db[clean_text] = new_subject_l

    with tags.span(text, id=subject_id):
        tags.attr(cls=type)
Esempio n. 47
0
def _render_response(resp):
    with H.section():
        with H.div(_class=u'message-display'):
            if resp.remark:
                H.p(printable(resp.remark), _class=u'message-remark')
            with H.h2(), H.code():      # Status line
                # See above regarding spaces.
                if resp.version:
                    H.span(printable(resp.version),
                           **_for_object(resp.version))
                # httpolice-devtool (the Chrome extension) relies
                # on the ``StatusCode`` class. Avoid breaking it, at least
                # as long as it doesn't inconvenience HTTPolice itself.
                with H.span(**_for_object(resp.status, u'StatusCode')):
                    _render_known(resp.status)
                    text_node(u' ' + printable(find_reason_phrase(resp)))
            _render_message(resp)       # Headers, body and all that
        _render_complaints(resp)
Esempio n. 48
0
    def visit_Subgroup(self, node):
        group = tags.ul(_class='subgroup')
        title = tags.span(node.title)

        if node.active:
            title.attributes['class'] = 'active'

        for item in node.items:
            group.add(tags.li(self.visit(item)))

        return tags.div(title, group)
Esempio n. 49
0
def _render_known(obj):
    cls = type(obj).__name__
    text = printable(six.text_type(obj))
    cite = known.citation(obj)
    if cite:
        elem = H.a(text, _class=cls, href=cite.url, target=u'_blank')
    else:
        elem = H.span(text, _class=cls)
    title = known.title(obj, with_citation=True)
    if title:
        with elem:
            H.attr(title=title)
Esempio n. 50
0
    def visit_Navbar(self, node):
        # create a navbar id that is somewhat fixed, but do not leak any
        # information about memory contents to the outside
        node_id = self.id or sha1(str(id(node)).encode()).hexdigest()

        root = tags.nav() if self.html5 else tags.div(role="navigation")
        root["class"] = "navbar navbar-default"

        cont = root.add(tags.div(_class="container-fluid"))

        # collapse button
        header = cont.add(tags.div(_class="navbar-header"))
        btn = header.add(tags.button())
        btn["type"] = "button"
        btn["class"] = "navbar-toggle collapsed"
        btn["data-toggle"] = "collapse"
        btn["data-target"] = "#" + node_id
        btn["aria-expanded"] = "false"
        btn["aria-controls"] = "navbar"

        btn.add(tags.span("Toggle navigation", _class="sr-only"))
        btn.add(tags.span(_class="icon-bar"))
        btn.add(tags.span(_class="icon-bar"))
        btn.add(tags.span(_class="icon-bar"))

        # title may also have a 'get_url()' method, in which case we render
        # a brand-link
        if node.title is not None:
            if hasattr(node.title, "get_url"):
                header.add(tags.a(node.title.text, _class="navbar-brand", href=node.title.get_url()))
            else:
                header.add(tags.span(node.title, _class="navbar-brand"))

        bar = cont.add(tags.div(_class="navbar-collapse collapse", id=node_id))
        bar_list = bar.add(tags.ul(_class="nav navbar-nav"))

        for item in node.items:
            bar_list.add(self.visit(item))

        return root
Esempio n. 51
0
    def visit_View(self, node):
        item = tags.a(href=node.get_url(), title=node.text,
                      _class='nav-item nav-link')

        if node.kwargs.get('icon'):
            item.add(tags.span(_class='fas fa-{}'.format(node.kwargs.get('icon'))))
            node.text = ' ' + node.text

        item.add_raw_string(node.text)

        if node.kwargs.get('class_'):
            item['class'] += (' ' + node.kwargs['class_'])

        if node.active:
            item['class'] += ' active'

        return item
Esempio n. 52
0
    def visit_Subgroup(self, node):
        if not self._in_dropdown:
            li = tags.li(_class="dropdown")
            if node.active:
                li["class"] = "active"
            a = li.add(tags.a(node.title, href="#", _class="dropdown-toggle"))
            a["data-toggle"] = "dropdown"
            a["role"] = "button"
            a["aria-haspopup"] = "true"
            a["aria-expanded"] = "false"
            a.add(tags.span(_class="caret"))

            ul = li.add(tags.ul(_class="dropdown-menu"))

            self._in_dropdown = True
            for item in node.items:
                ul.add(self.visit(item))
            self._in_dropdown = False

            return li
        else:
            raise RuntimeError("Cannot render nested Subgroups")
Esempio n. 53
0
    def visit_Subgroup(self, node):
        if not self._in_dropdown:
            li = tags.li(_class='dropdown')
            if node.active:
                li['class'] = 'active'
            a = li.add(tags.a(node.title, href='#', _class='dropdown-toggle'))
            a['data-toggle'] = 'dropdown'
            a['role'] = 'button'
            a['aria-haspopup'] = 'true'
            a['aria-expanded'] = 'false'
            a.add(tags.span(_class='caret'))

            ul = li.add(tags.ul(_class='dropdown-menu'))

            self._in_dropdown = True
            for item in node.items:
                ul.add(self.visit(item))
            self._in_dropdown = False

            return li
        else:
            raise RuntimeError('Cannot render nested Subgroups')
Esempio n. 54
0
def htmlize(notation):
    """Translate notation to a dominate HTML tree"""
    top = tags.span(_class='notation')
    with top:
        TacticNotationsToHTMLVisitor().visit(parse(notation))
    return top
Esempio n. 55
0
 def visitWhitespace(self, ctx:TacticNotationsParser.WhitespaceContext):
     tags.span(" ")          # TODO: no need for a <span> here
Esempio n. 56
0
 def visitHole(self, ctx:TacticNotationsParser.HoleContext):
     tags.span(ctx.ID().getText()[1:], _class="hole")
Esempio n. 57
0
 def visitAtomic(self, ctx:TacticNotationsParser.AtomicContext):
     tags.span(ctx.ATOM().getText())
Esempio n. 58
0
 def visitCurlies(self, ctx:TacticNotationsParser.CurliesContext):
     sp = tags.span(_class="curlies")
     sp.add("{")
     with sp:
         self.visitChildren(ctx)
     sp.add("}")
Esempio n. 59
0
def _ref_to_html(ref, ctx):
    target = resolve_reference(ctx, ref.reference)
    H.span(u'', **_referring_to(target))