Preview support for blog entries (mostly intended for testing markdown syntax) Signed-off-by: Priit Laes --- forms.py | 3 ++- shared/admin/style.css | 4 ++++ templates/admin/_form_helpers.html | 12 ++++++++++++ templates/admin/edit_entry.html | 23 ++++++++++++++--------- utils/admin.py | 5 ++++- views/admin.py | 15 +++++++++++++++ 6 files changed, 51 insertions(+), 11 deletions(-) diff -r 067c3aad0df2 zine/forms.py --- a/zine/forms.py Mon Apr 06 00:05:01 2009 +0200 +++ b/zine/forms.py Thu Apr 23 21:54:24 2009 +0300 @@ -312,10 +312,11 @@ raise ValidationError(_('Selected parser is no longer ' 'available on the system.')) - def as_widget(self): + def as_widget(self, preview=False): widget = forms.Form.as_widget(self) widget.new = self.post is None widget.post = self.post + widget.preview = preview widget.parser_missing = self.parser_missing return widget diff -r 067c3aad0df2 zine/shared/admin/style.css --- a/zine/shared/admin/style.css Mon Apr 06 00:05:01 2009 +0200 +++ b/zine/shared/admin/style.css Thu Apr 23 21:54:24 2009 +0300 @@ -468,6 +468,10 @@ padding: 5px 0 5px 10px; } +div.preview { + border: 1px solid #FCF7F7; padding: 1em; +} + ul.errors { background-color: #FCF7F7; border: 1px solid #E8B5B5; diff -r 067c3aad0df2 zine/templates/admin/_form_helpers.html --- a/zine/templates/admin/_form_helpers.html Mon Apr 06 00:05:01 2009 +0200 +++ b/zine/templates/admin/_form_helpers.html Thu Apr 23 21:54:24 2009 +0300 @@ -5,3 +5,15 @@ {{ caller() if caller else field() }} {% endmacro %} + +{% macro render_post_actions(form) %} +
+ + + {%- if not form.new %} + + {%- endif %} + + +
+{% endmacro %} diff -r 067c3aad0df2 zine/templates/admin/edit_entry.html --- a/zine/templates/admin/edit_entry.html Mon Apr 06 00:05:01 2009 +0200 +++ b/zine/templates/admin/edit_entry.html Thu Apr 23 21:54:24 2009 +0300 @@ -1,10 +1,21 @@ {% extends "admin/layout.html" %} -{% from "admin/_form_helpers.html" import render_formbox %} +{% from "admin/_form_helpers.html" import render_formbox, render_post_actions %} {% block title %}{{ _("New Entry") if form.new else _("Edit Entry ā€œ%sā€") % form.post.title }}{% endblock %} {% block contents %} + {% if form.preview %} +
+ {{_('Preview')}} ({{_('skip')}}) +
+
+ {{text}} +
+
+
+ {% endif %}

{{ self.title() }}

+ {% call form() %} {%- if form.parser_missing %}