From 353cb5dfdef1b4b87fc5367b52edbf4cd3f5bff0 Mon Sep 17 00:00:00 2001 From: Jade Date: Sat, 4 Mar 2023 00:28:57 +0100 Subject: [PATCH] removed attempt at rewriting in other template system, it's not that important for now --- Cargo.lock | 22 ------------ Cargo.toml | 1 - flake.nix | 2 +- src/main.rs | 17 +--------- src/templates/mod.rs | 80 -------------------------------------------- 5 files changed, 2 insertions(+), 120 deletions(-) delete mode 100644 src/templates/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 83f9299..9479b4a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1266,27 +1266,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "markup" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd9196a235d499738d04f6a2466ce2610bf6b84730610efea8bee1b90d028b0d" -dependencies = [ - "itoa", - "markup-proc-macro", -] - -[[package]] -name = "markup-proc-macro" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a927f0e237dcbdd8c1a8ab03c4e1e8b1999804c448ebf06ff3b5512506c8150" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "memchr" version = "2.5.0" @@ -1321,7 +1300,6 @@ dependencies = [ "lazy_static", "linkify", "log", - "markup", "mime_guess", "qrcode-generator", "rand", diff --git a/Cargo.toml b/Cargo.toml index 693744e..b1db321 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,6 @@ qrcode-generator = "4.1.6" rust-embed = "6.4.2" mime_guess = "2.0.4" harsh = "0.2" -markup = "0.13" [profile.release] lto = true diff --git a/flake.nix b/flake.nix index 2f907a6..d455ca4 100644 --- a/flake.nix +++ b/flake.nix @@ -14,7 +14,7 @@ { defaultPackage = naersk-lib.buildPackage ./.; devShell = with pkgs; mkShell { - buildInputs = [ cargo rustc rustfmt pre-commit rustPackages.clippy ]; + buildInputs = [ cargo rustc rustfmt pre-commit rustPackages.clippy cargo-watch ]; RUST_SRC_PATH = rustPlatform.rustLibSrc; }; }); diff --git a/src/main.rs b/src/main.rs index b7da678..fd4f412 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,21 +7,18 @@ use crate::endpoints::{ use crate::pasta::Pasta; use crate::util::dbio; use actix_web::middleware::Condition; -use actix_web::{middleware, web, App, HttpServer, HttpResponse, get}; +use actix_web::{middleware, web, App, HttpServer}; use actix_web_httpauth::middleware::HttpAuthentication; use chrono::Local; use env_logger::Builder; use futures::lock::Mutex; use log::LevelFilter; -use templates::BasePage; use std::fs; use std::io::Write; pub mod args; pub mod pasta; -pub mod templates; - pub mod util { pub mod pasta_id_converter; pub mod auth; @@ -111,7 +108,6 @@ async fn main() -> std::io::Result<()> { .wrap(middleware::Logger::default()) .service(remove::remove) .service(pastalist::list) - .service(testtemplate) .wrap(Condition::new( ARGS.auth_username.is_some(), HttpAuthentication::basic(util::auth::auth_validator), @@ -122,14 +118,3 @@ async fn main() -> std::io::Result<()> { .run() .await } - -#[get("/testtemplate")] -async fn testtemplate() -> HttpResponse { - HttpResponse::Ok() - .content_type("text/html") - .body(BasePage { - body: markup::new! { - p "Test content!" - } - }.to_string()) -} diff --git a/src/templates/mod.rs b/src/templates/mod.rs deleted file mode 100644 index 04e21fa..0000000 --- a/src/templates/mod.rs +++ /dev/null @@ -1,80 +0,0 @@ -use crate::args::ARGS; - -markup::define!{ - Create() { - @BasePage { - body: markup::new! { - form [ - id = "pasta-form", - action = "upload", - method = "POST", - enctype = "multipart/form-data", - ] { - br; - } - } - } - } - BasePage( body: Body ) { - @markup::doctype() - html { - head { - title { @ARGS.title } - meta[charset = "utf-8"]; - meta[ - name = "viewport", - content = "width=device-width, initial-scale=1.0" - ]; - link[ - rel = "stylesheet", - href = if let Some(custom_css_url) = ARGS.custom_css.as_ref() { - custom_css_url.clone() - } else { - format!("{}/static/water.css", ARGS.public_path) - } - ]; - } - body[ - style = format!( - "margin:auto;padding-left: 0.5rem;padding-right: 0.5rem;line-height:1.5;font-size: 1.1em;{}", - if ARGS.wide { "1080px" } else { "800px" } - ) - ] { - br; - b[ style = "margin-right: 0.5rem" ] { - @if !ARGS.hide_logo { - a[ href = format!("{}/", ARGS.public_path) ] { - img[ - width = 26, - style = "margin-bottom: -6px; margin-right: 0.5rem;", - src = format!("{}/static/logo.png", ARGS.public_path) - ]; - } - @ARGS.title - } - } - a[ href = format!("{}/", ARGS.public_path), style = "margin-right: 0.5rem; margin-left: 0.5rem" ] "New" - a[ href = format!("{}/pastalist", ARGS.public_path), style = "margin-right: 0.5rem; margin-left: 0.5rem" ] "List" - a[ href = format!("{}/info", ARGS.public_path), style = "margin-right: 0.5rem; margin-left: 0.5rem" ] "Info" - hr; - - @body - - hr; - // TODO: footer text but like with proper markdown and customizability - p[ style = "font-size:smaller" ] { - @if let Some(footer_text) = ARGS.footer_text.as_ref() { - @footer_text - } else { - a[ href = "https://microbin.eu" ] "MicroBin" - " by Dániel Szabó and the FOSS Community." - "Let's keep the Web " - b "compact" ", " - b "accessible" " and " - b "humane" "!" - } - } - } - } - } -}