From 7f78d26924cdc1113f95ae46f31f8ca230c14df9 Mon Sep 17 00:00:00 2001
From: Darius Auding <Darius.auding@gmx.de>
Date: Wed, 26 Jul 2023 17:41:54 +0200
Subject: [PATCH] Finished

---
 core/codegen/.gitignore              |  1 -
 core/codegen/Cargo.lock              |  7 ---
 core/codegen/Cargo.toml              |  8 ---
 core/codegen/src/lib.rs              | 14 ------
 core/html/.gitignore                 |  1 -
 core/html/Cargo.lock                 |  7 ---
 core/html/Cargo.toml                 |  8 ---
 core/html/src/lib.rs                 | 14 ------
 core/http/Cargo.toml                 |  4 +-
 core/http/src/utils/url_utils/uri.rs |  1 -
 generatersenum.py                    | 73 ----------------------------
 site/Cargo.lock                      |  4 +-
 site/Cargo.toml                      |  2 +-
 site/src/main.rs                     | 33 +++++++------
 small.csv                            | 20 --------
 tree.txt                             | 44 -----------------
 16 files changed, 24 insertions(+), 217 deletions(-)
 delete mode 100644 core/codegen/.gitignore
 delete mode 100644 core/codegen/Cargo.lock
 delete mode 100644 core/codegen/Cargo.toml
 delete mode 100644 core/codegen/src/lib.rs
 delete mode 100644 core/html/.gitignore
 delete mode 100644 core/html/Cargo.lock
 delete mode 100644 core/html/Cargo.toml
 delete mode 100644 core/html/src/lib.rs
 delete mode 100644 generatersenum.py
 delete mode 100644 small.csv
 delete mode 100644 tree.txt

diff --git a/core/codegen/.gitignore b/core/codegen/.gitignore
deleted file mode 100644
index ea8c4bf..0000000
--- a/core/codegen/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/target
diff --git a/core/codegen/Cargo.lock b/core/codegen/Cargo.lock
deleted file mode 100644
index 0f1eef0..0000000
--- a/core/codegen/Cargo.lock
+++ /dev/null
@@ -1,7 +0,0 @@
-# This file is automatically @generated by Cargo.
-# It is not intended for manual editing.
-version = 3
-
-[[package]]
-name = "codegen"
-version = "0.1.0"
diff --git a/core/codegen/Cargo.toml b/core/codegen/Cargo.toml
deleted file mode 100644
index d233c6a..0000000
--- a/core/codegen/Cargo.toml
+++ /dev/null
@@ -1,8 +0,0 @@
-[package]
-name = "codegen"
-version = "0.1.0"
-edition = "2021"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
diff --git a/core/codegen/src/lib.rs b/core/codegen/src/lib.rs
deleted file mode 100644
index 7d12d9a..0000000
--- a/core/codegen/src/lib.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-pub fn add(left: usize, right: usize) -> usize {
-    left + right
-}
-
-#[cfg(test)]
-mod tests {
-    use super::*;
-
-    #[test]
-    fn it_works() {
-        let result = add(2, 2);
-        assert_eq!(result, 4);
-    }
-}
diff --git a/core/html/.gitignore b/core/html/.gitignore
deleted file mode 100644
index ea8c4bf..0000000
--- a/core/html/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/target
diff --git a/core/html/Cargo.lock b/core/html/Cargo.lock
deleted file mode 100644
index bcf40f4..0000000
--- a/core/html/Cargo.lock
+++ /dev/null
@@ -1,7 +0,0 @@
-# This file is automatically @generated by Cargo.
-# It is not intended for manual editing.
-version = 3
-
-[[package]]
-name = "html"
-version = "0.1.0"
diff --git a/core/html/Cargo.toml b/core/html/Cargo.toml
deleted file mode 100644
index d593c98..0000000
--- a/core/html/Cargo.toml
+++ /dev/null
@@ -1,8 +0,0 @@
-[package]
-name = "html"
-version = "0.1.0"
-edition = "2021"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
diff --git a/core/html/src/lib.rs b/core/html/src/lib.rs
deleted file mode 100644
index 7d12d9a..0000000
--- a/core/html/src/lib.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-pub fn add(left: usize, right: usize) -> usize {
-    left + right
-}
-
-#[cfg(test)]
-mod tests {
-    use super::*;
-
-    #[test]
-    fn it_works() {
-        let result = add(2, 2);
-        assert_eq!(result, 4);
-    }
-}
diff --git a/core/http/Cargo.toml b/core/http/Cargo.toml
index 4d7fb4f..8f14568 100644
--- a/core/http/Cargo.toml
+++ b/core/http/Cargo.toml
@@ -1,10 +1,10 @@
 [package]
 name = "http"
-version = "0.1.0"
+version = "1.0.0"
 edition = "2021"
 
 [features]
-defautl = []
+default = []
 secure = []
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
diff --git a/core/http/src/utils/url_utils/uri.rs b/core/http/src/utils/url_utils/uri.rs
index 0a36f30..e0a1cbf 100644
--- a/core/http/src/utils/url_utils/uri.rs
+++ b/core/http/src/utils/url_utils/uri.rs
@@ -191,7 +191,6 @@ impl FromStr for RawUri {
                 .parts
                 .push(RawUriElement::Name(UrlEncodeData::from_raw(part)))
         }
-        println!("{:?}", result);
         Ok(result)
     }
 }
diff --git a/generatersenum.py b/generatersenum.py
deleted file mode 100644
index 2c686bd..0000000
--- a/generatersenum.py
+++ /dev/null
@@ -1,73 +0,0 @@
-import csv
-
-
-def generate_rust_enum(csv_file):
-    rust_enum = "use phf::phf_map;\n\nenum Mime {\n"
-
-    with open(csv_file, "r") as file:
-        csv_data = csv.reader(file)
-        next(csv_data)  # Skip the header row
-
-        for row in csv_data:
-            if row[1] == "":
-                continue
-            if "DEPRECATED" in row[0]:
-                continue
-            name = format_enum_member(row[0:2])
-            rust_enum += f"\t{name},\n"
-
-    rust_enum += "}\n\n"
-    rust_enum += "impl std::fmt::Display for Mime {\n"
-    rust_enum += "\tfn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {\n"
-    rust_enum += "\t\tmatch self {\n"
-
-    with open(csv_file, "r") as file:
-        csv_data = csv.reader(file)
-        next(csv_data)  # Skip the header row
-        for row in csv_data:
-            if row[1] == "":
-                continue
-            if "DEPRECATED" in row[0]:
-                continue
-            name = format_enum_member(row[0:2])
-            rust_enum += f'\t\t\tMime::{name} => write!(f, "{row[1]}"),\n'
-
-    rust_enum += "\t\t}\n\t}\n}\n\n"
-
-    rust_enum += "static MimeMap: phf::Map<&'static str, Mime> = phf_map! {\n"
-    with open(csv_file, "r") as file:
-        csv_data = csv.reader(file)
-        next(csv_data)
-        for row in csv_data:
-            if row[1] == "":
-                continue
-            if "DEPRECATED" in row[0]:
-                continue
-            key = row[1]
-            value = format_enum_member(row[0:2])
-            rust_enum += f'\t"{key}" => Mime::{value},\n'
-    rust_enum += "};"
-
-    return rust_enum
-
-
-def format_enum_member(name):
-    prefix = "".join(name[1].split("/")[0:-1])
-    name = name[0].split("-")
-    words = []
-    parts = []
-    for part in name:
-        parts += part.split("+")
-    for part in parts:
-        words += part.split(".")
-
-    formatted_name = "".join(word.capitalize() for word in words)
-    if not formatted_name.startswith(prefix.capitalize()):
-        formatted_name = prefix.capitalize() + formatted_name
-    return formatted_name
-
-
-# Usage example
-csv_file = "mimes.csv"
-rust_enum_code = generate_rust_enum(csv_file)
-print(rust_enum_code)
diff --git a/site/Cargo.lock b/site/Cargo.lock
index 8373d43..f0357c6 100644
--- a/site/Cargo.lock
+++ b/site/Cargo.lock
@@ -110,7 +110,7 @@ checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b"
 
 [[package]]
 name = "http"
-version = "0.1.0"
+version = "1.0.0"
 dependencies = [
  "phf",
  "tokio",
@@ -457,7 +457,7 @@ checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de"
 
 [[package]]
 name = "site"
-version = "0.1.0"
+version = "1.0.0"
 dependencies = [
  "http",
  "tokio",
diff --git a/site/Cargo.toml b/site/Cargo.toml
index 1d8b400..999203e 100644
--- a/site/Cargo.toml
+++ b/site/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "site"
-version = "0.1.0"
+version = "1.0.0"
 edition = "2021"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
diff --git a/site/src/main.rs b/site/src/main.rs
index 2437a50..d494b89 100644
--- a/site/src/main.rs
+++ b/site/src/main.rs
@@ -1,12 +1,12 @@
 use http::handling::{
-    methods::Method, 
-    routes::{Route, Data},
+    file_handlers::NamedFile,
+    methods::Method,
     request::Request,
-    response::{Response, Outcome, Status}, 
-    file_handlers::NamedFile};
+    response::{Outcome, Response, Status},
+    routes::{Data, Route},
+};
 
 fn static_files_handler(request: Request, _data: Data) -> Outcome<Response, Status, Data> {
-    println!("{:?} {}", request.uri, request.uri);
     let response = static_files(&request.uri.to_string());
     let response = match response {
         Ok(dat) => Response {
@@ -25,19 +25,24 @@ fn static_files(path: &str) -> Result<NamedFile, Status> {
 }
 
 fn index_handler(_request: Request, _data: Data) -> Outcome<Response, Status, Data> {
-    Outcome::Success(Response { headers: vec![], cookies: None, status: None, body: Box::new(index()) })
+    Outcome::Success(Response {
+        headers: vec![],
+        cookies: None,
+        status: None,
+        body: Box::new(index()),
+    })
 }
 
 fn index() -> NamedFile {
-    NamedFile::open("templates/index.html".into()).unwrap()
+    NamedFile::open("../templates/index.html".into()).unwrap()
 }
 
 fn favicon_handler(_request: Request, _data: Data) -> Outcome<Response, Status, Data> {
     let response = Response {
         headers: vec![],
-        cookies: None, 
+        cookies: None,
         status: None,
-        body: Box::new(NamedFile::open("/assets/favicon.svg".into()).unwrap())
+        body: Box::new(NamedFile::open("/assets/favicon.svg".into()).unwrap()),
     };
     Outcome::Success(response)
 }
@@ -53,29 +58,29 @@ async fn main() {
         rank: 0,
     };
 
-    let static_route = Route { 
+    let static_route = Route {
         format: None,
         handler: static_files_handler,
         name: Some("static files"),
         uri: "<file..>".try_into().unwrap(),
         method: Method::Get,
-        rank: 0
+        rank: 0,
     };
 
     let favicon = Route {
-        format: None, 
+        format: None,
         handler: favicon_handler,
         name: Some("favicon"),
         uri: "favicon.ico".try_into().unwrap(),
         method: Method::Get,
-        rank: 0
+        rank: 0,
     };
 
     // http::build("127.0.0.1:8000")
     http::build("127.0.0.1:8443", "127.0.0.1:8080")
         .await
-        .mount("/".try_into().unwrap(), vec![index_route, favicon])
         .mount("/static".try_into().unwrap(), vec![static_route])
+        .mount("/".try_into().unwrap(), vec![index_route, favicon])
         .launch()
         .await;
 }
diff --git a/small.csv b/small.csv
deleted file mode 100644
index aa3809c..0000000
--- a/small.csv
+++ /dev/null
@@ -1,20 +0,0 @@
-Name, format, asdf
-vnd.motorola.video,video/vnd.motorola.video,[Tom_McGinty]
-vnd.motorola.videop,video/vnd.motorola.videop,[Tom_McGinty]
-vnd.mpegurl,video/vnd.mpegurl,[Heiko_Recktenwald]
-vnd.ms-playready.media.pyv,video/vnd.ms-playready.media.pyv,[Steve_DiAcetis]
-vnd.nokia.interleaved-multimedia,video/vnd.nokia.interleaved-multimedia,[Petteri_Kangaslampi]
-vnd.nokia.mp4vr,video/vnd.nokia.mp4vr,[Miska_M._Hannuksela]
-vnd.nokia.videovoip,video/vnd.nokia.videovoip,[Nokia]
-vnd.objectvideo,video/vnd.objectvideo,[John_Clark]
-vnd.radgamettools.bink,video/vnd.radgamettools.bink,[Henrik_Andersson]
-vnd.radgamettools.smacker,video/vnd.radgamettools.smacker,[Henrik_Andersson]
-vnd.sealed.mpeg1,video/vnd.sealed.mpeg1,[David_Petersen]
-vnd.sealed.mpeg4,video/vnd.sealed.mpeg4,[David_Petersen]
-vnd.sealed.swf,video/vnd.sealed.swf,[David_Petersen]
-vnd.sealedmedia.softseal.mov,video/vnd.sealedmedia.softseal.mov,[David_Petersen]
-vnd.uvvu.mp4,video/vnd.uvvu.mp4,[Michael_A_Dolan]
-vnd.youtube.yt,video/vnd.youtube.yt,[Google]
-vnd.vivo,video/vnd.vivo,[John_Wolfe]
-VP8,video/VP8,[RFC7741]
-VP9,video/VP9,[RFC-ietf-payload-vp9-16]
diff --git a/tree.txt b/tree.txt
deleted file mode 100644
index 05d432b..0000000
--- a/tree.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-.
-├── core
-│   ├── codegen
-│   │   ├── Cargo.lock
-│   │   ├── Cargo.toml
-│   │   ├── src
-│   │   │   └── lib.rs
-│   ├── html
-│   │   ├── Cargo.lock
-│   │   ├── Cargo.toml
-│   │   └── src
-│   │       └── lib.rs
-│   └── http
-│       ├── Cargo.lock
-│       ├── Cargo.toml
-│       └── src
-│           ├── handlers
-│           │   ├── file_handlers.rs
-│           │   ├── handlers.rs
-│           │   └── mod.rs
-│           ├── lib.rs
-│           ├── routing
-│           │   ├── methods.rs
-│           │   ├── mod.rs
-│           │   └── routes.rs
-│           ├── setup.rs
-│           ├── threading.rs
-│           └── utils
-│               └── mod.rs
-├── README.md
-├── site
-│   ├── 404.html
-│   ├── Cargo.lock
-│   ├── Cargo.toml
-│   ├── hello.css
-│   ├── img.jpg
-│   ├── src
-│   │   └── main.rs
-│   ├── static
-│   │   └── hello.html
-│   └── target
-│       └── CACHEDIR.TAG
-└── tree.txt
-
-- 
GitLab