staticdash 0.1.0__py3-none-any.whl

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/__init__.py ADDED
@@ -0,0 +1,2 @@
1
+ from .dashboard import Page, Dashboard
2
+ import simpledash.assets.css
@@ -0,0 +1,88 @@
1
+ import os
2
+ import shutil
3
+ import dominate
4
+ from dominate.tags import div, h1, h2, p, a, script, link, table, thead, tr, th, tbody, td
5
+ from dominate.util import raw # ✅ correct usage
6
+
7
+ import plotly.graph_objs as go
8
+ import pandas as pd
9
+
10
+
11
+ class Page:
12
+ def __init__(self, slug, title):
13
+ self.slug = slug
14
+ self.title = title
15
+ self.elements = []
16
+
17
+ def append(self, element):
18
+ if isinstance(element, str):
19
+ self.elements.append(p(element))
20
+ elif isinstance(element, go.Figure):
21
+ html = element.to_html(include_plotlyjs=False, full_html=False)
22
+ self.elements.append(raw(html))
23
+ elif isinstance(element, pd.DataFrame):
24
+ tbl = table()
25
+ tbl.add(thead(tr(*[th(col) for col in element.columns])))
26
+ tb = tbody()
27
+ for _, row in element.iterrows():
28
+ tb.add(tr(*[td(str(val)) for val in row]))
29
+ tbl.add(tb)
30
+ self.elements.append(tbl)
31
+ else:
32
+ self.elements.append(element)
33
+
34
+
35
+ class Dashboard:
36
+ def __init__(self, title="Dashboard"):
37
+ self.title = title
38
+ self.pages = []
39
+
40
+ def add_page(self, page):
41
+ self.pages.append(page)
42
+
43
+ def publish(self, output_dir="output"):
44
+ os.makedirs(output_dir, exist_ok=True)
45
+ self._write_assets(output_dir)
46
+ self._write_index(output_dir)
47
+
48
+ def _write_assets(self, output_dir):
49
+ css_src = os.path.join(os.path.dirname(__file__), "assets", "css", "style.css")
50
+ css_dst_dir = os.path.join(output_dir, "assets", "css")
51
+ os.makedirs(css_dst_dir, exist_ok=True)
52
+ shutil.copyfile(css_src, os.path.join(css_dst_dir, "style.css"))
53
+
54
+ def _write_index(self, output_dir):
55
+ doc = dominate.document(title=self.title)
56
+
57
+ with doc.head:
58
+ link(rel="stylesheet", href="assets/css/style.css")
59
+ script(src="https://cdn.plot.ly/plotly-latest.min.js")
60
+
61
+ with doc:
62
+ with div(id="sidebar"):
63
+ h1(self.title)
64
+ for i, page in enumerate(self.pages):
65
+ a(page.title, href="#", cls="nav-link", onclick=f"showPage('page-{i}')")
66
+
67
+ with div(id="content"):
68
+ for i, page in enumerate(self.pages):
69
+ section = div(id=f"page-{i}", cls="page-section")
70
+ section.add(h2(page.title))
71
+ for elem in page.elements:
72
+ section.add(elem)
73
+
74
+ # JavaScript block
75
+ js_code = """
76
+ function showPage(id) {
77
+ document.querySelectorAll('.page-section').forEach(el => el.style.display = 'none');
78
+ document.getElementById(id).style.display = 'block';
79
+ document.querySelectorAll('.nav-link').forEach(el => el.classList.remove('active'));
80
+ event.target.classList.add('active');
81
+ }
82
+ window.onload = () => showPage('page-0');
83
+ """
84
+ with doc:
85
+ script(raw(js_code))
86
+
87
+ with open(os.path.join(output_dir, "index.html"), "w") as f:
88
+ f.write(doc.render())
@@ -0,0 +1,79 @@
1
+ Metadata-Version: 2.4
2
+ Name: staticdash
3
+ Version: 0.1.0
4
+ Summary: A minimal static dashboard generator with Plotly support
5
+ Author-email: Brian Day <brian.day1@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/briday1/staticdash
8
+ Project-URL: Repository, https://github.com/briday1/staticdash
9
+ Requires-Python: >=3.8
10
+ Description-Content-Type: text/markdown
11
+
12
+ # staticdash
13
+
14
+ staticdash is a lightweight Python module for creating static, multi-page HTML dashboards. It supports Plotly plots, tables, and text content, with a fixed sidebar for navigation.
15
+
16
+ ## Installation
17
+
18
+ Clone the repository and install it in editable mode:
19
+
20
+ ```bash
21
+ git clone https://github.com/briday1/staticdash.git
22
+ cd staticdash
23
+ pip install .
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ Create a Python script like this:
29
+
30
+ ```python
31
+ from staticdash.dashboard import Dashboard, Page
32
+ import plotly.graph_objects as go
33
+ import pandas as pd
34
+
35
+ # Create the dashboard
36
+ dashboard = Dashboard(title="StaticDash Demo")
37
+
38
+ # Page 1: Overview
39
+ page1 = Page("overview", "Overview")
40
+
41
+ # Add plo
42
+ fig = go.Figure()
43
+ fig.add_trace(go.Scatter(x=[1, 2, 3], y=[4, 1, 6], mode='lines+markers', name="Demo Line"))
44
+ fig.update_layout(title="Sample Plot")
45
+ page1.append(fig)
46
+
47
+ # Add table
48
+ df1 = pd.DataFrame({
49
+ "Category": ["A", "B", "C"],
50
+ "Value": [100, 200, 150]
51
+ })
52
+ page1.append(df1)
53
+
54
+ # Add extra text
55
+ page1.append("This page includes a sample plot, table, and descriptive text.")
56
+ dashboard.add_page(page1)
57
+
58
+ # Page 2: Data Table
59
+ page2 = Page("data", "Data")
60
+ df2 = pd.DataFrame({
61
+ "Name": ["Alice", "Bob", "Charlie"],
62
+ "Score": [85, 92, 78],
63
+ "Passed": [True, True, False]
64
+ })
65
+ page2.append("This table shows individual scores and pass/fail status.")
66
+ page2.append(df2)
67
+ dashboard.add_page(page2)
68
+
69
+ # Page 3: Notes
70
+ page3 = Page("notes", "Notes")
71
+ page3.append("These are concluding notes about the dataset.")
72
+ page3.append("You can also add multiple text blocks like this.")
73
+ dashboard.add_page(page3)
74
+
75
+ # Publish the dashboard
76
+ dashboard.publish(output_dir="output")
77
+ ```
78
+
79
+ After running the script, open output/index.html in your browser.
@@ -0,0 +1,6 @@
1
+ staticdash/__init__.py,sha256=NBEjkx3xBwyM5uAbBRGypiokkebsNwF7yM7AFP0quDg,67
2
+ staticdash/dashboard.py,sha256=ShL9YkqiTL4Lwd9Wkvr6TEBFUFmMN5BOXoC3wKJ5rkQ,3081
3
+ staticdash-0.1.0.dist-info/METADATA,sha256=cRIzyfwdxk1knwaC786xdqArgSbGu3i4YAllAV_qfwA,2075
4
+ staticdash-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
5
+ staticdash-0.1.0.dist-info/top_level.txt,sha256=3MzZU6SptkUkjcHV1cvPji0H4aRzPphLHnpStgGEcxM,11
6
+ staticdash-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ staticdash