def html_editor_settings(blog): try: html_editor_settings = Template.get( Template.blog == blog, Template.title == 'HTML Editor Init', Template.template_type == template_type.system).body except Template.DoesNotExist: from core.static import html_editor_settings return html_editor_settings
def blog_new_page(blog_id): ''' Displays UI for newly created (unsaved) page ''' user = auth.is_logged_in(request) blog = Blog.load(blog_id) permission = auth.is_blog_member(user, blog) tags = template_tags(blog=blog, user=user) tags.page = Page() referer = request.headers.get('Referer') if referer is None: referer = BASE_URL + "/blog/" + str(blog.id) blog_new_page = tags.page for n in new_page_submission_fields: blog_new_page.__setattr__(n, "") if n in request.query: blog_new_page.__setattr__(n, request.query.getunicode(n)) import datetime blog_new_page.blog = blog blog_new_page.user = user blog_new_page.publication_date = datetime.datetime.utcnow() blog_new_page.basename = '' from core.cms import save_action_list from core.ui import kv kv_ui_data = kv.ui(blog_new_page.kv_list()) try: html_editor_settings = Template.get( Template.blog == blog, Template.title == 'HTML Editor Init', Template.template_type == template_type.system).body except Template.DoesNotExist: from core.static import html_editor_settings return template( 'edit/page', menu=generate_menu('create_page', blog), parent_path=referer, # search_context=(search_context['blog'], blog), html_editor_settings=html_editor_settings, sidebar=sidebar.render_sidebar(panel_set='edit_page', status_badge=status_badge, save_action=save_action, save_action_list=save_action_list, kv_ui=kv_ui_data, kv_object='Page', kv_objectid=None, **tags.__dict__), **tags.__dict__)
def html_editor_settings(blog): try: html_editor_settings = Template.get( Template.blog == blog, Template.title == 'HTML Editor Init', Template.template_type == template_type.system ).body except Template.DoesNotExist: from core.static import html_editor_settings return html_editor_settings
def page_add_media_with_template(page_id, media_id, template_id): user = auth.is_logged_in(request) page = Page.load(page_id) permission = auth.is_page_editor(user, page) media = Media.load(media_id, page.blog) media_template = Template.get(Template.id == template_id) from core.template import tpl generated_template = tpl(media_template.body, blog=page.blog, media=media) if media not in page.media: media.associate(page) return generated_template
def page_add_media_with_template(page_id, media_id, template_id): user = auth.is_logged_in(request) page = Page.load(page_id) permission = auth.is_page_editor(user, page) media = Media.load(media_id, page.blog) media_template = Template.get( Template.id == template_id) from core.template import tpl generated_template = tpl(media_template.body, blog=page.blog, media=media) if media not in page.media: media.associate(page) return generated_template
def blog_editor_css(blog_id): ''' Route for a copy of the blog's editor CSS; this allows it to be cached browser-side ''' blog = Blog.load(blog_id) from core.models import Template, template_type try: editor_css_template = Template.get( Template.blog == blog, Template.title == 'HTML Editor CSS', Template.template_type == template_type.system) except: from core import static template = static.editor_css else: template = editor_css_template.body response.content_type = "text/css" response.add_header('Cache-Control', 'max-age=7200') return template
def blog_editor_css(blog_id): ''' Route for a copy of the blog's editor CSS; this allows it to be cached browser-side ''' blog = Blog.load(blog_id) from core.models import Template, template_type try: editor_css_template = Template.get( Template.blog == blog, Template.title == 'HTML Editor CSS', Template.template_type == template_type.system) except: from core import static template = static.editor_css else: template = editor_css_template.body response.content_type = "text/css" response.add_header('Cache-Control', 'max-age=7200') return template
def _include(self, env, _name=None, **kwargs): from core.models import Template template_to_import = Template.get(Template.title == _name) tpl = MetalTemplate(template_to_import.body) self.includes.append(_name) return tpl.execute(env['_stdout'], env)
def blog_new_page(blog_id): ''' Displays UI for newly created (unsaved) page ''' user = auth.is_logged_in(request) blog = Blog.load(blog_id) permission = auth.is_blog_member(user, blog) tags = template_tags( blog=blog, user=user) tags.page = Page() referer = request.headers.get('Referer') if referer is None: referer = BASE_URL + "/blog/" + str(blog.id) blog_new_page = tags.page for n in new_page_submission_fields: blog_new_page.__setattr__(n, "") if n in request.query: blog_new_page.__setattr__(n, request.query.getunicode(n)) import datetime blog_new_page.blog = blog blog_new_page.user = user blog_new_page.publication_date = datetime.datetime.utcnow() blog_new_page.basename = '' from core.cms import save_action_list from core.ui import kv kv_ui_data = kv.ui(blog_new_page.kv_list()) try: html_editor_settings = Template.get( Template.blog == blog, Template.title == 'HTML Editor Init', Template.template_type == template_type.system ).body except Template.DoesNotExist: from core.static import html_editor_settings return template('edit/page', menu=generate_menu('create_page', blog), parent_path=referer, # search_context=(search_context['blog'], blog), html_editor_settings=html_editor_settings, sidebar=sidebar.render_sidebar( panel_set='edit_page', status_badge=status_badge, save_action=save_action, save_action_list=save_action_list, kv_ui=kv_ui_data, kv_object='Page', kv_objectid=None, **tags.__dict__), **tags.__dict__)