Compare commits
No commits in common. "main" and "custom_content" have entirely different histories.
main
...
custom_con
11 changed files with 37 additions and 87 deletions
10
CONFIG.md
10
CONFIG.md
|
@ -8,9 +8,7 @@ title = "bingus-blog" # title of the blog
|
|||
description = "blazingly fast markdown blog software written in rust memory safe"
|
||||
markdown_access = true # allow users to see the raw markdown of a post
|
||||
# endpoint: /posts/<name>.md
|
||||
js_enable = true # enable javascript (required for sorting and dates)
|
||||
|
||||
[style]
|
||||
js_enable = true # enable javascript (required for below 2 options)
|
||||
date_format = "RFC3339" # format string used to format dates in the backend
|
||||
# it's highly recommended to leave this as default,
|
||||
# so the date can be formatted by the browser.
|
||||
|
@ -18,10 +16,6 @@ date_format = "RFC3339" # format string used to format dates in the backend
|
|||
default_sort = "date" # default sorting method ("date" or "name")
|
||||
#default_color = "#f5c2e7" # default embed color, optional
|
||||
|
||||
[style.display_dates]
|
||||
creation = true # display creation ("written") dates
|
||||
modification = true # display modified ("last modified") dates
|
||||
|
||||
[rss]
|
||||
enable = false # serve an rss field under /feed.xml
|
||||
# this may be a bit resource intensive
|
||||
|
@ -60,7 +54,7 @@ a default value
|
|||
you don't have to copy the whole thing from here,
|
||||
it's generated by the program if it doesn't exist
|
||||
|
||||
## Specifying the configuration file
|
||||
## Specifying Configuration
|
||||
|
||||
the configuration file is loaded from `config.toml` by default, but the path
|
||||
can be overriden by setting the environment variable `BINGUS_BLOG_CONFIG`,
|
||||
|
|
|
@ -17,7 +17,7 @@ for bingus-blog viewers: [see original document](https://git.slonk.ing/slonk/bin
|
|||
can write posts from anywhere and sync it with the server without headache
|
||||
- RSS is supported
|
||||
- the look of the blog is extremely customizable, with support for
|
||||
[custom drop-ins](CUSTOM.md) for both templates and static content
|
||||
[custom drop-ins](/CUSTOM.md) for both templates and static content
|
||||
- really easy to deploy (the server is one executable file)
|
||||
- blazingly fast
|
||||
|
||||
|
@ -26,20 +26,18 @@ for bingus-blog viewers: [see original document](https://git.slonk.ing/slonk/bin
|
|||
- [ ] blog thumbnail and favicon
|
||||
- [ ] sort asc/desc
|
||||
- [ ] extend syntect options
|
||||
- [ ] ^ fix syntect mutex poisoning
|
||||
- [ ] better error reporting and error pages
|
||||
- [ ] better tracing
|
||||
- [ ] replace HashMap with HashCache once i implement [this](https://github.com/wvwwvwwv/scalable-concurrent-containers/issues/139)
|
||||
- [ ] make date parsing less strict
|
||||
- [ ] improve home page
|
||||
- [ ] multi-language support
|
||||
- [ ] add credits
|
||||
- [x] be blazingly fast
|
||||
- [x] 100+ MiB binary size
|
||||
|
||||
## Configuration
|
||||
|
||||
see [CONFIG.md](CONFIG.md)
|
||||
see [CONFIG.md](/CONFIG.md)
|
||||
|
||||
## Building
|
||||
|
||||
|
@ -54,7 +52,7 @@ cargo +nightly build --release
|
|||
|
||||
the executable will be located at `target/release/bingus-blog`.
|
||||
|
||||
see [BUILDING.md](BUILDING.md) for more information and detailed instructions.
|
||||
see [BUILDING.md](/BUILDING.md) for more information and detailed instructions.
|
||||
|
||||
## Writing Posts
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<div class="table">
|
||||
{{#if (and (ne this.created_at null) style.display_dates.creation)}}
|
||||
{{#if (ne this.created_at null)}}
|
||||
<div class="created">written</div>
|
||||
<div class="created value">{{>span_date dt=this.created_at df=style.date_format}}</div>
|
||||
<div class="created value">{{>span_date date_time=this.created_at}}</div>
|
||||
{{/if}}
|
||||
{{#if (and (ne this.modified_at null) style.display_dates.modification)}}
|
||||
{{#if (ne this.modified_at null)}}
|
||||
<div class="modified">last modified</div>
|
||||
<div class="modified value">{{>span_date dt=this.modified_at df=style.date_format}}</div>
|
||||
<div class="modified value">{{>span_date date_time=this.modified_at}}</div>
|
||||
{{/if}}
|
||||
{{#if (gt (len this.tags) 0)}}
|
||||
<div class="tags">tags</div>
|
||||
|
|
|
@ -1 +1 @@
|
|||
<span class="date {{#if (eq df "RFC3339")}}date-rfc3339{{/if}}">{{date dt df}}</span>
|
||||
<span class="date {{#if (eq df "RFC3339")}}date-rfc3339{{/if}}">{{date date_time df}}</span>
|
||||
|
|
19
src/app.rs
19
src/app.rs
|
@ -19,7 +19,7 @@ use tower_http::services::ServeDir;
|
|||
use tower_http::trace::TraceLayer;
|
||||
use tracing::{info, info_span, Span};
|
||||
|
||||
use crate::config::{Config, StyleConfig};
|
||||
use crate::config::{Config, DateFormat, Sort};
|
||||
use crate::error::{AppError, AppResult};
|
||||
use crate::post::{MarkdownPosts, PostManager, PostMetadata, RenderStats, ReturnedPost};
|
||||
use crate::serve_dir_included::handle;
|
||||
|
@ -40,10 +40,12 @@ struct IndexTemplate<'a> {
|
|||
description: &'a str,
|
||||
posts: Vec<PostMetadata>,
|
||||
rss: bool,
|
||||
df: &'a DateFormat,
|
||||
js: bool,
|
||||
color: Option<&'a str>,
|
||||
sort: Sort,
|
||||
tags: Map<String, serde_json::Value>,
|
||||
joined_tags: String,
|
||||
style: &'a StyleConfig,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
@ -52,10 +54,10 @@ struct PostTemplate<'a> {
|
|||
rendered: String,
|
||||
rendered_in: RenderStats,
|
||||
markdown_access: bool,
|
||||
df: &'a DateFormat,
|
||||
js: bool,
|
||||
color: Option<&'a str>,
|
||||
joined_tags: String,
|
||||
style: &'a StyleConfig,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
@ -126,10 +128,12 @@ async fn index<'a>(
|
|||
description: &config.description,
|
||||
posts,
|
||||
rss: config.rss.enable,
|
||||
df: &config.date_format,
|
||||
js: config.js_enable,
|
||||
color: config.default_color.as_deref(),
|
||||
sort: config.default_sort,
|
||||
tags,
|
||||
joined_tags,
|
||||
style: &config.style,
|
||||
},
|
||||
);
|
||||
drop(reg);
|
||||
|
@ -224,13 +228,10 @@ async fn post(
|
|||
rendered,
|
||||
rendered_in,
|
||||
markdown_access: config.markdown_access,
|
||||
df: &config.date_format,
|
||||
js: config.js_enable,
|
||||
color: meta
|
||||
.color
|
||||
.as_deref()
|
||||
.or(config.style.default_color.as_deref()),
|
||||
color: meta.color.as_deref().or(config.default_color.as_deref()),
|
||||
joined_tags,
|
||||
style: &config.style,
|
||||
},
|
||||
);
|
||||
drop(reg);
|
||||
|
|
|
@ -76,23 +76,6 @@ pub enum Sort {
|
|||
Name,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
#[serde(default)]
|
||||
#[derive(Default)]
|
||||
pub struct StyleConfig {
|
||||
pub display_dates: DisplayDates,
|
||||
pub date_format: DateFormat,
|
||||
pub default_sort: Sort,
|
||||
pub default_color: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
#[serde(default)]
|
||||
pub struct DisplayDates {
|
||||
pub creation: bool,
|
||||
pub modification: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
#[serde(default)]
|
||||
pub struct Config {
|
||||
|
@ -100,7 +83,9 @@ pub struct Config {
|
|||
pub description: String,
|
||||
pub markdown_access: bool,
|
||||
pub js_enable: bool,
|
||||
pub style: StyleConfig,
|
||||
pub date_format: DateFormat,
|
||||
pub default_sort: Sort,
|
||||
pub default_color: Option<String>,
|
||||
pub rss: RssConfig,
|
||||
pub dirs: DirsConfig,
|
||||
pub http: HttpConfig,
|
||||
|
@ -115,7 +100,9 @@ impl Default for Config {
|
|||
description: "blazingly fast markdown blog software written in rust memory safe".into(),
|
||||
markdown_access: true,
|
||||
js_enable: true,
|
||||
style: Default::default(),
|
||||
date_format: Default::default(),
|
||||
default_sort: Default::default(),
|
||||
default_color: None,
|
||||
// i have a love-hate relationship with serde
|
||||
// it was engimatic at first, but then i started actually using it
|
||||
// writing my own serialize and deserialize implementations.. spending
|
||||
|
@ -134,16 +121,6 @@ impl Default for Config {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for DisplayDates {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
creation: true,
|
||||
modification: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl Default for DirsConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
|
|
|
@ -29,7 +29,7 @@ fn is_ext(path: impl AsRef<Path>, ext: &str) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_template_name(path: &Path) -> Option<&str> {
|
||||
pub(self) fn get_template_name<'a>(path: &'a Path) -> Option<&'a str> {
|
||||
if !is_ext(path, "hbs") {
|
||||
return None;
|
||||
}
|
||||
|
@ -47,10 +47,10 @@ fn register_included_file(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn register_path(
|
||||
fn register_path<'a>(
|
||||
path: impl AsRef<std::path::Path>,
|
||||
name: &str,
|
||||
registry: &mut Handlebars<'_>,
|
||||
registry: &mut Handlebars<'a>,
|
||||
) -> Result<(), TemplateError> {
|
||||
let template = compile_path(path)?;
|
||||
registry.register_template(name, template);
|
||||
|
@ -85,7 +85,7 @@ fn compile_path(path: impl AsRef<std::path::Path>) -> Result<Template, TemplateE
|
|||
Ok(template)
|
||||
}
|
||||
|
||||
async fn compile_path_async_io(
|
||||
pub(self) async fn compile_path_async_io(
|
||||
path: impl AsRef<std::path::Path>,
|
||||
) -> Result<Template, TemplateError> {
|
||||
use tokio::fs::OpenOptions;
|
||||
|
|
|
@ -54,22 +54,3 @@ th,
|
|||
td:nth-child(1) {
|
||||
word-break: keep-all;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
margin-left: 1em;
|
||||
padding-left: 1.5em;
|
||||
border-left: 0.5em solid;
|
||||
border-color: var(--blue);
|
||||
& > blockquote {
|
||||
border-color: var(--mauve);
|
||||
& > blockquote {
|
||||
border-color: var(--pink);
|
||||
& > blockquote {
|
||||
border-color: var(--rosewater);
|
||||
& > blockquote {
|
||||
border-color: var(--text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/* colors from catppuccin https://github.com/catppuccin/catppuccin
|
||||
licensed under the MIT license, available in the source tree */
|
||||
/* colors */
|
||||
:root {
|
||||
--base: #1e1e2e;
|
||||
--text: #cdd6f4;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<meta property="og:description" content="{{description}}" />
|
||||
<meta name="keywords" content="{{joined_tags}}" />
|
||||
{{#if (ne color null)}}
|
||||
<meta name="theme-color" content="{{style.color}}" />
|
||||
<meta name="theme-color" content="{{color}}" />
|
||||
{{/if}}
|
||||
<title>{{title}}</title>
|
||||
<link rel="stylesheet" href="/static/style.css" />
|
||||
|
@ -30,9 +30,9 @@
|
|||
<form id="sort" style="display: none">
|
||||
sort by: {{sort}}
|
||||
<br />
|
||||
<input type="radio" name="sort" id="sort-date" value="date" {{#if (eq style.default_sort "date")}}checked{{/if}} />
|
||||
<input type="radio" name="sort" id="sort-date" value="date" {{#if (eq sort "date")}}checked{{/if}} />
|
||||
<label for="sort-date">date</label>
|
||||
<input type="radio" name="sort" id="sort-name" value="name" {{#if (eq style.default_sort "name")}}checked{{/if}} />
|
||||
<input type="radio" name="sort" id="sort-name" value="name" {{#if (eq sort "name")}}checked{{/if}} />
|
||||
<label for="sort-name">name</label>
|
||||
</form>
|
||||
{{/if}}
|
||||
|
@ -43,7 +43,7 @@
|
|||
<span class="post-author">- by {{author}}</span>
|
||||
<br />
|
||||
{{description}}<br />
|
||||
{{>post_table post style=@root.style}}
|
||||
{{>post_table post df=@root.df}}
|
||||
</div>
|
||||
</div>
|
||||
{{else}} there are no posts right now. check back later! {{/each}}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<meta property="twitter:image:alt" content="{{meta.icon_alt}}" />
|
||||
{{/if}}{{/if}}
|
||||
{{#if (ne color null)}}
|
||||
<meta name="theme-color" content="{{color}}" />
|
||||
<meta name="theme-color" content="{{meta.color}}" />
|
||||
{{/if}}
|
||||
<title>{{meta.title}}</title>
|
||||
<link rel="stylesheet" href="/static/style.css" />
|
||||
|
@ -41,7 +41,7 @@
|
|||
</h1>
|
||||
<p class="post-desc">{{meta.description}}</p>
|
||||
<div class="post">
|
||||
{{>post_table meta style=@root.style}}
|
||||
{{>post_table meta df=@root.df}}
|
||||
<a href="/posts/{{meta.name}}">link</a><br />
|
||||
<a href="/">back to home</a>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue