You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by tv...@apache.org on 2013/08/20 15:28:44 UTC
[18/25] git commit: Added Gittip macro for Wiki tool
Added Gittip macro for Wiki tool
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/e81ffc0d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/e81ffc0d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/e81ffc0d
Branch: refs/heads/db/6482
Commit: e81ffc0d0a4ce5bdc7d5bef0c93122f8a6995514
Parents: afb7bb4
Author: Wayne Witzel III <wa...@pieceofpy.com>
Authored: Thu Aug 15 15:23:41 2013 -0400
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Mon Aug 19 19:40:13 2013 +0000
----------------------------------------------------------------------
.../templates/admin_widgets/metadata_admin.html | 2 ++
Allura/allura/lib/macro.py | 7 +++++++
Allura/allura/lib/utils.py | 3 ++-
Allura/allura/lib/widgets/macros.py | 6 ++++++
Allura/allura/templates/jinja_master/lib.html | 6 ++++++
.../allura/templates/widgets/gittip_button.html | 19 +++++++++++++++++++
Allura/allura/tests/test_globals.py | 6 ++++++
7 files changed, 48 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e81ffc0d/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html b/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
index 454f33a..bfce390 100644
--- a/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
+++ b/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
@@ -67,9 +67,11 @@
{{ widget.display_label(widget.fields.twitter_handle) }}
<br>
{{widget.display_field(widget.fields.twitter_handle) }}
+
{{ widget.display_label(widget.fields.facebook_page) }}
<br>
{{widget.display_field(widget.fields.facebook_page) }}
+
{% if c.project.neighborhood.features['google_analytics'] %}
{{ widget.display_label(widget.fields.tracking_id) }}
<br>
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e81ffc0d/Allura/allura/lib/macro.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/macro.py b/Allura/allura/lib/macro.py
index aac20ff..97d5206 100644
--- a/Allura/allura/lib/macro.py
+++ b/Allura/allura/lib/macro.py
@@ -294,6 +294,13 @@ def project_screenshots():
response = ps.display(project=c.project)
return response
+@macro()
+def gittip_button(username):
+ from allura.lib.widgets.macros import GittipButton
+ button = GittipButton(username=username)
+ g.resource_manager.register(button)
+ response = button.display(username=username)
+ return response
# FIXME: this is SourceForge specific - need to provide a way for macros to come from other packages
@macro()
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e81ffc0d/Allura/allura/lib/utils.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/utils.py b/Allura/allura/lib/utils.py
index d6796e5..4bd1e3c 100644
--- a/Allura/allura/lib/utils.py
+++ b/Allura/allura/lib/utils.py
@@ -502,6 +502,7 @@ class ForgeHTMLSanitizer(_HTMLSanitizer):
def unknown_starttag(self, tag, attrs):
if 'iframe' in self.acceptable_elements:
self.acceptable_elements.remove('iframe')
- if (tag == 'iframe') and (dict(attrs).get('src', '').startswith('http://www.youtube.com/embed/')):
+ if (tag == 'iframe') and (dict(attrs).get('src', '').startswith('http://www.youtube.com/embed/') or
+ dict(attrs).get('src', '').startswith('https://www.gittip.com/')):
self.acceptable_elements.append('iframe')
_HTMLSanitizer.unknown_starttag(self, tag, attrs)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e81ffc0d/Allura/allura/lib/widgets/macros.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/macros.py b/Allura/allura/lib/widgets/macros.py
index 0921ab9..5f93d2a 100644
--- a/Allura/allura/lib/widgets/macros.py
+++ b/Allura/allura/lib/widgets/macros.py
@@ -25,6 +25,12 @@ class Include(ew.Widget):
'style':'width:270px;float:right;background-color:#ccc'
}
+class GittipButton(ew.Widget):
+ template='jinja:allura:templates/widgets/gittip_button.html'
+ params=['username']
+ project=None
+
+
class DownloadButton(ew.Widget):
template='jinja:allura:templates/widgets/download_button.html'
params=['project']
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e81ffc0d/Allura/allura/templates/jinja_master/lib.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/lib.html b/Allura/allura/templates/jinja_master/lib.html
index a3e8d6b..9d8b3c1 100644
--- a/Allura/allura/templates/jinja_master/lib.html
+++ b/Allura/allura/templates/jinja_master/lib.html
@@ -706,6 +706,12 @@ allowed, permitting basic styling and layout: <div markdown style="float:left
[[download_button]]
</pre></div>
+<h2 id="md_ex_gittip_button{{id}}">Gittip Button</h2>
+<p>You can display a Gittip button in your wiki. You will need to set your gittip handle in the Metadata section of the Admin tool for your project.</p>
+<div class="codehilite"><pre>
+[[gittip_button username=foo]]
+</pre></div>
+
<h2 id="md_ex_member{{id}}">Project Member List</h2>
<p>You can display a list of project members. By default the list is limited to 20 members, and a link is provided to a page with the full list.</p>
<div class="codehilite"><pre>
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e81ffc0d/Allura/allura/templates/widgets/gittip_button.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/gittip_button.html b/Allura/allura/templates/widgets/gittip_button.html
new file mode 100644
index 0000000..708793a
--- /dev/null
+++ b/Allura/allura/templates/widgets/gittip_button.html
@@ -0,0 +1,19 @@
+{#-
+ 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.
+-#}
+<p><iframe style="border: 0; margin: 0; padding: 0;" src="https://www.gittip.com/{{username}}/widget.html" width="48pt" height="22pt"></iframe></p>
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e81ffc0d/Allura/allura/tests/test_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index 60860a5..526af04 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -148,6 +148,12 @@ def test_macro_download_button():
r = g.markdown_wiki.convert('[[download_button]]')
assert_equal(r, '<div class="markdown_content"><p><span class="download-button-%s" style="margin-bottom: 1em; display: block;"></span></p>\n</div>' % p_test._id)
+def test_macro_gittip_button():
+ p_nbhd = M.Neighborhood.query.get(name='Projects')
+ p_test = M.Project.query.get(shortname='test', neighborhood_id=p_nbhd._id)
+ with h.push_config(c, project=p_test):
+ r = g.markdown_wiki.convert('[[gittip_button username=test]]')
+ assert_equal(r, u'<div class="markdown_content"><p><iframe height="22pt" src="https://www.gittip.com/test/widget.html" style="border: 0; margin: 0; padding: 0;" width="48pt"></iframe></p>\n</div>')
def test_macro_neighborhood_feeds():
p_nbhd = M.Neighborhood.query.get(name='Projects')