Details

Applies to
moin 1.9.1
Purpose

List the pages included in the language pack (in LanguageSetup).

Description
Users may have hard time identifying which language package should be installed in the wiki underlay.

ListPages.png

Patch

   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)
languages_packs_content-1-of-2.patch

   1 Author: Frank Lin Piatroot <fpiat@klabs.be>
   2 Date:   Sat Feb 20 18:57:34 2010 +0100
   3 
   4     Print the lists of package and pages side-by-side
   5 
   6 diff --git a/language_setup.py b/language_setup.py
   7 index 2ab9452..a6a8b22 100644
   8 --- a/language_setup.py
   9 +++ b/language_setup.py
  10 @@ -18,6 +18,7 @@ i18n.strings = strings
  11  from MoinMoin.action import AttachFile
  12  from MoinMoin.util.dataset import TupleDataset, Column
  13  from MoinMoin.widget.browser import DataBrowserWidget
  14 +from MoinMoin.widget import html
  15  from MoinMoin import wikiutil
  16  
  17  def execute(pagename, request):
  18 @@ -43,6 +44,7 @@ def execute(pagename, request):
  19      target = request.values.get('target') or ''
  20      mode = request.values.get('mode') or 'show'
  21      msg = ''
  22 +    pkg_content = ''
  23      # if target is given it tries to install the package.
  24      if target:
  25          dummy_pagename, dummy_target, targetpath = AttachFile._access_file(language_setup_page, request)
  26 @@ -54,7 +56,7 @@ def execute(pagename, request):
  27                  else:
  28                      msg = _("Installation of '%(filename)s' failed.") % {'filename': target}
  29              else:
  30 -                    msg = "<pre><b>%s</b>\n%s</pre>" % (_("Package script:"), wikiutil.escape(package.getScript()))
  31 +                    pkg_content = "<b>%s</b>(%s)<br><pre>%s</pre>" % (_("Package script:"), target, wikiutil.escape(package.getScript()))
  32  
  33          else:
  34              msg = _('The file %s is not a MoinMoin package file.') % target
  35 @@ -96,12 +98,22 @@ def execute(pagename, request):
  36  
  37      lang_selector = u''.join([fmt.paragraph(1), _("Choose:"), ' ', ' '.join(lang_links), fmt.paragraph(0)])
  38  
  39 +    tbl = html.TABLE(border="0")
  40 +    tr = html.TR()
  41 +    tbl.append(tr)
  42 +    td = html.TD(valign="top")
  43 +    tr.append(td)
  44 +    td.append(page_table)
  45 +    td = html.TD(valign="top")
  46 +    tr.append(td)
  47 +    td.append(pkg_content)
  48 +
  49      title = _("Install language packs for '%s'") % (lang)
  50      request.theme.add_msg(msg, "info")
  51      request.theme.send_title(title, page=request.page, pagename=pagename)
  52      request.write(request.formatter.startContent("content"))
  53      request.write(lang_selector)
  54 -    request.write(page_table)
  55 +    request.write(unicode(tbl))
  56      request.write(request.formatter.endContent())
  57      request.theme.send_footer(pagename)
  58      request.theme.send_closing_html()
languages_packs_content-2-of-2.patch

Discussion

This is a very simple implementation. It looks ugly because the outer table if forced to have border using CSS.

It should be possible to have a much nicer list, but it would add more code (and code maintenance in the futur).

However, I am willing to work on that if needed.

/!\ The patches look like having indentation issues. Always use 4 blanks, never tabs.

That's what I have had in mind. Sorry haven't seen that you also work on it. But my intention is to show at least admins that they can help translating pages which are missing. FranklinPiat/UnderstandingLanguagePacks/ListPagePacks.py -- ReimarBauer 2010-02-20 22:38:48

Plan


CategoryMoinMoinPatch

MoinMoin: MoinMoinPatch/ListLanguagePackagesContent (last edited 2010-02-20 22:38:48 by ReimarBauer)