def _copy_customization_files(self, used_assets): css_files = {url for url in used_assets if re.match('static/custom/.*\.css$', url)} for file_path in css_files: with open(os.path.join(config.CUSTOMIZATION_DIR, self._strip_custom_prefix(file_path))) as f: rewritten_css, used_urls, __ = rewrite_css_urls(self.event, f.read()) used_assets |= used_urls self._zip_file.writestr(os.path.join(self._content_dir, file_path), rewritten_css) for file_path in used_assets - css_files: if not file_path.startswith('static/custom/'): continue self._copy_file(os.path.join(self._content_dir, file_path), os.path.join(config.CUSTOMIZATION_DIR, self._strip_custom_prefix(file_path)))
def _copy_customization_files(self, used_assets): css_files = {url for url in used_assets if re.match(r'static/custom/.*\.css$', url)} for file_path in css_files: with open(os.path.join(config.CUSTOMIZATION_DIR, self._strip_custom_prefix(file_path))) as f: rewritten_css, used_urls, __ = rewrite_css_urls(self.event, f.read()) used_assets |= used_urls self._zip_file.writestr(os.path.join(self._content_dir, file_path), rewritten_css) for file_path in used_assets - css_files: if not file_path.startswith('static/custom/'): continue self._copy_file(os.path.join(self._content_dir, file_path), os.path.join(config.CUSTOMIZATION_DIR, self._strip_custom_prefix(file_path)))
def _create_home(self): if self.event.has_stylesheet: css, used_urls, used_images = rewrite_css_urls(self.event, self.event.stylesheet) g.used_url_for_assets |= used_urls self._zip_file.writestr(os.path.join(self._content_dir, 'custom.css'), css) for image_file in used_images: with image_file.open() as f: self._zip_file.writestr(os.path.join(self._content_dir, f'images/{image_file.id}-{image_file.filename}'), f.read()) if self.event.has_logo: self._zip_file.writestr(os.path.join(self._content_dir, 'logo.png'), self.event.logo) return WPStaticConferenceDisplay(self._rh, self.event).display()
def _create_home(self): if self.event.has_stylesheet: css, used_urls, used_images = rewrite_css_urls(self.event, self.event.stylesheet) g.used_url_for_assets |= used_urls self._zip_file.writestr(os.path.join(self._content_dir, 'custom.css'), css) for image_file in used_images: with image_file.open() as f: self._zip_file.writestr(os.path.join(self._content_dir, 'images/{}-{}'.format(image_file.id, image_file.filename)), f.read()) if self.event.has_logo: self._zip_file.writestr(os.path.join(self._content_dir, 'logo.png'), self.event.logo) return WPStaticConferenceDisplay(self._rh, self.event).display()
def _copy_static_files(self, used_assets): # add favicon used_assets.add('static/images/indico.ico') # assets css_files = {url for url in used_assets if re.match(r'static/dist/.*\.css$', url)} for file_path in css_files: with open(os.path.join(self._web_dir, file_path)) as f: rewritten_css, used_urls, __ = rewrite_css_urls(self.event, f.read()) used_assets |= used_urls self._zip_file.writestr(os.path.join(self._content_dir, file_path), rewritten_css) for file_path in used_assets - css_files: if not re.match('^static/(images|fonts|dist)/(?!js/ckeditor/)', file_path): continue self._copy_file(os.path.join(self._content_dir, file_path), os.path.join(self._web_dir, file_path))
def _copy_static_files(self, used_assets): # add favicon used_assets.add('static/images/indico.ico') # assets css_files = {url for url in used_assets if re.match('static/dist/.*\.css$', url)} for file_path in css_files: with open(os.path.join(self._web_dir, file_path)) as f: rewritten_css, used_urls, __ = rewrite_css_urls(self.event, f.read()) used_assets |= used_urls self._zip_file.writestr(os.path.join(self._content_dir, file_path), rewritten_css) for file_path in used_assets - css_files: if not re.match('^static/(images|fonts|dist)/(?!js/ckeditor/)', file_path): continue self._copy_file(os.path.join(self._content_dir, file_path), os.path.join(self._web_dir, file_path))
def _copy_plugin_files(self, used_assets): css_files = {url for url in used_assets if re.match(r'static/plugins/.*\.css$', url)} for file_path in css_files: plugin_name, path = re.match(r'static/plugins/([^/]+)/(.+.css)', file_path).groups() plugin = plugin_engine.get_plugin(plugin_name) with open(os.path.join(plugin.root_path, 'static', path)) as f: rewritten_css, used_urls, __ = rewrite_css_urls(self.event, f.read()) used_assets |= used_urls self._zip_file.writestr(os.path.join(self._content_dir, file_path), rewritten_css) for file_path in used_assets - css_files: match = re.match(r'static/plugins/([^/]+)/(.+)', file_path) if not match: continue plugin_name, path = match.groups() plugin = plugin_engine.get_plugin(plugin_name) self._copy_file(os.path.join(self._content_dir, file_path), os.path.join(plugin.root_path, 'static', path))
def _copy_plugin_files(self, used_assets): css_files = {url for url in used_assets if re.match('static/plugins/.*\.css$', url)} for file_path in css_files: plugin_name, path = re.match(r'static/plugins/([^/]+)/(.+.css)', file_path).groups() plugin = plugin_engine.get_plugin(plugin_name) with open(os.path.join(plugin.root_path, 'static', path)) as f: rewritten_css, used_urls, __ = rewrite_css_urls(self.event, f.read()) used_assets |= used_urls self._zip_file.writestr(os.path.join(self._content_dir, file_path), rewritten_css) for file_path in used_assets - css_files: match = re.match(r'static/plugins/([^/]+)/(.+)', file_path) if not match: continue plugin_name, path = match.groups() plugin = plugin_engine.get_plugin(plugin_name) self._copy_file(os.path.join(self._content_dir, file_path), os.path.join(plugin.root_path, 'static', path))