Changeset 845:cafe86006e8a in hatta-dev


Ignore:
Timestamp:
11/11/10 16:03:43 (18 months ago)
Author:
Radomir Dopieralski <hatta-dev@…>
Branch:
default
Children:
846:6b0f5b41ffed, 849:47b21d9a202a
Message:

templates for the editor

Location:
hatta
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • hatta/page.py

    r844 r845  
    224224        return stream 
    225225 
    226     def render_content(self, content, special_title=None): 
    227         return self.template(self.template_name, content=content, 
    228                              special_title=special_title) 
    229  
    230226    def dependencies(self): 
    231227        """Refresh the page when any of those pages was changed.""" 
     
    242238        return dependencies 
    243239 
     240    def render_editor(self, preview=None): 
     241        _ = self.wiki.gettext 
     242        author = self.request.get_author() 
     243        if self.title in self.storage: 
     244            comment = _(u'changed') 
     245            (rev, old_date, old_author, 
     246                old_comment) = self.storage.page_meta(self.title) 
     247            if old_author == author: 
     248                comment = old_comment 
     249        else: 
     250            comment = _(u'uploaded') 
     251            rev = -1 
     252        return self.template('edit_file.html', comment=comment, 
     253                             author=author, parent=rev) 
     254 
    244255 
    245256class WikiPageSpecial(WikiPage): 
     
    275286        return self.content_iter(lines) 
    276287 
    277     def editor_form(self, preview=None): 
     288    def render_editor(self, preview=None): 
    278289        """Generate the HTML for the editor.""" 
    279290 
     
    293304            rev = -1 
    294305        except error.ForbiddenErr, e: 
    295             yield werkzeug.html.p( 
    296                 werkzeug.html(_(unicode(e)))) 
    297             return 
     306            return werkzeug.html.p(werkzeug.html(_(unicode(e)))) 
    298307        if preview: 
    299308            lines = preview 
    300309            comment = self.request.form.get('comment', comment) 
    301         html = werkzeug.html 
    302         yield u'<form action="" method="POST" class="editor"><div>' 
    303         yield u'<textarea name="text" cols="80" rows="20" id="editortext">' 
    304         for line in lines: 
    305             yield werkzeug.escape(line) 
    306         yield u"""</textarea>""" 
    307         yield html.input(type_="hidden", name="parent", value=rev) 
    308         yield html.label(html(_(u'Comment')), html.input(name="comment", 
    309             value=comment), class_="comment") 
    310         yield html.label(html(_(u'Author')), html.input(name="author", 
    311             value=self.request.get_author()), class_="comment") 
    312         yield html.div( 
    313                 html.input(type_="submit", name="save", value=_(u'Save')), 
    314                 html.input(type_="submit", name="preview", value=_(u'Preview')), 
    315                 html.input(type_="submit", name="cancel", value=_(u'Cancel')), 
    316                 class_="buttons") 
    317         yield u'</div></form>' 
    318         if preview: 
    319             yield html.h1(html(_(u'Preview, not saved')), class_="preview") 
    320             for part in self.view_content(preview): 
    321                 yield part 
     310        return self.template('edit_text.html', comment=comment, 
     311                             preview=preview, 
     312                             author=author, parent=rev, lines=lines) 
    322313 
    323314    def diff_content(self, from_text, to_text, message=u''): 
     
    419410        yield html 
    420411 
     412 
    421413class WikiPageWiki(WikiPageColorText): 
    422414    """Pages of with wiki markup use this for display.""" 
     
    491483        return content 
    492484 
    493     def editor_form(self, preview=None): 
    494         _ = self.wiki.gettext 
    495         author = self.request.get_author() 
    496         if self.title in self.storage: 
    497             comment = _(u'changed') 
    498             (rev, old_date, old_author, 
    499                 old_comment) = self.storage.page_meta(self.title) 
    500             if old_author == author: 
    501                 comment = old_comment 
    502         else: 
    503             comment = _(u'uploaded') 
    504             rev = -1 
    505         html = werkzeug.html 
    506         yield html.p(html( 
    507                 _(u"This is a binary file, it can't be edited on a wiki. " 
    508                   u"Please upload a new version instead."))) 
    509         yield html.form(html.div( 
    510             html.div(html.input(type_="file", name="data"), class_="upload"), 
    511             html.input(type_="hidden", name="parent", value=rev), 
    512             html.label(html(_(u'Comment')), html.input(name="comment", 
    513                        value=comment)), 
    514             html.label(html(_(u'Author')), html.input(name="author", 
    515                        value=author)), 
    516             html.div(html.input(type_="submit", name="save", value=_(u'Save')), 
    517                      html.input(type_="submit", name="cancel", 
    518                                 value=_(u'Cancel')), 
    519             class_="buttons")), action="", method="POST", class_="editor", 
    520                                 enctype="multipart/form-data") 
    521485 
    522486class WikiPageImage(WikiPageFile): 
     
    557521        cache_file.close() 
    558522        return cache_path 
     523 
    559524 
    560525class WikiPageCSV(WikiPageFile): 
  • hatta/templates/backlinks.html

    r843 r845  
    66    <h1>{{ _("Links to %(title)s", title=title) }}</h1> 
    77{% endblock %} 
     8{% block title %}{{ _("Links to %(title)s", title=title) }} - {{ wiki.site_name }}{% endblock %} 
    89 
    910{% block content %} 
  • hatta/templates/changes.html

    r844 r845  
    11{% extends "page_special.html" %}  
    22 
    3 {% block title %}{{ _("Recent changes") }}{% endblock %} 
     3{% block page_title %}{{ _("Recent changes") }}{% endblock %} 
     4{% block title %}{{ _("Recent changes") }} - {{ wiki.site_name }}{% endblock %} 
    45 
    56{% block content %} 
  • hatta/templates/history.html

    r842 r845  
    44 
    55{% block page_title %} 
    6     <h1>{{ _('History of %(title)s', title=title) }}</h1> 
     6    <h1>{{ _("History of %(title)s", title=title) }}</h1> 
    77{% endblock %} 
     8{% block title %}{{ _("History of %(title)s", title=title) }} - {{ wiki.site_name }}{% endblock %} 
    89 
    910{% block content %} 
    10     <p>{{ _('History of changes for %(link)s.', link=page.wiki_link(title)|safe) }}</p> 
     11    <p>{{ _("History of changes for %(link)s.", link=page.wiki_link(title)|safe) }}</p> 
    1112    <form action="{{ url(title, wiki.undo, method='POST') }}" method="POST"> 
    1213        <ul id="hatta-history"> 
  • hatta/templates/page.html

    r841 r845  
    22 
    33{% block page_title %}<h1>{{ title }}</h1>{% endblock %} 
     4{% block title %}{{ title }} - {{ wiki.site_name }}{% endblock %} 
    45 
    56{% block footer %} 
  • hatta/templates/page_special.html

    r841 r845  
    44 
    55{% block page_title %}<h1>{{ special_title }}</h1>{% endblock %} 
     6{% block title %}{{ special_title }} - {{ wiki.site_name }}{% endblock %} 
    67 
    78{% block footer %} 
  • hatta/templates/wanted.html

    r843 r845  
    11{% extends "page_special.html" %}  
    22 
     3{% block page_title %}{{ _("Wanted pages") }}{% endblock %} 
    34{% block title %}{{ _("Wanted pages") }}{% endblock %} 
    45 
  • hatta/wiki.py

    r844 r845  
    355355            url = request.get_url(title, self.edit, external=True) 
    356356            return werkzeug.routing.redirect(url, code=303) 
    357         html = page.render_content(content) 
     357        html = page.template(page.template_name, content=content) 
    358358        dependencies = page.dependencies() 
    359359        etag = '/(%s)' % u','.join(dependencies) 
     
    375375        special_title = _(u'Revision of "%(title)s"') % {'title': title} 
    376376        page = self.get_page(request, title) 
    377         html = page.render_content(content, special_title) 
     377        html = page.template('page_special.html', content=content, 
     378                             special_title=special_title) 
    378379        response = self.response(request, title, html, rev=rev, etag='/old') 
    379380        return response 
     
    460461            self.storage.reopen() 
    461462        page = self.get_page(request, title) 
    462         content = page.editor_form(preview) 
    463         special_title = _(u'Editing "%(title)s"') % {'title': title} 
    464         html = page.render_content(content, special_title) 
     463        html = page.render_editor(preview) 
    465464        if not exists: 
    466465            response = WikiResponse(html, mimetype="text/html", 
     
    713712                _(u"Diff not available for this kind of pages.")))] 
    714713        special_title = _(u'Diff for "%(title)s"') % {'title': title} 
    715         html = page.render_content(content, special_title) 
     714        html = page.template('page_special.html', content=content, 
     715                            special_title=special_title) 
    716716        response = WikiResponse(html, mimetype='text/html') 
    717717        return response 
     
    819819        title = _(u'Searching for "%s"') % u" ".join(words) 
    820820        content = page_search(words, page, request) 
    821         html = page.render_content(content, title) 
     821        html = page.template('page_special.html', content=content, 
     822                             special_title=title) 
    822823        return WikiResponse(html, mimetype='text/html') 
    823824 
Note: See TracChangeset for help on using the changeset viewer.