Commits

Thomas Waldmann  committed 1ac84f1 Merge

merged default into namespaces branch

  • Participants
  • Parent commits ff503e7, b02d552
  • Branches namespaces

Comments (0)

Files changed (9)

File MoinMoin/conftest.py

 from MoinMoin.app import create_app_ext, destroy_app, before_wiki, teardown_wiki
 from MoinMoin._tests import wikiconfig
 from MoinMoin.storage import create_simple_mapping
-from flask import g as flaskg
 
 
 def init_test_app(given_config):

File MoinMoin/converter/_tests/test_include.py

 
         update_item(u'page1', {CONTENTTYPE: u'text/x.moin.wiki'}, u'{{logo}}')
         rendered = Item.create(u'page1').content._render_data()
-        assert '<img alt="logo" class="moin-transclusion"' in rendered
+        assert '<div class="moin-transclusion" data-href="/logo"><img alt="logo"' in rendered
 
         # <p /> is not valid html5; should be <p></p>. to be valid.  Even better, there should be no empty p's.
         update_item(u'page1', {CONTENTTYPE: u'text/x.moin.wiki'}, u'{{logo}}{{logo}}')

File MoinMoin/converter/html_out.py

 
 import re
 
+from flask import request
 from emeraldtree import ElementTree as ET
 
 from MoinMoin import wikiutil
 logging = log.getLogger(__name__)
 
 
+def convert_getlink_to_showlink(href):
+    """
+    If the incoming transclusion reference is within this domain, then remove "+get/<revision number>/".
+    """
+    if href.startswith('/'):
+        return re.sub(r'\+get/\+[0-9a-fA-F]+/', '', href)
+    return href
+
+def mark_item_as_transclusion(elem, href):
+    """
+    Return elem after adding a "moin-transclusion" class and a "data-href" attribute with
+    a link to the transcluded item.
+
+    On the client side, a Javascript function will wrap the element (or a parent element)
+    in a span or div and 2 overlay siblings will be created.
+    """
+    href = unicode(href)
+    # href will be "/wikiroot/SomeObject" or "/SomePage" for internal wiki items
+    # or "http://Some.Org/SomeThing" for external link
+    if elem.tag.name not in ('object', 'img'):
+        # XXX see issue #167: for wikis not running at root, only object and img elements have complete path
+        # if wiki is not running at server root, prefix href with wiki root
+        wiki_root = request.url_root[len(request.host_url):-1]
+        if wiki_root:
+            href = '/' + wiki_root + href
+    href = convert_getlink_to_showlink(href)
+    # data_href will create an attribute named data-href: any attribute beginning with "data-" passes html5 validation
+    elem.attrib[html.data_href] = href
+    classes = elem.attrib.get(html.class_, '').split()
+    classes.append('moin-transclusion')
+    elem.attrib[html.class_] = ' '.join(classes)
+    return elem
+
+
 class ElementException(RuntimeError):
     pass
 
     visit_style = Attribute('style')
     visit_title = Attribute('title')
     visit_id = Attribute('id')
+    visit_type = Attribute('type') # IE8 needs <object... type="image/svg+xml" ...> to display svg images
 
     def __init__(self, element):
         self.element = element
             return "object"
 
     def visit_moinpage_object(self, elem):
+        # TODO: maybe IE8 would display transcluded external pages if we could do <object... type="text/html" ...>
         href = elem.get(xlink.href, None)
         attrib = {}
         mimetype = Type(_type=elem.get(moin_page.type_, 'application/x-nonexistent'))
                 attrib[html.controls] = 'controls'
             new_elem = self.new_copy(getattr(html, obj_type), elem, attrib)
 
+        if obj_type == "object" and href.scheme:
+            # items similar to {{http://moinmo.in}} are marked here, other objects are marked in include.py
+            return mark_item_as_transclusion(new_elem, href)
         return new_elem
 
     def visit_moinpage_p(self, elem):

File MoinMoin/converter/include.py

 from MoinMoin import log
 logging = log.getLogger(__name__)
 
-from flask import request
 from flask import current_app as app
 from flask import g as flaskg
 
 from MoinMoin.items import Item
 from MoinMoin.util.mime import type_moin_document
 from MoinMoin.util.iri import Iri, IriPath
-from MoinMoin.util.tree import html, moin_page, xinclude, xlink
+from MoinMoin.util.tree import moin_page, xinclude, xlink
 
-from MoinMoin.converter.html_out import Attributes
-
-
-def convert_getlink_to_showlink(href):
-    """
-    If the incoming transclusion reference is within this domain, then remove "+get/<revision number>/".
-    """
-    if href.startswith('/'):
-        return re.sub(r'\+get/\+[0-9a-fA-F]+/', '', href)
-    return href
-
-def mark_item_as_transclusion(elem, href):
-    """
-    Return elem after adding a "moin-transclusion" class and a "data-href" attribute with
-    a link to the transcluded item.
-
-    On the client side, a Javascript function will wrap the element (or a parent element)
-    in a span or div and 2 overlay siblings will be created.
-    """
-    href = unicode(href)
-    # href will be "/wikiroot/SomeObject" or "/SomePage" for internal wiki items
-    # or "http://Some.Org/SomeThing" for external link
-    if elem.tag.name not in ('object', 'img'):
-        # XXX see issue #167: for wikis not running at root, only object and img elements have complete path
-        # if wiki is not running at server root, prefix href with wiki root
-        wiki_root = request.url_root[len(request.host_url):-1]
-        if wiki_root:
-            href = '/' + wiki_root + href
-    href = convert_getlink_to_showlink(href)
-    # data_href will create an attribute named data-href: any attribute beginning with "data-" passes html5 validation
-    elem.attrib[html.data_href] = href
-    classes = elem.attrib.get(html.class_, '').split()
-    classes.append('moin-transclusion')
-    elem.attrib[html.class_] = ' '.join(classes)
-    return elem
+from MoinMoin.converter.html_out import mark_item_as_transclusion, Attributes
 
 
 class XPointer(list):

File MoinMoin/templates/base.html

     {%- endif %}
     {% endblock %}
 
-    {% block head_scripts %}
-    <script src="{{ url_for('serve.files', name='jquery', filename='jquery.min.js') }}"></script>
-    <script src="{{ url_for('serve.files', name='svgweb', filename='svg.js') }}"></script>
-    <script src="{{ url_for('frontend.template', filename='common.js') }}"></script>
-    {{ scripts }}
-    <!--[if lt IE 9]>
-        {# TODO: use a local copy later #}
-        <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
-    <![endif]-->
-    <!--[if lt IE 8]>
-        {# required to save user settings with IE7 and earlier #}
-        <script src="{{ url_for('serve.files', name='json_js', filename='json2.js') }}"></script>
-    <![endif]-->
-    {% endblock %}
+
 {% endblock %}
 </head>
 <body{% if body_onload %} onload="{{ body_onload }}"{% endif %} lang="{{ theme_supp.ui_lang }}" dir="{{ theme_supp.ui_dir }}">
 {% endblock %}
 </div>
 
+{% block body_scripts %} {# js before </body> reduces IE8 js errors related to svgweb #}
+    <!--[if IE 8]>
+        <script src="{{ url_for('serve.files', name='svgweb', filename='svg.js') }}"></script>
+    <![endif]-->
+    <script src="{{ url_for('serve.files', name='jquery', filename='jquery.min.js') }}"></script>
+    <script src="{{ url_for('frontend.template', filename='common.js') }}"></script>
+    {{ scripts }}
+    <!--[if lt IE 9]>
+        {# TODO: use a local copy later #}
+        <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
+    <![endif]-->
+    <!--[if lt IE 8]>
+        {# required to save user settings with IE7 and earlier #}
+        <script src="{{ url_for('serve.files', name='json_js', filename='json2.js') }}"></script>
+    <![endif]-->
+{% endblock %}
+
 </body>
 </html>

File MoinMoin/templates/common.js

             if ($(elem).parent()[0].tagName === 'A') {
                 elem = $(elem).parent()[0];
             }
-            // wrap element, add UL and LR overlay siblings, and replace old elem with wrapped elem
-            $(wrapper).append($(elem).clone(true));
+            // insert wrapper after elem, append (move) elem, append overlays
+            $(elem).after(wrapper);
+            $(wrapper).append(elem);
             $(wrapper).append(overlayUL);
             $(wrapper).append(overlayLR);
-            $(elem).replaceWith(wrapper);
         }
     });
     // if an element was wrapped above, then make the Transclusions buttons visible
         MESSAGEOLD = ' {{ _("Your browser is old. Upgrade to gain auto-scroll page after edit feature.") }} ',
         OPERA = 'Opera', // special handling required because textareas have \r\n line endings
         modifyButton,
+        modifyForm,
         lineno,
         message,
         caretLineno;
                 textArea.setSelectionRange(scrolledText.length, scrolledText.length + 8);
                 setTimeout(function () {textArea.setSelectionRange(scrolledText.length, scrolledText.length + 4); }, 1000);
                 setTimeout(function () {textArea.setSelectionRange(scrolledText.length, scrolledText.length); }, 1500);
-            } else{
+            } else {
                 // IE8 workaround to position the caret and scroll textarea
                 setSelection(textArea, scrolledText.length);
             }
     } else {
         // provide reduced functionality for obsolete browsers that do not support local storage: IE6, IE7, etc.
         if (document.getElementById('moin-edit-on-doubleclick')) {
-            moinFlashMessage(MOINFLASHWARNING, MESSAGEOBSOLETE);
             modifyButton = $('.moin-modify-button')[0];
             if (modifyButton) {
-                // add doubleclick event handler when user doubleclicks within the content area
+                // this is a "show" page, add doubleclick event handler to content node
                 $('#moin-content').dblclick(function (e) {
                     document.location = modifyButton.href;
                 });
             }
+        } else {
+            modifyForm = $('#moin-modify')[0];
+            if (modifyForm) {
+                // user is editing with obsolete browser, give warning about missing features
+                moinFlashMessage(MOINFLASHWARNING, MESSAGEOBSOLETE);
+            }
         }
     }
 });

File MoinMoin/templates/forms.html

   </dd>
 {% endmacro %}
 
-{% macro render_file_uploader(submit_url) %}
+{% macro render_file_uploader(submit_url) %} {# pages that use this macro must also use file_uploader_scripts macro below #}
     <div id="file_upload">
         <div class="upload-form">
         <form action="{{ submit_url }}" method="POST" enctype="multipart/form-data" class="upload_file">
             </tr>
         </table>
     </div>
+{% endmacro %}
+{% macro file_uploader_scripts() %}
     <link rel="stylesheet" href="{{ url_for('serve.files', name='jquery_file_upload', filename='jquery.fileupload-ui.css') }}">
     <script src="{{ url_for('serve.files', name='jquery_file_upload', filename='jquery.fileupload.js') }}"></script>
     <script src="{{ url_for('serve.files', name='jquery_file_upload', filename='jquery.fileupload-ui.js') }}"></script>

File MoinMoin/templates/index.html

     {% set title = _("Global Index") %}
 {% endif %}
 
-{% block head_scripts %}
-{{ super() }}
-    <script src="{{ url_for('frontend.template', filename='index_action.js') }}"></script>
-{% endblock %}
-
 {% block action_bars_inner %}
     <ul>
-        {% if index %}
+        {% if dirs or files %}
         <li class="action-bar">
         <div class="moin-select-all">
             <span class="moin-select-allitem allitem-toselect" title="{{ _("Select All") }}">{{ _("Select All") }}</span>
             </div>
             <ul>
                 <li id="moin-create-newitem">{{ _("New item") }}</li>
-                {% if index %}
+                {% if dirs or files %}
                 <li id="moin-download-trigger">{{ _("Download") }}</li>
                 <li class="moin-action-tab"
                     id="moin-delete-trigger"
     {{ forms.render_file_uploader(submit_url) }}
     </div>
     <span class="moin-drag">{{ _("(Drag and drop multiple files to this white area to upload them.)") }}</span>
-    <script src="{{ url_for('static', filename='js/jfu.js') }}"></script>
     <div id="lightbox">&nbsp;</div>
 {% endblock %}
+
+{% block body_scripts %}
+{{ super() }}
+    <script src="{{ url_for('frontend.template', filename='index_action.js') }}"></script>
+    <script src="{{ url_for('static', filename='js/jfu.js') }}"></script>
+    {{ forms.file_uploader_scripts() }}
+{% endblock %}
         'Jinja2>=2.6', # template engine
         'pygments>=1.4', # src code / text file highlighting
         'Werkzeug>=0.8.1', # wsgi toolkit
-        'pytest>=2.1', # pytest is needed by unit tests
+        'pytest>=2.1, <2.3', # pytest is needed by unit tests
+                             # note: currently 2.3.x is not compatible with our test code,
+                             # likely due to the fixtures changes.
         'pytest-pep8', # coding style checker
         'whoosh>=2.4.0', # needed for indexed search
         'sphinx>=1.1', # needed to build the docs