staticdash 0.2.2__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {staticdash-0.2.2 → staticdash-0.3.0}/PKG-INFO +1 -1
- {staticdash-0.2.2 → staticdash-0.3.0}/pyproject.toml +1 -1
- {staticdash-0.2.2 → staticdash-0.3.0}/staticdash/assets/css/style.css +11 -0
- {staticdash-0.2.2 → staticdash-0.3.0}/staticdash/dashboard.py +80 -51
- {staticdash-0.2.2 → staticdash-0.3.0}/staticdash.egg-info/PKG-INFO +1 -1
- {staticdash-0.2.2 → staticdash-0.3.0}/README.md +0 -0
- {staticdash-0.2.2 → staticdash-0.3.0}/setup.cfg +0 -0
- {staticdash-0.2.2 → staticdash-0.3.0}/staticdash/__init__.py +0 -0
- {staticdash-0.2.2 → staticdash-0.3.0}/staticdash/assets/js/script.js +0 -0
- {staticdash-0.2.2 → staticdash-0.3.0}/staticdash.egg-info/SOURCES.txt +0 -0
- {staticdash-0.2.2 → staticdash-0.3.0}/staticdash.egg-info/dependency_links.txt +0 -0
- {staticdash-0.2.2 → staticdash-0.3.0}/staticdash.egg-info/requires.txt +0 -0
- {staticdash-0.2.2 → staticdash-0.3.0}/staticdash.egg-info/top_level.txt +0 -0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "staticdash"
|
7
|
-
version = "0.
|
7
|
+
version = "0.3.0"
|
8
8
|
description = "A lightweight static HTML dashboard generator with Plotly and pandas support."
|
9
9
|
authors = [
|
10
10
|
{ name = "Brian Day", email = "brian.day1@gmail.com" }
|
@@ -174,4 +174,15 @@ table.sortable th.sorted-asc::after {
|
|
174
174
|
|
175
175
|
table.sortable th.sorted-desc::after {
|
176
176
|
content: "\25BC";
|
177
|
+
}
|
178
|
+
|
179
|
+
.minipage-row {
|
180
|
+
display: flex;
|
181
|
+
gap: 20px;
|
182
|
+
margin-bottom: 20px;
|
183
|
+
}
|
184
|
+
|
185
|
+
.minipage {
|
186
|
+
box-sizing: border-box;
|
187
|
+
padding: 10px;
|
177
188
|
}
|
@@ -4,15 +4,12 @@ import uuid
|
|
4
4
|
import pandas as pd
|
5
5
|
import plotly.graph_objects as go
|
6
6
|
from dominate import document
|
7
|
-
from dominate.tags import div, h1, h2, h3, h4, p, a, script, link
|
7
|
+
from dominate.tags import div, h1, h2, h3, h4, p, a, script, link
|
8
8
|
from dominate.util import raw as raw_util
|
9
9
|
|
10
|
-
class
|
11
|
-
def __init__(self
|
12
|
-
self.slug = slug
|
13
|
-
self.title = title
|
10
|
+
class AbstractPage:
|
11
|
+
def __init__(self):
|
14
12
|
self.elements = []
|
15
|
-
self.add_header(title, level=1) # Add page title as level 1 header
|
16
13
|
|
17
14
|
def add_header(self, text, level=1):
|
18
15
|
if level not in (1, 2, 3, 4):
|
@@ -40,20 +37,25 @@ class Page:
|
|
40
37
|
raise FileNotFoundError(f"File not found: {file_path}")
|
41
38
|
self.elements.append(("download", (file_path, label)))
|
42
39
|
|
43
|
-
def
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
40
|
+
def add_minipage(self, minipage):
|
41
|
+
self.elements.append(("minipage", minipage))
|
42
|
+
|
43
|
+
class Page(AbstractPage):
|
44
|
+
def __init__(self, slug, title):
|
45
|
+
super().__init__()
|
46
|
+
self.slug = slug
|
47
|
+
self.title = title
|
48
|
+
self.add_header(title, level=1)
|
52
49
|
|
53
50
|
def render(self, index):
|
54
|
-
section = div(
|
51
|
+
section = div()
|
52
|
+
minipage_row = []
|
55
53
|
for kind, content in self.elements:
|
56
|
-
if kind == "
|
54
|
+
if kind == "minipage":
|
55
|
+
row_div = div(cls="minipage-row")
|
56
|
+
row_div += content.render(index)
|
57
|
+
section += row_div
|
58
|
+
elif kind == "header":
|
57
59
|
text, level = content
|
58
60
|
if level == 1:
|
59
61
|
section += h1(text)
|
@@ -70,8 +72,65 @@ class Page:
|
|
70
72
|
elif kind == "table":
|
71
73
|
table_html, _ = content
|
72
74
|
section += raw_util(table_html)
|
75
|
+
elif kind == "download":
|
76
|
+
file_path, label = content
|
77
|
+
btn = a(label or os.path.basename(file_path),
|
78
|
+
href=file_path,
|
79
|
+
cls="download-button",
|
80
|
+
download=True)
|
81
|
+
section += div(btn)
|
73
82
|
return section
|
74
83
|
|
84
|
+
class MiniPage(AbstractPage):
|
85
|
+
def __init__(self, width=1.0):
|
86
|
+
super().__init__()
|
87
|
+
self.width = width
|
88
|
+
|
89
|
+
def render(self, index=None):
|
90
|
+
style = f"flex: 0 0 {self.width * 100}%; max-width: {self.width * 100}%;"
|
91
|
+
container = div(cls="minipage", style=style)
|
92
|
+
minipage_row = []
|
93
|
+
for kind, content in self.elements:
|
94
|
+
if kind == "minipage":
|
95
|
+
minipage_row.append(content)
|
96
|
+
else:
|
97
|
+
if minipage_row:
|
98
|
+
row_div = div(cls="minipage-row")
|
99
|
+
for mp in minipage_row:
|
100
|
+
row_div += mp.render(index)
|
101
|
+
container += row_div
|
102
|
+
minipage_row = []
|
103
|
+
if kind == "header":
|
104
|
+
text, level = content
|
105
|
+
if level == 1:
|
106
|
+
container += h1(text)
|
107
|
+
elif level == 2:
|
108
|
+
container += h2(text)
|
109
|
+
elif level == 3:
|
110
|
+
container += h3(text)
|
111
|
+
elif level == 4:
|
112
|
+
container += h4(text)
|
113
|
+
elif kind == "text":
|
114
|
+
container += p(content)
|
115
|
+
elif kind == "plot":
|
116
|
+
container += div(content, cls="plot-container")
|
117
|
+
elif kind == "table":
|
118
|
+
table_html, _ = content
|
119
|
+
container += raw_util(table_html)
|
120
|
+
elif kind == "download":
|
121
|
+
file_path, label = content
|
122
|
+
btn = a(label or os.path.basename(file_path),
|
123
|
+
href=file_path,
|
124
|
+
cls="download-button",
|
125
|
+
download=True)
|
126
|
+
container += div(btn)
|
127
|
+
if minipage_row:
|
128
|
+
row_div = div(cls="minipage-row")
|
129
|
+
for mp in minipage_row:
|
130
|
+
row_div += mp.render(index)
|
131
|
+
container += row_div
|
132
|
+
return container
|
133
|
+
|
75
134
|
class Dashboard:
|
76
135
|
def __init__(self, title="Dashboard"):
|
77
136
|
self.title = title
|
@@ -99,7 +158,6 @@ class Dashboard:
|
|
99
158
|
|
100
159
|
with doc:
|
101
160
|
with div(cls="page-section", id=f"page-{page.slug}"):
|
102
|
-
# Remove h1(page.title) here, since it's already a header element
|
103
161
|
for kind, content in page.elements:
|
104
162
|
if kind == "header":
|
105
163
|
text, level = content
|
@@ -136,39 +194,10 @@ class Dashboard:
|
|
136
194
|
a("Produced by staticdash", href="https://pypi.org/project/staticdash/", target="_blank")
|
137
195
|
|
138
196
|
with div(id="content"):
|
139
|
-
for page in self.pages:
|
140
|
-
with div(id=f"page-{page.slug}", cls="page-section", style="display:none;"):
|
141
|
-
|
142
|
-
|
143
|
-
if kind == "header":
|
144
|
-
text, level = content
|
145
|
-
if level == 1:
|
146
|
-
h1(text)
|
147
|
-
elif level == 2:
|
148
|
-
h2(text)
|
149
|
-
elif level == 3:
|
150
|
-
h3(text)
|
151
|
-
elif level == 4:
|
152
|
-
h4(text)
|
153
|
-
elif kind == "text":
|
154
|
-
p(content)
|
155
|
-
elif kind == "plot":
|
156
|
-
div(content, cls="plot-container")
|
157
|
-
elif kind == "table":
|
158
|
-
table_html, _ = content
|
159
|
-
div(raw_util(table_html))
|
160
|
-
elif kind == "download":
|
161
|
-
src_path, label = content
|
162
|
-
file_uuid = f"{uuid.uuid4().hex}_{os.path.basename(src_path)}"
|
163
|
-
dst_path = os.path.join(downloads_dir, file_uuid)
|
164
|
-
shutil.copy2(src_path, dst_path)
|
165
|
-
download_link = f"downloads/{file_uuid}"
|
166
|
-
btn = a(label or os.path.basename(src_path),
|
167
|
-
href=download_link,
|
168
|
-
cls="download-button",
|
169
|
-
download=True)
|
170
|
-
div(btn)
|
171
|
-
div(raw_util("<br>"))
|
197
|
+
for idx, page in enumerate(self.pages):
|
198
|
+
with div(id=f"page-{page.slug}", cls="page-section", style="display:none;") as section:
|
199
|
+
rendered = page.render(idx)
|
200
|
+
section += rendered # This is correct
|
172
201
|
|
173
202
|
with open(os.path.join(output_dir, "index.html"), "w") as f:
|
174
203
|
f.write(str(index_doc))
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|