From 172ef7986d2a2b3886d8301512ffa8ec11487ce1 Mon Sep 17 00:00:00 2001 From: Su Yang Date: Sat, 6 Jan 2024 12:02:10 +0800 Subject: [PATCH] chore: mv internal/state/fn => internal/fn --- {config/state => internal/fn}/favicon.go | 2 +- {config/state => internal/fn}/network.go | 2 +- {config/state => internal/fn}/url.go | 2 +- internal/pages/guide/guide.go | 3 ++- internal/pages/home/application.go | 6 +++--- internal/pages/home/bookmark.go | 8 ++++---- internal/pages/home/home.go | 7 ++++--- 7 files changed, 16 insertions(+), 14 deletions(-) rename {config/state => internal/fn}/favicon.go (95%) rename {config/state => internal/fn}/network.go (97%) rename {config/state => internal/fn}/url.go (98%) diff --git a/config/state/favicon.go b/internal/fn/favicon.go similarity index 95% rename from config/state/favicon.go rename to internal/fn/favicon.go index 3e4003f..503d6fc 100644 --- a/config/state/favicon.go +++ b/internal/fn/favicon.go @@ -1,4 +1,4 @@ -package FlareState +package FlareFn import ( "fmt" diff --git a/config/state/network.go b/internal/fn/network.go similarity index 97% rename from config/state/network.go rename to internal/fn/network.go index f71a75d..44fd5bd 100644 --- a/config/state/network.go +++ b/internal/fn/network.go @@ -1,4 +1,4 @@ -package FlareState +package FlareFn import ( "encoding/json" diff --git a/config/state/url.go b/internal/fn/url.go similarity index 98% rename from config/state/url.go rename to internal/fn/url.go index e29549a..eb7cdb7 100644 --- a/config/state/url.go +++ b/internal/fn/url.go @@ -1,4 +1,4 @@ -package FlareState +package FlareFn import ( "net/http" diff --git a/internal/pages/guide/guide.go b/internal/pages/guide/guide.go index a992cbd..9eea914 100644 --- a/internal/pages/guide/guide.go +++ b/internal/pages/guide/guide.go @@ -11,6 +11,7 @@ import ( "github.com/soulteary/memfs" FlareState "github.com/soulteary/flare/config/state" + FlareFn "github.com/soulteary/flare/internal/fn" ) var MemFs *memfs.FS @@ -45,7 +46,7 @@ func render(c *gin.Context) { func getUserHomePage() string { port := strconv.Itoa(FlareState.AppFlags.Port) - body, err := FlareState.GetHTML("http://localhost:" + port + "/") + body, err := FlareFn.GetHTML("http://localhost:" + port + "/") if err != nil { return "" } diff --git a/internal/pages/home/application.go b/internal/pages/home/application.go index 385f0f8..6b75af1 100644 --- a/internal/pages/home/application.go +++ b/internal/pages/home/application.go @@ -6,7 +6,7 @@ import ( FlareData "github.com/soulteary/flare/config/data" FlareModel "github.com/soulteary/flare/config/model" - FlareState "github.com/soulteary/flare/config/state" + FlareFn "github.com/soulteary/flare/internal/fn" FlareMDI "github.com/soulteary/flare/internal/resources/mdi" ) @@ -17,7 +17,7 @@ func GenerateApplicationsTemplate(filter string) template.HTML { var parseApps []FlareModel.Bookmark for _, app := range appsData.Items { - app.URL = FlareState.ParseDynamicUrl(app.URL) + app.URL = FlareFn.ParseDynamicUrl(app.URL) parseApps = append(parseApps, app) } @@ -63,7 +63,7 @@ func GenerateApplicationsTemplate(filter string) template.HTML { templateIcon = FlareMDI.GetIconByName(app.Icon) } else { if options.IconMode == "FILLING" { - templateIcon = FlareState.GetYandexFavicon(app.URL, FlareMDI.GetIconByName(app.Icon)) + templateIcon = FlareFn.GetYandexFavicon(app.URL, FlareMDI.GetIconByName(app.Icon)) } else { templateIcon = FlareMDI.GetIconByName(app.Icon) } diff --git a/internal/pages/home/bookmark.go b/internal/pages/home/bookmark.go index e16d400..3f370a1 100644 --- a/internal/pages/home/bookmark.go +++ b/internal/pages/home/bookmark.go @@ -6,7 +6,7 @@ import ( FlareData "github.com/soulteary/flare/config/data" FlareModel "github.com/soulteary/flare/config/model" - FlareState "github.com/soulteary/flare/config/state" + FlareFn "github.com/soulteary/flare/internal/fn" FlareMDI "github.com/soulteary/flare/internal/resources/mdi" ) @@ -17,7 +17,7 @@ func GenerateBookmarkTemplate(filter string) template.HTML { var parseBookmarks []FlareModel.Bookmark for _, bookmark := range bookmarksData.Items { - bookmark.URL = FlareState.ParseDynamicUrl(bookmark.URL) + bookmark.URL = FlareFn.ParseDynamicUrl(bookmark.URL) parseBookmarks = append(parseBookmarks, bookmark) } @@ -72,7 +72,7 @@ func renderBookmarksWithoutCategories(bookmarks *[]FlareModel.Bookmark, OpenBook templateIcon = FlareMDI.GetIconByName(bookmark.Icon) } else { if IconMode == "FILLING" { - templateIcon = FlareState.GetYandexFavicon(bookmark.URL, FlareMDI.GetIconByName(bookmark.Icon)) + templateIcon = FlareFn.GetYandexFavicon(bookmark.URL, FlareMDI.GetIconByName(bookmark.Icon)) } else { templateIcon = FlareMDI.GetIconByName(bookmark.Icon) } @@ -113,7 +113,7 @@ func renderBookmarksWithCategories(bookmarks *[]FlareModel.Bookmark, category *F templateIcon = FlareMDI.GetIconByName(bookmark.Icon) } else { if IconMode == "FILLING" { - templateIcon = FlareState.GetYandexFavicon(bookmark.URL, FlareMDI.GetIconByName(bookmark.Icon)) + templateIcon = FlareFn.GetYandexFavicon(bookmark.URL, FlareMDI.GetIconByName(bookmark.Icon)) } else { templateIcon = FlareMDI.GetIconByName(bookmark.Icon) } diff --git a/internal/pages/home/home.go b/internal/pages/home/home.go index 7dacd8a..10f5ff4 100644 --- a/internal/pages/home/home.go +++ b/internal/pages/home/home.go @@ -14,6 +14,7 @@ import ( FlareModel "github.com/soulteary/flare/config/model" FlareState "github.com/soulteary/flare/config/state" FlareAuth "github.com/soulteary/flare/internal/auth" + FlareFn "github.com/soulteary/flare/internal/fn" FlareWeather "github.com/soulteary/flare/internal/settings/weather" weather "github.com/soulteary/funny-china-weather" ) @@ -226,7 +227,7 @@ func getGreeting(greeting string) string { func pageBookmark(c *gin.Context) { options := FlareData.GetAllSettingsOptions() - FlareState.ParseRequestURL(c.Request) + FlareFn.ParseRequestURL(c.Request) c.HTML( http.StatusOK, @@ -258,7 +259,7 @@ func pageBookmark(c *gin.Context) { func pageApplication(c *gin.Context) { options := FlareData.GetAllSettingsOptions() - FlareState.ParseRequestURL(c.Request) + FlareFn.ParseRequestURL(c.Request) c.HTML( http.StatusOK, @@ -289,7 +290,7 @@ func pageApplication(c *gin.Context) { func render(c *gin.Context, filter string) { options := FlareData.GetAllSettingsOptions() - FlareState.ParseRequestURL(c.Request) + FlareFn.ParseRequestURL(c.Request) hasKeyword := false searchKeyword := " "