add a bunch of frontend stuff
This commit is contained in:
		
							parent
							
								
									2586161abd
								
							
						
					
					
						commit
						bc85b7c340
					
				
					 30 changed files with 1459 additions and 136 deletions
				
			
		
							
								
								
									
										1
									
								
								web/frontend/.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								web/frontend/.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1 @@ | |||
| assets | ||||
|  | @ -1,13 +1,13 @@ | |||
| <!DOCTYPE html> | ||||
| <!doctype html> | ||||
| <html lang="en"> | ||||
| <head> | ||||
|     <meta charset="UTF-8"> | ||||
|     <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||||
|     <title>{{.Config.Name}}</title> | ||||
| 	<head> | ||||
| 		<meta charset="UTF-8" /> | ||||
| 		<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||||
| 		<title>{{.Config.Name}}</title> | ||||
| 
 | ||||
|     {{.Vue.RenderTags}} | ||||
| </head> | ||||
| <body> | ||||
|     <div id="app"></div> | ||||
| </body> | ||||
| 		{{.Vue.RenderTags}} | ||||
| 	</head> | ||||
| 	<body> | ||||
| 		<div id="app"></div> | ||||
| 	</body> | ||||
| </html> | ||||
|  |  | |||
|  | @ -1,22 +1,26 @@ | |||
| package frontend | ||||
| 
 | ||||
| import ( | ||||
| 	"embed" | ||||
| 	"html/template" | ||||
| 	"net/http" | ||||
| 	"os" | ||||
| 	"path/filepath" | ||||
| 
 | ||||
| 	"git.sleepycat.moe/sam/mercury/frontend" | ||||
| 	"git.sleepycat.moe/sam/mercury/internal/database" | ||||
| 	"git.sleepycat.moe/sam/mercury/web/app" | ||||
| 	"github.com/go-chi/chi/v5" | ||||
| 	"github.com/rs/zerolog/log" | ||||
| 	vueglue "github.com/torenware/vite-go" | ||||
| 
 | ||||
| 	_ "embed" | ||||
| ) | ||||
| 
 | ||||
| //go:embed app.html | ||||
| var htmlTemplate string | ||||
| 
 | ||||
| //go:embed assets | ||||
| var assets embed.FS | ||||
| 
 | ||||
| type Frontend struct { | ||||
| 	*app.App | ||||
| 	glue       *vueglue.VueGlue | ||||
|  | @ -94,3 +98,14 @@ func (app *Frontend) ServeFrontend(w http.ResponseWriter, r *http.Request) { | |||
| 		log.Err(err).Msg("executing frontend template") | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func (app *Frontend) ServeStaticAssets(w http.ResponseWriter, r *http.Request) { | ||||
| 	if app.Config.Core.Dev { | ||||
| 		// TODO: this is unsafe | ||||
| 		path := filepath.Join("web/frontend/assets/", chi.URLParam(r, "*")) | ||||
| 		http.ServeFile(w, r, path) | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	_ = assets | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue