mirror of
				https://github.com/mickael-kerjean/filestash.git
				synced 2025-10-31 10:07:15 +08:00 
			
		
		
		
	improve (404): SVG artwork from pixeltrue.com
This commit is contained in:
		| @ -100,7 +100,7 @@ func Page(stuff string) string { | |||||||
|     <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"> |     <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"> | ||||||
|     <style> |     <style> | ||||||
|       html { background: #f4f4f4; color: #455164; font-size: 16px; font-family: -apple-system,system-ui,BlinkMacSystemFont,Roboto,"Helvetica Neue",Arial,sans-serif; } |       html { background: #f4f4f4; color: #455164; font-size: 16px; font-family: -apple-system,system-ui,BlinkMacSystemFont,Roboto,"Helvetica Neue",Arial,sans-serif; } | ||||||
|       body { text-align: center; padding-top: 50px; text-align: center; } |       body { text-align: center; padding-top: 50px; text-align: center; margin: 0; } | ||||||
|       h1 { font-weight: 200; line-height: 1em; font-size: 40px; } |       h1 { font-weight: 200; line-height: 1em; font-size: 40px; } | ||||||
|       p { opacity: 0.8; font-size: 1.05em; } |       p { opacity: 0.8; font-size: 1.05em; } | ||||||
|     </style> |     </style> | ||||||
|  | |||||||
| @ -28,8 +28,7 @@ func IndexHandler(_path string) func(App, http.ResponseWriter, *http.Request) { | |||||||
| 	return func(ctx App, res http.ResponseWriter, req *http.Request) { | 	return func(ctx App, res http.ResponseWriter, req *http.Request) { | ||||||
| 		urlObj, err := URL.Parse(req.URL.String()) | 		urlObj, err := URL.Parse(req.URL.String()) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			res.WriteHeader(http.StatusInternalServerError) | 			NotFoundHandler(ctx, res, req) | ||||||
| 			res.Write([]byte(Page("<h1>404 - Not Found</h1>"))) |  | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
| 		url := urlObj.Path | 		url := urlObj.Path | ||||||
| @ -40,8 +39,7 @@ func IndexHandler(_path string) func(App, http.ResponseWriter, *http.Request) { | |||||||
| 		} else if url != "/" && strings.HasPrefix(url, "/s/") == false && | 		} else if url != "/" && strings.HasPrefix(url, "/s/") == false && | ||||||
| 			strings.HasPrefix(url, "/view/") == false && strings.HasPrefix(url, "/files/") == false && | 			strings.HasPrefix(url, "/view/") == false && strings.HasPrefix(url, "/files/") == false && | ||||||
| 			url != "/login" && url != "/logout" && strings.HasPrefix(url, "/admin") == false { | 			url != "/login" && url != "/logout" && strings.HasPrefix(url, "/admin") == false { | ||||||
| 			res.WriteHeader(http.StatusNotFound) | 			NotFoundHandler(ctx, res, req) | ||||||
| 			res.Write([]byte(Page("<h1>404 - Not Found</h1>"))) |  | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
| 		ua := req.Header.Get("User-Agent"); | 		ua := req.Header.Get("User-Agent"); | ||||||
| @ -65,6 +63,11 @@ func IndexHandler(_path string) func(App, http.ResponseWriter, *http.Request) { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func NotFoundHandler(ctx App, res http.ResponseWriter, req *http.Request) { | ||||||
|  | 	res.WriteHeader(http.StatusNotFound) | ||||||
|  | 	res.Write([]byte(Page(`<img style="max-width:800px" src="/assets/icons/404.svg" />`))) | ||||||
|  | } | ||||||
|  |  | ||||||
| func AboutHandler(ctx App, res http.ResponseWriter, req *http.Request) { | func AboutHandler(ctx App, res http.ResponseWriter, req *http.Request) { | ||||||
| 	t, _ := template.New("about").Parse(Page(` | 	t, _ := template.New("about").Parse(Page(` | ||||||
| 	  <h1> {{index .App 0}} </h1> | 	  <h1> {{index .App 0}} </h1> | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Mickael Kerjean
					Mickael Kerjean