def get_css(self): """Fetches and returns stylesheet file path or contents, for both print and screen contexts, depending if we want a standalone presentation or not """ css = {} print_css = os.path.join(self.theme_dir, 'css', 'print.css') if not os.path.exists(print_css): # Fall back to default theme print_css = os.path.join(THEMES_DIR, 'default', 'css', 'print.css') if not os.path.exists(print_css): raise IOError(u"Cannot find css/print.css in default theme") css['print'] = {'path_url': utils.get_abs_path_url(print_css), 'contents': open(print_css).read()} screen_css = os.path.join(self.theme_dir, 'css', 'screen.css') if (os.path.exists(screen_css)): css['screen'] = {'path_url': utils.get_abs_path_url(screen_css), 'contents': open(screen_css).read()} else: self.log(u"No screen stylesheet provided in current theme", 'warning') return css
def get_js(self): """Fetches and returns javascript fiel path or contents, depending if we want a standalone presentation or not """ js_file = os.path.join(self.theme_dir, "js", "slides.js") if os.path.exists(js_file): return {"path_url": utils.get_abs_path_url(js_file), "contents": open(js_file).read()} else: self.log(u"No javascript provided in current theme", "warning")
def get_js(self): """Fetches and returns javascript fiel path or contents, depending if we want a standalone presentation or not """ js_file = os.path.join(self.theme_dir, 'js', 'slides.js') if (os.path.exists(js_file)): return {'path_url': utils.get_abs_path_url(js_file), 'contents': open(js_file).read()} else: self.log(u"No javascript provided in current theme", 'warning')
def get_css(self): """Fetches and returns stylesheet file path or contents, for both print and screen contexts, depending if we want a standalone presentation or not """ css = {} print_css = os.path.join(self.theme_dir, "css", "print.css") if os.path.exists(print_css): css["print"] = {"path_url": utils.get_abs_path_url(print_css), "contents": open(print_css).read()} else: self.log(u"No print stylesheet provided in current theme", "warning") screen_css = os.path.join(self.theme_dir, "css", "screen.css") if os.path.exists(screen_css): css["screen"] = {"path_url": utils.get_abs_path_url(screen_css), "contents": open(screen_css).read()} else: self.log(u"No screen stylesheet provided in current theme", "warning") return css
def get_js(self): """Fetches and returns javascript file path or contents, depending if we want a standalone presentation or not """ js_file = os.path.join(self.theme_dir, 'js', 'slides.js') if not os.path.exists(js_file): js_file = os.path.join(THEMES_DIR, 'default', 'js', 'slides.js') if not os.path.exists(js_file): raise IOError(u"Cannot find slides.js in default theme") return {'path_url': utils.get_abs_path_url(js_file), 'contents': open(js_file).read()}
def process(self, content, source=None): classes = [] if self.embed: return content, classes base_url = os.path.split(utils.get_abs_path_url(source))[0] fn = lambda p: r'<img src="%s" />' % os.path.join(base_url, p.group(1)) sub_regex = r'<img.*?src="(?!http://)(.*?)".*/?>' content = re.sub(sub_regex, fn, content, re.UNICODE) return content, classes
def get_css(self): """Fetches and returns stylesheet file path or contents, for both print and screen contexts, depending if we want a standalone presentation or not """ css = {} print_css = os.path.join(self.theme_dir, 'css', 'print.css') if (os.path.exists(print_css)): css['print'] = {'path_url': utils.get_abs_path_url(print_css), 'contents': open(print_css).read()} else: self.log(u"No print stylesheet provided in current theme", 'warning') screen_css = os.path.join(self.theme_dir, 'css', 'screen.css') if (os.path.exists(screen_css)): css['screen'] = {'path_url': utils.get_abs_path_url(screen_css), 'contents': open(screen_css).read()} else: self.log(u"No screen stylesheet provided in current theme", 'warning') return css