wip: adding RSS feeds
This commit is contained in:
parent
70f302b5b5
commit
9ebc0c9736
2 changed files with 20 additions and 8 deletions
11
src/main.rs
11
src/main.rs
|
@ -308,7 +308,7 @@ struct CliDebugRss {
|
|||
}
|
||||
|
||||
/// Wraps rss::Item in our own type suitable for merging
|
||||
struct RssItem {
|
||||
pub(crate) struct FeedItem {
|
||||
channel_title: String,
|
||||
date: chrono::DateTime<chrono::FixedOffset>,
|
||||
inner: rss::Item,
|
||||
|
@ -316,6 +316,7 @@ struct RssItem {
|
|||
|
||||
fn main_debug_rss(cli: CliDebugRss) -> Result<()> {
|
||||
let mut items = Vec::new();
|
||||
let now = Utc::now();
|
||||
|
||||
for path in &cli.paths {
|
||||
let s = std::fs::read(path)?;
|
||||
|
@ -329,7 +330,7 @@ fn main_debug_rss(cli: CliDebugRss) -> Result<()> {
|
|||
.context("Every RSS Item should have a pub_date")?,
|
||||
)?;
|
||||
|
||||
let item = RssItem {
|
||||
let item = FeedItem {
|
||||
channel_title: channel_title.clone(),
|
||||
date,
|
||||
inner: item,
|
||||
|
@ -348,6 +349,12 @@ fn main_debug_rss(cli: CliDebugRss) -> Result<()> {
|
|||
println!();
|
||||
}
|
||||
|
||||
std::fs::create_dir_all("output")?;
|
||||
output::atomic_write(
|
||||
"output/feed.html",
|
||||
&output::feed_page(&items, now.with_timezone(&chrono_tz::UTC)),
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue