Beispiel #1
0
def get_form(section, title, body):
    f = form(section, section.full_path)
    f.add_control(control(section, 'text', 'title', title, 'Title', 60))
    f.add_control(
        textareacontrol(section, 'body', body, 'Body', 100, 10, html=True))
    f.add_control(control(section, 'submit', 'submit'))
    return unicode(f)
Beispiel #2
0
 def action_edit(self):
     if self.section.handler.request.get('submit'):
         self.SITE_HEADER = self.section.handler.request.get('SITE_HEADER')
         self.SITE_SUB_HEADER = self.section.handler.request.get('SITE_SUB_HEADER')
         self.DEFAULT_THEME = self.section.handler.request.get('DEFAULT_THEME')
         self.GOOGLE_ANALYTICS_UA = self.section.handler.request.get('GOOGLE_ANALYTICS_UA')
         self.ROBOTS_TXT = self.section.handler.request.get('ROBOTS_TXT')
         if self.section.handler.request.get('FAVICON_ICO'):
             data = db.Blob(self.section.handler.request.get('FAVICON_ICO'))
             if self.FAVICON_ICO:
                 self.FAVICON_ICO.data = data
             else:
                 self.FAVICON_ICO = File(filename='favicon.ico', content_type='image/x-icon', data=data)
             self.FAVICON_ICO.put()
         self.ENABLE_THEME_PREVIEW = self.section.handler.request.get('ENABLE_THEME_PREVIEW') != ''
         self.DEBUG_MODE = self.section.handler.request.get('DEBUG_MODE') != ''
         cache.delete(CACHE_KEY)
         self.update()
         raise Exception('Redirect', self.section.action_redirect_path)
     f = form(self.section, self.section.full_path)
     f.add_control(control(self.section, 'text', 'SITE_HEADER', self.SITE_HEADER, 'Site header', 50))
     f.add_control(control(self.section, 'text', 'SITE_SUB_HEADER', self.SITE_SUB_HEADER, 'Site sub-header', 50))
     combined_themes = get_local_theme_namespaces() + get_custom_theme_namespaces()
     f.add_control(selectcontrol(self.section, 'DEFAULT_THEME', combined_themes, self.DEFAULT_THEME if self.DEFAULT_THEME else DEFAULT_LOCAL_THEME_TEMPLATE, 'Default theme'))
     f.add_control(control(self.section, 'text', 'GOOGLE_ANALYTICS_UA', self.GOOGLE_ANALYTICS_UA, 'Google analytics UA'))
     f.add_control(control(self.section, 'file', 'FAVICON_ICO', label='favicon.ico'))
     f.add_control(textareacontrol(self.section, 'ROBOTS_TXT', self.ROBOTS_TXT, 'robots.txt', 90, 5))
     f.add_control(checkboxcontrol(self.section, 'ENABLE_THEME_PREVIEW', self.ENABLE_THEME_PREVIEW, 'Enable theme preview'))
     f.add_control(checkboxcontrol(self.section, 'DEBUG_MODE', self.DEBUG_MODE, 'Debug mode'))
     f.add_control(control(self.section, 'submit', 'submit', 'Submit'))
     return '<h2>Edit configuration</h2>%s' % unicode(f)
Beispiel #3
0
 def action_edit(self):
     if self.section.handler.request.get('submit'):
         self.SITE_HEADER = self.section.handler.request.get('SITE_HEADER')
         self.SITE_SUB_HEADER = self.section.handler.request.get(
             'SITE_SUB_HEADER')
         self.DEFAULT_THEME = self.section.handler.request.get(
             'DEFAULT_THEME')
         self.GOOGLE_ANALYTICS_UA = self.section.handler.request.get(
             'GOOGLE_ANALYTICS_UA')
         self.ROBOTS_TXT = self.section.handler.request.get('ROBOTS_TXT')
         if self.section.handler.request.get('FAVICON_ICO'):
             if self.FAVICON_ICO:
                 BlobInfo.get(self.FAVICON_ICO).delete()
             data = self.section.handler.request.get('FAVICON_ICO')
             handle = files.blobstore.create(
                 mime_type='image/x-icon',
                 _blobinfo_uploaded_filename='favicon.ico')
             with files.open(handle, 'a') as f:
                 f.write(data)
             files.finalize(handle)
             self.FAVICON_ICO = files.blobstore.get_blob_key(handle)
         self.ENABLE_THEME_PREVIEW = self.section.handler.request.get(
             'ENABLE_THEME_PREVIEW') != ''
         self.DEBUG_MODE = self.section.handler.request.get(
             'DEBUG_MODE') != ''
         cache.delete(CACHE_KEY)
         self.update()
         raise Exception('Redirect', self.section.action_redirect_path)
     f = form(self.section, self.section.full_path)
     f.add_control(
         control(self.section, 'text', 'SITE_HEADER', self.SITE_HEADER,
                 'Site header', 50))
     f.add_control(
         control(self.section, 'text', 'SITE_SUB_HEADER',
                 self.SITE_SUB_HEADER, 'Site sub-header', 50))
     combined_themes = get_local_theme_namespaces(
     ) + get_custom_theme_namespaces()
     f.add_control(
         selectcontrol(
             self.section, 'DEFAULT_THEME', combined_themes,
             self.DEFAULT_THEME if self.DEFAULT_THEME else
             DEFAULT_LOCAL_THEME_TEMPLATE, 'Default theme'))
     f.add_control(
         control(self.section, 'text', 'GOOGLE_ANALYTICS_UA',
                 self.GOOGLE_ANALYTICS_UA, 'Google analytics UA'))
     f.add_control(
         control(self.section, 'file', 'FAVICON_ICO', label='favicon.ico'))
     f.add_control(
         textareacontrol(self.section, 'ROBOTS_TXT', self.ROBOTS_TXT,
                         'robots.txt', 90, 5))
     f.add_control(
         checkboxcontrol(self.section, 'ENABLE_THEME_PREVIEW',
                         self.ENABLE_THEME_PREVIEW, 'Enable theme preview'))
     f.add_control(
         checkboxcontrol(self.section, 'DEBUG_MODE', self.DEBUG_MODE,
                         'Debug mode'))
     f.add_control(control(self.section, 'submit', 'submit', 'Submit'))
     return '<h2>Edit configuration</h2>%s' % unicode(f)
Beispiel #4
0
def get_form(s, path, parent_path, name=None, title=None, keywords=None, description=None, theme=None, is_private=False, is_default=False, redirect_to=None, new_window=False):
    f = form(s, s.full_path)
    f.add_control(control(s, 'text', 'path', path, 'Path'))
    f.add_control(control(s, 'text', 'parent_path', parent_path if parent_path else '', 'Parent path'))
    f.add_control(control(s, 'text', 'name', name if name else '', 'Name', 30))
    f.add_control(control(s, 'text', 'title', title if title else '', 'Title', 60))
    f.add_control(textareacontrol(s, 'keywords', keywords if keywords else '', 'Keywords', 60, 5))
    f.add_control(textareacontrol(s, 'description', description if description else '', 'Description', 60, 5))
    combined_themes = get_local_theme_namespaces() + get_custom_theme_namespaces()
    default_theme = configuration.default_theme()
    if not default_theme: default_theme = template.DEFAULT_LOCAL_THEME_TEMPLATE
    f.add_control(selectcontrol(s, 'theme', combined_themes, theme if theme else default_theme, 'Theme'))
    f.add_control(checkboxcontrol(s, 'is_private', is_private, 'Is private'))
    if not is_default: f.add_control(checkboxcontrol(s, 'is_default', is_default, 'Is default'))
    f.add_control(control(s, 'text', 'redirect_to', redirect_to if redirect_to else '', 'Redirect to', 60))
    f.add_control(checkboxcontrol(s, 'new_window', new_window, 'New window'))
    f.add_control(control(s, 'submit', 'submit'))
    return unicode(f)
Beispiel #5
0
def get_form(s, path, parent_path, name=None, title=None, keywords=None, description=None, theme=None, is_private=False, is_default=False, redirect_to=None, new_window=False):
    f = form(s, s.full_path)
    f.add_control(control(s, 'text', 'path', path, 'Path'))
    f.add_control(control(s, 'text', 'parent_path', parent_path if parent_path else '', 'Parent path'))
    f.add_control(control(s, 'text', 'name', name if name else '', 'Name', 30))
    f.add_control(control(s, 'text', 'title', title if title else '', 'Title', 60))
    f.add_control(textareacontrol(s, 'keywords', keywords if keywords else '', 'Keywords', 60, 5))
    f.add_control(textareacontrol(s, 'description', description if description else '', 'Description', 60, 5))
    combined_themes = get_local_theme_namespaces() + get_custom_theme_namespaces()
    default_theme = configuration.default_theme()
    if not default_theme: default_theme = template.DEFAULT_LOCAL_THEME_TEMPLATE
    f.add_control(selectcontrol(s, 'theme', combined_themes, theme if theme else default_theme, 'Theme'))
    f.add_control(checkboxcontrol(s, 'is_private', is_private, 'Is private'))
    if not is_default: f.add_control(checkboxcontrol(s, 'is_default', is_default, 'Is default'))
    f.add_control(control(s, 'text', 'redirect_to', redirect_to if redirect_to else '', 'Redirect to', 60))
    f.add_control(checkboxcontrol(s, 'new_window', new_window, 'New window'))
    f.add_control(control(s, 'submit', 'submit'))
    return unicode(f)
Beispiel #6
0
 def edit_text_resource(self,
                        theme,
                        filename,
                        filenames,
                        contents,
                        validate_body_template=False):
     if filename:
         index = filenames.index(filename)
         content = contents[index]
     else:
         index = len(filenames) if filenames else 0
         content = ''
     message = ''
     if self.section.handler.request.get('submit'):
         new_filename = self.section.handler.request.get(
             'filename').replace('/', '')
         content = self.section.handler.request.get('content')
         if not new_filename:
             message = '<div class="status error">Filename is required</div>'
         elif filename != new_filename and new_filename in filenames:
             message = '<div class="status error">Filename already exists</div>'
         else:
             try:
                 if validate_body_template:
                     content = validated_body_template(content)
             except Exception as inst:
                 message = '<div class="status error">%s</div>' % inst[0]
             else:
                 if filename:
                     filenames[index] = new_filename
                     contents[index] = content
                 else:
                     filenames.append(new_filename)
                     contents.append(content)
                 theme.put()
                 cache.flush_all(
                 )  # Flush all cached resources for this theme which is important for sections where it is active
                 raise Exception('Redirect',
                                 self.section.action_redirect_path)
     f = form(self.section, self.section.full_path)
     f.add_control(
         control(self.section, 'text', 'filename', filename, 'Filename'))
     f.add_control(
         textareacontrol(self.section, 'content', content, 'Content', 90,
                         50))
     f.add_control(control(self.section, 'submit', 'submit', 'Submit'))
     return '%s<h1>Add</h1>%s' % (message, unicode(f))
Beispiel #7
0
 def edit_text_resource(self, theme, filename, filenames, contents, validate_body_template=False):
     if filename:
         index = filenames.index(filename)
         content = contents[index]
     else:
         index = len(filenames) if filenames else 0
         content = ''
     message = ''
     if self.section.handler.request.get('submit'):
         new_filename = self.section.handler.request.get('filename').replace('/', '')
         content = self.section.handler.request.get('content')
         if not new_filename:
             message = '<div class="status error">Filename is required</div>'
         elif filename != new_filename and new_filename in filenames:
             message = '<div class="status error">Filename already exists</div>'
         else:
             try:
                 if validate_body_template:
                     content = validated_body_template(content)
             except Exception as inst:
                 message = '<div class="status error">%s</div>' % inst[0]
             else:
                 if filename:
                     filenames[index] = new_filename
                     contents[index] = content
                 else:
                     filenames.append(new_filename)
                     contents.append(content)
                 theme.put()
                 cache.flush_all() # Flush all cached resources for this theme which is important for sections where it is active
                 raise Exception('Redirect', self.section.action_redirect_path)
     f = form(self.section, self.section.full_path)
     f.add_control(control(self.section, 'text', 'filename', filename, 'Filename'))
     f.add_control(textareacontrol(self.section, 'content', content, 'Content', 90, 50))
     f.add_control(control(self.section, 'submit', 'submit', 'Submit'))
     return '%s<h1>Add</h1>%s' % (message, unicode(f))
Beispiel #8
0
def get_form(section, title, body):
    f = form(section, section.full_path)
    f.add_control(control(section, "text", "title", title, "Title", 60))
    f.add_control(textareacontrol(section, "body", body, "Body", 100, 10, html=True))
    f.add_control(control(section, "submit", "submit"))
    return unicode(f)
Beispiel #9
0
def get_form(section, title, body):
    f = form(section, section.full_path)
    f.add_control(control(section, 'text', 'title', title, 'Title', 60))
    f.add_control(textareacontrol(section, 'body', body, 'Body', 100, 10, html=True))
    f.add_control(control(section, 'submit', 'submit'))
    return unicode(f)