From 2f166bab49d43c29c66bc3d8965b45911a0ce997 Mon Sep 17 00:00:00 2001 From: Zachary Dunn Date: Mon, 10 Sep 2018 10:08:22 -0400 Subject: [PATCH 1/3] Add webapp manifest --- src/main.rs | 1 + src/routes/instance.rs | 14 ++++++++++++++ templates/base.html.tera | 1 + 3 files changed, 16 insertions(+) diff --git a/src/main.rs b/src/main.rs index c00c4570..f03959f5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -64,6 +64,7 @@ fn main() { routes::instance::shared_inbox, routes::instance::nodeinfo, routes::instance::about, + routes::instance::web_manifest, routes::likes::create, routes::likes::create_auth, diff --git a/src/routes/instance.rs b/src/routes/instance.rs index 159fc6cd..2dc4a0c2 100644 --- a/src/routes/instance.rs +++ b/src/routes/instance.rs @@ -154,3 +154,17 @@ fn about(user: Option, conn: DbConn) -> Template { "n_instances": Instance::count(&*conn) - 1 })) } + +#[get("/manifest.json")] +fn web_manifest(conn: DbConn) -> Json { + let instance = Instance::get_local(&*conn); + Json(json!({ + "name": &instance.name, + "description": &instance.short_description, + "start_url": String::from("/"), + "scope": String::from("/"), + "display": String::from("standalone"), + "background_color": String::from("#f4f4f4"), + "theme_color": String::from("#7765e3") + })) +} diff --git a/templates/base.html.tera b/templates/base.html.tera index 6825e736..7051a74e 100644 --- a/templates/base.html.tera +++ b/templates/base.html.tera @@ -6,6 +6,7 @@ +
From 3a81dd70898a53858f4b2b843573c3b089315bf7 Mon Sep 17 00:00:00 2001 From: Zachary Dunn Date: Mon, 10 Sep 2018 10:08:22 -0400 Subject: [PATCH 2/3] Add webapp manifest --- src/main.rs | 1 + src/routes/instance.rs | 14 ++++++++++++++ templates/base.html.tera | 1 + 3 files changed, 16 insertions(+) diff --git a/src/main.rs b/src/main.rs index 932e6e5f..a51b34d1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -75,6 +75,7 @@ fn main() { routes::instance::shared_inbox, routes::instance::nodeinfo, routes::instance::about, + routes::instance::web_manifest, routes::likes::create, routes::likes::create_auth, diff --git a/src/routes/instance.rs b/src/routes/instance.rs index a8d7965d..4d3a1847 100644 --- a/src/routes/instance.rs +++ b/src/routes/instance.rs @@ -244,3 +244,17 @@ fn about(user: Option, conn: DbConn) -> Template { "n_instances": Instance::count(&*conn) - 1 })) } + +#[get("/manifest.json")] +fn web_manifest(conn: DbConn) -> Json { + let instance = Instance::get_local(&*conn); + Json(json!({ + "name": &instance.name, + "description": &instance.short_description, + "start_url": String::from("/"), + "scope": String::from("/"), + "display": String::from("standalone"), + "background_color": String::from("#f4f4f4"), + "theme_color": String::from("#7765e3") + })) +} diff --git a/templates/base.html.tera b/templates/base.html.tera index 0fd1047f..f68031e6 100644 --- a/templates/base.html.tera +++ b/templates/base.html.tera @@ -8,6 +8,7 @@ +
From 8765b1222977864c74c329fa91082d24774d6e58 Mon Sep 17 00:00:00 2001 From: Zachary Dunn Date: Mon, 10 Sep 2018 14:54:18 -0400 Subject: [PATCH 3/3] Unwrap option --- src/routes/instance.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/instance.rs b/src/routes/instance.rs index 4d3a1847..1bec0f3c 100644 --- a/src/routes/instance.rs +++ b/src/routes/instance.rs @@ -247,7 +247,7 @@ fn about(user: Option, conn: DbConn) -> Template { #[get("/manifest.json")] fn web_manifest(conn: DbConn) -> Json { - let instance = Instance::get_local(&*conn); + let instance = Instance::get_local(&*conn).unwrap(); Json(json!({ "name": &instance.name, "description": &instance.short_description,