-
Notifications
You must be signed in to change notification settings - Fork 0
/
navigation.py
72 lines (52 loc) · 2.14 KB
/
navigation.py
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
from time import sleep
import streamlit as st
from streamlit.runtime.scriptrunner import get_script_run_ctx
from streamlit.source_util import get_pages
def get_current_page_name():
"""
Retrieves the name of the current page.
Returns:
str: The name of the current page.
"""
ctx = get_script_run_ctx()
if ctx is None:
raise RuntimeError("Couldn't get script context")
pages = get_pages("")
return pages[ctx.page_script_hash]["page_name"]
# HORIZONTAL = "./media/DailyLinkai_horizontal.png"
# ICON = "./media/D.png"
def make_sidebar():
"""
Creates a sidebar for the application with a logo, title, and description.
It also includes a login status check, providing a link to the main page if logged in,
and a logout button. If not logged in, it redirects to the login page if attempting to access a secret page.
Parameters:
None
Returns:
None
"""
with st.sidebar:
# st.logo(HORIZONTAL, icon_image=ICON)
# st.image("./media/2.png",width=200)
st.title(" 📰 Your News, Smarter 📰")
st.write(
"DailyLinkai 💎, Powered by cutting-edge AI, curates articles tailored to your interests, evolving with your preferences through smart learning. Say goodbye to irrelevant news and hello to a customized, effortless news experience. "
)
st.write(
"Stay informed and explore new topics with DailyLinkai, your ultimate news companion!"
)
if st.session_state.get("logged_in", False):
st.page_link("pages/app.py", label="Main", icon="🔒")
st.write("")
st.write("")
if st.button("Log out"):
logout()
elif get_current_page_name() != "Homepage.py":
# If anyone tries to access a secret page without being logged in,
# redirect them to the login page
st.switch_page("Homepage.py")
def logout():
st.session_state.logged_in = False
st.info("Logged out successfully!")
sleep(0.5)
st.switch_page("Homepage.py")