Compare commits
2 commits
0663b7d4d5
...
f7ac4995ef
Author | SHA1 | Date | |
---|---|---|---|
f7ac4995ef | |||
bf6a7ade5a |
7 changed files with 739 additions and 704 deletions
1378
Cargo.lock
generated
1378
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
13
Cargo.toml
13
Cargo.toml
|
@ -33,25 +33,24 @@ chrono = { version = "0.4.37", features = [
|
||||||
"serde",
|
"serde",
|
||||||
], default-features = false }
|
], default-features = false }
|
||||||
color-eyre = "0.6.3"
|
color-eyre = "0.6.3"
|
||||||
comrak = { version = "0.22.0", features = [
|
comrak = { version = "0.32.0", features = [
|
||||||
"syntect",
|
"syntect",
|
||||||
], default-features = false }
|
], default-features = false }
|
||||||
console-subscriber = { version = "0.2.0", optional = true }
|
console-subscriber = { version = "0.4.1", optional = true }
|
||||||
derive_more = "0.99.17"
|
|
||||||
fronma = "0.2.0"
|
fronma = "0.2.0"
|
||||||
futures = "0.3.31"
|
futures = "0.3.31"
|
||||||
handlebars = "6.0.0"
|
handlebars = "6.0.0"
|
||||||
include_dir = "0.7.4"
|
include_dir = "0.7.4"
|
||||||
indexmap = { version = "2.7.0", features = ["serde"] }
|
indexmap = { version = "2.7.0", features = ["serde"] }
|
||||||
mime_guess = "2.0.5"
|
mime_guess = "2.0.5"
|
||||||
notify-debouncer-full = { version = "0.3.1", default-features = false }
|
notify-debouncer-full = { version = "0.4.0", default-features = false }
|
||||||
rss = "2.0.7"
|
rss = "2.0.7"
|
||||||
scc = { version = "2.1.0", features = ["serde"] }
|
scc = { version = "2.1.0", features = ["serde"] }
|
||||||
serde = { version = "1.0.197", features = ["derive", "rc"] }
|
serde = { version = "1.0.197", features = ["derive", "rc"] }
|
||||||
serde-value = "0.7.0"
|
serde-value = "0.7.0"
|
||||||
serde_json = { version = "1.0.124", features = ["preserve_order"] }
|
serde_json = { version = "1.0.124", features = ["preserve_order"] }
|
||||||
syntect = "5.2.0"
|
syntect = "5.2.0"
|
||||||
thiserror = "1.0.58"
|
thiserror = "2.0.9"
|
||||||
tokio = { version = "1.37.0", features = [
|
tokio = { version = "1.37.0", features = [
|
||||||
"fs",
|
"fs",
|
||||||
"macros",
|
"macros",
|
||||||
|
@ -61,8 +60,8 @@ tokio = { version = "1.37.0", features = [
|
||||||
] }
|
] }
|
||||||
tokio-util = { version = "0.7.10", default-features = false }
|
tokio-util = { version = "0.7.10", default-features = false }
|
||||||
toml = "0.8.12"
|
toml = "0.8.12"
|
||||||
tower = "0.4.13"
|
tower = { version = "0.5.2", features = ["util"] }
|
||||||
tower-http = { version = "0.5.2", features = [
|
tower-http = { version = "0.6.2", features = [
|
||||||
"compression-gzip",
|
"compression-gzip",
|
||||||
"fs",
|
"fs",
|
||||||
"trace",
|
"trace",
|
||||||
|
|
|
@ -39,10 +39,7 @@ pub fn render(markdown: &str, syntect: Option<&dyn SyntaxHighlighterAdapter>) ->
|
||||||
let mut render_plugins = RenderPlugins::default();
|
let mut render_plugins = RenderPlugins::default();
|
||||||
render_plugins.codefence_syntax_highlighter = syntect;
|
render_plugins.codefence_syntax_highlighter = syntect;
|
||||||
|
|
||||||
let plugins = comrak::PluginsBuilder::default()
|
let plugins = comrak::Plugins::builder().render(render_plugins).build();
|
||||||
.render(render_plugins)
|
|
||||||
.build()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
markdown_to_html_with_plugins(markdown, &options, &plugins)
|
markdown_to_html_with_plugins(markdown, &options, &plugins)
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ use serde_value::Value;
|
||||||
use tokio::fs::OpenOptions;
|
use tokio::fs::OpenOptions;
|
||||||
use tokio::io::{AsyncBufReadExt, AsyncReadExt, BufReader};
|
use tokio::io::{AsyncBufReadExt, AsyncReadExt, BufReader};
|
||||||
use tokio::time::Instant;
|
use tokio::time::Instant;
|
||||||
use tracing::{debug, error, info, instrument, warn};
|
use tracing::{debug, error, info, instrument};
|
||||||
|
|
||||||
use crate::error::PostError;
|
use crate::error::PostError;
|
||||||
use crate::post::Filter;
|
use crate::post::Filter;
|
||||||
|
@ -281,8 +281,7 @@ impl PostManager for Blag {
|
||||||
if !dont_cache && let Some(cache) = &self.cache {
|
if !dont_cache && let Some(cache) = &self.cache {
|
||||||
cache
|
cache
|
||||||
.insert(name, meta.clone(), mtime, Arc::clone(&body), query_hash)
|
.insert(name, meta.clone(), mtime, Arc::clone(&body), query_hash)
|
||||||
.await
|
.await;
|
||||||
.unwrap_or_else(|err| warn!("failed to insert {:?} into cache", err.0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let total = start.elapsed();
|
let total = start.elapsed();
|
||||||
|
|
|
@ -79,28 +79,17 @@ impl Cache {
|
||||||
mtime: u64,
|
mtime: u64,
|
||||||
rendered: Arc<str>,
|
rendered: Arc<str>,
|
||||||
extra: u64,
|
extra: u64,
|
||||||
) -> Result<(), (CacheKey, (PostMetadata, Arc<str>))> {
|
) -> Option<CacheValue> {
|
||||||
let key = CacheKey { name, extra };
|
self.0
|
||||||
|
.upsert_async(
|
||||||
let value = CacheValue {
|
CacheKey { name, extra },
|
||||||
meta: metadata,
|
CacheValue {
|
||||||
body: rendered,
|
meta: metadata,
|
||||||
mtime,
|
body: rendered,
|
||||||
};
|
mtime,
|
||||||
|
},
|
||||||
if self
|
)
|
||||||
.0
|
|
||||||
.update_async(&key, |_, _| value.clone())
|
|
||||||
.await
|
.await
|
||||||
.is_none()
|
|
||||||
{
|
|
||||||
self.0
|
|
||||||
.insert_async(key, value)
|
|
||||||
.await
|
|
||||||
.map_err(|x| (x.0, (x.1.meta, x.1.body)))
|
|
||||||
} else {
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
|
|
|
@ -129,9 +129,8 @@ impl MarkdownPosts {
|
||||||
Arc::clone(&post),
|
Arc::clone(&post),
|
||||||
self.render_hash,
|
self.render_hash,
|
||||||
)
|
)
|
||||||
.await
|
.await;
|
||||||
.unwrap_or_else(|err| warn!("failed to insert {:?} into cache", err.0))
|
}
|
||||||
};
|
|
||||||
|
|
||||||
Ok((metadata, post, (parsing, rendering)))
|
Ok((metadata, post, (parsing, rendering)))
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use handlebars::{Handlebars, Template};
|
use handlebars::{Handlebars, Template};
|
||||||
use notify_debouncer_full::notify::{self, Watcher};
|
use notify_debouncer_full::notify::{self};
|
||||||
use notify_debouncer_full::{new_debouncer, DebouncedEvent};
|
use notify_debouncer_full::{new_debouncer, DebouncedEvent};
|
||||||
use tokio::select;
|
use tokio::select;
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
@ -85,9 +85,7 @@ pub async fn watch_templates<'a>(
|
||||||
.expect("failed to send message over channel")
|
.expect("failed to send message over channel")
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
debouncer
|
debouncer.watch(path, notify::RecursiveMode::NonRecursive)?;
|
||||||
.watcher()
|
|
||||||
.watch(path, notify::RecursiveMode::NonRecursive)?;
|
|
||||||
|
|
||||||
'event_loop: while let Some(events) = select! {
|
'event_loop: while let Some(events) = select! {
|
||||||
_ = watcher_token.cancelled() => {
|
_ = watcher_token.cancelled() => {
|
||||||
|
|
Loading…
Reference in a new issue