You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by he...@apache.org on 2015/08/20 18:57:50 UTC
[2/9] allura git commit: [#7923] ticket:827 Make wiki "Create Page"
and "Subscribe/Unsubscribe" work from sidebar on admin pages
[#7923] ticket:827 Make wiki "Create Page" and "Subscribe/Unsubscribe" work from sidebar on admin pages
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/ac014139
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/ac014139
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/ac014139
Branch: refs/heads/hs/7963
Commit: ac0141399af95ffe552dba5076a3495c842b590f
Parents: 82a08dd
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Aug 14 12:04:45 2015 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Aug 18 22:17:59 2015 +0000
----------------------------------------------------------------------
Allura/allura/app.py | 7 +++++
.../templates/jinja_master/sidebar_menu.html | 5 ++++
.../templates/wiki/create_page_widget.html | 25 ++++++++++++++++++
ForgeWiki/forgewiki/templates/wiki/master.html | 9 -------
.../forgewiki/templates/wiki/page_view.html | 19 --------------
.../templates/wiki/wiki_subscribe_form.html | 27 ++++++++++++++++++++
ForgeWiki/forgewiki/widgets/wiki.py | 16 ++++++++++++
ForgeWiki/forgewiki/wiki_main.py | 17 ++++++++----
8 files changed, 92 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/ac014139/Allura/allura/app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index 2d748c5..46770af 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -581,6 +581,13 @@ class Application(object):
"""
return ""
+ def sidebar_menu_widgets(self):
+ """Return widgets needed by the sidebar menu of this Application.
+
+ :return: a list of widgets
+ """
+ return []
+
@LazyProperty
def _webhooks(self):
"""A list of webhooks that can be triggered by this app.
http://git-wip-us.apache.org/repos/asf/allura/blob/ac014139/Allura/allura/templates/jinja_master/sidebar_menu.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/sidebar_menu.html b/Allura/allura/templates/jinja_master/sidebar_menu.html
index df06d18..af70a48 100644
--- a/Allura/allura/templates/jinja_master/sidebar_menu.html
+++ b/Allura/allura/templates/jinja_master/sidebar_menu.html
@@ -89,6 +89,11 @@
</ul>
{% do ul_active.append(False) %}
{% endif %}
+ {% if c.app and c.app.sidebar_menu_widgets() %}
+ {% for w in c.app.sidebar_menu_widgets() %}
+ {{ w.display() }}
+ {% endfor %}
+ {% endif %}
{% if c.app and c.app.sidebar_menu_js() %}
<script>
{{c.app.sidebar_menu_js()|safe}}
http://git-wip-us.apache.org/repos/asf/allura/blob/ac014139/ForgeWiki/forgewiki/templates/wiki/create_page_widget.html
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/create_page_widget.html b/ForgeWiki/forgewiki/templates/wiki/create_page_widget.html
new file mode 100644
index 0000000..43ab051
--- /dev/null
+++ b/ForgeWiki/forgewiki/templates/wiki/create_page_widget.html
@@ -0,0 +1,25 @@
+{#-
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-#}
+<h1>Add a Wiki Page</h1>
+<form class="grid-10">
+ <label class="grid-2">Name</label>
+ <div class="grid-7"><input type="text" name="name"></div>
+ <label class="grid-2"> </label>
+ <div class="grid-7"><input type="submit" value="Create page"></div>
+</form>
http://git-wip-us.apache.org/repos/asf/allura/blob/ac014139/ForgeWiki/forgewiki/templates/wiki/master.html
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/master.html b/ForgeWiki/forgewiki/templates/wiki/master.html
index 529c483..9f0ada1 100644
--- a/ForgeWiki/forgewiki/templates/wiki/master.html
+++ b/ForgeWiki/forgewiki/templates/wiki/master.html
@@ -34,15 +34,6 @@
{% endblock %}
{% block extra_js %}
- {{c.create_page_lightbox.display(content='''
- <h1>Add a Wiki Page</h1>
- <form class="grid-10">
- <label class="grid-2">Name</label>
- <div class="grid-7"><input type="text" name="name"></div>
- <label class="grid-2"> </label>
- <div class="grid-7"><input type="submit" value="Create page"></div>
- </form>
- ''')}}
<script type="text/javascript">
$('.post-link').click(function () {
var version = $(this).data("dialog-id");
http://git-wip-us.apache.org/repos/asf/allura/blob/ac014139/ForgeWiki/forgewiki/templates/wiki/page_view.html
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/page_view.html b/ForgeWiki/forgewiki/templates/wiki/page_view.html
index 7a6135e..5762064 100644
--- a/ForgeWiki/forgewiki/templates/wiki/page_view.html
+++ b/ForgeWiki/forgewiki/templates/wiki/page_view.html
@@ -116,23 +116,4 @@
{% endif %}
{% endif %}
{{c.confirmation.display(content='')}}
- {% if not c.user.is_anonymous() %}
- <form action="{{c.app.url}}subscribe" id="wiki_subscribe_form" style="display:none;" method="POST">
- {{lib.csrf_token()}}
- {% if c.subscribed %}
- <input type="hidden" name="unsubscribe" value="1">
- {% else %}
- <input type="hidden" name="subscribe" value="1">
- {% endif %}
- </form>
- {% endif %}
{% endblock %}
-
-{% block wiki_extra_js %}
- <script type="text/javascript">
- $('a[href$="#toggle-subscribe"]').click(function() {
- $('#wiki_subscribe_form').submit();
- return false;
- })
- </script>
-{% endblock wiki_extra_js %}
http://git-wip-us.apache.org/repos/asf/allura/blob/ac014139/ForgeWiki/forgewiki/templates/wiki/wiki_subscribe_form.html
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/wiki_subscribe_form.html b/ForgeWiki/forgewiki/templates/wiki/wiki_subscribe_form.html
new file mode 100644
index 0000000..9ac328e
--- /dev/null
+++ b/ForgeWiki/forgewiki/templates/wiki/wiki_subscribe_form.html
@@ -0,0 +1,27 @@
+{#-
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-#}
+{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
+<form action="{{action}}" id="wiki_subscribe_form" class="hidden" method="POST">
+ {% if subscribed %}
+ <input type="hidden" name="unsubscribe" value="1">
+ {% else %}
+ <input type="hidden" name="subscribe" value="1">
+ {% endif %}
+ {{lib.csrf_token()}}
+</form>
http://git-wip-us.apache.org/repos/asf/allura/blob/ac014139/ForgeWiki/forgewiki/widgets/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/widgets/wiki.py b/ForgeWiki/forgewiki/widgets/wiki.py
index 7dc8b56..ffd2727 100644
--- a/ForgeWiki/forgewiki/widgets/wiki.py
+++ b/ForgeWiki/forgewiki/widgets/wiki.py
@@ -17,9 +17,11 @@
import ew.jinja2_ew as ew
from allura.lib.widgets import form_fields as ffw
+from allura.lib.widgets.forms import ForgeForm
class CreatePageWidget(ffw.Lightbox):
+ content_template='forgewiki:templates/wiki/create_page_widget.html'
def resources(self):
for r in super(CreatePageWidget, self).resources():
@@ -31,3 +33,17 @@ class CreatePageWidget(ffw.Lightbox):
return false;
});
});''')
+
+
+class WikiSubscribeForm(ForgeForm):
+ template='jinja:forgewiki:templates/wiki/wiki_subscribe_form.html'
+ defaults = dict(ForgeForm.defaults, subscribed=False)
+
+ def resources(self):
+ for r in super(WikiSubscribeForm, self).resources():
+ yield r
+ yield ew.JSScript("""
+ $('a[href$="#toggle-subscribe"]').click(function() {
+ $('#wiki_subscribe_form').submit();
+ return false;
+ })""")
http://git-wip-us.apache.org/repos/asf/allura/blob/ac014139/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index a43be58..8747e87 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -51,7 +51,7 @@ from allura.lib.widgets.search import SearchResults, SearchHelp
# Local imports
from forgewiki import model as WM
from forgewiki import version
-from forgewiki.widgets.wiki import CreatePageWidget
+from forgewiki.widgets.wiki import CreatePageWidget, WikiSubscribeForm
log = logging.getLogger(__name__)
@@ -279,6 +279,17 @@ The wiki uses [Markdown](%s) syntax.
def sidebar_menu(self):
return self.create_common_wiki_menu(has_access(self, 'create'), c.app.url, 'add_wiki_page')
+ @h.exceptionless([], log)
+ def sidebar_menu_widgets(self):
+ widgets = super(ForgeWikiApp, self).sidebar_menu_widgets()
+ widgets.append(W.create_page_lightbox)
+ if not c.user.is_anonymous():
+ form = WikiSubscribeForm(
+ action=self.url + 'subscribe',
+ subscribed=M.Mailbox.subscribed())
+ widgets.append(form)
+ return widgets
+
def install(self, project):
'Set up any default permissions and roles here'
self.config.options['project_name'] = project.name
@@ -336,7 +347,6 @@ The wiki uses [Markdown](%s) syntax.
class RootController(BaseController, DispatchIndex, FeedController):
def __init__(self):
- c.create_page_lightbox = W.create_page_lightbox
self._discuss = AppDiscussionController()
def _check_security(self):
@@ -483,9 +493,6 @@ class PageController(BaseController, FeedController):
app_config_id=c.app.config._id, title=self.title)
if self.page is not None:
self.attachment = WikiAttachmentsController(self.page)
- c.create_page_lightbox = W.create_page_lightbox
- if not c.user.is_anonymous():
- c.subscribed = M.Mailbox.subscribed()
def _check_security(self):
if self.page: