Skip to content

Commit

Permalink
Add manifest to make it installable
Browse files Browse the repository at this point in the history
  • Loading branch information
stvnrhodes committed Sep 2, 2024
1 parent 1201664 commit 23ab123
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/bin/cecvol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use log::info;
use rouille::router;
use rouille::Request;
use rouille::Response;
use rouille::ResponseBody;
use serde_json::json;
use std::collections::HashSet;
use std::sync::Arc;
Expand All @@ -24,6 +25,17 @@ const DEVICE_ID: &str = "1";
fn index() -> Response {
Response::html(include_str!("../index.html"))
}
fn manifest() -> Response {
Response {
status_code: 200,
headers: vec![(
"Content-Type".into(),
"application/json; charset=utf-8".into(),
)],
data: ResponseBody::from_data(include_str!("../manifest.json")),
upgrade: None,
}
}

fn fulfillment(app_state: AppState, request: &Request) -> Response {
let cec = &app_state.cec;
Expand Down Expand Up @@ -330,9 +342,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
);
let route = |req: &Request| {
router!(req,
(GET) (/) => {index()},
(GET) (/varz) => {varz()},
(POST) (/fulfillment) => {fulfillment(app_state.clone(), req)},
(GET) ["/"] => {index()},
(GET) ["/manifest.json"] => {manifest()},
(GET) ["/varz"] => {varz()},
(POST) ["/fulfillment"] => {fulfillment(app_state.clone(), req)},
_ => rouille::Response::empty_404()
)
};
Expand Down
1 change: 1 addition & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<title>CECvol</title>
<link rel="stylesheet" href="https://unpkg.com/material-components-web@latest/dist/material-components-web.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="manifest" href="/manifest.json">
<style>
h1,
p {
Expand Down
20 changes: 20 additions & 0 deletions src/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "CECVol",
"icons": [
{
"src": "data:image/svg+xml,<svg width='80pt' height='80pt' version='1.0' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'><g transform='translate(0 80) scale(.1 -.1)' fill='purple'><path d='m50 565v-205h350 350v205 205h-350-350v-205zm630 0v-135h-280-280v135 135h280 280v-135z' /><path d='m170 295v-35h230 230v35 35h-230-230v-35z' /><path d='m520 20v70h-70v70h70v70h70v-70h70v-70h-70v-70z' /><path d='m130 115v-35h105 105v35 35h-105-105v-35z' /></g></svg>",
"type": "image/svg+xml",
"sizes": "512x512"
},
{
"src": "data:image/svg+xml,<svg width='80pt' height='80pt' version='1.0' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'><g transform='translate(0 80) scale(.1 -.1)' fill='purple'><path d='m50 565v-205h350 350v205 205h-350-350v-205zm630 0v-135h-280-280v135 135h280 280v-135z' /><path d='m170 295v-35h230 230v35 35h-230-230v-35z' /><path d='m520 20v70h-70v70h70v70h70v-70h70v-70h-70v-70z' /><path d='m130 115v-35h105 105v35 35h-105-105v-35z' /></g></svg>",
"type": "image/svg+xml",
"sizes": "192x192"
}
],
"start_url": "/",
"background_color": "#7F25FF",
"display": "standalone",
"scope": "/",
"theme_color": "#7F25FF"
}

0 comments on commit 23ab123

Please sign in to comment.