Put real feed url into feed
Instead of hardcoding the feed file name to be feed.atom, it has been configurable for a while. This is now also reflected in the feed itself. Signed-off-by: Jacob Kiers <jacob@jacobkiers.net>
This commit is contained in:
parent
71371cb3e1
commit
9129f7e11b
|
@ -57,10 +57,11 @@ pub(crate) fn add_entry_to_feed(
|
|||
feed.entries.push(entry);
|
||||
}
|
||||
|
||||
pub(crate) fn build_atom_feed(hostname: &String) -> Feed {
|
||||
pub(crate) fn build_atom_feed(hostname: &String, feed_file: &str) -> Feed {
|
||||
let feed_url = format!("https://{}/{}", hostname, feed_file);
|
||||
FeedBuilder::default()
|
||||
.title("JJKiers Newsletters")
|
||||
.id(format!("https://{}/feed.atom", hostname))
|
||||
.id(&feed_url)
|
||||
.link(
|
||||
LinkBuilder::default()
|
||||
.href(format!("https://{}/", hostname))
|
||||
|
@ -69,7 +70,7 @@ pub(crate) fn build_atom_feed(hostname: &String) -> Feed {
|
|||
)
|
||||
.link(
|
||||
LinkBuilder::default()
|
||||
.href(format!("https://{}/feed.atom", hostname))
|
||||
.href(&feed_url)
|
||||
.rel("self".to_string())
|
||||
.build(),
|
||||
)
|
||||
|
|
|
@ -70,7 +70,11 @@ fn build_feed(filename: &PathBuf, hostname: String, include_html: bool) -> Resul
|
|||
|
||||
create_directory(dir)?;
|
||||
|
||||
let mut feed = feed::build_atom_feed(&hostname);
|
||||
let feed_file = filename
|
||||
.file_name().expect("Feed path should have a file name")
|
||||
.to_str().expect("Feed path should be printable.");
|
||||
|
||||
let mut feed = feed::build_atom_feed(&hostname, feed_file);
|
||||
|
||||
let mut reader = DataDirectoryMessageReader::new((&Path::new("data")).to_path_buf());
|
||||
|
||||
|
@ -117,7 +121,6 @@ fn build_feed(filename: &PathBuf, hostname: String, include_html: bool) -> Resul
|
|||
// Another ugly hack, but I don't know how to do this better...
|
||||
let file_name = format!("{:?}", filename.file_name().unwrap()).replace('"', "");
|
||||
write_file(dir.join("index.html"), INDEX_HTML.replace("{FEED}", file_name.as_str()))?;
|
||||
|
||||
}
|
||||
|
||||
println!("Finished building the feed.");
|
||||
|
|
Loading…
Reference in New Issue