diff --git a/Cargo.lock b/Cargo.lock index a1d3aab..9f42256 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -53,7 +53,7 @@ dependencies = [ "actix-service", "actix-utils", "ahash", - "base64", + "base64 0.21.0", "bitflags", "brotli", "bytes", @@ -190,7 +190,7 @@ dependencies = [ "serde_urlencoded", "smallvec", "socket2", - "time", + "time 0.3.17", "url", ] @@ -247,6 +247,15 @@ dependencies = [ "alloc-no-stdlib", ] +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "askama" version = "0.11.1" @@ -306,12 +315,29 @@ dependencies = [ "toml", ] +[[package]] +name = "async-trait" +version = "0.1.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd7fce9ba8c3c042128ce72d8b2ddbf3a05747efb67ea0313c635e10bda47a2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + [[package]] name = "base64" version = "0.21.0" @@ -354,6 +380,31 @@ dependencies = [ "alloc-stdlib", ] +[[package]] +name = "bson" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8746d07211bb12a7c34d995539b4a2acd4e0b0e757de98ce2ab99bcf17443fad" +dependencies = [ + "ahash", + "base64 0.13.1", + "hex", + "indexmap", + "lazy_static", + "rand", + "serde", + "serde_bytes", + "serde_json", + "time 0.3.17", + "uuid 1.3.0", +] + +[[package]] +name = "bumpalo" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" + [[package]] name = "bytes" version = "1.4.0" @@ -384,6 +435,39 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cheezenotes" +version = "0.1.0" +dependencies = [ + "actix-files", + "actix-web", + "askama", + "askama_actix", + "clap", + "git2", + "lazy_static", + "mongodb", + "regex", + "rusqlite", + "serde", + "serde_json", +] + +[[package]] +name = "chrono" +version = "0.4.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-integer", + "num-traits", + "time 0.1.45", + "wasm-bindgen", + "winapi", +] + [[package]] name = "clap" version = "4.1.4" @@ -421,6 +505,16 @@ dependencies = [ "os_str_bytes", ] +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + [[package]] name = "convert_case" version = "0.4.0" @@ -434,10 +528,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb" dependencies = [ "percent-encoding", - "time", + "time 0.3.17", "version_check", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + [[package]] name = "cpufeatures" version = "0.2.5" @@ -466,6 +566,102 @@ dependencies = [ "typenum", ] +[[package]] +name = "cxx" +version = "1.0.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86d3488e7665a7a483b57e25bdd90d0aeb2bc7608c8d0346acf2ad3f1caf1d62" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48fcaf066a053a41a81dfb14d57d99738b767febb8b735c3016e469fac5da690" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2ef98b8b717a829ca5603af80e1f9e2e48013ab227b68ef37872ef84ee479bf" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "086c685979a698443656e5cf7856c95c642295a38599f12fb1ff76fb28d19892" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "darling" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "data-encoding" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb" + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -475,7 +671,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "rustc_version", + "rustc_version 0.4.0", "syn", ] @@ -487,6 +683,7 @@ checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ "block-buffer", "crypto-common", + "subtle", ] [[package]] @@ -498,6 +695,18 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "enum-as-inner" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21cdad81446a7f7dc43f6a77409efeb9733d2fa65553efef6018ef257c959b73" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "errno" version = "0.2.8" @@ -556,12 +765,49 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "futures-channel" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5" +dependencies = [ + "futures-core", +] + [[package]] name = "futures-core" version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" +[[package]] +name = "futures-executor" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8de0a35a6ab97ec8869e32a2473f4b1324459e14c29275d14b10cb1fd19b50e" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfb8371b6fb2aeb2d280374607aeabfc99d95c72edfe51692e42d3d7f0d08531" + +[[package]] +name = "futures-macro" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95a73af87da33b5acf53acfebdc339fe592ecf5357ac7c0a7734ab9d8c876a70" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "futures-sink" version = "0.3.26" @@ -581,9 +827,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1" dependencies = [ "futures-core", + "futures-io", + "futures-macro", "futures-task", + "memchr", "pin-project-lite", "pin-utils", + "slab", ] [[package]] @@ -604,7 +854,7 @@ checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", ] [[package]] @@ -674,6 +924,32 @@ dependencies = [ "libc", ] +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "hostname" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" +dependencies = [ + "libc", + "match_cfg", + "winapi", +] + [[package]] name = "http" version = "0.2.8" @@ -709,6 +985,47 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02296996cb8796d7c6e3bc2d9211b7802812d36999a51bb754123ead7d37d026" +[[package]] +name = "iana-time-zone" +version = "0.1.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] + +[[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.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "idna" version = "0.3.0" @@ -739,6 +1056,24 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "ipconfig" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd302af1b90f2463a98fa5ad469fc212c8e3175a41c3068601bfa2727591c5be" +dependencies = [ + "socket2", + "widestring", + "winapi", + "winreg", +] + +[[package]] +name = "ipnet" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" + [[package]] name = "is-terminal" version = "0.4.2" @@ -766,6 +1101,15 @@ dependencies = [ "libc", ] +[[package]] +name = "js-sys" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "language-tags" version = "0.3.2" @@ -835,6 +1179,21 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "link-cplusplus" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" +dependencies = [ + "cc", +] + +[[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.1.4" @@ -879,25 +1238,38 @@ dependencies = [ ] [[package]] -name = "mdnotes" -version = "0.1.0" +name = "lru-cache" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" dependencies = [ - "actix-files", - "actix-web", - "askama", - "askama_actix", - "clap", - "git2", - "lazy_static", - "regex", - "rusqlite", - "serde", - "serde_json", + "linked-hash-map", ] [[package]] -name = "memchr" -version = "2.5.0" +name = "match_cfg" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" + +[[package]] +name = "matches" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" + +[[package]] +name = "md-5" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" +dependencies = [ + "digest", +] + +[[package]] +name = "memchr" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" @@ -940,10 +1312,56 @@ checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.42.0", ] +[[package]] +name = "mongodb" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5a1df476ac9541b0e4fdc8e2cc48884e66c92c933cd17a1fd75e68caf75752e" +dependencies = [ + "async-trait", + "base64 0.13.1", + "bitflags", + "bson", + "chrono", + "derivative", + "futures-core", + "futures-executor", + "futures-util", + "hex", + "hmac", + "lazy_static", + "md-5", + "os_info", + "pbkdf2", + "percent-encoding", + "rand", + "rustc_version_runtime", + "rustls", + "rustls-pemfile", + "serde", + "serde_bytes", + "serde_with", + "sha-1", + "sha2", + "socket2", + "stringprep", + "strsim", + "take_mut", + "thiserror", + "tokio", + "tokio-rustls", + "tokio-util", + "trust-dns-proto", + "trust-dns-resolver", + "typed-builder", + "uuid 0.8.2", + "webpki-roots", +] + [[package]] name = "nom" version = "7.1.3" @@ -954,6 +1372,16 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.15" @@ -998,6 +1426,16 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "os_info" +version = "3.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c424bc68d15e0778838ac013b5b3449544d8133633d8016319e7e05a820b8c0" +dependencies = [ + "log", + "winapi", +] + [[package]] name = "os_str_bytes" version = "6.4.1" @@ -1033,6 +1471,15 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" +[[package]] +name = "pbkdf2" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271779f35b581956db91a3e55737327a03aa051e90b1c47aeb189508533adfd7" +dependencies = [ + "digest", +] + [[package]] name = "percent-encoding" version = "2.2.0" @@ -1096,6 +1543,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + [[package]] name = "quote" version = "1.0.23" @@ -1161,6 +1614,31 @@ version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +[[package]] +name = "resolv-conf" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" +dependencies = [ + "hostname", + "quick-error", +] + +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi", +] + [[package]] name = "rusqlite" version = "0.28.0" @@ -1175,13 +1653,32 @@ dependencies = [ "smallvec", ] +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver 0.9.0", +] + [[package]] name = "rustc_version" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver", + "semver 1.0.16", +] + +[[package]] +name = "rustc_version_runtime" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d31b7153270ebf48bf91c65ae5b0c00e749c4cfad505f66530ac74950249582f" +dependencies = [ + "rustc_version 0.2.3", + "semver 0.9.0", ] [[package]] @@ -1198,6 +1695,27 @@ dependencies = [ "windows-sys 0.42.0", ] +[[package]] +name = "rustls" +version = "0.20.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" +dependencies = [ + "log", + "ring", + "sct", + "webpki", +] + +[[package]] +name = "rustls-pemfile" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ee86d63972a7c661d1536fefe8c3c8407321c3df668891286de28abcd087360" +dependencies = [ + "base64 0.13.1", +] + [[package]] name = "ryu" version = "1.0.12" @@ -1210,12 +1728,43 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "scratch" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" + +[[package]] +name = "sct" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + [[package]] name = "semver" version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + [[package]] name = "serde" version = "1.0.152" @@ -1225,6 +1774,15 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde_bytes" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "416bda436f9aab92e02c8e10d49a15ddd339cea90b6e340fe51ed97abb548294" +dependencies = [ + "serde", +] + [[package]] name = "serde_derive" version = "1.0.152" @@ -1242,6 +1800,7 @@ version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" dependencies = [ + "indexmap", "itoa", "ryu", "serde", @@ -1259,6 +1818,39 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_with" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678b5a069e50bf00ecd22d0cd8ddf7c236f68581b03db652061ed5eb13a312ff" +dependencies = [ + "serde", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e182d6ec6f05393cc0e5ed1bf81ad6db3a8feedf8ee515ecdd369809bcce8082" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sha-1" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sha1" version = "0.10.5" @@ -1270,6 +1862,17 @@ dependencies = [ "digest", ] +[[package]] +name = "sha2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "signal-hook-registry" version = "1.4.0" @@ -1304,12 +1907,34 @@ dependencies = [ "winapi", ] +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "stringprep" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ee348cb74b87454fff4b551cbf727025810a004f88aeacae7f85b87f4e9a1c1" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "strsim" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + [[package]] name = "syn" version = "1.0.107" @@ -1321,6 +1946,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "take_mut" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" + [[package]] name = "termcolor" version = "1.2.0" @@ -1330,6 +1961,37 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "thiserror" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "time" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" +dependencies = [ + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi", +] + [[package]] name = "time" version = "0.3.17" @@ -1383,13 +2045,37 @@ dependencies = [ "libc", "memchr", "mio", + "num_cpus", "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", + "tokio-macros", "windows-sys 0.42.0", ] +[[package]] +name = "tokio-macros" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-rustls" +version = "0.23.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" +dependencies = [ + "rustls", + "tokio", + "webpki", +] + [[package]] name = "tokio-util" version = "0.7.4" @@ -1434,6 +2120,62 @@ dependencies = [ "once_cell", ] +[[package]] +name = "trust-dns-proto" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c31f240f59877c3d4bb3b3ea0ec5a6a0cff07323580ff8c7a605cd7d08b255d" +dependencies = [ + "async-trait", + "cfg-if", + "data-encoding", + "enum-as-inner", + "futures-channel", + "futures-io", + "futures-util", + "idna 0.2.3", + "ipnet", + "lazy_static", + "log", + "rand", + "smallvec", + "thiserror", + "tinyvec", + "tokio", + "url", +] + +[[package]] +name = "trust-dns-resolver" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4ba72c2ea84515690c9fcef4c6c660bb9df3036ed1051686de84605b74fd558" +dependencies = [ + "cfg-if", + "futures-util", + "ipconfig", + "lazy_static", + "log", + "lru-cache", + "parking_lot", + "resolv-conf", + "smallvec", + "thiserror", + "tokio", + "trust-dns-proto", +] + +[[package]] +name = "typed-builder" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89851716b67b937e393b3daa8423e67ddfc4bbbf1654bcf05488e95e0828db0c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "typenum" version = "1.16.0" @@ -1470,6 +2212,18 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + [[package]] name = "url" version = "2.3.1" @@ -1477,10 +2231,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" dependencies = [ "form_urlencoded", - "idna", + "idna 0.3.0", "percent-encoding", ] +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +dependencies = [ + "getrandom", +] + +[[package]] +name = "uuid" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1674845326ee10d37ca60470760d4288a6f80f304007d92e5c53bab78c9cfd79" +dependencies = [ + "getrandom", + "serde", +] + [[package]] name = "vcpkg" version = "0.2.15" @@ -1493,12 +2266,107 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" + +[[package]] +name = "web-sys" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "webpki-roots" +version = "0.22.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" +dependencies = [ + "webpki", +] + +[[package]] +name = "widestring" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17882f045410753661207383517a6f62ec3dbeb6a4ed2acce01f0728238d1983" + [[package]] name = "winapi" version = "0.3.9" @@ -1611,6 +2479,15 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] + [[package]] name = "zstd" version = "0.12.3+zstd.1.5.2" diff --git a/Cargo.toml b/Cargo.toml index a4b4e94..4ac4247 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "mdnotes" +name = "cheezenotes" version = "0.1.0" edition = "2021" @@ -22,4 +22,6 @@ git2 = "0.16.0" regex = "1" rusqlite = {version = "0.28.0", features=["bundled"]} + lazy_static = "1.4.0" +mongodb = "2.3.1" diff --git a/README.md b/README.md index f22bbcd..d03f685 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -mdnotes +cheezenotes ====== Notes utilisant la syntaxe MarkDown pour être rapide et facile à modifier. diff --git a/pages/Gaufres de Mulhouse.md b/pages/Gaufres de Mulhouse.md new file mode 100644 index 0000000..c4d31c1 --- /dev/null +++ b/pages/Gaufres de Mulhouse.md @@ -0,0 +1,14 @@ +[Cuisine](cuisine) +# Gaufres de Mulhouse +> Pour une douzaine de gaufres environ +## Ingrédients +- 125 g de beurre pommade +- 250 g de farine +- 4 œufs +- 37 cl de lait tiède +- 65 g de sucre +- 1 sachet de levure chimique +## Recette +Tourner le beurre en pommade. Ajouter les œufs un à un en tournant bien entre chaque œuf. +Incorporer la farine en alternant avec le lait tiède et le sucre. Ajouter une pincée de sel fin et la levure chimique. +Laisser reposer la pâte une heure avant de faire les gaufres. \ No newline at end of file diff --git a/pages/Gaufres.md b/pages/Gaufres.md new file mode 100644 index 0000000..e5ca5eb --- /dev/null +++ b/pages/Gaufres.md @@ -0,0 +1,21 @@ +[Cuisine](cuisine) +# Gaufres +> Gaufres inspirées de la recette de la grand-mère Bocuse +## Ingrédients +- 150 g de beurre +- 4 oeufs entier +- 250 g de farine +- 40 cl de crème liquide +- 12 cl d'eau (à adopter selon la consistance) +- 1 pincée de sel fin +- 35 g de sucre semoule +## Recette +Faire fondre le beurre dans une casserole. +Séparer les blancs des jaunes d'oeuf. + +Mettre la farine dans un saladier et former un puits. +Ajouter la crème liquide et progressivement l'eau tout en incorporant la farine à l'aide d'un fouet (la pâte doit faire le ruban). +Ajouter, tout en mélangeant, le beurre fondu + +Cuisson dans le gaufrier position II moelleux. +Deux cuillère à salade bien remplie pour chaque fournée. \ No newline at end of file diff --git a/pages/Glace au yaourt.md b/pages/Glace au yaourt.md new file mode 100644 index 0000000..b74d63f --- /dev/null +++ b/pages/Glace au yaourt.md @@ -0,0 +1,11 @@ +[Cuisine](cuisine) +# Glace au yaourt +> Pour 1l de glace environ +## Ingrédients +- 3 yaourts à la vanille maison +- 20 cl de crème liquide +- 100 g de sucre +## Recette +Fouetter la crème en ajoutant progressivement le sucre. +Mélanger délicatement la crème fouettée et le yaourt. +Turbiner 40 minutes. \ No newline at end of file diff --git a/pages/Kouglof perdu.md b/pages/Kouglof perdu.md new file mode 100644 index 0000000..5632126 --- /dev/null +++ b/pages/Kouglof perdu.md @@ -0,0 +1,9 @@ +[Cuisine](cuisine) +# Kouglof perdu +> Comme du pain perdu +## Ingrédients +- 50 cl de lait +- 60 g de sucre +- 2 œufs +- Du sucre en poudre ou du caramel +## Recette \ No newline at end of file diff --git a/pages/Kouglof.md b/pages/Kouglof.md new file mode 100644 index 0000000..b88d74a --- /dev/null +++ b/pages/Kouglof.md @@ -0,0 +1,31 @@ +[Cuisine](cuisine) +# Kouglof +> Pour un moule moyen à kouglof (pour un grand moule, voir les informations entre parenthèses) +## Ingrédients +- 375 g (500 g) de farine +- 150 g (200 g) de beurre +- 60 g (80 g) de sucre +- Une pincée de sel +- 3 œufs (4 œufs) entiers (moyen) +- 1,5 paquets (2 paquets) de levure de boulangerie sèche (oetker) +- 75 ml (100 ml) de lait légèrement tiédi +- 75 g (100 g) de raisin sec +## Recette +Faire gonfler les raisins secs dans de l'eau chaude avec du sucre. + +Mettre la levure dans le lait tiède. + +Tout mettre dans le bol du robot (sauf les raisins secs) et battre au crochet jusqu'à ce que la pâte se détache du crochet. + +Egouter les raisins secs et les ajouter à la pâte et faire tourner le robot pour bien les incorporer à la pâte. + +Mettre un torchon humide sur le bol du mixer et faire lever dans le bol du mixer (2h environ). + +Beurrer le moule et mettre du sucre et couvrir d'amandes effilées. + +Sortir la pâte du bol du mixer, la casser et façonner comme une boule de pâte à pizza (replier plusieurs fois pour incorporer de l'air). +Faire un trou au milieu de la pâte et la mettre dans le moule et laisser monter encore une fois (1 bonne heure) en couvrant avec un torchon humide. + +Mettre au four à 160°C pendant 45 minutes (50 minutes). + +Démouler à la sortie du four et laisser refroidir sur une grille. \ No newline at end of file diff --git a/pages/Madeleines.md b/pages/Madeleines.md new file mode 100644 index 0000000..e86beb6 --- /dev/null +++ b/pages/Madeleines.md @@ -0,0 +1,18 @@ +[Cuisine](cuisine) +# Madeleines +> Madeleines De Commercy ou d'ailleurs. +> Recette pour 12 madeleines environ +## Ingrédients +- 2 œufs entiers +- 87 g de sucre semoule +- 33 g de Lait +- 125 g de farine +- 5 g de levure chimique +- 125 g de beurre +- 1 gousse de vanille ou le zeste râpé d'un citron non traité +## Recette +Beurrer et fariner les moules à madeleines. +Mélanger les oeufs et le sucre. +Ajouter le lait. +Ajouter la farine et la poudre à lever préalablement mélangés. +Ajouter les arômes. \ No newline at end of file diff --git a/pages/Mangues pochées au jus d'orange sanguine.md b/pages/Mangues pochées au jus d'orange sanguine.md new file mode 100644 index 0000000..6db5aec --- /dev/null +++ b/pages/Mangues pochées au jus d'orange sanguine.md @@ -0,0 +1,14 @@ +[Cuisine](cuisine) +## Mangues pochées au jus d'orange sanguine +> A tester +## Ingrédients +- Une mangue +- 30 cl de jus d'orange sanguine +- 60 g de sucre semoule +- 1 feuille de menthe +## Recette +Porter à ébullition le jus d'orange et le sucre avec la feuille de menthe. +Laisser refroidir. + +Couper la mangue en fines lamelles et les plonger dans le sirop obtenu. +Faire cuire pendant 10 minutes à feu doux. \ No newline at end of file diff --git a/pages/Meringues.md b/pages/Meringues.md new file mode 100644 index 0000000..77b04d1 --- /dev/null +++ b/pages/Meringues.md @@ -0,0 +1,13 @@ +[Cuisine](cuisine) +# Meringues +> Des mini meringues qui tiennent sur deux plaques de cuisson +## Ingrédients +- 340 g de sucre +- 5 blancs d’œufs +- 1 cuillère à café d’extrait de vanille +## Recette +Battre les blancs d’œufs en ajoutant progressivement 170 g de sucre jusqu’à ce qu’ils doublent de volume. +Ajouter 85 g de sucre et l’extrait de vanille et fouetter jusqu’à ce que les œufs soient brillants et fermes. +Ajouter le reste de sucre en pluie et continuer à battre deux minutes. +A l’aide d’une poche à douille former les meringues sur une plaque de cuisson. +Cuire 1h15 a 90ºC. \ No newline at end of file diff --git a/pages/Sauce caramel beurre salé.md b/pages/Sauce caramel beurre salé.md new file mode 100644 index 0000000..6ac1c90 --- /dev/null +++ b/pages/Sauce caramel beurre salé.md @@ -0,0 +1,15 @@ +[Cuisine](cuisine) +# Sauce caramel beurre salé +> Idéale pour les crêpes ou les gaufres. +## Ingrédients +- 20 cl de crème liquide (environ 190 g) +- 30 g de beurre demi-sel +- 160 g de sucre en poudre +## Recette +Mettre une casserole sur feu doux et repartir une petite quantité du sucre sur toute la surface, puis au fur et à mesure qu’il fond rajouter le sucre. Ne pas remuer. + +Pendant ce temps faire bouillir la crème. + +Une fois tout le sucre fondu, le caramel sera alors noisette, décuire avec le beurre coupé en petits dés (verser peu à peu le beurre en remuant sans s’arreter pour faire baisser la température du sucre). + +Puis ajouter la crème bouillie en remuant. Porter à ébullition puis verser dans un récipient placé dans de l’eau glacée. \ No newline at end of file diff --git a/pages/accueil.md b/pages/accueil.md index 15c0c60..7b78700 100644 --- a/pages/accueil.md +++ b/pages/accueil.md @@ -1,4 +1,5 @@ -[index]() +[Index](index) # Accueil ## [Notes](notes) ## [Cuisine](cuisine) +[Page de tests pour le développement de CheezeNotes](test) \ No newline at end of file diff --git a/pages/cuisine.md b/pages/cuisine.md index d49f94c..b0a10c1 100644 --- a/pages/cuisine.md +++ b/pages/cuisine.md @@ -46,4 +46,14 @@ [Crêpes]() [Fondants au chocolat]() [Gâteau au chocolat leger]() +[Gaufres]() +[Gaufres de Mulhouse]() +[Glace au yaourt]() +[Kouglof]() +[Kouglof perdu]() +[Madeleines]() +[Mangues pochées au jus d'orange sanguine]() +[Meringues]() +[Œufs au lait]() +[Sauce caramel beurre salé]() ## Autre \ No newline at end of file diff --git a/pages/index.md b/pages/index.md index f534687..2bb31ff 100644 --- a/pages/index.md +++ b/pages/index.md @@ -1,6 +1,7 @@ -# RustyNotes -L'objectif de RustyNotes est de pouvoir saisir des notes avec un minimum de formatage le plus rapidement possible. -> Cette page est un bac à sable. Les modifications ne seront jamais enregistrées. +[Accueil](accueil) +# CheezeNotes +L'objectif de CheezeNotes est de pouvoir saisir des notes avec un minimum de formatage le plus rapidement possible. +> Cette page est un bac à sable. Les modifications ne seront jamais enregistrées. > Pour réinitialiser la page, il suffit de la recharger. ## Utilisation Pour passer en mode édition, il suffit de cliquer sur le texte à modifier. @@ -13,16 +14,20 @@ Il y a 4 niveaux de titres : - `## titre 2` - `### titre 3` - `#### titre 4` +- `##### titre 5` +- `###### titre 6` ### **Gras**, *italic* etc. |:Syntaxe:|:Résultat:|:Ok ?:| |:`**gras**`|:**gras**|:| |`*italic*`|*italic*|| |`__gras__`|__gras__|| |`_italic_`|_italic_|| +|`~~barré~~`|~~barré~~|| |`***gras_italic***`|***gras_italic***|| |`___gras_italic___`|___gras_italic___|Non| |`__*gras_italic*__`|__*gras_italic*__|| |````texte formaté````|`texte formaté`|| +| `````````|```|| ### Liens Pour une url longue à laquelle on veut associer un libellé plus parlant, on choisira la syntaxe complète : - [Wikipedia Markdown](https://fr.wikipedia.org/wiki/Markdown) diff --git a/pages/test.md b/pages/test.md new file mode 100644 index 0000000..4d17437 --- /dev/null +++ b/pages/test.md @@ -0,0 +1,3 @@ +[Accueil](accueil) +# Test pour développement CheezeNotes +test de gras au milieu d'un texte \ No newline at end of file diff --git a/pages/Œufs au lait.md b/pages/Œufs au lait.md new file mode 100644 index 0000000..1b91d01 --- /dev/null +++ b/pages/Œufs au lait.md @@ -0,0 +1,25 @@ +[Cuisine](cuisine) +# Œufs au lait +> Pour 6 ramequins +## Ingrédients +- 75 g de sucre en poudre +- Une gousse de vanille +- 50 cl de lait +- 3 gros œufs +## Recette +Dans une casserole, mettez le lait, le sucre en poudre et la demi-gousse de vanille +fendue dans le sens de la longueur, puis portez à ébullition. Éteignez le feu et laissez infuser 5 minutes, retirez ensuite la vanille. + +Battez vigoureusement les oeufs dans une terrine. Versez peu à peu le lait chaud +tout en battant. Passez cette crème au travers d’un tamis fin et répartissez-la dans six ramequins. + +Recouvrez la lèchefrite du four avec deux ou trois épaisseurs de papier absorbant. +Posez les ramequins. Remplissez d’eau jusqu’au niveau de la crème. + +Enfournez (à 210°C) en prenant soin de placer le plat au tiers supérieur du four +pour que le fond des ramequins ne reçoive pas de chaleur trop vive et que la surface, +en revanche, se teinte légèrement. La crème est cuite lorsqu’elle ne coule plus, soit au +bout de 40 minutes environ. Retirez du four et laissez refroidir : la crème épaissit en +refroidissant. + +Servez et dégustez. \ No newline at end of file diff --git a/src/commons.rs b/src/commons.rs index 27e29a8..08937c9 100644 --- a/src/commons.rs +++ b/src/commons.rs @@ -6,8 +6,11 @@ pub struct Arguments { #[arg(short, long, default_value_t = String::from("127.0.0.1"))] pub ip: String, /// Port to listen to - #[arg(short, long, default_value_t = 8081)] + #[arg(short, long, default_value_t = 8333)] pub port: u16, + /// root of the url ending and starting with / + #[arg(short, long, default_value_t = String::from("/"))] + pub root: String, } impl Arguments { @@ -22,7 +25,8 @@ impl Arguments { #[derive(Clone)] pub struct AppData { pub name: String, + pub root: String, pub db_url: String, pub db_user: String, - pub db_passwd: String, + pub db_password: String, } diff --git a/src/index.rs b/src/index.rs index 3ca19a3..cd073d7 100644 --- a/src/index.rs +++ b/src/index.rs @@ -10,10 +10,12 @@ use crate::commons::AppData; #[template(path = "index.html")] pub struct PageTemplate { pub name: String, + pub root: String, } #[get("/")] async fn index(data: web::Data) -> impl Responder { let name = data.name.to_owned(); - PageTemplate { name }.to_response() + let root = data.root.to_owned(); + PageTemplate { name, root }.to_response() } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 505893e..2cb7592 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,8 @@ use actix_web::{web, App, HttpServer}; use actix_files; -use mdnotes::commons::{Arguments, AppData}; -use mdnotes::{ page, index }; +use cheezenotes::commons::{Arguments, AppData}; +use cheezenotes::{ page, index }; #[actix_web::main] async fn main() -> std::io::Result<()> { @@ -11,9 +11,14 @@ async fn main() -> std::io::Result<()> { let ip = args.ip; let port = args.port; + let root = args.root; let appdata = AppData { - name: String::from("MdNotes"), + name: String::from("CheezeNotes"), + root, + db_url: String::from(""), + db_user: String::from(""), + db_password: String::from(""), }; HttpServer::new(move || { diff --git a/src/page.rs b/src/page.rs index b395be9..8f04485 100644 --- a/src/page.rs +++ b/src/page.rs @@ -9,12 +9,13 @@ use askama_actix::Template; use askama_actix::TemplateToResponse; use crate::commons::AppData; -use crate::database::DatabaseConnection; +//use crate::database::DatabaseConnection; #[derive(Template)] #[template(path = "page.html")] pub struct PageTemplate { pub name: String, + pub root: String, pub md: String, pub init: String, } @@ -23,21 +24,22 @@ pub struct PageTemplate { async fn page(path: web::Path<(String,)>, data: web::Data) -> impl Responder { let pagename = &path.0; let name = data.name.to_owned() + " " + pagename.as_str(); + let root = data.root.to_owned(); let filename = String::from("pages/") + pagename.as_str() + ".md"; let md = match fs::read_to_string(filename) { Ok(txt) => txt, Err(_) => String::from("# Nouvelle page"), }; let init = String::from("init();"); - PageTemplate { name, md, init }.to_response() + PageTemplate { name, root, md, init }.to_response() } #[put("/page/{page}")] async fn save_page(body: String, path: web::Path<(String,)>) -> impl Responder { let pagename = &path.0; - if pagename == "index" { + /*if pagename == "index" { return HttpResponse::Ok(); - } + }*/ let filename = String::from("pages/") + pagename.as_str() + ".md"; let mut file = match fs::File::create(&filename) { Ok(f) => f, diff --git a/static/MaterialIcons-Regular.ttf b/static/MaterialIcons-Regular.ttf new file mode 100644 index 0000000..9d09b0f Binary files /dev/null and b/static/MaterialIcons-Regular.ttf differ diff --git a/static/cheezenotes.css b/static/cheezenotes.css new file mode 100644 index 0000000..c04fe93 --- /dev/null +++ b/static/cheezenotes.css @@ -0,0 +1,283 @@ +@font-face { + font-family: 'Material Icons'; + font-style: normal; + font-weight: 400; + src: local('Material Icons'), + local('MaterialIcons-Regular'), + url(/static/MaterialIcons-Regular.ttf) format('truetype'); +} + +.material-icons { + font-family: 'Material Icons'; + font-weight: normal; + font-style: normal; + font-size: 24px; /* Preferred icon size */ + display: inline-block; + line-height: 1; + text-transform: none; + letter-spacing: normal; + word-wrap: normal; + white-space: nowrap; + direction: ltr; + -webkit-font-smoothing: antialiased; + text-rendering: optimizeLegibility; + -moz-osx-font-smoothing: grayscale; + font-feature-settings: 'liga'; +} + +html { + font-family: system-ui; + font-size: 12pt; +} + +body { + margin: 0; + background-color: #f6f6f6; +} + +button { + width: 2.2rem; + height: 2.2rem; +} + +div#buttons { + position: fixed; + background-color: #dddddddd; + border-bottom: 3px solid #ccccccdd; + top: 0; + left: 0; + right: 0; + height: 3rem; + margin-left: auto; + margin-right: auto; + max-width: 1200; +} + +div#buttons #taButtonLabel { + position: relative; + font-size: 1.8rem; + top: +0.2rem; +} + +div#buttons #lockButtonLabel { + position: relative; + top: +.5rem; +} + +div.ta { + margin-left: auto; + margin-right: auto; + max-width: 1200; +} + +textarea#ta { + position: relative; + top: 3rem; + display: none; + width: 100%; + height: 15rem; + padding-left: 3rem; + padding-right: 3rem; + background-color: #cceeff; +} + +div#cheezenotes { + margin-top: 3rem; + margin-left: auto; + margin-right: auto; + max-width: 1200; + padding-top: 1rem; + padding-left: 3rem; + padding-right: 3rem; + padding-bottom: 1rem; + margin-bottom: 3rem; + background-color: #ffffff; + min-height: 90%; + overflow-x: auto; +} + +div#cheezenotes div.cheezenotes_line { + /* Pour firefox : white-space: pre; */ +} + +div#cheezenotes span.tokenfictif { + font-weight: 1; + color: #1353b3; +} + +div#cheezenotes:focus { + outline: none; +} + +div#cheezenotes div.line { + border-bottom: 1px solid #dddddd; + padding-top: 0rem; + margin-top: 0rem; + font-size: 8pt; +} + +div#cheezenotes div.h1 { + font-size: 3rem; + margin-top: 1.5rem; + margin-bottom: 1.3rem; + padding-bottom: 0.5rem; + border-bottom: 1px solid #dddddd; +} + +div#cheezenotes div.h2 { + font-size: 2.3rem; + margin-top: 1rem; + margin-bottom: 1rem; +} + +div#cheezenotes div.h3 { + font-size: 1.8rem; + margin-top: 0.8rem; + margin-bottom: 0.8rem; +} + +div#cheezenotes div.h4 { + font-size: 1.5rem; + margin-top: 0.5rem; + margin-bottom: 0.5rem; +} + +div#cheezenotes div.h5 { + font-size: 1.3rem; + margin-top: 0.5rem; + margin-bottom: 0.5rem; +} + +div#cheezenotes div.h6 { + font-size: 1.2rem; + margin-top: 0.5rem; + margin-bottom: 0.5rem; +} + +div#cheezenotes div.bq1 { + padding-top: 0.3rem; + padding-bottom: 0.3rem; + padding-left: .9rem; + background-color: #f5f5f5; + border-left: .3rem solid #446699; +} + +div#cheezenotes div.bq2 { + padding-top: 0.3rem; + padding-bottom: 0.3rem; + padding-left: .6rem; + background-color: #f5f5f5; + border-left: .6rem solid #5577aa; +} + +div#cheezenotes div.bq3 { + padding-top: 0.3rem; + padding-bottom: 0.3rem; + padding-left: .3rem; + background-color: #f5f5f5; + border-left: .9rem solid #6688bb; +} + +div#cheezenotes div.ul1 { display:list-item; list-style-position: inside; padding-left: 2.2rem; padding-bottom: .2rem; padding-top: .2rem; } +div#cheezenotes div.ul1.bq1 { padding-left: 1.9rem; } +div#cheezenotes div.ul1.bq2 { padding-left: 1.6rem; } +div#cheezenotes div.ul1.bq3 { padding-left: 1.3rem; } + +div#cheezenotes div.ul2 { display:list-item; list-style-position: inside; list-style-type: circle; padding-left: 2.7rem; padding-bottom: .2rem; padding-top: .2rem; } +div#cheezenotes div.ul2.bq1 { padding-left: 2.4rem; } +div#cheezenotes div.ul2.bq2 { padding-left: 2.1rem; } +div#cheezenotes div.ul2.bq3 { padding-left: 1.8rem; } + +div#cheezenotes div.ul3 { display:list-item; list-style-position: inside; list-style-type: square; padding-left: 3.2rem; padding-bottom: .2rem; padding-top: .2rem; } +div#cheezenotes div.ul3.bq1 { padding-left: 2.9rem; } +div#cheezenotes div.ul3.bq2 { padding-left: 2.6rem; } +div#cheezenotes div.ul3.bq3 { padding-left: 2.3rem; } + +div#cheezenotes div.ol1 { padding-left: 2.2rem; padding-bottom: .2rem; padding-top: .2rem; } +div#cheezenotes div.ol1.bq1 { padding-left: 1.9rem; } +div#cheezenotes div.ol1.bq2 { padding-left: 1.6rem; } +div#cheezenotes div.ol1.bq3 { padding-left: 1.3rem; } + +div#cheezenotes div.ol2 { padding-left: 2.7rem; padding-bottom: .2rem; padding-top: .2rem; } +div#cheezenotes div.ol2.bq1 { padding-left: 2.4rem; } +div#cheezenotes div.ol2.bq2 { padding-left: 2.1rem; } +div#cheezenotes div.ol2.bq3 { padding-left: 1.8rem; } + +div#cheezenotes div.ol3 { padding-left: 3.2rem; padding-bottom: .2rem; padding-top: .2rem; } +div#cheezenotes div.ol3.bq1 { padding-left: 2.9rem; } +div#cheezenotes div.ol3.bq2 { padding-left: 2.6rem; } +div#cheezenotes div.ol3.bq3 { padding-left: 2.3rem; } + +div#cheezenotes span.oltoken { + display: inline-block; + width: 2rem; +} + +div#cheezenotes a.link { + color: rgb(0, 0, 238); +} + +div#cheezenotes span.lefttablespacer { + display: inline-block; +} + +div#cheezenotes span.righttablespacer { + display: inline-block; +} + +div#cheezenotes div.tablerow { + margin-top: .5rem; + margin-bottom: .9rem; + overflow-x: visible; +} + +div#cheezenotes span.tablerow { + white-space: nowrap; + overflow-x: visible; + border-bottom: 1px solid #dddddd; + padding-bottom: 0.4rem; +} + +div#cheezenotes div.firsttablerow { + margin-top: 1.5rem; +} + +div#cheezenotes div.firsttablerow span.tablerow { + margin-bottom: 1.5rem; + border-bottom: 1px solid #666666; + font-weight: bold; +} + +div#cheezenotes div.lasttablerow { + margin-bottom: 1.5rem; +} + +div#cheezenotes div.lasttablerow span.tablerow { + margin-bottom: 1.5rem; + border-bottom: none; +} + + + +div#cheezenotes div.cheezenotes_line span.token { + font-weight: 1; + color: #1353b3; + overflow: hidden; +} + +div#cheezenotes div.cheezenotes_line span.token { + font-size: 0; +} + +div#cheezenotes:focus div.cheezenotes_line span.token { + font-size: inherit; +} + +div#cheezenotes div.body { + margin-top: 0.5rem; + margin-bottom: 0.5rem; +} +div#cheezenotes span.mono { + font-family: monospace; + color: #555555; +} \ No newline at end of file diff --git a/static/mdnotes.css b/static/mdnotes.css deleted file mode 100644 index 8fdf4b8..0000000 --- a/static/mdnotes.css +++ /dev/null @@ -1,251 +0,0 @@ -html { - font-family: system-ui; - font-size: 12pt; -} - -body { - margin: 0; - background-color: #f6f6f6; -} - -button { - width: 2.2rem; - height: 2.2rem; -} - -div#buttons { - position: fixed; - background-color: #dddddddd; - border-bottom: 3px solid #ccccccdd; - top: 0; - left: 0; - right: 0; - height: 3rem; - margin-left: auto; - margin-right: auto; - max-width: 1200; -} - -div#buttons #taButtonLabel { - position: relative; - font-size: 1.8rem; - top: +0.2rem; -} - -div#buttons #lockButtonLabel { - position: relative; - font-size: 1.8rem; - top: +0.2rem; -} - -div.ta { - margin-left: auto; - margin-right: auto; - max-width: 1200; -} - -textarea#ta { - position: relative; - top: 3rem; - display: none; - width: 100%; - height: 15rem; - padding-left: 3rem; - padding-right: 3rem; - background-color: #cceeff; -} - -div#mdnotes { - margin-top: 3rem; - margin-left: auto; - margin-right: auto; - max-width: 1200; - padding-top: 1rem; - padding-left: 3rem; - padding-right: 3rem; - padding-bottom: 1rem; - margin-bottom: 3rem; - background-color: #ffffff; - min-height: 90%; - overflow-x: auto; -} - -div#mdnotes div.mdnotes_line { - /* Pour firefox : white-space: pre; */ -} - -div#mdnotes span.tokenfictif { - font-weight: 1; - color: #1353b3; -} - -div#mdnotes:focus { - outline: none; -} - -div#mdnotes div.line { - border-bottom: 1px solid #dddddd; - padding-top: 0rem; - margin-top: 0rem; - font-size: 8pt; -} - -div#mdnotes div.h1 { - font-size: 3rem; - margin-top: 1.5rem; - margin-bottom: 1.3rem; - padding-bottom: 0.5rem; - border-bottom: 1px solid #dddddd; -} - -div#mdnotes div.h2 { - font-size: 2.3rem; - margin-top: 1rem; - margin-bottom: 1rem; -} - -div#mdnotes div.h3 { - font-size: 1.8rem; - margin-top: 0.8rem; - margin-bottom: 0.8rem; -} - -div#mdnotes div.h4 { - font-style: italic; - font-size: 1.4rem; - margin-top: 0.5rem; - margin-bottom: 0.5rem; -} - -div#mdnotes div.bq1 { - padding-top: 0.3rem; - padding-bottom: 0.3rem; - padding-left: .9rem; - background-color: #f5f5f5; - border-left: .3rem solid #446699; -} - -div#mdnotes div.bq2 { - padding-top: 0.3rem; - padding-bottom: 0.3rem; - padding-left: .6rem; - background-color: #f5f5f5; - border-left: .6rem solid #5577aa; -} - -div#mdnotes div.bq3 { - padding-top: 0.3rem; - padding-bottom: 0.3rem; - padding-left: .3rem; - background-color: #f5f5f5; - border-left: .9rem solid #6688bb; -} - -div#mdnotes div.ul1 { display:list-item; list-style-position: inside; padding-left: 2.2rem; padding-bottom: .2rem; padding-top: .2rem; } -div#mdnotes div.ul1.bq1 { padding-left: 1.9rem; } -div#mdnotes div.ul1.bq2 { padding-left: 1.6rem; } -div#mdnotes div.ul1.bq3 { padding-left: 1.3rem; } - -div#mdnotes div.ul2 { display:list-item; list-style-position: inside; list-style-type: circle; padding-left: 2.7rem; padding-bottom: .2rem; padding-top: .2rem; } -div#mdnotes div.ul2.bq1 { padding-left: 2.4rem; } -div#mdnotes div.ul2.bq2 { padding-left: 2.1rem; } -div#mdnotes div.ul2.bq3 { padding-left: 1.8rem; } - -div#mdnotes div.ul3 { display:list-item; list-style-position: inside; list-style-type: square; padding-left: 3.2rem; padding-bottom: .2rem; padding-top: .2rem; } -div#mdnotes div.ul3.bq1 { padding-left: 2.9rem; } -div#mdnotes div.ul3.bq2 { padding-left: 2.6rem; } -div#mdnotes div.ul3.bq3 { padding-left: 2.3rem; } - -div#mdnotes div.ol1 { padding-left: 2.2rem; padding-bottom: .2rem; padding-top: .2rem; } -div#mdnotes div.ol1.bq1 { padding-left: 1.9rem; } -div#mdnotes div.ol1.bq2 { padding-left: 1.6rem; } -div#mdnotes div.ol1.bq3 { padding-left: 1.3rem; } - -div#mdnotes div.ol2 { padding-left: 2.7rem; padding-bottom: .2rem; padding-top: .2rem; } -div#mdnotes div.ol2.bq1 { padding-left: 2.4rem; } -div#mdnotes div.ol2.bq2 { padding-left: 2.1rem; } -div#mdnotes div.ol2.bq3 { padding-left: 1.8rem; } - -div#mdnotes div.ol3 { padding-left: 3.2rem; padding-bottom: .2rem; padding-top: .2rem; } -div#mdnotes div.ol3.bq1 { padding-left: 2.9rem; } -div#mdnotes div.ol3.bq2 { padding-left: 2.6rem; } -div#mdnotes div.ol3.bq3 { padding-left: 2.3rem; } - -div#mdnotes span.oltoken { - display: inline-block; - width: 2rem; -} - -div#mdnotes span.lefttablespacer { - display: inline-block; -} - -div#mdnotes span.righttablespacer { - display: inline-block; -} - -div#mdnotes div.tablerow { - margin-top: .5rem; - margin-bottom: .9rem; - overflow-x: visible; -} - -div#mdnotes span.tablerow { - white-space: nowrap; - overflow-x: visible; - border-bottom: 1px solid #dddddd; - padding-bottom: 0.4rem; -} - -div#mdnotes div.firsttablerow { - margin-top: 1.5rem; -} - -div#mdnotes div.firsttablerow span.tablerow { - margin-bottom: 1.5rem; - border-bottom: 1px solid #666666; - font-weight: bold; -} - -div#mdnotes div.lasttablerow { - margin-bottom: 1.5rem; -} - -div#mdnotes div.lasttablerow span.tablerow { - margin-bottom: 1.5rem; - border-bottom: none; -} - - - -div#mdnotes div.mdnotes_line span.token { - font-weight: 1; - color: #1353b3; - overflow: hidden; -} - -div#mdnotes div.mdnotes_line span.token { - font-size: 0; -} - -div#mdnotes:focus div.mdnotes_line span.token { - font-size: inherit; -} - -div#mdnotes div.body { - margin-top: 0.5rem; - margin-bottom: 0.5rem; -} - -div#mdnotes span.bold { - font-weight: bold; -} - -div#mdnotes span.italic { - font-style: italic; -} - -div#mdnotes span.mono { - font-family: monospace; - color: #885511; -} \ No newline at end of file diff --git a/static/modules/caret.js b/static/modules/caret.js new file mode 100644 index 0000000..6bab702 --- /dev/null +++ b/static/modules/caret.js @@ -0,0 +1,193 @@ +function insertTextAtCaret(txtBefore, txtAfter = '') { + let ret = saveSelection(); + let line = ret[0]; + let start = ret[1]; + let end = ret[3]; + let txt = line.innerText; + let before = '' + if (start == 0) { + } else { + before = txt.substring(0, start); + } + let after = txt.substring(end, txt.length); + let selection = ''; + if (end > start) { + selection = txt.substring(start, end); + } + line.innerHTML = before + txtBefore + selection + txtAfter + after; + let span = document.createElement('span'); + if (start == end && ret[0] == ret[2]) { + span.innerHTML = txtBefore; + ret[1] = start + span.innerText.length; + ret[3] = ret[1]; + } else { + span.innerHTML = txtBefore + txtAfter; + ret[3] = end + span.innerText.length; + } + loadSelection(ret); +} + +function saveSelection() { + let ret = getStartPositionInLine(); + let startLine = ret[0]; + let startPosition = ret[1]; + ret = getEndPositionInLine(); + let endLine = ret[0]; + let endPosition = ret[1]; + return [startLine, startPosition, endLine, endPosition]; +} + +function loadSelection(sel) { + setStartPositionInLine(sel[0], sel[1]); + setEndPositionInLine(sel[2], sel[3]); +} + +function getStartPositionInLine() { + let selection = window.getSelection(); + if (selection.rangeCount == 0) { + return [null, 0]; + } + let range = selection.getRangeAt(0).cloneRange(); + let obj = range.startContainer; + + let position = range.startOffset; + + if (obj.nodeName == 'DIV' && obj.classList.contains('cheezenotes_line')) { + return [obj, position]; + } + + let line = null; + + while (obj != null) { + if (obj.previousSibling != null) { + obj = obj.previousSibling; + if (obj.innerText != null) { + position += obj.innerText.length; + } else if (obj.length != null) { + position += obj.length; + } + } else if (obj.parentNode != null && obj.parentNode.classList != null && !obj.parentNode.classList.contains('cheezenotes_line')) { + obj = obj.parentNode; + } else if (obj.parentNode != null && obj.parentNode.classList != null && obj.parentNode.classList.contains('cheezenotes_line')) { + line = obj.parentNode; + obj = null; + } else { + obj = null; + } + } + return [line, position]; +} + +function setStartPositionInLine(line, position) { + setStartPositionInDiv(line, position) +} + +function setStartPositionInDiv(obj, position) { + let temppos = position; + if (temppos > obj.innerText.length) { + return temppos - obj.innerText.length; + } + let children = obj.childNodes; + for (let i = 0; i < children.length; i++) { + let child = children[i]; + if (child.nodeType == 3) { + temppos = setStartPositionInText(child, temppos); + } else { + temppos = setStartPositionInDiv(child, temppos); + } + if (temppos == 0) { + return temppos; + } + } + return temppos; +} + +function setStartPositionInText(obj, position) { + if (position > obj.length) { + return position - obj.length; + } + + let selection = window.getSelection(); + selection.removeAllRanges(); + let range = document.createRange(); + range.setStart(obj, position); + selection.addRange(range); + return 0; +} + +function getEndPositionInLine() { + let selection = window.getSelection(); + if (selection.rangeCount == 0) { + return [null, 0]; + } + let range = selection.getRangeAt(0).cloneRange(); + let obj = range.endContainer; + + let position = range.endOffset; + + if (obj.nodeName == 'DIV' && obj.classList.contains('cheezenotes_line')) { + return [obj, position]; + } + + let line = null; + + while (obj != null) { + if (obj.previousSibling != null) { + obj = obj.previousSibling; + if (obj.innerText != null) { + position += obj.innerText.length; + } else if (obj.length != null) { + position += obj.length; + } + } else if (obj.parentNode != null && obj.parentNode.classList != null && !obj.parentNode.classList.contains('cheezenotes_line')) { + obj = obj.parentNode; + } else if (obj.parentNode != null && obj.parentNode.classList != null && obj.parentNode.classList.contains('cheezenotes_line')) { + line = obj.parentNode; + obj = null; + } else { + obj = null; + } + } + return [line, position]; +} + +function setEndPositionInLine(line, position) { + setEndPositionInDiv(line, position) +} + +function setEndPositionInDiv(obj, position) { + let temppos = position; + if (temppos > obj.innerText.length) { + return temppos - obj.innerText.length; + } + let children = obj.childNodes; + for (let i = 0; i < children.length; i++) { + let child = children[i]; + if (child.nodeType == 3) { + temppos = setEndPositionInText(child, temppos); + } else { + temppos = setEndPositionInDiv(child, temppos); + } + if (temppos == 0) { + return temppos; + } + } + return temppos; +} + +function setEndPositionInText(obj, position) { + if (position > obj.length) { + return position - obj.length; + } + + let selection = window.getSelection(); + let oldRange = selection.getRangeAt(0); + let range = document.createRange(); + range.setStart(oldRange.startContainer, oldRange.startOffset); + range.setEnd(obj, position); + selection.removeAllRanges(); + selection.addRange(range); + return 0; +} + +export { saveSelection, loadSelection, insertTextAtCaret }; \ No newline at end of file diff --git a/static/modules/cheezenotes.js b/static/modules/cheezenotes.js new file mode 100644 index 0000000..9b363e2 --- /dev/null +++ b/static/modules/cheezenotes.js @@ -0,0 +1,209 @@ +import { saveSelection, loadSelection, insertTextAtCaret } from './caret.js'; +import { formatLine, load, save, formatTable, redrawTables, appendData, dpwidth } from './md.js'; + +function timeoutSave() { + if (window.tos !== null) { + window.clearTimeout(window.tos); + } + window.tos = window.setTimeout(onsave, 5000); +} + +function ontextarea(e) { + let ta = document.getElementById('ta'); + if (ta.style.display != 'inline') { + ta.style.display = 'inline'; + } else { + ta.style.display = 'none'; + } +} + +function onboldbutton(e) { + e.preventDefault(); + let cheezenotes = document.getElementById('cheezenotes'); + cheezenotes.focus(); + insertTextAtCaret('**', '**'); + onedit(e); + return false; +} + +function onitalicbutton(e) { + e.preventDefault(); + let cheezenotes = document.getElementById('cheezenotes'); + cheezenotes.focus(); + insertTextAtCaret('_', '_'); + onedit(e); + return false; +} + +function onstrikebutton(e) { + e.preventDefault(); + let cheezenotes = document.getElementById('cheezenotes'); + cheezenotes.focus(); + insertTextAtCaret('~~', '~~'); + onedit(e); + return false; +} + +function onsave(e) { + let saveButton = document.getElementById('saveButton'); + saveButton.disabled = true; + let text = save(document.getElementById('ta'), document.getElementById('cheezenotes')); + var xhttp = new XMLHttpRequest(); + xhttp.onreadystatechange = function () { + if (this.readyState == 4 && this.status != 200) { + saveButton.disabled = false; + alert(xhttp.responseText); + } + } + xhttp.open("PUT", document.location.href, true); + xhttp.send(text); +} + +function onload(e) { + load(document.getElementById('ta'), document.getElementById('cheezenotes')); +} + +function onedit(e) { + timeoutSave(); + + if (e.inputType == 'insertCompositionText') { + e.preventDefault(); + return false; + } + + saveButton.disabled = false; + let ret = saveSelection(); + let line = ret[0]; + let position = ret[1]; + + if (line.innerText == '\n') { + line.className = 'cheezenotes_line'; + line.classList.add('body'); + return; + } + + let prevline = line.previousSibling; + if (prevline != null && prevline.innerText == '\n') { + prevline.className = 'cheezenotes_line'; + prevline.classList.add('body'); + } + + let newline = formatLine(line.innerText); + line.parentNode.replaceChild(newline, line); + formatTable(newline, dpwidth()); + ret[0] = newline; + ret[2] = newline; + loadSelection(ret); + console.log('onedit fin'); +} + +function onkeydown(e) { + if (e.key != 'Tab') { + return true; + } + + e.preventDefault(); + let key = ' '; + insertTextAtCaret(key); + onedit(e); + return false; +} + +function onkeyup(e) { + if (e.key !== 'Escape') { + return true; + } + + e.preventDefault(); + document.getElementById('cheezenotes').blur(); + if (saveButton.disabled == false) { + onsave(); + } + return false; +} + +function onkeypress(e) { + if (e.key !== 'Escape') { + return true; + } + + e.preventDefault(); + document.getElementById('cheezenotes').blur(); + if (saveButton.disabled == false) { + onsave(); + } + return false; +} + +function onpaste(e) { + e.preventDefault(); + timeoutSave(); + let data = e.clipboardData.getData('text/plain'); + appendData(document.getElementById('cheezenotes'), data); + saveButton.disabled = false; + return false; +} + +function oncopy(e) { + //alert(e.clipboardData.getData('text/plain')); +} + +function onlockbutton(e) { + let lockButton = document.getElementById('lockButton'); + let lockButtonLabel = document.getElementById('lockButtonLabel'); + let cheezenotes = document.getElementById('cheezenotes'); + if (lockButton.checked) { + cheezenotes.contentEditable = false; + lockButtonLabel.innerText = 'visibility'; + } else { + cheezenotes.contentEditable = true; + lockButtonLabel.innerText = 'visibility_off'; + } +} + +function ondrag(e) { + // alert('drag'); +} + +function ondragenter(e) { + // alert('enter'); +} + +function ondragleave(e) { + // alert('leave') +} + +function init(pagename = null) { + let cheezenotesdiv = document.getElementById('cheezenotes'); + + dpwidth(cheezenotesdiv); + + cheezenotesdiv.addEventListener('input', onedit); + cheezenotesdiv.addEventListener('keyup', onkeyup); + cheezenotesdiv.addEventListener('keypress', onkeypress); + cheezenotesdiv.addEventListener('keydown', onkeydown); + cheezenotesdiv.addEventListener('paste', onpaste); + cheezenotesdiv.addEventListener('copy', oncopy); + cheezenotesdiv.addEventListener('blur', () => { redrawTables(cheezenotesdiv); onsave() }); + cheezenotesdiv.addEventListener('focus', () => { redrawTables(cheezenotesdiv, dpwidth()); }); + cheezenotesdiv.addEventListener('drag', ondrag); + cheezenotesdiv.addEventListener('dragenter', ondragenter); + cheezenotesdiv.addEventListener('dragleave', ondragleave); + + let saveButton = document.getElementById('saveButton'); + saveButton.disabled = true; + saveButton.addEventListener('click', onsave); + let taButton = document.getElementById('taButton'); + taButton.addEventListener('click', ontextarea); + let lockButton = document.getElementById('lockButton'); + lockButton.addEventListener('click', onlockbutton); + let boldButton = document.getElementById('boldButton'); + boldButton.addEventListener('mousedown', onboldbutton); + let italicButton = document.getElementById('italicButton'); + italicButton.addEventListener('mousedown', onitalicbutton); + let strikeButton = document.getElementById('strikeButton'); + strikeButton.addEventListener('mousedown', onstrikebutton); + onload(); +} + +export { init }; \ No newline at end of file diff --git a/static/modules/md.js b/static/modules/md.js index ad0d6bb..8baa3b3 100644 --- a/static/modules/md.js +++ b/static/modules/md.js @@ -1,4 +1,4 @@ -import { getStartPositionInLine, setStartPositionInLine } from "./position.js"; +import { saveSelection, loadSelection } from "./caret.js"; function load(textarea, div) { div.innerHTML = ''; @@ -14,7 +14,7 @@ function load(textarea, div) { function appendData(div, data) { const selection = window.getSelection(); selection.deleteFromDocument(); - let ret = getStartPositionInLine(); + let ret = saveSelection(); let line = ret[0]; let position = ret[1]; if (line == null) { @@ -41,7 +41,7 @@ function appendData(div, data) { prevline.after(newline); position = lines[lines.length - 1].length; } - setStartPositionInLine(newline, position); + loadSelection([newline, position, newline, position]); redrawTables(div, dpwidth(div)); } @@ -80,16 +80,16 @@ function emsp() { function onlinkin(e) { let link = e.currentTarget; - if (document.getElementById('mdnotes') !== document.activeElement) { - document.getElementById('mdnotes').contentEditable = false; + if (document.getElementById('cheezenotes') !== document.activeElement) { + document.getElementById('cheezenotes').contentEditable = false; } } function onlink(e) { - let mdnotes = document.getElementById('mdnotes'); - if (mdnotes.contentEditable == 'false') { + let cheezenotes = document.getElementById('cheezenotes'); + if (cheezenotes.contentEditable == 'false') { e.preventDefault(); - mdnotes.contentEditable = true; + cheezenotes.contentEditable = true; let link = e.currentTarget; if (link.host !== document.location.host) { open(link.href); @@ -103,16 +103,16 @@ function onlink(e) { } function onlinkout(e) { - let mdnotes = document.getElementById('mdnotes'); - if (mdnotes.contentEditable == 'false') { - mdnotes.contentEditable = true; + let cheezenotes = document.getElementById('cheezenotes'); + if (cheezenotes.contentEditable == 'false') { + cheezenotes.contentEditable = true; } } function formatLine(line) { let token = null; let elem = document.createElement('div'); - elem.classList.add('mdnotes_line'); + elem.classList.add('cheezenotes_line'); if (line == '' || line == '\n') { elem.classList.add('body'); elem.innerHTML = '
'; @@ -125,13 +125,19 @@ function formatLine(line) { line = ret[0]; let listMono = ret[1]; - // test remove link ret = removeLink(line); - console.log('removeLink ' + ret[0]); + line = ret[0]; + let listLink = ret[1]; - if (line.match(/^\s*-{3,}\s*$/)) { - token = /^(\s*-{3,}\s*)$/ + if (line.match(/^\s*_{3,}\s*$/)) { + token = /^(\s*_{3,}\s*)$/ elem.classList.add('line'); + } else if (line.match(/^\s*######(\s|$)/i)) { + token = /^(\s*######(\s|$))/i; + elem.classList.add('h6'); + } else if (line.match(/^\s*#####(\s|$)/i)) { + token = /^(\s*#####(\s|$))/i; + elem.classList.add('h5'); } else if (line.match(/^\s*####(\s|$)/i)) { token = /^(\s*####(\s|$))/i; elem.classList.add('h4'); @@ -189,10 +195,11 @@ function formatLine(line) { if (token != null) { line = line.replace(token, '$1'); } - line = addLink(line); line = addBold(line); line = addItalic(line); + line = addStrike(line); line = addTableLine(line); + line = addLink(line, listLink); line = addMono(line, listMono); elem.innerHTML = line; if (elem.getElementsByClassName('tablerow').length > 0) { @@ -282,11 +289,11 @@ function addTableLine(line) { return line; } -function redrawTables(mdnotes, dpwidth = 0) { - if (mdnotes.childNodes.length == 0) { +function redrawTables(cheezenotes, dpwidth = 0) { + if (cheezenotes.childNodes.length == 0) { return; } - let child = mdnotes.childNodes[0]; + let child = cheezenotes.childNodes[0]; let firsttableline = null; while(child != null) { if (firsttableline == null) { @@ -465,11 +472,33 @@ function removeLink(line) { return [line, null]; } - line = line.replace(/(\[([^\]]*?)\]\(([^\)]*?)\))/g, "[$2]()"); + line = line.replace(/(\[([^\]]*?)\]\(([^\)]*?)\))/g, "[]()"); return [line, listLink.reverse()]; } -function addLink(line) { +function addLink(line, listLink) { + if (listLink == null) { + return line; + } + let cpt = 0; + let match; + let matches = []; + let re = /\[\]\(\)/g; + while ((match = re.exec(line)) != null) { + matches[cpt] = match.index; + if (cpt > 1000) { + continue; + } + cpt++; + } + matches = matches.reverse(); + for(let i=0; i[$2]($3)'); line = line.replace(/(\[([^\]]+?)\]\(\))/ig, '[$2]()'); line = line.replace(/(\[\]\(([^\)]+?)\))/ig, '[]($2)'); @@ -477,14 +506,19 @@ function addLink(line) { } function addBold(line) { - line = line.replace(/\*\*([^\s].*?)\*\*/ig, '**$1**'); - line = line.replace(/__([^\s].*?)__/ig, '__$1__'); + line = line.replace(/\*\*([^\s].*?)\*\*/ig, '**$1**'); + line = line.replace(/__([^\s].*?)__/ig, '__$1__'); return line; } function addItalic(line) { - line = line.replace(/(^|[^\*])\*([^\*\s].*?[^\*\s]|[^\*\s])\*([^\*]|$)/ig, '$1*$2*$3'); - line = line.replace(/(^|[\s^*])_([^_\s].*?[^_\s]|[^_\s])_([^_]|$)/ig, '$1_$2_$3'); + line = line.replace(/(^|[^\*])\*([^\*\s].*?[^\*\s]|[^\*\s])\*([^\*]|$)/ig, '$1*$2*$3'); + line = line.replace(/(^|[\s^*])_([^_\s].*?[^_\s]|[^_\s])_([^_]|$)/ig, '$1_$2_$3'); + return line; +} + +function addStrike(line) { + line = line.replace(/~~([^\s].*?)~~/ig, '~~$1~~'); return line; } diff --git a/static/modules/mdnotes.js b/static/modules/mdnotes.js deleted file mode 100644 index 3218f54..0000000 --- a/static/modules/mdnotes.js +++ /dev/null @@ -1,177 +0,0 @@ -import { getStartPositionInLine, setStartPositionInLine } from './position.js'; -import { formatLine, load, save, formatTable, redrawTables, appendData, dpwidth } from './md.js'; - -function timeoutSave() { - if (window.tos !== null) { - window.clearTimeout(window.tos); - } - window.tos = window.setTimeout(onsave, 5000); -} - -function ontextarea(e) { - let ta = document.getElementById('ta'); - if (ta.style.display != 'inline') { - ta.style.display = 'inline'; - } else { - ta.style.display = 'none'; - } -} - -function onsave(e) { - let saveButton = document.getElementById('saveButton'); - saveButton.disabled = true; - let text = save(document.getElementById('ta'), document.getElementById('mdnotes')); - var xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (this.readyState == 4 && this.status != 200) { - saveButton.disabled = false; - alert(xhttp.responseText); - } - } - xhttp.open("PUT", document.location.href, true); - xhttp.send(text); -} - -function onload(e) { - load(document.getElementById('ta'), document.getElementById('mdnotes')); -} - -function onedit(e) { - console.log('onedit'); - timeoutSave(); - saveButton.disabled = false; - let ret = getStartPositionInLine(); - let line = ret[0]; - let position = ret[1]; - - if (line.innerText == '\n') { - line.className = 'mdnotes_line'; - line.classList.add('body'); - return; - } - - let prevline = line.previousSibling; - if (prevline != null && prevline.innerText == '\n') { - prevline.className = 'mdnotes_line'; - prevline.classList.add('body'); - } - - let newline = formatLine(line.innerText); - line.parentNode.replaceChild(newline, line); - formatTable(newline, dpwidth()); - setStartPositionInLine(newline, position); - console.log('onedit fin'); -} - -function onkeydown(e) { - if (e.key != 'Tab') { - return true; - } - - e.preventDefault(); - let key = ' '; - let ret = getStartPositionInLine(); - let line = ret[0]; - let position = ret[1]; - let txt = line.innerText; - if (position == 0) { - line.innerHTML = key + txt; // 4 espaces =>   - } else { - line.innerHTML = txt.substring(0, position) + key + txt.substring(position, txt.length); - } - setStartPositionInLine(line, position + 1); - onedit(e); - return false; -} - -function onkeypress(e) { - if (e.key == 'Escape') { - e.preventDefault(); - document.getElementById('mdnotes').blur(); - if (saveButton.disabled == false) { - onsave(); - } - return false; - } - if (e.key == 'Enter') { - - } -} - -function onkeyup(e) { - if (e.key == 'Escape') { - e.preventDefault(); - document.getElementById('mdnotes').blur(); - if (saveButton.disabled == false) { - onsave(); - } - return false; - } -} - -function onpaste(e) { - e.preventDefault(); - timeoutSave(); - let data = e.clipboardData.getData('text/plain'); - appendData(document.getElementById('mdnotes'), data); - saveButton.disabled = false; - return false; -} - -function oncopy(e) { - //alert(e.clipboardData.getData('text/plain')); -} - -function onlockbutton(e) { - let lockButton = document.getElementById('lockButton'); - let mdnotes = document.getElementById('mdnotes'); - if (lockButton.checked) { - mdnotes.contentEditable = false; - } else { - mdnotes.contentEditable = true; - } -} - -function ondrag(e) { - // alert('drag'); -} - -function ondragenter(e) { - // alert('enter'); -} - -function ondragleave(e) { - // alert('leave') -} - -function init(pagename = null) { - /*if (pagename != null) { - window.history.replaceState(null, '', '/page/' + pagename); - }*/ - let mdnotesdiv = document.getElementById('mdnotes'); - - dpwidth(mdnotesdiv); - - mdnotesdiv.addEventListener('input', onedit); - mdnotesdiv.addEventListener('keyup', onkeyup); - mdnotesdiv.addEventListener('keypress', onkeypress); - mdnotesdiv.addEventListener('keydown', onkeydown); - mdnotesdiv.addEventListener('paste', onpaste); - mdnotesdiv.addEventListener('copy', oncopy); - mdnotesdiv.addEventListener('blur', () => {redrawTables(mdnotesdiv); onsave()}); - mdnotesdiv.addEventListener('focus', () => {redrawTables(mdnotesdiv, dpwidth());}); - mdnotesdiv.addEventListener('drag', ondrag); - mdnotesdiv.addEventListener('dragenter', ondragenter); - mdnotesdiv.addEventListener('dragleave', ondragleave); - - let saveButton = document.getElementById('saveButton'); - saveButton.disabled = true; - saveButton.addEventListener('click', onsave); - let taButton = document.getElementById('taButton'); - taButton.addEventListener('click', ontextarea); - let lockButton = document.getElementById('lockButton'); - lockButton.addEventListener('click', onlockbutton); - onload(); -} - -export { init }; \ No newline at end of file diff --git a/static/modules/position.js b/static/modules/position.js deleted file mode 100644 index 6208190..0000000 --- a/static/modules/position.js +++ /dev/null @@ -1,74 +0,0 @@ -function getStartPositionInLine() { - let selection = window.getSelection(); - if (selection.rangeCount == 0) { - return [null, 0]; - } - let range = selection.getRangeAt(0).cloneRange(); - let obj = range.startContainer; - - let position = range.startOffset; - - if (obj.nodeName == 'DIV' && obj.classList.contains('mdnotes_line')) { - return [obj, position]; - } - - let line = null; - - while (obj != null) { - if (obj.previousSibling != null) { - obj = obj.previousSibling; - if (obj.innerText != null) { - position += obj.innerText.length; - } else if (obj.length != null) { - position += obj.length; - } - } else if (obj.parentNode != null && obj.parentNode.classList != null && !obj.parentNode.classList.contains('mdnotes_line')) { - obj = obj.parentNode; - } else if (obj.parentNode != null && obj.parentNode.classList != null && obj.parentNode.classList.contains('mdnotes_line')) { - line = obj.parentNode; - obj = null; - } else { - obj = null; - } - } - return [line, position]; -} - -function setStartPositionInLine(line, position) { - setStartPositionInDiv(line, position) -} - -function setStartPositionInDiv(obj, position) { - let temppos = position; - if (temppos > obj.innerText.length) { - return temppos - obj.innerText.length; - } - let children = obj.childNodes; - for (let i = 0; i < children.length; i++) { - let child = children[i]; - if (child.nodeType == 3) { - temppos = setStartPositionInText(child, temppos); - } else { - temppos = setStartPositionInDiv(child, temppos); - } - if (temppos == 0) { - return temppos; - } - } - return temppos; -} - -function setStartPositionInText(obj, position) { - if (position > obj.length) { - return position - obj.length; - } - - let selection = window.getSelection(); - selection.removeAllRanges(); - let range = document.createRange(); - range.setStart(obj, position); - selection.addRange(range); - return 0; -} - -export { getStartPositionInLine, setStartPositionInLine }; \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 2390f95..de55b3f 100644 --- a/templates/index.html +++ b/templates/index.html @@ -8,7 +8,7 @@ {{name}} - +

diff --git a/templates/page.html b/templates/page.html index bb5bfe6..bc9623a 100644 --- a/templates/page.html +++ b/templates/page.html @@ -8,16 +8,22 @@ {{name}} - - + + -
-
-
- +
+ + + + + + +
+
+