Merged Divergent Branches
This commit is contained in:
commit
6c3f257942
4 changed files with 104 additions and 13 deletions
|
|
@ -1,22 +1,21 @@
|
|||
use crate::helpers::read_doc_from_file;
|
||||
|
||||
use super::render::execute_lua;
|
||||
use super::render::expand_template;
|
||||
use super::render::{execute_lua, expand_template, process_markdown};
|
||||
use anyhow::Result;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::path::{Path, PathBuf}
|
||||
;
|
||||
|
||||
pub fn serve_content(request_uri: &str) -> Result<String> {
|
||||
// TODO: read from config
|
||||
let pages = PathBuf::from("/var/www/htmlua/pages");
|
||||
let components = PathBuf::from("/var/www/htmlua/components");
|
||||
|
||||
let safe_path = Path::new(request_uri).strip_prefix("/")?;
|
||||
let page_path = pages.join(safe_path);
|
||||
|
||||
let doc = read_doc_from_file(page_path)?;
|
||||
|
||||
let full_doc = expand_template(doc, &components, None)?;
|
||||
let executed_doc = execute_lua(full_doc)?;
|
||||
|
||||
let markdown_doc = process_markdown(full_doc)?;
|
||||
let executed_doc = execute_lua(markdown_doc)?;
|
||||
Ok(executed_doc.to_string())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue