From 6d934f7dc6796c151f20c2118559d3ef9e3fc22d Mon Sep 17 00:00:00 2001 From: rma945 <6511900+rma945@users.noreply.github.com> Date: Mon, 13 Oct 2025 15:30:40 +0700 Subject: [PATCH 1/3] feat: move views templates into web folder --- {views => web/views}/bottom.go.html | 0 {views => web/views}/head.go.html | 0 {views => web/views}/jslinks.go.html | 0 {views => web/views}/main.go.html | 0 {views => web/views}/metrica.go.html | 0 {views => web/views}/modal.go.html | 0 {views => web/views}/toast.go.html | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename {views => web/views}/bottom.go.html (100%) rename {views => web/views}/head.go.html (100%) rename {views => web/views}/jslinks.go.html (100%) rename {views => web/views}/main.go.html (100%) rename {views => web/views}/metrica.go.html (100%) rename {views => web/views}/modal.go.html (100%) rename {views => web/views}/toast.go.html (100%) diff --git a/views/bottom.go.html b/web/views/bottom.go.html similarity index 100% rename from views/bottom.go.html rename to web/views/bottom.go.html diff --git a/views/head.go.html b/web/views/head.go.html similarity index 100% rename from views/head.go.html rename to web/views/head.go.html diff --git a/views/jslinks.go.html b/web/views/jslinks.go.html similarity index 100% rename from views/jslinks.go.html rename to web/views/jslinks.go.html diff --git a/views/main.go.html b/web/views/main.go.html similarity index 100% rename from views/main.go.html rename to web/views/main.go.html diff --git a/views/metrica.go.html b/web/views/metrica.go.html similarity index 100% rename from views/metrica.go.html rename to web/views/metrica.go.html diff --git a/views/modal.go.html b/web/views/modal.go.html similarity index 100% rename from views/modal.go.html rename to web/views/modal.go.html diff --git a/views/toast.go.html b/web/views/toast.go.html similarity index 100% rename from views/toast.go.html rename to web/views/toast.go.html From 4b0b063b58b8904db94fdf7a9409a205517a834e Mon Sep 17 00:00:00 2001 From: rma945 <6511900+rma945@users.noreply.github.com> Date: Mon, 13 Oct 2025 15:32:10 +0700 Subject: [PATCH 2/3] feat: move views/*.go.html from fs to embed --- web/server.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/web/server.go b/web/server.go index 765f861..81e0d32 100644 --- a/web/server.go +++ b/web/server.go @@ -1,10 +1,9 @@ package web import ( - "github.com/gin-contrib/cors" - "github.com/gin-gonic/gin" + "embed" + "html/template" "log" - "path/filepath" "strings" ss "sync" "time" @@ -12,8 +11,14 @@ import ( "torrsru/global" "torrsru/web/api" "torrsru/web/static" + + "github.com/gin-contrib/cors" + "github.com/gin-gonic/gin" ) +//go:embed views/*.go.html +var viewFS embed.FS + func Start(port string) { go db.StartSync() @@ -27,7 +32,10 @@ func Start(port string) { global.Route = gin.New() global.Route.Use(gin.Recovery(), cors.New(corsCfg), blockUsers()) static.RouteStaticFiles(global.Route) - global.Route.LoadHTMLGlob(filepath.Join(global.PWD, "views/*.go.html")) + + tmpl := template.Must(template.ParseFS(viewFS, "views/*.go.html")) + global.Route.SetHTMLTemplate(tmpl) + api.SetRoutes(global.Route) err := global.Route.Run(":" + port) From b5e67164dfcdc3289685d687ad2b2aaa5ace54a8 Mon Sep 17 00:00:00 2001 From: rma945 <6511900+rma945@users.noreply.github.com> Date: Mon, 13 Oct 2025 15:33:35 +0700 Subject: [PATCH 3/3] feat: update readme.md - remove information about views folder for builded dist --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e85c10c..52cdd66 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ ## Подготовка к запуску -Скопируйте собранный файл `./dist/torrs` в директорию от куда будет запускаться программа. Далее нужно переписать папку views в тот же каталог. +Скопируйте собранный файл `./dist/torrs` в директорию от куда будет запускаться программа. ### Запуск