work?
Some checks are pending
ci/woodpecker/push/publish Pipeline is pending

This commit is contained in:
Mylloon 2023-10-31 22:46:05 +01:00
parent 4ccd2c8709
commit fc44816a04
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 37 additions and 1 deletions

View file

@ -13,6 +13,7 @@
- [Blog](#blog)
- [Projects](#projects)
- [Contacts](#contacts)
- [Courses](#courses)
# Installation
@ -204,3 +205,7 @@ Custom project description
- `user` is the username used in the platform
- `description` will be rendered as HTML "title" (text will appear when cursor
is hover the link)
## Courses
Markdown files are stored in `/app/data/cours/`

View file

@ -34,10 +34,14 @@ pub struct FileMetadataPortfolio {
pub language: Option<String>,
}
#[derive(Default, Deserialize, Content, Debug)]
pub struct FileMetadataCours {}
pub enum TypeFileMetadata {
Blog,
Contact,
Portfolio,
Cours,
}
#[derive(Default, Deserialize, Content, Debug)]
@ -45,6 +49,7 @@ pub struct FileMetadata {
pub blog: Option<FileMetadataBlog>,
pub contact: Option<FileMetadataContact>,
pub portfolio: Option<FileMetadataPortfolio>,
pub cours: Option<FileMetadataCours>,
}
#[derive(Content, Debug, Clone)]
@ -227,6 +232,10 @@ pub fn get_metadata<'a>(root: &'a AstNode<'a>, mtype: TypeFileMetadata) -> FileM
portfolio: Some(deserialize_metadata(text)),
..FileMetadata::default()
},
TypeFileMetadata::Cours => FileMetadata {
cours: Some(deserialize_metadata(text)),
..FileMetadata::default()
},
}),
_ => None,
}) {
@ -244,6 +253,10 @@ pub fn get_metadata<'a>(root: &'a AstNode<'a>, mtype: TypeFileMetadata) -> FileM
portfolio: Some(FileMetadataPortfolio::default()),
..FileMetadata::default()
},
TypeFileMetadata::Cours => FileMetadata {
cours: Some(FileMetadataCours::default()),
..FileMetadata::default()
},
},
}
}

View file

@ -1,9 +1,13 @@
use actix_web::{get, web, Responder};
use glob::glob;
use ramhorns::Content;
use crate::{
config::Config,
misc::utils::{make_kw, Html},
misc::{
markdown::{read_file, TypeFileMetadata},
utils::{make_kw, Html},
},
template::{Infos, NavBar},
};
@ -15,6 +19,20 @@ async fn page(config: web::Data<Config>) -> impl Responder {
#[derive(Content, Debug)]
struct CoursTemplate {
navbar: NavBar,
/* filetree: Truc, */
}
/// Get the filetree
fn get_filetree() {
let cours_dir = "data/cours";
glob(&format!("{cours_dir}/*")).unwrap();
}
/// Get a page
fn get_page(filename: &str) {
let cours_dir = "data/cours";
let post = read_file(&format!("{cours_dir}/{filename}"), TypeFileMetadata::Cours);
}
// #[once(time = 60)]