Add a browser-facing Miniflux URL and link feeds to their entries page

The pipeline talks to Miniflux on loopback, so links meant for a person
need their own base. `[miniflux].public_url` defaults to base_url, and
`feed_url` builds the web UI's `/feed/{id}/entries` page, which the feeds
dashboard now uses instead of the non-existent `/feeds/{id}` route.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YWmCpUojfHXhSZ2129Z7Nv
This commit is contained in:
2026-09-09 05:45:14 +00:00
co-authored by Claude Fable 5.1
parent c8df55e91a
commit 8a8d5d1f16
4 changed files with 68 additions and 6 deletions
+60
View File
@@ -122,6 +122,9 @@ impl Default for Config {
#[serde(deny_unknown_fields, default)]
pub struct MinifluxConfig {
pub base_url: String,
/// Where a browser reaches the Miniflux web UI, for links in the dashboard;
/// defaults to `base_url`.
pub public_url: Option<String>,
/// `X-Auth-Token`; supply via `DAILY_EPUB_MINIFLUX__API_KEY`.
pub api_key: Option<String>,
/// Page size for `GET /v1/entries` (Miniflux caps this at 250).
@@ -132,12 +135,29 @@ impl Default for MinifluxConfig {
fn default() -> Self {
Self {
base_url: "http://127.0.0.1:8082".into(),
public_url: None,
api_key: None,
page_limit: 250,
}
}
}
impl MinifluxConfig {
/// Browser-facing base URL without trailing slashes.
pub fn public_url(&self) -> &str {
self.public_url
.as_deref()
.filter(|url| !url.trim().is_empty())
.unwrap_or(&self.base_url)
.trim_end_matches('/')
}
/// Browser-facing URL for one feed's entries.
pub fn feed_url(&self, feed_id: i64) -> String {
format!("{}/feed/{feed_id}/entries", self.public_url())
}
}
/// `[llm]` — the role assignments and the role-level knobs (§4).
///
/// `bulk` runs triage, deep assessment and every fallback; `editor` runs the
@@ -1473,6 +1493,46 @@ mod tests {
c.validate().unwrap();
}
#[test]
fn miniflux_public_url_defaults_to_base_url() {
let miniflux = MinifluxConfig {
base_url: "http://127.0.0.1:8082/".into(),
..MinifluxConfig::default()
};
assert_eq!(miniflux.public_url(), "http://127.0.0.1:8082");
let blank = MinifluxConfig {
base_url: "https://api.example.com/".into(),
public_url: Some(" ".into()),
..MinifluxConfig::default()
};
assert_eq!(blank.public_url(), "https://api.example.com");
}
#[test]
fn explicit_miniflux_public_url_wins_and_trims_trailing_slashes() {
let miniflux = MinifluxConfig {
public_url: Some("https://miniflux.example.com///".into()),
..MinifluxConfig::default()
};
assert_eq!(miniflux.public_url(), "https://miniflux.example.com");
}
#[test]
fn miniflux_feed_url_points_to_the_web_ui_entries_route() {
let miniflux = MinifluxConfig {
public_url: Some("https://miniflux.example.com/".into()),
..MinifluxConfig::default()
};
assert_eq!(
miniflux.feed_url(77),
"https://miniflux.example.com/feed/77/entries"
);
}
#[test]
// `Jail::expect_with` dictates the closure's `figment::Error` return type.
#[allow(clippy::result_large_err)]
+4 -6
View File
@@ -88,7 +88,7 @@ struct FeedRow {
/// timestamps sit in the cell's tooltip.
seen: String,
decided_at: String,
/// `{miniflux.base_url}/feeds/{id}` for a candidate we subscribed to.
/// The Miniflux web UI page for a candidate we subscribed to.
miniflux_href: Option<String>,
}
@@ -157,10 +157,9 @@ async fn index(
None => load_evidence(db, &config, &candidates).await?,
};
let titles = article_titles(db, &candidates).await?;
let base_url = config.miniflux.base_url.trim_end_matches('/').to_string();
let rows: Vec<FeedRow> = candidates
.iter()
.map(|candidate| row(candidate, &evidence, &titles, &config, &base_url))
.map(|candidate| row(candidate, &evidence, &titles, &config))
.collect();
// The picker is only ever used by the candidate view, so only it pays for
@@ -381,7 +380,6 @@ fn row(
evidence: &HashMap<ArticleId, ArticleEvidence>,
titles: &HashMap<ArticleId, String>,
config: &Config,
base_url: &str,
) -> FeedRow {
let mut scored = evidence_of(candidate, evidence);
let score = discovery::score(&scored);
@@ -433,7 +431,7 @@ fn row(
decided_at: fmt_stored_time(candidate.decided_at.as_deref(), config),
miniflux_href: candidate
.miniflux_feed_id
.map(|feed_id| format!("{base_url}/feeds/{feed_id}")),
.map(|feed_id| config.miniflux.feed_url(feed_id)),
}
}
@@ -610,7 +608,7 @@ mod tests {
assert!(body.contains("Added Strong Blog."), "{body}");
let added =
response_text(get(&app, "/dashboard/feeds?status=added", Some(&admin)).await).await;
assert!(added.contains("/feeds/77"), "{added}");
assert!(added.contains("/feed/77/entries"), "{added}");
}
#[tokio::test]
+2
View File
@@ -218,6 +218,7 @@ pub const RESTART_REQUIRED: &[&str] = &[
/// Optional keys that `Config::default()` leaves unset (and therefore do not
/// appear when the defaults are serialized), with the kind they take.
const OPTIONAL_KEYS: &[(&str, FieldKind)] = &[
("miniflux.public_url", FieldKind::Text),
("miniflux.api_key", FieldKind::Secret),
("providers.*.api_key", FieldKind::Secret),
("providers.*.effort", FieldKind::Text),
@@ -296,6 +297,7 @@ pub const SETTINGS_HELP: &[(&str, &str)] = &[
("profile_path", "Hand-maintained reader profile, loaded every run."),
("interests_opml", "Scour interests OPML merged with the profile interests."),
("miniflux.base_url", "Miniflux root (no /v1)."),
("miniflux.public_url", "Browser-facing Miniflux web UI URL for dashboard links. Defaults to miniflux.base_url."),
("miniflux.api_key", "X-Auth-Token for Miniflux. Required; environment only."),
("miniflux.page_limit", "Entries per page for GET /v1/entries; Miniflux caps this at 250."),
("llm.bulk", "The [providers.*] name that runs triage, deep assessment and every fallback. Empty means no bulk provider (those stages are skipped)."),