Compare commits

..

16 Commits

Author SHA1 Message Date
fluxcdbot
b3929f22f3 CI: autofix rust code.
Some checks failed
clippy Build clippy has failed
format Build format has succeeded
rust-test Build rust-test has failed
build Build build has succeeded
2025-08-31 22:24:16 +00:00
Tom Alexander
bad12160ac Let chains have been stabalized.
Some checks are pending
clippy Build clippy has started
format Build format has succeeded
rust-test Build rust-test has succeeded
build Build build has succeeded
2025-08-31 18:22:06 -04:00
Tom Alexander
c43679fda9 Switch to local-path-provisioner.
Some checks failed
build Build build has started
clippy Build clippy has failed
rust-test Build rust-test has failed
format Build format has failed
2025-08-31 17:53:10 -04:00
Tom Alexander
9cc28f6f0d Merge branch 'unlisted_posts'
All checks were successful
format Build format has succeeded
clippy Build clippy has succeeded
rust-test Build rust-test has succeeded
build Build build has succeeded
2025-02-23 12:12:43 -05:00
Tom Alexander
d2256b8333 Add publish filter to blog posts and pages.
All checks were successful
format Build format has succeeded
clippy Build clippy has succeeded
rust-test Build rust-test has succeeded
2025-02-23 12:08:43 -05:00
Tom Alexander
fa8753077a Add support for unlisted posts.
All checks were successful
format Build format has succeeded
clippy Build clippy has succeeded
rust-test Build rust-test has succeeded
2025-02-23 12:02:14 -05:00
Tom Alexander
0420f58d02 Add a hover effect to the home link in the page header.
All checks were successful
format Build format has succeeded
clippy Build clippy has succeeded
rust-test Build rust-test has succeeded
build Build build has succeeded
2025-02-22 23:16:18 -05:00
Tom Alexander
0250aa106e Merge branch 'about_me'
All checks were successful
format Build format has succeeded
clippy Build clippy has succeeded
rust-test Build rust-test has succeeded
build Build build has succeeded
2025-02-22 22:54:18 -05:00
Tom Alexander
ca1c456571 Pass the nav links in the PageHeader render context.
All checks were successful
format Build format has succeeded
clippy Build clippy has succeeded
rust-test Build rust-test has succeeded
2025-02-22 22:49:59 -05:00
Tom Alexander
4403980e2e Add a me link to the nav bar. 2025-02-22 22:36:42 -05:00
Tom Alexander
dbfbce955d Merge branch 'tracing'
Some checks are pending
clippy Build clippy has started
format Build format has succeeded
rust-test Build rust-test has succeeded
build Build build has succeeded
2025-02-22 21:12:44 -05:00
Tom Alexander
2e08d2e59a Set up tracing. 2025-02-22 21:12:33 -05:00
Tom Alexander
9f14534c10 Merge branch 'source_code_highlighting'
All checks were successful
format Build format has succeeded
clippy Build clippy has succeeded
rust-test Build rust-test has succeeded
build Build build has succeeded
2025-02-22 19:56:47 -05:00
Tom Alexander
4e34ebc29e Reformat css.
All checks were successful
format Build format has succeeded
clippy Build clippy has succeeded
rust-test Build rust-test has succeeded
2025-02-22 19:45:04 -05:00
Tom Alexander
8d85d5ef79 Fix clippy.
All checks were successful
format Build format has succeeded
clippy Build clippy has succeeded
rust-test Build rust-test has succeeded
2025-02-22 19:42:24 -05:00
Tom Alexander
7d73a3c948 Clean up. 2025-02-22 19:24:05 -05:00
57 changed files with 1244 additions and 137 deletions

View File

@@ -203,7 +203,7 @@ spec:
- name: git-source - name: git-source
volumeClaimTemplate: volumeClaimTemplate:
spec: spec:
storageClassName: "nfs-client" storageClassName: "local-path"
accessModes: accessModes:
- ReadWriteOnce - ReadWriteOnce
resources: resources:

View File

@@ -345,7 +345,7 @@ spec:
- name: git-source - name: git-source
volumeClaimTemplate: volumeClaimTemplate:
spec: spec:
storageClassName: "nfs-client" storageClassName: "local-path"
accessModes: accessModes:
- ReadWriteOnce - ReadWriteOnce
resources: resources:

View File

@@ -289,7 +289,7 @@ spec:
- name: git-source - name: git-source
volumeClaimTemplate: volumeClaimTemplate:
spec: spec:
storageClassName: "nfs-client" storageClassName: "local-path"
accessModes: accessModes:
- ReadWriteOnce - ReadWriteOnce
resources: resources:

View File

@@ -279,7 +279,7 @@ spec:
- name: git-source - name: git-source
volumeClaimTemplate: volumeClaimTemplate:
spec: spec:
storageClassName: "nfs-client" storageClassName: "local-path"
accessModes: accessModes:
- ReadWriteOnce - ReadWriteOnce
resources: resources:

870
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
[package] [package]
name = "natter" name = "natter"
version = "0.0.1" version = "0.0.1"
edition = "2021" edition = "2024"
authors = ["Tom Alexander <tom@fizz.buzz>"] authors = ["Tom Alexander <tom@fizz.buzz>"]
description = "A static site generator using org source files." description = "A static site generator using org source files."
license = "0BSD" license = "0BSD"
@@ -36,6 +36,16 @@ tree-sitter-highlight = "0.25.2"
tree-sitter-nix = "0.0.2" tree-sitter-nix = "0.0.2"
tree-sitter-python = "0.23.6" tree-sitter-python = "0.23.6"
url = "2.5.0" url = "2.5.0"
tracing = { version = "0.1.37", optional = true }
tracing-opentelemetry = { version = "0.20.0", optional = true }
tracing-subscriber = { version = "0.3.17", optional = true, features = ["env-filter"] }
opentelemetry = { version = "0.20.0", optional = true, default-features = false, features = ["trace", "rt-tokio"] }
opentelemetry-otlp = { version = "0.13.0", optional = true }
opentelemetry-semantic-conventions = { version = "0.12.0", optional = true }
[features]
default = ["tracing"]
tracing = ["dep:opentelemetry", "dep:opentelemetry-otlp", "dep:opentelemetry-semantic-conventions", "dep:tracing", "dep:tracing-opentelemetry", "dep:tracing-subscriber"]
# Optimized build for any sort of release. # Optimized build for any sort of release.
[profile.release-lto] [profile.release-lto]

View File

@@ -1,4 +1,4 @@
* Things to do [4/14] * Things to do [6/17]
** 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
@@ -8,7 +8,7 @@
** TODO Support references to code block lines ** TODO Support references to code block lines
** TODO Only include text up to first heading on homepage and include a "read more" link ** TODO Only include text up to first heading on homepage and include a "read more" link
** DONE Make loading language-specific CSS files conditional on the presence of src blocks using those languages ** DONE Make loading language-specific CSS files conditional on the presence of src blocks using those languages
** TODO Set up tracing so I can use warning and such ** DONE Set up tracing so I can use warning and such
** TODO Make copying of language-specific CSS files conditional on the presence of src blocks using those languages ** TODO Make copying of language-specific CSS files conditional on the presence of src blocks using those languages
** TODO Switch to an entirely lazily-evaluated output tree ** TODO Switch to an entirely lazily-evaluated output tree
** TODO Add highlighting for languages [1/2] ** TODO Add highlighting for languages [1/2]
@@ -16,3 +16,6 @@
*** 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

@@ -9,9 +9,8 @@
--blog-post-background-color: #0a0a0a; --blog-post-background-color: #0a0a0a;
--src-font-family: --src-font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo,
ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, Consolas, "DejaVu Sans Mono", monospace;
"DejaVu Sans Mono", monospace;
--src-block-background-color: #141414; --src-block-background-color: #141414;
--src-block-border-color: #84828f; --src-block-border-color: #84828f;
@@ -23,6 +22,13 @@
--table-border-color: #6a687a; --table-border-color: #6a687a;
--table-odd-background-color: #0a0a0a; --table-odd-background-color: #0a0a0a;
--table-even-background-color: #141414; --table-even-background-color: #141414;
--header-nav-regular-font-color: var(--site-text-color);
--header-nav-regular-background-color: var(--site-background-color);
--header-nav-hover-font-color: var(--site-background-color);
--header-nav-hover-background-color: var(--site-text-color);
--header-home-regular-font-color: var(--site-text-color);
--header-home-hover-font-color: #6ccff6;
} }
@media (prefers-color-scheme: light) { @media (prefers-color-scheme: light) {
@@ -46,6 +52,13 @@
--table-border-color: #959785; --table-border-color: #959785;
--table-odd-background-color: #f5f5f5; --table-odd-background-color: #f5f5f5;
--table-even-background-color: #ebebeb; --table-even-background-color: #ebebeb;
--header-nav-regular-font-color: var(--site-text-color);
--header-nav-regular-background-color: var(--site-background-color);
--header-nav-hover-font-color: var(--site-background-color);
--header-nav-hover-background-color: var(--site-text-color);
--header-home-regular-font-color: var(--site-text-color);
--header-home-hover-font-color: #933009;
} }
} }
@@ -56,9 +69,8 @@
body { body {
color: var(--site-text-color); color: var(--site-text-color);
background-color: var(--site-background-color); background-color: var(--site-background-color);
font-family: font-family: source-sans-pro, Seravek, "Gill Sans Nova", Ubuntu, Calibri,
source-sans-pro, Seravek, "Gill Sans Nova", Ubuntu, Calibri, "DejaVu Sans", "DejaVu Sans", sans-serif;
sans-serif;
a:link, a:link,
a:visited { a:visited {
@@ -74,18 +86,57 @@ body {
} }
.page_header { .page_header {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: stretch;
width: 100%; width: 100%;
max-width: var(--main-max-width); max-width: var(--main-max-width);
border-bottom: 0.1rem solid var(--header-divider-color); border-bottom: 0.1rem solid var(--header-divider-color);
.home_link { .home_link {
display: block;
font-size: 2rem; font-size: 2rem;
font-weight: 600; font-weight: 600;
text-decoration: none; text-decoration: none;
color: var(--header-home-regular-font-color);
transition-property: color;
transition-duration: 0.1s;
transition-timing-function: ease-out;
&:hover {
color: var(--header-home-hover-font-color) !important;
}
&:link, &:link,
&:visited { &:visited {
color: var(--site-text-color); color: inherit;
}
}
.header_nav_bar {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: end;
align-items: stretch;
column-gap: 1rem;
.nav_link {
display: flex;
flex-direction: column;
justify-content: space-around;
color: var(--header-nav-regular-font-color);
background: var(--header-nav-regular-background-color);
padding: 0 0.5rem;
transition-property: background, color;
transition-duration: 0.1s;
transition-timing-function: ease-out;
&:hover {
color: var(--header-nav-hover-font-color);
background: var(--header-nav-hover-background-color);
}
} }
} }
} }

View File

@@ -1,4 +1,9 @@
<header class="page_header"> <header class="page_header">
<a class="home_link" href="{.home_link}">{.website_title}</a> <a class="home_link" href="{.home_link}">{.website_title}</a>
{! TODO: Additional links? Probably using the nav semantic element. !} {! TODO: Additional links? Probably using the nav semantic element. !}
<nav class="header_nav_bar">
{#.nav_links}
<a class="nav_link" href="{.url}"><div>{.text}</div></a>
{/.nav_links}
</nav>
</header> </header>

View File

@@ -1,8 +1,8 @@
use std::ffi::OsStr; use std::ffi::OsStr;
use std::path::PathBuf; use std::path::PathBuf;
use include_dir::include_dir;
use include_dir::Dir; use include_dir::Dir;
use include_dir::include_dir;
use tokio::fs::DirEntry; use tokio::fs::DirEntry;
use tokio::task::JoinHandle; use tokio::task::JoinHandle;
@@ -15,14 +15,15 @@ use crate::context::RenderBlogStreamInput;
use crate::context::RenderContext; use crate::context::RenderContext;
use crate::context::RenderPage; use crate::context::RenderPage;
use crate::error::CustomError; use crate::error::CustomError;
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::intermediate::get_web_path;
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::WalkAction; use crate::walk_fs::WalkAction;
use crate::walk_fs::WalkFsFilterResult; use crate::walk_fs::WalkFsFilterResult;
use crate::walk_fs::walk_fs;
use super::stylesheet::Stylesheet; use super::stylesheet::Stylesheet;
@@ -84,7 +85,11 @@ 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 { for page in self.pages.iter().filter(|page| match page.natter_publish {
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()));
@@ -115,7 +120,17 @@ 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 { for blog_post in self.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 => 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
@@ -155,7 +170,21 @@ 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.blog_posts.iter().collect(); let mut sorted_blog_posts: Vec<_> = self
.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

@@ -8,17 +8,17 @@ use crate::cli::parameters::BuildArgs;
use crate::command::build::render::SiteRenderer; use crate::command::build::render::SiteRenderer;
use crate::config::Config; use crate::config::Config;
use crate::error::CustomError; use crate::error::CustomError;
use crate::intermediate::get_org_files;
use crate::intermediate::BlogPost; use crate::intermediate::BlogPost;
use crate::intermediate::IPage; use crate::intermediate::IPage;
use crate::intermediate::IntermediateContext; use crate::intermediate::IntermediateContext;
use crate::intermediate::PageInput; use crate::intermediate::PageInput;
use crate::intermediate::Registry; use crate::intermediate::Registry;
use crate::walk_fs::walk_fs; use crate::intermediate::get_org_files;
use crate::walk_fs::WalkAction; use crate::walk_fs::WalkAction;
use crate::walk_fs::WalkFsFilterResult; use crate::walk_fs::WalkFsFilterResult;
use include_dir::include_dir; use crate::walk_fs::walk_fs;
use include_dir::Dir; use include_dir::Dir;
use include_dir::include_dir;
use tokio::fs::DirEntry; use tokio::fs::DirEntry;
static DEFAULT_STYLESHEETS: Dir = static DEFAULT_STYLESHEETS: Dir =

View File

@@ -3,6 +3,8 @@ use serde::Serialize;
use crate::error::CustomError; use crate::error::CustomError;
use crate::intermediate::IAstNode; use crate::intermediate::IAstNode;
use super::RenderHeading;
use super::RenderSection;
use super::angle_link::RenderAngleLink; use super::angle_link::RenderAngleLink;
use super::babel_call::RenderBabelCall; use super::babel_call::RenderBabelCall;
use super::bold::RenderBold; use super::bold::RenderBold;
@@ -55,8 +57,6 @@ use super::timestamp::RenderTimestamp;
use super::underline::RenderUnderline; use super::underline::RenderUnderline;
use super::verbatim::RenderVerbatim; use super::verbatim::RenderVerbatim;
use super::verse_block::RenderVerseBlock; use super::verse_block::RenderVerseBlock;
use super::RenderHeading;
use super::RenderSection;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(untagged)] #[serde(untagged)]

View File

@@ -5,15 +5,15 @@ use serde::Serialize;
use super::render_context::RenderContext; use super::render_context::RenderContext;
use crate::context::macros::push_file; use crate::context::macros::push_file;
use crate::error::CustomError; use crate::error::CustomError;
use crate::intermediate::get_web_path;
use crate::intermediate::BlogPost; use crate::intermediate::BlogPost;
use crate::intermediate::BlogPostPage; use crate::intermediate::BlogPostPage;
use crate::intermediate::get_web_path;
use super::footnote_definition::RenderRealFootnoteDefinition;
use super::macros::render;
use super::GlobalSettings; use super::GlobalSettings;
use super::PageHeader; use super::PageHeader;
use super::RenderDocumentElement; use super::RenderDocumentElement;
use super::footnote_definition::RenderRealFootnoteDefinition;
use super::macros::render;
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct RenderBlogPostPageInput<'a> { pub(crate) struct RenderBlogPostPageInput<'a> {
@@ -61,6 +61,12 @@ render!(
render_context.output_file, render_context.output_file,
"", "",
)?), )?),
Some(get_web_path(
render_context.config,
render_context.output_root_directory,
render_context.output_file,
"about_me",
)?),
); );
let link_to_blog_post = get_web_path( let link_to_blog_post = get_web_path(
render_context.config, render_context.config,

View File

@@ -4,12 +4,12 @@ use serde::Serialize;
use super::macros::render; use super::macros::render;
use super::render_context::RenderContext; use super::render_context::RenderContext;
use crate::context::macros::push_file;
use crate::context::RenderDocumentElement; use crate::context::RenderDocumentElement;
use crate::context::RenderRealFootnoteDefinition; use crate::context::RenderRealFootnoteDefinition;
use crate::context::macros::push_file;
use crate::error::CustomError; use crate::error::CustomError;
use crate::intermediate::get_web_path;
use crate::intermediate::BlogPost; use crate::intermediate::BlogPost;
use crate::intermediate::get_web_path;
use super::GlobalSettings; use super::GlobalSettings;
use super::PageHeader; use super::PageHeader;
@@ -59,6 +59,12 @@ render!(
render_context.output_file, render_context.output_file,
"", "",
)?), )?),
Some(get_web_path(
render_context.config,
render_context.output_root_directory,
render_context.output_file,
"about_me",
)?),
); );
let children = original let children = original

View File

@@ -3,9 +3,9 @@ use serde::Serialize;
use crate::error::CustomError; use crate::error::CustomError;
use crate::intermediate::IBold; use crate::intermediate::IBold;
use super::RenderObject;
use super::macros::render; use super::macros::render;
use super::render_context::RenderContext; use super::render_context::RenderContext;
use super::RenderObject;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "type")] #[serde(tag = "type")]

View File

@@ -41,7 +41,7 @@ impl Dependency {
} }
Ok(()) Ok(())
} }
Dependency::CssFile { name } => { Dependency::CssFile { name: _ } => {
// We don't do anything because the CSS files are already copied into the output from natter's default environment. // We don't do anything because the CSS files are already copied into the output from natter's default environment.
// TODO: When we add support for CSS outside the default environment, we should add support for dynamically picking which ones to copy here. // TODO: When we add support for CSS outside the default environment, we should add support for dynamically picking which ones to copy here.
Ok(()) Ok(())

View File

@@ -4,9 +4,9 @@ use super::render_context::RenderContext;
use crate::error::CustomError; use crate::error::CustomError;
use crate::intermediate::IDocumentElement; use crate::intermediate::IDocumentElement;
use super::macros::render;
use super::RenderHeading; use super::RenderHeading;
use super::RenderSection; use super::RenderSection;
use super::macros::render;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(untagged)] #[serde(untagged)]

View File

@@ -4,9 +4,9 @@ use super::render_context::RenderContext;
use crate::error::CustomError; use crate::error::CustomError;
use crate::intermediate::IHeading; use crate::intermediate::IHeading;
use super::macros::render;
use super::RenderDocumentElement; use super::RenderDocumentElement;
use super::RenderObject; use super::RenderObject;
use super::macros::render;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "type")] #[serde(tag = "type")]

View File

@@ -4,8 +4,8 @@ use super::render_context::RenderContext;
use crate::error::CustomError; use crate::error::CustomError;
use crate::intermediate::IItalic; use crate::intermediate::IItalic;
use super::macros::render;
use super::RenderObject; use super::RenderObject;
use super::macros::render;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "type")] #[serde(tag = "type")]

View File

@@ -1,15 +1,15 @@
use std::collections::HashSet; use std::collections::HashSet;
use super::footnote_definition::RenderRealFootnoteDefinition;
use super::macros::render;
use super::render_context::RenderContext;
use super::GlobalSettings; use super::GlobalSettings;
use super::PageHeader; use super::PageHeader;
use super::RenderDocumentElement; use super::RenderDocumentElement;
use super::footnote_definition::RenderRealFootnoteDefinition;
use super::macros::render;
use super::render_context::RenderContext;
use crate::context::macros::push_file; use crate::context::macros::push_file;
use crate::error::CustomError; use crate::error::CustomError;
use crate::intermediate::get_web_path;
use crate::intermediate::IPage; use crate::intermediate::IPage;
use crate::intermediate::get_web_path;
use serde::Serialize; use serde::Serialize;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
@@ -40,6 +40,12 @@ render!(RenderPage, IPage, original, render_context, {
render_context.output_file, render_context.output_file,
"", "",
)?), )?),
Some(get_web_path(
render_context.config,
render_context.output_root_directory,
render_context.output_file,
"about_me",
)?),
); );
let link_to_blog_post = get_web_path( let link_to_blog_post = get_web_path(
render_context.config, render_context.config,

View File

@@ -7,13 +7,35 @@ use serde::Serialize;
pub(crate) struct PageHeader { pub(crate) struct PageHeader {
website_title: Option<String>, website_title: Option<String>,
home_link: Option<String>, home_link: Option<String>,
nav_links: Vec<NavLink>,
}
/// A link in the top-right of the page.
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "nav_link")]
pub(crate) struct NavLink {
text: Option<String>,
url: Option<String>,
} }
impl PageHeader { impl PageHeader {
pub(crate) fn new(website_title: Option<String>, home_link: Option<String>) -> PageHeader { pub(crate) fn new(
website_title: Option<String>,
home_link: Option<String>,
about_me_link: Option<String>,
) -> PageHeader {
PageHeader { PageHeader {
website_title, website_title,
home_link, home_link,
nav_links: about_me_link
.map(|url| {
vec![NavLink {
text: Some("About Me".to_owned()),
url: Some(url),
}]
})
.unwrap_or_default(),
} }
} }
} }

View File

@@ -4,8 +4,8 @@ use super::render_context::RenderContext;
use crate::error::CustomError; use crate::error::CustomError;
use crate::intermediate::IParagraph; use crate::intermediate::IParagraph;
use super::macros::render;
use super::RenderObject; use super::RenderObject;
use super::macros::render;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "type")] #[serde(tag = "type")]

View File

@@ -4,9 +4,9 @@ use super::render_context::RenderContext;
use crate::error::CustomError; use crate::error::CustomError;
use crate::intermediate::IPlainListItem; use crate::intermediate::IPlainListItem;
use super::macros::render;
use super::RenderElement; use super::RenderElement;
use super::RenderObject; use super::RenderObject;
use super::macros::render;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "type")] #[serde(tag = "type")]

View File

@@ -4,8 +4,8 @@ use super::render_context::RenderContext;
use crate::error::CustomError; use crate::error::CustomError;
use crate::intermediate::IPlainListSimpleItem; use crate::intermediate::IPlainListSimpleItem;
use super::macros::render;
use super::RenderObject; use super::RenderObject;
use super::macros::render;
/// Special case for list items with only paragraphs and sublists as their children. In those cases, the paragraph tags are omitted. This is equivalent to a Paragraph but in a different struct to have a different type tag. /// Special case for list items with only paragraphs and sublists as their children. In those cases, the paragraph tags are omitted. This is equivalent to a Paragraph but in a different struct to have a different type tag.
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]

View File

@@ -4,8 +4,8 @@ use super::render_context::RenderContext;
use crate::error::CustomError; use crate::error::CustomError;
use crate::intermediate::IQuoteBlock; use crate::intermediate::IQuoteBlock;
use super::macros::render;
use super::RenderElement; use super::RenderElement;
use super::macros::render;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "type")] #[serde(tag = "type")]

View File

@@ -5,8 +5,8 @@ use crate::error::CustomError;
use crate::intermediate::IRegularLink; use crate::intermediate::IRegularLink;
use crate::intermediate::LinkTarget; use crate::intermediate::LinkTarget;
use super::macros::render;
use super::RenderObject; use super::RenderObject;
use super::macros::render;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "type")] #[serde(tag = "type")]

View File

@@ -4,8 +4,8 @@ use super::render_context::RenderContext;
use crate::error::CustomError; use crate::error::CustomError;
use crate::intermediate::ISection; use crate::intermediate::ISection;
use super::macros::render;
use super::RenderElement; use super::RenderElement;
use super::macros::render;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "type")] #[serde(tag = "type")]

View File

@@ -55,7 +55,7 @@ render!(RenderSrcBlock, ISrcBlock, original, render_context, {
RenderSrcLine { children } RenderSrcLine { children }
}) })
.collect(); .collect();
match original.language.as_ref().map(String::as_str) { match original.language.as_deref() {
Some("bash") => { Some("bash") => {
render_context render_context
.dependency_manager .dependency_manager

View File

@@ -4,8 +4,8 @@ use super::render_context::RenderContext;
use crate::error::CustomError; use crate::error::CustomError;
use crate::intermediate::IStrikeThrough; use crate::intermediate::IStrikeThrough;
use super::macros::render;
use super::RenderObject; use super::RenderObject;
use super::macros::render;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "type")] #[serde(tag = "type")]

View File

@@ -4,8 +4,8 @@ use super::render_context::RenderContext;
use crate::error::CustomError; use crate::error::CustomError;
use crate::intermediate::ITableCell; use crate::intermediate::ITableCell;
use super::macros::render;
use super::RenderObject; use super::RenderObject;
use super::macros::render;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "type")] #[serde(tag = "type")]

View File

@@ -4,8 +4,8 @@ use super::render_context::RenderContext;
use crate::error::CustomError; use crate::error::CustomError;
use crate::intermediate::IUnderline; use crate::intermediate::IUnderline;
use super::macros::render;
use super::RenderObject; use super::RenderObject;
use super::macros::render;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "type")] #[serde(tag = "type")]

88
src/init_tracing.rs Normal file
View File

@@ -0,0 +1,88 @@
#[cfg(feature = "tracing")]
use opentelemetry_otlp::WithExportConfig;
#[cfg(feature = "tracing")]
use tracing::warn;
#[cfg(feature = "tracing")]
use tracing_subscriber::fmt;
#[cfg(feature = "tracing")]
use tracing_subscriber::prelude::__tracing_subscriber_SubscriberExt;
#[cfg(feature = "tracing")]
use tracing_subscriber::util::SubscriberInitExt;
const SERVICE_NAME: &str = "natter";
// Despite the obvious verbosity that fully-qualifying everything causes, in these functions I am fully-qualifying everything relating to tracing. This is because the tracing feature involves multiple libraries working together and so I think it is beneficial to see which libraries contribute which bits.
#[cfg(feature = "tracing")]
pub(crate) fn init_telemetry() -> Result<(), Box<dyn std::error::Error>> {
let log_to_console = fmt::layer();
let subscriber = tracing_subscriber::Registry::default();
let level_filter_layer = tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or(tracing_subscriber::EnvFilter::new("WARN"));
// by default it will hit http://localhost:4317 with a gRPC payload
// TODO: I think the endpoint can be controlled by the OTEL_EXPORTER_OTLP_TRACES_ENDPOINT env variable instead of hard-coded into this code base. Regardless, I am the only developer right now so I am not too concerned.
let exporter = opentelemetry_otlp::new_exporter()
.tonic()
// Using "localhost" is broken inside the docker container when tracing
.with_endpoint("http://127.0.0.1:4317/v1/traces");
let tracer = opentelemetry_otlp::new_pipeline()
.tracing()
.with_exporter(exporter)
.with_trace_config(opentelemetry::sdk::trace::config().with_resource(
opentelemetry::sdk::Resource::new(vec![opentelemetry::KeyValue::new(
opentelemetry_semantic_conventions::resource::SERVICE_NAME,
SERVICE_NAME.to_string(),
)]),
))
// If I do install_batch then 1K+ spans will get orphaned off into their own trace and I get the error message "OpenTelemetry trace error occurred. cannot send message to batch processor as the channel is closed"
//
// If I do install_simple then it only creates 1 trace (which is good!) but my console gets spammed with this concerning log message that makes me think it might be dropping the extra spans on the floor: "OpenTelemetry trace error occurred. Exporter otlp encountered the following error(s): the grpc server returns error (Unknown error): , detailed error message: Service was not ready: transport error"
//
// I suspect it is related to this bug: https://github.com/open-telemetry/opentelemetry-rust/issues/888
//
// .install_simple()
.install_batch(opentelemetry::runtime::Tokio);
let tracing_layer = tracer.map(|tracer| tracing_opentelemetry::layer().with_tracer(tracer));
opentelemetry::global::set_text_map_propagator(
opentelemetry::sdk::propagation::TraceContextPropagator::new(),
);
match tracing_layer {
Ok(tracing_layer) => {
subscriber
.with(level_filter_layer)
.with(tracing_layer)
.with(log_to_console)
.try_init()?;
}
Err(e) => {
subscriber
.with(level_filter_layer)
.with(fmt::layer())
.try_init()?;
warn!("Failed initialize OpenTelemetry tracing: {}", e);
}
};
Ok(())
}
#[cfg(feature = "tracing")]
pub(crate) fn shutdown_telemetry() -> Result<(), Box<dyn std::error::Error>> {
opentelemetry::global::shutdown_tracer_provider();
Ok(())
}
#[cfg(not(feature = "tracing"))]
pub(crate) fn init_telemetry() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}
#[cfg(not(feature = "tracing"))]
pub(crate) fn shutdown_telemetry() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}

View File

@@ -1,28 +1,3 @@
use super::angle_link::IAngleLink;
use super::bold::IBold;
use super::citation::ICitation;
use super::citation_reference::ICitationReference;
use super::code::ICode;
use super::comment::IComment;
use super::entity::IEntity;
use super::export_snippet::IExportSnippet;
use super::footnote_reference::IFootnoteReference;
use super::inline_babel_call::IInlineBabelCall;
use super::inline_source_block::IInlineSourceBlock;
use super::italic::IItalic;
use super::keyword::IKeyword;
use super::latex_fragment::ILatexFragment;
use super::line_break::ILineBreak;
use super::org_macro::IOrgMacro;
use super::plain_link::IPlainLink;
use super::plain_text::IPlainText;
use super::radio_link::IRadioLink;
use super::radio_target::IRadioTarget;
use super::regular_link::IRegularLink;
use super::statistics_cookie::IStatisticsCookie;
use super::strike_through::IStrikeThrough;
use super::subscript::ISubscript;
use super::superscript::ISuperscript;
use super::IBabelCall; use super::IBabelCall;
use super::ICenterBlock; use super::ICenterBlock;
use super::IClock; use super::IClock;
@@ -52,6 +27,31 @@ use super::IUnderline;
use super::IVerbatim; use super::IVerbatim;
use super::IVerseBlock; use super::IVerseBlock;
use super::IntermediateContext; use super::IntermediateContext;
use super::angle_link::IAngleLink;
use super::bold::IBold;
use super::citation::ICitation;
use super::citation_reference::ICitationReference;
use super::code::ICode;
use super::comment::IComment;
use super::entity::IEntity;
use super::export_snippet::IExportSnippet;
use super::footnote_reference::IFootnoteReference;
use super::inline_babel_call::IInlineBabelCall;
use super::inline_source_block::IInlineSourceBlock;
use super::italic::IItalic;
use super::keyword::IKeyword;
use super::latex_fragment::ILatexFragment;
use super::line_break::ILineBreak;
use super::org_macro::IOrgMacro;
use super::plain_link::IPlainLink;
use super::plain_text::IPlainText;
use super::radio_link::IRadioLink;
use super::radio_target::IRadioTarget;
use super::regular_link::IRegularLink;
use super::statistics_cookie::IStatisticsCookie;
use super::strike_through::IStrikeThrough;
use super::subscript::ISubscript;
use super::superscript::ISuperscript;
use crate::error::CustomError; use crate::error::CustomError;
use futures::future::{BoxFuture, FutureExt}; use futures::future::{BoxFuture, FutureExt};

View File

@@ -7,12 +7,12 @@ use tokio::fs::DirEntry;
use tokio::task::JoinHandle; use tokio::task::JoinHandle;
use crate::error::CustomError; use crate::error::CustomError;
use crate::intermediate::IntermediateContext;
use crate::intermediate::blog_post_page::BlogPostPageInput; use crate::intermediate::blog_post_page::BlogPostPageInput;
use crate::intermediate::registry::Registry; use crate::intermediate::registry::Registry;
use crate::intermediate::IntermediateContext;
use crate::walk_fs::walk_fs;
use crate::walk_fs::WalkAction; use crate::walk_fs::WalkAction;
use crate::walk_fs::WalkFsFilterResult; use crate::walk_fs::WalkFsFilterResult;
use crate::walk_fs::walk_fs;
use super::BlogPostPage; use super::BlogPostPage;

View File

@@ -4,10 +4,10 @@ use crate::error::CustomError;
use super::footnote_definition::IRealFootnoteDefinition; use super::footnote_definition::IRealFootnoteDefinition;
use super::macros::intermediate;
use super::IDocumentElement; use super::IDocumentElement;
use super::IHeading; use super::IHeading;
use super::ISection; use super::ISection;
use super::macros::intermediate;
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct BlogPostPageInput<'b, 'parse> { pub(crate) struct BlogPostPageInput<'b, 'parse> {
@@ -48,6 +48,16 @@ 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!(
@@ -93,6 +103,7 @@ 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(),
}) })
} }
); );
@@ -129,3 +140,25 @@ 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

@@ -1,7 +1,7 @@
use organic::types::StandardProperties; use organic::types::StandardProperties;
use super::macros::intermediate;
use super::IObject; use super::IObject;
use super::macros::intermediate;
use crate::error::CustomError; use crate::error::CustomError;

View File

@@ -1,7 +1,7 @@
use super::IPlainListSimpleItem;
use super::comment::IComment; use super::comment::IComment;
use super::keyword::IKeyword; use super::keyword::IKeyword;
use super::macros::iselector; use super::macros::iselector;
use super::IPlainListSimpleItem;
use super::IBabelCall; use super::IBabelCall;
use super::ICenterBlock; use super::ICenterBlock;

View File

@@ -1,7 +1,7 @@
use super::macros::intermediate;
use super::registry::register_footnote_definition;
use super::IAstNode; use super::IAstNode;
use super::IntermediateContext; use super::IntermediateContext;
use super::macros::intermediate;
use super::registry::register_footnote_definition;
use crate::error::CustomError; use crate::error::CustomError;
use organic::types::StandardProperties; use organic::types::StandardProperties;
@@ -32,6 +32,7 @@ pub(crate) struct IRealFootnoteDefinition {
} }
impl IRealFootnoteDefinition { impl IRealFootnoteDefinition {
#[allow(clippy::needless_lifetimes)]
pub(crate) async fn new<'orig, 'parse>( pub(crate) async fn new<'orig, 'parse>(
_intermediate_context: IntermediateContext<'orig, 'parse>, _intermediate_context: IntermediateContext<'orig, 'parse>,
footnote_id: usize, footnote_id: usize,

View File

@@ -1,6 +1,6 @@
use super::macros::intermediate;
use super::IDocumentElement; use super::IDocumentElement;
use super::IObject; use super::IObject;
use super::macros::intermediate;
use crate::error::CustomError; use crate::error::CustomError;
use organic::types::StandardProperties; use organic::types::StandardProperties;

View File

@@ -1,7 +1,7 @@
use organic::types::StandardProperties; use organic::types::StandardProperties;
use super::macros::intermediate;
use super::IObject; use super::IObject;
use super::macros::intermediate;
use crate::error::CustomError; use crate::error::CustomError;

View File

@@ -9,6 +9,7 @@ macro_rules! inoop {
} }
impl $istruct { impl $istruct {
#[allow(clippy::extra_unused_lifetimes)]
pub(crate) async fn new<'reg, 'orig, 'parse>( pub(crate) async fn new<'reg, 'orig, 'parse>(
_intermediate_context: crate::intermediate::IntermediateContext<'orig, 'parse>, _intermediate_context: crate::intermediate::IntermediateContext<'orig, 'parse>,
original: &'orig organic::types::$pstruct<'parse>, original: &'orig organic::types::$pstruct<'parse>,

View File

@@ -71,9 +71,10 @@ mod verse_block;
pub(crate) use angle_link::IAngleLink; pub(crate) use angle_link::IAngleLink;
pub(crate) use ast_node::IAstNode; pub(crate) use ast_node::IAstNode;
pub(crate) use babel_call::IBabelCall; pub(crate) use babel_call::IBabelCall;
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::get_org_files;
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

@@ -21,6 +21,7 @@ use super::plain_text::IPlainText;
use super::radio_link::IRadioLink; use super::radio_link::IRadioLink;
use super::radio_target::IRadioTarget; use super::radio_target::IRadioTarget;
use super::ITarget;
use super::regular_link::IRegularLink; use super::regular_link::IRegularLink;
use super::statistics_cookie::IStatisticsCookie; use super::statistics_cookie::IStatisticsCookie;
use super::strike_through::IStrikeThrough; use super::strike_through::IStrikeThrough;
@@ -29,7 +30,6 @@ use super::superscript::ISuperscript;
use super::timestamp::ITimestamp; use super::timestamp::ITimestamp;
use super::underline::IUnderline; use super::underline::IUnderline;
use super::verbatim::IVerbatim; use super::verbatim::IVerbatim;
use super::ITarget;
use futures::future::{BoxFuture, FutureExt}; use futures::future::{BoxFuture, FutureExt};
#[derive(Debug, Clone)] #[derive(Debug, Clone)]

View File

@@ -1,10 +1,12 @@
use super::blog_post_page::get_date;
use super::blog_post_page::get_title;
use super::footnote_definition::IRealFootnoteDefinition;
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 super::blog_post_page::get_date;
use super::blog_post_page::get_publish_status;
use super::blog_post_page::get_title;
use super::footnote_definition::IRealFootnoteDefinition;
use super::macros::intermediate;
use crate::error::CustomError; use crate::error::CustomError;
use std::path::PathBuf; use std::path::PathBuf;
@@ -24,6 +26,8 @@ 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!(
@@ -69,6 +73,7 @@ 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(),
}) })
} }
); );

View File

@@ -1,7 +1,5 @@
use std::any::Any;
use super::macros::intermediate;
use super::IObject; use super::IObject;
use super::macros::intermediate;
use crate::error::CustomError; use crate::error::CustomError;
use organic::types::StandardProperties; use organic::types::StandardProperties;
@@ -33,6 +31,7 @@ intermediate!(
); );
impl IParagraph { impl IParagraph {
#[allow(clippy::needless_lifetimes)]
pub(crate) async fn artificial<'orig, 'parse>( pub(crate) async fn artificial<'orig, 'parse>(
_intermediate_context: crate::intermediate::IntermediateContext<'orig, 'parse>, _intermediate_context: crate::intermediate::IntermediateContext<'orig, 'parse>,
children: Vec<IObject>, children: Vec<IObject>,
@@ -52,19 +51,19 @@ impl IParagraph {
.children .children
.iter() .iter()
.filter(|c| match c { .filter(|c| match c {
IObject::RegularLink(iregular_link) => match &iregular_link.target { IObject::RegularLink(iregular_link) => matches!(
super::LinkTarget::Image { src, alt } => true, &iregular_link.target,
_ => false, super::LinkTarget::Image { src: _, alt: _ }
}, ),
_ => false, _ => false,
}) })
.count(); .count();
num_images == 1 num_images == 1
&& self.children.iter().all(|c| match c { && self.children.iter().all(|c| match c {
IObject::RegularLink(iregular_link) => match &iregular_link.target { IObject::RegularLink(iregular_link) => matches!(
super::LinkTarget::Image { src, alt } => true, &iregular_link.target,
_ => false, super::LinkTarget::Image { src: _, alt: _ }
}, ),
IObject::PlainText(iplain_text) => { IObject::PlainText(iplain_text) => {
iplain_text.source.chars().all(|c| c.is_ascii_whitespace()) iplain_text.source.chars().all(|c| c.is_ascii_whitespace())
} }

View File

@@ -1,5 +1,5 @@
use super::macros::intermediate;
use super::IPlainListItem; use super::IPlainListItem;
use super::macros::intermediate;
use crate::error::CustomError; use crate::error::CustomError;
use organic::types::StandardProperties; use organic::types::StandardProperties;

View File

@@ -1,5 +1,5 @@
use super::macros::intermediate;
use super::IPlainListSimpleItem; use super::IPlainListSimpleItem;
use super::macros::intermediate;
use super::IElement; use super::IElement;
use super::IObject; use super::IObject;

View File

@@ -1,5 +1,5 @@
use super::macros::intermediate;
use super::IObject; use super::IObject;
use super::macros::intermediate;
use crate::error::CustomError; use crate::error::CustomError;
use organic::types::StandardProperties; use organic::types::StandardProperties;

View File

@@ -1,5 +1,5 @@
use super::macros::intermediate;
use super::IElement; use super::IElement;
use super::macros::intermediate;
use crate::error::CustomError; use crate::error::CustomError;
use organic::types::StandardProperties; use organic::types::StandardProperties;

View File

@@ -3,11 +3,11 @@ use organic::types::Element;
use organic::types::Object; use organic::types::Object;
use std::collections::HashMap; use std::collections::HashMap;
use super::ast_node::IAstNode;
use super::ast_node::IntoIAstNode;
use super::IObject; use super::IObject;
use super::IParagraph; use super::IParagraph;
use super::IntermediateContext; use super::IntermediateContext;
use super::ast_node::IAstNode;
use super::ast_node::IntoIAstNode;
type IdCounter = u16; type IdCounter = u16;
@@ -180,6 +180,7 @@ async fn convert_definition_contents<'orig, 'parse>(
} }
/// Take a footnote definition that has not yet received a reference and move it into the active footnotes. /// Take a footnote definition that has not yet received a reference and move it into the active footnotes.
#[allow(clippy::needless_lifetimes)]
pub(crate) async fn promote_footnote_definition<'orig, 'parse>( pub(crate) async fn promote_footnote_definition<'orig, 'parse>(
intermediate_context: IntermediateContext<'orig, 'parse>, intermediate_context: IntermediateContext<'orig, 'parse>,
label: &'parse str, label: &'parse str,

View File

@@ -5,9 +5,9 @@ use organic::types::LinkType;
use organic::types::StandardProperties; use organic::types::StandardProperties;
use url::Url; use url::Url;
use super::IntermediateContext;
use super::get_web_path; use super::get_web_path;
use super::macros::intermediate; use super::macros::intermediate;
use super::IntermediateContext;
use super::IObject; use super::IObject;
use crate::context::RenderContext; use crate::context::RenderContext;
@@ -186,7 +186,7 @@ impl LinkTarget {
if path.is_absolute() { if path.is_absolute() {
return Ok(format!("file://{}", input)); return Ok(format!("file://{}", input));
} }
return Ok(input.into_owned()); Ok(input.into_owned())
} }
/// Get file name from the last segment of an image path. /// Get file name from the last segment of an image path.
@@ -199,7 +199,7 @@ impl LinkTarget {
let path = Path::new(input.as_ref()); let path = Path::new(input.as_ref());
match path match path
.components() .components()
.last() .next_back()
.ok_or("Images should have at least one component in their path.")? .ok_or("Images should have at least one component in their path.")?
{ {
std::path::Component::Prefix(_) => { std::path::Component::Prefix(_) => {
@@ -209,9 +209,7 @@ impl LinkTarget {
std::path::Component::RootDir std::path::Component::RootDir
| std::path::Component::CurDir | std::path::Component::CurDir
| std::path::Component::ParentDir => { | std::path::Component::ParentDir => {
return Err( Err("Final component of an image path should be a normal component.".into())
"Final component of an image path should be a normal component.".into(),
);
} }
std::path::Component::Normal(file_name) => Ok(file_name std::path::Component::Normal(file_name) => Ok(file_name
.to_str() .to_str()
@@ -236,6 +234,7 @@ mod tests {
let registry = Registry::new(); let registry = Registry::new();
let registry = Arc::new(Mutex::new(registry)); let registry = Arc::new(Mutex::new(registry));
let intermediate_context = IntermediateContext::new(registry)?; let intermediate_context = IntermediateContext::new(registry)?;
#[allow(clippy::single_element_loop)]
for (inp, typ) in [( for (inp, typ) in [(
"https://test.example/foo", "https://test.example/foo",
LinkType::Protocol(Cow::from("https")), LinkType::Protocol(Cow::from("https")),

View File

@@ -1,5 +1,5 @@
use super::macros::intermediate;
use super::IElement; use super::IElement;
use super::macros::intermediate;
use crate::error::CustomError; use crate::error::CustomError;
use organic::types::StandardProperties; use organic::types::StandardProperties;

View File

@@ -1,10 +1,8 @@
use std::borrow::Borrow; use std::borrow::Borrow;
use std::borrow::Cow;
use super::macros::intermediate; use super::macros::intermediate;
use crate::error::CustomError; use crate::error::CustomError;
use organic::types::StandardProperties; use organic::types::StandardProperties;
use tree_sitter_highlight::Highlight;
use tree_sitter_highlight::HighlightConfiguration; use tree_sitter_highlight::HighlightConfiguration;
use tree_sitter_highlight::HighlightEvent; use tree_sitter_highlight::HighlightEvent;
use tree_sitter_highlight::Highlighter; use tree_sitter_highlight::Highlighter;
@@ -79,7 +77,7 @@ intermediate!(
.collect(); .collect();
let language = original.language.map(str::to_owned); let language = original.language.map(str::to_owned);
match language.as_ref().map(String::as_str) { match language.as_deref() {
Some(lang @ "bash") => { Some(lang @ "bash") => {
let highlighted = highlight_bash(&lines); let highlighted = highlight_bash(&lines);
if let Ok(highlighted) = highlighted { if let Ok(highlighted) = highlighted {
@@ -153,7 +151,7 @@ where
std::string::String: for<'a> From<&'a L>, std::string::String: for<'a> From<&'a L>,
{ {
Ok(lines Ok(lines
.into_iter() .iter()
.map(|l| { .map(|l| {
let mut line = ISrcLine::new(); let mut line = ISrcLine::new();
line.children.push(ISrcSegment::RawText(l.into())); line.children.push(ISrcSegment::RawText(l.into()));

View File

@@ -1,7 +1,7 @@
use organic::types::StandardProperties; use organic::types::StandardProperties;
use super::macros::intermediate;
use super::IObject; use super::IObject;
use super::macros::intermediate;
use crate::error::CustomError; use crate::error::CustomError;

View File

@@ -1,4 +1,3 @@
use super::macros::inoop;
use super::macros::intermediate; use super::macros::intermediate;
use super::util::coalesce_whitespace; use super::util::coalesce_whitespace;
use crate::error::CustomError; use crate::error::CustomError;

View File

@@ -1,7 +1,7 @@
use organic::types::StandardProperties; use organic::types::StandardProperties;
use super::macros::intermediate;
use super::IObject; use super::IObject;
use super::macros::intermediate;
use crate::error::CustomError; use crate::error::CustomError;

View File

@@ -1,4 +1,3 @@
#![feature(let_chains)]
use std::process::ExitCode; use std::process::ExitCode;
use clap::Parser; use clap::Parser;
@@ -8,11 +7,14 @@ use self::cli::parameters::Commands;
use self::command::build::build_site; use self::command::build::build_site;
use self::command::init::init_natter_folder; use self::command::init::init_natter_folder;
use self::error::CustomError; use self::error::CustomError;
use self::init_tracing::init_telemetry;
use self::init_tracing::shutdown_telemetry;
mod cli; mod cli;
mod command; mod command;
mod config; mod config;
mod context; mod context;
mod error; mod error;
mod init_tracing;
mod intermediate; mod intermediate;
mod render; mod render;
mod walk_fs; mod walk_fs;
@@ -23,6 +25,7 @@ fn main() -> Result<ExitCode, CustomError> {
} }
async fn main_body() -> Result<ExitCode, CustomError> { async fn main_body() -> Result<ExitCode, CustomError> {
init_telemetry().expect("Telemetry should initialize successfully.");
let args = Cli::parse(); let args = Cli::parse();
match args.command { match args.command {
Commands::Init(args) => { Commands::Init(args) => {
@@ -32,5 +35,6 @@ async fn main_body() -> Result<ExitCode, CustomError> {
build_site(args).await?; build_site(args).await?;
} }
}; };
shutdown_telemetry().expect("Telemetry should shutdown successfully.");
Ok(ExitCode::SUCCESS) Ok(ExitCode::SUCCESS)
} }