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()
|
2020-11-25 05:42:09 +00:00
|
|
|
.filter_module("kochab", LevelFilter::Debug)
|
2020-11-14 08:55:21 +00:00
|
|
|
.init();
|
|
|
|
|
2020-11-24 04:30:59 +00:00
|
|
|
let response: Response = Document::new()
|
2020-11-25 05:42:09 +00:00
|
|
|
.add_preformatted_with_alt("kochab", include_str!("kochab_logo.txt"))
|
2020-11-20 04:39:07 +00:00
|
|
|
.add_blank_line()
|
2020-11-25 05:42:09 +00:00
|
|
|
.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."
|
|
|
|
)
|
|
|
|
)
|
2020-11-20 04:39:07 +00:00
|
|
|
.add_blank_line()
|
2020-11-25 05:42:09 +00:00
|
|
|
.add_link("https://github.com/Alch-Emi/kochab", "GitHub")
|
2020-11-20 04:39:07 +00:00
|
|
|
.add_blank_line()
|
2020-11-25 05:42:09 +00:00
|
|
|
.add_heading(H2, "Usage")
|
2020-11-20 04:39:07 +00:00
|
|
|
.add_blank_line()
|
2020-11-25 05:42:09 +00:00
|
|
|
.add_text("Add the latest version of kochab to your `Cargo.toml`.")
|
2020-11-20 04:39:07 +00:00
|
|
|
.add_blank_line()
|
2020-11-25 05:42:09 +00:00
|
|
|
.add_preformatted_with_alt("toml", r#"kochab = { git = "https://github.com/Alch-Emi/kochab.git" }"#)
|
2020-11-20 04:39:07 +00:00
|
|
|
.add_blank_line()
|
2020-11-25 05:42:09 +00:00
|
|
|
.add_heading(H2, "Generating a key & certificate")
|
2020-11-20 04:39:07 +00:00
|
|
|
.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 {
|
2020-11-30 19:27:58 +00:00
|
|
|
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",
|
2020-11-20 14:51:37 +00:00
|
|
|
))
|
|
|
|
.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()
|
|
|
|
=======
|
2020-12-01 07:31:08 +00:00
|
|
|
Server::new()
|
2020-11-24 04:30:59 +00:00
|
|
|
.add_route("/", response)
|
2020-12-01 07:31:08 +00:00
|
|
|
.serve_unix("kochab.sock")
|
2020-11-24 04:30:59 +00:00
|
|
|
.await
|
2020-12-07 22:29:34 +00:00
|
|
|
>>>>>>> devel
|
2020-11-14 08:55:21 +00:00
|
|
|
}
|