Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Dan docs update#1250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
chillenberger merged 5 commits intomasterfromdan-docs-update
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 49 additions & 28 deletionspgml-dashboard/src/api/cms.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,8 +39,11 @@ pub struct Document {
}

implDocument{
pubasyncfnfrom_path(path:&PathBuf) -> anyhow::Result<Document>{
let contents = tokio::fs::read_to_string(&path).await?;
pubasyncfnfrom_path(path:&PathBuf) -> anyhow::Result<Document, std::io::Error>{
let contents =match tokio::fs::read_to_string(&path).await{
Ok(contents) => contents,
Err(_) =>String::from("<h3>Failed to find your requested document!</h3>"),
};

let parts = contents.split("---").collect::<Vec<&str>>();

Expand DownExpand Up@@ -271,35 +274,40 @@ impl Collection {

// renders document in layout
asyncfnrender<'a>(&self,path:&'aPathBuf,cluster:&Cluster) ->Result<ResponseOk,Status>{
let doc =Document::from_path(&path).await.unwrap();
let index =self.open_index(doc.path);
matchDocument::from_path(&path).await{
Ok(doc) =>{
let index =self.open_index(doc.path);

let user =if cluster.context.user.is_anonymous(){
None
}else{
Some(cluster.context.user.clone())
};

letmut layout =crate::templates::Layout::new(&doc.title,Some(cluster));
ifletSome(image) = doc.image{
layout.image(&config::asset_url(image.into()));
}
ifletSome(description) =&doc.description{
layout.description(description);
}
ifletSome(user) =&user{
layout.user(user);
}

let user =if cluster.context.user.is_anonymous(){
None
}else{
Some(cluster.context.user.clone())
};
let layout = layout
.nav_title(&self.name)
.nav_links(&index)
.toc_links(&doc.toc_links)
.footer(cluster.context.marketing_footer.to_string());

letmut layout =crate::templates::Layout::new(&doc.title,Some(cluster));
ifletSome(image) = doc.image{
layout.image(&config::asset_url(image.into()));
}
ifletSome(description) =&doc.description{
layout.description(description);
}
ifletSome(user) =&user{
layout.user(user);
Ok(ResponseOk(
layout.render(crate::templates::Article{content: doc.html}),
))
}
// Return page not found on bad path
_ =>Err(Status::NotFound),
}

let layout = layout
.nav_title(&self.name)
.nav_links(&index)
.toc_links(&doc.toc_links)
.footer(cluster.context.marketing_footer.to_string());

Ok(ResponseOk(
layout.render(crate::templates::Article{content: doc.html}),
))
}
}

Expand DownExpand Up@@ -534,4 +542,17 @@ This is the end of the markdown
)
}
}

#[sqlx::test]
asyncfndoc_not_found(){
let client =Client::tracked(rocket().await).await.unwrap();
let req = client.get("/docs/not_a_doc");
let rsp = req.dispatch().await;

assert!(
rsp.status() ==Status::NotFound,
"Returned status {:?}",
rsp.status()
);
}
}
2 changes: 1 addition & 1 deletionpgml-dashboard/src/utils/markdown.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -446,7 +446,7 @@ impl SyntaxHighlighterAdapter for SyntaxHighlighter {
.enumerate()
.map(|(index, code)|{
format!(
r#"<div>{}</div>"#,
r#"<divx x-first x-last"> d-inline-block">{}</div>"#,
match options.highlight.get(&(index +1).to_string()){
Some(color) => color,
_ =>"none",
Expand Down
9 changes: 9 additions & 0 deletionspgml-dashboard/static/css/scss/pages/_docs.scss
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -169,5 +169,14 @@
}
}
}

figure {
display:flex;
flex-direction:column;
img,figcaption {
margin-left:auto;
margin-right:auto;
}
}
}


[8]ページ先頭

©2009-2025 Movatter.jp