@@ -41,9 +41,8 @@ func replaceStrings(content string, replacements map[string]string) string {
4141 return content
4242}
4343
44- func initIndex () {
44+ func initIndex (siteConfig SiteConfig ) {
4545 utils .Log .Debug ("Initializing index.html..." )
46- siteConfig := getSiteConfig ()
4746 // dist_dir is empty and cdn is not empty add web_version is empty or beta or dev
4847 if conf .Conf .DistDir == "" && conf .Conf .Cdn != "" && (conf .WebVersion == "" || conf .WebVersion == "beta" || conf .WebVersion == "dev" ) {
4948 utils .Log .Infof ("Fetching index.html from CDN: %s/index.html..." , conf .Conf .Cdn )
@@ -89,13 +88,15 @@ func initIndex() {
8988func UpdateIndex () {
9089 utils .Log .Debug ("Updating index.html with settings..." )
9190 favicon := setting .GetStr (conf .Favicon )
91+ logo := strings .Split (setting .GetStr (conf .Logo ), "\n " )[0 ]
9292 title := setting .GetStr (conf .SiteTitle )
9393 customizeHead := setting .GetStr (conf .CustomizeHead )
9494 customizeBody := setting .GetStr (conf .CustomizeBody )
9595 mainColor := setting .GetStr (conf .MainColor )
9696 utils .Log .Debug ("Applying replacements for default pages..." )
9797 replaceMap1 := map [string ]string {
9898 "https://cdn.oplist.org/gh/OpenListTeam/Logo@main/logo.svg" : favicon ,
99+ "https://cdn.oplist.org/gh/OpenListTeam/Logo@main/logo.png" : logo ,
99100 "Loading..." : title ,
100101 "main_color: undefined" : fmt .Sprintf ("main_color: '%s'" , mainColor ),
101102 }
@@ -111,8 +112,9 @@ func UpdateIndex() {
111112
112113func Static (r * gin.RouterGroup , noRoute func (handlers ... gin.HandlerFunc )) {
113114 utils .Log .Debug ("Setting up static routes..." )
115+ siteConfig := getSiteConfig ()
114116 initStatic ()
115- initIndex ()
117+ initIndex (siteConfig )
116118 folders := []string {"assets" , "images" , "streamer" , "static" }
117119 if conf .Conf .Cdn == "" {
118120 utils .Log .Debug ("Setting up static file serving..." )
@@ -136,7 +138,7 @@ func Static(r *gin.RouterGroup, noRoute func(handlers ...gin.HandlerFunc)) {
136138 for _ , folder := range folders {
137139 r .GET (fmt .Sprintf ("/%s/*filepath" , folder ), func (c * gin.Context ) {
138140 filepath := c .Param ("filepath" )
139- c .Redirect (http .StatusFound , fmt .Sprintf ("%s/%s%s" , conf . Conf .Cdn , folder , filepath ))
141+ c .Redirect (http .StatusFound , fmt .Sprintf ("%s/%s%s" , siteConfig .Cdn , folder , filepath ))
140142 })
141143 }
142144 }
0 commit comments