Преглед изворни кода

Moved homepage to www directory in web to match the industry standard

TC pushbot 5 пре 4 година
родитељ
комит
3f147a9d02

BIN
examples/HomeDynamic2/Sinilink_WiFi_Relay/FIDTRK6JH8JBTII.webp


+ 7 - 0
examples/HomeDynamic2/Sinilink_WiFi_Relay/README.md

@@ -0,0 +1,7 @@
+To see the full flashing tutorial, read the following blog (Traditional Chinese only)
+
+http://imuslab.com/wordpress/2021/04/12/sinilink-xy-wf5v-%E7%81%8C-home-dynamic-v2-iot-%E6%8E%A7%E5%88%B6%E5%99%A8/
+
+
+
+Required IoT Hub with ArozOS 1.112 or above

BIN
examples/HomeDynamic2/Sinilink_WiFi_Relay/esp12.png


BIN
examples/HomeDynamic2/Sinilink_WiFi_Relay/programing wiring.png


BIN
examples/HomeDynamic2/Sinilink_WiFi_Relay/programing wiring.psd


+ 1 - 1
main.flags.go

@@ -83,7 +83,7 @@ var allow_public_registry = flag.Bool("public_reg", false, "Enable public regist
 var allow_autologin = flag.Bool("allow_autologin", true, "Allow RESTFUL login redirection that allow machines like billboards to login to the system on boot")
 var demo_mode = flag.Bool("demo_mode", false, "Run the system in demo mode. All directories and database are read only.")
 var allow_package_autoInstall = flag.Bool("allow_pkg_install", true, "Allow the system to install package using Advanced Package Tool (aka apt or apt-get)")
-var allow_homepage = flag.Bool("enable_homepage", false, "Redirect not logged in users to home page instead of login interface")
+var allow_homepage = flag.Bool("enable_homepage", false, "Redirect not logged in users to public web hosting folder (web/www/) instead of login interface")
 
 //Scheduling and System Service Related
 var nightlyTaskRunTime = flag.Int("ntt", 3, "Nightly tasks execution time. Default 3 = 3 am in the morning")

+ 3 - 3
main.router.go

@@ -90,7 +90,7 @@ func mrouter(h http.Handler) http.Handler {
 			}
 		} else if r.URL.Path == "/" && !authAgent.CheckAuth(r) && *allow_homepage == true {
 			//User not logged in but request the index, redirect to homepage
-			http.Redirect(w, r, "/homepage/index.html", 307)
+			http.Redirect(w, r, "/www/index.html", 307)
 		} else if authAgent.CheckAuth(r) {
 			//User logged in. Continue to serve the file the client want
 			authAgent.UpdateSessionExpireTime(w, r)
@@ -138,14 +138,14 @@ func mrouter(h http.Handler) http.Handler {
 			} else if r.URL.Path[len(r.URL.Path)-1:] != "/" && filepath.Base(filepath.Dir(r.URL.Path)) == "public" {
 				//This file path end with public/. Allow public access
 				h.ServeHTTP(w, r)
-			} else if *allow_homepage == true && r.URL.Path[:10] == "/homepage/" {
+			} else if *allow_homepage == true && len(r.URL.Path) >= 5 && r.URL.Path[:5] == "/www/" {
 				//Handle public home serving if homepage mode is enabled
 				h.ServeHTTP(w, r)
 			} else {
 				//Other paths
 				if *allow_homepage {
 					//Redirect to home page if home page function is enabled
-					http.Redirect(w, r, "/homepage/index.html", 307)
+					http.Redirect(w, r, "/www/index.html", 307)
 				} else {
 					//Rediect to login page
 					w.Header().Set("Cache-Control", "no-cache, no-store, no-transform, must-revalidate, private, max-age=0")

+ 0 - 0
web/homepage/favicon.png → web/www/favicon.png


+ 1 - 1
web/homepage/index.html → web/www/index.html

@@ -33,7 +33,7 @@
                 <div class="ten wide column">
                     <h3>You are seeing this page instead of the login page because you have enabled home page mode</h3>
                     <p>The ArozOS Home Page is a good way to show something simple for your organization or company when hosting on the cloud or a DIY NAS. </p>
-                    <p>To edit this page, take a look at ./web/homepage/index.html</p>
+                    <p>To edit this page, take a look at ./web/www/index.html</p>
                     
                     <h3>How can I turn it this off?</h3>
                     <p>Remove the -enable_homepage flag from your startup script and restart. All users that are not logged in will be redirected to login page instead.</p>