File size: 6,138 Bytes
0282af8
f930455
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0282af8
d6b80b8
f930455
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7574941
d6b80b8
f930455
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2e3df3f
080bf38
f930455
 
 
 
080bf38
80cc1fe
5adbe4c
6cac1f5
35780ab
08cdbb6
35780ab
7175e43
 
 
f930455
 
7175e43
80cc1fe
f930455
 
7175e43
 
bb4e6a7
 
 
f930455
 
 
bb4e6a7
7ddead7
e843d90
f930455
96733b5
370e3f9
7ddead7
 
f930455
7ddead7
f930455
7ddead7
de45608
9d3d386
 
f930455
cbcf742
 
f930455
 
 
 
 
 
 
 
 
 
 
 
a617b4a
 
 
 
 
 
 
556e2e3
a617b4a
 
 
f930455
370e3f9
 
2e3df3f
f930455
 
8c6f2a8
a4e2829
 
9bc59ec
 
5d52afd
f930455
00bb9ed
bad2542
5d5ec50
1960f31
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import panel as pn
pn.extension('katex')

import pytz
from datetime import date
from datetime import datetime
from dateutil.relativedelta import relativedelta, MO
import param

import TLDR
from src.search import Search_Papers

class MainBody(param.Parameterized):
    main_body = param.List(default=[pn.pane.LaTeX("Please select some tags!", styles={'font-size': '20pt'})])

    @param.depends("main_body")
    def update(self):
        return pn.Column(*self.main_body)

main_body_instance = MainBody()

paper_list = []  # Add this line to initialize paper_list as an empty list

main_body = [pn.pane.LaTeX("Please select some tags!", styles={'font-size': '20pt'})]

# Create buttons for the toggleable sidebar
# button1 = pn.widgets.Button(name="๐Ÿ  Home", button_type='default', button_style='outline', width=140)
# button2 = pn.widgets.Button(name='๐Ÿ“ My papers', button_type='default', button_style='outline', width=140)
# button3 = pn.widgets.Toggle(name='โš™๏ธ Settings', button_type='default', button_style='outline', width=140, value=False)

# Create buttons for the toggleable sidebar
button1 = pn.widgets.Button(icon='home', name="Daily papers", icon_size='1.5em', button_type = 'primary', button_style = 'outline', width = 140)
button2 = pn.widgets.Button(icon='calendar-filled', name="Search papers", icon_size='1.5em', button_type = 'primary', button_style = 'outline', width = 140)
button3 = pn.widgets.Button(icon='file-analytics', name='My papers', icon_size='1.5em', button_type = 'primary', button_style = 'outline', width = 140)
button4 = pn.widgets.Toggle(name='Accessibility',icon='settings', icon_size='1.5em', button_type='default', button_style='outline', width=140, value=False)

# Custom RadioButtonGroup widget
select = pn.widgets.RadioButtonGroup(value="Scientic", options=["General", "Scientic"], name='String', align='center', button_type='default') # , align='center'
select2 = pn.widgets.RadioButtonGroup(value="Normal", options=["Bionic", "Normal"], name='String', align='center', button_type='default')

# Define a callback to display the selected value
def display_selected_value(event):
    print(f"Selected value: {event.new}", flush=True)

# Attach the callback to the value_change event of the RadioButtonGroup
select.param.watch(display_selected_value, 'value')
select2.param.watch(display_selected_value, 'value')


# Create a column layout for the buttons inside the toggleable sidebar
buttons = pn.Column(
    button1, button2, button3,
    pn.Column(
        select,
        select2,
        visible=True,
        sizing_mode='stretch_width',
    ),
    css_classes=['hidden']
)

# Define a callback to show/hide the select buttons when "Settings" button is toggled
def toggle_settings(event):
    buttons[-1].visible = event.new

button3.param.watch(toggle_settings, 'value')

# List to store the entered options
loaded_dict = TLDR.load_categories()

arxiv_tags = list(loaded_dict.keys())
entered_options = list(loaded_dict.values())

# Create buttons for the header
header_buttons = pn.Row(sizing_mode='stretch_width', css_classes=['header-buttons'])

# "+" button to trigger the addition to the header
add_to_header_button = pn.widgets.Button(name="", icon='search', icon_size='1.5em', button_style = 'outline',button_type = 'light')

# List to store the names of buttons to be added to the header
buttons_to_add = []

paper_list = []

# Callback for adding selected options to the list
def add_to_header(event):
    global paper_list
    
    selected_options = filter_list.value
    if selected_options:
        for option in selected_options:
            if option not in buttons_to_add:  # Check if option is already in header
                buttons_to_add.append(option)  # Add to header if not already present

                paper_list_itr = TLDR.run_code(option, loaded_dict)
                paper_list.append(paper_list_itr)
        filter_list.value = []  # Clear the selected options after adding them to the header
        update_header()  # Update the header after adding options


add_to_header_button.on_click(add_to_header)

# Function to update the header layout with the newly created buttons
def update_header():
    global paper_list
    header_buttons.clear()  # Clear the existing buttons

    for button_name in buttons_to_add:
        header_button = pn.widgets.Button(name=button_name, button_type = 'primary', button_style = 'outline')
        header_button.on_click(remove_from_header)  # Add callback to remove the header button
        header_buttons.append(header_button)
    buttons_to_add
    # Update the filter list options to exclude buttons that are already in the header
    filter_list.options = [option for option in entered_options if option not in buttons_to_add]
    main_body_instance.main_body = TLDR.update_mainTLDR(buttons_to_add, paper_list)
    
# Callback to remove the clicked header button
def remove_from_header(event):
    global paper_list
    button = event.obj  # Get the clicked button
    if button.name in buttons_to_add:
        del paper_list[buttons_to_add.index(button.name)]
        buttons_to_add.remove(button.name)  # Remove from the header buttons list
        filter_list.options.append(button.name)  # Add back to the filter list options
    update_header()  # Update the header and filter list
    
# MultiChoice widget to display the filter options with delete buttons
filter_list = pn.widgets.MultiChoice(
    name='',
    value=[],
    options=entered_options,
    margin=(20, 10),
    sizing_mode='fixed',
    solid=False,
    styles={'background': '#f0f0f0'},
    placeholder="Search Topics"
)
   
# Layout using Template
template = pn.template.FastListTemplate(
    title="EasySciRead",
    header=[pn.Row(header_buttons, width=750, sizing_mode='stretch_width'), pn.Row(filter_list, width=250), pn.Row(add_to_header_button, width=55)],
    main= main_body_instance.update,
    sidebar=[buttons],
    accent_base_color="#88d8b0",
    header_background="#FFFFFF",
    header_color="#000000",
    text_align='center',
    sidebar_width=160,
    sizing_mode = 'stretch_both'
)

# Run the app
template.servable()