Spaces:
Running
Running
File size: 5,548 Bytes
b5a1c35 e2793c2 b5a1c35 e2793c2 b5a1c35 e2793c2 b5a1c35 |
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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
import gradio as gr
from _rss_parser import rss_parser
# ====================================================================================================
# ====================================================================================================
# ====================================================================================================
def fn_display_all_news():
# import time
# time.sleep(9999)
html_content = ""
html_content += "<div id='all-news-items'>"
for e in rss_parser():
html_content += f"""
<div class='news-item'>
<div class='news-info'>
{e['time_ago']} • {e['meta_domain']}
</div>
<a target='_blank' href={e['link']}>
<p class='news-title'>
{e['title']}
</p>
</a>
<div class='news-summary'>
{e['summary'][:500]}
</div>
</div>
"""
html_content += "</div>"
return html_content
# ====================================================================================================
# ====================================================================================================
# ====================================================================================================
theme = gr.themes.Base(
primary_hue="neutral",
secondary_hue="neutral",
neutral_hue="neutral",
text_size="lg",
font=[gr.themes.GoogleFont('Inter')],
font_mono=[gr.themes.GoogleFont('Manufacturing Consent')],
)
head = """
<link rel="icon" href="https://cdn.jsdelivr.net/gh/OneLevelStudio/CORE/STATIC/1LV_LOGO_DARK.png">
"""
# * { -ms-overflow-style: none; scrollbar-width: none; }
# *::-webkit-scrollbar { display: none; }
css = """
#huggingface-space-header { display: none !important; }
footer { display: none !important; }
body {
overflow: hidden !important;
}
main {
padding: 0 !important;
max-width: 100% !important;
}
textarea {
padding-top: 5px !important;
padding-bottom: 6px !important;
}
.row, .column {
gap: 0 !important;
}
/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
background: transparent;
width: 8px;
border-radius: 999px;
}
::-webkit-scrollbar-track {
background: transparent;
border-radius: 999px;
}
::-webkit-scrollbar-thumb {
background: hsla(0, 0%, 50%, 0.5);
border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
background: hsla(0, 0%, 50%, 0.9);
}
/* ---------- Desktop/Mobile Only ---------- */
.desktop-only {
display: block;
}
@media only screen and (max-width: 1000px) {
.desktop-only {
display: none;
}
}
.mobile-only {
display: block;
}
@media only screen and (min-width: 1000px) {
.mobile-only {
display: none;
}
}
/* ---------- ---------- */
#all-news-items {
display: flex;
flex-direction: column;
height: 100svh;
overflow-y: scroll;
border-left: solid 1px hsla(0, 0%, 50%, 0.0);
border-right: solid 1px hsla(0, 0%, 50%, 0.0);
padding: 64px 33svw;
gap: 64px;
}
@media only screen and (max-width: 1000px) {
#all-news-items {
padding: 64px 16px;
}
}
.news-item {
border-radius: 8px;
background: hsla(0, 0%, 100%, 0.00);
border: solid 1px hsla(0, 0%, 100%, 0.00);
padding: 0px;
}
.news-item a {
padding: 0 !important;
text-align: left !important;
}
.news-item a .news-title {
font-size: 20px !important;
font-weight: 600 !important;
line-height: 1.3 !important;
margin: 0 !important;
color: white !important;
}
.news-info, .news-info * {
font-size: 14px !important;
color: grey !important;
}
.news-summary, .news-summary * {
font-size: 14px !important;
color: grey !important;
margin: 0 !important;
line-height: 1.5 !important;
text-decoration: none !important;
text-align: justify;
}
.news-info {
margin-bottom: 4px !important;
}
.news-summary {
margin-top: 8px !important;
}
/* ---------- ---------- */
#title-the-news {
border: none !important;
background: transparent !important;
}
#title-the-news .top-panel,
#title-the-news .cm-gutters {
display: none !important;
}
#title-the-news .cm-line {
font-size: 32px;
text-align: center;
}
.progress-text {
display: none !important;
}
"""
# ====================================================================================================
# ====================================================================================================
# ====================================================================================================
with gr.Blocks(title="The News") as demo:
with gr.Row():
# with gr.Column(scale=1):
# gr.Markdown()
with gr.Column(scale=1):
gr.Code("The News", container=False, show_label=False, show_line_numbers=False, elem_id="title-the-news")
display_all_news = gr.HTML("<div style='text-align: center; margin-top: 37svh;'>🕷 Spiders are crawling the big web 🕷<br>Please wait...</div>")
# with gr.Column(scale=1):
# gr.Markdown()
demo.load(
fn=lambda: fn_display_all_news(),
inputs=[],
outputs=[display_all_news],
show_progress="full",
)
demo.launch(theme=theme, head=head, css=css) |