Compare commits

..

No commits in common. "2330648b69ba56d18c44116b4f7131bc24dc9bcc" and "e555f437c7c23170f2e653c23117f4c6f45644a5" have entirely different histories.

5 changed files with 511 additions and 513 deletions

947
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,47 +1,47 @@
[package]
description = "static site generator fit for a dog"
edition = "2024"
edition = "2021"
homepage = "https://webdog.zyl.gay"
license = "AGPL-3.0-or-later"
name = "webdog"
readme = "README.md"
repository = "https://github.com/zyllian/webdog"
version = "0.1.3"
version = "0.1.1"
[dependencies]
clap = { version = "4", features = ["derive"] }
color-eyre = { version = "0.6", optional = true }
clap = {version = "4", features = ["derive"]}
color-eyre = {version = "0.6", optional = true}
extract-frontmatter = "4"
eyre = "0.6"
fs_extra = "1.2"
futures = { version = "0.3", optional = true }
grass = { version = "0.13", default-features = false }
hotwatch = { version = "0.5", optional = true }
html5ever = "0.31"
futures = {version = "0.3", optional = true}
grass = {version = "0.13", default-features = false}
hotwatch = {version = "0.5", optional = true}
html5ever = "0.29"
include_dir = "0.7"
itertools = "0.14"
kuchikiki = "0.8.8-speedreader"
kuchikiki = "0.8.6-speedreader"
lol_html = "2"
minifier = { version = "0.3", features = ["html"] }
percent-encoding = { version = "2", optional = true }
pulldown-cmark = { version = "0.13", default-features = false, features = [
minifier = {version = "0.3", features = ["html"]}
percent-encoding = {version = "2", optional = true}
pulldown-cmark = {version = "0.12", default-features = false, features = [
"simd",
"html",
] }
]}
rayon = "1"
rss = { version = "2", features = ["validation"] }
serde = { version = "1", features = ["derive"] }
rss = {version = "2", features = ["validation"]}
serde = {version = "1", features = ["derive"]}
serde_yaml_ng = "0.10"
syntect = "5"
tera = "1"
time = { version = "0.3", features = ["serde-human-readable"] }
tokio = { version = "1", features = [
time = {version = "0.3", features = ["serde-human-readable"]}
tokio = {version = "1", features = [
"macros",
"rt-multi-thread",
], optional = true }
url = { version = "2", features = ["serde"] }
], optional = true}
url = {version = "2", features = ["serde"]}
walkdir = "2"
warp = { version = "0.3", optional = true }
warp = {version = "0.3", optional = true}
[features]
default = ["serve", "color-eyre"]

View file

@ -37,10 +37,6 @@ list of sass/scss stylesheets in the site's `sass` directory to treat as root st
base url for the various cdn url transformation features of webdog.
## `webdog_path`
optional custom path for webdog's static resources.
## `code_theme`
the theme to use for code blocks. valid options: `base16-ocean.dark`, `base16-eighties.dark`, `base16-mocha.dark`, `base16-ocean.light`, `InspiredGitHub`, `Solarized (dark)`, and `Solarized (light)`

View file

@ -2,18 +2,18 @@
use std::{collections::HashMap, path::PathBuf};
use eyre::{Context, OptionExt, eyre};
use lol_html::{HtmlRewriter, Settings, element, html_content::ContentType};
use eyre::{eyre, Context, OptionExt};
use lol_html::{element, html_content::ContentType, HtmlRewriter, Settings};
use rayon::prelude::*;
use serde::Serialize;
use syntect::{highlighting::ThemeSet, parsing::SyntaxSet};
use tera::Tera;
use url::Url;
use crate::{PageMetadata, ROOT_PATH, SASS_PATH, Site, resource::ResourceBuilder, util};
use crate::{resource::ResourceBuilder, util, PageMetadata, Site, ROOT_PATH, SASS_PATH};
/// Default path for static webdog resources included with the site build.
const WEBDOG_DEFAULT_PATH: &str = "webdog";
/// Path for static webdog resources included with the site build.
const WEBDOG_PATH: &str = "webdog";
/// Struct containing data to be sent to templates when rendering them.
#[derive(Debug, Serialize)]
@ -96,13 +96,7 @@ impl SiteBuilder {
std::fs::create_dir(&self.build_path).wrap_err("Failed to create build directory")?;
}
let webdog_path = self.build_path.join(
self.site
.config
.webdog_path
.clone()
.unwrap_or_else(|| WEBDOG_DEFAULT_PATH.to_string()),
);
let webdog_path = self.build_path.join(WEBDOG_PATH);
std::fs::create_dir(&webdog_path)?;
std::fs::write(
webdog_path.join("webdog.js"),
@ -161,7 +155,6 @@ impl SiteBuilder {
}
/// Function to rewrite HTML wow.
#[allow(clippy::too_many_arguments)]
pub fn rewrite_html(
&self,
html: String,
@ -170,7 +163,6 @@ impl SiteBuilder {
scripts: &[String],
styles: &[String],
is_partial: bool,
webdog_path: &str,
) -> eyre::Result<String> {
use kuchikiki::traits::*;
@ -259,9 +251,7 @@ impl SiteBuilder {
);
}
el.append(
&format!(
r#"<script type="text/javascript" src="/{webdog_path}/webdog.js" defer></script>"#
),
r#"<script type="text/javascript" src="/webdog/webdog.js" defer></script>"#,
ContentType::Html,
);
if self.serving {
@ -387,12 +377,6 @@ impl SiteBuilder {
&page_metadata.scripts,
&page_metadata.styles,
page_metadata.is_partial,
&self
.site
.config
.webdog_path
.clone()
.unwrap_or_else(|| WEBDOG_DEFAULT_PATH.to_string()),
)?;
if let Some(data) = extra {

View file

@ -49,8 +49,6 @@ pub struct SiteConfig {
pub sass_styles: Vec<PathBuf>,
/// URL to the CDN used for the site's images.
pub cdn_url: Url,
/// The path to output webdog static resources to. Defaults to "webdog"
pub webdog_path: Option<String>,
/// The theme to use for the site's code blocks.
/// TODO: dark/light themes
/// TODO: export themes as CSS instead of styling HTML directly
@ -75,7 +73,6 @@ impl SiteConfig {
build: None,
sass_styles: vec!["index.scss".into()],
cdn_url,
webdog_path: None,
code_theme: "base16-ocean.dark".to_string(),
resources: Default::default(),
}