Daniel0315 commited on
Commit
c089330
Β·
verified Β·
1 Parent(s): d993b71

Upload app.py

Browse files
Files changed (1) hide show
  1. src/app.py +17 -15
src/app.py CHANGED
@@ -1,5 +1,6 @@
1
  from __future__ import annotations
2
 
 
3
  import os
4
  from pathlib import Path
5
  from typing import List
@@ -13,6 +14,19 @@ from pyvis.network import Network
13
  import streamlit.components.v1 as components
14
 
15
  HF_REPO_ID = os.environ.get("HF_REPO_ID", "")
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  HF_TOKEN = os.environ.get("HF_TOKEN", "")
17
 
18
  st.set_page_config(page_title="CitationHub", page_icon="πŸ“š", layout="wide")
@@ -1149,11 +1163,7 @@ with tab_analytics:
1149
  csv_seed = seed_filtered[
1150
  ["title", "doi", "journal", "author", "country", "field", "citedby_count"]
1151
  ].to_csv(index=False).encode("utf-8")
1152
- st.download_button(
1153
- "⬇ Seed Papers (CSV)",
1154
- csv_seed, "seed_papers.csv", "text/csv",
1155
- use_container_width=True,
1156
- )
1157
 
1158
  with col_e2:
1159
  _cite_cols = [c for c in
@@ -1167,16 +1177,8 @@ with tab_analytics:
1167
  "primary_intent": "intent", "context_count": "contexts",
1168
  "is_influential": "influential",
1169
  }).to_csv(index=False).encode("utf-8"))
1170
- st.download_button(
1171
- "⬇ Citation Events (CSV)",
1172
- cite_export, "citation_events.csv", "text/csv",
1173
- use_container_width=True,
1174
- )
1175
 
1176
  with col_e3:
1177
  intent_csv = intent_summary.to_csv(index=False).encode("utf-8")
1178
- st.download_button(
1179
- "⬇ Intent Summary (CSV)",
1180
- intent_csv, "intent_summary.csv", "text/csv",
1181
- use_container_width=True,
1182
- )
 
1
  from __future__ import annotations
2
 
3
+ import base64
4
  import os
5
  from pathlib import Path
6
  from typing import List
 
14
  import streamlit.components.v1 as components
15
 
16
  HF_REPO_ID = os.environ.get("HF_REPO_ID", "")
17
+
18
+
19
+ def csv_download_link(data: bytes, filename: str, label: str) -> None:
20
+ """st.download_button λŒ€μ‹  base64 HTML 링크둜 λ‹€μš΄λ‘œλ“œ β€” μ„œλ²„ μ—°κ²° λΆˆν•„μš”."""
21
+ b64 = base64.b64encode(data).decode()
22
+ st.markdown(
23
+ f'<a href="data:text/csv;base64,{b64}" download="{filename}" '
24
+ f'style="display:block;text-align:center;padding:8px 12px;'
25
+ f'background:#1e293b;color:white;border-radius:8px;'
26
+ f'text-decoration:none;font-size:14px;width:100%;box-sizing:border-box;">'
27
+ f'{label}</a>',
28
+ unsafe_allow_html=True,
29
+ )
30
  HF_TOKEN = os.environ.get("HF_TOKEN", "")
31
 
32
  st.set_page_config(page_title="CitationHub", page_icon="πŸ“š", layout="wide")
 
1163
  csv_seed = seed_filtered[
1164
  ["title", "doi", "journal", "author", "country", "field", "citedby_count"]
1165
  ].to_csv(index=False).encode("utf-8")
1166
+ csv_download_link(csv_seed, "seed_papers.csv", "⬇ Seed Papers (CSV)")
 
 
 
 
1167
 
1168
  with col_e2:
1169
  _cite_cols = [c for c in
 
1177
  "primary_intent": "intent", "context_count": "contexts",
1178
  "is_influential": "influential",
1179
  }).to_csv(index=False).encode("utf-8"))
1180
+ csv_download_link(cite_export, "citation_events.csv", "⬇ Citation Events (CSV)")
 
 
 
 
1181
 
1182
  with col_e3:
1183
  intent_csv = intent_summary.to_csv(index=False).encode("utf-8")
1184
+ csv_download_link(intent_csv, "intent_summary.csv", "⬇ Intent Summary (CSV)")