From 97817359833fb9bc0f6367be3bed44e1bbb6442b Mon Sep 17 00:00:00 2001 From: Toby Chui Date: Sun, 27 Apr 2025 13:55:54 +0800 Subject: [PATCH] Moved dev settings to flag - Moved internal DEVELOPMENT_MODE flag to start parameters --- src/api.go | 2 +- src/def.go | 10 +++++----- src/router.go | 2 +- src/start.go | 4 ++-- src/web/snippet/pluginstore.html | 9 ++++----- src/wrappers.go | 2 +- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/api.go b/src/api.go index 1caedeb..01adf20 100644 --- a/src/api.go +++ b/src/api.go @@ -324,7 +324,7 @@ func initAPIs(targetMux *http.ServeMux) { // Register the standard web services URLs var staticWebRes http.Handler - if DEVELOPMENT_BUILD { + if *development_build { staticWebRes = http.FileServer(http.Dir("web/")) } else { subFS, err := fs.Sub(webres, "web") diff --git a/src/def.go b/src/def.go index 9b717ef..7efd638 100644 --- a/src/def.go +++ b/src/def.go @@ -43,9 +43,8 @@ import ( const ( /* Build Constants */ - SYSTEM_NAME = "Zoraxy" - SYSTEM_VERSION = "3.2.1" - DEVELOPMENT_BUILD = true /* Development: Set to false to use embedded web fs */ + SYSTEM_NAME = "Zoraxy" + SYSTEM_VERSION = "3.2.1" /* System Constants */ TMP_FOLDER = "./tmp" @@ -101,8 +100,9 @@ var ( path_webserver = flag.String("webroot", "./www", "Static web server root folder. Only allow change in start paramters") path_plugin = flag.String("plugin", "./plugins", "Plugin folder path") - /* Maintaince Function Flags */ - geoDbUpdate = flag.Bool("update_geoip", false, "Download the latest GeoIP data and exit") + /* Maintaince & Development Function Flags */ + geoDbUpdate = flag.Bool("update_geoip", false, "Download the latest GeoIP data and exit") + development_build = flag.Bool("dev", false, "Use external web folder for UI development") ) /* Global Variables and Handlers */ diff --git a/src/router.go b/src/router.go index 05f91dd..064ed27 100644 --- a/src/router.go +++ b/src/router.go @@ -101,7 +101,7 @@ func handleInjectHTML(w http.ResponseWriter, r *http.Request, relativeFilepath s if len(relativeFilepath) > 0 && relativeFilepath[len(relativeFilepath)-1:] == "/" { relativeFilepath = relativeFilepath + "index.html" } - if DEVELOPMENT_BUILD { + if *development_build { //Load from disk targetFilePath := strings.ReplaceAll(filepath.Join("web/", relativeFilepath), "\\", "/") content, err = os.ReadFile(targetFilePath) diff --git a/src/start.go b/src/start.go index 83ed7f1..0fadc05 100644 --- a/src/start.go +++ b/src/start.go @@ -100,7 +100,7 @@ func startupSequence() { }) //Create a TLS certificate manager - tlsCertManager, err = tlscert.NewManager(CONF_CERT_STORE, DEVELOPMENT_BUILD, SystemWideLogger) + tlsCertManager, err = tlscert.NewManager(CONF_CERT_STORE, *development_build, SystemWideLogger) if err != nil { panic(err) } @@ -321,7 +321,7 @@ func startupSequence() { SystemConst: &zoraxy_plugin.RuntimeConstantValue{ ZoraxyVersion: SYSTEM_VERSION, ZoraxyUUID: nodeUUID, - DevelopmentBuild: DEVELOPMENT_BUILD, + DevelopmentBuild: *development_build, }, PluginStoreURLs: []string{ "https://raw.githubusercontent.com/aroz-online/zoraxy-official-plugins/refs/heads/main/directories/index.json", diff --git a/src/web/snippet/pluginstore.html b/src/web/snippet/pluginstore.html index 3f479d4..e7205f0 100644 --- a/src/web/snippet/pluginstore.html +++ b/src/web/snippet/pluginstore.html @@ -130,7 +130,8 @@ items.forEach(item => { const name = item.querySelector('.header').textContent.toLowerCase(); const description = item.querySelector('.description p').textContent.toLowerCase(); - const author = item.querySelector('.meta span:nth-child(2)').textContent.toLowerCase(); + const authorElement = item.querySelector('.plugin_author'); + const author = authorElement ? authorElement.textContent.toLowerCase() : ''; const id = item.getAttribute('plugin_id').toLowerCase(); if (name.includes(query) || description.includes(query) || author.includes(query) || id.includes(query)) { @@ -184,11 +185,9 @@ ${plugin.PluginIntroSpect.name}
-
${plugin.PluginIntroSpect.name}
+
${plugin.PluginIntroSpect.name}
- Version: ${plugin.PluginIntroSpect.version_major}.${plugin.PluginIntroSpect.version_minor}.${plugin.PluginIntroSpect.version_patch} - ${plugin.PluginIntroSpect.author} - Website +

v${plugin.PluginIntroSpect.version_major}.${plugin.PluginIntroSpect.version_minor}.${plugin.PluginIntroSpect.version_patch} by ${plugin.PluginIntroSpect.author}

${plugin.PluginIntroSpect.description}

diff --git a/src/wrappers.go b/src/wrappers.go index 41d8133..81783a7 100644 --- a/src/wrappers.go +++ b/src/wrappers.go @@ -345,7 +345,7 @@ func HandleZoraxyInfo(w http.ResponseWriter, r *http.Request) { info := ZoraxyInfo{ Version: SYSTEM_VERSION, NodeUUID: displayUUID, - Development: DEVELOPMENT_BUILD, + Development: *development_build, BootTime: displayBootTime, EnableSshLoopback: displayAllowSSHLB, }