mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-23 08:32:23 +03:00
rename apps_home to homepage
This commit is contained in:
parent
bcb32810c8
commit
177ee55e7d
2
build.rs
2
build.rs
@ -32,7 +32,7 @@ fn main() {
|
||||
|
||||
// Build wasm32-wasi apps.
|
||||
const WASI_APPS: [&str; 8] = [
|
||||
"apps_home",
|
||||
"homepage",
|
||||
"chess",
|
||||
"http_bindings",
|
||||
"http_proxy",
|
||||
|
@ -8,18 +8,6 @@ version = "1.0.75"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
|
||||
|
||||
[[package]]
|
||||
name = "apps_home"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bincode",
|
||||
"cargo-component-bindings",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"wit-bindgen 0.9.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bincode"
|
||||
version = "1.3.3"
|
||||
@ -95,6 +83,18 @@ dependencies = [
|
||||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "homepage"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bincode",
|
||||
"cargo-component-bindings",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"wit-bindgen 0.9.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "id-arena"
|
||||
version = "2.2.1"
|
@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "apps_home"
|
||||
name = "homepage"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
@ -228,7 +228,7 @@
|
||||
// webSocket.send(JSON.stringify({
|
||||
// Register: {
|
||||
// auth_token: getCookie(`uqbar-ws-auth_${window.our}`),
|
||||
// channel_id: "apps_home" // Can be unique to this connection, app, or omitted entirely
|
||||
// channel_id: "homepage" // Can be unique to this connection, app, or omitted entirely
|
||||
// }
|
||||
// }))
|
||||
|
||||
@ -238,9 +238,9 @@
|
||||
// auth_token: getCookie(`uqbar-ws-auth_${window.our}`),
|
||||
// target: {
|
||||
// node: window.our,
|
||||
// process: 'apps_home'
|
||||
// process: 'homepage'
|
||||
// },
|
||||
// channel_id: 'apps_home',
|
||||
// channel_id: 'homepage',
|
||||
// json: {
|
||||
// action: 'ping'
|
||||
// // You could add a unique ID here so that the server can respond to only this ID
|
@ -8,7 +8,7 @@ mod process_lib;
|
||||
|
||||
struct Component;
|
||||
|
||||
const APPS_HOME_PAGE: &str = include_str!("home.html");
|
||||
const HOME_PAGE: &str = include_str!("home.html");
|
||||
|
||||
fn generate_http_binding(add: Address, path: &str, authenticated: bool) -> (Address, Request, Option<Context>, Option<Payload>) {
|
||||
(
|
||||
@ -19,7 +19,7 @@ fn generate_http_binding(add: Address, path: &str, authenticated: bool) -> (Addr
|
||||
ipc: Some(serde_json::json!({
|
||||
"action": "bind-app",
|
||||
"path": path,
|
||||
"app": "apps_home",
|
||||
"app": "homepage",
|
||||
"authenticated": authenticated
|
||||
}).to_string()),
|
||||
metadata: None,
|
||||
@ -31,7 +31,7 @@ fn generate_http_binding(add: Address, path: &str, authenticated: bool) -> (Addr
|
||||
|
||||
impl Guest for Component {
|
||||
fn init(our: Address) {
|
||||
print_to_terminal(1, "apps_home: start");
|
||||
print_to_terminal(1, "homepage: start");
|
||||
|
||||
let bindings_address = Address {
|
||||
node: our.node.clone(),
|
||||
@ -46,28 +46,28 @@ impl Guest for Component {
|
||||
|
||||
loop {
|
||||
let Ok((_source, message)) = receive() else {
|
||||
print_to_terminal(0, "apps_home: got network error");
|
||||
print_to_terminal(0, "homepage: got network error");
|
||||
continue;
|
||||
};
|
||||
let Message::Request(request) = message else {
|
||||
print_to_terminal(0, &format!("apps_home: got unexpected message: {:?}", message));
|
||||
print_to_terminal(0, &format!("homepage: got unexpected message: {:?}", message));
|
||||
continue;
|
||||
};
|
||||
|
||||
if let Some(json) = request.ipc {
|
||||
print_to_terminal(1, format!("apps_home: JSON {}", json).as_str());
|
||||
print_to_terminal(1, format!("homepage: JSON {}", json).as_str());
|
||||
let message_json: serde_json::Value = match serde_json::from_str(&json) {
|
||||
Ok(v) => v,
|
||||
Err(_) => {
|
||||
print_to_terminal(1, "apps_home: failed to parse ipc JSON, skipping");
|
||||
print_to_terminal(1, "homepage: failed to parse ipc JSON, skipping");
|
||||
continue;
|
||||
},
|
||||
};
|
||||
|
||||
print_to_terminal(1, "apps_home: parsed ipc JSON");
|
||||
print_to_terminal(1, "homepage: parsed ipc JSON");
|
||||
|
||||
if message_json["path"] == "/" && message_json["method"] == "GET" {
|
||||
print_to_terminal(1, "apps_home: sending response");
|
||||
print_to_terminal(1, "homepage: sending response");
|
||||
|
||||
send_response(
|
||||
&Response {
|
||||
@ -82,7 +82,7 @@ impl Guest for Component {
|
||||
},
|
||||
Some(&Payload {
|
||||
mime: Some("text/html".to_string()),
|
||||
bytes: APPS_HOME_PAGE.replace("${our}", &our.node).to_string().as_bytes().to_vec(),
|
||||
bytes: HOME_PAGE.replace("${our}", &our.node).to_string().as_bytes().to_vec(),
|
||||
}),
|
||||
);
|
||||
} else if message_json["path"].is_string() {
|
||||
@ -136,7 +136,7 @@ impl Guest for Component {
|
||||
expects_response: None,
|
||||
ipc: Some(serde_json::json!({
|
||||
"EncryptAndForwardAction": {
|
||||
"channel_id": "apps_home",
|
||||
"channel_id": "homepage",
|
||||
"forward_to": {
|
||||
"node": our.node.clone(),
|
||||
"process": {
|
||||
@ -147,7 +147,7 @@ impl Guest for Component {
|
||||
"WebSocketPush": {
|
||||
"target": {
|
||||
"node": our.node.clone(),
|
||||
"id": "apps_home", // If the message passed in an ID then we could send to just that ID
|
||||
"id": "homepage", // If the message passed in an ID then we could send to just that ID
|
||||
}
|
||||
}
|
||||
})),
|
@ -193,7 +193,7 @@ impl Guest for Component {
|
||||
.trim_start_matches('/')
|
||||
.split("/")
|
||||
.collect::<Vec<&str>>();
|
||||
if app != "apps_home"
|
||||
if app != "homepage"
|
||||
&& (path_segments.is_empty()
|
||||
|| path_segments[0] != app.clone().replace("_", "-"))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user