Compare commits

..

No commits in common. "main" and "v0.1.0" have entirely different histories.
main ... v0.1.0

11 changed files with 49 additions and 48 deletions

36
Cargo.lock generated
View file

@ -115,6 +115,12 @@ dependencies = [
"windows-sys 0.59.0", "windows-sys 0.59.0",
] ]
[[package]]
name = "anyhow"
version = "1.0.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
[[package]] [[package]]
name = "atom_syndication" name = "atom_syndication"
version = "0.12.6" version = "0.12.6"
@ -1443,6 +1449,16 @@ dependencies = [
"redox_syscall", "redox_syscall",
] ]
[[package]]
name = "libyml"
version = "0.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3302702afa434ffa30847a83305f0a69d6abd74293b6554c18ec85c7ef30c980"
dependencies = [
"anyhow",
"version_check",
]
[[package]] [[package]]
name = "linked-hash-map" name = "linked-hash-map"
version = "0.5.6" version = "0.5.6"
@ -2382,16 +2398,18 @@ dependencies = [
] ]
[[package]] [[package]]
name = "serde_yaml_ng" name = "serde_yml"
version = "0.10.0" version = "0.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b4db627b98b36d4203a7b458cf3573730f2bb591b28871d916dfa9efabfd41f" checksum = "59e2dd588bf1597a252c3b920e0143eb99b0f76e4e082f4c92ce34fbc9e71ddd"
dependencies = [ dependencies = [
"indexmap", "indexmap",
"itoa 1.0.14", "itoa 1.0.14",
"libyml",
"memchr",
"ryu", "ryu",
"serde", "serde",
"unsafe-libyaml", "version_check",
] ]
[[package]] [[package]]
@ -2920,12 +2938,6 @@ version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
[[package]]
name = "unsafe-libyaml"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
[[package]] [[package]]
name = "url" name = "url"
version = "2.5.4" version = "2.5.4"
@ -3094,7 +3106,7 @@ dependencies = [
[[package]] [[package]]
name = "webdog" name = "webdog"
version = "0.1.1" version = "0.1.0"
dependencies = [ dependencies = [
"clap", "clap",
"color-eyre", "color-eyre",
@ -3115,7 +3127,7 @@ dependencies = [
"rayon", "rayon",
"rss", "rss",
"serde", "serde",
"serde_yaml_ng", "serde_yml",
"syntect", "syntect",
"tera", "tera",
"time", "time",

View file

@ -2,11 +2,11 @@
description = "static site generator fit for a dog" description = "static site generator fit for a dog"
edition = "2021" edition = "2021"
homepage = "https://webdog.zyl.gay" homepage = "https://webdog.zyl.gay"
license = "AGPL-3.0-or-later" license = "AGPLv2"
name = "webdog" name = "webdog"
readme = "README.md" readme = "README.md"
repository = "https://github.com/zyllian/webdog" repository = "https://github.com/zyllian/webdog"
version = "0.1.1" version = "0.1.0"
[dependencies] [dependencies]
clap = {version = "4", features = ["derive"]} clap = {version = "4", features = ["derive"]}
@ -31,7 +31,7 @@ pulldown-cmark = {version = "0.12", default-features = false, features = [
rayon = "1" rayon = "1"
rss = {version = "2", features = ["validation"]} rss = {version = "2", features = ["validation"]}
serde = {version = "1", features = ["derive"]} serde = {version = "1", features = ["derive"]}
serde_yaml_ng = "0.10" serde_yml = "0.0.12"
syntect = "5" syntect = "5"
tera = "1" tera = "1"
time = {version = "0.3", features = ["serde-human-readable"]} time = {version = "0.3", features = ["serde-human-readable"]}

View file

@ -3,7 +3,7 @@
webdog, the static site generator fit for a dog :3 webdog, the static site generator fit for a dog :3
```sh ```sh
cargo install webdog --locked cargo install webdog
``` ```
after installing, you can create your first site: after installing, you can create your first site:

View file

@ -5,7 +5,7 @@ welcome to webdog, the static site generator fit for a dog :3
if you have [rust](https://rust-lang.org) installed, all you need to do to install webdog is run the following command: if you have [rust](https://rust-lang.org) installed, all you need to do to install webdog is run the following command:
```sh ```sh
cargo install webdog --locked cargo install webdog --git https://github.com/zyllian/webdog
``` ```
then you can make your first webdog site! then you can make your first webdog site!

View file

@ -25,7 +25,7 @@ struct TemplateData<'a, T> {
/// Custom template data. /// Custom template data.
pub data: T, pub data: T,
/// Userdata supplied from the page. /// Userdata supplied from the page.
pub userdata: serde_yaml_ng::Value, pub userdata: serde_yml::Value,
} }
/// Struct used to build the site. /// Struct used to build the site.
@ -189,7 +189,7 @@ impl SiteBuilder {
let new_html = self.build_page_raw( let new_html = self.build_page_raw(
PageMetadata { PageMetadata {
template: Some(template.to_string()), template: Some(template.to_string()),
userdata: serde_yaml_ng::to_value(attr_map)?, userdata: serde_yml::to_value(attr_map)?,
is_partial: true, is_partial: true,
..Default::default() ..Default::default()
}, },
@ -267,8 +267,7 @@ impl SiteBuilder {
#[allow(clippy::single_match)] #[allow(clippy::single_match)]
match command { match command {
"cdn" => { "cdn" => {
new_src = new_src = self.site.config.cdn_url(&new_src)?.to_string();
self.site.config.cdn_url(&new_src)?.to_string();
} }
_ => new_src = src, _ => new_src = src,
} }
@ -292,8 +291,7 @@ impl SiteBuilder {
)?; )?;
} }
"cdn" => { "cdn" => {
new_href = new_href = self.site.config.cdn_url(&new_href)?.to_string();
self.site.config.cdn_url(&new_href)?.to_string();
} }
_ => { _ => {
new_href = href; new_href = href;

View file

@ -30,7 +30,7 @@ impl Extra {
match self { match self {
Self::Basic => { Self::Basic => {
let data: BasicData = serde_yaml_ng::from_value(data.inner.clone())?; let data: BasicData = serde_yml::from_value(data.inner.clone())?;
let content = builder.tera.render(&data.template, &tera::Context::new())?; let content = builder.tera.render(&data.template, &tera::Context::new())?;
append_to(&page, &content, "main.page") append_to(&page, &content, "main.page")
} }
@ -46,7 +46,7 @@ pub struct ExtraData {
pub name: String, pub name: String,
/// The inner data for the extra. /// The inner data for the extra.
#[serde(flatten)] #[serde(flatten)]
pub inner: serde_yaml_ng::Value, pub inner: serde_yml::Value,
} }
/// Gets the extra for the given value. /// Gets the extra for the given value.
@ -90,7 +90,7 @@ fn resource_list_outside(
resources: Vec<ResourceTemplateData<'r>>, resources: Vec<ResourceTemplateData<'r>>,
} }
let data: ResourceListData = serde_yaml_ng::from_value(data.inner.clone())?; let data: ResourceListData = serde_yml::from_value(data.inner.clone())?;
let res_builder = builder let res_builder = builder
.resource_builders .resource_builders

View file

@ -32,7 +32,7 @@ where
pub fn parse(input: String) -> eyre::Result<Self> { pub fn parse(input: String) -> eyre::Result<Self> {
if input.starts_with("---\n") { if input.starts_with("---\n") {
if let Some((frontmatter, content)) = input[3..].split_once("\n---\n") { if let Some((frontmatter, content)) = input[3..].split_once("\n---\n") {
let data = serde_yaml_ng::from_str(frontmatter)?; let data = serde_yml::from_str(frontmatter)?;
return Ok(Self { return Ok(Self {
content: content.to_string(), content: content.to_string(),
data, data,
@ -56,7 +56,7 @@ where
if let Some(data) = &self.data { if let Some(data) = &self.data {
output.push_str("---\n"); output.push_str("---\n");
output.push_str(&serde_yaml_ng::to_string(data)?); output.push_str(&serde_yml::to_string(data)?);
output.push_str("---\n\n"); output.push_str("---\n\n");
} }

View file

@ -100,9 +100,7 @@ impl SiteConfig {
if !config_path.exists() { if !config_path.exists() {
eyre::bail!("no site config found!"); eyre::bail!("no site config found!");
} }
Ok(serde_yaml_ng::from_str(&std::fs::read_to_string( Ok(serde_yml::from_str(&std::fs::read_to_string(config_path)?)?)
config_path,
)?)?)
} }
} }
@ -131,7 +129,7 @@ pub struct PageMetadata {
pub extra: Option<ExtraData>, pub extra: Option<ExtraData>,
/// Custom values passed to the base template. /// Custom values passed to the base template.
#[serde(default)] #[serde(default)]
pub userdata: serde_yaml_ng::Value, pub userdata: serde_yml::Value,
/// Whether this page being rendered is a partial. Set by the builder, not your page metadata. /// Whether this page being rendered is a partial. Set by the builder, not your page metadata.
#[serde(skip)] #[serde(skip)]
pub is_partial: bool, pub is_partial: bool,

View file

@ -135,7 +135,7 @@ fn main() -> eyre::Result<()> {
let config = SiteConfig::new(base_url.clone(), cdn_url.unwrap_or(base_url), title); let config = SiteConfig::new(base_url.clone(), cdn_url.unwrap_or(base_url), title);
std::fs::write( std::fs::write(
cli.site.join(SiteConfig::FILENAME), cli.site.join(SiteConfig::FILENAME),
serde_yaml_ng::to_string(&config)?, serde_yml::to_string(&config)?,
)?; )?;
DEFAULT_PROJECT.extract(&cli.site)?; DEFAULT_PROJECT.extract(&cli.site)?;
std::fs::create_dir(cli.site.join(webdog::ROOT_PATH))?; std::fs::create_dir(cli.site.join(webdog::ROOT_PATH))?;
@ -227,7 +227,7 @@ fn main() -> eyre::Result<()> {
config.resources.insert(id.clone(), resource_config); config.resources.insert(id.clone(), resource_config);
std::fs::write(config_path, serde_yaml_ng::to_string(&config)?)?; std::fs::write(config_path, serde_yml::to_string(&config)?)?;
let resource_path = cli.site.join(webdog::RESOURCES_PATH).join(&id); let resource_path = cli.site.join(webdog::RESOURCES_PATH).join(&id);
std::fs::create_dir_all(&resource_path)?; std::fs::create_dir_all(&resource_path)?;
@ -240,7 +240,7 @@ fn main() -> eyre::Result<()> {
tags: vec!["first".to_string()], tags: vec!["first".to_string()],
cdn_file: None, cdn_file: None,
desc: Some(format!("This is the first {name} :)")), desc: Some(format!("This is the first {name} :)")),
inner: serde_yaml_ng::Value::Null, inner: serde_yml::Value::Null,
draft: true, draft: true,
}, },
)?; )?;
@ -256,11 +256,7 @@ fn main() -> eyre::Result<()> {
title, title,
template, template,
} => { } => {
let page_path = cli let page_path = cli.site.join(webdog::PAGES_PATH).join(&id).with_extension("md");
.site
.join(webdog::PAGES_PATH)
.join(&id)
.with_extension("md");
let dir = page_path.parent().expect("should never fail"); let dir = page_path.parent().expect("should never fail");
if page_path.exists() { if page_path.exists() {
eprintln!("page already exists!"); eprintln!("page already exists!");
@ -314,7 +310,7 @@ fn main() -> eyre::Result<()> {
tags, tags,
cdn_file: None, cdn_file: None,
desc: description, desc: description,
inner: serde_yaml_ng::Value::Null, inner: serde_yml::Value::Null,
draft: !skip_draft, draft: !skip_draft,
}, },
)?; )?;

View file

@ -10,11 +10,8 @@ use serde::{Deserialize, Serialize};
use time::{format_description::well_known::Rfc2822, OffsetDateTime}; use time::{format_description::well_known::Rfc2822, OffsetDateTime};
use crate::{ use crate::{
builder::SiteBuilder, builder::SiteBuilder, frontmatter::FrontMatterRequired, link_list::Link,
frontmatter::FrontMatterRequired, util::{self, format_timestamp}, PageMetadata,
link_list::Link,
util::{self, format_timestamp},
PageMetadata,
}; };
/// Metadata for resources. /// Metadata for resources.
@ -33,7 +30,7 @@ pub struct ResourceMetadata {
pub desc: Option<String>, pub desc: Option<String>,
/// Extra resource data not included. /// Extra resource data not included.
#[serde(flatten)] #[serde(flatten)]
pub inner: serde_yaml_ng::Value, pub inner: serde_yml::Value,
/// Whether the resource is a draft. Drafts can be committed without being published to the live site. /// Whether the resource is a draft. Drafts can be committed without being published to the live site.
#[serde(default)] #[serde(default)]
pub draft: bool, pub draft: bool,

View file

@ -95,7 +95,7 @@ fn create(
builder.build_all_resources()?; builder.build_all_resources()?;
} }
} else if relative_path.display().to_string() == SiteConfig::FILENAME { } else if relative_path.display().to_string() == SiteConfig::FILENAME {
let new_config = serde_yaml_ng::from_str(&std::fs::read_to_string(path)?)?; let new_config = serde_yml::from_str(&std::fs::read_to_string(path)?)?;
builder.site.config = new_config; builder.site.config = new_config;
builder.reload()?; builder.reload()?;
builder.build_all()?; builder.build_all()?;