changeset 466:7754844a1dbe

branch merged with main repo
author Akash Sinha <akash2607@gmail.com>
date Mon, 13 Jun 2011 02:12:21 +0530
parents 3076415fdaba (current diff) 37c117ad8f7e (diff)
children 71988ea0f53e
files MoinMoin/apps/frontend/views.py MoinMoin/themes/modernized/static/css/common.css
diffstat 9 files changed, 41 insertions(+), 93 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/__init__.py	Mon Jun 13 02:08:44 2011 +0530
+++ b/MoinMoin/apps/__init__.py	Mon Jun 13 02:12:21 2011 +0530
@@ -0,0 +1,13 @@
+# Copyright: 2011 MoinMoin:ThomasWaldmann
+# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
+
+"""
+MoinMoin - flask modules for better modularization
+
+This package contains some Flask Modules:
+
+- frontend has all usual wiki user interface code
+- feed Module for all feed-like stuff
+- admin Module for special stuff for wiki admins
+- serve Module for static file serving
+"""
--- a/MoinMoin/items/__init__.py	Mon Jun 13 02:08:44 2011 +0530
+++ b/MoinMoin/items/__init__.py	Mon Jun 13 02:12:21 2011 +0530
@@ -28,7 +28,6 @@
 
 from MoinMoin.security.textcha import TextCha, TextChaizedForm, TextChaValid
 from MoinMoin.signalling import item_modified
-from MoinMoin.util.forms import make_generator
 from MoinMoin.util.mimetype import MimeType
 from MoinMoin.util.mime import Type, type_moin_document
 from MoinMoin.util.tree import moin_page, html, xlink, docbook
@@ -721,7 +720,6 @@
                                rows_meta=str(ROWS_META), cols=str(COLS),
                                help=self.modify_help,
                                form=form,
-                               gen=make_generator(),
                               )
 
     copy_template = 'copy.html'
@@ -1186,7 +1184,6 @@
                                rows_data=str(ROWS_DATA), rows_meta=str(ROWS_META), cols=str(COLS),
                                help=self.modify_help,
                                form=form,
-                               gen=make_generator(),
                               )
 
 item_registry.register(Text._factory, Type('text/*'))
@@ -1376,7 +1373,6 @@
                                rows_meta=str(ROWS_META), cols=str(COLS),
                                help=self.modify_help,
                                form=form,
-                               gen=make_generator(),
                               )
 
     def _render_data(self):
@@ -1474,7 +1470,6 @@
                                help=self.modify_help,
                                drawing_exists=drawing_exists,
                                form=form,
-                               gen=make_generator(),
                               )
 
     def _render_data(self):
@@ -1558,7 +1553,6 @@
                                rows_meta=str(ROWS_META), cols=str(COLS),
                                help=self.modify_help,
                                form=form,
-                               gen=make_generator(),
                               )
 
     def _render_data(self):
--- a/MoinMoin/static/js/common.js	Mon Jun 13 02:08:44 2011 +0530
+++ b/MoinMoin/static/js/common.js	Mon Jun 13 02:12:21 2011 +0530
@@ -4,43 +4,6 @@
 
 var QUICKLINKS_EXPAND = ">>>";
 var QUICKLINKS_COLLAPSE = "<<<";
-// We keep here the state of the search box
-searchIsDisabled = false;
-
-function searchChange(e) {
-    // Update search buttons status according to search box content.
-    // Ignore empty or whitespace search term.
-    var value = e.value.replace(/\s+/, '');
-    if (value == '' || searchIsDisabled) {
-        searchSetDisabled(true);
-    } else {
-        searchSetDisabled(false);
-    }
-}
-
-function searchSetDisabled(flag) {
-    // Enable or disable search
-    document.getElementById('moin-fullsearch').disabled = flag;
-    document.getElementById('moin-titlesearch').disabled = flag;
-}
-
-function searchFocus(e) {
-    // Update search input content on focus
-    if (e.value == search_hint) {
-        e.value = '';
-        e.className = '';
-        searchIsDisabled = false;
-    }
-}
-
-function searchBlur(e) {
-    // Update search input content on blur
-    if (e.value == '') {
-        e.value = search_hint;
-        e.className = 'disabled';
-        searchIsDisabled = true;
-    }
-}
 
 // use this instead of assigning to window.onload directly:
 function addLoadEvent(func) {
@@ -786,28 +749,6 @@
         this.selectedIndex = 0;
     });
 
-    // Functions related to search form
-    var e = document.getElementById('moin-searchinput');
-    searchChange(e);
-    searchBlur(e);
-
-    $('#moin-searchinput').blur(function(){
-        searchBlur(this);
-    });
-
-    $('#moin-searchinput').focus(function(){
-        searchFocus(this);
-    });
-
-    $('#moin-searchinput').change(function(){
-        searchChange(this);
-    });
-
-    $('#moin-searchinput').keyup(function(){
-        searchChange(this);
-    });
-
-
 });
 
 // Insert Zero-Width-Space characters into long text strings of textNode elements.
--- a/MoinMoin/storage/_tests/test_middleware_acl.py	Mon Jun 13 02:08:44 2011 +0530
+++ b/MoinMoin/storage/_tests/test_middleware_acl.py	Mon Jun 13 02:12:21 2011 +0530
@@ -45,7 +45,7 @@
 
     def test_noaccess(self):
         name = u"noaccess"
-        self.create_item_acl(name, "All:")
+        self.create_item_acl(name, u"All:")
         assert py.test.raises(AccessDeniedError, self.get_item, name)
 
     def test_create_item(self):
@@ -56,7 +56,7 @@
         backend = flaskg.storage
         assert py.test.raises(AccessDeniedError, backend.create_item, u"I will never exist")
 
-        item = self.create_item_acl(u"i will exist!", "All:read,write")
+        item = self.create_item_acl(u"i will exist!", u"All:read,write")
         rev = item.create_revision(1)
         data = "my very existent data"
         rev.write(data)
@@ -65,7 +65,7 @@
 
     def test_read_access_allowed(self):
         name = u"readaccessallowed"
-        self.create_item_acl(name, "All:read")
+        self.create_item_acl(name, u"All:read")
         # Should simply pass...
         item = self.get_item(name)
 
@@ -75,12 +75,12 @@
 
     def test_write_after_create(self):
         name = u"writeaftercreate"
-        item = self.create_item_acl(name, "All:")
+        item = self.create_item_acl(name, u"All:")
         assert py.test.raises(AccessDeniedError, item.create_revision, 1)
 
     def test_modify_without_acl_change(self):
         name = u"copy_without_acl_change"
-        acl = "All:read,write"
+        acl = u"All:read,write"
         self.create_item_acl(name, acl)
         item = self.get_item(name)
         rev = item.create_revision(1)
@@ -90,15 +90,16 @@
 
     def test_copy_with_acl_change(self):
         name = u"copy_with_acl_change"
-        acl = "All:read,write"
+        acl = u"All:read,write"
         self.create_item_acl(name, acl)
         item = self.get_item(name)
         rev = item.create_revision(1)
-        py.test.raises(AccessDeniedError, rev.__setitem__, ACL, acl + ",write")
+        # without admin rights it is disallowed to change ACL
+        py.test.raises(AccessDeniedError, rev.__setitem__, ACL, acl + u",destroy")
 
     def test_write_without_read(self):
         name = u"write_but_not_read"
-        acl = "All:write"
+        acl = u"All:write"
         item = flaskg.storage.create_item(name)
         rev = item.create_revision(0)
         rev[ACL] = acl
--- a/MoinMoin/storage/backends/acl.py	Mon Jun 13 02:08:44 2011 +0530
+++ b/MoinMoin/storage/backends/acl.py	Mon Jun 13 02:12:21 2011 +0530
@@ -168,14 +168,15 @@
             item = self.backend.get_item(itemname)
             # we always use the ACLs set on the latest revision:
             current_rev = item.get_revision(-1)
-            acls = current_rev[ACL]
+            acl = current_rev[ACL]
+            if not isinstance(acl, unicode):
+                raise TypeError("%s metadata has unsupported type: %r" % (ACL, acl))
+            acls = [acl, ]
         except (NoSuchItemError, NoSuchRevisionError, KeyError):
             # do not use default acl here
             acls = []
-        if not isinstance(acls, (tuple, list)):
-            acls = (acls, )
         default = self.default.default
-        return ContentACL(self.cfg, acls, default=default, valid=self.valid)
+        return ContentACL(self.cfg, tuple(acls), default=default, valid=self.valid)
 
     def _may(self, itemname, right, username=None):
         """ Check if username may have <right> access on item <itemname>.
@@ -482,7 +483,7 @@
                 last_rev = self._item.get_revision(-1)
                 last_acl = last_rev[ACL]
             except (NoSuchRevisionError, KeyError):
-                last_acl = ''
+                last_acl = u''
 
             acl_changed = value != last_acl
 
--- a/MoinMoin/templates/base.html	Mon Jun 13 02:08:44 2011 +0530
+++ b/MoinMoin/templates/base.html	Mon Jun 13 02:12:21 2011 +0530
@@ -55,11 +55,6 @@
         {# TODO: use a local copy later #}
         <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
     <![endif]-->
-    <script>
-        <!--
-        var search_hint = " {{ _('Search') }}";
-        //-->
-    </script>
     {% endblock %}
 {% endblock %}
 </head>
--- a/MoinMoin/templates/layout.html	Mon Jun 13 02:08:44 2011 +0530
+++ b/MoinMoin/templates/layout.html	Mon Jun 13 02:12:21 2011 +0530
@@ -1,3 +1,4 @@
+{% import "forms.html" as forms %}
 {% extends "base.html" %}
 
 {% import "snippets.html" as snippets with context %}
@@ -17,16 +18,15 @@
 
 <div id="moin-header">
 {% block header %}
-    <form id="moin-searchform" method="get" action="{{ url_for('frontend.search') }}">
+    {% if search_form %} 
+    {{ gen.form.open(search_form, id='moin-searchform', method='get', action=url_for('frontend.show_item', item_name=item_name)) }}
         <div>
-            <input type="hidden" name="do" value="fullsearch" />
-            <input type="hidden" name="context" value="180" />
-            <label for="moin-searchinput">{{ _('Search') }}</label>
-            <input id="moin-searchinput" type="search" name="value" value="{{ request.values.get('value', '') }}" size="20" />
-            <input id="moin-titlesearch" name="titlesearch" type="submit" value="{{ _('Titles') }}" />
-            <input id="moin-fullsearch" name="fullsearch" type="submit" value="{{ _('Text') }}" />
+            {{ gen.input(search_form['q'], type='search', id='moin-search-query', size='30') }}
+            {{ gen.input(search_form['submit'], type='submit') }}
+            {{ forms.render_errors(search_form) }}
         </div>
-    </form>
+    {{ gen.form.close() }}
+    {% endif %} 
 
     {% if logo %}
     <div id="moin-logo">
--- a/MoinMoin/themes/__init__.py	Mon Jun 13 02:08:44 2011 +0530
+++ b/MoinMoin/themes/__init__.py	Mon Jun 13 02:12:21 2011 +0530
@@ -23,6 +23,7 @@
 from MoinMoin.config import USERID, ADDRESS, HOSTNAME
 from MoinMoin.util.interwiki import split_interwiki, resolve_interwiki, join_wiki, getInterwikiHome
 from MoinMoin.util.crypto import cache_key
+from MoinMoin.util.forms import make_generator
 
 
 def get_current_theme():
@@ -392,5 +393,6 @@
                             'cfg': app.cfg,
                             'item_name': 'handlers need to give it',
                             'get_editor_info': lambda rev: get_editor_info(rev),
+                            'gen': make_generator(),
                             })
 
--- a/MoinMoin/themes/modernized/static/css/common.css	Mon Jun 13 02:08:44 2011 +0530
+++ b/MoinMoin/themes/modernized/static/css/common.css	Mon Jun 13 02:12:21 2011 +0530
@@ -483,12 +483,13 @@
             line-height: 1.12em; }
 
 /* moin-header searchform */
-#moin-searchform { margin: 8px .5em; padding: 0; font-size: 0.82em; float: right;  text-align: right; }
+#moin-searchform { margin: 8px .5em; padding: 0; font-size: 0.82em; float: right;  text-align: left; }
 #moin-searchform input { font-size: 100%; vertical-align: middle;
             background-color: #F3F7FD; /* same as body bg col */
             border: 1px solid #A4B9DF; }
-#moin-searchform label { display:none; }
 #moin-searchform div { margin: 0; }
+#moin-searchform ul { border: 1px solid #A4B9DF; margin: 0; padding: 0; background-color: #F3F7FD; }
+#moin-searchform li { list-style:none; }
 
 /* moin-header moin-logo -- logos may be text only */
 #moin-logo { float: left; margin: 5px 10px; padding: 0; font-size: 1.4em; line-height: 1em; font-weight: bold; }