@@ -417,8 +417,10 @@ def renderWrapper(self, site, path, inner_path, title, extra_headers, show_loadi
417417 if site .content_manager .contents .get ("content.json" ): # Got content.json
418418 content = site .content_manager .contents ["content.json" ]
419419 if content .get ("background-color" ):
420- body_style += "background-color: %s;" % \
421- cgi .escape (site .content_manager .contents ["content.json" ]["background-color" ], True )
420+ user = self .getCurrentUser ()
421+ theme = user .settings .get ("theme" , "light" )
422+ background_color = content .get ("background-color-%s" % theme , content ["background-color" ])
423+ body_style += "background-color: %s;" % cgi .escape (background_color , True )
422424 if content .get ("viewport" ):
423425 meta_tags += '<meta name="viewport" id="viewport" content="%s">' % cgi .escape (content ["viewport" ], True )
424426 if content .get ("favicon" ):
@@ -434,6 +436,9 @@ def renderWrapper(self, site, path, inner_path, title, extra_headers, show_loadi
434436 if show_loadingscreen is None :
435437 show_loadingscreen = not site .storage .isFile (file_inner_path )
436438
439+ user = self .getCurrentUser ()
440+ themeclass = "theme-%-6s" % re .sub ("[^a-z]" , "" , user .settings .get ("theme" , "light" ))
441+
437442 return self .render (
438443 "src/Ui/template/wrapper.html" ,
439444 server_url = server_url ,
@@ -454,7 +459,8 @@ def renderWrapper(self, site, path, inner_path, title, extra_headers, show_loadi
454459 sandbox_permissions = sandbox_permissions ,
455460 rev = config .rev ,
456461 lang = config .language ,
457- homepage = homepage
462+ homepage = homepage ,
463+ themeclass = themeclass
458464 )
459465
460466 # Create a new wrapper nonce that allows to get one html file without the wrapper
@@ -605,6 +611,12 @@ def actionFile(self, file_path, block_size=64 * 1024, send_header=True, header_l
605611
606612 range = self .env .get ("HTTP_RANGE" )
607613 range_start = None
614+
615+ is_html_file = file_path .endswith (".html" )
616+ if is_html_file :
617+ user = self .getCurrentUser ()
618+ themeclass = "theme-%-6s" % re .sub ("[^a-z]" , "" , user .settings .get ("theme" , "light" ))
619+
608620 if send_header :
609621 extra_headers = {}
610622 extra_headers ["Accept-Ranges" ] = "bytes"
@@ -632,6 +644,8 @@ def actionFile(self, file_path, block_size=64 * 1024, send_header=True, header_l
632644 while 1 :
633645 try :
634646 block = file_obj .read (block_size )
647+ if is_html_file :
648+ block = block .replace ("{themeclass}" , themeclass .encode ("utf8" ))
635649 if block :
636650 yield block
637651 else :
0 commit comments