Skip to content

Commit

Permalink
feat: add customize project logo
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnacioHeredia committed Aug 27, 2024
1 parent d7cd87a commit 1358d3a
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,4 @@ For archival purposes, as option 2 was the initial approach, we provide:
All the best practices can be seen in the [demo_app API implementation](https://github.com/ai4os-hub/ai4os-demo-app/blob/main/ai4os_demo_app/api.py). Here is how the UI looks like (left-hand side are inputs, right-hand side are outputs):
![](demo-ui.png)
![](./_static/images/demo-ui.png)
File renamed without changes
File renamed without changes.
Binary file added _static/images/logo-ai4eosc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _static/images/logo-imagine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ def main(api_url, ui_port):
theme=gr.themes.Default(
primary_hue=gr.themes.colors.cyan,
),
css=".ai4eosc-logo {border-radius: 10px;}",
)

interfaces.append(interface)
Expand All @@ -156,7 +155,7 @@ def main(api_url, ui_port):
server_port=ui_port,
show_error = True,
debug=False,
favicon_path='./favicon.ico'
favicon_path='./_static/images/favicon.ico'
)


Expand Down
30 changes: 24 additions & 6 deletions ui_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import inspect
import json
import mimetypes
import os
from pathlib import Path
import re
import requests
Expand Down Expand Up @@ -370,21 +371,38 @@ def generate_footer(metadata):
version_text = f"deepaas_ui/{git_branch}@{git_commit[:5]}"
version_link = f"https://github.com/ai4os/deepaas_ui/tree/{git_commit}"

# Get module description
description = metadata.get('description', '')
if not description:
# In old modules, description was named "summary"
description = metadata.get('summary', '')

# Get the appropriate logo (default is "ai4eosc")
namespace = os.getenv('NOMAD_NAMESPACE', 'ai4eosc')
namespace = namespace if namespace in ['imagine'] else 'ai4eosc' # other namespace don't have logo
homepages = {
'ai4eosc': 'https://ai4eosc.eu/',
'imagine': 'https://www.imagine-ai.eu/',
}
logo = f"""
<a href="{homepages[namespace]}">
<div align="center">
<img src="https://raw.githubusercontent.com/ai4os/deepaas_ui/master/_static/images/logo-{namespace}.png" width="200" />
</div>
</a>
"""

# Generate the footer
author = metadata.get('author', '')
if isinstance(author, list):
author = ', '.join(author)
footer = f"""
<link href="https://use.fontawesome.com/releases/v5.13.0/css/all.css" rel="stylesheet">
<b>Author(s)</b>: {author} <br>
<b>Summary</b>: {metadata.get('summary', '')} <br>
<b>Description:</b>: {metadata.get('summary', '')} <br>
<b>UI version</b>: <a href="{version_link}"><code>{version_text}</code></a> <br>
<br><br>
<a href="https://ai4eosc.eu/">
<div align="center">
<img src="https://ai4eosc.eu/wp-content/uploads/sites/10/2023/01/horizontal-bg-green.png" class="ai4eosc-logo" width="200" />
</div>
</a>
{logo}
"""
footer = inspect.cleandoc(footer)
return footer
Expand Down

0 comments on commit 1358d3a

Please sign in to comment.