mirror of
				https://github.com/nkanaev/yarr.git
				synced 2025-10-31 06:53:30 +00:00 
			
		
		
		
	Merge 9740e5ee12 into a895145586
				
					
				
			This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								src/assets/graphicarts/favicon-144.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/assets/graphicarts/favicon-144.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 5.3 KiB | 
| @@ -3,16 +3,22 @@ | ||||
| <head> | ||||
|     <meta charset="UTF-8"> | ||||
|     <title>yarr!</title> | ||||
|     <link rel="stylesheet" href="./static/stylesheets/bootstrap.min.css"> | ||||
|     <link rel="stylesheet" href="./static/stylesheets/app.css"> | ||||
|     <link rel="icon" href="./static/graphicarts/favicon.svg" type="image/svg+xml"> | ||||
|     <link rel="alternate icon" href="./static/graphicarts/favicon.png" type="image/png"> | ||||
|     <link rel="manifest" href="./manifest.json" /> | ||||
|     <link rel="stylesheet" href="./static/stylesheets/bootstrap.min.css" crossorigin="use-credentials"> | ||||
|     <link rel="stylesheet" href="./static/stylesheets/app.css" crossorigin="use-credentials"> | ||||
|     <link rel="icon" href="./static/graphicarts/favicon.svg" type="image/svg+xml" crossorigin="use-credentials"> | ||||
|     <link rel="alternate icon" href="./static/graphicarts/favicon.png" type="image/png" crossorigin="use-credentials"> | ||||
|     <link rel="manifest" href="./manifest.json" crossorigin="use-credentials"/> | ||||
|     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||||
|     <script> | ||||
|         window.app = window.app || {} | ||||
|         window.app.settings = {% .settings %} | ||||
|         window.app.authenticated = {% .authenticated %} | ||||
|  | ||||
|         if ("serviceWorker" in navigator) { | ||||
|             // we use `./sw.js` instead of `./static/javascripts/sw.js` since the latter would not work with | ||||
|             // `./manifest.json`, and it leads to uninstallable PWA | ||||
|             navigator.serviceWorker.register("./sw.js") | ||||
|         } | ||||
|     </script> | ||||
| </head> | ||||
| <body class="theme-{% .settings.theme_name %}"> | ||||
|   | ||||
							
								
								
									
										34
									
								
								src/assets/javascripts/sw.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								src/assets/javascripts/sw.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,34 @@ | ||||
| const VERSION = "v2.4" | ||||
| const APP_STATIC_RESOURCES = [ | ||||
|   "/", | ||||
|   "/static/stylesheets/bootstrap.min.css", | ||||
|   "/static/stylesheets/app.css", | ||||
|   "/static/graphicarts/favicon.svg", | ||||
|   "/static/graphicarts/favicon.png", | ||||
| ] | ||||
| const CACHE_NAME = `yarr-${VERSION}`; | ||||
|  | ||||
| self.addEventListener("install", (e) => { | ||||
|   e.waitUntil((async () => { | ||||
|       const cache = await caches.open(CACHE_NAME) | ||||
|       await cache.addAll(APP_STATIC_RESOURCES) | ||||
|     })() | ||||
|   ) | ||||
| }) | ||||
|  | ||||
| // delete old caches on activate | ||||
| self.addEventListener("activate", (event) => { | ||||
|   event.waitUntil( | ||||
|     (async () => { | ||||
|       const names = await caches.keys() | ||||
|       await Promise.all( | ||||
|         names.map((name) => { | ||||
|           if (name !== CACHE_NAME) { | ||||
|             return caches.delete(name) | ||||
|           } | ||||
|         }), | ||||
|       ) | ||||
|       await clients.claim() | ||||
|     })(), | ||||
|   ) | ||||
| }) | ||||
| @@ -41,6 +41,7 @@ func (s *Server) handler() http.Handler { | ||||
|  | ||||
| 	r.For("/", s.handleIndex) | ||||
| 	r.For("/manifest.json", s.handleManifest) | ||||
| 	r.For("/sw.js", s.handleServiceWorker) | ||||
| 	r.For("/static/*path", s.handleStatic) | ||||
| 	r.For("/api/status", s.handleStatus) | ||||
| 	r.For("/api/folders", s.handleFolderList) | ||||
| @@ -93,10 +94,24 @@ func (s *Server) handleManifest(c *router.Context) { | ||||
| 				"sizes": "64x64", | ||||
| 				"type":  "image/png", | ||||
| 			}, | ||||
| 			{ | ||||
| 				"src":   s.BasePath + "/static/graphicarts/favicon-144.png", | ||||
| 				"sizes": "144x144", | ||||
| 				"type":  "image/png", | ||||
| 			}, | ||||
| 			{ | ||||
| 				"src":   s.BasePath + "/static/graphicarts/favicon.svg", | ||||
| 				"sizes": "any", | ||||
| 				"type":  "image/svg", | ||||
| 			}, | ||||
| 		}, | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| func (s *Server) handleServiceWorker(c *router.Context) { | ||||
| 	http.ServeFile(c.Out, c.Req, "src/assets/javascripts/sw.js") | ||||
| } | ||||
|  | ||||
| func (s *Server) handleStatus(c *router.Context) { | ||||
| 	c.JSON(http.StatusOK, map[string]interface{}{ | ||||
| 		"running": s.worker.FeedsPending(), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user