removed attempt at rewriting in other template system, it's not that important for now

This commit is contained in:
Schrottkatze 2023-03-04 00:28:57 +01:00
parent 1f2589976d
commit 353cb5dfde
5 changed files with 2 additions and 120 deletions

22
Cargo.lock generated
View file

@ -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",

View file

@ -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

View file

@ -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;
};
});

View file

@ -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())
}

View file

@ -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: markup::Render>( 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" "!"
}
}
}
}
}
}