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/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..78923e4c 100644 --- a/server/int/api/resources/massaBox.html +++ b/server/int/api/resources/massaBox.html @@ -31,10 +31,25 @@ 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) { + 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"; + }); } // Function to close the element and save the state in local storage