macroblog.rs @ ea058a851098bf81cb645249e02d26a8c253db90

ref: Add embded rust and router

- Use embed rust to load and resolve file from `content/post` folder, so
the whole process is a bit more dynamic.

- Add router to to resolve the path. It is the first step to try to get
the code a bit cleaner.
  1diff --git a/Cargo.lock b/Cargo.lock
  2index 9f33acf3c98818217ece2468b7dbc88e4f9ab63a..b687dc4ba345533b859801322d8dd90f09f8eec1 100644
  3--- a/Cargo.lock
  4+++ b/Cargo.lock
  5@@ -24,6 +24,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
  6 checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
  7 
  8 [[package]]
  9+name = "block-buffer"
 10+version = "0.9.0"
 11+source = "registry+https://github.com/rust-lang/crates.io-index"
 12+checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4"
 13+dependencies = [
 14+ "generic-array",
 15+]
 16+
 17+[[package]]
 18 name = "bytes"
 19 version = "1.1.0"
 20 source = "registry+https://github.com/rust-lang/crates.io-index"
 21@@ -34,6 +43,24 @@ name = "cfg-if"
 22 version = "1.0.0"
 23 source = "registry+https://github.com/rust-lang/crates.io-index"
 24 checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
 25+
 26+[[package]]
 27+name = "cpufeatures"
 28+version = "0.2.2"
 29+source = "registry+https://github.com/rust-lang/crates.io-index"
 30+checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b"
 31+dependencies = [
 32+ "libc",
 33+]
 34+
 35+[[package]]
 36+name = "digest"
 37+version = "0.9.0"
 38+source = "registry+https://github.com/rust-lang/crates.io-index"
 39+checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066"
 40+dependencies = [
 41+ "generic-array",
 42+]
 43 
 44 [[package]]
 45 name = "filetime"
 46@@ -93,6 +120,16 @@  "pin-utils",
 47 ]
 48 
 49 [[package]]
 50+name = "generic-array"
 51+version = "0.14.5"
 52+source = "registry+https://github.com/rust-lang/crates.io-index"
 53+checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803"
 54+dependencies = [
 55+ "typenum",
 56+ "version_check",
 57+]
 58+
 59+[[package]]
 60 name = "h2"
 61 version = "0.3.13"
 62 source = "registry+https://github.com/rust-lang/crates.io-index"
 63@@ -252,6 +289,7 @@ version = "0.1.0"
 64 dependencies = [
 65  "hyper",
 66  "regex",
 67+ "rust-embed",
 68  "sailfish",
 69  "tokio",
 70 ]
 71@@ -309,6 +347,12 @@ name = "once_cell"
 72 version = "1.10.0"
 73 source = "registry+https://github.com/rust-lang/crates.io-index"
 74 checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
 75+
 76+[[package]]
 77+name = "opaque-debug"
 78+version = "0.3.0"
 79+source = "registry+https://github.com/rust-lang/crates.io-index"
 80+checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
 81 
 82 [[package]]
 83 name = "parking_lot"
 84@@ -390,6 +434,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 85 checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
 86 
 87 [[package]]
 88+name = "rust-embed"
 89+version = "6.4.0"
 90+source = "registry+https://github.com/rust-lang/crates.io-index"
 91+checksum = "9a17e5ac65b318f397182ae94e532da0ba56b88dd1200b774715d36c4943b1c3"
 92+dependencies = [
 93+ "rust-embed-impl",
 94+ "rust-embed-utils",
 95+ "walkdir",
 96+]
 97+
 98+[[package]]
 99+name = "rust-embed-impl"
100+version = "6.2.0"
101+source = "registry+https://github.com/rust-lang/crates.io-index"
102+checksum = "94e763e24ba2bf0c72bc6be883f967f794a019fafd1b86ba1daff9c91a7edd30"
103+dependencies = [
104+ "proc-macro2",
105+ "quote",
106+ "rust-embed-utils",
107+ "syn",
108+ "walkdir",
109+]
110+
111+[[package]]
112+name = "rust-embed-utils"
113+version = "7.2.0"
114+source = "registry+https://github.com/rust-lang/crates.io-index"
115+checksum = "756feca3afcbb1487a1d01f4ecd94cf8ec98ea074c55a69e7136d29fb6166029"
116+dependencies = [
117+ "sha2",
118+ "walkdir",
119+]
120+
121+[[package]]
122 name = "ryu"
123 version = "1.0.9"
124 source = "registry+https://github.com/rust-lang/crates.io-index"
125@@ -434,6 +512,15 @@  "sailfish-compiler",
126 ]
127 
128 [[package]]
129+name = "same-file"
130+version = "1.0.6"
131+source = "registry+https://github.com/rust-lang/crates.io-index"
132+checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
133+dependencies = [
134+ "winapi-util",
135+]
136+
137+[[package]]
138 name = "scopeguard"
139 version = "1.1.0"
140 source = "registry+https://github.com/rust-lang/crates.io-index"
141@@ -460,6 +547,19 @@  "syn",
142 ]
143 
144 [[package]]
145+name = "sha2"
146+version = "0.9.9"
147+source = "registry+https://github.com/rust-lang/crates.io-index"
148+checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800"
149+dependencies = [
150+ "block-buffer",
151+ "cfg-if",
152+ "cpufeatures",
153+ "digest",
154+ "opaque-debug",
155+]
156+
157+[[package]]
158 name = "signal-hook-registry"
159 version = "1.4.0"
160 source = "registry+https://github.com/rust-lang/crates.io-index"
161@@ -600,6 +700,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
162 checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642"
163 
164 [[package]]
165+name = "typenum"
166+version = "1.15.0"
167+source = "registry+https://github.com/rust-lang/crates.io-index"
168+checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
169+
170+[[package]]
171 name = "unicode-xid"
172 version = "0.2.3"
173 source = "registry+https://github.com/rust-lang/crates.io-index"
174@@ -612,6 +718,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
175 checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
176 
177 [[package]]
178+name = "walkdir"
179+version = "2.3.2"
180+source = "registry+https://github.com/rust-lang/crates.io-index"
181+checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56"
182+dependencies = [
183+ "same-file",
184+ "winapi",
185+ "winapi-util",
186+]
187+
188+[[package]]
189 name = "want"
190 version = "0.3.0"
191 source = "registry+https://github.com/rust-lang/crates.io-index"
192@@ -642,6 +759,15 @@ name = "winapi-i686-pc-windows-gnu"
193 version = "0.4.0"
194 source = "registry+https://github.com/rust-lang/crates.io-index"
195 checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
196+
197+[[package]]
198+name = "winapi-util"
199+version = "0.1.5"
200+source = "registry+https://github.com/rust-lang/crates.io-index"
201+checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
202+dependencies = [
203+ "winapi",
204+]
205 
206 [[package]]
207 name = "winapi-x86_64-pc-windows-gnu"
208diff --git a/Cargo.toml b/Cargo.toml
209index 093a4d3252d590fdd23a2c4a3834b9bc0e143381..de00d117e0465b66e6fd3f2616ffb608e3a6b7b6 100644
210--- a/Cargo.toml
211+++ b/Cargo.toml
212@@ -8,6 +8,7 @@ sailfish = "0.4.0"
213 hyper = { version = "0.14", features = ["full"] }
214 tokio = { version = "1", features = ["full"] }
215 regex = "1.5"
216+rust-embed="6.4.0"
217 
218 [profile.release]
219 opt-level = 'z'
220@@ -15,3 +16,7 @@ lto = true
221 codegen-units = 1
222 panic = 'abort'
223 strip = true
224+
225+[lib]
226+name="router"
227+path="src/router.rs"
228diff --git a/assets/post1.html b/assets/post1.html
229deleted file mode 100644
230index 6eafb918836bf0d77fb26a94465247e9a58dbb6f..0000000000000000000000000000000000000000
231--- a/assets/post1.html
232+++ /dev/null
233@@ -1,9 +0,0 @@
234-<section>
235-    <h2>Title</h2>
236-    <p>
237-        Nice content
238-        <code>
239-            My code here
240-        </code>
241-    </p>
242-</section>
243diff --git a/assets/post2.html b/assets/post2.html
244deleted file mode 100644
245index 077734ef45473f4c25aa2d5cf58446966e6a278f..0000000000000000000000000000000000000000
246--- a/assets/post2.html
247+++ /dev/null
248@@ -1,9 +0,0 @@
249-<section>
250-    <h2>Title</h2>
251-    <p>
252-        Nice content 2
253-        <code>
254-            My code here
255-        </code>
256-    </p>
257-</section>
258diff --git a/content/posts/Friz.box_turned_off_DHCP.html b/content/posts/Friz.box_turned_off_DHCP.html
259new file mode 100644
260index 0000000000000000000000000000000000000000..569604b4a4169a0eca392de73071f6a436ded7b7
261--- /dev/null
262+++ b/content/posts/Friz.box_turned_off_DHCP.html
263@@ -0,0 +1,18 @@
264+<section>
265+    <h2>Friz.box turned off DHCP</h2>
266+    <p>
267+        If you turned off your DHCP server follow these steps to connect to FritzBox settings.
268+        <br/>
269+    <ul>
270+        <li> Set your computer IP to 170.254.1.2 and your mask to 255.255.0.0</li>
271+        <li> Then go to 169.254.1.1, login and re-enable the DHCP server:</li>
272+    </ul>
273+    </p>
274+    <p>
275+        On gnome turn the wired connection off on again to apply the settings.
276+    </p>
277+    <p>
278+        <strong>Note</strong>: why in the hell does FritzBox 7490 require a land-line telephone to be physically factory
279+        reset?
280+    </p>
281+</section>
282diff --git a/content/posts/K8S_private_gitlab_registry_using_podman.html b/content/posts/K8S_private_gitlab_registry_using_podman.html
283new file mode 100644
284index 0000000000000000000000000000000000000000..367275598b6ba9d73c5f6f44d10da9d16068d2ea
285--- /dev/null
286+++ b/content/posts/K8S_private_gitlab_registry_using_podman.html
287@@ -0,0 +1,55 @@
288+<section>
289+    <h2>K8S private gitlab registry using podman</h2>
290+    <p>
291+        This is based on <a
292+            href="https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/">Log in to
293+        Docker Hub</a>. It is just a bit different to use podman.
294+    </p>
295+    <p>
296+        First we should take a look at podman-login man page:
297+    <pre>
298+        <code>man podman login</code>
299+    </pre>
300+    </p>
301+    <p>
302+        It will give some valueable information like the location of auth.json file. Now we can login using podman:
303+    <pre>
304+        <code>podman login registry.gitlab.com</code>
305+    </pre>
306+    </p>
307+    <p>Then check the <i> auth.json </i>file located at <i>${XDG_RUNTIME_DIR}/containers/auth.json</i> (as described
308+        by the manual). It will contain your auth config:
309+    <pre>
310+        <code>
311+{
312+	"auths": {
313+		"registry.gitlab.com": {
314+			"auth": "..."
315+		}
316+	}
317+}
318+        </code>
319+    </pre>
320+    </p>
321+    <p>
322+        Now copy that file over to the server and register it in k8s with the following command:
323+    <pre>
324+        <code>
325+kubectl create secret generic regcred \
326+    --from-file=.dockerconfigjson=auth.json \
327+    --type=kubernetes.io/dockerconfigjson
328+
329+        </code>
330+    </pre>
331+    </p>
332+    <p>
333+        Once you have created you can list by kubectl get secret:
334+    <pre>
335+        <code>
336+NAME     TYPE                                  DATA   AGE
337+regcred  kubernetes.io/dockerconfigjson        1      53s
338+        </code>
339+    </pre>
340+    </p>
341+
342+</section>
343diff --git a/src/main.rs b/src/main.rs
344index 1fb0e9003272d0f3e5a537d5277227549600abee..cabff0e25c2cbc88ad464f30c968bdc5b0862441 100644
345--- a/src/main.rs
346+++ b/src/main.rs
347@@ -1,54 +1,59 @@
348+pub mod router;
349+
350 use std::convert::Infallible;
351-use std::{include_str, env};
352+use rust_embed::RustEmbed;
353+use std::{env, str};
354 use std::net::SocketAddr;
355 use hyper::{Body, Request, Response, Server};
356 use hyper::service::{make_service_fn, service_fn};
357-use regex::Regex;
358 use sailfish::TemplateOnce;
359-
360+use ::router::Router;
361 
362 #[derive(TemplateOnce)]
363 #[template(path = "index.html")]
364 struct IndexTemplate {
365-    posts: [Post; 2],
366+    posts: Vec<String>,
367 }
368 
369 #[derive(TemplateOnce)]
370 #[template(path = "post.html")]
371 struct PostTemplate {
372-    content: &'static str,
373+    content: String,
374 }
375 
376+#[derive(RustEmbed)]
377+#[folder = "content/posts/"]
378+struct PostAsset;
379 
380-struct Post(
381-    u8,
382-    &'static str,
383-    &'static str,
384-);
385 
386-const POSTS: [Post; 2] = [
387-    Post(
388-        0,
389-        "K8S private gitlab registry using podman",
390-        include_str!("../assets/post1.html"),
391-    ),
392-    Post(
393-        1,
394-        "Automation part 1",
395-        include_str!("../assets/post2.html"),
396-    ),
397-];
398+fn get_file_content(path: &str) -> String {
399+    let buffer = PostAsset::get(path)
400+        .unwrap()
401+        .data
402+        .into_owned();
403+
404+    return String::from_utf8(buffer).unwrap();
405+}
406+
407+fn get_post_title() -> Vec<String> {
408+    PostAsset::iter()
409+        .map(|e| format!("{}", e))
410+        .collect()
411+}
412 
413-fn get_path_id(path: &str) -> usize {
414-    let re = Regex::new(r"(?P<id>\d+)").unwrap();
415-    let caps = re.captures(path).unwrap();
416-    let id = &caps["id"];
417 
418-    return id.parse::<usize>().unwrap();
419+async fn not_found() -> Result<Response<Body>, Infallible> {
420+    let resp: Response<Body> = Response::builder()
421+        .status(404)
422+        .body("Not Found".into())
423+        .unwrap();
424+    Ok(resp)
425 }
426+
427 
428 async fn index() -> Result<Response<Body>, Infallible> {
429-    let body = IndexTemplate { posts: POSTS }
430+    let files = get_post_title();
431+    let body = IndexTemplate { posts: files }
432         .render_once()
433         .unwrap();
434 
435@@ -62,8 +67,8 @@     Ok(resp)
436 }
437 
438 
439-async fn post(index: usize) -> Result<Response<Body>, Infallible> {
440-    let body = PostTemplate { content: POSTS[index].2 }
441+async fn post(path: &String) -> Result<Response<Body>, Infallible> {
442+    let body = PostTemplate { content: get_file_content(path) }
443         .render_once()
444         .unwrap();
445 
446@@ -78,16 +83,12 @@ }
447 
448 async fn request(req: Request<Body>) -> Result<Response<Body>, Infallible> {
449     let path = req.uri().path();
450-    if path == "/favicon.ico" {
451-        return index().await
452+
453+    match Router::new(path) {
454+        Router::Index => index().await,
455+        Router::Post { page } => post(&page).await,
456+        Router::NotFound => not_found().await
457     }
458-    if path != "/" {
459-        let index = get_path_id(&path);
460-        return post(index).await;
461-    }
462-
463-
464-    return index().await;
465 }
466 
467 
468diff --git a/src/router.rs b/src/router.rs
469new file mode 100644
470index 0000000000000000000000000000000000000000..0bba091cb8533672e794fd3b48c9dac9cdd2e6a0
471--- /dev/null
472+++ b/src/router.rs
473@@ -0,0 +1,27 @@
474+use regex::{Regex};
475+
476+const ACTION_REGEX: &str = r"/{0,1}(?P<action>\w*)/(?P<id>.+)";
477+
478+pub enum Router {
479+    NotFound,
480+    Index,
481+    Post { page: String },
482+}
483+
484+impl Router {
485+    pub fn new(path: &str) -> Router {
486+        let re = Regex::new(ACTION_REGEX).unwrap();
487+        let caps = re.captures(path);
488+        let action = match caps {
489+            Some(ref value) => &value["action"],
490+            None => "index"
491+        };
492+
493+        match action {
494+            "posts" => Router::Post { page: caps.unwrap()["id"].to_string() },
495+            "index" => Router::Index,
496+            _ => Router::NotFound
497+        }
498+    }
499+}
500+
501diff --git a/templates/header.html b/templates/header.html
502index e55cebef599eded1db5be972ddb071b808191601..1005e66b8875d2bf57e725bda2405dade9f6f61c 100644
503--- a/templates/header.html
504+++ b/templates/header.html
505@@ -4,9 +4,7 @@         <ul>
506             <li><strong>Yet Another Blog</strong></li>
507         </ul>
508         <ul>
509-            <li><a class="secondary">Posts</a></li>
510-            <li><a class="secondary">Projects</a></li>
511-            <li><a class="secondary">Resume</a></li>
512+            <li><a href="https://gitlab.com/gabrielgio/cv/-/raw/main/cv.pdf?inline=false" class="secondary">Resume</a></li>
513         </ul>
514     </nav>
515     <hgroup>
516diff --git a/templates/index.html b/templates/index.html
517index 3558e0691376bc93ee0cc5e9d90ff8112e09802b..6d0c1399c2406964174131b8ce5adf1dc6a09cbc 100644
518--- a/templates/index.html
519+++ b/templates/index.html
520@@ -9,7 +9,7 @@ <main class="container">
521     <section>
522         <ul>
523         <% for p in &posts { %>
524-            <li><a href="/post/<%- p.0 %>"><%- p.1 %></a></li>
525+            <li><a href="/posts/<%- p %>"><%- p %></a></li>
526         <% } %>
527         </ul>
528     </section>
529diff --git a/templates/pico.min.css b/templates/pico.min.css
530index 1179471453b3bb57f3935f37166f7f8a05655fb3..7713ba92ff1ed322eeebb8f2e994eeec4c0488c1 100644
531--- a/templates/pico.min.css
532+++ b/templates/pico.min.css
533@@ -325,7 +325,7 @@ b, strong {
534     font-weight: bolder
535 }
536 
537-address, blockquote, dl, figure, form, ol, p, pre, table, ul {
538+address, blockquote, dl, figure, form, ol, p, table, ul {
539     margin-top: 0;
540     margin-bottom: var(--typography-spacing-vertical);
541     color: var(--color);
542@@ -336,7 +336,7 @@ }
543 
544 [role=link], a {
545     --color: var(--primary);
546-    --background-color: transparent;
547+    ckground-color: transparent;
548     outline: 0;
549     background-color: var(--background-color);
550     color: var(--color);
551@@ -413,7 +413,7 @@ h6 {
552     --color: var(--h6-color)
553 }
554 
555-:where(address,blockquote,dl,figure,form,ol,p,pre,table,ul) ~ :is(h1,h2,h3,h4,h5,h6) {
556+:where(address,blockquote,dl,figure,form,ol,p,table,ul) ~ :is(h1,h2,h3,h4,h5,h6) {
557     margin-top: var(--typography-spacing-vertical)
558 }
559 
560@@ -454,7 +454,7 @@     margin: calc(var(--typography-spacing-vertical) * .25) 0 0
561 }
562 
563 ul li {
564-    list-style: none
565+    list-style: square;
566 }
567 
568 mark {
569@@ -503,61 +503,22 @@ [type=color]::-webkit-color-swatch-wrapper {
570     padding: 0
571 }
572 
573-code, kbd, pre, samp {
574+kbd,  samp {
575     font-size: 0.875em;
576     font-family: var(--font-family)
577 }
578 
579-pre {
580-    -ms-overflow-style: scrollbar;
581-    overflow: auto
582-}
583-
584-code, kbd, pre {
585+kbd {
586     border-radius: var(--border-radius);
587-    background: var(--code-background-color);
588+    background: var(--eode-background-color);
589     color: var(--code-color);
590     font-weight: var(--font-weight);
591     line-height: initial
592 }
593 
594-code, kbd {
595+ kbd {
596     display: inline-block;
597     padding: 0.375rem 0.5rem
598-}
599-
600-pre {
601-    display: block;
602-    margin-bottom: var(--spacing);
603-    overflow-x: auto
604-}
605-
606-pre > code {
607-    display: block;
608-    padding: var(--spacing);
609-    background: 0 0;
610-    font-size: 14px;
611-    line-height: var(--line-height)
612-}
613-
614-code b {
615-    color: var(--code-tag-color);
616-    font-weight: var(--font-weight)
617-}
618-
619-code i {
620-    color: var(--code-property-color);
621-    font-style: normal
622-}
623-
624-code u {
625-    color: var(--code-value-color);
626-    text-decoration: none
627-}
628-
629-code em {
630-    color: var(--code-comment-color);
631-    font-style: normal
632 }
633 
634 kbd {
635diff --git a/templates/post.html b/templates/post.html
636index 68211c1fd5b22ac6a6faa7f6dfa6b3994e52c2aa..410cfbfc7670a835541b07351ef7063fd0e2b40c 100644
637--- a/templates/post.html
638+++ b/templates/post.html
639@@ -1,13 +1,16 @@
640 <!DOCTYPE html>
641 <html data-theme="light" lang="en">
642 <head>
643-  <% include!("head.html"); %>
644+    <% include!("head.html"); %>
645 </head>
646 <body>
647 <% include!("simple_header.html"); %>
648 <main class="container">
649-  <%- content %>
650-</section>
651+    <%- content %>
652+    </section>
653 </main>
654 </body>
655+
656+<script>
657+</script>
658 </html>
659diff --git a/templates/simple_header.html b/templates/simple_header.html
660index 0132334d05dc3d402fe303fc7b4f483f53e0e7fc..4382df4342e8602d50ea29aca519284f3451e021 100644
661--- a/templates/simple_header.html
662+++ b/templates/simple_header.html
663@@ -4,9 +4,7 @@         <ul>
664             <li><strong><a href="/">Yet Another Blog</a></strong></li>
665         </ul>
666         <ul>
667-            <li><a class="secondary">Posts</a></li>
668-            <li><a class="secondary">Projects</a></li>
669-            <li><a class="secondary">Resume</a></li>
670+            <li><a href="https://gitlab.com/gabrielgio/cv/-/raw/main/cv.pdf?inline=false" class="secondary">Resume</a></li>
671         </ul>
672     </nav>
673 </header>
674diff --git a/tests/test_router.rs b/tests/test_router.rs
675new file mode 100644
676index 0000000000000000000000000000000000000000..0158d782b5eb5b06f948be3b48417943a44180e6
677--- /dev/null
678+++ b/tests/test_router.rs
679@@ -0,0 +1,28 @@
680+use router::{Router};
681+
682+#[test]
683+fn test_router_new_posts() {
684+    match Router::new("/posts/k8s.html") {
685+        Router::NotFound => assert!(false, "Wrong type parse"),
686+        Router::Index => assert!(false, "Wrong type parse"),
687+        Router::Post { page } => assert_eq!(page, "k8s.html".to_string())
688+    };
689+}
690+
691+#[test]
692+fn test_router_new_index() {
693+    match Router::new("/") {
694+        Router::Index => assert!(true),
695+        Router::NotFound => assert!(false, "Wrong type parse"),
696+        Router::Post { page: _ } => assert!(false, "Wrong type parse")
697+    };
698+}
699+
700+#[test]
701+fn test_router_new_not_found() {
702+    match Router::new("/not_found") {
703+        Router::NotFound => assert!(true),
704+        Router::Index => assert!(false, "Wrong type parse"),
705+        Router::Post { page: _ } => assert!(false, "Wrong type parse")
706+    };
707+}
708diff --git a/watch b/watch
709index 9f5acdb892dd59d940fab9a5b32a6539b2f79c2f..5a5076c72464d490604a9bfa6f44f6193fb000c2 100755
710--- a/watch
711+++ b/watch
712@@ -11,6 +11,6 @@
713 while true; do
714   cargo run &
715   PID=$!
716-  inotifywait -e modify -e move -e create -e delete -e attrib -r  src/ templates/ assets/
717+  inotifywait -e modify -e move -e create -e delete -e attrib -r  src/ templates/ content/
718   kill $PID
719 done