Stuart Colville avatar Stuart Colville committed c78a192 Merge

merge from zine-main

Comments (0)

Files changed (9)

scripts/add-translation

     Add new Translation
     ~~~~~~~~~~~~~~~~~~~
 
-    This script adds a new translation to Zine or a Zine plugin.
+    This script adds a new translation to the main application or a plugin.
 
     :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details.
     :license: BSD, see LICENSE for more details.
 """
-from os import makedirs
-from os.path import dirname, join, realpath, pardir, isdir, isfile
+from os import path, makedirs
 from optparse import OptionParser
 from datetime import datetime
 from babel import Locale, UnknownLocaleError
 from babel.messages.pofile import read_po, write_po
 from babel.util import LOCALTZ
 
-zine = realpath(join(dirname(__file__), '..', 'zine'))
+app_dir = 'zine'
+i18n_dir = 'i18n'
+app_path = path.realpath(path.join(path.dirname(__file__), path.pardir, app_dir))
+app_i18n_path = path.join(app_path, i18n_dir)
+
 
 def main():
     global parser
 
 
 def write_catalog(catalog, folder):
-    target = join(folder, str(catalog.locale))
-    if not isdir(target):
+    target = path.join(folder, str(catalog.locale))
+    if not path.isdir(target):
         makedirs(target)
-    f = file(join(target, 'messages.po'), 'w')
+    f = file(path.join(target, 'messages.po'), 'w')
     try:
         write_po(f, catalog, width=79)
     finally:
 
 
 def create_application_lang(locale):
-    catalog = create_from_pot(locale, join(zine, 'i18n', 'messages.pot'))
-    write_catalog(catalog, join(zine, 'i18n'))
+    catalog = create_from_pot(locale, path.join(app_i18n_path, 'messages.pot'))
+    write_catalog(catalog, app_i18n_path)
     print 'Created catalog for %s' % locale
 
 
 def create_plugin_lang(locale, path):
-    catalog = create_from_pot(locale, join(path, 'i18n', 'messages.pot'))
+    catalog = create_from_pot(locale, path.join(path, i18n_dir, 'messages.pot'))
 
     # incorporate existing translations from the application
-    zinepath = join(zine, 'i18n', str(locale), 'messages.po')
-    if isfile(zinepath):
-        f = file(zinepath)
+    app_messages = path.join(app_i18n_path, str(locale), 'messages.po')
+    if path.isfile(app_messages):
+        f = file(app_messages)
         try:
             translated = read_po(f)
         finally:
             if message.id and message.id in catalog:
                 catalog[message.id].string = message.string
 
-    write_catalog(catalog, join(path, 'i18n'))
+    write_catalog(catalog, path.join(path, i18n_dir))
     print 'Created catalog for %s' % locale
 
 

scripts/compile-translations

     Compile translations
     ~~~~~~~~~~~~~~~~~~~~
 
-    Compile translations into pickles containing the translated messages.
-    We do not use standard MO files because we have to store additional
-    information in those files.
+    This script compiles translations of the main application or a plugin.
+    It writes standard MO files and then appends pickled translations for
+    client-side usage by javascript code.
 
     :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details.
     :license: BSD, see LICENSE for more details.
 """
 import pickle
 import struct
-from os import listdir, path
+from os import path, listdir
 from optparse import OptionParser
 from babel.messages.pofile import read_po
 from babel.messages.mofile import write_mo
 
 domains = ['messages']
 
+app_dir = 'zine'
+i18n_dir = 'i18n'
+app_path = path.realpath(path.join(path.dirname(__file__), path.pardir, app_dir))
+app_i18n_path = path.join(app_path, i18n_dir)
+
 
 def is_untranslated(obj):
     if not obj:
     options, args = parser.parse_args()
     if not args:
         print 'Compiling builtin languages'
-        root = path.abspath(path.join(path.dirname(__file__),
-                                      path.pardir, 'zine', 'i18n'))
+        root = app_i18n_path
     elif len(args) == 1:
-        root = path.join(path.abspath(args[0]), 'i18n')
+        root = path.join(path.abspath(args[0]), i18n_dir)
         if not path.isdir(root):
-            parser.error('i18n folder missing')
+            parser.error('%s folder missing' % i18n_dir)
         print 'Compiling', root
     else:
-        parser.error('incorrent number of arguments')
+        parser.error('incorrect number of arguments')
 
     for domain in domains:
         for lang in listdir(root):
                 else:
                     print
 
-                # Dump pickled data into standard catalog
+                # Dump pickled data at the end of the standard catalog
                 pickle.dump(client_messages, mo_file, 2)
-                # Write the pickled data pointer position
+                # Write offset of the start of the pickled data
                 mo_file.write(struct.pack('i', pickled_data_pointer_pos))
                 mo_file.close()
     print 'All done.'

scripts/extract-messages

     Extract Messages
     ~~~~~~~~~~~~~~~~
 
-    Extract messages into a PO-Template.
+    This script extracts messages from the main application or a plugin and
+    writes them into a PO-Template (POT).
 
     :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details.
     :license: BSD, see LICENSE for more details.
 from babel.messages.extract import extract_from_dir
 from babel.messages.pofile import write_po
 
+app_dir = 'zine'
+i18n_dir = 'i18n'
+app_path = path.realpath(path.join(path.dirname(__file__), path.pardir, app_dir))
 
 KEYWORDS = {
     '_': None,
     options, args = parser.parse_args()
     if not args:
         print 'Extracting core strings'
-        root = path.abspath(path.join(path.dirname(__file__),
-                                      path.pardir, 'zine'))
+        root = app_path
     elif len(args) == 1:
         root = path.join(path.abspath(args[0]))
         if not path.isdir(root):
             parser.error('source folder missing')
         print 'Extracting from', root
     else:
-        parser.error('incorrent number of arguments')
+        parser.error('incorrect number of arguments')
 
     catalog = Catalog(msgid_bugs_address=BUGS_ADDRESS,
                       copyright_holder=COPYRIGHT, charset='utf-8')
         catalog.add(message, None, [(strip_path(filename, root), lineno)],
                     auto_comments=comments)
 
-    output_path = path.join(root, 'i18n')
+    output_path = path.join(root, i18n_dir)
     if not path.isdir(output_path):
         makedirs(output_path)
 

scripts/reset-instance

     elif len(args) == 1:
         instance = args[0]
     else:
-        parser.error('incorrent number of arguments')
+        parser.error('incorrect number of arguments')
 
     print 'Resetting instance', instance
 

scripts/update-translations

     Update the translations
     ~~~~~~~~~~~~~~~~~~~~~~~
 
-    Update the translations from the POT.
+    This script updates the translations of the main application or a plugin
+    from a POT file.
 
     :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details.
     :license: BSD, see LICENSE for more details.
 
 domains = ['messages']
 
+app_dir = 'zine'
+i18n_dir = 'i18n'
+app_path = path.realpath(path.join(path.dirname(__file__), path.pardir, app_dir))
+
 
 def main():
     global parser
     options, args = parser.parse_args()
     if not args:
         print 'Updating core strings'
-        root = path.abspath(path.join(path.dirname(__file__),
-                                      path.pardir, 'zine', 'i18n'))
+        root = path.join(app_path, i18n_dir)
     elif len(args) == 1:
-        root = path.join(path.abspath(args[0]), 'i18n')
+        root = path.join(path.abspath(args[0]), i18n_dir)
         if not path.isdir(root):
             parser.error('source folder missing')
         print 'Updating', root
     else:
-        parser.error('incorrent number of arguments')
+        parser.error('incorrect number of arguments')
 
     if options.locale:
         for domain in domains:

zine/application.py

         """Return the URL of the author of the theme."""
         return self.author_info[2]
 
+    @property
+    def contributors(self):
+        """The Contributors of the plugin."""
+        from zine.utils.mail import split_email
+        data = self.metadata.get('contributors', '')
+        if not data:
+            return []
+        return [split_email(c.strip()) for c in
+        self.metadata.get('contributors', '').split(',')]
+
+    @property
+    def html_contributors_info(self):
+        from zine.utils.mail import check, is_valid_email
+        result = []
+        for contributor in self.contributors:
+            name, contact = contributor
+            if not contact:
+                result.append(escape(name))
+            else:
+                result.append('<a href="%s">%s</a>' % (
+                    escape(check(is_valid_email, contact) and
+                           'mailto:' + contact or contact),
+                    escape(name)
+                ))
+        return u', '.join(result)
+
     @cached_property
     def settings(self):
         return ReadOnlyMultiMapping(self._settings, DEFAULT_THEME_SETTINGS)

zine/templates/admin/theme.html

         <div class="detail">
           <blockquote><p>{{ theme.description|e }}</p></blockquote>
           {%- if theme.has_author %}
-            <p class="author">{% trans author=theme.html_author_info %}by {{ author }}{% endtrans %}</p>
+            <p class="author">
+              {% trans author=theme.html_author_info %}by {{ author }}{% endtrans %}
+              {% if theme.contributors %}
+              {% trans contributors=theme.html_contributors_info %}
+                and {{ contributors }}
+              {% endtrans %}
+              {% endif %}
+            </p>
           {%- endif %}
         </div>
       </div>

zine/views/account.py

     if rv is None:
         resource = get_resource(req.app, page)
         if resource is None:
-            return render_account_response('admin/help.html', 'system.help',
+            return render_account_response('account/help.html', 'system.help',
                                            not_found=True)
         return resource
 

zine/views/admin.py

     if request.app.cfg['maintenance_mode'] and \
                                         request.user.has_privilege(BLOG_ADMIN):
         flash(_(u'Zine is in maintenance mode. Don\'t forget to '
-                u'turn it off again once you finish your changes.'))
+                u'turn it off again once you finish your changes. You '
+                u'can do that under System -&gt; Maintenance'))
 
     # check for broken plugins if we have the plugin guard enabled
     if request.app.cfg['plugin_guard']:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.