def render_slide(self, slide, slide_defaults=None): """ Returns the complete HTML element representing the given slide rendered without any outer capsule.""" if slide_defaults is None: slide_defaults = {} deep_update(slide_defaults, slide.get_content()) return self.slide_renderer.__getattr__(slide.get_template())( slide=slide_defaults, slide_b=slide, base="base.html")
def get_slide_defaults(cls, theme): """ Returns the default values of slide elements based on the given theme and its parents """ parent = cls[theme].get('parent') if parent: defaults = cls.get_slide_defaults(parent) deep_update(defaults, cls[theme].get('slide_defaults', {})) else: defaults = cls[theme].get('slide_defaults', {}) return deepcopy(defaults)
def GET(self, slide_id, channel): try: slide_id = int(slide_id) s = EditorSlide.get(slide_id) if s.contains_video: raise seeother(channel.id, '/capsules/%d' % s.capsule.id) plugin_s = s.to_plugin_slide() except ValueError: return "this is not a valid slide id" except SQLObjectNotFound: return "there is no slide with the id " + str( slide_id) + " in the channel " + str(channel.id) capsule = s.capsule.to_plugin_capsule() PluginManager.dereference_assets([capsule]) capsule_theme = capsule.get_theme() if capsule.get_theme( ) in Themes else self.app.config['default_theme'] content = Themes.get_slide_defaults(capsule_theme) deep_update(content, s.get_content()) vertical = channel.get_config_param('vertical') templates = self.slide_templates template = s.get_template() if vertical: templates = { 'template-image-bg': templates['template-image-bg'], 'template-background-text-center': self.slide_templates['template-background-text-center'] } default_template = channel.get_config_param('default_template') template = template if default_template in [ "template-image-bg", 'template-background-text-center' ] else 'template-background-text-center' return self.renderer.editor( capsule=s.capsule, channel=channel, slide=s, template=template, old_content=json.dumps(content), templates=templates, theme=capsule_theme, theme_palette=Themes[capsule_theme].get('ckeditor_palette'), themes=Themes.prepare_for_css_inclusion([capsule_theme]), theme_defaults=json.dumps( Themes.get_slide_defaults(capsule_theme)), vertical=channel.get_config_param('vertical'))
def GET(self, capsule_id, slide_id=None, template=None): capsule = EditorCapsule.get(capsule_id) theme = capsule.theme if capsule.theme in Themes else self.config[ 'default_theme'] if slide_id: slide = EditorSlide.get(slide_id) capsule = type('DummyCapsule', (PluginCapsule, object), { 'get_slides': lambda: [slide], 'get_theme': lambda: theme }) self.plugin_manager.dereference_assets([capsule]) content = slide.get_content() duration = slide.duration t = template if template else slide.get_template() slide = type( 'DummySlide', (PluginSlide, object), { 'get_duration': lambda: duration, 'get_content': lambda: content, 'get_template': lambda: t }) else: slide = type( 'DummySlide', (PluginSlide, object), { 'get_duration': lambda: 5000, 'get_content': lambda: {}, 'get_template': lambda: template }) if template: content = self.get_slide_defaults(slide) deep_update(content, Themes.get_slide_defaults(theme)) deep_update(content, slide.get_content()) slide.get_content = lambda: content return self.ictv_renderer.preview_slide(slide, theme, small_size=True)