kochab/examples/document.rs

109 lines
4.2 KiB
Rust
Raw Normal View History

2020-11-14 08:55:21 +00:00
use anyhow::*;
use log::LevelFilter;
2020-12-07 22:29:34 +00:00
use kochab::{Server, Response, Gemtext};
2020-11-14 08:55:21 +00:00
#[tokio::main]
async fn main() -> Result<()> {
env_logger::builder()
.filter_module("kochab", LevelFilter::Debug)
2020-11-14 08:55:21 +00:00
.init();
let response: Response = Document::new()
.add_preformatted_with_alt("kochab", include_str!("kochab_logo.txt"))
.add_blank_line()
.add_text(
concat!(
"Kochab is an extension & a fork of the Gemini SDK [northstar]. Where",
" northstar creates an efficient and flexible foundation for Gemini projects,",
" kochab seeks to be as ergonomic and intuitive as possible, making it",
" possible to get straight into getting your ideas into geminispace, with no",
" worrying about needing to build the tools to get there."
)
)
.add_blank_line()
.add_link("https://github.com/Alch-Emi/kochab", "GitHub")
.add_blank_line()
.add_heading(H2, "Usage")
.add_blank_line()
.add_text("Add the latest version of kochab to your `Cargo.toml`.")
.add_blank_line()
.add_preformatted_with_alt("toml", r#"kochab = { git = "https://github.com/Alch-Emi/kochab.git" }"#)
.add_blank_line()
.add_heading(H2, "Generating a key & certificate")
.add_blank_line()
.add_preformatted_with_alt("sh", concat!(
"mkdir cert && cd cert\n",
"openssl req -x509 -nodes -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365",
2020-11-23 15:55:48 +00:00
))
.into();
2020-11-14 08:55:21 +00:00
2020-12-07 22:29:34 +00:00
<<<<<<< HEAD
2020-11-14 08:55:21 +00:00
fn handle_request(_request: Request) -> BoxFuture<'static, Result<Response>> {
async move {
let response = Gemtext::new()
.preformatted("Northstar", include_str!("northstar_logo.txt"))
.blank_line()
.link("https://docs.rs/northstar", Some("Documentation"))
.link("https://github.com/panicbit/northstar", Some("GitHub"))
.blank_line()
.heading(1, "Usage")
.blank_line()
.text("Add the latest version of northstar to your `Cargo.toml`.")
.blank_line()
.heading(2, "Manually")
.blank_line()
.preformatted("toml", r#"northstar = "0.3.0" # check crates.io for the latest version"#)
.blank_line()
.heading(2, "Automatically")
.blank_line()
.preformatted("sh", "cargo add northstar")
.blank_line()
.heading(1, "Generating a key & certificate")
.blank_line()
.preformatted("sh", concat!(
2020-11-14 08:55:21 +00:00
"mkdir cert && cd cert\n",
"openssl req -x509 -nodes -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365",
))
.into();
Ok(response)
2020-11-14 08:55:21 +00:00
}
.boxed()
2020-12-07 22:29:34 +00:00
||||||| merged common ancestors
fn handle_request(_request: Request) -> BoxFuture<'static, Result<Response>> {
async move {
let response = Document::new()
.add_preformatted(include_str!("northstar_logo.txt"))
.add_blank_line()
.add_link("https://docs.rs/northstar", "Documentation")
.add_link("https://github.com/panicbit/northstar", "GitHub")
.add_blank_line()
.add_heading(H1, "Usage")
.add_blank_line()
.add_text("Add the latest version of northstar to your `Cargo.toml`.")
.add_blank_line()
.add_heading(H2, "Manually")
.add_blank_line()
.add_preformatted_with_alt("toml", r#"northstar = "0.3.0" # check crates.io for the latest version"#)
.add_blank_line()
.add_heading(H2, "Automatically")
.add_blank_line()
.add_preformatted_with_alt("sh", "cargo add northstar")
.add_blank_line()
.add_heading(H1, "Generating a key & certificate")
.add_blank_line()
.add_preformatted_with_alt("sh", concat!(
"mkdir cert && cd cert\n",
"openssl req -x509 -nodes -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365",
))
.into();
Ok(response)
}
.boxed()
=======
Server::new()
.add_route("/", response)
.serve_unix("kochab.sock")
.await
2020-12-07 22:29:34 +00:00
>>>>>>> devel
2020-11-14 08:55:21 +00:00
}