From f927091148856f83928c7175c1181e937ffaf1c0 Mon Sep 17 00:00:00 2001 From: Triston Armstrong Date: Mon, 25 Mar 2024 23:22:47 -0500 Subject: [PATCH] add dynamic file based routing and md files --- Cargo.lock | 490 ++++++++++++++++++++++++- Cargo.toml | 1 + notes/automatic_dereferece_via_self.md | 5 + src/main.rs | 3 + src/router.rs | 22 +- src/routes.rs | 26 +- src/templates.rs | 7 + templates/tut.html | 8 + tuts/dayz_work_command.md | 5 + tuts/dont_use_state_to_set_state.md | 31 ++ tuts/dynamic_route_names.md | 54 +++ tuts/fix_broken_yay.md | 27 ++ tuts/fixing_computer.md | 68 ++++ tuts/gnome_tweak_tool_arch.md | 15 + tuts/install_displaymanager_arch.md | 27 ++ tuts/install_gnome_arch.md | 35 ++ tuts/notes.md | 72 ++++ tuts/rm_orphans_arch.md | 7 + 18 files changed, 898 insertions(+), 5 deletions(-) create mode 100644 notes/automatic_dereferece_via_self.md create mode 100644 templates/tut.html create mode 100644 tuts/dayz_work_command.md create mode 100644 tuts/dont_use_state_to_set_state.md create mode 100644 tuts/dynamic_route_names.md create mode 100644 tuts/fix_broken_yay.md create mode 100644 tuts/fixing_computer.md create mode 100644 tuts/gnome_tweak_tool_arch.md create mode 100644 tuts/install_displaymanager_arch.md create mode 100644 tuts/install_gnome_arch.md create mode 100644 tuts/notes.md create mode 100644 tuts/rm_orphans_arch.md diff --git a/Cargo.lock b/Cargo.lock index b998bd3..c9bc393 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -60,6 +60,54 @@ dependencies = [ "libc", ] +[[package]] +name = "anstream" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" + +[[package]] +name = "anstyle-parse" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + [[package]] name = "anyhow" version = "1.0.81" @@ -305,6 +353,30 @@ dependencies = [ "serde", ] +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + [[package]] name = "bitflags" version = "1.3.2" @@ -372,6 +444,53 @@ dependencies = [ "windows-targets 0.52.4", ] +[[package]] +name = "clap" +version = "4.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim 0.11.0", + "terminal_size", +] + +[[package]] +name = "clap_derive" +version = "4.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.53", +] + +[[package]] +name = "clap_lex" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "colored" version = "2.1.0" @@ -394,6 +513,26 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "comrak" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6751998a48e2327773c95f6f8e03c6e77c0156ce539d74c17d2199ff3d05e197" +dependencies = [ + "clap", + "derive_builder", + "entities", + "memchr", + "once_cell", + "regex", + "shell-words", + "slug", + "syntect", + "typed-arena", + "unicode_categories", + "xdg", +] + [[package]] name = "const-oid" version = "0.9.6" @@ -430,6 +569,15 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" +[[package]] +name = "crc32fast" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +dependencies = [ + "cfg-if", +] + [[package]] name = "crossbeam-channel" version = "0.5.12" @@ -505,6 +653,41 @@ dependencies = [ "typenum", ] +[[package]] +name = "darling" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.10.0", + "syn 1.0.109", +] + +[[package]] +name = "darling_macro" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" +dependencies = [ + "darling_core", + "quote", + "syn 1.0.109", +] + [[package]] name = "der" version = "0.7.8" @@ -516,6 +699,52 @@ dependencies = [ "zeroize", ] +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + +[[package]] +name = "derive_builder" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d67778784b508018359cbc8696edb3db78160bab2c2a28ba7f56ef6932997f8" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c11bdc11a0c47bc7d37d582b5285da6849c96681023680b906673c5707af7b0f" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive_builder_macro" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebcda35c7a396850a55ffeac740804b40ffec779b98fffbb1738f4033f0ee79e" +dependencies = [ + "derive_builder_core", + "syn 1.0.109", +] + +[[package]] +name = "deunicode" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6e854126756c496b8c81dec88f9a706b15b875c5849d4097a3854476b9fdf94" + [[package]] name = "diesel" version = "2.1.5" @@ -590,6 +819,12 @@ dependencies = [ "serde", ] +[[package]] +name = "entities" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5320ae4c3782150d900b79807611a59a99fc9a1d61d686faafc24b93fc8d7ca" + [[package]] name = "equivalent" version = "1.0.1" @@ -629,6 +864,16 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" +[[package]] +name = "fancy-regex" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2" +dependencies = [ + "bit-set", + "regex", +] + [[package]] name = "fastrand" version = "2.0.1" @@ -641,6 +886,16 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" +[[package]] +name = "flate2" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + [[package]] name = "flume" version = "0.11.0" @@ -856,6 +1111,12 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" version = "0.3.9" @@ -902,6 +1163,7 @@ dependencies = [ "askama", "askama_axum", "axum 0.7.4", + "comrak", "serde", "serde_json", "shuttle-axum", @@ -1084,6 +1346,12 @@ dependencies = [ "cc", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.5.0" @@ -1179,6 +1447,18 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "line-wrap" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd1bc4d24ad230d21fb898d1116b1801d7adfc449d42026475862ab48b11e70e" + +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + [[package]] name = "linux-raw-sys" version = "0.4.13" @@ -1312,6 +1592,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-integer" version = "0.1.46" @@ -1367,6 +1653,28 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "onig" +version = "6.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c4b31c8722ad9171c6d77d3557db078cab2bd50afcc9d09c8b315c59df8ca4f" +dependencies = [ + "bitflags 1.3.2", + "libc", + "once_cell", + "onig_sys", +] + +[[package]] +name = "onig_sys" +version = "69.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b829e3d7e9cc74c7e315ee8edb185bf4190da5acde74afd7fc59c35b1f086e7" +dependencies = [ + "cc", + "pkg-config", +] + [[package]] name = "opentelemetry" version = "0.21.0" @@ -1551,6 +1859,20 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +[[package]] +name = "plist" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9d34169e64b3c7a80c8621a48adaf44e0cf62c78a9b25dd9dd35f1881a17cf9" +dependencies = [ + "base64", + "indexmap 2.2.5", + "line-wrap", + "quick-xml", + "serde", + "time", +] + [[package]] name = "postgres-protocol" version = "0.6.6" @@ -1580,6 +1902,12 @@ dependencies = [ "postgres-protocol", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -1651,6 +1979,15 @@ dependencies = [ "prost", ] +[[package]] +name = "quick-xml" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" +dependencies = [ + "memchr", +] + [[package]] name = "quote" version = "1.0.35" @@ -1839,6 +2176,15 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "scoped-futures" version = "0.1.3" @@ -1958,6 +2304,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shell-words" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" + [[package]] name = "shuttle-axum" version = "0.42.0" @@ -2128,6 +2480,16 @@ dependencies = [ "autocfg", ] +[[package]] +name = "slug" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd94acec9c8da640005f8e135a39fc0372e74535e6b368b7a04b875f784c8c4" +dependencies = [ + "deunicode", + "wasm-bindgen", +] + [[package]] name = "smallvec" version = "1.13.1" @@ -2256,7 +2618,7 @@ checksum = "5833ef53aaa16d860e92123292f1f6a3d53c34ba8b1969f152ef1a7bb803f3c8" dependencies = [ "dotenvy", "either", - "heck", + "heck 0.4.1", "hex", "once_cell", "proc-macro2", @@ -2394,6 +2756,18 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "strsim" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" + [[package]] name = "strum" version = "0.24.1" @@ -2415,7 +2789,7 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", @@ -2428,7 +2802,7 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", @@ -2469,6 +2843,29 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "syntect" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "874dcfa363995604333cf947ae9f751ca3af4522c60886774c4963943b4746b1" +dependencies = [ + "bincode", + "bitflags 1.3.2", + "fancy-regex", + "flate2", + "fnv", + "once_cell", + "onig", + "plist", + "regex-syntax 0.8.2", + "serde", + "serde_derive", + "serde_json", + "thiserror", + "walkdir", + "yaml-rust", +] + [[package]] name = "tempfile" version = "3.10.1" @@ -2481,6 +2878,16 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "terminal_size" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" +dependencies = [ + "rustix", + "windows-sys 0.48.0", +] + [[package]] name = "thiserror" version = "1.0.58" @@ -2511,6 +2918,37 @@ dependencies = [ "once_cell", ] +[[package]] +name = "time" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" +dependencies = [ + "num-conv", + "time-core", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -2776,6 +3214,12 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "typed-arena" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" + [[package]] name = "typenum" version = "1.17.0" @@ -2854,6 +3298,12 @@ version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "uuid" version = "1.8.0" @@ -2882,6 +3332,16 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "want" version = "0.3.1" @@ -3010,6 +3470,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -3157,6 +3626,21 @@ version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +[[package]] +name = "xdg" +version = "2.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546" + +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] + [[package]] name = "zerocopy" version = "0.7.32" diff --git a/Cargo.toml b/Cargo.toml index b5890af..31f9197 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" askama = { version = "0.12.1", features = ["with-axum"] } askama_axum = "0.4.0" axum = "0.7.4" +comrak = "0.21.0" serde = { version = "1.0.189", features = ["derive"] } serde_json = "1.0.107" shuttle-axum = "0.42.0" diff --git a/notes/automatic_dereferece_via_self.md b/notes/automatic_dereferece_via_self.md new file mode 100644 index 0000000..c4e3f3a --- /dev/null +++ b/notes/automatic_dereferece_via_self.md @@ -0,0 +1,5 @@ +# Automatic Dereference Via Self (Rust) + +quick note: when function takes 'self' and auto dereference occurs due to the function moving the value into itself? + +> > research diff --git a/src/main.rs b/src/main.rs index 07859ce..13959c1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,6 @@ +use shuttle_axum::AxumService; +use shuttle_runtime::{CustomError, Error}; + mod errors; mod models; mod router; diff --git a/src/router.rs b/src/router.rs index 584ca6d..fa5c03c 100644 --- a/src/router.rs +++ b/src/router.rs @@ -1,4 +1,5 @@ use axum::{routing::get, Router}; +use std::{env, fs}; use crate::routes; @@ -10,9 +11,28 @@ pub fn init_notes_routes() -> Router { Router::new().route("/", get(routes::notes)) } +pub fn update_route(router: Router, file_name_str: String, file_path_str: String) -> Router { + let route = format!("/{}", file_name_str); + router.route( + route.clone().as_str(), + get(move || routes::tuts_builder(file_path_str)), + ) +} // put all tutorial routes here pub fn init_tuts_routes() -> Router { - Router::new().route("/", get(routes::tuts)) + let mut router = Router::new().route("/", get(routes::tuts)); + let path = env::current_dir().unwrap(); + let mut path_string = path.clone().into_os_string(); + path_string.push("/tuts"); + for entry in fs::read_dir(path_string).unwrap() { + let entry = entry.unwrap(); + let file_path = entry.path().to_str().unwrap().to_string(); + let file_name = entry.file_name(); + let file_name_str = file_name.to_str().unwrap().to_string(); + router = update_route(router, file_name_str, file_path); + } + + router } // put any non nested routes here diff --git a/src/routes.rs b/src/routes.rs index 195690c..5783408 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -1,9 +1,16 @@ +use std::{fs::File, io::Read}; + +use askama::Template; use axum::{ http::StatusCode, response::{IntoResponse, Response}, }; +use comrak::markdown_to_html; -use crate::{errors::ApiError, templates}; +use crate::{ + errors::ApiError, + templates::{self, Tut}, +}; pub async fn portfolio() -> impl IntoResponse { templates::Portfolio @@ -17,6 +24,23 @@ pub async fn tuts() -> impl IntoResponse { templates::Tuts } +pub async fn tuts_builder(path: String) -> Result { + let file_contents = std::fs::read_to_string(path).unwrap(); + let file_contents_to_html = + markdown_to_html(file_contents.as_str(), &comrak::Options::default()); + let file_template = Tut { + title: "test title", + content: file_contents_to_html.as_str(), + }; + let response = Response::builder() + .status(StatusCode::OK) + .header("Content-Type", "text/html") + .body(file_template.render().unwrap()) + .unwrap(); + + Ok(response) +} + pub async fn styles() -> Result { let response = Response::builder() .status(StatusCode::OK) diff --git a/src/templates.rs b/src/templates.rs index cc15e59..44c4ad3 100644 --- a/src/templates.rs +++ b/src/templates.rs @@ -11,3 +11,10 @@ pub struct Notes; #[derive(Template)] #[template(path = "tuts.html")] pub struct Tuts; + +#[derive(Template)] +#[template(path = "tut.html", ext = "html", escape = "none")] +pub struct Tut<'a> { + pub title: &'a str, + pub content: &'a str, +} diff --git a/templates/tut.html b/templates/tut.html new file mode 100644 index 0000000..eee2f9c --- /dev/null +++ b/templates/tut.html @@ -0,0 +1,8 @@ +{% extends "base.html" %} {% block title %}{{title}}{% endblock %} {% block +content %} + +{{content}} {% endblock content%} diff --git a/tuts/dayz_work_command.md b/tuts/dayz_work_command.md new file mode 100644 index 0000000..299d57a --- /dev/null +++ b/tuts/dayz_work_command.md @@ -0,0 +1,5 @@ +# Get dayz to work properly + +```bash +sudo sysctl -w vm.max_map_count=1048576 +``` \ No newline at end of file diff --git a/tuts/dont_use_state_to_set_state.md b/tuts/dont_use_state_to_set_state.md new file mode 100644 index 0000000..5955514 --- /dev/null +++ b/tuts/dont_use_state_to_set_state.md @@ -0,0 +1,31 @@ +# Don't use state to set state + +This is very nasty stuff +```tsx +const {someHookState} = useSomeHook() +const [someState, setSomeState] = usState() + +useEffect(() => { + if (!someHookState) return + setSomeState(someHookState) +}, [someHookState]) + +return ( +
{someState}
+) +``` +It essentially causes two completely different rerenders unnecessarily. You may be thinking, well thats just stupid, ofcourse i wouldnt do that! + + +You'd be VERY surprised. I see this all the time, all over the place. Makes absolutely no sense to me. + +All you need to do.. literally.. is this: +```tsx +const {someHookState} = useSomeHook() + +return ( +
{someHookState}
+) +``` + +This is MUCH cleaner. Now you may be thinking, "Well what if someHookState is falsy". Then check for that like you normally would, dumbass. \ No newline at end of file diff --git a/tuts/dynamic_route_names.md b/tuts/dynamic_route_names.md new file mode 100644 index 0000000..be7fb4b --- /dev/null +++ b/tuts/dynamic_route_names.md @@ -0,0 +1,54 @@ +# Dynamic route names + +```tsx +/** All application routes. Assign new routes here as needed*/ +export const ROUTES = { + MY_CASES: { + main: 'mycases/', + sub: { + // --- nothing here yet + } + }, + NEW_CASES: { + main: 'new-cases/', + sub: { + VIEW_FINDER: 'new-cases/view-finder', + APPROVE_IMAGE: 'new-cases/view-finder/approve-image', + CLASSIFY_IMAGE: 'new-cases/view-finder/classify-image', + CAPTURED_LIST: 'new-cases/captured-list' + } + }, + LOGIN: { + main: 'login/', + sub: { + MFA: 'login/mfa', + MFA_PHONE: 'login/mfa-phone', + FORGOT_PASSWORD: 'login/forgot-password' + } + }, + PROFILE: { + main: 'profile/', // sometimes we dont want to actually go to this route. so we'll skip this one + sub: { + PASSWORD: 'profile/password', + PHONE: 'profile/phone' + } + }, + EXTERNAL: { + main: 'https://ventrahealth.com', + sub: { + // put any other routes here - may not have any + } + } +} as const + +// Dont mess with these, these are builders for the values below +type KeyExtractor = keyof T +type RoutesType = typeof ROUTES +type RoutesKeys = KeyExtractor +type RoutesSubsKeys = KeyExtractor> + +/** All main routes available to you */ +export type MainRoutes = RoutesType[RoutesKeys]['main'] +/** All sub routes available to you */ +export type SubRoutes = Union.Merge[RoutesSubsKeys] +``` \ No newline at end of file diff --git a/tuts/fix_broken_yay.md b/tuts/fix_broken_yay.md new file mode 100644 index 0000000..234c58b --- /dev/null +++ b/tuts/fix_broken_yay.md @@ -0,0 +1,27 @@ +# Yay is broken (micro tut) + +## Reinstall Yay + +### clone the repo + +```bash +git clone https://aur.archlinux.org/yay.git +``` + +### go to dir + +```bash +cd yay +``` + +### rust install script + +```bash +makepkg -si +``` + +## update yay packages for good measure + +```bash +yay +``` diff --git a/tuts/fixing_computer.md b/tuts/fixing_computer.md new file mode 100644 index 0000000..632a238 --- /dev/null +++ b/tuts/fixing_computer.md @@ -0,0 +1,68 @@ +# How to save your penguin when your system wont boot after removing or changing a drive + +## So first off, what was my problem? +I had setup my 1TB HDD in `/etc/fstab` and everything was perfect. I could boot my system and BLAM, there it was all nice and mounted. Little did i know, this would come to bite me. + +## What happened? +I was just playing around and testing things when i set up my drive with fstab. I had no idea what that even meant. I knew i planned to eventually dual boot windows on this thing, just didnt know when. Well, today was the day. I reformatted the drive as NTFS and attempted to load up windows on the little fella. Unfortunately that failed misserably, probably due to a bad drive tbh. I said f**k-it and went to boot back into arch. i was tired of fucking with it. I wasted enough time. + +I booted... + +... wah... what is this?.. + +i get hit with a message saying that arch cant boot, arch cant sign in, and arch is fucked. It tells me to press enter to continue. That didnt do jack diddly squat. What do i do now? + +## The solution +I reeeeeeally didnt wanna have to format my usb stick again, but it seems i had no choice. I KNOW that pesky fstab file is the culprit. And, i KNOW i need to change it. I need to delete that dasterdly line i added to auto boot that 1TB drive of mine. + +I caved, loaded up arch onto my flashdrive. Slammed it in that sexy blue usb port. And booted. + +what do i do? .... lets see... Oh thats right, i need to mount my drive. + +lets go ahead and do that... + +clickity clack on the K-B-D... +```bash +fdisk -l +# shows my drives n shit +# pics my drive (nvme0n1) +# partition (p2) 465.3G +``` +so thats my drive. I need a place to mount it. +```bash +mkdir /repair # drive mount point +``` +lets mount it +```bash +mount /dev/nvme0n1p2 /repair +cd /repair +``` + +THANK GOD it mounted without issues.. Why would it give me issues? hell if i know at this point. + +I go into that `/etc/fstab` file, and open it with vim... +```bash +vim /etc/fstab +#... empty file +``` +WTF??? oh come on..... oh wait.. duuuh relative path - me stupid +```bash +vim ./etc/fstab +#... lots of stuff +``` +I see the line.. the line causing me all this pain... +I go to the line in question.... and perform the all mighty `dd` + +i save.. `:w` +it saves.. YES!!, i say +i quit.. `:q` +i reboot.. `reboot` +i wait.. + +## The results +YES IM IN! Im finally booted back into my beautiful ass KDE Plasma environement. Never thought id see her gorgeous face again! + +This was scary for 1 main reason... Im no linux guru. I barely know what im doing half the time. And i break my stuff a lot and usually end up having to reinstall everything.. I did not want to go through that again lol + +im sure ill be back with another +__end note__ diff --git a/tuts/gnome_tweak_tool_arch.md b/tuts/gnome_tweak_tool_arch.md new file mode 100644 index 0000000..2d2d301 --- /dev/null +++ b/tuts/gnome_tweak_tool_arch.md @@ -0,0 +1,15 @@ +# Install and use Gnome Tweak Tool (micro tut) + +## Install gnome tweaks + +```bash +sudo pacman -S gnome-tweaks +``` + +## Install extensions + +Gnome tweak tool extensions moved to gnome extensions + +```bash +flatpak install flathub org.gnome.Extensions +``` diff --git a/tuts/install_displaymanager_arch.md b/tuts/install_displaymanager_arch.md new file mode 100644 index 0000000..c57b30a --- /dev/null +++ b/tuts/install_displaymanager_arch.md @@ -0,0 +1,27 @@ +# Install a Display Manager (micro tut) + +## Install display manager + +_LXDM - MDM - SDDM - XDM - GDM - SDDM_ + +```bash +sudo pacman -s lxdm +``` + +## Stop and disable current display manager + +```bash +sudo systemctl stop gdm.service +sudo systemctl disable gdm.service +``` + +## Start the display manager you chose + +```bash +sudo systemctl start lxdm.service +sudo systemctl enable lxdm.service +``` + +## reboot + +`sudo reboot` diff --git a/tuts/install_gnome_arch.md b/tuts/install_gnome_arch.md new file mode 100644 index 0000000..ca334b0 --- /dev/null +++ b/tuts/install_gnome_arch.md @@ -0,0 +1,35 @@ +# Install Gnome on Arch linux (micro tut) + +## Update Arch Linux & reboot + +```bash +sudo pacman -Syu; sudo reboot +``` + +## Install xorg (if not using wayland) + +use defaults + +```bash +sudo pacman -S xorg xorg-server +``` + +## install gnome desktop environment + +use defaults + +```bash +sudo pacman -S gnome +``` + +## start and enable gdm.service + +```bash +sudo systemctl start gdm.service +``` + +log into gnome then run: + +```bash +sudo systemctl enable gdm.service +``` diff --git a/tuts/notes.md b/tuts/notes.md new file mode 100644 index 0000000..5541c59 --- /dev/null +++ b/tuts/notes.md @@ -0,0 +1,72 @@ +# How to add eslint to neovim + +using npm global install `vscode-langservers-extracted`. +This will give your editor access to `vscode-eslint-language-server`. + +## add the appropriate packages + +```lua +{ + "neovim/nvim-lspconfig", + config = function() + require "plugins.configs.lspconfig" + end, -- Override to setup mason-lspconfig + }, + { + "jose-elias-alvarez/null-ls.nvim", + }, + { + "MunifTanjim/eslint.nvim", + config = function() + require "custom.configs.eslint" + end, + }, +``` + +I have a `custom.configs.eslint` file that contains other eslint configs + +```lua +local null_ls = require "null-ls" +local eslint = require "eslint" + +null_ls.setup() + +eslint.setup { + bin = "eslint", -- or `eslint_d` + code_actions = { + enable = true, + apply_on_save = { + enable = true, + types = { "directive", "problem", "suggestion", "layout" }, + }, + disable_rule_comment = { + enable = true, + location = "separate_line", -- or `same_line` + }, + }, + diagnostics = { + enable = true, + report_unused_disable_directives = false, + run_on = "type", -- or `save` + }, +} +``` + +then in your lspconfig configuration file, add your eslint + +```lua +-- here --v +local servers = { "lua_ls", "html", "cssls", "tsserver", "clangd", "eslint" } +local lspConfig = require "lspconfig" + +for _, lsp in ipairs(servers) do + lspConfig[lsp].setup { + on_attach = M.on_attach, + capabilities = M.capabilities, + } +end +``` + +### Tools to help with custom eslint making + +[AST Explorer](https://astexplorer.net/) diff --git a/tuts/rm_orphans_arch.md b/tuts/rm_orphans_arch.md new file mode 100644 index 0000000..cdff15a --- /dev/null +++ b/tuts/rm_orphans_arch.md @@ -0,0 +1,7 @@ +# Remove Orphan packages (micro tut) + +## Simply call command + +```bash +sudo pacman -Rs $(pacman -Qqtd) +```