diff --git a/src/soca/assets/template.html b/src/soca/assets/template.html index 765e709..3df1d1c 100755 --- a/src/soca/assets/template.html +++ b/src/soca/assets/template.html @@ -16,7 +16,7 @@
-
+
diff --git a/src/soca/commands/create_summary.py b/src/soca/commands/create_summary.py index fbba851..1eb40e3 100755 --- a/src/soca/commands/create_summary.py +++ b/src/soca/commands/create_summary.py @@ -1,7 +1,7 @@ from datetime import date, datetime import json import os -from soca import __version__ as soca_ver +from .. import __version__ as soca_ver from somef import __version__ as somef_ver from .upload_summary import upload_summary diff --git a/src/soca/commands/portal/metadata.py b/src/soca/commands/portal/metadata.py index f26e0ee..df124a3 100755 --- a/src/soca/commands/portal/metadata.py +++ b/src/soca/commands/portal/metadata.py @@ -1,4 +1,4 @@ -from soca import base_dir +from ... import base_dir from pathlib import Path from os import listdir from os.path import isfile, join @@ -10,45 +10,49 @@ from pygments.formatters import HtmlFormatter import mistune import os -#from cffconvert import Citation -#from cffconvert.cli import cli as cff2bibcli + + +# from cffconvert import Citation +# from cffconvert.cli import cli as cff2bibcli class metadata(object): - def __init__(self, repo_metadata_dir, repo_metadata, embedded = False): + def __init__(self, repo_metadata_dir, repo_metadata, embedded=False): self.repo_metadata_dir = os.path.abspath(repo_metadata_dir) self.md = repo_metadata self.base = 'https://github.com/oeg-upm/soca/tree/main/src/soca/assets' if embedded else '' # Assets #################################################### def logo(self): - logo = safe_dic(safe_dic(safe_dic(safe_list(self.md,'logo'),0),'result'),'value') - #if logo: - #if str(logo).startswith('https://github'): - #logo = logo.replace("github.com", "raw.githubusercontent.com").replace("/blob/", "/") + logo = safe_dic(safe_dic(safe_dic(safe_list(self.md, 'logo'), 0), 'result'), 'value') + # if logo: + # if str(logo).startswith('https://github'): + # logo = logo.replace("github.com", "raw.githubusercontent.com").replace("/blob/", "/") return logo if logo else f"{self.base}img/github-default.svg" def html_repo_type(self): repo_type = self.repo_type() if not repo_type: return '' - if repo_type == 'web': - return f'repo-type' - elif repo_type == 'ontology': - #ontologies = safe_dic(safe_dic(self.md,'ontologies'),'excerpt') - ontologies = safe_dic(self.md,'ontologies') + if repo_type == 'web': + return f'repo-type' + elif repo_type == 'ontology': + # ontologies = safe_dic(safe_dic(self.md,'ontologies'),'excerpt') + ontologies = safe_dic(self.md, 'ontologies') if ontologies: - onto_list = '\n'.join(list(dict.fromkeys([ f'* <{safe_dic(safe_dic(x,"result"),"value")}>' for x in ontologies if 'http' in safe_dic(safe_dic(x,"result"),"value")]))) - #onto_list = '\n'.join([ f'* <{safe_dic(x,"file_url")}>' for x in ontologies]) + onto_list = '\n'.join(list(dict.fromkeys( + [f'* <{safe_dic(safe_dic(x, "result"), "value")}>' for x in ontologies if + 'http' in safe_dic(safe_dic(x, "result"), "value")]))) + # onto_list = '\n'.join([ f'* <{safe_dic(x,"file_url")}>' for x in ontologies]) return self.icon_wrapper( - icon_html = f'repo-type', - modal_html= self.modal( - title= 'Ontologies', - body= onto_list + icon_html=f'repo-type', + modal_html=self.modal( + title='Ontologies', + body=onto_list ), other_field='class="m_ontology"' ) - return f'
repo-type
' + return f'
repo-type
' def icon_star(self): return f"{self.base}repo_icons/star.png" @@ -67,7 +71,8 @@ def html_languages(self): return '' language_icons_dir = Path(base_dir, 'assets', 'language_icons') - supported_languages = [str(f).removesuffix('.svg').lower() for f in listdir(language_icons_dir) if isfile(join(language_icons_dir, f))] + supported_languages = [str(f).removesuffix('.svg').lower() for f in listdir(language_icons_dir) if + isfile(join(language_icons_dir, f))] html = '' @@ -86,7 +91,7 @@ def copy_btn(self): """ def html_license(self, license_input): - if safe_dic(license_input,"url"): + if safe_dic(license_input, "url"): html = """

@@ -105,14 +110,13 @@ def html_license(self, license_input): """ else: html = f""" -

{safe_dic(license_input,"name")}

+

{safe_dic(license_input, "name")}

Description:

There is not an available description.

""" return html - def html_repo_icons(self): html = '' @@ -120,92 +124,92 @@ def html_repo_icons(self): readme_url = self.readme() if readme_url: html += self.icon_wrapper( - icon_html = f""" + icon_html=f""" + {self.add_tooltip('bottom', 'Readme')}> """) license = self.license() if license: - html += self.icon_wrapper( - icon_html = f""" + {self.add_tooltip('bottom', f'License: {safe_dic(license, "name")}')}> """, - modal_html= self.modal( - title = 'License', - body = self.html_license(license), + modal_html=self.modal( + title='License', + body=self.html_license(license), markdown_translation=False), - other_field = f'data-url="{safe_dic(license,"url")}"', - extra_class = 'ref-license' - ) - + other_field=f'data-url="{safe_dic(license, "url")}"', + extra_class='ref-license' + ) + notebook = self.notebook() if notebook: mk_list = "\n".join([f'* <{n}>' for n in notebook]) html += self.icon_wrapper( - icon_html = f"""""", - - modal_html = self.modal( - title = 'Notebook', - body = mk_list)) + {self.add_tooltip('bottom', 'Notebook')}>""", + modal_html=self.modal( + title='Notebook', + body=mk_list)) docker = self.docker() if docker: mk_list = "\n".join([f'* <{d}>' for d in docker]) html += self.icon_wrapper( - icon_html = f"""""", + {self.add_tooltip('bottom', "Docker")}>""", - modal_html = self.modal( - title = 'Docker', - body = mk_list)) + modal_html=self.modal( + title='Docker', + body=mk_list)) papers = self.paper() if papers: for paper in papers: html += self.icon_wrapper( - icon_html = f""" + icon_html=f""" + {self.add_tooltip('bottom', paper.title_paper)}> """) - #TODO check ScdocLexer + # TODO check ScdocLexer citations = self.citations() if citations: citation = "No Citation Indicated" formatter = HtmlFormatter(linenos=False, full=True, style='friendly') - #TODO once fixed turn to if, elif, else so that it prioritises CFF (converted to bibtex format) - if 'cff' in citations: + # TODO once fixed turn to if, elif, else so that it prioritises CFF (converted to bibtex format) + if 'bibtex' in citations: + citation = safe_dic(citations, "bibtex") + elif 'cff' in citations: + citation = safe_dic(citations, "cff") + if citation: + citation.replace("`", "") # try: # cite = Citation(cffstr=safe_dic(citations,"cff")) # citation = cite.as_bibtex() # except: - pass - if 'bibtex' in citations: - citation = safe_dic(citations,"bibtex") else: try: citation = citations['citation'][0] - #citation = safe_list(safe_dic(citations,citation),0) + # citation = safe_list(safe_dic(citations,citation),0) except Exception as e: print(str(e)) html += self.icon_wrapper( - icon_html = f"""""", - modal_html = self.modal( - title = 'Citation', - body = f'
{highlight(citation, ScdocLexer(), formatter)}
', + {self.add_tooltip('bottom', f"Citation")}>""", + modal_html=self.modal( + title='Citation', + body=f'
{highlight(citation, ScdocLexer(), formatter)}
', markdown_translation=False, extra_html= - f""" + f"""