list supported css lang in rust
All checks were successful
PR Check / lint-and-format (pull_request) Successful in 19m47s
All checks were successful
PR Check / lint-and-format (pull_request) Successful in 19m47s
This commit is contained in:
parent
97db918a61
commit
f79f1a8956
6 changed files with 123 additions and 94 deletions
|
@ -7,7 +7,7 @@ use std::io::Result;
|
|||
|
||||
use crate::routes::{
|
||||
agreements, api_v1, blog, contact, contrib, cours, cv, gaming, index, memorial, not_found,
|
||||
portfolio, setup, web3,
|
||||
portfolio, setup, statik, web3,
|
||||
};
|
||||
|
||||
mod config;
|
||||
|
@ -55,6 +55,7 @@ async fn main() -> Result<()> {
|
|||
),
|
||||
)
|
||||
.service(index::page)
|
||||
.service(statik::languages)
|
||||
.service(agreements::security)
|
||||
.service(agreements::humans)
|
||||
.service(agreements::robots)
|
||||
|
|
|
@ -11,4 +11,5 @@ pub mod memorial;
|
|||
pub mod not_found;
|
||||
pub mod portfolio;
|
||||
pub mod setup;
|
||||
pub mod statik;
|
||||
pub mod web3;
|
||||
|
|
72
src/routes/statik.rs
Normal file
72
src/routes/statik.rs
Normal file
|
@ -0,0 +1,72 @@
|
|||
use actix_web::{get, web, HttpResponse, Responder};
|
||||
use cached::proc_macro::once;
|
||||
use ramhorns::Content;
|
||||
|
||||
use crate::{config::Config, template::InfosPage};
|
||||
|
||||
#[get("/css/languages.css")]
|
||||
pub async fn languages(config: web::Data<Config>) -> impl Responder {
|
||||
HttpResponse::Ok()
|
||||
.content_type("text/css")
|
||||
.body(build_languages(config.get_ref().to_owned()))
|
||||
}
|
||||
|
||||
#[derive(Content, Debug)]
|
||||
struct Language {
|
||||
name: String,
|
||||
code: String,
|
||||
color: String,
|
||||
}
|
||||
|
||||
#[derive(Content, Debug)]
|
||||
struct LanguagesTemplate {
|
||||
langs: Vec<Language>,
|
||||
}
|
||||
|
||||
#[once]
|
||||
fn build_languages(config: Config) -> String {
|
||||
config.tmpl.render(
|
||||
"static/languages.css",
|
||||
LanguagesTemplate {
|
||||
langs: vec![
|
||||
Language {
|
||||
name: "TypeScript".into(),
|
||||
code: "ts".into(),
|
||||
color: "3178c6".into(),
|
||||
},
|
||||
Language {
|
||||
name: "Rust".into(),
|
||||
code: "rust".into(),
|
||||
color: "dea584".into(),
|
||||
},
|
||||
Language {
|
||||
name: "Python".into(),
|
||||
code: "py".into(),
|
||||
color: "3572a5".into(),
|
||||
},
|
||||
Language {
|
||||
name: "OCaml".into(),
|
||||
code: "ocaml".into(),
|
||||
color: "ef7a08".into(),
|
||||
},
|
||||
Language {
|
||||
name: "Go".into(),
|
||||
code: "go".into(),
|
||||
color: "00add8".into(),
|
||||
},
|
||||
Language {
|
||||
name: "GDScript".into(),
|
||||
code: "gdscript".into(),
|
||||
color: "355570".into(),
|
||||
},
|
||||
Language {
|
||||
name: "TeX".into(),
|
||||
code: "tex".into(),
|
||||
color: "3d6117".into(),
|
||||
},
|
||||
],
|
||||
},
|
||||
InfosPage::default(),
|
||||
None,
|
||||
)
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
:root {
|
||||
--lang-size-dot: 0.8em;
|
||||
--lang-margin-text: 3px;
|
||||
--lang-font-size: calc(var(--font-size) * 0.65);
|
||||
}
|
||||
|
||||
/* Dot */
|
||||
p[data-lang]::before {
|
||||
content: "";
|
||||
|
||||
height: var(--lang-size-dot);
|
||||
width: var(--lang-size-dot);
|
||||
|
||||
border-radius: 50%;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
/* Text */
|
||||
p[data-lang]::after {
|
||||
margin-left: var(--lang-margin-text);
|
||||
font-size: var(--lang-font-size);
|
||||
}
|
||||
|
||||
/* Definitions */
|
||||
p[data-lang="ts"]::before {
|
||||
background-color: #3178c6;
|
||||
}
|
||||
|
||||
p[data-lang="ts"]::after {
|
||||
content: "TypeScript";
|
||||
}
|
||||
|
||||
p[data-lang="rust"]::before {
|
||||
background-color: #dea584;
|
||||
}
|
||||
|
||||
p[data-lang="rust"]::after {
|
||||
content: "Rust";
|
||||
}
|
||||
|
||||
p[data-lang="py"]::before {
|
||||
background-color: #3572a5;
|
||||
}
|
||||
|
||||
p[data-lang="py"]::after {
|
||||
content: "Python";
|
||||
}
|
||||
|
||||
p[data-lang="ocaml"]::before {
|
||||
background-color: #ef7a08;
|
||||
}
|
||||
|
||||
p[data-lang="ocaml"]::after {
|
||||
content: "OCaml";
|
||||
}
|
||||
|
||||
p[data-lang="go"]::before {
|
||||
background-color: #00add8;
|
||||
}
|
||||
|
||||
p[data-lang="go"]::after {
|
||||
content: "Go";
|
||||
}
|
||||
|
||||
p[data-lang="gdscript"]::before {
|
||||
background-color: #355570;
|
||||
}
|
||||
|
||||
p[data-lang="gdscript"]::after {
|
||||
content: "GDScript";
|
||||
}
|
||||
|
||||
p[data-lang="tex"]::before {
|
||||
background-color: #3d6117;
|
||||
}
|
||||
|
||||
p[data-lang="tex"]::after {
|
||||
content: "TeX";
|
||||
}
|
|
@ -126,17 +126,3 @@ ul ul {
|
|||
p[data-lang] {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Filters */
|
||||
div.filters:has(input[type="checkbox"]:checked) ~ ul li {
|
||||
display: none;
|
||||
}
|
||||
|
||||
div.filters:has(input[type="checkbox"][value="ts"]:checked)
|
||||
~ ul
|
||||
li:has(p[data-lang="ts"]),
|
||||
div.filters:has(input[type="checkbox"][value="py"]:checked)
|
||||
~ ul
|
||||
li:has(p[data-lang="py"]) {
|
||||
display: flex;
|
||||
}
|
||||
|
|
48
templates/static/languages.css
Normal file
48
templates/static/languages.css
Normal file
|
@ -0,0 +1,48 @@
|
|||
:root {
|
||||
--lang-size-dot: 0.8em;
|
||||
--lang-margin-text: 3px;
|
||||
--lang-font-size: calc(var(--font-size) * 0.65);
|
||||
}
|
||||
|
||||
/* Dot */
|
||||
p[data-lang]::before {
|
||||
content: "";
|
||||
|
||||
height: var(--lang-size-dot);
|
||||
width: var(--lang-size-dot);
|
||||
|
||||
border-radius: 50%;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
/* Text */
|
||||
p[data-lang]::after {
|
||||
margin-left: var(--lang-margin-text);
|
||||
font-size: var(--lang-font-size);
|
||||
}
|
||||
|
||||
/* Definitions */
|
||||
{{#data}}{{#langs}}
|
||||
p[data-lang="{{code}}"]::before {
|
||||
background-color: #{{color}};
|
||||
}
|
||||
|
||||
p[data-lang="{{code}}"]::after {
|
||||
content: "{{name}}";
|
||||
}
|
||||
{{/langs}}
|
||||
|
||||
/* Filters */
|
||||
div.filters:has(input[type="checkbox"]:checked) ~ ul li {
|
||||
display: none;
|
||||
}
|
||||
|
||||
{{#langs}}
|
||||
div.filters:has(input[type="checkbox"][value="{{code}}"]:checked)
|
||||
~ ul
|
||||
li:has(p[data-lang="{{code}}"]) {
|
||||
display: flex;
|
||||
}
|
||||
{{/langs}}
|
||||
|
||||
{{/data}}
|
Loading…
Add table
Add a link
Reference in a new issue