Spaces:
Sleeping
Sleeping
Update utils/ui_helpers.py
Browse files- utils/ui_helpers.py +19 -64
utils/ui_helpers.py
CHANGED
|
@@ -1,67 +1,22 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import pandas as pd
|
| 3 |
|
| 4 |
-
def
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
col1.metric("Status Code", data["metadata"]["status_code"])
|
| 12 |
-
col2.metric("Content Type", content_type)
|
| 13 |
-
col3.metric("Timestamp", data["metadata"]["timestamp"])
|
| 14 |
-
|
| 15 |
-
# Content sections based on what was extracted
|
| 16 |
-
if "article" in data["content"]:
|
| 17 |
-
with st.expander("π Article Content", expanded=True):
|
| 18 |
-
st.subheader(data["content"]["article"]["title"])
|
| 19 |
-
st.write(data["content"]["article"]["content"])
|
| 20 |
-
|
| 21 |
-
if "text" in data["content"]:
|
| 22 |
-
with st.expander("π Text Content"):
|
| 23 |
-
for i, text in enumerate(data["content"]["text"][:10]): # Show first 10 paragraphs
|
| 24 |
-
st.write(text)
|
| 25 |
-
if i < len(data["content"]["text"][:10]) - 1:
|
| 26 |
-
st.divider()
|
| 27 |
-
|
| 28 |
-
if "images" in data["content"] and data["content"]["images"]:
|
| 29 |
-
with st.expander("πΌοΈ Images"):
|
| 30 |
-
for img in data["content"]["images"][:5]: # Show first 5 images
|
| 31 |
-
st.image(img["src"], caption=img["alt"], use_column_width=True)
|
| 32 |
-
|
| 33 |
-
if "links" in data["content"] and data["content"]["links"]:
|
| 34 |
-
with st.expander("π Links"):
|
| 35 |
-
links_df = pd.DataFrame(data["content"]["links"])
|
| 36 |
-
st.dataframe(links_df[["text", "href"]].head(10)) # Show first 10 links
|
| 37 |
-
|
| 38 |
-
if "custom" in data["content"] and data["content"]["custom"]:
|
| 39 |
-
with st.expander("π― Custom Elements"):
|
| 40 |
-
for element in data["content"]["custom"]:
|
| 41 |
-
st.write(f"**Selector**: `{element['selector']}`")
|
| 42 |
-
st.write(f"**Text**: {element['text']}")
|
| 43 |
-
st.divider()
|
| 44 |
|
| 45 |
-
def
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
if "quote" in element["selector"]:
|
| 58 |
-
st.info(f'"{element["text"]}"')
|
| 59 |
-
st.divider()
|
| 60 |
-
|
| 61 |
-
def render_newsletter(data):
|
| 62 |
-
"""Specialized rendering for news content"""
|
| 63 |
-
if "custom" in data["content"]:
|
| 64 |
-
st.subheader("π° News Headlines")
|
| 65 |
-
for element in data["content"]["custom"]:
|
| 66 |
-
if any(sel in element["selector"] for sel in [".title", ".storylink"]):
|
| 67 |
-
st.write(f"β’ {element['text']}")
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
|
| 3 |
+
def styled_container(title, content):
|
| 4 |
+
return st.markdown(f"""
|
| 5 |
+
<div class="card">
|
| 6 |
+
<h3>{title}</h3>
|
| 7 |
+
{content}
|
| 8 |
+
</div>
|
| 9 |
+
""", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
def render_footer():
|
| 12 |
+
st.divider()
|
| 13 |
+
st.markdown("""
|
| 14 |
+
<div style="text-align: center; padding: 1.5rem; color: #666;">
|
| 15 |
+
<p>Built with β€οΈ using Python, FastAPI, and Streamlit</p>
|
| 16 |
+
<p>
|
| 17 |
+
<a href="https://github.com/yourusername/webtapi" target="_blank">GitHub</a> |
|
| 18 |
+
<a href="https://huggingface.co/spaces" target="_blank">Hugging Face</a> |
|
| 19 |
+
AGPL-3.0 License
|
| 20 |
+
</p>
|
| 21 |
+
</div>
|
| 22 |
+
""", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|