Skip to content

Commit 37eceb0

Browse files
committed
🎨 streamlit footer in utils? use central constants for footer, dedent
1 parent 85e2c53 commit 37eceb0

File tree

9 files changed

+65
-42
lines changed

9 files changed

+65
-42
lines changed

src/vuegen/utils/__init__.py

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,27 @@
55
import logging
66
import os
77
import sys
8+
import textwrap
89
from datetime import datetime
9-
10-
try:
11-
from enum import StrEnum
12-
except ImportError:
13-
from strenum import StrEnum
14-
1510
from io import StringIO
1611
from pathlib import Path
17-
from typing import Iterable, Type
12+
from typing import Iterable, Optional, Type
1813
from urllib.parse import urlparse
1914

2015
import networkx as nx
2116
import requests
2217
import yaml
2318
from bs4 import BeautifulSoup
2419

20+
try:
21+
from enum import StrEnum
22+
except ImportError:
23+
from strenum import StrEnum
2524

26-
## CHECKS
25+
from vuegen.constants import GITHUB_ORG_URL, LOGO_URL, ORG, REPO_URL, TIMEOUT
26+
27+
28+
# CHECKS
2729
def check_path(filepath: Path) -> bool:
2830
"""
2931
Checks if the given file or folder path exists.
@@ -848,7 +850,8 @@ def get_completion_message(report_type: str, config_path: str) -> str:
848850
return f"{message}\n{border}"
849851

850852

851-
## REPORT FORMATTING
853+
# REPORT FORMATTING
854+
# ? move as only used in streamlit_report
852855
def generate_footer() -> str:
853856
"""
854857
Generate an HTML footer for a report.
@@ -861,23 +864,27 @@ def generate_footer() -> str:
861864
str
862865
A formatted HTML string representing the footer.
863866
"""
864-
footer = """<style type="text/css">
865-
.footer {
866-
position: relative;
867-
left: 0;
868-
width: 100%;
869-
text-align: center;
870-
}
871-
</style>
872-
<footer class="footer">
873-
This report was generated with
874-
<a href="https://github.com/Multiomics-Analytics-Group/vuegen" target="_blank">
875-
<img src="https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/vuegen_logo.svg" alt="VueGen" width="65px">
876-
</a>
877-
| Copyright 2025 <a href="https://github.com/Multiomics-Analytics-Group" target="_blank">
878-
Multiomics Network Analytics Group (MoNA)
879-
</a>
880-
</footer>"""
867+
footer = textwrap.dedent(
868+
f"""
869+
<style type="text/css">
870+
.footer \u007b
871+
position: relative;
872+
left: 0;
873+
width: 100%;
874+
text-align: center;
875+
\u007d
876+
</style>
877+
<footer class="footer">
878+
This report was generated with
879+
<a href="{REPO_URL}" target="_blank">
880+
<img src="{LOGO_URL}" alt="VueGen" width="65px">
881+
</a>
882+
| Copyright 2025 <a href="{GITHUB_ORG_URL}" target="_blank">
883+
{ORG}
884+
</a>
885+
</footer>
886+
"""
887+
)
881888
return footer
882889

883890

tests/report_examples/Basic_example_vuegen_demo_notebook/streamlit_report/sections/Dataframes/All_Formats.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@
204204
mime='text/csv',
205205
key=f"download_button_{df_index}")
206206
df_index += 1
207-
footer = '''<style type="text/css">
207+
footer = '''
208+
<style type="text/css">
208209
.footer {
209210
position: relative;
210211
left: 0;
@@ -220,6 +221,7 @@
220221
| Copyright 2025 <a href="https://github.com/Multiomics-Analytics-Group" target="_blank">
221222
Multiomics Network Analytics Group (MoNA)
222223
</a>
223-
</footer>'''
224+
</footer>
225+
'''
224226

225227
st.markdown(footer, unsafe_allow_html=True)

tests/report_examples/Basic_example_vuegen_demo_notebook/streamlit_report/sections/Home/Homepage.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
),
88
unsafe_allow_html=True)
99

10-
footer = '''<style type="text/css">
10+
footer = '''
11+
<style type="text/css">
1112
.footer {
1213
position: relative;
1314
left: 0;
@@ -23,6 +24,7 @@
2324
| Copyright 2025 <a href="https://github.com/Multiomics-Analytics-Group" target="_blank">
2425
Multiomics Network Analytics Group (MoNA)
2526
</a>
26-
</footer>'''
27+
</footer>
28+
'''
2729

2830
st.markdown(footer, unsafe_allow_html=True)

tests/report_examples/Basic_example_vuegen_demo_notebook/streamlit_report/sections/Html/All_Html.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@
6363

6464
st.components.v1.html(html_content, height=600, scrolling=True)
6565

66-
footer = '''<style type="text/css">
66+
footer = '''
67+
<style type="text/css">
6768
.footer {
6869
position: relative;
6970
left: 0;
@@ -79,6 +80,7 @@
7980
| Copyright 2025 <a href="https://github.com/Multiomics-Analytics-Group" target="_blank">
8081
Multiomics Network Analytics Group (MoNA)
8182
</a>
82-
</footer>'''
83+
</footer>
84+
'''
8385

8486
st.markdown(footer, unsafe_allow_html=True)

tests/report_examples/Basic_example_vuegen_demo_notebook/streamlit_report/sections/Markdown/All_Markdown.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323

2424
st.markdown(markdown_content, unsafe_allow_html=True)
2525

26-
footer = '''<style type="text/css">
26+
footer = '''
27+
<style type="text/css">
2728
.footer {
2829
position: relative;
2930
left: 0;
@@ -39,6 +40,7 @@
3940
| Copyright 2025 <a href="https://github.com/Multiomics-Analytics-Group" target="_blank">
4041
Multiomics Network Analytics Group (MoNA)
4142
</a>
42-
</footer>'''
43+
</footer>
44+
'''
4345

4446
st.markdown(footer, unsafe_allow_html=True)

tests/report_examples/Basic_example_vuegen_demo_notebook/streamlit_report/sections/Networks/Interactive_Networks.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@
5757

5858
st.markdown(markdown_content, unsafe_allow_html=True)
5959

60-
footer = '''<style type="text/css">
60+
footer = '''
61+
<style type="text/css">
6162
.footer {
6263
position: relative;
6364
left: 0;
@@ -73,6 +74,7 @@
7374
| Copyright 2025 <a href="https://github.com/Multiomics-Analytics-Group" target="_blank">
7475
Multiomics Network Analytics Group (MoNA)
7576
</a>
76-
</footer>'''
77+
</footer>
78+
'''
7779

7880
st.markdown(footer, unsafe_allow_html=True)

tests/report_examples/Basic_example_vuegen_demo_notebook/streamlit_report/sections/Networks/Static_Networks.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020
st.image('docs/example_data/Basic_example_vuegen_demo_notebook/3_Networks/2_Static_networks/1_phyla_correlation_network.png', caption='', use_column_width=True)
2121

22-
footer = '''<style type="text/css">
22+
footer = '''
23+
<style type="text/css">
2324
.footer {
2425
position: relative;
2526
left: 0;
@@ -35,6 +36,7 @@
3536
| Copyright 2025 <a href="https://github.com/Multiomics-Analytics-Group" target="_blank">
3637
Multiomics Network Analytics Group (MoNA)
3738
</a>
38-
</footer>'''
39+
</footer>
40+
'''
3941

4042
st.markdown(footer, unsafe_allow_html=True)

tests/report_examples/Basic_example_vuegen_demo_notebook/streamlit_report/sections/Plots/Interactive_Plots.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@
149149

150150
st.markdown(markdown_content, unsafe_allow_html=True)
151151

152-
footer = '''<style type="text/css">
152+
footer = '''
153+
<style type="text/css">
153154
.footer {
154155
position: relative;
155156
left: 0;
@@ -165,6 +166,7 @@
165166
| Copyright 2025 <a href="https://github.com/Multiomics-Analytics-Group" target="_blank">
166167
Multiomics Network Analytics Group (MoNA)
167168
</a>
168-
</footer>'''
169+
</footer>
170+
'''
169171

170172
st.markdown(footer, unsafe_allow_html=True)

tests/report_examples/Basic_example_vuegen_demo_notebook/streamlit_report/sections/Plots/Static_Plots.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141

4242
st.image('docs/example_data/Basic_example_vuegen_demo_notebook/1_Plots/2_Static_plots/3_alpha_diversity_host_associated_samples.png', caption='', use_column_width=True)
4343

44-
footer = '''<style type="text/css">
44+
footer = '''
45+
<style type="text/css">
4546
.footer {
4647
position: relative;
4748
left: 0;
@@ -57,6 +58,7 @@
5758
| Copyright 2025 <a href="https://github.com/Multiomics-Analytics-Group" target="_blank">
5859
Multiomics Network Analytics Group (MoNA)
5960
</a>
60-
</footer>'''
61+
</footer>
62+
'''
6163

6264
st.markdown(footer, unsafe_allow_html=True)

0 commit comments

Comments
 (0)