fix: fix static assets url generation (#965)
							parent
							
								
									6e5405eeed
								
							
						
					
					
						commit
						ba47e3b2fe
					
				|  | @ -11,8 +11,8 @@ | |||
| 
 | ||||
|   <title>[{[ if .Name -]}][{[ .Name ]}][{[ else ]}]File Browser[{[ end ]}]</title> | ||||
| 
 | ||||
|   <link rel="icon" type="image/png" sizes="32x32" href="/[{[ .StaticURL ]}]/img/icons/favicon-32x32.png"> | ||||
|   <link rel="icon" type="image/png" sizes="16x16" href="/[{[ .StaticURL ]}]/img/icons/favicon-16x16.png"> | ||||
|   <link rel="icon" type="image/png" sizes="32x32" href="[{[ .StaticURL ]}]/img/icons/favicon-32x32.png"> | ||||
|   <link rel="icon" type="image/png" sizes="16x16" href="[{[ .StaticURL ]}]/img/icons/favicon-16x16.png"> | ||||
|   <!-- Add to home screen for Android and modern mobile browsers --> | ||||
|   <link rel="manifest" id="manifestPlaceholder" crossorigin="use-credentials"> | ||||
|   <meta name="theme-color" content="#2979ff"> | ||||
|  | @ -21,17 +21,17 @@ | |||
|   <meta name="apple-mobile-web-app-capable" content="yes"> | ||||
|   <meta name="apple-mobile-web-app-status-bar-style" content="black"> | ||||
|   <meta name="apple-mobile-web-app-title" content="assets"> | ||||
|   <link rel="apple-touch-icon" href="/[{[ .StaticURL ]}]/img/icons/apple-touch-icon-152x152.png"> | ||||
|   <link rel="apple-touch-icon" href="[{[ .StaticURL ]}]/img/icons/apple-touch-icon-152x152.png"> | ||||
| 
 | ||||
|   <!-- Add to home screen for Windows --> | ||||
|   <meta name="msapplication-TileImage" content="/[{[ .StaticURL ]}]/img/icons/msapplication-icon-144x144.png"> | ||||
|   <meta name="msapplication-TileImage" content="[{[ .StaticURL ]}]/img/icons/msapplication-icon-144x144.png"> | ||||
|   <meta name="msapplication-TileColor" content="#2979ff"> | ||||
| 
 | ||||
|   <!-- Inject Some Variables and generate the manifest json --> | ||||
|   <script> | ||||
|     window.FileBrowser = JSON.parse(`[{[ .Json ]}]`); | ||||
|      | ||||
|     var fullStaticURL = window.location.origin + "/" + window.FileBrowser.StaticURL;  | ||||
|     var fullStaticURL = window.location.origin + window.FileBrowser.StaticURL; | ||||
|     var dynamicManifest = { | ||||
|       "name": window.FileBrowser.Name || 'File Browser', | ||||
|       "short_name": window.FileBrowser.Name || 'File Browser', | ||||
|  | @ -134,10 +134,10 @@ | |||
|   </div> | ||||
| 
 | ||||
|   [{[ if .Theme -]}] | ||||
|     <link rel="stylesheet" href="/[{[ .StaticURL ]}]/themes/[{[ .Theme ]}].css" /> | ||||
|     <link rel="stylesheet" href="[{[ .StaticURL ]}]/themes/[{[ .Theme ]}].css" /> | ||||
|   [{[ end ]}] | ||||
|   [{[ if .CSS -]}] | ||||
|     <link rel="stylesheet" href="/[{[ .StaticURL ]}]/custom.css" /> | ||||
|     <link rel="stylesheet" href="[{[ .StaticURL ]}]/custom.css" /> | ||||
|   [{[ end ]}] | ||||
| </body> | ||||
| </html> | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ const recaptcha = window.FileBrowser.ReCaptcha | |||
| const recaptchaKey = window.FileBrowser.ReCaptchaKey | ||||
| const signup = window.FileBrowser.Signup | ||||
| const version = window.FileBrowser.Version | ||||
| const logoURL = `/${staticURL}/img/logo.svg` | ||||
| const logoURL = `${staticURL}/img/logo.svg` | ||||
| const noAuth = window.FileBrowser.NoAuth | ||||
| const authMethod = window.FileBrowser.AuthMethod | ||||
| const loginPage = window.FileBrowser.LoginPage | ||||
|  |  | |||
|  | @ -4,6 +4,7 @@ import ( | |||
| 	"crypto/rand" | ||||
| 	"encoding/base64" | ||||
| 	"net/http" | ||||
| 	"path" | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
| 	"time" | ||||
|  | @ -56,7 +57,7 @@ var sharePostHandler = withPermShare(func(w http.ResponseWriter, r *http.Request | |||
| 		var err error | ||||
| 		s, err = d.store.Share.GetPermanent(r.URL.Path, d.user.ID) | ||||
| 		if err == nil { | ||||
| 			w.Write([]byte(d.server.BaseURL + "/share/" + s.Hash)) | ||||
| 			w.Write([]byte(path.Join(d.server.BaseURL, "/share/", s.Hash))) | ||||
| 			return 0, nil | ||||
| 		} | ||||
| 	} | ||||
|  |  | |||
|  | @ -5,6 +5,7 @@ import ( | |||
| 	"log" | ||||
| 	"net/http" | ||||
| 	"os" | ||||
| 	"path" | ||||
| 	"path/filepath" | ||||
| 	"strings" | ||||
| 	"text/template" | ||||
|  | @ -19,8 +20,6 @@ import ( | |||
| func handleWithStaticData(w http.ResponseWriter, r *http.Request, d *data, box *rice.Box, file, contentType string) (int, error) { | ||||
| 	w.Header().Set("Content-Type", contentType) | ||||
| 
 | ||||
| 	staticURL := strings.TrimPrefix(d.server.BaseURL+"/static", "/") | ||||
| 
 | ||||
| 	auther, err := d.store.Auth.Get(d.settings.AuthMethod) | ||||
| 	if err != nil { | ||||
| 		return http.StatusInternalServerError, err | ||||
|  | @ -31,7 +30,7 @@ func handleWithStaticData(w http.ResponseWriter, r *http.Request, d *data, box * | |||
| 		"DisableExternal": d.settings.Branding.DisableExternal, | ||||
| 		"BaseURL":         d.server.BaseURL, | ||||
| 		"Version":         version.Version, | ||||
| 		"StaticURL":       staticURL, | ||||
| 		"StaticURL":       path.Join(d.server.BaseURL, "/static"), | ||||
| 		"Signup":          d.settings.Signup, | ||||
| 		"NoAuth":          d.settings.AuthMethod == auth.MethodNoAuth, | ||||
| 		"AuthMethod":      d.settings.AuthMethod, | ||||
|  |  | |||
|  | @ -43,7 +43,7 @@ func errToStatus(err error) int { | |||
| // This is an addaptation if http.StripPrefix in which we don't
 | ||||
| // return 404 if the page doesn't have the needed prefix.
 | ||||
| func stripPrefix(prefix string, h http.Handler) http.Handler { | ||||
| 	if prefix == "" { | ||||
| 	if prefix == "" || prefix == "/" { | ||||
| 		return h | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Oleg Lobanov
						Oleg Lobanov