File size: 1,967 Bytes
1af50a8
 
 
236cb26
1af50a8
4651ba2
 
 
 
a0916c3
 
 
 
1af50a8
 
 
a0916c3
 
 
 
 
 
 
4651ba2
1af50a8
 
 
4651ba2
 
1af50a8
4651ba2
 
1af50a8
4651ba2
 
 
a0916c3
 
 
1af50a8
4651ba2
 
 
1af50a8
4651ba2
 
1af50a8
 
 
 
a0916c3
38ec6be
1af50a8
 
959f16c
1af50a8
a0916c3
1af50a8
 
959f16c
 
a0916c3
3968f3b
 
a0916c3
3968f3b
1af50a8
 
4651ba2
a0916c3
3968f3b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import gradio as gr
import pandas as pd

df = pd.read_csv("JournalDB 1cfe54e949178196af93d90c73636f9d.csv").sort_index(ascending=False)

def filter_table(query):
    if query.strip() == "":
        filtered = df.copy()
    else:
        filtered = df[
            df['Paper name'].str.contains(query, case=False, na=False) |
            df['Note'].str.contains(query, case=False, na=False)
        ]

    style = """
    <style>
    .scroll-container {
        max-height: 500px;
        overflow-y: auto;
        border: 1px solid #333;
        border-radius: 6px;
        background-color: #1e1e1e;
    }
    .styled-table {
        width: 100%;
        border-collapse: collapse;
        font-family: 'Segoe UI', sans-serif;
        color: #e0e0e0;
        background-color: #1e1e1e;
    }
    .styled-table th {
        background-color: #2c2c2c;
        padding: 10px;
        text-align: left;
        color: #64b5f6;
        border-bottom: 2px solid #444;
        position: sticky;
        top: 0;
        z-index: 1;
    }
    .styled-table td {
        padding: 10px;
        border-bottom: 1px solid #333;
    }
    .styled-table tr:hover {
        background-color: #2a2a2a;
    }
    </style>
    """

    html_table = f"{style}<div class='scroll-container'><table class='styled-table'>"
    html_table += "<tr><th>Paper</th><th>Note</th><th>Status</th><th>Link</th></tr>"

    for _, row in filtered.iterrows():
        html_table += f"<tr><td>{row['Paper name']}</td><td>{row['Note']}</td><td>{row['Status']}</td><td>{row['Link']}</td></tr>"

    html_table += "</table></div>"
    return html_table

with gr.Blocks(title="Paper reading with notes") as demo:
    gr.Markdown("### Search and browse reading notes and papers")

    search_box = gr.Textbox(label="Search", placeholder="Type a keyword...")
    table_output = gr.HTML(value=filter_table(""))

    search_box.change(fn=filter_table, inputs=search_box, outputs=table_output)

demo.launch()