add SPA config UI, wire media/rss adapters, event-driven layout push

- React SPA: dashboard, data sources CRUD, widgets CRUD, layout builder,
  presets. TanStack Router + Query, shadcn/ui, Vite proxy to :3000
- wire media + rss adapters into polling loop, remove xtb source type
- media adapter: read username/password from headers, proper subsonic auth
- event handler: subscribe to LayoutChanged, push screen update to clients
- fix clippy warnings across workspace (Default impls, collapsible ifs,
  redundant closures, is_none_or, unused imports)
This commit is contained in:
2026-06-19 00:12:42 +02:00
parent 21c08911df
commit 26ebfad3a2
175 changed files with 12338 additions and 801 deletions

View File

@@ -10,21 +10,32 @@ pub struct RssAdapter {
client: reqwest::Client,
}
impl RssAdapter {
pub fn new() -> Self {
impl Default for RssAdapter {
fn default() -> Self {
Self {
client: reqwest::Client::new(),
}
}
}
impl RssAdapter {
pub fn new() -> Self {
Self::default()
}
}
impl DataSourcePort for RssAdapter {
type Error = RssError;
async fn poll(&self, source: &DataSource) -> Result<Value, Self::Error> {
let url = source.config.url.as_ref().ok_or(RssError::NoUrl)?;
let resp = self.client.get(url).send().await.map_err(RssError::Request)?;
let resp = self
.client
.get(url)
.send()
.await
.map_err(RssError::Request)?;
let xml = resp.text().await.map_err(RssError::Request)?;
parser::parse_rss(&xml)

View File

@@ -29,10 +29,10 @@ pub fn parse_rss(xml: &str) -> Result<Value, RssError> {
}
Ok(Event::End(e)) => {
let tag = String::from_utf8_lossy(e.name().as_ref()).to_string();
if tag == "item" {
if let Some(item) = current_item.take() {
items.push(Value::Object(item));
}
if tag == "item"
&& let Some(item) = current_item.take()
{
items.push(Value::Object(item));
}
current_tag.clear();
}
@@ -52,10 +52,10 @@ pub fn parse_rss(xml: &str) -> Result<Value, RssError> {
}
Ok(Event::CData(e)) => {
let text = String::from_utf8_lossy(&e).to_string();
if !current_tag.is_empty() {
if let Some(item) = current_item.as_mut() {
item.insert(current_tag.clone(), Value::String(text));
}
if !current_tag.is_empty()
&& let Some(item) = current_item.as_mut()
{
item.insert(current_tag.clone(), Value::String(text));
}
}
Ok(Event::Eof) => break,

View File

@@ -1,5 +1,5 @@
use domain::Value;
use rss_adapter::{parse_rss, RssError};
use rss_adapter::{RssError, parse_rss};
const SAMPLE_RSS: &str = r#"<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
@@ -23,8 +23,20 @@ const SAMPLE_RSS: &str = r#"<?xml version="1.0" encoding="UTF-8"?>
fn parses_rss_into_value() {
let result = parse_rss(SAMPLE_RSS).unwrap();
assert_eq!(result.get_path("$.title"), Some(&Value::String("Test Feed".into())));
assert_eq!(result.get_path("$.items[0].title"), Some(&Value::String("First Article".into())));
assert_eq!(result.get_path("$.items[1].title"), Some(&Value::String("Second Article".into())));
assert_eq!(result.get_path("$.items[0].description"), Some(&Value::String("Description of first article".into())));
assert_eq!(
result.get_path("$.title"),
Some(&Value::String("Test Feed".into()))
);
assert_eq!(
result.get_path("$.items[0].title"),
Some(&Value::String("First Article".into()))
);
assert_eq!(
result.get_path("$.items[1].title"),
Some(&Value::String("Second Article".into()))
);
assert_eq!(
result.get_path("$.items[0].description"),
Some(&Value::String("Description of first article".into()))
);
}