Ejemplo n.º 1
0
    def get_ncdump_html(self):
        """
        Generates html code to display the contents of the ncdump text file. The generated html
        is used for netcdf file type metadata view and edit modes.
        :return:
        """

        nc_dump_div = div()
        nc_dump_res_file = None
        for f in self.logical_file.files.all():
            if f.extension == ".txt":
                nc_dump_res_file = f
                break
        if nc_dump_res_file is not None:
            nc_dump_div = div(style="clear: both", cls="col-xs-12")
            with nc_dump_div:
                legend("NetCDF Header Information")
                p(nc_dump_res_file.full_path[33:])
                header_info = nc_dump_res_file.resource_file.read()
                header_info = header_info.decode('utf-8')
                textarea(header_info,
                         readonly="",
                         rows="15",
                         cls="input-xlarge",
                         style="min-width: 100%")

        return nc_dump_div
Ejemplo n.º 2
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.div()
        root['class'] = "navbar-dark text-white"
        container = root.add(tags.div())
        container['class'] = "container"
        root = tags.nav() if self.html5 else tags.div(role='navigation')
        root['class'] = 'navbar px-0 navbar-expand-lg navbar-dark'

        # collapse button
        # header = nav.add(tags.div(_class='navbar-header'))
        # btn = header.add(tags.button())
        btn = root.add(tags.button())
        btn['type'] = 'button'
        btn['class'] = 'navbar-toggler'
        btn['data-toggle'] = 'collapse'
        btn['data-target'] = '#navbarNavAltMarkup'
        btn['aria-expanded'] = 'false'
        btn['aria-controls'] = 'navbarNavAltMarkup'
        btn['aria-label'] = 'Toggle navigation'
        btn.add(tags.span(_class='navbar-toggler-icon'))

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

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

        return root
Ejemplo n.º 3
0
 def accordian_collapse(color, title, content, pre, raw_html, **kwargs):
     """
     Creates a collapsible accordian
     """
     title_random = HelperFunctions.id_with_random(5, title)
     with tag.div(_class="jumbotron container reportng-section-collapsible-class") as h:
         # with tag.div(id="accordian"):
         with tag.div(_class="card"):
             with tag.div(_class="card-header %s reportng-collapse-card-header-class" % color,
                          id="headingOne%s" % title_random):
                 tag.h1(title, _class=color, data_toggle="collapse", data_target="#collapse%s" % title_random,
                        aria_expanded="true", aria_controls="collapse%s" % title_random, id=title_random)
             with tag.div(id="collapse%s" % title_random, _class="collapse",
                          aria_labelledby="headingOne%s" % title_random, data_parent="#accordion"):
                 with tag.div(_class="card-body context reportng-collapse-card-body-class"):
                     if raw_html != '':
                         raw(raw_html)
                     elif pre:
                         tag.pre(content)
                     else:
                         tag.p(content)
             if 'alert' in kwargs:
                 HelperFunctions.make_alert(kwargs.get('alert'))
             if 'badge' in kwargs:
                 HelperFunctions.create_badges(kwargs.get('badge'))
     return HelperFunctions.convert_to_string(h)
Ejemplo n.º 4
0
    def get_html(self):
        """generates html code for viewing web service related data"""

        root_div = div(cls="col-xs-12 pull-left", style="margin-top:10px;")

        def get_th(heading_name):
            return th(heading_name, cls="text-muted")

        with root_div:
            with div(cls="custom-well"):
                # strong(self.name)
                with table(cls='custom-table'):
                    with tbody():
                        with tr():
                            get_th('URL')
                            td(self.url)
                        with tr():
                            get_th('Service Type')
                            td(self.service_type)
                        with tr():
                            get_th('Return Type')
                            td(self.return_type)
                        with tr():
                            get_th('Reference Type')
                            td(self.reference_type)

        return root_div.render(pretty=True)
Ejemplo n.º 5
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
Ejemplo n.º 6
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
Ejemplo n.º 7
0
    def __init__(self, *fields, col_args=None, offset=None, **kwargs):
        self.kclass_dep = KClassDep('row')
        self.kstyle = KStyle('padding-bottom: 10px;', 'padding-top:20px;')
        super().__init__(**self.update_kwargs(kwargs))

        def _col(n):
            return 'col-sm-{}'.format(n)

        if offset is not None:
            self.add(div(_class=_col(offset)))

        if col_args is None:
            col_args = ()

        count = 0
        while count < len(fields):  
            # _kwargs get passed to the form group or div if it's a submit field
            _kwargs = {}
            if count < len(col_args):
                _kwargs['_class'] = _col(col_args[count])

            _kwargs['style'] = 'float:left;'

            field = fields[count]

            if isinstance(field, SubmitField):
                _kwargs['style'] += 'padding-top:25px;'
                self.add(div(raw(field(class_='btn btn-primary')), **_kwargs))
            else:
                self.add(FormGroup(field=field, **_kwargs))

            count += 1
Ejemplo n.º 8
0
    def get_contest_details(contest) -> div:
        """Return 'div' element with info about 'contest' instance
        and it's options.
        :param contest: Contest instance from which 'div' tag should
            be build.
        """
        contest_attributes = [
            ('name from OCR', contest.name),
            ('name from fuzzy matching', contest.fuzzy_name),
            ('name from alias', contest.alias_name),
            ('referendum header', contest.additional_text),
            ('question', contest.question),
            ('Yes/No contest', contest.bipolar),
            ('on page', contest.page + 1),
            ('vote for', contest.vote_for),
        ]
        title = contest.alias_name or contest.fuzzy_name or contest.name
        contest_container = div(id=title, cls='py-1')
        contest_container.add(h4(title, cls='mt-2'))
        contest_div = div(cls='col pl-4')
        for contest_key, contest_value in contest_attributes:
            contest_div.add(
                StyleSummary.get_details_row(contest_key, str(contest_value)))
        options_div = div()
        contest_div.add(h5('Options', cls='mt-2'))
        for option in reversed(contest.options):
            options_div.add(StyleSummary.get_option_details(option))
        contest_div.add(options_div)
        contest_container.add(contest_div)

        return contest_container
Ejemplo n.º 9
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
Ejemplo n.º 10
0
    def get_html(self):
        """generates html code for viewing site related data"""

        root_div = div(cls="col-xs-12 pull-left", style="margin-top:10px;")

        def get_th(heading_name):
            return th(heading_name, cls="text-muted")

        with root_div:
            with div(cls="custom-well"):
                # strong(self.name)
                with table(cls='custom-table'):
                    with tbody():
                        with tr():
                            get_th('Name')
                            td(self.name)
                        with tr():
                            get_th('Code')
                            td(self.code)
                        with tr():
                            get_th('Latitude')
                            td(self.latitude)
                        with tr():
                            get_th('Longitude')
                            td(self.longitude)

        return root_div.render(pretty=True)
Ejemplo n.º 11
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()
Ejemplo n.º 12
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
Ejemplo n.º 13
0
def cv():
    base = Path('cv')
    with (base / 'content' / 'data.toml').open() as toml, \
         (base / 'style' / 'index.css').open() as css:
        data = loads(toml.read())
        with html(lang='en') as document:
            with head():
                meta(charset='utf-8')
                meta(name='description',
                     content=f'{SHARED.info.person_name} (engineer|designer)')
                meta(name='keywords', content=','.join(SHARED.meta.keywords))
                meta(name='author', content=f'{SHARED.info.person_name}')
                title(SHARED.info.person_name)
                style(raw(css.read()))
            with body():
                with table(id='content') as content:
                    with tr():
                        with td(id='image', colspan=4):
                            img(src='img/header.png', alt='...')
                            div('Curriculum Vitae')
                for row in chain(
                        Basic(data['basic']).as_rows(),
                        Skills(data['skills']).as_rows(),
                        Experience(data['experience']).as_rows(),
                        Education(data['education']).as_rows()):
                    content.add(row)

    copyright = comment(f'Copyright (C) 2015 - {datetime.now().year} '
                        f'{SHARED.info.person_name}. '
                        'All rights reserved.')
    return f'<!DOCTYPE html>{copyright}{document.render(pretty=False)}'
Ejemplo n.º 14
0
    def get_html(self):
        """generates html code for viewing web service related data"""

        root_div = div(cls="col-xs-12 pull-left", style="margin-top:10px;")

        def get_th(heading_name):
            return th(heading_name, cls="text-muted")

        with root_div:
            with div(cls="custom-well"):
                # strong(self.name)
                with table(cls='custom-table'):
                    with tbody():
                        with tr():
                            get_th('URL')
                            td(self.url)
                        with tr():
                            get_th('Service Type')
                            td(self.service_type)
                        with tr():
                            get_th('Return Type')
                            td(self.return_type)
                        with tr():
                            get_th('Reference Type')
                            td(self.reference_type)

        return root_div.render(pretty=True)
Ejemplo n.º 15
0
    def get_update_netcdf_file_html_form(self):
        form_action = "/hsapi/_internal/{}/update-netcdf-file/".format(self.id)
        style = "display:none;"
        if self.is_dirty:
            style = "margin-bottom:10px"
        root_div = div(id="div-netcdf-file-update", cls="row", style=style)

        with root_div:
            with div(cls="col-sm-12"):
                with div(cls="alert alert-warning alert-dismissible",
                         role="alert"):
                    strong(
                        "NetCDF file needs to be synced with metadata changes."
                    )
                    input(id="metadata-dirty",
                          type="hidden",
                          value=self.is_dirty)
                    with form(action=form_action,
                              method="post",
                              id="update-netcdf-file"):
                        button("Update NetCDF File",
                               type="button",
                               cls="btn btn-primary",
                               id="id-update-netcdf-file")

        return root_div
Ejemplo n.º 16
0
    def step1(self):

        with html.div() as content:
            html.div('Wählen Sie Ihren Kanton')
            form = KantonsForm()
            form.html(action='/step2')
        return self.template.render(content=content)
Ejemplo n.º 17
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")
        dom.script(src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js')

    with doc.body:
        with dom.div(cls=CENTER_FRAME)as CenterFrame:
            with dom.div(cls=CARD) as Card:
                with dom.form(cls=UPLOAD_FORM) 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",cls=BUTTON)
                    dom.input(cls='hidden',type="file",id="fileupload",onchange=''' $('#1').text(this.value.split("\\\\").pop(-1))''')
            with dom.div(cls=RESULT_CONTAINER) as ResultContainer:
                for _ in range(4):
                    with dom.div(cls=RESULT_ITEM) as ResultItem:
                        dom.p("filename.jpg",cls="text-xl text-gray-400")
                        dom.i(cls="fas fa-download text-xl text-gray-400")

            with dom.div() as ResultContainer:
                pass
    return doc.render()
Ejemplo n.º 18
0
    def __init__(self, subtitle=''):
        self.doc = dominate.document(self.site_name)
        self.subtitle = subtitle if subtitle else self.__class__.__name__
        self.on_ready_scriptage = []

        with self.doc.head:
            for css in self.cssfiles.split():
                self._link_css(css)
            for scripturl in self.scripturls:
                tags.script(crossorigin="anonymous", src=scripturl)
            self.script_list = tags.script().children

        with self.doc.body.add(tags.div(cls="container")):
            self.header = tags.div(id="header")
            with self.header.add(tags.h2()):
                tags.a(self.site_name, href='/', id="site_name")
                tags.h3(self.subtitle, id="subtitle")
                with tags.ul(id="status", style=self.status_style):
                    for msg in flask.get_flashed_messages():
                        tags.li(msg)
            self.content = tags.div(id="content")
            self.footer = tags.div(id="footer")
            with self.footer:
                tags.a("Latest", href=url_for("list_latest"))
                tags.a("Back to the Front", href="/")
                tags.a("Catalog",
                       href=url_for("show_catalog_page"),
                       onclick="shift_edit(event, this)")
                tags.a("Register", href=url_for('loginbp.new_user'))
                tags.label("")
                if flask_login.current_user.is_authenticated:
                    tags.a(f"Log out", href=url_for('loginbp.logout'))
                else:
                    tags.a(f"Login", href=url_for('loginbp.login'))
Ejemplo n.º 19
0
def _errors(errors):
    if errors:
        d = t.div(cls='errors')
        with d:
            for error in errors:
                t.div(error, cls='error')
        return d
Ejemplo n.º 20
0
def formatDoubleWeek(week1, week2, image, backgroundImage, imageDescription):
    # week frame with background
    bg = "background-image:url({});".format(backgroundImage)
    with div(cls="page", style=bg):
        # image
        with div(cls="week-image-container"):
            with div(cls="week-image-aspect-ratio"):
                img(src=image, cls="week-image", alt="")
        # image description
        div(imageDescription, cls="week-image-description")
        # month name(s)
        month1 = week1.month1
        month2 = week2.month2 if week2 else month1
        if month1 is month2:
            monthName = month1.name
        else:
            monthName = u"{} / {}".format(month1.name, month2.name)
        div(monthName, cls="month-name")
        # days
        with div(cls="double-week"):
            with div(cls="week week-1"):
                formatWeek(week1)
            if week2:
                with div(cls="week week-2"):
                    formatWeek(week2)
Ejemplo n.º 21
0
 def test_many_argument_strings(self):
     c = Converter('Man', file='links.man')
     c.translate()
     text = c.html.render()
     text = c.change_special_symbols(text)
     doc = tags.html(lang='en')
     doc = add_head(doc)
     doc_body = tags.body()
     row = tags.div(cls='row')
     row = add_row(row, 'GREP(1)', 'User Commands', 'GREP(1)')
     doc_body.add(row)
     with doc_body:
         paragraph = tags.p()
         paragraph += (tags.a('the bug-reporting address',
                              href='mailto:[email protected]'))
         paragraph += tags.br()
         paragraph += (tags.a(
             'email archive',
             href='http://lists.gnu.org/mailman/listinfo/bug-grep'))
         paragraph += tags.br()
         paragraph += tags.br()
     row = tags.div(cls='row')
     row = add_row(row, 'GNU grep 3.1', '2017-06-21', 'GREP(1)')
     doc_body.add(row)
     doc.add(doc_body)
     self.assertEqual(doc.render(), text)
Ejemplo n.º 22
0
def site():
    base = Path('website')
    with (base/'content'/'index.toml').open() as toml, \
         (base/'style'/'index.css').open() as css:
        data = loads(toml.read())

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

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

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

    copyright = comment(f'Copyright (C) 2015 - {datetime.now().year} '
                        f'{SHARED.info.person_name}. '
                        'All rights reserved.')
    return f'<!DOCTYPE html>{copyright}{document.render(pretty=False)}'
Ejemplo n.º 23
0
def makeHtml(path, fileName, sitename, authorname, usecss, usejs):
    doc = dominate.document(title=sitename)

    with doc.head:
        if (usecss.lower() == "y"):
            link(rel='stylesheet', href='style.css')
        if (usejs.lower() == "y"):
            script(type='text/javascript', src='script.js')
        with meta():
            attr(author=authorname)

    with doc:
        with div(id='header').add(ol()):
            for i in ['home', 'about', 'contact']:
                li(a(i.title(), href='/%s.html' % i))

        with div():
            attr(cls='body')
            p('Lorem ipsum..')

    if not os.path.exists("./" + path):
        os.makedirs("./" + path)

    f = open("./" + path + "/" + fileName, 'w+')
    f.write(str(doc))
    f.close()

    if (usejs.lower() == "y"):
        if not os.path.exists("./" + sitename + "/js"):
            os.makedirs("./" + sitename + "/js")
    if (usecss.lower() == "y"):
        if not os.path.exists("./" + sitename + "/css"):
            os.makedirs("./" + sitename + "/css")
Ejemplo n.º 24
0
 def test_other(self):
     c = Converter('Man', file='diff.man')
     c.translate()
     text = c.html.render()
     text = c.change_special_symbols(text)
     doc = tags.html(lang='en')
     doc = add_head(doc)
     doc_body = tags.body()
     row = tags.div(cls='row')
     row = add_row(row, 'GCC(1)', '', 'GCC(1)')
     doc_body.add(row)
     with doc_body:
         paragraph = tags.p()
         paragraph.add(tags.br())
         paragraph.add('\n\\f(CW        c  c-header  cpp-output\\fP')
         paragraph.add(tags.br())
         paragraph.add(tags.br())
         def_list = tags.dl()
         def_termin = tags.dt()
         def_termin.add('\n')
         def_termin.add('\\fB-x none\\fR')
         def_def = tags.dd(cls='indent')
         def_def.add('\nstandard_output.')
         def_list.add(def_termin)
         def_list.add(def_def)
     row = tags.div(cls='row')
     row = add_row(row, '', '2018-07-20', 'GCC(1)')
     doc_body.add(row)
     doc.add(doc_body)
     doc = c.change_special_symbols(doc.render())
     self.assertEqual(doc, text)
Ejemplo n.º 25
0
    def get_html(self):
        """generates html code for viewing site related data"""

        root_div = div(cls="col-xs-12 pull-left", style="margin-top:10px;")

        def get_th(heading_name):
            return th(heading_name, cls="text-muted")

        with root_div:
            with div(cls="custom-well"):
                # strong(self.name)
                with table(cls='custom-table'):
                    with tbody():
                        with tr():
                            get_th('Name')
                            td(self.name)
                        with tr():
                            get_th('Code')
                            td(self.code)
                        with tr():
                            get_th('Latitude')
                            td(self.latitude)
                        with tr():
                            get_th('Longitude')
                            td(self.longitude)

        return root_div.render(pretty=True)
Ejemplo n.º 26
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_
Ejemplo n.º 27
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()
Ejemplo n.º 28
0
 def __init__(self, vid):
     super().__init__(f"{vid.name} of {vid.series.name}")
     self.on_ready_scriptage.append("$('#content').fitVids()")
     with self.content:
         quality = flask.request.args.get('quality', 'auto')
         if quality == 'auto':
             vhtml = vid.html
             altdisp = altqual = '720p'
         else:
             tags.div(f"({quality} Version)", id="ver")
             vmatch = re.match(r'(.*src=")(\S+)(".*)', vid.html)
             vhtml = f"{vmatch.group(1)}{vmatch.group(2)}"
             vhtml = f"{vhtml}&amp;quality={quality}{vmatch.group(3)}"
             altqual = 'auto'
             altdisp = 'Hi Res'
         tags.div(
             raw(vhtml),
             tags.a(tags.button("Play Audio"),
                    href=url_for('play_audio',
                                 series=vid.series.name,
                                 video=vid.name)),
             tags.a(tags.button("Download Audio"),
                    href=url_for('play_audio',
                                 series=vid.series.name,
                                 video=vid.name),
                    download=vid.name),
             tags.a(tags.button(f"Play {altdisp} Video"),
                    href=url_for('play_latest',
                                 series=vid.series.name,
                                 video=vid.name,
                                 quality=altqual)),
             tags.a(tags.button("Download Video"), href=vid.dlink),
         )
Ejemplo n.º 29
0
    def upload_form(self):
        with tags.form(
            id=self.config['upload_name'],
            onsubmit=self.config['onsubmit'],
            enctype='multipart/form-data',
            method=self.config['upload_method'],
            action=self.config['upload_route'],
            cls='card p-3 bg-light'):

            tags.h5('Upload an image', cls='card-title')

            with tags.div(cls='form-group row'):
                with tags.div(cls='col-12'):
                    # This requires JavaScript to show the filename.
                    # https://github.com/Johann-S/bs-custom-file-input
                    #
                    # 'style' is necessary to avoid overlapping in Safari and
                    # Chrome on iOS:
                    # https://github.com/twbs/bootstrap/issues/26933
                    with tags.div(cls='custom-file', style='overflow: hidden;'):
                        tags.input(
                            type='file', cls='custom-file-input p-1 rounded',
                            id=self.config['upload_name'], name=self.config['upload_name'])
                        tags.label(
                            'Choose file', fr=self.config['upload_name'],
                            cls='custom-file-label bg-light')

            with tags.div(cls='form-group row'):
                with tags.div(cls='col-3'):
                    with tags.button(type='submit', cls='btn btn-primary'):
                        util.text('Submit')
Ejemplo n.º 30
0
    def get_extra_metadata_html_form(self):
        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

        if self.extra_metadata:
            root_div_extra = div(cls="col-xs-12", id="filetype-extra-metadata")
            with root_div_extra:
                legend('Extended Metadata')
                get_add_keyvalue_button()
                with table(cls="table table-striped funding-agencies-table",
                           style="width: 100%"):
                    with tbody():
                        with tr(cls="header-row"):
                            th("Key")
                            th("Value")
                            th("Edit/Remove")
                        counter = 0
                        for k, v in self.extra_metadata.iteritems():
                            counter += 1
                            with tr(data_key=k):
                                td(k)
                                td(v)
                                with td():
                                    a(data_toggle="modal",
                                      data_placement="auto",
                                      title="Edit",
                                      cls=
                                      "glyphicon glyphicon-pencil icon-button icon-blue",
                                      data_target="#edit-keyvalue-filetype-modal"
                                      "-{}".format(counter))
                                    a(data_toggle="modal",
                                      data_placement="auto",
                                      title="Remove",
                                      cls=
                                      "glyphicon glyphicon-trash icon-button btn-remove",
                                      data_target=
                                      "#delete-keyvalue-filetype-modal"
                                      "-{}".format(counter))

                self._get_add_key_value_modal_form()
                self._get_edit_key_value_modal_forms()
                self._get_delete_key_value_modal_forms()
            return root_div_extra
        else:
            root_div_extra = div(cls="row", id="filetype-extra-metadata")
            with root_div_extra:
                with div(cls="col-lg-12 content-block"):
                    legend('Extended Metadata')
                    get_add_keyvalue_button()
                    self._get_add_key_value_modal_form()
            return root_div_extra
Ejemplo n.º 31
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
Ejemplo n.º 32
0
 def _highlights(self):
     highlights = self._toml['highlights']
     assert isinstance(highlights, list)
     for highlight in highlights:
         with tr() as row:
             with td(colspan=3, class_name='value'):
                 div(highlight, class_name='details highlight')
         yield row
Ejemplo n.º 33
0
 def body_(self, contents, scriptData=""):
     """ The HTML <body> contents """
     return (div(self.topNav(),
                 div(div(contents, _class="column col-12"),
                     _class="columns"),
                 _class="container",
                 style="width: 55em; margin: 0 auto;"),
             script(raw(scriptData)))
Ejemplo n.º 34
0
def formatWeek(week):
    hr()
    for day in week.days:
        formatDay(day)
        hr()
    # week number
    number = u"Week {}".format(week.number)
    div(number, cls="week-number")
Ejemplo n.º 35
0
    def add_text(self, text):
        """Insert a header to the HTML file

        Parameters:
            text (str) -- the header text
        """
        with self.doc:
            div(text)
Ejemplo n.º 36
0
    def get_html(self, ):

        gr_name = div(b(self.type.name.title()), cls="panel-heading text-center")
        
        group = div(cls="panel panel-primary")

        group_body = div(cls="panel-body")
        for element in self.elements:
            group_body.add(element.get_html())

        group.add(gr_name, group_body)
        return group
Ejemplo n.º 37
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
Ejemplo n.º 38
0
    def get_ts_series_html(self):
        """Generates html for all time series """

        root_div = div()
        with root_div:
            legend("Reference Time Series")
            panel_group_div = div(cls="panel-group", id="accordion")
            panel_group_div.add(p("Note: Time series are listed below by site name. "
                                  "Click on a site name to see details."))
            for index, series in enumerate(self.time_series_list):
                panel_group_div.add(series.get_html(index + 1))

        return root_div
Ejemplo n.º 39
0
    def get_html(self, ):
        """Generates room html"""
        rows = self.get_display_data()

        room_container = div(cls = "well", id='room' + str(self.id))
        room_name = h3(self.name, cls="text-center")
        room_container.add(room_name)
        for row in rows:            
            r = div(cls='row')
            with r:
                for group in row:
                    div(cls="col-sm-3 group").add(group.get_html())
            room_container.add(r)
        return room_container.render()
Ejemplo n.º 40
0
    def get_abstract_form(self):
        form_action = "/hsapi/_internal/{}/update-reftimeseries-abstract/"
        form_action = form_action.format(self.logical_file.id)
        root_div = div(cls="col-xs-12")

        # if json file contains abstract then we don't need this form since abstract can't be
        # edited in that case at the aggregation level
        if self.has_abstract_in_json:
            return

        with root_div:
            with form(action=form_action, id="filetype-abstract",
                      method="post", enctype="multipart/form-data"):
                div("{% csrf_token %}")
                with div(cls="form-group"):
                    with div(cls="control-group"):
                        legend('Abstract')
                        with div(cls="controls"):
                            abstract = ""
                            if self.abstract:
                                abstract = self.abstract
                            textarea(abstract,
                                     cls="form-control input-sm textinput textInput",
                                     id="file_abstract", cols=40, rows=5,
                                     name="abstract")
                with div(cls="row", style="margin-top:10px;"):
                    with div(cls="col-md-offset-10 col-xs-offset-6 col-md-2 col-xs-6"):
                        button("Save changes", cls="btn btn-primary pull-right btn-form-submit",
                               style="display: none;", type="button")
        return root_div
Ejemplo n.º 41
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
Ejemplo n.º 42
0
    def render(self, posts_per_page=25):
        pages_count = (len(self.rendered_items) + posts_per_page - 1) // posts_per_page
        page_names = ["%d.html" % i for i in range(pages_count)]

        nav_section = T.nav(
            *[T.a(str(i), href=page_names[i], target=_PAGE_FRAME) for i in range(pages_count)]
        )

        index = T.html(
            T.head(
                T.meta(charset='utf-8'),
                stylesheet(_STYLE_CSS),
                stylesheet(_NAVBAR_CSS),
                T.script(src=_JQUERY_URL),
                inline_script_from(get_resource(Path(_SELECTED_JS)))
            ),
            T.body(
                nav_section,
                T.iframe(name=_PAGE_FRAME, src=page_names[0] if pages_count > 0 else 'none', width='100%', height='100%', style='border:none')
            )
        )
        self.pages['index.html'] = index

        for page_index in range(pages_count):
            page_items = self.rendered_items[page_index * posts_per_page: (page_index + 1) * posts_per_page]
            chunk_html = T.html(
                T.head(stylesheet('page.css')),
                T.body(
                    T.div(*page_items, id=ID_CONTAINER)
                )
            )
            self.pages[page_names[page_index]] = chunk_html
Ejemplo n.º 43
0
def close_html_doc(html_doc):
    with html_doc.body.children[-1]:
        assert html_doc.body.children[-1]['class'] == 'container-fluid'
        with tags.div(id="search_modal"):
            tags.attr(cls="modal fade")


    with html_doc:
        # add footnotes content of this section:
        with tags.ol(id="footnotes"):
            for (id) in html_doc.footnote_ids_of_this_html_doc:
                footnote = word_doc_footnotes.footnotes_part.notes[id + 1]
                assert footnote.id == id
                htmler.add_footnote_to_output(footnote.paragraphs)

        # add placeholder for searching
        tags.comment("search_placeholder")

    place_holder = "<!--search_placeholder-->"
    with open("input_web/stub_search.html", 'r') as file:
        search_html = file.read()

    html_doc_name = html_doc.index
    name = "debug_%s.html" % html_doc_name
    with open("output/" + name, 'w') as f:
        f.write(html_doc.render(pretty=True).encode('utf8'))
    replace_in_file("output/" + name, place_holder, search_html)

    name = "%s.html" % html_doc_name
    with open("output/" + name, 'w') as f:
        f.write(html_doc.render(pretty=False).encode('utf8'))
        print "Created ", name
    replace_in_file("output/" + name, place_holder, search_html)
Ejemplo n.º 44
0
    def get_html(self, pretty=True):
        """Generates html code for displaying data for this metadata element"""

        root_div = div(cls="content-block")

        def get_th(heading_name):
            return th(heading_name, cls="text-muted")

        with root_div:
            legend('Cell Information')
            with table(cls='custom-table'):
                with tbody():
                    with tr():
                        get_th('Rows')
                        td(self.rows)
                    with tr():
                        get_th('Columns')
                        td(self.columns)
                    with tr():
                        get_th('Cell Size X Value')
                        td(self.cellSizeXValue)
                    with tr():
                        get_th('Cell Size Y Value')
                        td(self.cellSizeYValue)
                    with tr():
                        get_th('Cell Data Type')
                        td(self.cellDataType)

        return root_div.render(pretty=pretty)
Ejemplo n.º 45
0
 def state_field(self, ):
     st = "off"
     if self.value == '1':
         st = "on"
     elif self.value == '0':
         st = "off"
     return div(cls="field-value field-value-icon "+st, id=str(self.id))
Ejemplo n.º 46
0
 def blind(self, ):
     btn_up = input(value='click', type="button", cls='btn btn-md btn-primary', id="input" + str(self.id))
     st = "off"
     if self.value == '1':
         st = "on"
     elif self.value == '0':
         st = "off"
     btn_state = div(cls="field-value field-value-icon "+st, id=str(self.id))      
     return btn_up, btn_state
Ejemplo n.º 47
0
    def get_update_netcdf_file_html_form(self):
        form_action = "/hsapi/_internal/{}/update-netcdf-file/".format(self.logical_file.id)
        style = "display:none;"
        self.refresh_from_db()
        if self.is_dirty:
            style = "margin-bottom:15px"
        root_div = div(id="div-netcdf-file-update", cls="row", style=style)

        with root_div:
            with div(cls="col-sm-12"):
                with div(cls="alert alert-warning alert-dismissible", role="alert"):
                    div("NetCDF file needs to be synced with metadata changes.", cls='space-bottom')
                    input(id="metadata-dirty", type="hidden", value=self.is_dirty)
                    with form(action=form_action, method="post", id="update-netcdf-file"):
                        button("Update NetCDF File", type="button", cls="btn btn-primary",
                               id="id-update-netcdf-file")

        return root_div
Ejemplo n.º 48
0
def _render_message(msg):
    _render_header_entries(msg.annotated_header_entries)

    body, transforms = _displayable_body(msg)
    if body != u'':
        with H.div(**_for_object(msg.body, u'body-display')):
            if body is None:
                H.h3(u'Body is unknown')
            elif body is Unavailable:
                H.h3(u'Body is present, but not available for inspection')
            else:
                if transforms:
                    H.h3(u'Body after %s' % nicely_join(transforms))
                H.pre(body)

    if msg.trailer_entries:
        with H.div(_class=u'trailer'):
            H.h3(u'Headers from the trailer part')
            _render_header_entries(msg.annotated_trailer_entries)
Ejemplo n.º 49
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)
Ejemplo n.º 50
0
    def get_html(self, pretty=True):
        """Generates html code for displaying data for this metadata element"""

        root_div = div()

        def get_th(heading_name):
            return th(heading_name, cls="text-muted")

        with root_div:
            with div(cls="custom-well"):
                strong(self.name)
                with table(cls='custom-table'):
                    with tbody():
                        with tr():
                            get_th('Variable Name')
                            td(self.variableName)
                        with tr():
                            get_th('Variable Unit')
                            td(self.variableUnit)
                        if self.noDataValue:
                            with tr():
                                get_th('No Data Value')
                                td(self.noDataValue)
                        if self.maximumValue:
                            with tr():
                                get_th('Maximum Value')
                                td(self.maximumValue)
                        if self.minimumValue:
                            with tr():
                                get_th('Minimum Value')
                                td(self.minimumValue)
                        if self.method:
                            with tr():
                                get_th('Method')
                                td(self.method)
                        if self.comment:
                            with tr():
                                get_th('Comment')
                                td(self.comment)

        return root_div.render(pretty=pretty)
Ejemplo n.º 51
0
def list_notices(buf):
    title = u'HTTPolice notices'
    document = dominate.document(title=title)
    _common_meta(document)
    with document:
        H.h1(title)
        with H.div(_class=u'notices-list'):
            placeholder = Placeholder()
            for id_ in sorted(notice.notices.keys()):
                _notice_to_html(notice.notices[id_], placeholder,
                                with_anchor=True)
    buf.write(document.render().encode('utf-8'))
Ejemplo n.º 52
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)
Ejemplo n.º 53
0
    def _get_wrap(self, node, classes='form-group'):
        # add required class, which strictly speaking isn't bootstrap, but
        # a common enough customization
        if node.flags.required:
            classes += ' required'

        div = tags.div(_class=classes)
        if current_app.debug:
            div.add(tags.comment(' Field: {} ({}) '.format(
                node.name, node.__class__.__name__)))

        return div
Ejemplo n.º 54
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
Ejemplo n.º 55
0
def _render_exchanges(exchanges):
    for exch in exchanges:
        with H.div(_class=u'exchange'):
            # The ``hr`` elements really help readability in w3m.
            if exch.request:
                _render_request(exch.request)
                H.hr()
            for resp in exch.responses:
                _render_response(resp)
                H.hr()
            if exch.complaints:
                _render_complaints(exch)
                H.hr()
Ejemplo n.º 56
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)
Ejemplo n.º 57
0
    def visit_Subgroup(self, node):
        if not self._in_dropdown:
            div = tags.div(_class='nav-item dropdown')
            if node.active:
                div['class'] += ' active'
            a = div.add(tags.a(node.title, href='#',
                               _class='nav-link dropdown-toggle'))
            a['data-toggle'] = 'dropdown'
            a['role'] = 'button'
            a['aria-haspopup'] = 'true'
            a['aria-expanded'] = 'false'

            menu = div.add(tags.div(_class='dropdown-menu'))

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

            return div
        else:
            raise RuntimeError('Cannot render nested Subgroups')
Ejemplo n.º 58
0
    def get_html(self):
        """overrides the base class function"""

        html_string = super(RefTimeseriesFileMetaData, self).get_html()
        if self.abstract:
            abstract_div = div(cls="content-block")
            with abstract_div:
                legend("Abstract")
                p(self.abstract)

            html_string += abstract_div.render()
        if self.file_version:
            file_ver_div = div(cls="content-block")
            with file_ver_div:
                legend("File Version")
                p(self.file_version)
            html_string += file_ver_div.render()
        if self.symbol:
            symbol_div = div(cls="content-block")
            with symbol_div:
                legend("Symbol")
                if self.symbol.startswith('http'):
                    with p():
                        a(self.symbol, href=self.symbol, target="_blank")
                else:
                    p(self.symbol)
            html_string += symbol_div.render()
        if self.temporal_coverage:
            html_string += self.temporal_coverage.get_html()

        if self.spatial_coverage:
            html_string += self.spatial_coverage.get_html()

        html_string += self.get_ts_series_html().render()
        html_string += self.get_json_file_data_html().render()
        template = Template(html_string)
        context = Context({})
        return template.render(context)
Ejemplo n.º 59
0
    def get_html(self):
        """overrides the base class function"""

        html_string = super(GenericFileMetaDataMixin, self).get_html()
        if not self.has_metadata:
            no_metadata_message = div(id="#fb-metadata-default", cls="text-center text-muted",
                                      role="alert")
            with no_metadata_message:
                div("No file level metadata exists for the selected file.")
                hr()
                i_tag = i(cls="fa fa-eye-slash fa-2x")
                i_tag['aria-hidden'] = 'true'
            html_string = no_metadata_message.render()
        else:
            if self.temporal_coverage:
                html_string += self.temporal_coverage.get_html()

            if self.spatial_coverage:
                html_string += self.spatial_coverage.get_html()

        template = Template(html_string)
        context = Context({})
        return template.render(context)
Ejemplo n.º 60
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)