Procházet zdrojové kódy

Create and serve logos.

Lee Morgan před 1 rokem
rodič
revize
92796f8053
4 změnil soubory, kde provedl 32 přidání a 1 odebrání
  1. 17 1
      src/routes/other.rs
  2. 6 0
      src/views/index.html
  3. binární
      src/views/logo.png
  4. 9 0
      src/views/logo.svg

+ 17 - 1
src/routes/other.rs

@@ -1,8 +1,12 @@
-use actix_web::{get, HttpResponse, Responder, web};
+use actix_web::{get, HttpResponse, Responder, web, Error};
+use actix_files::NamedFile;
 use crate::HTML;
+use std::path::PathBuf;
 
 pub fn config(cfg: &mut web::ServiceConfig) {
     cfg.service(landing_page);
+    cfg.service(svg_logo);
+    cfg.service(png_logo);
 }
 
 #[get("/")]
@@ -12,3 +16,15 @@ async fn landing_page() -> impl Responder {
         .content_type("text/html; charset=utf-8")
         .body(html.clone())
 }
+
+#[get("/logo.svg")]
+async fn svg_logo() -> Result<NamedFile, Error> {
+    let path: PathBuf = PathBuf::from("src/views/logo.svg");
+    Ok(NamedFile::open(path)?)
+}
+
+#[get("/logo.png")]
+async fn png_logo() -> Result<NamedFile, Error> {
+    let path: PathBuf = PathBuf::from("src/views/logo.png");
+    Ok(NamedFile::open(path)?)
+}

+ 6 - 0
src/views/index.html

@@ -1,10 +1,16 @@
 <!DOCTYPE html>
 <html lang="en">
 <head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <meta name="theme-color" content="#6e4b3a">
+    <meta name="description" content="Personal finance application">
+    <link rel="icon" href="/logo.svg" type="image/svg+xml">
     <title>Suma</title>
     <style></style>
 </head>
 <body>
+    <img src="/logo.svg" alt="Suma logo">
     <h1>Suma landing page</h1>
     <script></script>
 </body>

binární
src/views/logo.png


+ 9 - 0
src/views/logo.svg

@@ -0,0 +1,9 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64" fill="none">
+  <circle cx="32" cy="32" r="32" fill="#D4AF37" />
+  <circle cx="32" cy="32" r="30" stroke="#B8962E" stroke-width="2" fill="none"/>
+  <text x="32" y="42" text-anchor="middle" fill="#6E4B3A"
+        font-family="Georgia, serif" font-size="28" font-weight="bold">
+    S
+  </text>
+</svg>
+