changeset 2851:5a49eeb1f307

add spaces to jinja2 expressions, add tests for missing spaces to coding_std.py
author RogerHaase <haaserd@gmail.com>
date Wed, 19 Nov 2014 11:51:19 -0700
parents 86b747edc4a7
children 97f5909dabcc
files MoinMoin/apps/admin/templates/admin/item_acl_report.html MoinMoin/apps/admin/templates/admin/trash.html MoinMoin/apps/admin/templates/admin/userbrowser.html MoinMoin/templates/ajaxsearch.html MoinMoin/templates/link_list_item_panel.html MoinMoin/templates/link_list_no_item_panel.html MoinMoin/templates/search.html MoinMoin/templates/show.html MoinMoin/templates/sitemap.html MoinMoin/templates/snippets.html MoinMoin/templates/ticket/base.html MoinMoin/templates/tickets.html MoinMoin/themes/basic/templates/layout.html MoinMoin/themes/basic/templates/modify.html MoinMoin/themes/basic/templates/show.html contrib/pep8/coding_std.py
diffstat 16 files changed, 64 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/admin/templates/admin/item_acl_report.html	Thu Nov 13 11:25:34 2014 -0700
+++ b/MoinMoin/apps/admin/templates/admin/item_acl_report.html	Wed Nov 19 11:51:19 2014 -0700
@@ -24,7 +24,7 @@
                     <td>
                         {% if user.may.admin(item['fqname']) %}
                             <form id="moin-acl-form" action="{{ url_for('admin.modify_acl', item_name=item['fqname']) }}" method="POST">
-                                <input type="text" class="moin-acl-string" {%if item['acl_default'] %}style="color:green;"{%endif%} name="{{ item['itemid'] }}" value="{{ item['acl'] }}"/>
+                                <input type="text" class="moin-acl-string" {% if item['acl_default'] %}style="color:green;"{% endif %} name="{{ item['itemid'] }}" value="{{ item['acl'] }}"/>
                                 <input type="submit" value="{{ _("Modify ACL") }}"/>
                             </form>
                         {% else %}
--- a/MoinMoin/apps/admin/templates/admin/trash.html	Thu Nov 13 11:25:34 2014 -0700
+++ b/MoinMoin/apps/admin/templates/admin/trash.html	Wed Nov 19 11:51:19 2014 -0700
@@ -18,7 +18,7 @@
                 </tr>
             </thead>
             <tbody>
-                {% for result in results| sort(attribute='mtime', reverse=True)%}
+                {% for result in results| sort(attribute='mtime', reverse=True) %}
                     <tr>
                         <td class="moin-wordbreak">{{ result.oldname|join(' | ') }}</td>
                         <td>{{ result.revid | shorten_id }}</td>
--- a/MoinMoin/apps/admin/templates/admin/userbrowser.html	Thu Nov 13 11:25:34 2014 -0700
+++ b/MoinMoin/apps/admin/templates/admin/userbrowser.html	Wed Nov 19 11:51:19 2014 -0700
@@ -13,7 +13,7 @@
         <tbody>
             {% for u in user_accounts %}
                 <tr>
-                    <td><a href="{{ url_for('frontend.show_item', item_name=u.fqname) }}">{{ u.name|join(', ') }}</a>{{ u.disabled and " (%s)" % _("disabled") or ""}}</td>
+                    <td><a href="{{ url_for('frontend.show_item', item_name=u.fqname) }}">{{ u.name|join(', ') }}</a>{{ u.disabled and " (%s)" % _("disabled") or "" }}</td>
                     <td>{{ u.groups|join(', ') }}</td>
                     <td>
                         {% if u.email %}
--- a/MoinMoin/templates/ajaxsearch.html	Thu Nov 13 11:25:34 2014 -0700
+++ b/MoinMoin/templates/ajaxsearch.html	Wed Nov 19 11:51:19 2014 -0700
@@ -29,9 +29,9 @@
                                 <td class="moin-wordbreak">
                                     {% if result['name'] %}
                                         {% if history %}
-                                            <a href="{{ url_for_item(item_name=result['revid'], wiki_name='Self', namespace=result['namespace'], field='revid') }}"><b>{{ result['name'] | join(' | ')}}</b></a>
+                                            <a href="{{ url_for_item(item_name=result['revid'], wiki_name='Self', namespace=result['namespace'], field='revid') }}"><b>{{ result['name'] | join(' | ') }}</b></a>
                                         {% else %}
-                                            <a href="{{ url_for_item(item_name=result['name'][0], wiki_name='Self', namespace=result['namespace']) }}"><b>{{ result['name'] | join(' | ')}}</b></a>
+                                            <a href="{{ url_for_item(item_name=result['name'][0], wiki_name='Self', namespace=result['namespace']) }}"><b>{{ result['name'] | join(' | ') }}</b></a>
                                         {% endif %}
                                     {% else %}
                                         <a href="{{ url_for_item(item_name=result['revid'], wiki_name='Self', namespace=result['namespace'], field='revid') }}"><b>Item ID : {{ result['itemid'] }}</b></a>
--- a/MoinMoin/templates/link_list_item_panel.html	Thu Nov 13 11:25:34 2014 -0700
+++ b/MoinMoin/templates/link_list_item_panel.html	Wed Nov 19 11:51:19 2014 -0700
@@ -7,7 +7,7 @@
         Total: {{ fq_names|count }}
         <ul class="moin-link-list">
             {% for fq_name in fq_names|sort(attribute='value') %}
-                <li><a class="moin-fqname" href="{{ url_for('frontend.show_item', item_name=fq_name) }}" data-fqname="{{fq_name}}">{{ fq_name.value }}</a></li>
+                <li><a class="moin-fqname" href="{{ url_for('frontend.show_item', item_name=fq_name) }}" data-fqname="{{ fq_name }}">{{ fq_name.value }}</a></li>
             {% endfor %}
         </ul>
     {% endif %}
--- a/MoinMoin/templates/link_list_no_item_panel.html	Thu Nov 13 11:25:34 2014 -0700
+++ b/MoinMoin/templates/link_list_no_item_panel.html	Wed Nov 19 11:51:19 2014 -0700
@@ -10,7 +10,7 @@
                 <li>
                     <a class="moin-fqname"
                        href="{{ url_for('frontend.show_item', item_name=fq_name) }}"
-                       data-fqname="{{fq_name}}">
+                       data-fqname="{{ fq_name }}">
                            {{ fq_name.value }}
                     </a>
                 </li>
--- a/MoinMoin/templates/search.html	Thu Nov 13 11:25:34 2014 -0700
+++ b/MoinMoin/templates/search.html	Wed Nov 19 11:51:19 2014 -0700
@@ -10,7 +10,7 @@
 {% endblock %}
 
 {% block content %}
-    <h1>{{_("Search")}}</h1>
+    <h1>{{ _("Search") }}</h1>
     {{ gen.form.open(medium_search_form, id='moin-long-searchform', method='get', action=url_for('frontend.search', item_name=item_name)) }}
         <p>
             {{ forms.render(medium_search_form['q']) }}
--- a/MoinMoin/templates/show.html	Thu Nov 13 11:25:34 2014 -0700
+++ b/MoinMoin/templates/show.html	Wed Nov 19 11:51:19 2014 -0700
@@ -75,7 +75,7 @@
 {% endblock %}
 
 {% block footer_meta %}
-    {{footer_meta}}
+    {{ footer_meta }}
 {% endblock %}
 
 {% block options_for_javascript %}
--- a/MoinMoin/templates/sitemap.html	Thu Nov 13 11:25:34 2014 -0700
+++ b/MoinMoin/templates/sitemap.html	Wed Nov 19 11:51:19 2014 -0700
@@ -20,7 +20,7 @@
                     <a href="{{ url_for('frontend.sitemap', item_name=entry) }}">
                         <span class="fa fa-sitemap"></span>
                     </a>
-                    <a class="moin-fqname" href="{{ url_for('frontend.show_item', item_name=entry) }}" data-fqname="{{entry}}">
+                    <a class="moin-fqname" href="{{ url_for('frontend.show_item', item_name=entry) }}" data-fqname="{{ entry }}">
                         {{ entry.value }}
                     </a>
                 </li>
--- a/MoinMoin/templates/snippets.html	Thu Nov 13 11:25:34 2014 -0700
+++ b/MoinMoin/templates/snippets.html	Wed Nov 19 11:51:19 2014 -0700
@@ -74,7 +74,7 @@
             {% if cfg.show_interwiki %}
                 {{ cfg.interwikiname }}:
             {% endif %}
-            {{ item_name }} (rev {{rev.revid | shorten_id}}),
+            {{ item_name }} (rev {{ rev.revid | shorten_id }}),
             {{ _("modified") }} {{ rev.meta['mtime']|datetimeformat }}
             {{ _("by") }} {{ utils.editor_info(rev.meta) }}
             {% if item.meta['tags'] %}
--- a/MoinMoin/templates/ticket/base.html	Thu Nov 13 11:25:34 2014 -0700
+++ b/MoinMoin/templates/ticket/base.html	Wed Nov 19 11:51:19 2014 -0700
@@ -23,7 +23,7 @@
         {{ forms.render(form['meta'][e]) }}
         {% if e!='assigned_to' and item.meta[e] %}
             <dd>
-                <a class="moin-ticket-link"  href="{{ url_for_item(item.meta[e], field='itemid') }}">{{item.meta[e]|shorten_id}}</a>
+                <a class="moin-ticket-link"  href="{{ url_for_item(item.meta[e], field='itemid') }}">{{ item.meta[e]|shorten_id }}</a>
             </dd>
         {% endif %}
     {% endfor %}
--- a/MoinMoin/templates/tickets.html	Thu Nov 13 11:25:34 2014 -0700
+++ b/MoinMoin/templates/tickets.html	Wed Nov 19 11:51:19 2014 -0700
@@ -3,19 +3,19 @@
 {% set title = _("Tickets") %}
 
 {% block content %}
-    <h1>{{_("Tickets")}}</h1>
+    <h1>{{ _("Tickets") }}</h1>
 
     {% set status_values = ['all', 'open', 'closed']  %}
-    <span>{{_("Filter:")}}</span>
+    <span>{{ _("Filter:") }}</span>
     {% for status_value in status_values %}
         <form action="{{ url_for('frontend.tickets', selected_tags=list(), time_sorting=time_sorting if time_sorting) }}" method="post" class='moin-ticketsearch-form'>
             <input type="hidden" name="q" value="" >
             <input type="hidden" name="status" value="{{ status_value }}">
-            <input type="submit" value="{{ status_value.capitalize() }}" title="{{ _('Show %(status)s tickets', status=status_value) }}" class="{{ 'ticket-query-button active' if status == status_value  else 'ticket-query-button'}}">
+            <input type="submit" value="{{ status_value.capitalize() }}" title="{{ _('Show %(status)s tickets', status=status_value) }}" class="{{ 'ticket-query-button active' if status == status_value  else 'ticket-query-button' }}">
         </form>
     {% endfor %}
 
-    <input type="button" class="ticket-tags-button ticket-tags-toggle" title="{{_("Show all tags")}}" value="{{_("Tags")}}">
+    <input type="button" class="ticket-tags-button ticket-tags-toggle" title="{{ _("Show all tags") }}" value="{{ _("Tags") }}">
 
     <div class="tickets-sort-button dropdown">
         <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown">
@@ -24,7 +24,7 @@
             {% elif time_sorting == 'old' %}
                 {% set sortedby = 'Least recently updated' %}
             {% endif %}
-            {{_("Sort: %(sortedby)s", sortedby=sortedby if sortedby)}}
+            {{ _("Sort: %(sortedby)s", sortedby=sortedby if sortedby) }}
             <span class="caret"></span>
         </button>
         <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
@@ -33,7 +33,7 @@
                     <input type="hidden" name="status" value="{{ status }}">
                     <input type="hidden" name="q" value="{{ query if query }}" >
                     <button type="submit">
-                        {{_("Recently updated")}}
+                        {{ _("Recently updated") }}
                     </button>
                 </form>
             </li>
@@ -42,7 +42,7 @@
                     <input type="hidden" name="status" value="{{ status }}">
                     <input type="hidden" name="q" value="{{ query if query }}" >
                     <button type="submit">
-                        {{_("Least Recently updated")}}
+                        {{ _("Least Recently updated") }}
                     </button>
                 </form>
             </li>
@@ -51,7 +51,7 @@
 
     <form class="moin-ticket-search" action="{{ url_for('frontend.tickets',selected_tags=list(selected_tags), time_sorting=time_sorting if time_sorting) }}" method="post">
         <input type="hidden" name="status" value="{{ status }}">
-        <input type="text" name="q" value="{{ query if query }}" id="moin-ticketsearch-query" placeholder="{{_('Find tickets')}}">
+        <input type="text" name="q" value="{{ query if query }}" id="moin-ticketsearch-query" placeholder="{{ _('Find tickets') }}">
     </form>
 
     {# TODO: This is a workaround that creates named tickets, rework when there is a means of creating unnamed tickets #}
@@ -61,7 +61,7 @@
     </form>
 
     <div class="moin-ticket-tags">
-        <span>{{_("Tags:")}}</span>
+        <span>{{ _("Tags:") }}</span>
         {% for tag in tags|sort %}
             {# If user clicks on the tag then it gets selected if it is not already selected #}
             {# If that tag is already selected then it gets deselected #}
@@ -79,25 +79,25 @@
         <table class="table table-hover" id="ticket-list">
             <thead>
                 <tr>
-                    <th id="ticket-itemid">{{_("ID")}}</th>
-                    <th id="ticket-summary">{{_("Summary")}}</th>
-                    <th id="ticket-status">{{_("Status")}}</th>
+                    <th id="ticket-itemid">{{ _("ID") }}</th>
+                    <th id="ticket-summary">{{ _("Summary") }}</th>
+                    <th id="ticket-status">{{ _("Status") }}</th>
                     <th id="ticket-effort" title="{{ _('Effort') }}">E</th>
                     <th id="ticket-difficulty" title="{{ _('Difficulty') }}">D</th>
                     <th id="ticket-severity" title="{{ _('Severity') }}">S</th>
                     <th id="ticket-priority" title="{{ _('Priority') }}">P</th>
-                    <th id="ticket-tags">{{_("Tags")}}</th>
+                    <th id="ticket-tags">{{ _("Tags") }}</th>
                 </tr>
             </thead>
             <tbody>
                 {% for result in results %}
                     <tr>
                         <td>
-                            <a href="{{  url_for_item(result['itemid'], field='itemid', namespace=result['namespace'])}}" title="{{ _('ITEMID: %(itemid)s', itemid=result['itemid'])}}">
-                                {{result['itemid'] | shorten_id}}
+                            <a href="{{ url_for_item(result['itemid'], field='itemid', namespace=result['namespace']) }}" title="{{ _('ITEMID: %(itemid)s', itemid=result['itemid']) }}">
+                                {{ result['itemid'] | shorten_id }}
                             </a>
                         <td>
-                            <a href="{{  url_for_item(result['itemid'], field='itemid', namespace=result['namespace'])}}" title="{{ _('ITEMID: %(itemid)s', itemid=result['itemid'])}}">
+                            <a href="{{ url_for_item(result['itemid'], field='itemid', namespace=result['namespace']) }}" title="{{ _('ITEMID: %(itemid)s', itemid=result['itemid']) }}">
                                 {{ result['summary'] }}
                             </a>
                         </td>
@@ -127,7 +127,7 @@
         </table>
 
         <p id="ticket-table-tip">
-            {{_("Tip: Sort multiple columns simultaneously by holding down the Shift key and clicking on additional column headers!")}}
+            {{ _("Tip: Sort multiple columns simultaneously by holding down the Shift key and clicking on additional column headers!") }}
         </p>
     {% else %}
         {{ _("No Ticket found.") }}
--- a/MoinMoin/themes/basic/templates/layout.html	Thu Nov 13 11:25:34 2014 -0700
+++ b/MoinMoin/themes/basic/templates/layout.html	Wed Nov 19 11:51:19 2014 -0700
@@ -41,7 +41,7 @@
         {% if title %} title="{{ title }}" {% endif %}>
         {% if iconcls %} <i class="{{ iconcls }}"> </i> {% endif %}
         {% if href == login_url %}
-            {{label }}
+            {{ label }}
         {% else %}
             <span class="hidden-sm hidden-xs">{{ label }}</span>
         {% endif %}
@@ -50,8 +50,8 @@
 
 {# Helper macro to generate a search form #}
 {% macro make_search_form(klass, clas) %}
-    <div class="{{klass}}">
-        <form class="{{clas}}" action="{{ url_for('frontend.search') }}" method="get" role="search">
+    <div class="{{ klass }}">
+        <form class="{{ clas }}" action="{{ url_for('frontend.search') }}" method="get" role="search">
             <div class="input-group">
                 <input name='q' type="text" class="form-control" placeholder="Search ...">
                 <div class="input-group-btn">
@@ -156,14 +156,14 @@
                                                 {{ hyperlink(wiki_href, title, exists, aliasname, "fa fa-user fa-inverse", None) }}
                                             </li>
                                             {% if 'frontend.usersettings' not in cfg.endpoints_excluded -%}
-                                                <li title="{{_('Settings')}}">
+                                                <li title="{{ _('Settings') }}">
                                                     {{ hyperlink(url_for('frontend.usersettings'), None, True,
                                                         _('Settings'), "fa fa-cog fa-inverse", None) }}
                                                 </li>
                                             {%- endif %}
                                         {%- endif %}
                                         {% if user.auth_method in cfg.auth_can_logout %}
-                                            <li title="{{_('Logout')}}">
+                                            <li title="{{ _('Logout') }}">
                                                 {{ hyperlink(url_for('frontend.logout', logout_submit=1), None, True,
                                                         _('Logout'), "fa fa-sign-out fa-inverse", None) }}
                                             </li>
--- a/MoinMoin/themes/basic/templates/modify.html	Thu Nov 13 11:25:34 2014 -0700
+++ b/MoinMoin/themes/basic/templates/modify.html	Wed Nov 19 11:51:19 2014 -0700
@@ -5,11 +5,11 @@
 {% import theme("itemviews.html") as itemviews with context %}
 {% import theme(form['content_form'].template) as content_template %}
 {% set extra_head = content_template.extra_head %}
-{%if content_template.basic_data_editor is defined%}
+{% if content_template.basic_data_editor is defined %}
     {% set data_editor = content_template.basic_data_editor %}
-{%else%}
+{% else %}
     {% set data_editor = content_template.data_editor %}
-{%endif%}
+{% endif %}
 {% set title = _("Modifying '%(item_name)s'", item_name=item_name) %}
 
 {% block head %}
--- a/MoinMoin/themes/basic/templates/show.html	Thu Nov 13 11:25:34 2014 -0700
+++ b/MoinMoin/themes/basic/templates/show.html	Wed Nov 19 11:51:19 2014 -0700
@@ -84,7 +84,7 @@
 {% endblock %}
 
 {% block footer_meta %}
-    {{footer_meta }}
+    {{ footer_meta }}
 {% endblock %}
 
 {% block options_for_javascript %}
--- a/contrib/pep8/coding_std.py	Thu Nov 13 11:25:34 2014 -0700
+++ b/contrib/pep8/coding_std.py	Wed Nov 19 11:51:19 2014 -0700
@@ -19,6 +19,7 @@
 
 import sys
 import os
+import re
 
 
 # file types to be processed
@@ -145,6 +146,30 @@
                 logger.log(filename, u"Non-standard dedent before line %d -- not fixed!" % (idx + 1))
 
 
+def check_template_spacing(lines, filename, logger):
+    """
+    Create message if there is not a blank afer {{, {%, {%-, {# and before }}, %}, -%}, #}.
+    """
+    pattern = re.compile(r'(\{[{#]\S)|(\S[}#]\})')
+    for idx, line in enumerate(lines):
+        # log missing spaces in {{myfunction}} and {#my comment#}
+        m = pattern.search(line)
+        if m:
+            logger.log(filename, u"Missing space within %s on line %d - not fixed!" % (m.group(0), idx + 1))
+        # log missing spaces in {%if something... and {%-if something...
+        m = [m.start() for m in re.finditer('{%', line)]
+        if m:
+            for index in m:
+                if not line.startswith((' ', '- '), index + 2):
+                    logger.log(filename, 'Missing space within %s on line %d - not fixed!' % (line[index:index + 4], idx + 1))
+        # log missing spaces in ...something%} and ...something-%}
+        m = [m.start() for m in re.finditer('%}', line)]
+        if m:
+            for index in m:
+                if not line.endswith((' ', ' -'), 0, index):
+                    logger.log(filename, 'Missing space within %s on line %d - not fixed!' % (line[index - 2:index + 2], idx + 1))
+
+
 def check_files(filename, suffix):
     """
     Delete trailing blanks, single linefeed at file end, line ending to be \r\n for bat files and \n for all others.
@@ -161,6 +186,7 @@
 
     if filename.endswith('.html'):
         check_template_indentation(lines, filename, logger)
+        check_template_spacing(lines, filename, logger)
 
     # now look at file end and get rid of all whitespace-only lines there:
     while lines: