This commit is contained in:
Cadey Ratio 2020-08-02 02:44:55 +00:00
parent 00f8fdc9e1
commit c6f15577bb
2 changed files with 6 additions and 12 deletions

View File

@ -46,7 +46,7 @@ struct Options {
hostname: String, hostname: String,
/// HTTP port /// HTTP port
#[structopt(long, default_value="34587")] #[structopt(long, default_value = "34587")]
http_port: u16, http_port: u16,
} }
@ -88,18 +88,12 @@ fn main() -> Result<(), maj::server::Error> {
{ {
let port = opts.http_port.clone(); let port = opts.http_port.clone();
let h = h.clone(); let h = h.clone();
thread::spawn(move || http::run(h.clone(), port)); thread::spawn(move || http::run(h.clone(), port));
} }
task::block_on(maj::server::serve( task::block_on(maj::server::serve(h.clone(), config, opts.host, opts.port))?;
h.clone(),
config,
opts.host,
opts.port,
))?;
Ok(()) Ok(())
} }
// And finally, include the generated code for templates and static files.
include!(concat!(env!("OUT_DIR"), "/templates.rs")); include!(concat!(env!("OUT_DIR"), "/templates.rs"));

View File

@ -62,8 +62,8 @@ pub fn render(nodes: Vec<Node>, out: &mut impl Write) -> io::Result<()> {
match node { match node {
Text(body) => write!(out, "{}\n", body)?, Text(body) => write!(out, "{}\n", body)?,
Link { to, name } => match name { Link { to, name } => match name {
Some(name) => write!(out, "{} {}\n", to, name)?, Some(name) => write!(out, "=> {} {}\n", to, name)?,
None => write!(out, "{}\n", to)?, None => write!(out, "=> {}\n", to)?,
}, },
Preformatted(body) => write!(out, "```\n{}\n```\n", body)?, Preformatted(body) => write!(out, "```\n{}\n```\n", body)?,
Heading { level, body } => write!(out, "{} {}\n", "#".repeat(level as usize), body)?, Heading { level, body } => write!(out, "{} {}\n", "#".repeat(level as usize), body)?,