UlrickBL commited on
Commit
4651ba2
Β·
verified Β·
1 Parent(s): 55efd73

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -27
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 search_papers(query):
8
- # Filter the dataframe based on the search query
9
- filtered = df[df['Paper name'].str.contains(query, case=False, na=False) |
10
- df['Note'].str.contains(query, case=False, na=False)]
 
 
11
 
12
- # Define a futuristic CSS style and wrap the results in a table
13
  style = """
14
  <style>
15
- .futuristic-table {
16
  width: 100%;
17
  border-collapse: collapse;
18
  font-family: 'Segoe UI', sans-serif;
19
- color: #00ffe7;
20
- background-color: #0d1117;
21
- border: 1px solid #30363d;
22
- border-radius: 10px;
 
23
  overflow: hidden;
24
- box-shadow: 0 0 20px #00ffe7aa;
25
  }
26
- .futuristic-table th {
27
- background-color: #161b22;
28
- color: #58a6ff;
29
  padding: 10px;
30
- border-bottom: 2px solid #30363d;
 
 
31
  }
32
- .futuristic-table td {
33
- padding: 12px;
34
- border-bottom: 1px solid #30363d;
35
  }
36
- .futuristic-table tr:hover {
37
- background-color: #1c2128;
38
  }
39
  </style>
40
  """
41
 
42
- html_table = f"{style}<table class='futuristic-table'>"
43
- html_table += "<tr><th>πŸ“„ Paper</th><th>πŸ“ Note</th><th>βœ… Status</th></tr>"
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 UI
52
  demo = gr.Interface(
53
- fn=search_papers,
54
- inputs=gr.Textbox(label="πŸ” Search Your Papers"),
55
  outputs=gr.HTML(label="Results"),
56
- title="πŸ“š Futuristic Paper Notes Explorer",
57
- description="Search your Notion-exported reading notes in style."
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
+