From cec88dca28d5df897dc2042008320dc10111cb1b Mon Sep 17 00:00:00 2001 From: Andrei Fleiser Date: Wed, 8 Oct 2025 18:32:29 +0200 Subject: [PATCH 1/2] add noBanner metadata for the site no to display the deweb banner --- server/api/read/models/de_web_info.go | 3 +++ server/api/read/restapi/embedded_spec.go | 6 ++++++ server/api/readAPI-V0.yml | 4 +++- server/int/api/config/config.go | 4 ++++ server/int/api/handlers.go | 1 + server/int/api/resources/massaBox.html | 20 +++++++++++++++++--- 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/server/api/read/models/de_web_info.go b/server/api/read/models/de_web_info.go index 166c9a74..a2bb7411 100644 --- a/server/api/read/models/de_web_info.go +++ b/server/api/read/models/de_web_info.go @@ -33,6 +33,9 @@ type DeWebInfo struct { // network Network *DeWebInfoNetwork `json:"network,omitempty"` + // no banner + NoBanner bool `json:"noBanner,omitempty"` + // version Version string `json:"version,omitempty"` } diff --git a/server/api/read/restapi/embedded_spec.go b/server/api/read/restapi/embedded_spec.go index a1ccd828..d5bd93ed 100644 --- a/server/api/read/restapi/embedded_spec.go +++ b/server/api/read/restapi/embedded_spec.go @@ -117,6 +117,9 @@ func init() { } } }, + "noBanner": { + "type": "boolean" + }, "version": { "type": "string" } @@ -232,6 +235,9 @@ func init() { } } }, + "noBanner": { + "type": "boolean" + }, "version": { "type": "string" } diff --git a/server/api/readAPI-V0.yml b/server/api/readAPI-V0.yml index 347d8dea..f4d52391 100644 --- a/server/api/readAPI-V0.yml +++ b/server/api/readAPI-V0.yml @@ -73,4 +73,6 @@ definitions: blockList: type: array items: - type: string \ No newline at end of file + type: string + noBanner: + type: boolean \ No newline at end of file diff --git a/server/int/api/config/config.go b/server/int/api/config/config.go index 26a1e411..d1ddb479 100644 --- a/server/int/api/config/config.go +++ b/server/int/api/config/config.go @@ -25,6 +25,7 @@ type ServerConfig struct { BlockList []string MiscPublicInfoJson interface{} CacheConfig CacheConfig + NoBanner bool } type YamlServerConfig struct { @@ -36,6 +37,7 @@ type YamlServerConfig struct { MiscPublicInfoJson interface{} `yaml:"misc_public_info,omitempty"` CacheConfig *YamlCacheConfig `yaml:"cache,omitempty"` AllowOffline bool `yaml:"allow_offline,omitempty"` + NoBanner bool `yaml:"no_banner,omitempty"` } func DefaultConfig() (*ServerConfig, error) { @@ -52,6 +54,7 @@ func DefaultConfig() (*ServerConfig, error) { BlockList: []string{}, MiscPublicInfoJson: map[string]interface{}{}, CacheConfig: DefaultCacheConfig(), + NoBanner: false, }, nil } @@ -122,6 +125,7 @@ func LoadServerConfig(configPath string) (*ServerConfig, error) { BlockList: yamlConf.BlockList, MiscPublicInfoJson: convertYamlMisc2Json(yamlConf.MiscPublicInfoJson), CacheConfig: cacheConfig, + NoBanner: yamlConf.NoBanner, } return config, nil diff --git a/server/int/api/handlers.go b/server/int/api/handlers.go index c316d0c7..7dcb437d 100644 --- a/server/int/api/handlers.go +++ b/server/int/api/handlers.go @@ -58,6 +58,7 @@ func (dI *dewebInfo) Handle(params operations.GetDeWebInfoParams) middleware.Res }, AllowList: dI.conf.AllowList, BlockList: dI.conf.BlockList, + NoBanner: dI.conf.NoBanner, }).WriteResponse(w, runtime) }) } diff --git a/server/int/api/resources/massaBox.html b/server/int/api/resources/massaBox.html index f65d3afd..5bf26235 100644 --- a/server/int/api/resources/massaBox.html +++ b/server/int/api/resources/massaBox.html @@ -31,10 +31,24 @@ function checkIfClosed() { const isClosed = localStorage.getItem("massaBoxClosed"); const massaBox = document.getElementById("massaBox"); - - if (isClosed != "true") { - massaBox.style.display = "flex"; + if (isClosed == "true") { + return; } + + // Check if banner should be hidden based on server response + fetch(window.location.origin + "/__deweb_info") + .then(response => response.json()) + .then(data => { + if (data.noBanner !== true) { + massaBox.style.display = "flex"; + return; + } else { + localStorage.setItem("massaBoxClosed", "true"); + } + }) + .catch(error => { + console.log("Could not fetch deweb info:", error); + }); } // Function to close the element and save the state in local storage From 21933b67e7c31db70393a1b412704c112c44fff6 Mon Sep 17 00:00:00 2001 From: Andrei Fleiser Date: Mon, 13 Oct 2025 11:29:09 +0200 Subject: [PATCH 2/2] upgrade deweb version and enhance code --- plugin/manifest.json | 2 +- server/int/api/resources/massaBox.html | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/plugin/manifest.json b/plugin/manifest.json index de021c60..4d6577ed 100644 --- a/plugin/manifest.json +++ b/plugin/manifest.json @@ -4,6 +4,6 @@ "description": "Your private access to DeWeb.", "logo": "favicon.png", "home": "", - "version": "0.4.7", + "version": "0.4.8", "apispec": "" } \ No newline at end of file diff --git a/server/int/api/resources/massaBox.html b/server/int/api/resources/massaBox.html index 5bf26235..78923e4c 100644 --- a/server/int/api/resources/massaBox.html +++ b/server/int/api/resources/massaBox.html @@ -31,7 +31,7 @@ function checkIfClosed() { const isClosed = localStorage.getItem("massaBoxClosed"); const massaBox = document.getElementById("massaBox"); - if (isClosed == "true") { + if (isClosed === "true") { return; } @@ -39,15 +39,16 @@ fetch(window.location.origin + "/__deweb_info") .then(response => response.json()) .then(data => { - if (data.noBanner !== true) { - massaBox.style.display = "flex"; - return; - } else { + if (data.noBanner) { localStorage.setItem("massaBoxClosed", "true"); + } else { + massaBox.style.display = "flex"; } }) .catch(error => { console.log("Could not fetch deweb info:", error); + // If we can't fetch the deweb info, show the banner by default + massaBox.style.display = "flex"; }); }