Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,43 +4,46 @@ import pandas as pd
|
|
| 4 |
# Load the exported Notion CSV file
|
| 5 |
df = pd.read_csv("JournalDB 1cfe54e949178196af93d90c73636f9d.csv") # Adjust to your actual column names if needed
|
| 6 |
|
| 7 |
-
def
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
#
|
| 13 |
style = """
|
| 14 |
<style>
|
| 15 |
-
.
|
| 16 |
width: 100%;
|
| 17 |
border-collapse: collapse;
|
| 18 |
font-family: 'Segoe UI', sans-serif;
|
| 19 |
-
color: #
|
| 20 |
-
background-color: #
|
| 21 |
-
border: 1px solid #
|
| 22 |
-
border-radius:
|
|
|
|
| 23 |
overflow: hidden;
|
| 24 |
-
box-shadow: 0 0 20px #00ffe7aa;
|
| 25 |
}
|
| 26 |
-
.
|
| 27 |
-
background-color: #
|
| 28 |
-
color: #58a6ff;
|
| 29 |
padding: 10px;
|
| 30 |
-
|
|
|
|
|
|
|
| 31 |
}
|
| 32 |
-
.
|
| 33 |
-
padding:
|
| 34 |
-
border-bottom: 1px solid #
|
| 35 |
}
|
| 36 |
-
.
|
| 37 |
-
background-color: #
|
| 38 |
}
|
| 39 |
</style>
|
| 40 |
"""
|
| 41 |
|
| 42 |
-
html_table = f"{style}<table class='
|
| 43 |
-
html_table += "<tr><th
|
| 44 |
|
| 45 |
for _, row in filtered.iterrows():
|
| 46 |
html_table += f"<tr><td>{row['Paper name']}</td><td>{row['Note']}</td><td>{row['Status']}</td></tr>"
|
|
@@ -48,13 +51,14 @@ def search_papers(query):
|
|
| 48 |
html_table += "</table>"
|
| 49 |
return html_table
|
| 50 |
|
| 51 |
-
# Gradio
|
| 52 |
demo = gr.Interface(
|
| 53 |
-
fn=
|
| 54 |
-
inputs=gr.Textbox(label="
|
| 55 |
outputs=gr.HTML(label="Results"),
|
| 56 |
-
title="
|
| 57 |
-
description="
|
| 58 |
)
|
| 59 |
|
| 60 |
demo.launch()
|
|
|
|
|
|
| 4 |
# Load the exported Notion CSV file
|
| 5 |
df = pd.read_csv("JournalDB 1cfe54e949178196af93d90c73636f9d.csv") # Adjust to your actual column names if needed
|
| 6 |
|
| 7 |
+
def filter_table(query):
|
| 8 |
+
if query.strip() == "":
|
| 9 |
+
filtered = df.copy()
|
| 10 |
+
else:
|
| 11 |
+
filtered = df[df['Paper name'].str.contains(query, case=False, na=False) |
|
| 12 |
+
df['Note'].str.contains(query, case=False, na=False)]
|
| 13 |
|
| 14 |
+
# Minimal modern CSS styling
|
| 15 |
style = """
|
| 16 |
<style>
|
| 17 |
+
.styled-table {
|
| 18 |
width: 100%;
|
| 19 |
border-collapse: collapse;
|
| 20 |
font-family: 'Segoe UI', sans-serif;
|
| 21 |
+
color: #e0e0e0;
|
| 22 |
+
background-color: #1e1e1e;
|
| 23 |
+
border: 1px solid #333;
|
| 24 |
+
border-radius: 8px;
|
| 25 |
+
box-shadow: 0 0 12px #00000044;
|
| 26 |
overflow: hidden;
|
|
|
|
| 27 |
}
|
| 28 |
+
.styled-table th {
|
| 29 |
+
background-color: #2c2c2c;
|
|
|
|
| 30 |
padding: 10px;
|
| 31 |
+
text-align: left;
|
| 32 |
+
color: #64b5f6;
|
| 33 |
+
border-bottom: 2px solid #444;
|
| 34 |
}
|
| 35 |
+
.styled-table td {
|
| 36 |
+
padding: 10px;
|
| 37 |
+
border-bottom: 1px solid #333;
|
| 38 |
}
|
| 39 |
+
.styled-table tr:hover {
|
| 40 |
+
background-color: #2a2a2a;
|
| 41 |
}
|
| 42 |
</style>
|
| 43 |
"""
|
| 44 |
|
| 45 |
+
html_table = f"{style}<table class='styled-table'>"
|
| 46 |
+
html_table += "<tr><th>Paper</th><th>Note</th><th>Status</th></tr>"
|
| 47 |
|
| 48 |
for _, row in filtered.iterrows():
|
| 49 |
html_table += f"<tr><td>{row['Paper name']}</td><td>{row['Note']}</td><td>{row['Status']}</td></tr>"
|
|
|
|
| 51 |
html_table += "</table>"
|
| 52 |
return html_table
|
| 53 |
|
| 54 |
+
# Gradio Interface
|
| 55 |
demo = gr.Interface(
|
| 56 |
+
fn=filter_table,
|
| 57 |
+
inputs=gr.Textbox(label="Search"),
|
| 58 |
outputs=gr.HTML(label="Results"),
|
| 59 |
+
title="Reading Notes Viewer",
|
| 60 |
+
description="Browse and search through your reading notes."
|
| 61 |
)
|
| 62 |
|
| 63 |
demo.launch()
|
| 64 |
+
|