2024-01-14 02:57:13 +00:00
|
|
|
use actix_web::{get, HttpRequest, Responder};
|
|
|
|
use maud::html;
|
2024-01-16 08:02:23 +00:00
|
|
|
|
2024-01-14 02:57:13 +00:00
|
|
|
mod item;
|
2024-01-16 08:02:23 +00:00
|
|
|
mod pages;
|
|
|
|
mod ui;
|
2024-01-14 02:57:13 +00:00
|
|
|
|
|
|
|
// ░░░░░░░░░░▀▀▀██████▄▄▄░░░░░░░░░░
|
|
|
|
// ░░░░░░░░░░░░░░░░░▀▀▀████▄░░░░░░░
|
|
|
|
// ░░░░░░░░░░▄███████▀░░░▀███▄░░░░░
|
|
|
|
// ░░░░░░░░▄███████▀░░░░░░░▀███▄░░░
|
|
|
|
// ░░░░░░▄████████░░░░░░░░░░░███▄░░
|
2024-01-16 08:02:23 +00:00
|
|
|
// ░░░░░██████████▄░░░░░░░░░░░███▌░ ▒█▀▀█ █▀▀█ █▀▄▀█ █▀▄▀█ ▒█▀▀▄ ▒█▀▀█
|
|
|
|
// ░░░░░▀█████▀░▀███▄░░░░░░░░░▐███░ ▒█░░░ █░░█ █░▀░█ █░▀░█ ▒█░▒█ ▒█▀▀▄
|
2024-01-14 02:57:13 +00:00
|
|
|
// ░░░░░░░▀█▀░░░░░▀███▄░░░░░░░▐███░ ▒█▄▄█ ▀▀▀▀ ▀░░░▀ ▀░░░▀ ▒█▄▄▀ ▒█▄▄█
|
|
|
|
// ░░░░░░░░░░░░░░░░░▀███▄░░░░░███▌░
|
|
|
|
// ░░░░▄██▄░░░░░░░░░░░▀███▄░░▐███░░
|
|
|
|
// ░░▄██████▄░░░░░░░░░░░▀███▄███░░░
|
|
|
|
// ░█████▀▀████▄▄░░░░░░░░▄█████░░░░
|
|
|
|
// ░████▀░░░▀▀█████▄▄▄▄█████████▄░░
|
|
|
|
// ░░▀▀░░░░░░░░░▀▀██████▀▀░░░▀▀██░░
|
|
|
|
|
|
|
|
#[get("/")]
|
|
|
|
pub(crate) async fn index(r: HttpRequest) -> impl Responder {
|
|
|
|
let itemdb: &actix_web::web::Data<item::ItemDB> = r.app_data().unwrap();
|
|
|
|
|
|
|
|
let content = html!(
|
|
|
|
p class="text-xl font-bold" { "Hello World" };
|
|
|
|
@for item in itemdb.items() {
|
|
|
|
a href=(format!("/item/{}", item)) { (item) };
|
|
|
|
}
|
|
|
|
)
|
|
|
|
.into_string();
|
|
|
|
web_base::func::build_site(&r, "Index", &content)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[actix_web::main]
|
|
|
|
async fn main() -> std::io::Result<()> {
|
|
|
|
env_logger::init();
|
|
|
|
|
2024-01-16 08:02:23 +00:00
|
|
|
let itemdb = item::ItemDB::new("./itemdb", "mongodb://user:pass@127.0.0.1:27017").await;
|
2024-01-14 02:57:13 +00:00
|
|
|
let itemdb = actix_web::web::Data::new(itemdb);
|
|
|
|
|
|
|
|
web_base::map!(
|
|
|
|
web_base::Site::new()
|
|
|
|
.head_content("<script src=\"https://cdn.tailwindcss.com\"></script>".to_string()),
|
2024-01-16 08:02:23 +00:00
|
|
|
|app: actix_web::App<_>| {
|
|
|
|
app.app_data(itemdb.clone())
|
|
|
|
.service(index)
|
|
|
|
.service(pages::item::item_page)
|
|
|
|
.service(pages::item::variant_pages::add_item_variant_page)
|
|
|
|
.service(pages::item::variant_pages::add_item_variant_page_post)
|
|
|
|
.service(pages::item::inventory_page::add_item_inventory_page)
|
|
|
|
.service(pages::item::inventory_page::add_item_inventory_page_post)
|
|
|
|
}
|
2024-01-14 02:57:13 +00:00
|
|
|
)
|
|
|
|
.bind(("0.0.0.0".to_string(), 8080))?
|
|
|
|
.run()
|
|
|
|
.await
|
|
|
|
}
|