Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load_logo function update. #66

Merged
merged 1 commit into from
Aug 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 2 additions & 27 deletions home/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,35 +53,10 @@ def load_start_md(name):


def load_logo(app):
"""Return logo object. Give the priority to the local version"""
"""Return HTML widget containing the logo."""

# For some reason standard ipw.Image() app does not work properly.
res = ipw.HTML(
'<img src="./aiidalab_logo_v4.svg">',
f'<img src="{app.logo}">',
layout={"width": "100px", "height": "100px"},
)

# Checking whether the 'logo' key is present in metadata dictionary.
if "logo" not in app.metadata:
res.value = '<img src="./aiidalab_logo_v4.svg">'

# If 'logo' key is present and the app is installed.
elif app.is_installed():
res.value = '<img src="{}">'.format(
path.join("..", app.name, app.metadata["logo"])
)

# If not installed, getting file from the remote git repository.
else:
# Remove .git if present.
html_link = path.splitext(app.url)[0]

# We expect it to always be a git repository
html_link += "/master/" + app.metadata["logo"]
if "github.com" in html_link:
html_link = html_link.replace("github.com", "raw.githubusercontent.com")
if html_link.endswith(".svg"):
html_link += "?sanitize=true"
res.value = '<img src="{}">'.format(html_link)

return res