Compare commits

..

No commits in common. "9cc28f6f0dc022b0b49689cfb82ff8bdb7a91900" and "0420f58d02470c950bcac216591e0963982ec241" have entirely different histories.

5 changed files with 4 additions and 75 deletions

View File

@ -1,4 +1,4 @@
* Things to do [6/17] * Things to do [5/14]
** DONE If the paragraph only contains an image, text-align center ** DONE If the paragraph only contains an image, text-align center
** DONE Syntax highlighting for code blocks ** DONE Syntax highlighting for code blocks
** TODO Render gnuplot ** TODO Render gnuplot
@ -16,6 +16,3 @@
*** TODO gnuplot *** TODO gnuplot
https://github.com/dpezto/tree-sitter-gnuplot is not on crates.io so I'd have to add a git dependency to use it. This would prevent publishing this crate to crates.io. https://github.com/dpezto/tree-sitter-gnuplot is not on crates.io so I'd have to add a git dependency to use it. This would prevent publishing this crate to crates.io.
** DONE Bug: carry over highlight starts when breaking lines ** DONE Bug: carry over highlight starts when breaking lines
** TODO Add dates to posts
** DONE Add support for unlisted posts (posts that do not show up on the homepage).
** TODO Add support for showing file name where we currently show language

View File

@ -18,7 +18,6 @@ use crate::error::CustomError;
use crate::intermediate::get_web_path; use crate::intermediate::get_web_path;
use crate::intermediate::BlogPost; use crate::intermediate::BlogPost;
use crate::intermediate::IPage; use crate::intermediate::IPage;
use crate::intermediate::PublishStatus;
use crate::render::DusterRenderer; use crate::render::DusterRenderer;
use crate::render::RendererIntegration; use crate::render::RendererIntegration;
use crate::walk_fs::walk_fs; use crate::walk_fs::walk_fs;
@ -85,11 +84,7 @@ impl SiteRenderer {
pub(crate) async fn render_pages(&self, config: &Config) -> Result<(), CustomError> { pub(crate) async fn render_pages(&self, config: &Config) -> Result<(), CustomError> {
let renderer_integration = self.init_renderer_integration()?; let renderer_integration = self.init_renderer_integration()?;
for page in self.pages.iter().filter(|page| match page.natter_publish { for page in &self.pages {
PublishStatus::Full => true,
PublishStatus::Unlisted => true,
PublishStatus::Unpublished => false,
}) {
let output_path = self.output_directory.join(page.get_output_path()); let output_path = self.output_directory.join(page.get_output_path());
let dependency_manager = let dependency_manager =
std::sync::Arc::new(std::sync::Mutex::new(DependencyManager::new())); std::sync::Arc::new(std::sync::Mutex::new(DependencyManager::new()));
@ -120,17 +115,7 @@ impl SiteRenderer {
pub(crate) async fn render_blog_posts(&self, config: &Config) -> Result<(), CustomError> { pub(crate) async fn render_blog_posts(&self, config: &Config) -> Result<(), CustomError> {
let renderer_integration = self.init_renderer_integration()?; let renderer_integration = self.init_renderer_integration()?;
for blog_post in self.blog_posts.iter().filter(|blog_post| { for blog_post in &self.blog_posts {
match blog_post
.get_index_page()
.expect("Blog posts should have an index page.")
.natter_publish
{
PublishStatus::Full => true,
PublishStatus::Unlisted => true,
PublishStatus::Unpublished => false,
}
}) {
for blog_post_page in &blog_post.pages { for blog_post_page in &blog_post.pages {
let output_path = self let output_path = self
.output_directory .output_directory
@ -170,21 +155,7 @@ impl SiteRenderer {
// Sort blog posts by date, newest first. // Sort blog posts by date, newest first.
let sorted_blog_posts = { let sorted_blog_posts = {
let mut sorted_blog_posts: Vec<_> = self let mut sorted_blog_posts: Vec<_> = self.blog_posts.iter().collect();
.blog_posts
.iter()
.filter(|blog_post| {
match blog_post
.get_index_page()
.expect("Blog posts should have an index page.")
.natter_publish
{
PublishStatus::Full => true,
PublishStatus::Unlisted => false,
PublishStatus::Unpublished => false,
}
})
.collect();
sorted_blog_posts sorted_blog_posts
.sort_by_key(|blog_post| (blog_post.get_date(), blog_post.id.as_str())); .sort_by_key(|blog_post| (blog_post.get_date(), blog_post.id.as_str()));
sorted_blog_posts.reverse(); sorted_blog_posts.reverse();

View File

@ -48,16 +48,6 @@ pub(crate) struct BlogPostPage {
pub(crate) children: Vec<IDocumentElement>, pub(crate) children: Vec<IDocumentElement>,
pub(crate) footnotes: Vec<IRealFootnoteDefinition>, pub(crate) footnotes: Vec<IRealFootnoteDefinition>,
pub(crate) natter_publish: PublishStatus,
}
#[derive(Debug, Default)]
pub(crate) enum PublishStatus {
#[default]
Full,
Unlisted,
Unpublished,
} }
intermediate!( intermediate!(
@ -103,7 +93,6 @@ intermediate!(
date: get_date(original.document), date: get_date(original.document),
children, children,
footnotes, footnotes,
natter_publish: get_publish_status(original.document).unwrap_or_default(),
}) })
} }
); );
@ -140,25 +129,3 @@ pub(crate) fn get_date(document: &organic::types::Document<'_>) -> Option<String
.last() .last()
.map(|kw| kw.value.to_owned()) .map(|kw| kw.value.to_owned())
} }
pub(crate) fn get_publish_status(document: &organic::types::Document<'_>) -> Option<PublishStatus> {
let publish_string = organic::types::AstNode::from(document)
.iter_all_ast_nodes()
.filter_map(|node| match node {
organic::types::AstNode::Keyword(kw)
if kw.key.eq_ignore_ascii_case("natter_publish") =>
{
Some(kw)
}
_ => None,
})
.last()
.map(|kw| kw.value);
match publish_string {
Some("full") => Some(PublishStatus::Full),
Some("unlisted") => Some(PublishStatus::Unlisted),
Some("unpublished") => Some(PublishStatus::Unpublished),
Some(status) => panic!("Unrecognized publish status: {}", status),
None => None,
}
}

View File

@ -74,7 +74,6 @@ pub(crate) use babel_call::IBabelCall;
pub(crate) use blog_post::get_org_files; pub(crate) use blog_post::get_org_files;
pub(crate) use blog_post::BlogPost; pub(crate) use blog_post::BlogPost;
pub(crate) use blog_post_page::BlogPostPage; pub(crate) use blog_post_page::BlogPostPage;
pub(crate) use blog_post_page::PublishStatus;
pub(crate) use bold::IBold; pub(crate) use bold::IBold;
pub(crate) use center_block::ICenterBlock; pub(crate) use center_block::ICenterBlock;
pub(crate) use citation::ICitation; pub(crate) use citation::ICitation;

View File

@ -1,12 +1,10 @@
use super::blog_post_page::get_date; use super::blog_post_page::get_date;
use super::blog_post_page::get_publish_status;
use super::blog_post_page::get_title; use super::blog_post_page::get_title;
use super::footnote_definition::IRealFootnoteDefinition; use super::footnote_definition::IRealFootnoteDefinition;
use super::macros::intermediate; use super::macros::intermediate;
use super::IDocumentElement; use super::IDocumentElement;
use super::IHeading; use super::IHeading;
use super::ISection; use super::ISection;
use super::PublishStatus;
use crate::error::CustomError; use crate::error::CustomError;
use std::path::PathBuf; use std::path::PathBuf;
@ -26,8 +24,6 @@ pub(crate) struct IPage {
pub(crate) children: Vec<IDocumentElement>, pub(crate) children: Vec<IDocumentElement>,
pub(crate) footnotes: Vec<IRealFootnoteDefinition>, pub(crate) footnotes: Vec<IRealFootnoteDefinition>,
pub(crate) natter_publish: PublishStatus,
} }
intermediate!( intermediate!(
@ -73,7 +69,6 @@ intermediate!(
date: get_date(original.document), date: get_date(original.document),
children, children,
footnotes, footnotes,
natter_publish: get_publish_status(original.document).unwrap_or_default(),
}) })
} }
); );