# HG changeset patch
# User cmlenz
# Date 1152135147 0
# Node ID 2cb5b54d87ff80aa3679a651856c4cab4fe66a9b
# Parent aa6ffd2d7274ce5a59e72d64995c113c70c543e0
Migrate attachment templates to Markup.
diff --git a/examples/trac/templates/about.cs b/examples/trac/templates/about.cs
deleted file mode 100644
--- a/examples/trac/templates/about.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-
-
-
-
-
Configuration
-
Section
- Name Value
-
-
-
-
-
- See
TracIni for information about
- the configuration.
-
-
-
-
Plugins
-
-
-
-
- Module
-
-
-
- Description
-
-
-
- Extension points:
-
- .
( extensions)
-
-
-
-
-
-
-
-
-
-
About Trac
-
-Trac is a web-based software project management and bug/issue
-tracking system emphasizing ease of use and low ceremony.
-It provides an interface to the Subversion revision control systems, integrated Wiki and convenient report facilities.
-
-
Trac is distributed under the modified BSD License.
- The complete text of the license can be found in the COPYING file
- included in the distribution.
-
Please visit the Trac open source project:
- http://projects.edgewall.com/trac/
-
Trac is a product of Edgewall
- Software , provider of professional Linux and software development
- services.
-
Copyright © 2003-2006 Edgewall
- Software
-
-
-
-
-
diff --git a/examples/trac/templates/attachment.cs b/examples/trac/templates/attachment.cs
deleted file mode 100644
--- a/examples/trac/templates/attachment.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
-
-
-
Add Attachment to
-
-
-
:
-
Are you sure you want to delete this attachment?
- This is an irreversible operation.
-
-
-
-
-
:
-
-
- File ,
- (added by , ago)
-
-
-
-
-
-
-
HTML preview not available , since the file size exceeds
- bytes. You may
download the file instead.
-
HTML preview not available . To view the file,
-
download the file .
-
-
-
-
-
-
diff --git a/examples/trac/templates/attachment_delete.html b/examples/trac/templates/attachment_delete.html
new file mode 100644
--- /dev/null
+++ b/examples/trac/templates/attachment_delete.html
@@ -0,0 +1,31 @@
+
+
+
+
+
Are you sure you want to delete this attachment?
+ This is an irreversible operation.
+
+
+
+
+
diff --git a/examples/trac/templates/attachment_list.html b/examples/trac/templates/attachment_list.html
new file mode 100644
--- /dev/null
+++ b/examples/trac/templates/attachment_list.html
@@ -0,0 +1,39 @@
+
+
+
-
-
Search
-
-
-
Search results 1 ?>( -
- of )
-
-
- Quickjump to
-
-
-
-
- By —
- &mdash
- Keywords:
-
-
-
-
1 ?>
-
-
No matches found.
-
-
-
-
-
diff --git a/examples/trac/trac/attachment.py b/examples/trac/trac/attachment.py
--- a/examples/trac/trac/attachment.py
+++ b/examples/trac/trac/attachment.py
@@ -330,42 +330,26 @@
parent_id = '/'.join(segments[:-1])
last_segment = segments[-1]
if len(segments) == 1:
- self._render_list(req, parent_type, last_segment)
- return 'attachment.cs', None
+ return self._render_list(req, parent_type, last_segment)
if not last_segment:
raise HTTPBadRequest('Bad request')
attachment = Attachment(self.env, parent_type, parent_id,
last_segment)
- parent_link, parent_text = self._parent_to_hdf(
- req, attachment.parent_type, attachment.parent_id)
+
if req.method == 'POST':
if action == 'new':
self._do_save(req, attachment)
elif action == 'delete':
self._do_delete(req, attachment)
elif action == 'delete':
- self._render_confirm(req, attachment)
+ return self._render_confirm(req, attachment)
elif action == 'new':
- self._render_form(req, attachment)
+ return self._render_form(req, attachment)
else:
- add_link(req, 'up', parent_link, parent_text)
- self._render_view(req, attachment)
-
- add_stylesheet(req, 'common/css/code.css')
- return 'attachment.cs', None
-
- def _parent_to_hdf(self, req, parent_type, parent_id):
- # Populate attachment.parent:
- parent_link = req.href(parent_type, parent_id)
- if parent_type == 'ticket':
- parent_text = 'Ticket #' + parent_id
- else: # 'wiki'
- parent_text = parent_id
- req.hdf['attachment.parent'] = {
- 'type': parent_type, 'id': parent_id,
- 'name': parent_text, 'href': parent_link
- }
- return parent_link, parent_text
+ add_link(req, 'up', req.href(attachment.parent_type,
+ attachment.parent_id),
+ attachment.title)
+ return self._render_view(req, attachment)
# IWikiSyntaxProvider methods
@@ -493,16 +477,14 @@
perm_map = {'ticket': 'TICKET_ADMIN', 'wiki': 'WIKI_DELETE'}
req.perm.assert_permission(perm_map[attachment.parent_type])
- req.hdf['title'] = '%s (delete)' % attachment.title
- req.hdf['attachment'] = {'filename': attachment.filename,
- 'mode': 'delete'}
+ return 'attachment_delete.html', {'attachment': attachment}, None
def _render_form(self, req, attachment):
perm_map = {'ticket': 'TICKET_APPEND', 'wiki': 'WIKI_MODIFY'}
req.perm.assert_permission(perm_map[attachment.parent_type])
- req.hdf['attachment'] = {'mode': 'new',
- 'author': get_reporter_id(req)}
+ data = {'author': get_reporter_id(req), 'attachment': attachment}
+ return 'attachment_new.html', data, None
def _render_view(self, req, attachment):
perm_map = {'ticket': 'TICKET_VIEW', 'wiki': 'WIKI_VIEW'}
@@ -511,16 +493,13 @@
req.check_modified(attachment.time)
# Render HTML view
- req.hdf['title'] = attachment.title
- req.hdf['attachment'] = attachment_to_hdf(self.env, req, None,
- attachment)
- # Override the 'oneliner'
- req.hdf['attachment.description'] = wiki_to_html(attachment.description,
- self.env, req)
+ data = {'attachment': attachment}
+ data['description'] = wiki_to_html(attachment.description, self.env,
+ req)
perm_map = {'ticket': 'TICKET_ADMIN', 'wiki': 'WIKI_DELETE'}
if req.perm.has_permission(perm_map[attachment.parent_type]):
- req.hdf['attachment.can_delete'] = 1
+ data['can_delete'] = True
fd = attachment.open()
try:
@@ -563,19 +542,23 @@
self.log.debug("Rendering preview of file %s with mime-type %s"
% (attachment.filename, mime_type))
- req.hdf['attachment'] = mimeview.preview_to_hdf(
+ data.update(mimeview.preview_to_hdf(
req, fd, os.fstat(fd.fileno()).st_size, mime_type,
- attachment.filename, raw_href, annotations=['lineno'])
+ attachment.filename, raw_href, annotations=['lineno']))
finally:
fd.close()
- def _render_list(self, req, p_type, p_id):
- self._parent_to_hdf(req, p_type, p_id)
- req.hdf['attachment'] = {
- 'mode': 'list',
- 'list': attachments_to_hdf(self.env, req, None, p_type, p_id),
- 'attach_href': req.href.attachment(p_type, p_id)
- }
+ add_stylesheet(req, 'common/css/code.css')
+ return 'attachment_view.html', data, None
+
+ def _render_list(self, req, parent_type, parent_id):
+ data = {
+ 'parent_href': req.href(parent_type, parent_id),
+ 'parent_type': parent_type,
+ 'parent_id': parent_id,
+ 'attachments': Attachment.select(self.env, parent_type, parent_id)
+ }
+ return 'attachment_list.html', data, None
def _format_link(self, formatter, ns, target, label):
link, params, fragment = formatter.split_link(target)