Changeset 845:cafe86006e8a in hatta-dev
- Timestamp:
- 11/11/10 16:03:43 (18 months ago)
- Branch:
- default
- Children:
- 846:6b0f5b41ffed, 849:47b21d9a202a
- Location:
- hatta
- Files:
-
- 2 added
- 8 edited
-
page.py (modified) (7 diffs)
-
templates/backlinks.html (modified) (1 diff)
-
templates/changes.html (modified) (1 diff)
-
templates/edit_file.html (added)
-
templates/edit_text.html (added)
-
templates/history.html (modified) (1 diff)
-
templates/page.html (modified) (1 diff)
-
templates/page_special.html (modified) (1 diff)
-
templates/wanted.html (modified) (1 diff)
-
wiki.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
hatta/page.py
r844 r845 224 224 return stream 225 225 226 def render_content(self, content, special_title=None):227 return self.template(self.template_name, content=content,228 special_title=special_title)229 230 226 def dependencies(self): 231 227 """Refresh the page when any of those pages was changed.""" … … 242 238 return dependencies 243 239 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 244 255 245 256 class WikiPageSpecial(WikiPage): … … 275 286 return self.content_iter(lines) 276 287 277 def editor_form(self, preview=None):288 def render_editor(self, preview=None): 278 289 """Generate the HTML for the editor.""" 279 290 … … 293 304 rev = -1 294 305 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)))) 298 307 if preview: 299 308 lines = preview 300 309 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) 322 313 323 314 def diff_content(self, from_text, to_text, message=u''): … … 419 410 yield html 420 411 412 421 413 class WikiPageWiki(WikiPageColorText): 422 414 """Pages of with wiki markup use this for display.""" … … 491 483 return content 492 484 493 def editor_form(self, preview=None):494 _ = self.wiki.gettext495 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_comment502 else:503 comment = _(u'uploaded')504 rev = -1505 html = werkzeug.html506 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")521 485 522 486 class WikiPageImage(WikiPageFile): … … 557 521 cache_file.close() 558 522 return cache_path 523 559 524 560 525 class WikiPageCSV(WikiPageFile): -
hatta/templates/backlinks.html
r843 r845 6 6 <h1>{{ _("Links to %(title)s", title=title) }}</h1> 7 7 {% endblock %} 8 {% block title %}{{ _("Links to %(title)s", title=title) }} - {{ wiki.site_name }}{% endblock %} 8 9 9 10 {% block content %} -
hatta/templates/changes.html
r844 r845 1 1 {% extends "page_special.html" %} 2 2 3 {% block title %}{{ _("Recent changes") }}{% endblock %} 3 {% block page_title %}{{ _("Recent changes") }}{% endblock %} 4 {% block title %}{{ _("Recent changes") }} - {{ wiki.site_name }}{% endblock %} 4 5 5 6 {% block content %} -
hatta/templates/history.html
r842 r845 4 4 5 5 {% block page_title %} 6 <h1>{{ _( 'History of %(title)s', title=title) }}</h1>6 <h1>{{ _("History of %(title)s", title=title) }}</h1> 7 7 {% endblock %} 8 {% block title %}{{ _("History of %(title)s", title=title) }} - {{ wiki.site_name }}{% endblock %} 8 9 9 10 {% 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> 11 12 <form action="{{ url(title, wiki.undo, method='POST') }}" method="POST"> 12 13 <ul id="hatta-history"> -
hatta/templates/page.html
r841 r845 2 2 3 3 {% block page_title %}<h1>{{ title }}</h1>{% endblock %} 4 {% block title %}{{ title }} - {{ wiki.site_name }}{% endblock %} 4 5 5 6 {% block footer %} -
hatta/templates/page_special.html
r841 r845 4 4 5 5 {% block page_title %}<h1>{{ special_title }}</h1>{% endblock %} 6 {% block title %}{{ special_title }} - {{ wiki.site_name }}{% endblock %} 6 7 7 8 {% block footer %} -
hatta/templates/wanted.html
r843 r845 1 1 {% extends "page_special.html" %} 2 2 3 {% block page_title %}{{ _("Wanted pages") }}{% endblock %} 3 4 {% block title %}{{ _("Wanted pages") }}{% endblock %} 4 5 -
hatta/wiki.py
r844 r845 355 355 url = request.get_url(title, self.edit, external=True) 356 356 return werkzeug.routing.redirect(url, code=303) 357 html = page. render_content(content)357 html = page.template(page.template_name, content=content) 358 358 dependencies = page.dependencies() 359 359 etag = '/(%s)' % u','.join(dependencies) … … 375 375 special_title = _(u'Revision of "%(title)s"') % {'title': title} 376 376 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) 378 379 response = self.response(request, title, html, rev=rev, etag='/old') 379 380 return response … … 460 461 self.storage.reopen() 461 462 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) 465 464 if not exists: 466 465 response = WikiResponse(html, mimetype="text/html", … … 713 712 _(u"Diff not available for this kind of pages.")))] 714 713 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) 716 716 response = WikiResponse(html, mimetype='text/html') 717 717 return response … … 819 819 title = _(u'Searching for "%s"') % u" ".join(words) 820 820 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) 822 823 return WikiResponse(html, mimetype='text/html') 823 824
Note: See TracChangeset
for help on using the changeset viewer.
