def init_resource(self, **kw): # Init resource BaseTheme.init_resource(self, **kw) # Get language website = self.parent language = website.get_default_language() # Banner (background set with CSS) path = get_abspath("data/k2-banner-ties.jpg") image = ro_database.get_handler(path, FileHandler) self.make_resource( "banner-itws", Image, body=image.to_str(), extension="jpg", filename="banner-itws.jpg", format="image/jpeg", state="public", ) # Set banner title vhosts = website.get_property("vhosts") if vhosts: banner_title = vhosts[0] else: banner_title = website.get_title() self.set_property("banner_title", banner_title, language=language) # CSS file # TODO Add an API in ikaaro that allow to easily change CSS... path = get_abspath("ui/themes/style.css") body = open(path).read() style = self.get_resource("style") style.handler.load_state_from_string(body) style.handler.set_changed() # Custom 404 self.make_resource("404", NotFoundPage) # Add footer self.make_resource("footer", FooterFolder) menu = self.get_resource("footer/menu") title = Property(MSG(u"Powered by itws").gettext(), language=language) menu.add_new_record({"title": title, "path": "/about-itws"}) title = Property(MSG(u"Contact us").gettext(), language=language) menu.add_new_record({"title": title, "path": "/;contact"}) # Turning footer self.make_resource("turning-footer", TurningFooterFolder)
def init_resource(self, **kw): # Init resource BaseTheme.init_resource(self, **kw) # Get language website = self.parent language = website.get_default_language() # Banner (background set with CSS) path = get_abspath('data/k2-banner-ties.jpg') image = ro_database.get_handler(path, FileHandler) self.make_resource('banner-itws', Image, body=image.to_str(), extension='jpg', filename='banner-itws.jpg', format='image/jpeg', state='public') # Set banner title vhosts = website.get_property('vhosts') if vhosts: banner_title = vhosts[0] else: banner_title = website.get_title() self.set_property('banner_title', banner_title, language=language) # Drop logo property since itws uses banner_path property self.del_property('logo') # CSS file # TODO Add an API in ikaaro that allow to easily change CSS... path = get_abspath('ui/themes/style.css') body = open(path).read() style = self.get_resource('style') style.handler.load_state_from_string(body) style.handler.set_changed() # Custom 404 self.make_resource('404', NotFoundPage) # Add footer self.make_resource('footer', FooterFolder) menu = self.get_resource('footer/menu') title = Property(MSG(u'Powered by itws').gettext(), language=language) menu.add_new_record({'title': title, 'path': '/about-itws'}) title = Property(MSG(u'Contact us').gettext(), language=language) menu.add_new_record({'title': title, 'path': '/;contact'}) # Turning footer self.make_resource('turning-footer', TurningFooterFolder)