Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use MC Number Formatting short code #1

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions mail-handler/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use imap::types::{AttributeValue, UnsolicitedResponse};
use mail_parser::MessageParser;
use std::{fs, io};
use std::io::Write;
use std::process::Command;
use std::{fs, io};

fn rebuild_zola() {
let output = Command::new("sh")
Expand All @@ -14,9 +14,12 @@ fn rebuild_zola() {
))
.output()
.expect("failed to execute zola build");
io::stdout().write_all(&output. stdout).unwrap();
io::stderr().write_all(&output. stderr).unwrap();
println!("Wrote zola output to {}", dotenv::var("WWW_OUT_DIR").unwrap());
io::stdout().write_all(&output.stdout).unwrap();
io::stderr().write_all(&output.stderr).unwrap();
println!(
"Wrote zola output to {}",
dotenv::var("WWW_OUT_DIR").unwrap()
);
}

fn post_file_contents(
Expand All @@ -27,17 +30,14 @@ fn post_file_contents(
html: &str,
) -> String {
let date_fmt = format!("{}-{}-{}", date.year, date.month, date.day);
let author_fmt = if is_not_anon { from_addr } else { "anonymous" };
format!(
"+++
title = \"{}\"
date = \"{}\"
authors = [\"{}\"]
title = \"{number}\"
date = \"{date_fmt}\"
authors = [\"{author_fmt}\"]
+++
{}",
number,
date_fmt,
if is_not_anon { from_addr } else { "anonymous" },
html
{{{ number(number=\"{number}\") }}}} {html}"
)
}

Expand Down Expand Up @@ -146,7 +146,9 @@ fn main() -> imap::error::Result<()> {
)
.unwrap();
rebuild_zola();
inner_session.store(format!("{}", id), "+FLAGS (\\Deleted)").unwrap();
inner_session
.store(format!("{}", id), "+FLAGS (\\Deleted)")
.unwrap();
inner_session.expunge().unwrap();
}
}
Expand Down