mirror of
https://gitlab.com/Anson-Projects/zine.git
synced 2025-07-27 00:31:23 +00:00
Make featured post temporary
Also remove factorio since it posts so frequently
This commit is contained in:
@@ -75,7 +75,7 @@ fn create_featured_card(entry: &Entry) -> Markup {
|
||||
}
|
||||
footer {
|
||||
a class="grid" href=(link.href) style="--pico-text-decoration: none;" {
|
||||
button class="outline primary" { "Read Post" }
|
||||
button class="outline primary" { "Read Featured Post" }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -246,10 +246,9 @@ fn about_modal(entries: Vec<Entry>) -> Markup {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn generate_index(mut entries: Vec<Entry>) -> Markup {
|
||||
pub fn generate_index(mut entries: Vec<Entry>, featured: Entry) -> Markup {
|
||||
let running_in_gitlab = env::var("CI").map(|val| val == "true").unwrap_or(false);
|
||||
|
||||
let featured = entries.remove(0);
|
||||
if running_in_gitlab {
|
||||
log::info!("Building for deployment");
|
||||
entries.truncate(30);
|
||||
@@ -258,6 +257,14 @@ pub fn generate_index(mut entries: Vec<Entry>) -> Markup {
|
||||
entries.truncate(6);
|
||||
}
|
||||
|
||||
let featured_card: maud::PreEscaped<String>;
|
||||
if (utilities::get_entry_date(&featured)) > (chrono::Utc::now() - chrono::Duration::days(3)) {
|
||||
featured_card = create_featured_card(&featured);
|
||||
entries.retain(|entry| entry != &featured);
|
||||
} else {
|
||||
featured_card = html! {};
|
||||
}
|
||||
|
||||
html! {
|
||||
(maud::DOCTYPE)
|
||||
html {
|
||||
@@ -272,7 +279,7 @@ pub fn generate_index(mut entries: Vec<Entry>) -> Markup {
|
||||
}
|
||||
body { main class="container" {
|
||||
{(generate_header())}
|
||||
(create_featured_card(&featured))
|
||||
(featured_card)
|
||||
div class="grid" {
|
||||
@for column_entries in utilities::group_by_nth(&entries, 3) {
|
||||
div {
|
||||
|
@@ -17,17 +17,14 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
simple_logger::init_with_level(log::Level::Info).unwrap();
|
||||
|
||||
let featured = read_feed("featured_feeds.txt").first().unwrap().clone();
|
||||
let mut entries = read_feed("feeds.txt");
|
||||
let entries = read_feed("feeds.txt");
|
||||
|
||||
// Move featured article to the front
|
||||
entries.retain(|entry| entry != &featured);
|
||||
entries.insert(0, featured);
|
||||
log::info!(
|
||||
"Featured article: {}",
|
||||
entries[0].links.first().unwrap().href.as_str()
|
||||
);
|
||||
|
||||
let index = index_generator::generate_index(entries);
|
||||
let index = index_generator::generate_index(entries, featured);
|
||||
|
||||
let output_path = Path::new("output/index.html");
|
||||
DirBuilder::new()
|
||||
|
@@ -28,12 +28,15 @@ pub fn read_feed(path: &str) -> Vec<Entry> {
|
||||
|
||||
// Remove any entries that don't have a timestamp, and then sort by timestamps
|
||||
entries.retain(|entry| entry.published.is_some() || entry.updated.is_some());
|
||||
entries
|
||||
.sort_by_key(|entry| Reverse(entry.published.unwrap_or(entry.updated.unwrap_or_default())));
|
||||
entries.sort_by_key(|entry| Reverse(get_entry_date(entry)));
|
||||
|
||||
entries
|
||||
}
|
||||
|
||||
pub fn get_entry_date(entry: &Entry) -> chrono::DateTime<chrono::Utc> {
|
||||
entry.published.unwrap_or(entry.updated.unwrap_or_default())
|
||||
}
|
||||
|
||||
pub fn get_root_url(input_url: &str) -> &str {
|
||||
let mut url = input_url;
|
||||
|
||||
|
Reference in New Issue
Block a user