UI-Anpassung: Feed-Anzeige entfernt, Tabelle verbessert
This commit is contained in:
parent
fe2191e6c8
commit
2db9544fda
9 changed files with 438 additions and 156 deletions
143
app.py
143
app.py
|
|
@ -1,92 +1,95 @@
|
|||
# app.py
|
||||
|
||||
import streamlit as st
|
||||
import json
|
||||
import os
|
||||
from datetime import datetime
|
||||
from dotenv import load_dotenv
|
||||
from email.utils import parsedate_to_datetime
|
||||
from main import load_articles, save_articles, process_articles, fetch_and_process_feed, rewrite_articles
|
||||
from main import (
|
||||
load_feeds,
|
||||
save_feeds,
|
||||
load_articles,
|
||||
save_articles,
|
||||
process_articles,
|
||||
rewrite_articles
|
||||
)
|
||||
import os
|
||||
|
||||
load_dotenv()
|
||||
st.set_page_config(page_title="📰 RSS Artikel Manager", layout="wide")
|
||||
st.title("📰 RSS Artikel Manager")
|
||||
|
||||
st.set_page_config(layout="wide", page_title="RSS Article Manager")
|
||||
# RSS Feed Verwaltung
|
||||
st.sidebar.header("📡 RSS Feeds verwalten")
|
||||
feeds = load_feeds()
|
||||
new_feed = st.sidebar.text_input("Neuen RSS Feed hinzufügen")
|
||||
if st.sidebar.button("Feed hinzufügen"):
|
||||
if new_feed and new_feed not in feeds:
|
||||
feeds.append({"url": new_feed})
|
||||
save_feeds(feeds)
|
||||
st.sidebar.success("Feed hinzugefügt")
|
||||
|
||||
# Artikelstatusfilter
|
||||
status_filter = st.sidebar.selectbox("🔍 Artikelstatus filtern", ["Alle", "New", "Rewrite", "Process", "Online", "On Hold", "Trash"])
|
||||
|
||||
# Neuen Feed hinzufügen
|
||||
st.sidebar.markdown("---")
|
||||
st.sidebar.header("➕ RSS Feed hinzufügen")
|
||||
new_feed_url = st.sidebar.text_input("Feed URL")
|
||||
if st.sidebar.button("Feed hinzufügen") and new_feed_url:
|
||||
fetch_and_process_feed(new_feed_url)
|
||||
st.rerun()
|
||||
|
||||
# Alle Feeds neu laden
|
||||
if st.sidebar.button("Alle Feeds neu laden"):
|
||||
process_articles()
|
||||
st.rerun()
|
||||
#if feeds:
|
||||
# st.sidebar.write("### Aktuelle Feeds:")
|
||||
# for feed in feeds:
|
||||
# url = feed["url"] if isinstance(feed, dict) else feed
|
||||
# st.sidebar.markdown(f"- {url}")
|
||||
#else:
|
||||
# st.sidebar.info("Noch keine Feeds hinzugefügt.")
|
||||
|
||||
# Artikel laden
|
||||
try:
|
||||
articles = load_articles()
|
||||
except json.decoder.JSONDecodeError:
|
||||
articles = []
|
||||
if st.sidebar.button("🔄 Alle Feeds neu laden"):
|
||||
existing_ids = [a["id"] for a in load_articles()]
|
||||
process_articles(existing_ids)
|
||||
st.rerun()
|
||||
|
||||
# Artikel nach Status filtern
|
||||
if st.sidebar.button("✍️ Artikel umschreiben (Rewrite)"):
|
||||
rewrite_articles()
|
||||
st.rerun()
|
||||
|
||||
# Artikelübersicht
|
||||
st.header("📋 Artikelübersicht")
|
||||
status_filter = st.selectbox("Status filtern", ["Alle", "New", "Rewrite", "Process", "Online", "On Hold", "Trash"])
|
||||
|
||||
articles = load_articles()
|
||||
if status_filter != "Alle":
|
||||
articles = [a for a in articles if a.get("status") == status_filter]
|
||||
|
||||
# Artikelübersicht
|
||||
st.title("📰 RSS Artikel Übersicht")
|
||||
st.markdown("---")
|
||||
|
||||
if not articles:
|
||||
st.info("Keine Artikel gefunden.")
|
||||
else:
|
||||
st.markdown("### 📄 Artikelliste")
|
||||
selected_ids = []
|
||||
all_statuses = ["New", "Rewrite", "Process", "Online", "On Hold", "Trash"]
|
||||
# Tabelle anzeigen
|
||||
if articles:
|
||||
st.markdown("### 📄 Übersichtstabelle")
|
||||
st.write("**Spaltenübersicht:** Auswahl | Datum | Titel | Zusammenfassung | Wörter | Tags | Status")
|
||||
|
||||
for article in articles:
|
||||
col1, col2, col3, col4, col5, col6, col7 = st.columns([0.5, 1.2, 2.5, 2, 1, 2, 1.2])
|
||||
with col1:
|
||||
if st.checkbox("", key=f"select_{article['id']}"):
|
||||
selected_ids.append(article['id'])
|
||||
with col2:
|
||||
date = parsedate_to_datetime(article['date']).strftime("%d.%m.%y")
|
||||
st.markdown(date)
|
||||
with col3:
|
||||
st.markdown(article['title'])
|
||||
with col4:
|
||||
st.markdown(article['summary'][:150] + ("..." if len(article['summary']) > 150 else ""))
|
||||
with col5:
|
||||
word_count = len(article['text'].split())
|
||||
st.markdown(str(word_count))
|
||||
with col6:
|
||||
cols = st.columns([0.05, 0.1, 0.2, 0.25, 0.05, 0.2, 0.15])
|
||||
with cols[0]:
|
||||
st.checkbox("", key=f"select_{article['id']}")
|
||||
with cols[1]:
|
||||
st.markdown(datetime.strptime(article["date"], "%a, %d %b %Y %H:%M:%S %z").strftime("%d.%m.%y") if "GMT" in article["date"] or "+" in article["date"] else article["date"][:10])
|
||||
with cols[2]:
|
||||
st.markdown(f"**{article['title']}**")
|
||||
with cols[3]:
|
||||
st.markdown(article.get("summary", "")[:150])
|
||||
with cols[4]:
|
||||
st.markdown(str(len(article.get("text", "").split())))
|
||||
with cols[5]:
|
||||
st.markdown(", ".join(article.get("tags", [])))
|
||||
with col7:
|
||||
status = st.selectbox("", all_statuses, index=all_statuses.index(article.get("status", "New")), key=f"status_{article['id']}")
|
||||
if status != article.get("status"):
|
||||
article["status"] = status
|
||||
with cols[6]:
|
||||
status_options = ["New", "Rewrite", "Process", "Online", "On Hold", "Trash"]
|
||||
current_status = article.get("status", "New")
|
||||
new_status = st.selectbox("", status_options, index=status_options.index(current_status), key=f"status_{article['id']}")
|
||||
if new_status != current_status:
|
||||
article["status"] = new_status
|
||||
save_articles(articles)
|
||||
st.rerun()
|
||||
|
||||
if selected_ids:
|
||||
new_status = st.selectbox("Status für ausgewählte Artikel setzen", all_statuses)
|
||||
if st.button("✅ Status aktualisieren"):
|
||||
for article in articles:
|
||||
if article['id'] in selected_ids:
|
||||
article['status'] = new_status
|
||||
save_articles(articles)
|
||||
st.success("Status aktualisiert.")
|
||||
st.rerun()
|
||||
with st.expander(f"🔍 {article['title']}"):
|
||||
st.markdown("#### ✍️ Artikeltext")
|
||||
st.code(f"{article['title']}\n\n{article['text']}\n\nQuelle: {article['link']}", language="markdown")
|
||||
|
||||
st.markdown("---")
|
||||
st.markdown("#### 🏷️ Tags")
|
||||
st.code(", ".join(article.get("tags", [])), language="markdown")
|
||||
|
||||
if st.button("✍️ Artikel mit Status 'Rewrite' umschreiben"):
|
||||
rewrite_articles()
|
||||
st.rerun()
|
||||
st.markdown("#### 🖼️ Bilder")
|
||||
for img in article.get("images", []):
|
||||
st.image(img["url"], caption=img.get("caption", "Kein Titel"), use_column_width=True)
|
||||
st.caption(f"© {img.get('copyright', 'Unbekannt')} | [Quelle]({img.get('copyright_url', '#')})")
|
||||
|
||||
st.markdown("---")
|
||||
else:
|
||||
st.info("Keine Artikel für den gewählten Status gefunden.")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue