Exemple #1
0
def _create_example_site(user):
    site = Site(
        name='Example Site',
        owner = user,
        users = [user],
        admins = [user],
        example = True,
    )
    site.put()

    for v in [4, 5]:
        name = 'Html%d Example' % v
        style = Style(site=site, name=name)
        style.put()
        rev = StyleRevision(parent=style, rev=0)
        rev.put()
        rev.update(render_template('examples/blog-html%d.css' % v))
        style.published_rev = rev
        rev = StyleRevision(parent=style, rev=1)
        rev.put()
        rev.update(render_template('examples/blog-html%d-preview.css' % v))
        style.preview_rev = rev
        style.put()
        page = Page(site=site, name=name, url=url_for('example%d' % v, page_key=0, _external=True), _styles=[style.key()])
        page.put()
        page.url = url_for('example%d' % v, page_key=page.key(), _external=True)
        page.put()
        page.queue_refresh()
Exemple #2
0
def _create_example_site(user):
    site = Site(
        name='Example Site',
        owner=user,
        users=[user],
        admins=[user],
        example=True,
    )
    site.put()

    for v in [4, 5]:
        name = 'Html%d Example' % v
        style = Style(site=site, name=name)
        style.put()
        rev = StyleRevision(parent=style, rev=0)
        rev.put()
        rev.update(render_template('examples/blog-html%d.css' % v))
        style.published_rev = rev
        rev = StyleRevision(parent=style, rev=1)
        rev.put()
        rev.update(render_template('examples/blog-html%d-preview.css' % v))
        style.preview_rev = rev
        style.put()
        page = Page(site=site,
                    name=name,
                    url=url_for('example%d' % v, page_key=0, _external=True),
                    _styles=[style.key()])
        page.put()
        page.url = url_for('example%d' % v,
                           page_key=page.key(),
                           _external=True)
        page.put()
        page.queue_refresh()
Exemple #3
0
def new_style(page_id):
    page = Page.get_admin_or_404(page_id)
    form = StyleForm(request.form, site=page.site)
    if request.method == 'POST' and form.validate():
        style = Style(
            name = form.name.data,
            site = page.site,
        )
        style.put()
        return redirect(url_for('editor', page_id=page_id))
    return render_template('new_style.html', form=form)
Exemple #4
0
def new_style(page_id):
    page = Page.get_admin_or_404(page_id)
    form = StyleForm(request.form, site=page.site)
    if request.method == 'POST' and form.validate():
        style = Style(
            name=form.name.data,
            site=page.site,
        )
        style.put()
        return redirect(url_for('editor', page_id=page_id))
    return render_template('new_style.html', form=form)