Moved dev settings to flag

- Moved internal DEVELOPMENT_MODE flag to start parameters
This commit is contained in:
Toby Chui 2025-04-27 13:55:54 +08:00
parent ffc67ede12
commit 9781735983
6 changed files with 14 additions and 15 deletions

View File

@ -324,7 +324,7 @@ func initAPIs(targetMux *http.ServeMux) {
// Register the standard web services URLs // Register the standard web services URLs
var staticWebRes http.Handler var staticWebRes http.Handler
if DEVELOPMENT_BUILD { if *development_build {
staticWebRes = http.FileServer(http.Dir("web/")) staticWebRes = http.FileServer(http.Dir("web/"))
} else { } else {
subFS, err := fs.Sub(webres, "web") subFS, err := fs.Sub(webres, "web")

View File

@ -43,9 +43,8 @@ import (
const ( const (
/* Build Constants */ /* Build Constants */
SYSTEM_NAME = "Zoraxy" SYSTEM_NAME = "Zoraxy"
SYSTEM_VERSION = "3.2.1" SYSTEM_VERSION = "3.2.1"
DEVELOPMENT_BUILD = true /* Development: Set to false to use embedded web fs */
/* System Constants */ /* System Constants */
TMP_FOLDER = "./tmp" 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_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") path_plugin = flag.String("plugin", "./plugins", "Plugin folder path")
/* Maintaince Function Flags */ /* Maintaince & Development Function Flags */
geoDbUpdate = flag.Bool("update_geoip", false, "Download the latest GeoIP data and exit") 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 */ /* Global Variables and Handlers */

View File

@ -101,7 +101,7 @@ func handleInjectHTML(w http.ResponseWriter, r *http.Request, relativeFilepath s
if len(relativeFilepath) > 0 && relativeFilepath[len(relativeFilepath)-1:] == "/" { if len(relativeFilepath) > 0 && relativeFilepath[len(relativeFilepath)-1:] == "/" {
relativeFilepath = relativeFilepath + "index.html" relativeFilepath = relativeFilepath + "index.html"
} }
if DEVELOPMENT_BUILD { if *development_build {
//Load from disk //Load from disk
targetFilePath := strings.ReplaceAll(filepath.Join("web/", relativeFilepath), "\\", "/") targetFilePath := strings.ReplaceAll(filepath.Join("web/", relativeFilepath), "\\", "/")
content, err = os.ReadFile(targetFilePath) content, err = os.ReadFile(targetFilePath)

View File

@ -100,7 +100,7 @@ func startupSequence() {
}) })
//Create a TLS certificate manager //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 { if err != nil {
panic(err) panic(err)
} }
@ -321,7 +321,7 @@ func startupSequence() {
SystemConst: &zoraxy_plugin.RuntimeConstantValue{ SystemConst: &zoraxy_plugin.RuntimeConstantValue{
ZoraxyVersion: SYSTEM_VERSION, ZoraxyVersion: SYSTEM_VERSION,
ZoraxyUUID: nodeUUID, ZoraxyUUID: nodeUUID,
DevelopmentBuild: DEVELOPMENT_BUILD, DevelopmentBuild: *development_build,
}, },
PluginStoreURLs: []string{ PluginStoreURLs: []string{
"https://raw.githubusercontent.com/aroz-online/zoraxy-official-plugins/refs/heads/main/directories/index.json", "https://raw.githubusercontent.com/aroz-online/zoraxy-official-plugins/refs/heads/main/directories/index.json",

View File

@ -130,7 +130,8 @@
items.forEach(item => { items.forEach(item => {
const name = item.querySelector('.header').textContent.toLowerCase(); const name = item.querySelector('.header').textContent.toLowerCase();
const description = item.querySelector('.description p').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(); const id = item.getAttribute('plugin_id').toLowerCase();
if (name.includes(query) || description.includes(query) || author.includes(query) || id.includes(query)) { if (name.includes(query) || description.includes(query) || author.includes(query) || id.includes(query)) {
@ -184,11 +185,9 @@
<img src="${plugin.IconPath}" alt="${plugin.PluginIntroSpect.name}"> <img src="${plugin.IconPath}" alt="${plugin.PluginIntroSpect.name}">
</div> </div>
<div class="content"> <div class="content">
<div class="header">${plugin.PluginIntroSpect.name}</div> <div class="header">${plugin.PluginIntroSpect.name} </div> <a class="section" href="${plugin.PluginIntroSpect.url}" target="_blank"><i class="ui linkify icon"></i></a>
<div class="meta"> <div class="meta">
<span>Version: ${plugin.PluginIntroSpect.version_major}.${plugin.PluginIntroSpect.version_minor}.${plugin.PluginIntroSpect.version_patch}</span> <p>v${plugin.PluginIntroSpect.version_major}.${plugin.PluginIntroSpect.version_minor}.${plugin.PluginIntroSpect.version_patch} by <span class="plugin_author">${plugin.PluginIntroSpect.author}</span></p>
<span>${plugin.PluginIntroSpect.author}</span>
<span><a href="${plugin.PluginIntroSpect.url}" target="_blank">Website</a></span>
</div> </div>
<div class="description"> <div class="description">
<p>${plugin.PluginIntroSpect.description}</p> <p>${plugin.PluginIntroSpect.description}</p>

View File

@ -345,7 +345,7 @@ func HandleZoraxyInfo(w http.ResponseWriter, r *http.Request) {
info := ZoraxyInfo{ info := ZoraxyInfo{
Version: SYSTEM_VERSION, Version: SYSTEM_VERSION,
NodeUUID: displayUUID, NodeUUID: displayUUID,
Development: DEVELOPMENT_BUILD, Development: *development_build,
BootTime: displayBootTime, BootTime: displayBootTime,
EnableSshLoopback: displayAllowSSHLB, EnableSshLoopback: displayAllowSSHLB,
} }