staticdash 0.1.2__py3-none-any.whl → 0.1.3__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.
@@ -97,4 +97,4 @@ tr:hover {
97
97
  .plot-container .plotly-graph-div {
98
98
  width: 100% !important;
99
99
  height: auto !important;
100
- }
100
+ }
@@ -40,4 +40,4 @@ document.addEventListener("DOMContentLoaded", () => {
40
40
  if (sections.length > 0) {
41
41
  showPage(sections[0].id);
42
42
  }
43
- });
43
+ });
staticdash/dashboard.py CHANGED
@@ -26,6 +26,11 @@ class Page:
26
26
  table_id = f"table-{len(self.elements)}"
27
27
  html = df.to_html(classes="table-hover table-striped", index=False, border=0, table_id=table_id)
28
28
  self.elements.append(("table", (html, table_id)))
29
+
30
+ def add_download(self, file_path, label=None):
31
+ if not os.path.isfile(file_path):
32
+ raise FileNotFoundError(f"File not found: {file_path}")
33
+ self.elements.append(("download", (file_path, label)))
29
34
 
30
35
  def add(self, element):
31
36
  if isinstance(element, str):
@@ -59,15 +64,18 @@ class Dashboard:
59
64
  self.pages.append(page)
60
65
 
61
66
  def publish(self, output_dir="output"):
62
- os.makedirs(output_dir, exist_ok=True)
67
+ output_dir = os.path.abspath(output_dir)
63
68
  pages_dir = os.path.join(output_dir, "pages")
64
- os.makedirs(pages_dir, exist_ok=True)
65
-
66
- # Copy assets
69
+ downloads_dir = os.path.join(output_dir, "downloads")
67
70
  assets_src = os.path.join(os.path.dirname(__file__), "assets")
68
71
  assets_dst = os.path.join(output_dir, "assets")
72
+
73
+ # Ensure directories exist
74
+ os.makedirs(pages_dir, exist_ok=True)
75
+ os.makedirs(downloads_dir, exist_ok=True)
69
76
  shutil.copytree(assets_src, assets_dst, dirs_exist_ok=True)
70
77
 
78
+
71
79
  # Generate each page
72
80
  for page in self.pages:
73
81
  doc = document(title=page.title)
@@ -113,7 +121,16 @@ class Dashboard:
113
121
  elif kind == "table":
114
122
  table_html, _ = content
115
123
  div(raw_util(table_html))
124
+ elif kind == "download":
125
+ src_path, label = content
126
+ file_uuid = f"{uuid.uuid4().hex}_{os.path.basename(src_path)}"
127
+ dst_path = os.path.join(downloads_dir, file_uuid)
128
+ shutil.copy2(src_path, dst_path)
129
+ a(label or os.path.basename(src_path),
130
+ href=f"{downloads_dir}/{file_uuid}",
131
+ cls="download-button",
132
+ download=True)
116
133
 
117
134
 
118
135
  with open(os.path.join(output_dir, "index.html"), "w") as f:
119
- f.write(str(index_doc))
136
+ f.write(str(index_doc))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: staticdash
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: A lightweight static HTML dashboard generator with Plotly and pandas support.
5
5
  Author-email: Brian Day <brian.day1@gmail.com>
6
6
  License: CC0-1.0
@@ -0,0 +1,8 @@
1
+ staticdash/__init__.py,sha256=KqViaDkiQnhBI8-j3hr14umLDmPgddvdB_G1nJeC5Xs,38
2
+ staticdash/dashboard.py,sha256=0A-1soi7ECzTeCQTjZqzFuT2Ef8a9YAPSLI2T7f66EY,5595
3
+ staticdash/assets/css/style.css,sha256=zcwUaOtGenWwGlWvWc5i9jnz_M1Jq2iGKGKizSGvBRo,1314
4
+ staticdash/assets/js/script.js,sha256=rAGEB9sgv8LGdpA1JLQwYAZVRimpEfFSELKb0fFeATI,1222
5
+ staticdash-0.1.3.dist-info/METADATA,sha256=0qjiyqbS0kGN78m6C8f5CNBIlRudnZ5xoBuV6JcK_48,2157
6
+ staticdash-0.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
+ staticdash-0.1.3.dist-info/top_level.txt,sha256=3MzZU6SptkUkjcHV1cvPji0H4aRzPphLHnpStgGEcxM,11
8
+ staticdash-0.1.3.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- staticdash/__init__.py,sha256=KqViaDkiQnhBI8-j3hr14umLDmPgddvdB_G1nJeC5Xs,38
2
- staticdash/dashboard.py,sha256=DFTPvqSOI00c2qVS4MvOyia1ly-Ph8-oSlbQDT9TSj8,4644
3
- staticdash/assets/css/style.css,sha256=OIcaUe9z3uQjfnisZiyxV-UodHQLq4kIWKxtq7BL2-Q,1315
4
- staticdash/assets/js/script.js,sha256=GA6dd--Z_gvsLylOHZX73FkPPkznuFzsFGYYKL-sDxM,1223
5
- staticdash-0.1.2.dist-info/METADATA,sha256=Mir0l0LNUGiusMsNv2lCOSB2y-sYwzmY10aUVUD5Gfg,2157
6
- staticdash-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- staticdash-0.1.2.dist-info/top_level.txt,sha256=3MzZU6SptkUkjcHV1cvPji0H4aRzPphLHnpStgGEcxM,11
8
- staticdash-0.1.2.dist-info/RECORD,,