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:
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user