Port to Rocket 0.5.0-rc2
This commit is contained in:
parent
c3ae8ca62a
commit
da5179d05a
6 changed files with 626 additions and 369 deletions
948
Cargo.lock
generated
948
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
16
Cargo.toml
16
Cargo.toml
|
@ -8,16 +8,16 @@ a family or group of friends.
|
|||
"""
|
||||
readme = "README.md"
|
||||
license = "MIT"
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
comrak = "0.7.0"
|
||||
Inflector = "0.11.4"
|
||||
comrak = "0.14.0"
|
||||
glob = "0.3.0"
|
||||
Inflector = "*"
|
||||
rocket = { version = "0.5.0-rc.1", features = ["json"] }
|
||||
rocket_dyn_templates = { version = "0.1.0-rc.1", features = ["tera"] }
|
||||
toml = "0.5"
|
||||
rocket = { version = "0.5.0-rc.2", features = ["json"] }
|
||||
rocket_dyn_templates = { version = "0.1.0-rc.2", features = ["tera"] }
|
||||
toml = "0.5.9"
|
||||
|
||||
[dev-dependencies]
|
||||
serde = "1.0"
|
||||
serde_json = "1.0"
|
||||
serde = "1.0.145"
|
||||
serde_json = "1.0.86"
|
||||
|
|
|
@ -40,14 +40,13 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn index() {
|
||||
let client = Client::untracked(crate::rocket(Some("test"))).unwrap();
|
||||
let client = Client::untracked(crate::build_rocket(Some("test"))).unwrap();
|
||||
|
||||
// Try to get the index and verify the body
|
||||
let res = client.get("/").header(Accept::HTML).dispatch();
|
||||
assert_eq!(res.status(), Status::Ok);
|
||||
|
||||
let body = res.into_string().unwrap();
|
||||
println!("body: {}", body);
|
||||
assert!(body.contains("<span id=\"note-name\">Test</span>"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn index() {
|
||||
let client = Client::untracked(crate::rocket(Some("test"))).unwrap();
|
||||
let client = Client::untracked(crate::build_rocket(Some("test"))).unwrap();
|
||||
|
||||
// Try to get all the notes
|
||||
let res = client.get("/notes").header(Accept::JSON).dispatch();
|
||||
|
@ -72,7 +72,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn show_html() {
|
||||
let client = Client::untracked(crate::rocket(Some("test"))).unwrap();
|
||||
let client = Client::untracked(crate::build_rocket(Some("test"))).unwrap();
|
||||
|
||||
// Try to get the note and verify the body
|
||||
let res = client.get("/notes/test").header(Accept::HTML).dispatch();
|
||||
|
@ -93,7 +93,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn show_json() {
|
||||
let client = Client::untracked(crate::rocket(Some("test"))).unwrap();
|
||||
let client = Client::untracked(crate::build_rocket(Some("test"))).unwrap();
|
||||
|
||||
// Try to get the note and verify the body
|
||||
let res = client.get("/notes/test").header(Accept::JSON).dispatch();
|
||||
|
@ -120,7 +120,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn update() {
|
||||
let client = Client::untracked(crate::rocket(Some("test"))).unwrap();
|
||||
let client = Client::untracked(crate::build_rocket(Some("test"))).unwrap();
|
||||
|
||||
// Try to get the note and determine what to change it to
|
||||
let res = client
|
||||
|
|
10
src/main.rs
10
src/main.rs
|
@ -17,7 +17,7 @@ pub struct Config {
|
|||
title: String,
|
||||
}
|
||||
|
||||
fn rocket(notes_path: Option<&str>) -> Rocket<Build> {
|
||||
fn build_rocket(notes_path: Option<&str>) -> Rocket<Build> {
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
use std::path::Path;
|
||||
|
@ -51,9 +51,7 @@ fn rocket(notes_path: Option<&str>) -> Rocket<Build> {
|
|||
.attach(Template::fairing())
|
||||
}
|
||||
|
||||
#[rocket::main]
|
||||
async fn main() -> Result<(), rocket::Error> {
|
||||
rocket(None).launch().await?;
|
||||
|
||||
Ok(())
|
||||
#[rocket::launch]
|
||||
fn rocket() -> _ {
|
||||
build_rocket(None)
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ pub struct Note {
|
|||
/// The ID of the note (unique string)
|
||||
pub id: String,
|
||||
/// The index of the note (unique number)
|
||||
pub index: i8,
|
||||
pub index: usize,
|
||||
/// The raw note data
|
||||
pub data: String,
|
||||
/// The time the note was last modified
|
||||
|
@ -29,10 +29,10 @@ pub struct Note {
|
|||
impl Note {
|
||||
pub fn to_html(&self) -> String {
|
||||
let mut options = comrak::ComrakOptions::default();
|
||||
options.ext_strikethrough = true;
|
||||
options.ext_tagfilter = true;
|
||||
options.ext_autolink = true;
|
||||
options.ext_tasklist = true;
|
||||
options.extension.strikethrough = true;
|
||||
options.extension.tagfilter = true;
|
||||
options.extension.autolink = true;
|
||||
options.extension.tasklist = true;
|
||||
|
||||
comrak::markdown_to_html(&self.data, &options)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue