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
def pager(self, *args, **kwargs): with tags.div(cls=u"pagination-wrapper") as wrapper: tags.ul(u"$link_previous ~2~ $link_next", cls=u"pagination") kwargs.update( format=text_type(wrapper), symbol_previous=u"«", symbol_next=u"»", curpage_attr={u"class": u"active"}, link_attr={}, ) return super(Page, self).pager(*args, **kwargs)
def pager(self, *args: Any, **kwargs: Any) -> Markup: with tags.div(cls=u"pagination-wrapper") as wrapper: tags.ul(u"$link_previous ~2~ $link_next", cls=u"pagination") params = dict( format=str(wrapper), symbol_previous=u"«", symbol_next=u"»", curpage_attr={u"class": u"active"}, link_attr={}, ) params.update(kwargs) return super(Page, self).pager(*args, **params)
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
def trans_html(container, payload, source): container.add(div(f'{langs[source]} detected', cls='lang')) trlns_box = container.add(div()).add(ul(cls='definition')) for t in payload: trlns_box.add(ul()) trlns_box.add(li(langs[t['to']])) trln_text = trlns_box.add(div(cls='indent')) trln_text.add(div(t['text'], cls='translation')) try: lit = t['transliteration'] trln_text.add(p(f"({lit['text']})", cls='lit')) except KeyError: continue
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') if hasattr(node, '_class'): root['class'] = node._class else: 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')) 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())) elif hasattr(node.title, 'image'): header.add(tags.span(tags.img(_src=node.title.image, _class='brand-img'), _class='navbar-brand')) 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')) for item in node.items: if hasattr(item, 'right'): bar_list_right.add(self.visit(item)) else: bar_list.add(self.visit(item)) return root
def generateStatsHTML(graph,statsFilePath = "stats.html",postStatsFilePath = "postStats.html"): #Generates the Stats HTML section firstLevel = checkFirstLevel(graph) softwareLabelNum = queryVersionNum(graph) softwareLabelNumList = addQueryToList(softwareLabelNum) stats = document(title="FSL Viewer") #Creates initial html page (stats) stats += h1("Sample FSL Viewer") stats += ul(li(a("Stats", href="stats.html")), li("-"),li(a("Post Stats", href = "postStats.html"))) stats += h2("Stats") stats += hr() stats += h3("Analysis Methods") if askSpm(graph) == True: #Checks if SPM was used stats += p("FMRI data processing was carried out using SPM Version %s (SPM, http://www.fil.ion.ucl.ac.uk/spm/)." % softwareLabelNumList[1]) elif askFsl(graph) == True: #Checks if FSL was used fslFeatVersion = queryFslFeatVersion(graph) stats += p("FMRI data processing was carried out using FEAT (FMRI Expert Analysis Tool) Version %s, part of FSL %s (FMRIB's Software Library, www.fmrib.ox.ac.uk/fsl)." % (fslFeatVersion[0], softwareLabelNumList[1])) stats += hr() stats += h3("Design Matrix") designMatrixLocation = queryDesignMatrixLocation(graph) stats += a(img(src = designMatrixLocation[1], style = "border:5px solid black", border = 0), href = designMatrixLocation[0]) #Adds design matrix image (as a link) to html page statsFile = open(statsFilePath, "x") print(stats, file = statsFile) #Prints html page to a file statsFile.close()
def render_comment(self, row: Row): """Render description column.""" comment = row.get('comment', '') or '' if comment: yield raw(comment) if row['prov_value'] is None: return see_also_links = list( map( operator.itemgetter('link'), self.query( ''' SELECT ?link WHERE { $node rdfs:seeAlso ?link . OPTIONAL { $node octa:position ?position . } } ORDER BY ?position ''', node=row['prov_value'], ), ), ) if see_also_links: yield ul( li(render( node=link, octiron=self.octiron, ), ) for link in see_also_links)
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
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'))
def _add_item(self, pocket_item: PocketItem) -> None: """Add a pocket item to the HTML report page Args: pocket_item (PocketItem): Returns: None """ self.doc.add(tags.h3(pocket_item.title, cls="defaultfontfamily")) # Add bullets pocket_item_description = tags.ul() pocket_item_description += tags.li( "Link: ", tags.a(pocket_item.url, href=pocket_item.url), cls="defaultfontfamily", ) pocket_item_description += tags.li( "Tags: ", ", ".join([elem for elem in pocket_item.tags]), cls="defaultfontfamily", ) pocket_item_description += tags.li( "Time added: ", pocket_item.convert_datetime_to_string(pocket_item.time_added), cls="defaultfontfamily", ) self.doc.add(pocket_item_description)
def visit_Navbar(self, node): root = tags.ul(_class="nav nav-tabs nav-fill") for item in node.items: root.add(self.visit(item)) return root
def directory_list(octiron: Octiron, iri: Node) -> Union[html_tag, str]: """Render a list of subdirectories in given directory.""" links = map( Prodict, octiron.query( ''' SELECT * WHERE { ?index_page octa:isChildOf ?directory . ?directory octa:isParentOf / octa:isParentOf / octa:isParentOf ?link . ?link a octa:IndexPage ; octa:title ?title ; octa:url ?url . } ORDER BY ?title ''', index_page=iri, )) lis = [li(a(link.title, href=link.url)) for link in links] return ul(*lis)
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')
def visit_Subgroup(self, node): if not self._in_dropdown: node_id = sha1(str(id(node)).encode()).hexdigest() li = tags.li(_class='dropdown') if node.active: li['class'] = 'active' a = li.add( tags.a(href='javascript:void(0);', _class='dropdown-toggle')) a.add(tags.i(_class='fa fa-fw fa-arrows-v')) a.add(node.title) a['data-toggle'] = 'collapse' a['data-target'] = '#' + node_id a['role'] = 'button' a['aria-haspopup'] = 'true' a['aria-expanded'] = 'false' if hasattr(node, 'icon') and node.icon != None: a.add(tags.i(_class='fa fa-fw fa-%s' % node.icon)) ul = li.add(tags.ul(_class='collapse', id=node_id)) active = node.active self._in_dropdown = True for item in node.items: ul.add(self.visit(item)) if item.active: active = True self._in_dropdown = False if active == True: li['class'] = 'sub_active' ul['class'] = 'collapse in' return li else: raise RuntimeError('Cannot render nested Subgroups')
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
def visit_SuperGroup(self, node): li = tags.li(_id=sanitise_for_css(node.title.text), _class="parent") if node.title.active: li['class'] = 'parent active' a = li.add(tags.a(node.title.text, href=node.title.get_url())) ul = tags.ul(*[self.visit(item) for item in node.items]) ul2 = li.add(ul) return li
def generateMainHTML(graph,mainFilePath = "Main.html", statsFilePath = "stats.html", postStatsFilePath = "postStats.html"): #Generates the main HTML page main = document(title="FSL Viewer") main += h1("Sample FSL Viewer") main += ul(li(a("Stats", href="stats.html")), li("-"),li(a("Post Stats", href = "postStats.html"))) mainFile = open(mainFilePath, "x") print(main, file = mainFile) mainFile.close()
def append_list(self, *items): with self.doc.body: with ul() as unorderedList: for item in items: if type(item) is list: self.append_list(*item) else: li(item)
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
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'): # a_tag = tags.a(node.title.text, _class='navbar-brand', # href=node.title.get_url()) style = 'max-width:100px;margin-top: 18px;margin-right: 4px;' header.add( tags.span('pip install', _class='navbar-left hidden-xs', style=style)) a_tag = tags.a(_class='navbar-left', title=node.title.text, href=node.title.get_url()) a_tag.add( tags.img(src='/images/logo_lofi.png', style='max-width:100px;margin-top: 10px;')) header.add(a_tag) 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
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 report_list_group(self, items, **kwargs): """ Creates a list group. Each arg is a line :param str title: Title of the section :param list items: Each arg passed will be treated as a new list item :param bool section: Kwarg Set to True to append the cards section to the preceding section. Default is false :param tuple alert: Kwarg Create a dismissable alert box. First value of tuple is the color, and the second is the message :param tuple reference: Kwarg Adds a small button which hrefs to a user supplied link. Is a tuple. First value is color, second is link :param dict badge: Kwarg Adds badges. Key is the color, and value is the message. :param str custom_html: Insert raw html to be added to the end of the section :param dict modal: Create a modal. Is a dictionary. Valid keys are button, title and content :raises NoValidTag: Raises not valid tag Example: >>> r += report.report_list_group('First entry', 'Second entry', ...) """ if not kwargs.get('title'): raise rng.NotValidTag('Need a title') title = kwargs.get('title') if not isinstance(items, list): raise rng.NotValidTag('Items have to be in the form of a list') if 'section' in kwargs: style = rng.CSSControl.sticky_section_css else: style = rng.CSSControl.css_overflow with tag.div( _class="jumbotron container context reportng-list-group-class", style=style) as r: t = tag.h1(title, id="%s" % rng.HelperFunctions.id_with_random(5, title)) # creates a reference button with link if 'reference' in kwargs: t.add(rng.HelperFunctions.ref_button(kwargs.get('reference'))) # creates dismissable alert box if 'alert' in kwargs: rng.HelperFunctions.make_alert(kwargs.get('alert')) with tag.ul(_class="list-group"): for i in range(len(items)): tag.li( items[i], _class= "list-group-item d-flex justify-content-between align-items-center text-primary" ) if 'badge' in kwargs: rng.HelperFunctions.create_badges(kwargs.get('badge')) if 'custom_html' in kwargs: raw(kwargs.get('custom_html')) if 'modal' in kwargs: if isinstance(kwargs.get('modal'), dict): rng.HelperFunctions.make_modals(title.replace(' ', ''), kwargs.get('modal')) return rng.HelperFunctions.convert_to_string(r)
def visit_Navbar(self, node): kwargs = {'_class': 'navbar'} kwargs.update(self.kwargs) cont = tags.nav(**kwargs) ul = cont.add(tags.ul()) for item in node.items: ul.add(tags.li(self.visit(item))) return cont
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)
def uniCourseList(): """ Make a list of universities and their courses. """ results = g.query(""" select distinct ?courseName ?instructorFN ?instructorGN ?university where { ?id a ccso:Course . ?id ccso:csName ?courseName . ?id ccso:hasInstructor ?inst . ?inst foaf:familyName ?instructorFN . ?inst foaf:givenName ?instructorGN . ?id ccso:offeredBy ?dept . ?dept ccso:belongsTo ?uni . ?uni ccso:legalName ?university . } limit 400""") # Build up a dictionary with universities as keys, # and courses as a list of values byUniversity = {} for courseName, instLast, instFirst, uni in results: # print(line) if uni in byUniversity: byUniversity[uni].append((courseName, instLast, instFirst)) else: byUniversity[uni] = [(courseName, instLast, instFirst)] uniList = ul(cls="universities") for uni in byUniversity: courses = byUniversity[uni] uniLi = uniList.add(li(uni, cls="university")) courseList = uniLi.add(ul(cls="courseList")) for course in courses: courseName, instFN, instGN = course name = f"{instGN} {instFN}" courseList.add( li(span(courseName, cls="courseName"), span(", "), span(name, cls="instName"), cls="course")) return h2("Courses by University"), uniList
def generateHtml(): with open(path.join(current_dir, '../changelog/', 'storage.json'), 'r') as f: data = json.load(f)[::-1] doc = document(title='Changelog - lkellar.org') articles = [] with doc.head: tags.link(rel='stylesheet', href='style.css') tags.meta(charset="UTF-8") tags.meta(name="description", content="A log of all changes made on lkellar.org") tags.meta(name="viewport", content="width=device-width, initial-scale=1") tags.link(rel="alternate", title="Changelog Feed", type="application/json", href="https://lkellar.org/changelog/feed.json") with doc: with tags.nav().add(tags.ol()): with tags.li(): tags.a("Home", href="../") tags.li("Changelog") with tags.main(): tags.h1('Changelog') for entry in data: tags.hr() article_content = tags.article() with article_content: tags.h2( f'{entry["title"]} - {entry["date"].split("T")[0]}', id=f'{entry["title"]} - {entry["date"]}'.replace( ' ', ''.lower())) list_content = tags.ul() with list_content: for line in entry['items']: line = urls.sub(r'<a href="\2">\1</a>', line) tags.li(raw(line)) articles.append((f'{entry["title"]} - {entry["date"]}'.replace( ' ', ''.lower()), list_content.render(), entry["date"], entry['title'])) with open(path.join(current_dir, '../changelog/', 'index.html'), 'w') as f: f.write(doc.render()) generateFeed(articles)
def _ul_right(self): img_ = img( _class="h-full w-full rounded-full mx-auto", src= ("https://avatars.githubusercontent.com/u/54931660?s=400&u=dcf55" "50498aee3550f2b2f835345d802fabe1833&v=4&_sm_au_=iNVf4trk1MFNLS" "NnVsBFjK664v423"), alt="profile boss", ) li_ = li(img_, _class="h-10 w-10") ul_right = ul(li_, _class="flex items-center") return ul_right
def visit_Subgroup(self, node): # 'a' tag required by smartmenus title = tags.a(node.title, href="#") group = tags.ul(_class='subgroup') if node.active: title.attributes['class'] = 'active' for item in node.items: group.add(tags.li(self.visit(item))) return [title, group]
def add_nulls(self): with self.doc: dtg.h2("Null tests", id='nulls') lst = dtg.ul() sorter = self.s_null.sortTracers() # All cross-correlations xcorrs = np.array(["%d_%d" % (s[0], s[1]) for s in sorter]) # Unique cross-correlations xc_un = np.unique(xcorrs) cls_null = self.s_null.mean.vector err_null = np.sqrt(self.s_null.precision.getCovarianceMatrix()) # Loop over unique correlations for comb in xc_un: t1, t2 = comb.split('_') t1 = int(t1) t2 = int(t2) # Find all power spectra for this pair of tracers ind_spectra = np.where(xcorrs == comb)[0] # Plot title title = self.s_null.tracers[t1].name[2:-1] title += " x " title += self.s_null.tracers[t2].name[2:-1] # Plot file fname = self.get_output('plots') + '/cls_null_' fname += self.s_null.tracers[t1].name[2:-1] fname += "_x_" fname += self.s_null.tracers[t2].name[2:-1] fname += ".png" print(fname) # Plot all power spectra plt.figure() plt.title(title, fontsize=15) for ind in ind_spectra: typ = sorter[ind][2].decode() ndx = sorter[ind][4] plt.errorbar(self.ells[self.msk], (cls_null[ndx] / err_null[ndx])[self.msk], yerr=np.ones(len(ndx))[self.msk], fmt=self.cols_typ[typ] + '-', label=typ) plt.xlabel('$\\ell$', fontsize=15) plt.ylabel('$C_\\ell/\\sigma_\\ell$', fontsize=15) plt.legend() plt.savefig(fname, bbox_index='tight') plt.close() lst += dtg.li(dtg.a(title, href=fname)) dtg.div(dtg.a('Back to TOC', href='#contents'))
def get_keywords_html(self): """generates html for viewing keywords""" keywords_div = div() if self.keywords: keywords_div = div(cls="col-sm-12 content-block") with keywords_div: legend('Keywords') with div(cls="tags"): with ul(id="list-keywords-file-type", cls="tag-list custom-well"): for kw in self.keywords: with li(): a(kw, cls="tag") return keywords_div
def get_html(self): """Generates html for displaying all metadata elements associated with this logical file. Subclass must override to include additional html for additional metadata it supports. """ root_div = div() dataset_name_div = div() if self.logical_file.dataset_name: with dataset_name_div: with table(cls='custom-table'): with tbody(): with tr(): th("Title", cls="text-muted") td(self.logical_file.dataset_name) keywords_div = div() if self.keywords: keywords_div = div(cls="col-sm-12 content-block") with keywords_div: legend('Keywords') with div(cls="tags"): with ul(id="list-keywords-file-type", cls="tag-list custom-well"): for kw in self.keywords: with li(): a(kw, cls="tag") extra_metadata_div = div() if self.extra_metadata: extra_metadata_div = div(cls="col-sm-12 content-block") with extra_metadata_div: legend('Extended Metadata') with table(cls="table table-striped funding-agencies-table", style="width: 100%"): with tbody(): with tr(cls="header-row"): th("Key") th("Value") for k, v in self.extra_metadata.iteritems(): with tr(data_key=k): td(k) td(v) if self.logical_file.dataset_name: root_div.add(dataset_name_div) if self.keywords: root_div.add(keywords_div) if self.extra_metadata: root_div.add(extra_metadata_div) return root_div.render()
def render_property_values( property_values: List[Node], octiron: Octiron, ) -> str: rendered_values = [ render( node=property_value, octiron=octiron, environments=[ADR.term('sidebar-property-value')], ) for property_value in property_values ] if len(rendered_values) == 1: return rendered_values[0] return ul(*map(li, rendered_values))
def getTableTabsDiv(r): table_tabs_div = div(['contentHolder', 'contentHolder'], cls='container') tablist = ul(cls='nav nav-pills mb-3') tablist.attributes['role'] = "tablist" tab_names = list() for count in range(len(r.report_df_list)): tab_names.append(getFormattedName(r.alg_names_list[count])) for count in range(len(r.report_df_list)): if (count == 0): tab = a(r.alg_names_list[count], cls="nav-link active", href='#' + tab_names[count] + "-tab-pane") else: tab = a(r.alg_names_list[count], href='#' + tab_names[count] + "-tab-pane", cls="nav-link") tab.attributes['data-toggle'] = "pill" li_element = li(tab, cls='nav-item') tablist += li_element table_tabs_div[0] = tablist tabContentDiv = div(cls='tab-content') for count in range(len(r.report_df_list)): if (count == 0): tabdiv = div(getDescriptionPills( r.report_df_list[count]['Error'].describe()), id=tab_names[count] + "-tab-pane", cls='tab-pane active') else: tabdiv = div(getDescriptionPills( r.report_df_list[count]['Error'].describe()), id=tab_names[count] + "-tab-pane", cls='tab-pane fade') tabdiv.appendChild( div('contentHolder', id=tab_names[count] + "-chart-div")) tabdiv.appendChild(div(getErrorTableContent(r.report_df_list[count]))) tabContentDiv.appendChild(tabdiv) table_tabs_div[1] = tabContentDiv return table_tabs_div.render()
def visit_Navbar(self, node): root = super(TwoSideRenderer, self).visit_Navbar(node) # hack: add navbar-right block collapse = root.children[0].children[1] right = tags.ul(_class='nav navbar-nav navbar-right') if hasattr(node, 'right_side_items'): for item in node.right_side_items: right.add(self.visit(item)) collapse.add(right) # hack: logo brand = root.children[0].children[0].children[1] brand.attributes['class'] = '' brand.add(self.visit(node.logo)) return root
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
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")
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')
def fix_links(html_docs_l): # fix outbound links print "Fixing links" for (doc) in html_docs_l: for (child) in doc.body.children[0].children: if 'definition' in child.attributes.get('class', ()): href = "" try: href = child.children[0].attributes.get("href") except AttributeError as e: pass # it's a link - try to update it if href: # first, strip it of weird chars try: href = clean_name(href) updated = False if update_values_for_href(child, href): updated = True else: if href[0] in (u"ה", u"ו", u"ש", u"ב", u"כ", u"ל", u"מ"): updated = update_values_for_href(child, href[1:]) if not updated: # failed to update - it's not a real link... update_href_no_link(child) except Exception as e: pass print e, "Exception of HREF update", href #TODO - investigate why it happens? (it's a single corner case, I think) def sorter(html_doc): if html_doc.name in [u"ערכים כלליים",]: return "FIRST" if html_doc.name in [u"נספחות",]: return u"תתתתתתתתתת" #last else: return html_doc.name # update sections menu for (doc) in html_docs_l: letters_l = [] # content_menu = doc.body.children[0].children[1].children[0].children[0].children[-1].children[0].children[1] content_menu = doc.body.children[0].children[1].children[0].children[1].children[-1] assert content_menu['class'] == 'dropdown-menu dropdown-menu-left scrollable-menu' with content_menu: with tags.li(): tags.a(u"אודות", href="index.html") with tags.li(): tags.a(u"הקדמות", href="opening_intros.html") with tags.li(): tags.a(u"הסכמות", href="opening_haskamot.html") with tags.li(): tags.a(u"קיצורים", href="opening_abbrev.html") with tags.li(): tags.a(u"סימנים", href="opening_signs.html") # if you add more entries here, please update add_menu_to_apriory_htmls(..) with tags.li(): tags.attr(cls="divider") sorted_html_docs_l = sorted(html_docs_l, key=sorter) for (html_doc) in sorted_html_docs_l: # Only if this a 'high' heading, and not just a letter - include it in the TOC if html_doc.name != "NEW_LETTER": with tags.li(): tags.a(html_doc.name, href=str(html_doc.index)+".html") if doc.section == html_doc.section: tags.attr(cls="active") else: # it's a letter - if it's related to me, save it if doc.section == html_doc.section: letters_l.append(html_doc) with doc.body.children[-1]: assert doc.body.children[-1]['class'] == 'container-fluid' with tags.ul(): tags.attr(cls="pagination") for (html_doc) in letters_l: tags.li(tags.a(html_doc.letter, href=str(html_doc.index)+".html")) return html_docs_l
def generatePostStatsHTML(graph,statsFilePath = "stats.html",postStatsFilePath = "postStats.html"): #Generates Post-Stats page voxelWise = checkHeightThreshold(graph) clusterWise = checkExtentThreshold(graph) softwareLabelNum = queryVersionNum(graph) softwareLabelNumList = addQueryToList(softwareLabelNum) statisticType = queryStatisticType(graph) statisticType = statisticImage(statisticType[0]) statisticTypeString = statisticImageString(statisticType) contrastName = queryContrastName(graph) statisticMapImage = queryExcursionSetMap(graph) postStats = document(title="FSL Viewer") #Creates initial HTML page (Post Stats) postStats += h1("Sample FSL Viewer") postStats += ul(li(a("Stats", href="stats.html")), li("-"),li(a("Post Stats", href = "postStats.html"))) postStats += h2("Post-stats") postStats += hr() postStats += h3("Analysis Methods") if voxelWise == True: #If main threshold is Height Threshold mainThreshValue = queryHeightThresholdValue(graph) if askSpm(graph) == True: postStats += p("FMRI data processing was carried out using SPM Version %s (SPM, http://www.fil.ion.ucl.ac.uk/spm/). %s statistic images were thresholded at P = %s (corrected)" % (softwareLabelNumList[1], statisticTypeString, mainThreshValue[0])) elif askFsl(graph) == True: fslFeatVersion = queryFslFeatVersion(graph) postStats += p("FMRI data processing was carried out using FEAT (FMRI Expert Analysis Tool) Version %s, part of FSL %s (FMRIB's Software Library, www.fmrib.ox.ac.uk/fsl)." "%s statistic images were thresholded at P = %s (corrected)" %(fslFeatVersion[0], softwareLabelNumList[1], statisticTypeString, mainThreshValue[0])) elif clusterWise == True: #If main threshold is extent threshold mainThreshValue = queryClusterThresholdValue(graph) heightThreshValue = queryUHeightThresholdValue(graph) clusterThreshType = clusterFormingThreshType(graph, statisticType) if askSpm(graph) == True: postStats += p("FMRI data processing was carried out using SPM Version %s (SPM, http://www.fil.ion.ucl.ac.uk/spm/). %s statistic images were thresholded using clusters determined by %s > %s and a (corrected) " "cluster significance of P = %s " % (softwareLabelNumList[1], statisticTypeString, clusterThreshType, heightThreshValue[0], mainThreshValue[0])) elif askFsl(graph) == True: fslFeatVersion = queryFslFeatVersion(graph) postStats += p("FMRI data processing was carried out using FEAT (FMRI Expert Analysis Tool) Version %s, part of FSL %s (FMRIB's Software Library, www.fmrib.ox.ac.uk/fsl). %s statistic images were thresholded " "using clusters determined by %s > %s and a (corrected) cluster significance of P = %s" %(fslFeatVersion[0], softwareLabelNumList[1], statisticTypeString, clusterThreshType, heightThreshValue[0], mainThreshValue[0])) else: #If there is no corrected threshold - assume voxel wise mainThreshValue = queryUHeightThresholdValue(graph) if askSpm(graph) == True and askIfPValueUncorrected(graph) == True: #SPM used and threshold type is nidm_PValueUncorrected postStats += p("FMRI data processing was carried out using SPM Version %s (SPM, http://www.fil.ion.ucl.ac.uk/spm/). %s statistic images were thresholded at P = %s (uncorrected)" % (softwareLabelNumList[1], statisticTypeString, mainThreshValue[0])) elif askSpm(graph) == True and askIfOboStatistic(graph) == True: #SPM used and threshold type is obo_statistic postStats += p("FMRI data processing was carried out using SPM Version %s (SPM, http://www.fil.ion.ucl.ac.uk/spm/). %s statistic images were thresholded at %s = %s (uncorrected)" % (softwareLabelNumList[1], statisticTypeString, statisticType, mainThreshValue[0])) elif askFsl(graph) == True and askIfPValueUncorrected(graph) == True: fslFeatVersion = queryFslFeatVersion(graph) postStats += p("FMRI data processing was carried out using FEAT (FMRI Expert Analysis Tool) Version %s, part of FSL %s (FMRIB's Software Library, www.fmrib.ox.ac.uk/fsl)." "%s statistic images were thresholded at P = %s (uncorrected)." % (fslFeatVersion[0], softwareLabelNumList[1], statisticTypeString, mainThreshValue[0])) elif askFsl(graph) == True and askIfOboStatistic(graph) == True: fslFeatVersion = queryFslFeatVersion(graph) postStats += p("FMRI data processing was carried out using FEAT (FMRI Expert Analysis Tool) Version %s, part of FSL %s (FMRIB's Software Library, www.fmrib.ox.ac.uk/fsl)." "%s statistic images were thresholded at %s = %s (uncorrected)." % (fslFeatVersion[0], softwareLabelNumList[1], statisticTypeString, statisticType, mainThreshValue[0])) postStats += hr() postStats += h3("Thresholded Activation Images") postStats += hr() i = 0 if askFsl(graph) == True: while i < len(contrastName): postStats += p("%s" % contrastName[i]) postStats += img(src = statisticMapImage[i]) i = i + 1 postStatsFile = open(postStatsFilePath, "x") print(postStats, file = postStatsFile) postStatsFile.close()