Compare commits

...

5 Commits

Author SHA1 Message Date
1210f7038a Bumping version to 0.0.7 2024-09-01 16:09:14 -07:00
f9ab7284a3 web: remove obsolete Makefile 2024-09-01 16:09:04 -07:00
100865c923 server: use same html cleanup idiom in nm as we do in newreader 2024-09-01 16:08:25 -07:00
b8c1710a83 dev: watch for git commits and rebuild on change 2024-09-01 16:07:22 -07:00
215b8cd41d shared: ignore dirty, if git is present we're developing
When developing dirty can get out of between client and server if you're
only doing development in one.
2024-09-01 15:57:02 -07:00
10 changed files with 59 additions and 40 deletions

10
Cargo.lock generated
View File

@ -2034,7 +2034,7 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]] [[package]]
name = "letterbox" name = "letterbox"
version = "0.0.6" version = "0.0.7"
dependencies = [ dependencies = [
"build-info", "build-info",
"build-info-build", "build-info-build",
@ -2393,7 +2393,7 @@ dependencies = [
[[package]] [[package]]
name = "notmuch" name = "notmuch"
version = "0.0.6" version = "0.0.7"
dependencies = [ dependencies = [
"itertools", "itertools",
"log", "log",
@ -2983,7 +2983,7 @@ dependencies = [
[[package]] [[package]]
name = "procmail2notmuch" name = "procmail2notmuch"
version = "0.0.6" version = "0.0.7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
] ]
@ -3750,7 +3750,7 @@ dependencies = [
[[package]] [[package]]
name = "server" name = "server"
version = "0.0.6" version = "0.0.7"
dependencies = [ dependencies = [
"ammonia", "ammonia",
"anyhow", "anyhow",
@ -3835,7 +3835,7 @@ dependencies = [
[[package]] [[package]]
name = "shared" name = "shared"
version = "0.0.6" version = "0.0.7"
dependencies = [ dependencies = [
"build-info", "build-info",
"notmuch", "notmuch",

4
dev.sh
View File

@ -1,7 +1,7 @@
cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"
tmux new-session -d -s letterbox-dev tmux new-session -d -s letterbox-dev
tmux rename-window web tmux rename-window web
tmux send-keys "cd web; trunk serve -w ../shared -w ../notmuch -w ./" C-m tmux send-keys "cd web; trunk serve -w ../.git -w ../shared -w ../notmuch -w ./" C-m
tmux new-window -n server tmux new-window -n server
tmux send-keys "cd server; cargo watch -c -x run -w ../shared -w ../notmuch -w ./" C-m tmux send-keys "cd server; cargo watch -c -x run -w ../.git -w ../shared -w ../notmuch -w ./" C-m
tmux attach -d -t letterbox-dev tmux attach -d -t letterbox-dev

View File

@ -1,6 +1,6 @@
[package] [package]
name = "notmuch" name = "notmuch"
version = "0.0.6" version = "0.0.7"
edition = "2021" 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

View File

@ -1,6 +1,6 @@
[package] [package]
name = "procmail2notmuch" name = "procmail2notmuch"
version = "0.0.6" version = "0.0.7"
edition = "2021" 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

View File

@ -1,6 +1,6 @@
[package] [package]
name = "server" name = "server"
version = "0.0.6" version = "0.0.7"
edition = "2021" edition = "2021"
default-run = "server" default-run = "server"

View File

@ -17,7 +17,7 @@ use crate::{
Attachment, Body, DispositionType, Email, EmailThread, Header, Html, Message, PlainText, Attachment, Body, DispositionType, Email, EmailThread, Header, Html, Message, PlainText,
Tag, Thread, ThreadSummary, UnhandledContentType, Tag, Thread, ThreadSummary, UnhandledContentType,
}, },
linkify_html, sanitize_html, linkify_html, InlineStyle, SanitizeHtml, Transformer,
}; };
const TEXT_PLAIN: &'static str = "text/plain"; const TEXT_PLAIN: &'static str = "text/plain";
@ -169,17 +169,29 @@ pub async fn thread(
}; };
Body::Html(Html { Body::Html(Html {
html: format!( html: {
r#"<p class="view-part-text-plain">{}</p>"#, let body_tranformers: Vec<Box<dyn Transformer>> = vec![
// Trim newlines to prevent excessive white space at the beginning/end of Box::new(InlineStyle),
// presenation. Leave tabs and spaces incase plain text attempts to center a Box::new(SanitizeHtml {
// header on the first line. cid_prefix: &cid_prefix,
sanitize_html( base_url: &base_url,
&linkify_html(&text.trim_matches('\n')), }),
&cid_prefix, ];
&base_url let mut html = linkify_html(&text.trim_matches('\n'));
)? for t in body_tranformers.iter() {
), if t.should_run(&None, &html) {
html = t.transform(&None, &html).await?;
}
}
format!(
r#"<p class="view-part-text-plain">{}</p>"#,
// Trim newlines to prevent excessive white space at the beginning/end of
// presenation. Leave tabs and spaces incase plain text attempts to center a
// header on the first line.
html
)
},
content_tree: if debug_content_tree { content_tree: if debug_content_tree {
render_content_type_tree(&m) render_content_type_tree(&m)
} else { } else {
@ -187,8 +199,27 @@ pub async fn thread(
}, },
}) })
} }
Body::Html(Html { html, content_tree }) => Body::Html(Html { Body::Html(Html {
html: sanitize_html(&html, &cid_prefix, &base_url)?, mut html,
content_tree,
}) => Body::Html(Html {
html: {
let body_tranformers: Vec<Box<dyn Transformer>> = vec![
// TODO: this breaks things like emails from calendar
//Box::new(InlineStyle),
Box::new(SanitizeHtml {
cid_prefix: &cid_prefix,
base_url: &base_url,
}),
];
for t in body_tranformers.iter() {
if t.should_run(&None, &html) {
html = t.transform(&None, &html).await?;
}
}
html
},
content_tree: if debug_content_tree { content_tree: if debug_content_tree {
render_content_type_tree(&m) render_content_type_tree(&m)
} else { } else {

View File

@ -1,6 +1,6 @@
[package] [package]
name = "shared" name = "shared"
version = "0.0.6" version = "0.0.7"
edition = "2021" 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

View File

@ -1,5 +1,5 @@
use build_info::{BuildInfo, VersionControl};
use notmuch::SearchSummary; use notmuch::SearchSummary;
use build_info::{VersionControl,BuildInfo};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
@ -34,16 +34,12 @@ pub mod urls {
} }
} }
} }
pub fn build_version(bi:fn()->&'static BuildInfo) -> String { pub fn build_version(bi: fn() -> &'static BuildInfo) -> String {
fn commit(git: &Option<VersionControl>) -> String { fn commit(git: &Option<VersionControl>) -> String {
let Some(VersionControl::Git(git)) = git else { let Some(VersionControl::Git(git)) = git else {
return String::new(); return String::new();
}; };
let mut s = vec!["-".to_string(), git.commit_short_id.clone()]; let mut s = vec!["-".to_string(), git.commit_short_id.clone()];
if git.dirty {
s.push(".+".to_string());
}
if let Some(branch) = &git.branch { if let Some(branch) = &git.branch {
s.push(format!(" ({branch})")); s.push(format!(" ({branch})"));
} }

View File

@ -1,5 +1,5 @@
[package] [package]
version = "0.0.6" version = "0.0.7"
name = "letterbox" name = "letterbox"
repository = "https://github.com/seed-rs/seed-quickstart" repository = "https://github.com/seed-rs/seed-quickstart"
authors = ["Bill Thiede <git@xinu.tv>"] authors = ["Bill Thiede <git@xinu.tv>"]

View File

@ -1,8 +0,0 @@
.PHONY: all
APP=letterbox
# Build in release mode and push to minio for serving.
all:
trunk build --release
mc mirror m/$(APP)/ /tmp/$(APP)-$(shell date +%s)
mc mirror --overwrite --remove dist/ m/$(APP)/