- Notifications
You must be signed in to change notification settings - Fork328
gitbook assets#1052
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
Uh oh!
There was an error while loading.Please reload this page.
gitbook assets#1052
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
DATABASE_URL=postgres:///pgml_dashboard_development | ||
DEV_MODE=true | ||
RUST_LOG=debug,tantivy=error,rocket=info |
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -24,54 +24,36 @@ async fn search(query: &str, index: &State<markdown::SearchIndex>) -> ResponseOk | ||
) | ||
} | ||
use rocket::fs::NamedFile; | ||
#[get("/docs/guides/.gitbook/assets/<path>", rank = 10)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Can't use the fileserver because we need the path to not be exact, but rather the relative gitbook path. | ||
pub async fn gitbook_assets(path: PathBuf) -> Option<NamedFile> { | ||
let path = PathBuf::from(&config::docs_dir()) | ||
.join("docs/guides/.gitbook/assets/") | ||
.join(path); | ||
NamedFile::open(path).await.ok() | ||
} | ||
#[get("/docs/<path..>", rank = 5)] | ||
async fn doc_handler(path: PathBuf, cluster: &Cluster) -> Result<ResponseOk, Status> { | ||
let root = PathBuf::from("docs/guides/"); | ||
let index_path = PathBuf::from(&config::docs_dir()) | ||
.join(&root) | ||
.join("SUMMARY.md"); | ||
let contents = tokio::fs::read_to_string(&index_path).await.expect( | ||
format!( | ||
"could not read table of contents markdown: {:?}", | ||
index_path | ||
) | ||
.as_str(), | ||
); | ||
let mdast = ::markdown::to_mdast(&contents, &::markdown::ParseOptions::default()) | ||
.expect("could not parse table of contents markdown"); | ||
let guides = markdown::parse_summary_into_nav_links(&mdast) | ||
.expect("could not extract nav links from table of contents"); | ||
render(cluster, &path, guides, "Guides", &Path::new("docs"), &config::docs_dir()).await | ||
} | ||
#[get("/blog/<path..>", rank = 10)] | ||
@@ -134,6 +116,7 @@ async fn blog_handler<'a>(path: PathBuf, cluster: &Cluster) -> Result<ResponseOk | ||
], | ||
"Blog", | ||
&Path::new("blog"), | ||
&config::blogs_dir(), | ||
) | ||
.await | ||
} | ||
@@ -144,14 +127,16 @@ async fn render<'a>( | ||
mut nav_links: Vec<NavLink>, | ||
nav_title: &'a str, | ||
folder: &'a Path, | ||
content: &'a str, | ||
) -> Result<ResponseOk, Status> { | ||
let url = path.clone(); | ||
// Get the document content | ||
let path = Path::new(&content) | ||
.join(folder) | ||
.join(&(path.to_str().unwrap().to_string() + ".md")); | ||
info!("path: {:?}", path); | ||
// Read to string | ||
let contents = match tokio::fs::read_to_string(&path).await { | ||
Ok(contents) => contents, | ||
@@ -244,7 +229,7 @@ async fn render<'a>( | ||
} | ||
pub fn routes() -> Vec<Route> { | ||
routes![gitbook_assets,doc_handler, blog_handler, search] | ||
} | ||
#[cfg(test)] | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -48,7 +48,7 @@ | ||
</li> | ||
<li class="nav-item d-flex align-items-center"> | ||
<a class="nav-link p-lg-0" href="/docs/guides/README">Docs</a> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Not very SEO friendly imo There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Yeah, but we can't control this lever in gitbook... and then again... it is kinda devvy. | ||
</li> | ||
<div class="vr my-2 opacity-100 d-lg-block d-none" style="width: 2px"></div> | ||
@@ -78,7 +78,7 @@ | ||
</li> | ||
<li class="menu-item rounded-0 d-flex align-items-center"> | ||
<a href="/docs/guides/README/">Docs</a> | ||
</li> | ||
<li class="menu-item rounded-0 d-flex align-items-center"> | ||
Uh oh!
There was an error while loading.Please reload this page.