Attachment 'languages_packs_content-1-of-2.patch'
Download 1 Author: Frank Lin Piatroot <fpiat@klabs.be>
2 Date: Sat Feb 20 21:07:24 2010 +0100
3
4 Print the list of pages in a language pack.
5 (very basic implementation)
6
7 diff --git a/language_setup.py b/language_setup.py
8 index 46046b7..2ab9452 100644
9 --- a/language_setup.py
10 +++ b/language_setup.py
11 @@ -18,6 +18,7 @@ i18n.strings = strings
12 from MoinMoin.action import AttachFile
13 from MoinMoin.util.dataset import TupleDataset, Column
14 from MoinMoin.widget.browser import DataBrowserWidget
15 +from MoinMoin import wikiutil
16
17 def execute(pagename, request):
18 _ = request.getText
19 @@ -40,16 +41,21 @@ def execute(pagename, request):
20
21 lang = request.values.get('language') or 'English'
22 target = request.values.get('target') or ''
23 + mode = request.values.get('mode') or 'show'
24 msg = ''
25 # if target is given it tries to install the package.
26 if target:
27 dummy_pagename, dummy_target, targetpath = AttachFile._access_file(language_setup_page, request)
28 package = packages.ZipPackage(request, targetpath)
29 if package.isPackage():
30 - if package.installPackage():
31 - msg = _("Attachment '%(filename)s' installed.") % {'filename': target}
32 + if mode == 'install':
33 + if package.installPackage():
34 + msg = _("Attachment '%(filename)s' installed.") % {'filename': target}
35 + else:
36 + msg = _("Installation of '%(filename)s' failed.") % {'filename': target}
37 else:
38 - msg = _("Installation of '%(filename)s' failed.") % {'filename': target}
39 + msg = "<pre><b>%s</b>\n%s</pre>" % (_("Package script:"), wikiutil.escape(package.getScript()))
40 +
41 else:
42 msg = _('The file %s is not a MoinMoin package file.') % target
43
44 @@ -57,20 +63,25 @@ def execute(pagename, request):
45 data = TupleDataset()
46 data.columns = [
47 Column('page package', label=_('page package')),
48 + Column('action', label=_('show')),
49 Column('action', label=_('install')),
50 ]
51
52 label_install = _("install")
53 + label_show = _("show")
54 for pageset_name in i18n.strings.pagesets:
55 attachment = "%s--%s.zip" % (lang, pageset_name)
56 # not_translated_system_pages are in english
57 if attachment.endswith(not_translated_system_pages):
58 attachment = 'English_not_translated_system_pages.zip'
59 install_link = ''
60 - querystr = {'action': 'language_setup', 'target': attachment, 'language': lang}
61 + show_link = ''
62 if AttachFile.exists(request, language_setup_page, attachment):
63 + querystr = {'action': 'language_setup', 'target': attachment, 'language': lang, 'mode': 'install'}
64 install_link = request.page.link_to(request, label_install, querystr=querystr)
65 - data.addRow((pageset_name, install_link))
66 + querystr = {'action': 'language_setup', 'target': attachment, 'language': lang, 'mode': 'show'}
67 + show_link = request.page.link_to(request, label_show, querystr=querystr)
68 + data.addRow((pageset_name, show_link, install_link))
69
70 table = DataBrowserWidget(request)
71 table.setData(data)
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.