2024-05-11 05:18:42 +01:00
|
|
|
use std::sync::OnceLock;
|
|
|
|
|
2024-05-11 04:25:49 +01:00
|
|
|
use actix_web::{get, HttpResponse, Responder, HttpRequest, Either};
|
2022-12-08 02:30:10 +00:00
|
|
|
|
2024-05-11 05:18:42 +01:00
|
|
|
use crate::storage::IStorage;
|
|
|
|
|
|
|
|
static DESCRIPTOR: OnceLock<String> = OnceLock::new();
|
|
|
|
|
2022-12-08 02:30:10 +00:00
|
|
|
#[get("/")]
|
2024-05-11 05:18:42 +01:00
|
|
|
pub async fn decky_index(req: HttpRequest, data: actix_web::web::Data<Box<dyn IStorage>>) -> impl Responder {
|
2024-05-11 04:25:49 +01:00
|
|
|
if req.headers().contains_key("X-Decky-Version") {
|
|
|
|
// a real store request
|
|
|
|
Either::Left(actix_web::web::Redirect::to("/plugins").temporary())
|
|
|
|
} else {
|
2024-05-11 05:18:42 +01:00
|
|
|
let descriptor = DESCRIPTOR.get_or_init(|| data.descriptor());
|
2024-05-11 04:25:49 +01:00
|
|
|
Either::Right(HttpResponse::Ok()
|
|
|
|
.insert_header(("Content-Type", "text/html"))
|
2024-05-11 05:18:42 +01:00
|
|
|
.body(format!(r##"
|
2024-05-11 04:25:49 +01:00
|
|
|
<!DOCTYTPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<title>Not Decky Store</title>
|
|
|
|
<meta name="title" content="Not Decky Store" />
|
|
|
|
<meta name="description" content="Alternate store implementation for Decky Loader" />
|
|
|
|
|
|
|
|
<!-- Open Graph -->
|
|
|
|
<meta property="og:type" content="website" />
|
|
|
|
<meta property="og:url" content="https://git.ngni.us/NG-SD-Plugins/not-decky-store" />
|
|
|
|
<meta property="og:title" content="Not Decky Store" />
|
|
|
|
<meta property="og:description" content="Alternate store implementation for Decky Loader" />
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h1>Not Decky Store</h1>
|
|
|
|
<h2>An alternate store implementation for Decky Loader</h2>
|
2024-05-11 04:28:50 +01:00
|
|
|
<h3>Maybe one day this page will display plugins in a human readable way...</h3>
|
2024-05-11 04:25:49 +01:00
|
|
|
<br/>
|
|
|
|
<a href="/plugins">plugins</a>
|
2024-05-11 05:18:42 +01:00
|
|
|
| <a href="/version_info">version</a>
|
2024-05-11 04:25:49 +01:00
|
|
|
| <a href="https://git.ngni.us/NG-SD-Plugins/not-decky-store">code</a>
|
|
|
|
| GPL v3.0
|
2024-05-11 05:18:42 +01:00
|
|
|
| <code>{}</code>
|
2024-05-11 04:25:49 +01:00
|
|
|
</body>
|
2024-05-11 05:18:42 +01:00
|
|
|
</html>"##, descriptor)))
|
2024-05-11 04:25:49 +01:00
|
|
|
}
|
2022-12-08 02:30:10 +00:00
|
|
|
}
|