Compare commits

..

No commits in common. "0e9d74b2c81f22653cb591cb98286f6d4b81fa5c" and "051e86e65a628165eb0a2ddbdf8fbbcd59eda4cc" have entirely different histories.

194 changed files with 19 additions and 4328 deletions

257
Cargo.lock generated
View File

@ -65,18 +65,6 @@ dependencies = [
"windows-sys", "windows-sys",
] ]
[[package]]
name = "arrayvec"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]]
name = "autocfg"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]] [[package]]
name = "backtrace" name = "backtrace"
version = "0.3.69" version = "0.3.69"
@ -92,24 +80,6 @@ dependencies = [
"rustc-demangle", "rustc-demangle",
] ]
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitvec"
version = "0.19.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55f93d0ef3363c364d5976646a38f04cf67cfe1d4c8d160cdea02cab2c116b33"
dependencies = [
"funty",
"radium",
"tap",
"wyz",
]
[[package]] [[package]]
name = "bytes" name = "bytes"
version = "1.5.0" version = "1.5.0"
@ -176,117 +146,12 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
[[package]]
name = "duster"
version = "0.1.1"
source = "git+https://code.fizz.buzz/talexander/duster.git?branch=master#3428a3f5097c7d2cc252d1bfd9aae7771553ab69"
dependencies = [
"nom 6.1.2",
"serde",
"serde_json",
]
[[package]] [[package]]
name = "equivalent" name = "equivalent"
version = "1.0.1" version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "funty"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7"
[[package]]
name = "futures"
version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335"
dependencies = [
"futures-channel",
"futures-core",
"futures-executor",
"futures-io",
"futures-sink",
"futures-task",
"futures-util",
]
[[package]]
name = "futures-channel"
version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb"
dependencies = [
"futures-core",
"futures-sink",
]
[[package]]
name = "futures-core"
version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c"
[[package]]
name = "futures-executor"
version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc"
dependencies = [
"futures-core",
"futures-task",
"futures-util",
]
[[package]]
name = "futures-io"
version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa"
[[package]]
name = "futures-macro"
version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "futures-sink"
version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817"
[[package]]
name = "futures-task"
version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2"
[[package]]
name = "futures-util"
version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104"
dependencies = [
"futures-channel",
"futures-core",
"futures-io",
"futures-macro",
"futures-sink",
"futures-task",
"memchr",
"pin-project-lite",
"pin-utils",
"slab",
]
[[package]] [[package]]
name = "gimli" name = "gimli"
version = "0.28.0" version = "0.28.0"
@ -311,25 +176,6 @@ version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7"
[[package]]
name = "include_dir"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18762faeff7122e89e0857b02f7ce6fcc0d101d5e9ad2ad7846cc01d61b7f19e"
dependencies = [
"include_dir_macros",
]
[[package]]
name = "include_dir_macros"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b139284b5cf57ecfa712bcc66950bb635b31aff41c188e8a4cfc758eca374a3f"
dependencies = [
"proc-macro2",
"quote",
]
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "2.0.2" version = "2.0.2"
@ -340,25 +186,6 @@ dependencies = [
"hashbrown", "hashbrown",
] ]
[[package]]
name = "itoa"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
[[package]]
name = "lexical-core"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe"
dependencies = [
"arrayvec",
"bitflags",
"cfg-if",
"ryu",
"static_assertions",
]
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.149" version = "0.2.149"
@ -386,19 +213,6 @@ dependencies = [
"adler", "adler",
] ]
[[package]]
name = "nom"
version = "6.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7413f999671bd4745a7b624bd370a569fb6bc574b23c83a3c5ed2e453f3d5e2"
dependencies = [
"bitvec",
"funty",
"lexical-core",
"memchr",
"version_check",
]
[[package]] [[package]]
name = "nom" name = "nom"
version = "7.1.3" version = "7.1.3"
@ -431,8 +245,10 @@ dependencies = [
[[package]] [[package]]
name = "organic" name = "organic"
version = "0.1.12" version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3f0f8a2a6d31c3cac7ebf543d8cb2e8f648300462fc2f6b1a09cac10daf0387"
dependencies = [ dependencies = [
"nom 7.1.3", "nom",
"walkdir", "walkdir",
] ]
@ -442,12 +258,6 @@ version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
[[package]]
name = "pin-utils"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.69" version = "1.0.69"
@ -466,24 +276,12 @@ dependencies = [
"proc-macro2", "proc-macro2",
] ]
[[package]]
name = "radium"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8"
[[package]] [[package]]
name = "rustc-demangle" name = "rustc-demangle"
version = "0.1.23" version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]]
name = "ryu"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
[[package]] [[package]]
name = "same-file" name = "same-file"
version = "1.0.6" version = "1.0.6"
@ -513,17 +311,6 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "serde_json"
version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65"
dependencies = [
"itoa",
"ryu",
"serde",
]
[[package]] [[package]]
name = "serde_spanned" name = "serde_spanned"
version = "0.6.3" version = "0.6.3"
@ -533,21 +320,6 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "slab"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67"
dependencies = [
"autocfg",
]
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.38" version = "2.0.38"
@ -559,12 +331,6 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "tap"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.33.0" version = "1.33.0"
@ -623,12 +389,6 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]]
name = "version_check"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]] [[package]]
name = "walkdir" name = "walkdir"
version = "2.4.0" version = "2.4.0"
@ -750,19 +510,8 @@ name = "writer"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"clap", "clap",
"duster",
"futures",
"include_dir",
"organic", "organic",
"serde", "serde",
"serde_json",
"tokio", "tokio",
"toml", "toml",
"walkdir",
] ]
[[package]]
name = "wyz"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214"

View File

@ -6,15 +6,11 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
# error-context, suggestions, usage | env
clap = { version = "4.4.6", default-features = false, features = ["std", "color", "help", "derive"] } clap = { version = "4.4.6", default-features = false, features = ["std", "color", "help", "derive"] }
duster = { git = "https://code.fizz.buzz/talexander/duster.git", branch = "master" } organic = "0.1.12"
futures = "0.3.29" # | alloc, rc, serde_derive, unstable
include_dir = "0.7.3"
# TODO: This is temporary to work on the latest organic code. Eventually switch back to using the published crate.
organic = { path = "../organic" }
# organic = "0.1.12"
serde = { version = "1.0.189", default-features = false, features = ["std", "derive"] } serde = { version = "1.0.189", default-features = false, features = ["std", "derive"] }
serde_json = "1.0.107"
tokio = { version = "1.30.0", default-features = false, features = ["rt", "rt-multi-thread", "fs", "io-util"] } tokio = { version = "1.30.0", default-features = false, features = ["rt", "rt-multi-thread", "fs", "io-util"] }
# display, parse | indexmap, preserve_order
toml = "0.8.2" toml = "0.8.2"
walkdir = "2.4.0"

View File

@ -1 +0,0 @@
angle_link

View File

@ -1 +0,0 @@
babel_call

View File

@ -1,14 +0,0 @@
<div class="blog_post">
<div class="blog_post_intro">
{?.title}{?.self_link}<a class="blog_post_title" href="{.link}">{.title}</a>{:else}<div class="blog_post_title">{.title}</div>{/.self_link}{/.title}
{! TODO: date? !}
</div>
{! TODO: Table of contents? !}
<div class="blog_post_body">
{#.children}
{>document_element/}
{/.children}
</div>
</div>

View File

@ -1 +0,0 @@
bold

View File

@ -1 +0,0 @@
center_block

View File

@ -1 +0,0 @@
citation

View File

@ -1 +0,0 @@
citation_reference

View File

@ -1 +0,0 @@
clock

View File

@ -1 +0,0 @@
code

View File

@ -1 +0,0 @@
comment

View File

@ -1 +0,0 @@
comment_block

View File

@ -1 +0,0 @@
diary_sexp

View File

@ -1,5 +0,0 @@
{@select key=.type}
{@eq value="heading"}{>heading/}{/eq}
{@eq value="section"}{>section/}{/eq}
{@none}{!TODO: make this panic!}ERROR: Unrecognized type {.type}.{/none}
{/select}

View File

@ -1 +0,0 @@
drawer

View File

@ -1 +0,0 @@
dynamic_block

View File

@ -1,27 +0,0 @@
{@select key=.type}
{@eq value="paragraph"}{>paragraph/}{/eq}
{@eq value="plain_list"}{>plain_list/}{/eq}
{@eq value="center_block"}{>center_block/}{/eq}
{@eq value="quote_block"}{>quote_block/}{/eq}
{@eq value="special_block"}{>special_block/}{/eq}
{@eq value="dynamic_block"}{>dynamic_block/}{/eq}
{@eq value="footnote_definition"}{>footnote_definition/}{/eq}
{@eq value="comment"}{>comment/}{/eq}
{@eq value="drawer"}{>drawer/}{/eq}
{@eq value="property_drawer"}{>property_drawer/}{/eq}
{@eq value="table"}{>table/}{/eq}
{@eq value="verse_block"}{>verse_block/}{/eq}
{@eq value="comment_block"}{>comment_block/}{/eq}
{@eq value="example_block"}{>example_block/}{/eq}
{@eq value="export_block"}{>export_block/}{/eq}
{@eq value="src_block"}{>src_block/}{/eq}
{@eq value="clock"}{>clock/}{/eq}
{@eq value="diary_sexp"}{>diary_sexp/}{/eq}
{@eq value="planning"}{>planning/}{/eq}
{@eq value="fixed_width_area"}{>fixed_width_area/}{/eq}
{@eq value="horizontal_rule"}{>horizontal_rule/}{/eq}
{@eq value="keyword"}{>keyword/}{/eq}
{@eq value="babel_call"}{>babel_call/}{/eq}
{@eq value="latex_environment"}{>latex_environment/}{/eq}
{@none}{!TODO: make this panic!}ERROR: Unrecognized type {.type}.{/none}
{/select}

View File

@ -1 +0,0 @@
entity

View File

@ -1 +0,0 @@
example_block

View File

@ -1 +0,0 @@
export_block

View File

@ -1 +0,0 @@
export_snippet

View File

@ -1 +0,0 @@
fixed_width_area

View File

@ -1 +0,0 @@
footnote_definition

View File

@ -1 +0,0 @@
footnote_reference

View File

@ -1 +0,0 @@
global_settings

View File

@ -1,11 +0,0 @@
{@lte key=.level value=4}
<h{.level}>{#.title}{>object/}{/.title}</h{.level}>
{:else}
<ol>
<li>{#.title}{>object/}{/.title}</li>
</ol>
{/lte}
{#.children}
{>document_element/}
{/.children}

View File

@ -1 +0,0 @@
horizontal_rule

View File

@ -1 +0,0 @@
inline_babel_call

View File

@ -1 +0,0 @@
inline_source_block

View File

@ -1 +0,0 @@
italic

View File

@ -1 +0,0 @@
keyword

View File

@ -1 +0,0 @@
latex_environment

View File

@ -1 +0,0 @@
latex_fragment

View File

@ -1 +0,0 @@
line_break

View File

@ -1,18 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
{#global_settings.css_files}<link rel="stylesheet" href="{.}">{/global_settings.css_files}
{#global_settings.js_files}<script type="text/javascript" src="{.}"></script>{/global_settings.js_files}
{?global_settings.page_title}<title>{global_settings.page_title}</title>{/global_settings.page_title}
</head>
<body>
{! TODO: Header bar with links? !}
<div class="main_content">
{@select key=.type}
{@eq value="blog_post_page"}{>blog_post_page/}{/eq}
{@none}{!TODO: make this panic!}ERROR: Unrecognized page content type{/none}
{/select}
</div>
</body>
</html>

View File

@ -1,30 +0,0 @@
{@select key=.type}
{@eq value="bold"}{>bold/}{/eq}
{@eq value="italic"}{>italic/}{/eq}
{@eq value="underline"}{>underline/}{/eq}
{@eq value="strike_through"}{>strike_through/}{/eq}
{@eq value="code"}{>code/}{/eq}
{@eq value="verbatim"}{>verbatim/}{/eq}
{@eq value="plain_text"}{>plain_text/}{/eq}
{@eq value="regular_link"}{>regular_link/}{/eq}
{@eq value="radio_link"}{>radio_link/}{/eq}
{@eq value="radio_target"}{>radio_target/}{/eq}
{@eq value="plain_link"}{>plain_link/}{/eq}
{@eq value="angle_link"}{>angle_link/}{/eq}
{@eq value="org_macro"}{>org_macro/}{/eq}
{@eq value="entity"}{>entity/}{/eq}
{@eq value="latex_fragment"}{>latex_fragment/}{/eq}
{@eq value="export_snippet"}{>export_snippet/}{/eq}
{@eq value="footnote_reference"}{>footnote_reference/}{/eq}
{@eq value="citation"}{>citation/}{/eq}
{@eq value="citation_reference"}{>citation_reference/}{/eq}
{@eq value="inline_babel_call"}{>inline_babel_call/}{/eq}
{@eq value="inline_source_block"}{>inline_source_block/}{/eq}
{@eq value="line_break"}{>line_break/}{/eq}
{@eq value="target"}{>target/}{/eq}
{@eq value="statistics_cookie"}{>statistics_cookie/}{/eq}
{@eq value="subscript"}{>subscript/}{/eq}
{@eq value="superscript"}{>superscript/}{/eq}
{@eq value="timestamp"}{>timestamp/}{/eq}
{@none}{!TODO: make this panic!}ERROR: Unrecognized type {.type}.{/none}
{/select}

View File

@ -1 +0,0 @@
org_macro

View File

@ -1,3 +0,0 @@
<p>{#.children}
{>object/}
{/.children}</p>

View File

@ -1 +0,0 @@
plain_link

View File

@ -1 +0,0 @@
plain_list

View File

@ -1 +0,0 @@
plain_text

View File

@ -1 +0,0 @@
planning

View File

@ -1 +0,0 @@
property_drawer

View File

@ -1 +0,0 @@
quote_block

View File

@ -1 +0,0 @@
radio_link

View File

@ -1 +0,0 @@
radio_target

View File

@ -1 +0,0 @@
regular_link

View File

@ -1,3 +0,0 @@
{#.children}
{>element/}
{/.children}

View File

@ -1 +0,0 @@
special_block

View File

@ -1 +0,0 @@
src_block

View File

@ -1 +0,0 @@
statistics_cookie

View File

@ -1 +0,0 @@
strike_through

View File

@ -1 +0,0 @@
subscript

View File

@ -1 +0,0 @@
superscript

View File

@ -1 +0,0 @@
table

View File

@ -1 +0,0 @@
target

View File

@ -1 +0,0 @@
timestamp

View File

@ -1 +0,0 @@
underline

View File

@ -1 +0,0 @@
verbatim

View File

@ -1 +0,0 @@
verse_block

View File

@ -1,4 +1,3 @@
mod render;
mod runner; mod runner;
pub(crate) use runner::build_site; pub(crate) use runner::build_site;

View File

@ -1,98 +0,0 @@
use std::ffi::OsStr;
use std::path::PathBuf;
use include_dir::include_dir;
use include_dir::Dir;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::convert_blog_post_page_to_render_context;
use crate::intermediate::BlogPost;
use crate::render::DusterRenderer;
use crate::render::RendererIntegration;
static MAIN_TEMPLATES: Dir = include_dir!("$CARGO_MANIFEST_DIR/default_environment/templates/html");
pub(crate) struct SiteRenderer {
output_directory: PathBuf,
blog_posts: Vec<BlogPost>,
}
impl SiteRenderer {
pub(crate) fn new<P: Into<PathBuf>>(
output_directory: P,
blog_posts: Vec<BlogPost>,
) -> SiteRenderer {
SiteRenderer {
output_directory: output_directory.into(),
blog_posts,
}
}
pub(crate) async fn render_blog_posts(&self, config: &Config) -> Result<(), CustomError> {
let mut renderer_integration = DusterRenderer::new();
let sources: Vec<_> = MAIN_TEMPLATES
.files()
.filter(|f| f.path().extension() == Some(OsStr::new("dust")))
.collect();
if sources
.iter()
.filter(|f| f.path().file_stem() == Some(OsStr::new("main")))
.count()
!= 1
{
return Err("Expect exactly 1 main.dust template file.".into());
}
let decoded_templates = {
let mut decoded_templates = Vec::with_capacity(sources.len());
for entry in sources {
decoded_templates.push(build_name_contents_pairs(entry)?);
}
decoded_templates
};
for (name, contents) in decoded_templates {
renderer_integration.load_template(name, contents)?;
}
for blog_post in &self.blog_posts {
for blog_post_page in &blog_post.pages {
let output_path = self
.output_directory
.join("posts")
.join(&blog_post.id)
.join(blog_post_page.get_output_path());
let render_context = convert_blog_post_page_to_render_context(
config,
&self.output_directory,
&output_path,
blog_post,
blog_post_page,
)?;
let rendered_output = renderer_integration.render(render_context)?;
let parent_directory = output_path
.parent()
.ok_or("Output file should have a containing directory.")?;
tokio::fs::create_dir_all(parent_directory).await?;
tokio::fs::write(output_path, rendered_output).await?;
}
}
Ok(())
}
}
fn build_name_contents_pairs<'a>(
entry: &'a include_dir::File<'_>,
) -> Result<(&'a str, &'a str), CustomError> {
let path = entry.path();
let name = path
.file_stem()
.ok_or("All templates should have a stem.")?
.to_str()
.ok_or("All template filenames should be valid utf-8.")?;
let contents = std::str::from_utf8(entry.contents())?;
Ok((name, contents))
}

View File

@ -1,60 +1,7 @@
use std::path::PathBuf;
use crate::cli::parameters::BuildArgs; use crate::cli::parameters::BuildArgs;
use crate::command::build::render::SiteRenderer;
use crate::config::Config; use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::BlogPost;
pub(crate) async fn build_site(args: BuildArgs) -> Result<(), CustomError> {
let config = Config::load_from_file(args.config).await?;
let blog_posts = load_blog_posts(&config).await?;
let renderer = SiteRenderer::new(get_output_directory(&config).await?, blog_posts);
renderer.render_blog_posts(&config).await?;
pub(crate) async fn build_site(args: BuildArgs) -> Result<(), Box<dyn std::error::Error>> {
let _config = Config::load_from_file(args.config).await?;
Ok(()) Ok(())
} }
/// Delete everything inside the output directory and return the path to that directory.
async fn get_output_directory(config: &Config) -> Result<PathBuf, CustomError> {
let output_directory = config.get_output_directory();
if !output_directory.exists() {
tokio::fs::create_dir(&output_directory).await?;
} else {
let mut existing_entries = tokio::fs::read_dir(&output_directory).await?;
while let Some(entry) = existing_entries.next_entry().await? {
let file_type = entry.file_type().await?;
if file_type.is_dir() {
tokio::fs::remove_dir_all(entry.path()).await?;
} else {
tokio::fs::remove_file(entry.path()).await?;
}
}
}
Ok(output_directory)
}
async fn get_post_directories(config: &Config) -> Result<Vec<PathBuf>, CustomError> {
let mut ret = Vec::new();
let mut entries = tokio::fs::read_dir(config.get_posts_directory()).await?;
while let Some(entry) = entries.next_entry().await? {
let file_type = entry.file_type().await?;
if file_type.is_dir() {
ret.push(entry.path());
}
}
Ok(ret)
}
async fn load_blog_posts(config: &Config) -> Result<Vec<BlogPost>, CustomError> {
let root_directory = config.get_root_directory().to_owned();
let post_directories = get_post_directories(&config).await?;
let load_jobs = post_directories
.into_iter()
.map(|path| tokio::spawn(BlogPost::load_blog_post(root_directory.clone(), path)));
let mut blog_posts = Vec::new();
for job in load_jobs {
blog_posts.push(job.await??);
}
Ok(blog_posts)
}

View File

@ -1,8 +1,7 @@
use crate::cli::parameters::InitArgs; use crate::cli::parameters::InitArgs;
use crate::config::Config; use crate::config::Config;
use crate::error::CustomError;
pub(crate) async fn init_writer_folder(args: InitArgs) -> Result<(), CustomError> { pub(crate) async fn init_writer_folder(args: InitArgs) -> Result<(), Box<dyn std::error::Error>> {
if args.path.exists() && !args.path.is_dir() { if args.path.exists() && !args.path.is_dir() {
return Err("The supplied path exists but is not a directory. Aborting.".into()); return Err("The supplied path exists but is not a directory. Aborting.".into());
} }

View File

@ -3,8 +3,6 @@ use std::path::PathBuf;
use tokio::fs::File; use tokio::fs::File;
use tokio::io::AsyncWriteExt; use tokio::io::AsyncWriteExt;
use crate::error::CustomError;
use super::raw::RawConfig; use super::raw::RawConfig;
/// This is the config struct used by most of the code, which is an interpreted version of the RawConfig struct which is the raw disk-representation of the config. /// This is the config struct used by most of the code, which is an interpreted version of the RawConfig struct which is the raw disk-representation of the config.
@ -14,8 +12,8 @@ pub(crate) struct Config {
} }
impl Config { impl Config {
pub(crate) fn new<P: AsRef<Path>>(root_dir: P) -> Result<Config, CustomError> { pub(crate) fn new<P: AsRef<Path>>(root_dir: P) -> Result<Config, Box<dyn std::error::Error>> {
fn inner(root_dir: &Path) -> Result<Config, CustomError> { fn inner(root_dir: &Path) -> Result<Config, Box<dyn std::error::Error>> {
let file_path = root_dir.join("writer.toml"); let file_path = root_dir.join("writer.toml");
Ok(Config { Ok(Config {
raw: RawConfig::default(), raw: RawConfig::default(),
@ -25,8 +23,10 @@ impl Config {
inner(root_dir.as_ref()) inner(root_dir.as_ref())
} }
pub(crate) async fn load_from_file<P: Into<PathBuf>>(path: P) -> Result<Config, CustomError> { pub(crate) async fn load_from_file<P: Into<PathBuf>>(
async fn inner(path: PathBuf) -> Result<Config, CustomError> { path: P,
) -> Result<Config, Box<dyn std::error::Error>> {
async fn inner(path: PathBuf) -> Result<Config, Box<dyn std::error::Error>> {
let contents = tokio::fs::read_to_string(&path).await?; let contents = tokio::fs::read_to_string(&path).await?;
let parsed_contents: RawConfig = toml::from_str(contents.as_str())?; let parsed_contents: RawConfig = toml::from_str(contents.as_str())?;
Ok(Config { Ok(Config {
@ -37,34 +37,11 @@ impl Config {
inner(path.into()).await inner(path.into()).await
} }
pub(crate) async fn write_to_disk(&self) -> Result<(), CustomError> { pub(crate) async fn write_to_disk(&self) -> Result<(), Box<dyn std::error::Error>> {
let mut config_file = File::create(&self.config_path).await?; let mut config_file = File::create(&self.config_path).await?;
config_file config_file
.write_all(toml::to_string(&self.raw)?.as_bytes()) .write_all(toml::to_string(&self.raw)?.as_bytes())
.await?; .await?;
Ok(()) Ok(())
} }
pub(crate) fn get_root_directory(&self) -> &Path {
&self
.config_path
.parent()
.expect("Config file must exist inside a directory.")
}
pub(crate) fn get_posts_directory(&self) -> PathBuf {
self.get_root_directory().join("posts")
}
pub(crate) fn get_output_directory(&self) -> PathBuf {
self.get_root_directory().join("output")
}
pub(crate) fn use_relative_paths(&self) -> bool {
self.raw.use_relative_paths.unwrap_or(true)
}
pub(crate) fn get_web_root(&self) -> Option<&str> {
self.raw.web_root.as_deref()
}
} }

View File

@ -7,8 +7,6 @@ pub(crate) struct RawConfig {
site_title: String, site_title: String,
author: Option<String>, author: Option<String>,
email: Option<String>, email: Option<String>,
pub(super) use_relative_paths: Option<bool>,
pub(super) web_root: Option<String>,
} }
impl Default for RawConfig { impl Default for RawConfig {
@ -17,8 +15,6 @@ impl Default for RawConfig {
site_title: "My super awesome website".to_owned(), site_title: "My super awesome website".to_owned(),
author: None, author: None,
email: None, email: None,
use_relative_paths: None,
web_root: None,
} }
} }
} }

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IAngleLink;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "angle_link")]
pub(crate) struct RenderAngleLink {}
impl RenderAngleLink {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
comment: &IAngleLink,
) -> Result<RenderAngleLink, CustomError> {
Ok(RenderAngleLink {})
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IBabelCall;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "babel_call")]
pub(crate) struct RenderBabelCall {}
impl RenderBabelCall {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
original: &IBabelCall,
) -> Result<RenderBabelCall, CustomError> {
Ok(RenderBabelCall {})
}
}

View File

@ -1,34 +0,0 @@
use serde::Serialize;
use super::GlobalSettings;
use super::RenderDocumentElement;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "blog_post_page")]
pub(crate) struct RenderBlogPostPage {
global_settings: GlobalSettings,
/// The title that will be shown visibly on the page.
title: Option<String>,
self_link: Option<String>,
children: Vec<RenderDocumentElement>,
}
impl RenderBlogPostPage {
pub(crate) fn new(
global_settings: GlobalSettings,
title: Option<String>,
self_link: Option<String>,
children: Vec<RenderDocumentElement>,
) -> RenderBlogPostPage {
RenderBlogPostPage {
global_settings,
title,
self_link,
children,
}
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IBold;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "bold")]
pub(crate) struct RenderBold {}
impl RenderBold {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
comment: &IBold,
) -> Result<RenderBold, CustomError> {
Ok(RenderBold {})
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::ICenterBlock;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "center_block")]
pub(crate) struct RenderCenterBlock {}
impl RenderCenterBlock {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
original: &ICenterBlock,
) -> Result<RenderCenterBlock, CustomError> {
Ok(RenderCenterBlock {})
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::ICitation;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "citation")]
pub(crate) struct RenderCitation {}
impl RenderCitation {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
comment: &ICitation,
) -> Result<RenderCitation, CustomError> {
Ok(RenderCitation {})
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::ICitationReference;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "citation_reference")]
pub(crate) struct RenderCitationReference {}
impl RenderCitationReference {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
comment: &ICitationReference,
) -> Result<RenderCitationReference, CustomError> {
Ok(RenderCitationReference {})
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IClock;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "clock")]
pub(crate) struct RenderClock {}
impl RenderClock {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
original: &IClock,
) -> Result<RenderClock, CustomError> {
Ok(RenderClock {})
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::ICode;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "code")]
pub(crate) struct RenderCode {}
impl RenderCode {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
comment: &ICode,
) -> Result<RenderCode, CustomError> {
Ok(RenderCode {})
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IComment;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "comment")]
pub(crate) struct RenderComment {}
impl RenderComment {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
comment: &IComment,
) -> Result<RenderComment, CustomError> {
Ok(RenderComment {})
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::ICommentBlock;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "comment_block")]
pub(crate) struct RenderCommentBlock {}
impl RenderCommentBlock {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
original: &ICommentBlock,
) -> Result<RenderCommentBlock, CustomError> {
Ok(RenderCommentBlock {})
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IDiarySexp;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "diary_sexp")]
pub(crate) struct RenderDiarySexp {}
impl RenderDiarySexp {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
original: &IDiarySexp,
) -> Result<RenderDiarySexp, CustomError> {
Ok(RenderDiarySexp {})
}
}

View File

@ -1,35 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IDocumentElement;
use super::RenderHeading;
use super::RenderSection;
#[derive(Debug, Serialize)]
#[serde(untagged)]
pub(crate) enum RenderDocumentElement {
Heading(RenderHeading),
Section(RenderSection),
}
impl RenderDocumentElement {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
original: &IDocumentElement,
) -> Result<RenderDocumentElement, CustomError> {
match original {
IDocumentElement::Heading(inner) => Ok(RenderDocumentElement::Heading(
RenderHeading::new(config, output_directory, output_file, inner)?,
)),
IDocumentElement::Section(inner) => Ok(RenderDocumentElement::Section(
RenderSection::new(config, output_directory, output_file, inner)?,
)),
}
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IDrawer;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "drawer")]
pub(crate) struct RenderDrawer {}
impl RenderDrawer {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
original: &IDrawer,
) -> Result<RenderDrawer, CustomError> {
Ok(RenderDrawer {})
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IDynamicBlock;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "dynamic_block")]
pub(crate) struct RenderDynamicBlock {}
impl RenderDynamicBlock {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
original: &IDynamicBlock,
) -> Result<RenderDynamicBlock, CustomError> {
Ok(RenderDynamicBlock {})
}
}

View File

@ -1,190 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IElement;
use super::babel_call::RenderBabelCall;
use super::center_block::RenderCenterBlock;
use super::clock::RenderClock;
use super::comment::RenderComment;
use super::comment_block::RenderCommentBlock;
use super::diary_sexp::RenderDiarySexp;
use super::drawer::RenderDrawer;
use super::dynamic_block::RenderDynamicBlock;
use super::example_block::RenderExampleBlock;
use super::export_block::RenderExportBlock;
use super::fixed_width_area::RenderFixedWidthArea;
use super::footnote_definition::RenderFootnoteDefinition;
use super::horizontal_rule::RenderHorizontalRule;
use super::keyword::RenderKeyword;
use super::latex_environment::RenderLatexEnvironment;
use super::paragraph::RenderParagraph;
use super::plain_list::RenderPlainList;
use super::planning::RenderPlanning;
use super::property_drawer::RenderPropertyDrawer;
use super::quote_block::RenderQuoteBlock;
use super::special_block::RenderSpecialBlock;
use super::src_block::RenderSrcBlock;
use super::table::RenderTable;
use super::verse_block::RenderVerseBlock;
#[derive(Debug, Serialize)]
#[serde(untagged)]
pub(crate) enum RenderElement {
Paragraph(RenderParagraph),
PlainList(RenderPlainList),
CenterBlock(RenderCenterBlock),
QuoteBlock(RenderQuoteBlock),
SpecialBlock(RenderSpecialBlock),
DynamicBlock(RenderDynamicBlock),
FootnoteDefinition(RenderFootnoteDefinition),
Comment(RenderComment),
Drawer(RenderDrawer),
PropertyDrawer(RenderPropertyDrawer),
Table(RenderTable),
VerseBlock(RenderVerseBlock),
CommentBlock(RenderCommentBlock),
ExampleBlock(RenderExampleBlock),
ExportBlock(RenderExportBlock),
SrcBlock(RenderSrcBlock),
Clock(RenderClock),
DiarySexp(RenderDiarySexp),
Planning(RenderPlanning),
FixedWidthArea(RenderFixedWidthArea),
HorizontalRule(RenderHorizontalRule),
Keyword(RenderKeyword),
BabelCall(RenderBabelCall),
LatexEnvironment(RenderLatexEnvironment),
}
impl RenderElement {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
element: &IElement,
) -> Result<RenderElement, CustomError> {
match element {
IElement::Paragraph(inner) => Ok(RenderElement::Paragraph(RenderParagraph::new(
config,
output_directory,
output_file,
inner,
)?)),
IElement::PlainList(inner) => Ok(RenderElement::PlainList(RenderPlainList::new(
config,
output_directory,
output_file,
inner,
)?)),
IElement::CenterBlock(inner) => Ok(RenderElement::CenterBlock(RenderCenterBlock::new(
config,
output_directory,
output_file,
inner,
)?)),
IElement::QuoteBlock(inner) => Ok(RenderElement::QuoteBlock(RenderQuoteBlock::new(
config,
output_directory,
output_file,
inner,
)?)),
IElement::SpecialBlock(inner) => Ok(RenderElement::SpecialBlock(
RenderSpecialBlock::new(config, output_directory, output_file, inner)?,
)),
IElement::DynamicBlock(inner) => Ok(RenderElement::DynamicBlock(
RenderDynamicBlock::new(config, output_directory, output_file, inner)?,
)),
IElement::FootnoteDefinition(inner) => Ok(RenderElement::FootnoteDefinition(
RenderFootnoteDefinition::new(config, output_directory, output_file, inner)?,
)),
IElement::Comment(inner) => Ok(RenderElement::Comment(RenderComment::new(
config,
output_directory,
output_file,
inner,
)?)),
IElement::Drawer(inner) => Ok(RenderElement::Drawer(RenderDrawer::new(
config,
output_directory,
output_file,
inner,
)?)),
IElement::PropertyDrawer(inner) => Ok(RenderElement::PropertyDrawer(
RenderPropertyDrawer::new(config, output_directory, output_file, inner)?,
)),
IElement::Table(inner) => Ok(RenderElement::Table(RenderTable::new(
config,
output_directory,
output_file,
inner,
)?)),
IElement::VerseBlock(inner) => Ok(RenderElement::VerseBlock(RenderVerseBlock::new(
config,
output_directory,
output_file,
inner,
)?)),
IElement::CommentBlock(inner) => Ok(RenderElement::CommentBlock(
RenderCommentBlock::new(config, output_directory, output_file, inner)?,
)),
IElement::ExampleBlock(inner) => Ok(RenderElement::ExampleBlock(
RenderExampleBlock::new(config, output_directory, output_file, inner)?,
)),
IElement::ExportBlock(inner) => Ok(RenderElement::ExportBlock(RenderExportBlock::new(
config,
output_directory,
output_file,
inner,
)?)),
IElement::SrcBlock(inner) => Ok(RenderElement::SrcBlock(RenderSrcBlock::new(
config,
output_directory,
output_file,
inner,
)?)),
IElement::Clock(inner) => Ok(RenderElement::Clock(RenderClock::new(
config,
output_directory,
output_file,
inner,
)?)),
IElement::DiarySexp(inner) => Ok(RenderElement::DiarySexp(RenderDiarySexp::new(
config,
output_directory,
output_file,
inner,
)?)),
IElement::Planning(inner) => Ok(RenderElement::Planning(RenderPlanning::new(
config,
output_directory,
output_file,
inner,
)?)),
IElement::FixedWidthArea(inner) => Ok(RenderElement::FixedWidthArea(
RenderFixedWidthArea::new(config, output_directory, output_file, inner)?,
)),
IElement::HorizontalRule(inner) => Ok(RenderElement::HorizontalRule(
RenderHorizontalRule::new(config, output_directory, output_file, inner)?,
)),
IElement::Keyword(inner) => Ok(RenderElement::Keyword(RenderKeyword::new(
config,
output_directory,
output_file,
inner,
)?)),
IElement::BabelCall(inner) => Ok(RenderElement::BabelCall(RenderBabelCall::new(
config,
output_directory,
output_file,
inner,
)?)),
IElement::LatexEnvironment(inner) => Ok(RenderElement::LatexEnvironment(
RenderLatexEnvironment::new(config, output_directory, output_file, inner)?,
)),
}
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IEntity;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "entity")]
pub(crate) struct RenderEntity {}
impl RenderEntity {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
comment: &IEntity,
) -> Result<RenderEntity, CustomError> {
Ok(RenderEntity {})
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IExampleBlock;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "example_block")]
pub(crate) struct RenderExampleBlock {}
impl RenderExampleBlock {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
original: &IExampleBlock,
) -> Result<RenderExampleBlock, CustomError> {
Ok(RenderExampleBlock {})
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IExportBlock;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "export_block")]
pub(crate) struct RenderExportBlock {}
impl RenderExportBlock {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
original: &IExportBlock,
) -> Result<RenderExportBlock, CustomError> {
Ok(RenderExportBlock {})
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IExportSnippet;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "export_snippet")]
pub(crate) struct RenderExportSnippet {}
impl RenderExportSnippet {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
comment: &IExportSnippet,
) -> Result<RenderExportSnippet, CustomError> {
Ok(RenderExportSnippet {})
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IFixedWidthArea;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "fixed_width_area")]
pub(crate) struct RenderFixedWidthArea {}
impl RenderFixedWidthArea {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
original: &IFixedWidthArea,
) -> Result<RenderFixedWidthArea, CustomError> {
Ok(RenderFixedWidthArea {})
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IFootnoteDefinition;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "footnote_definition")]
pub(crate) struct RenderFootnoteDefinition {}
impl RenderFootnoteDefinition {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
original: &IFootnoteDefinition,
) -> Result<RenderFootnoteDefinition, CustomError> {
Ok(RenderFootnoteDefinition {})
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IFootnoteReference;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "footnote_reference")]
pub(crate) struct RenderFootnoteReference {}
impl RenderFootnoteReference {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
comment: &IFootnoteReference,
) -> Result<RenderFootnoteReference, CustomError> {
Ok(RenderFootnoteReference {})
}
}

View File

@ -1,24 +0,0 @@
use serde::Serialize;
/// The settings that a "global" to a single dustjs render.
#[derive(Debug, Serialize)]
pub(crate) struct GlobalSettings {
/// The title that goes in the html <title> tag in the <head>.
page_title: Option<String>,
css_files: Vec<String>,
js_files: Vec<String>,
}
impl GlobalSettings {
pub(crate) fn new(
page_title: Option<String>,
css_files: Vec<String>,
js_files: Vec<String>,
) -> GlobalSettings {
GlobalSettings {
page_title,
css_files,
js_files,
}
}
}

View File

@ -1,60 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IHeading;
use super::RenderDocumentElement;
use super::RenderObject;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "heading")]
pub(crate) struct RenderHeading {
level: organic::types::HeadlineLevel,
title: Vec<RenderObject>,
children: Vec<RenderDocumentElement>,
}
impl RenderHeading {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
heading: &IHeading,
) -> Result<RenderHeading, CustomError> {
let title = {
let mut ret = Vec::new();
for obj in heading.title.iter() {
ret.push(RenderObject::new(
config,
&output_directory,
&output_file,
obj,
)?);
}
ret
};
let children = {
let mut ret = Vec::new();
for obj in heading.children.iter() {
ret.push(RenderDocumentElement::new(
config,
&output_directory,
&output_file,
obj,
)?);
}
ret
};
Ok(RenderHeading {
level: heading.level + 1, // Adding 1 because the page title is going to be h1.
title,
children,
})
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IHorizontalRule;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "horizontal_rule")]
pub(crate) struct RenderHorizontalRule {}
impl RenderHorizontalRule {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
original: &IHorizontalRule,
) -> Result<RenderHorizontalRule, CustomError> {
Ok(RenderHorizontalRule {})
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IInlineBabelCall;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "inline_babel_call")]
pub(crate) struct RenderInlineBabelCall {}
impl RenderInlineBabelCall {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
comment: &IInlineBabelCall,
) -> Result<RenderInlineBabelCall, CustomError> {
Ok(RenderInlineBabelCall {})
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IInlineSourceBlock;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "inline_source_block")]
pub(crate) struct RenderInlineSourceBlock {}
impl RenderInlineSourceBlock {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
comment: &IInlineSourceBlock,
) -> Result<RenderInlineSourceBlock, CustomError> {
Ok(RenderInlineSourceBlock {})
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IItalic;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "italic")]
pub(crate) struct RenderItalic {}
impl RenderItalic {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
comment: &IItalic,
) -> Result<RenderItalic, CustomError> {
Ok(RenderItalic {})
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IKeyword;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "keyword")]
pub(crate) struct RenderKeyword {}
impl RenderKeyword {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
keyword: &IKeyword,
) -> Result<RenderKeyword, CustomError> {
Ok(RenderKeyword {})
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::ILatexEnvironment;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "latex_environment")]
pub(crate) struct RenderLatexEnvironment {}
impl RenderLatexEnvironment {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
original: &ILatexEnvironment,
) -> Result<RenderLatexEnvironment, CustomError> {
Ok(RenderLatexEnvironment {})
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::ILatexFragment;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "latex_fragment")]
pub(crate) struct RenderLatexFragment {}
impl RenderLatexFragment {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
comment: &ILatexFragment,
) -> Result<RenderLatexFragment, CustomError> {
Ok(RenderLatexFragment {})
}
}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::ILineBreak;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "line_break")]
pub(crate) struct RenderLineBreak {}
impl RenderLineBreak {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
comment: &ILineBreak,
) -> Result<RenderLineBreak, CustomError> {
Ok(RenderLineBreak {})
}
}

Some files were not shown because too many files have changed in this diff Show More