mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-04 02:32:57 +00:00
fix please
This commit is contained in:
@@ -1920,6 +1920,69 @@ func (bc *BaseController) SetupInitialize(c *gin.Context) {
|
|||||||
host := c.Request.Host
|
host := c.Request.Host
|
||||||
if host != "" {
|
if host != "" {
|
||||||
baseURL := scheme + "://" + host + "/api/v1"
|
baseURL := scheme + "://" + host + "/api/v1"
|
||||||
|
// Best-effort: immediately write public settings cache from current Settings
|
||||||
|
go func(snap models.Settings) {
|
||||||
|
defer func() { _ = recover() }()
|
||||||
|
snap.LoadCustomNav()
|
||||||
|
var pubVids []string
|
||||||
|
if snap.VideosJSON != "" { _ = json.Unmarshal([]byte(snap.VideosJSON), &pubVids) }
|
||||||
|
var pubVidsItems any
|
||||||
|
if snap.VideosItemsJSON != "" { _ = json.Unmarshal([]byte(snap.VideosItemsJSON), &pubVidsItems) }
|
||||||
|
var pubMerchItems any
|
||||||
|
if snap.MerchItemsJSON != "" { _ = json.Unmarshal([]byte(snap.MerchItemsJSON), &pubMerchItems) }
|
||||||
|
resp := map[string]any{
|
||||||
|
"club_id": snap.ClubID,
|
||||||
|
"club_type": snap.ClubType,
|
||||||
|
"club_name": snap.ClubName,
|
||||||
|
"club_logo_url": snap.ClubLogoURL,
|
||||||
|
"club_url": snap.ClubURL,
|
||||||
|
"primary_color": snap.PrimaryColor,
|
||||||
|
"secondary_color": snap.SecondaryColor,
|
||||||
|
"accent_color": snap.AccentColor,
|
||||||
|
"background_color": snap.BackgroundColor,
|
||||||
|
"text_color": snap.TextColor,
|
||||||
|
"font_heading": snap.FontHeading,
|
||||||
|
"font_body": snap.FontBody,
|
||||||
|
"sponsors_layout": snap.SponsorsLayout,
|
||||||
|
"sponsors_theme": snap.SponsorsTheme,
|
||||||
|
"facebook_url": snap.FacebookURL,
|
||||||
|
"instagram_url": snap.InstagramURL,
|
||||||
|
"youtube_url": snap.YoutubeURL,
|
||||||
|
"gallery_url": snap.GalleryURL,
|
||||||
|
"gallery_label": snap.GalleryLabel,
|
||||||
|
"videos_module_enabled": snap.VideosModuleEnabled,
|
||||||
|
"videos_style": snap.VideosStyle,
|
||||||
|
"videos_source": snap.VideosSource,
|
||||||
|
"videos_limit": snap.VideosLimit,
|
||||||
|
"videos": pubVids,
|
||||||
|
"videos_items": pubVidsItems,
|
||||||
|
"merch_module_enabled": snap.MerchModuleEnabled,
|
||||||
|
"merch_style": snap.MerchStyle,
|
||||||
|
"merch_source": snap.MerchSource,
|
||||||
|
"merch_limit": snap.MerchLimit,
|
||||||
|
"merch_items": pubMerchItems,
|
||||||
|
"about_html": snap.AboutHTML,
|
||||||
|
"show_about_in_nav": snap.ShowAboutInNav,
|
||||||
|
"custom_nav": snap.CustomNav,
|
||||||
|
"contact_address": snap.ContactAddress,
|
||||||
|
"contact_city": snap.ContactCity,
|
||||||
|
"contact_zip": snap.ContactZip,
|
||||||
|
"contact_country": snap.ContactCountry,
|
||||||
|
"contact_phone": snap.ContactPhone,
|
||||||
|
"contact_email": snap.ContactEmail,
|
||||||
|
"location_latitude": snap.LocationLatitude,
|
||||||
|
"location_longitude": snap.LocationLongitude,
|
||||||
|
"map_zoom_level": snap.MapZoomLevel,
|
||||||
|
"map_style": snap.MapStyle,
|
||||||
|
"show_map_on_homepage": snap.ShowMapOnHomepage,
|
||||||
|
}
|
||||||
|
b, _ := json.MarshalIndent(resp, "", " ")
|
||||||
|
outPath := filepath.Join("cache", "prefetch", "settings.json")
|
||||||
|
_ = os.MkdirAll(filepath.Dir(outPath), 0o755)
|
||||||
|
tmp := outPath + ".tmp"
|
||||||
|
_ = os.WriteFile(tmp, b, 0o644)
|
||||||
|
_ = os.Rename(tmp, outPath)
|
||||||
|
}(s)
|
||||||
go services.PrefetchOnce(baseURL)
|
go services.PrefetchOnce(baseURL)
|
||||||
}
|
}
|
||||||
if strings.TrimSpace(s.YoutubeURL) != "" {
|
if strings.TrimSpace(s.YoutubeURL) != "" {
|
||||||
@@ -2181,6 +2244,70 @@ func (bc *BaseController) SetupInitialize(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
logger.Info("Initial settings saved: club_id=%s club_name=%s gallery_url=%s gallery_label=%s", s.ClubID, s.ClubName, s.GalleryURL, s.GalleryLabel)
|
logger.Info("Initial settings saved: club_id=%s club_name=%s gallery_url=%s gallery_label=%s", s.ClubID, s.ClubName, s.GalleryURL, s.GalleryLabel)
|
||||||
|
|
||||||
|
// Immediately write public settings cache from current Settings snapshot
|
||||||
|
func() {
|
||||||
|
defer func() { _ = recover() }()
|
||||||
|
s.LoadCustomNav()
|
||||||
|
var pubVids []string
|
||||||
|
if s.VideosJSON != "" { _ = json.Unmarshal([]byte(s.VideosJSON), &pubVids) }
|
||||||
|
var pubVidsItems any
|
||||||
|
if s.VideosItemsJSON != "" { _ = json.Unmarshal([]byte(s.VideosItemsJSON), &pubVidsItems) }
|
||||||
|
var pubMerchItems any
|
||||||
|
if s.MerchItemsJSON != "" { _ = json.Unmarshal([]byte(s.MerchItemsJSON), &pubMerchItems) }
|
||||||
|
resp := map[string]any{
|
||||||
|
"club_id": s.ClubID,
|
||||||
|
"club_type": s.ClubType,
|
||||||
|
"club_name": s.ClubName,
|
||||||
|
"club_logo_url": s.ClubLogoURL,
|
||||||
|
"club_url": s.ClubURL,
|
||||||
|
"primary_color": s.PrimaryColor,
|
||||||
|
"secondary_color": s.SecondaryColor,
|
||||||
|
"accent_color": s.AccentColor,
|
||||||
|
"background_color": s.BackgroundColor,
|
||||||
|
"text_color": s.TextColor,
|
||||||
|
"font_heading": s.FontHeading,
|
||||||
|
"font_body": s.FontBody,
|
||||||
|
"sponsors_layout": s.SponsorsLayout,
|
||||||
|
"sponsors_theme": s.SponsorsTheme,
|
||||||
|
"facebook_url": s.FacebookURL,
|
||||||
|
"instagram_url": s.InstagramURL,
|
||||||
|
"youtube_url": s.YoutubeURL,
|
||||||
|
"gallery_url": s.GalleryURL,
|
||||||
|
"gallery_label": s.GalleryLabel,
|
||||||
|
"videos_module_enabled": s.VideosModuleEnabled,
|
||||||
|
"videos_style": s.VideosStyle,
|
||||||
|
"videos_source": s.VideosSource,
|
||||||
|
"videos_limit": s.VideosLimit,
|
||||||
|
"videos": pubVids,
|
||||||
|
"videos_items": pubVidsItems,
|
||||||
|
"merch_module_enabled": s.MerchModuleEnabled,
|
||||||
|
"merch_style": s.MerchStyle,
|
||||||
|
"merch_source": s.MerchSource,
|
||||||
|
"merch_limit": s.MerchLimit,
|
||||||
|
"merch_items": pubMerchItems,
|
||||||
|
"about_html": s.AboutHTML,
|
||||||
|
"show_about_in_nav": s.ShowAboutInNav,
|
||||||
|
"custom_nav": s.CustomNav,
|
||||||
|
"contact_address": s.ContactAddress,
|
||||||
|
"contact_city": s.ContactCity,
|
||||||
|
"contact_zip": s.ContactZip,
|
||||||
|
"contact_country": s.ContactCountry,
|
||||||
|
"contact_phone": s.ContactPhone,
|
||||||
|
"contact_email": s.ContactEmail,
|
||||||
|
"location_latitude": s.LocationLatitude,
|
||||||
|
"location_longitude": s.LocationLongitude,
|
||||||
|
"map_zoom_level": s.MapZoomLevel,
|
||||||
|
"map_style": s.MapStyle,
|
||||||
|
"show_map_on_homepage": s.ShowMapOnHomepage,
|
||||||
|
}
|
||||||
|
b, _ := json.MarshalIndent(resp, "", " ")
|
||||||
|
outPath := filepath.Join("cache", "prefetch", "settings.json")
|
||||||
|
_ = os.MkdirAll(filepath.Dir(outPath), 0o755)
|
||||||
|
tmp := outPath + ".tmp"
|
||||||
|
_ = os.WriteFile(tmp, b, 0o644)
|
||||||
|
_ = os.Rename(tmp, outPath)
|
||||||
|
}()
|
||||||
|
|
||||||
// Seed default homepage page elements with all available sections
|
// Seed default homepage page elements with all available sections
|
||||||
bc.seedDefaultHomePageElements()
|
bc.seedDefaultHomePageElements()
|
||||||
logger.Info("Default homepage page elements seeded")
|
logger.Info("Default homepage page elements seeded")
|
||||||
|
|||||||
Reference in New Issue
Block a user