Mercurial > hatta-flask
changeset 2380:d93525563756
Fix #14: Add a help_page setting for displaying help at the edit page
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Sat, 11 May 2013 19:21:33 +0200 |
| parents | 9cb002eaa96a |
| children | 6bdd6a721a1f |
| files | hatta/config.py hatta/page.py hatta/templates/edit_file.html hatta/templates/edit_text.html hatta/wiki.py |
| diffstat | 5 files changed, 30 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/hatta/config.py Sat May 11 18:56:36 2013 +0200 +++ b/hatta/config.py Sat May 11 19:21:33 2013 +0200 @@ -34,6 +34,10 @@ help='Set the name of the site to NAME', metavar='NAME') _add('-m', '--front-page', dest='front_page', help='Use PAGE as the front page', metavar='PAGE') +_add('-a', '--alias-page', dest='alias_page', + help='Use PAGE as the alias page', metavar='PAGE') +_add('-H', '--help-page', dest='help_page', + help='Use PAGE as the editor help text', metavar='PAGE') _add('-e', '--encoding', dest='page_charset', help='Use encoding ENC to read and write pages', metavar='ENC') _add('-c', '--config-file', dest='config_file',
--- a/hatta/page.py Sat May 11 18:56:36 2013 +0200 +++ b/hatta/page.py Sat May 11 19:21:33 2013 +0200 @@ -243,6 +243,13 @@ dependencies.add(etag) return dependencies + def get_edit_help(self): + page = self.wiki.get_page(self.request, self.wiki.help_page) + try: + return ''.join(page.view_content()) + except error.NotFoundErr: + return '' + def render_editor(self, preview=None, captcha_error=None): _ = self.wiki.gettext author = self.request.get_author() @@ -265,6 +272,7 @@ 'author': author, 'parent': rev, 'recaptcha_html': recaptcha_html, + 'help': self.get_edit_help(), } return self.template('edit_file.html', **context) @@ -327,10 +335,16 @@ self.wiki.recaptcha_public_key, error=captcha_error) else: recaptcha_html = None - return self.template('edit_text.html', comment=comment, - preview=preview, - recaptcha_html=recaptcha_html, - author=author, parent=rev, lines=lines) + context = { + 'comment': comment, + 'preview': preview, + 'recaptcha_html': recaptcha_html, + 'help': self.get_edit_help(), + 'author': author, + 'parent': rev, + 'lines': lines, + } + return self.template('edit_text.html', **context) def diff_content(self, from_text, to_text, message=u''): """Generate the HTML markup for a diff."""
--- a/hatta/templates/edit_file.html Sat May 11 18:56:36 2013 +0200 +++ b/hatta/templates/edit_file.html Sat May 11 19:21:33 2013 +0200 @@ -23,6 +23,9 @@ </div> <input type="hidden" name="parent" value="{{ parent }}"> </div></form> + {% if help %} + <div id="hatta-help">{{ help|safe }}</div> + {% endif %} {% endblock %} {% block footer %}{% endblock %}
--- a/hatta/templates/edit_text.html Sat May 11 18:56:36 2013 +0200 +++ b/hatta/templates/edit_text.html Sat May 11 19:21:33 2013 +0200 @@ -26,6 +26,10 @@ <div id="hatta-preview"> {% for part in page.view_content(preview) %}{{ part|safe }}{% endfor %} </div> + {% else %} + {% if help %} + <div id="hatta-help">{{ help|safe }}</div> + {% endif %} {% endif %} {% endblock %}
--- a/hatta/wiki.py Sat May 11 18:56:36 2013 +0200 +++ b/hatta/wiki.py Sat May 11 19:21:33 2013 +0200 @@ -248,6 +248,7 @@ self.read_only = self.config.get_bool('read_only', False) self.icon_page = self.config.get('icon_page', None) self.alias_page = self.config.get('alias_page', 'Alias') + self.help_page = self.config.get('help_page', 'Help') self.pygments_style = self.config.get('pygments_style', 'tango') self.subdirectories = self.config.get_bool('subdirectories', False) self.extension = self.config.get('extension', None)
