diff --git a/README.md b/README.md new file mode 100644 index 0000000..5813197 --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ + +#
Flair
+ +An extra simplified version of Flask, written as a Rust lib. +## 🧐 Features +- Reads templates +- Dynamically generate content based on rust variables or bash commands + +# Templates ? + +Templates are defined as .ft files. + +They may contain any text. Special words are defined between percentage signs: +``` +Hello %%name%% +``` + +## Try +An example website is included. + +To see it, clone this repo, then: +```bash +cargo run +``` + +Next, go to http://localhost:8080 + +## Use +Add this to your Cargo.toml +```bash +flair = { git = "https://gitea.squi.fr/Rust/flair.git" } +``` + +## Doc +Clone this repo, then compile and open the doc: +```bash +cargo doc --open +``` + +## 🙇 Author +Justine Pelletreau + + +## ➤ License +Distributed as is. diff --git a/src/lib.rs b/src/lib.rs index e6ad330..d32e68d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,13 @@ +///! A simple templating library +///! +///! Takes template files : any text file ending in .ft +///! and substitutes special words. Special words can be of 2 types +///! and are written between four %: +///! %%cmd: my_bash_command%% : this will run the command my_bash_command +///! and subtitute the output. +///! %%myvar%% : this will be replaced by a given String. +///! +///! The only public function is analyze_file. pub mod flair { use std::{ fs, @@ -53,13 +63,22 @@ pub mod flair { } - ///Takes a file and submits it for analysis. + ///Takes a .ft file and submits it for analysis. ///Takes two values : the path of the file to analyze, ///and an HashMap of values that can be replaced when we find a ///%%var_name%% in our template file. ///vars must be : HashMapThis computer was up 7 hours, 55 minutes
\ No newline at end of file diff --git a/static_html/main.css b/static_html/main.css new file mode 100644 index 0000000..f7a6b7e --- /dev/null +++ b/static_html/main.css @@ -0,0 +1,80 @@ +miniature { + width: 200px; + height: 200px; + border-radius: 4px; + padding: 5px; + margin-top: 10px; + border: 1px solid #ddd; + object-fit: cover; +} + + +/* (X) DOES NOT MATTER */ +body, html { + background-color: #111111; + padding: 0; + margin: 0; + font-family: Verdana, "Bitstream Vera Sans", sans-serif; + color: #FFFFFF; + line-height: 1em; +} + +a { + text-decoration: none; + color: #FFFFFF; +} + +a:hover { + color: #F012BE; +} + +.container { + height: 100%; + width: 70%; + display: flex; + column-gap: 2rem; + row-gap: 8rem; + flex-direction: row; + flex-wrap: wrap; + align-content: flex-end; + justify-content: center; + text-align: center; + margin: auto; +} + +.item { + height: 200px; + font-size: 15px; + width: 150px; + line-height: 1em; + padding: 3em; + align-items: center; + display: flex; + flex-direction: column; +} +/* +@media screen and (max-width: 920px) { + .item { + width: 30%; + } +} + +@media screen and (max-width: 640px) { + .item { + width: 50%; + } +} +*/ +h1 { + text-align: center; +} + +h2 { + + color: #61cObf; + font-size: 1.5em; + line-height: 1px; + margin: 0px; + text-align: center; +} + diff --git a/templates/index.html.ft b/templates/index.html.ft new file mode 100644 index 0000000..3915742 --- /dev/null +++ b/templates/index.html.ft @@ -0,0 +1,23 @@ + + + + +This computer was %%cmd: uptime -p%%
diff --git a/templates/index.html.st b/templates/index.html.st deleted file mode 100644 index a1fedf2..0000000 --- a/templates/index.html.st +++ /dev/null @@ -1,3 +0,0 @@ -Hello %%name%% %%surname%% - -Today is the %%cmd: date%%