|
|
@ -1,23 +1,8 @@ |
|
|
|
use crate::cohost_account::CohostAccount; |
|
|
|
use crate::cohost_posts::*; |
|
|
|
use crate::ARGS; |
|
|
|
use atom_syndication::LinkBuilder; |
|
|
|
use rss::extension::atom::{AtomExtensionBuilder, Link}; |
|
|
|
use rss::Channel; |
|
|
|
|
|
|
|
fn rel_link_for(rel: &str, project_name: &str, page_number: u64) -> Link { |
|
|
|
LinkBuilder::default() |
|
|
|
.rel(rel) |
|
|
|
.href(format!( |
|
|
|
"https://{}{}{}/feed.rss?page={}", |
|
|
|
&ARGS.domain, |
|
|
|
&ARGS.base_url, |
|
|
|
project_name.clone(), |
|
|
|
page_number |
|
|
|
)) |
|
|
|
.build() |
|
|
|
} |
|
|
|
|
|
|
|
pub fn channel_for_posts_page( |
|
|
|
project_name: impl AsRef<str>, |
|
|
|
project: CohostAccount, |
|
|
@ -40,15 +25,6 @@ pub fn channel_for_posts_page( |
|
|
|
))) |
|
|
|
.link(format!("https://cohost.org/{}", project_name,)); |
|
|
|
|
|
|
|
let mut atom = AtomExtensionBuilder::default(); |
|
|
|
let links = vec![ |
|
|
|
rel_link_for("self", project_name, 0), |
|
|
|
rel_link_for("first", project_name, 0), |
|
|
|
]; |
|
|
|
atom.links(links); |
|
|
|
|
|
|
|
builder.atom_ext(Some(atom.build())); |
|
|
|
|
|
|
|
page.items.sort_by_key(|item| item.published_at); |
|
|
|
let mut items = Vec::with_capacity(page.number_items); |
|
|
|
for item in page.items { |
|
|
|