Commit 24cf091ded1d90b08a99dc3de7f31d6e47f337d6
1 parent
80163119
Exists in
master
and in
27 other branches
Fixing google cse tests
Showing
4 changed files
with
34 additions
and
33 deletions
Show diff stats
lib/noosfero/plugin/manager.rb
... | ... | @@ -90,10 +90,9 @@ class Noosfero::Plugin::Manager |
90 | 90 | end |
91 | 91 | end |
92 | 92 | |
93 | - def [](name) | |
94 | - klass = Noosfero::Plugin.klass(name) | |
93 | + def [](class_name) | |
95 | 94 | enabled_plugins.select do |plugin| |
96 | - plugin.kind_of?(klass) | |
95 | + plugin.kind_of?(class_name.constantize) | |
97 | 96 | end.first |
98 | 97 | end |
99 | 98 | ... | ... |
plugins/google_cse/controllers/google_cse_plugin_controller.rb
plugins/google_cse/views/google_cse_plugin/results.html.erb
0 → 100644
... | ... | @@ -0,0 +1,30 @@ |
1 | +<% plugin = @plugins['GoogleCsePlugin'] %> | |
2 | +<div id="cse" style="width: 100%;"><%= _('Loading') %></div> | |
3 | +<script src="//www.google.com/jsapi" type="text/javascript"></script> | |
4 | +<script type="text/javascript"> | |
5 | + function parseQueryFromUrl () { | |
6 | + var queryParamName = "q"; | |
7 | + var search = window.location.search.substr(1); | |
8 | + var parts = search.split('&'); | |
9 | + for (var i = 0; i < parts.length; i++) { | |
10 | + var keyvaluepair = parts[i].split('='); | |
11 | + if (decodeURIComponent(keyvaluepair[0]) == queryParamName) { | |
12 | + return decodeURIComponent(keyvaluepair[1].replace(/\+/g, ' ')); | |
13 | + } | |
14 | + } | |
15 | + return ''; | |
16 | + } | |
17 | + google.load('search', '1', {style : google.loader.themes.MINIMALIST}); | |
18 | + google.setOnLoadCallback(function() { | |
19 | + var customSearchControl = new google.search.CustomSearchControl( | |
20 | + '<%= plugin && plugin.google_id %>'); | |
21 | + customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET); | |
22 | + var options = new google.search.DrawOptions(); | |
23 | + options.enableSearchResultsOnly(); | |
24 | + customSearchControl.draw('cse', options); | |
25 | + var queryFromUrl = parseQueryFromUrl(); | |
26 | + if (queryFromUrl) { | |
27 | + customSearchControl.execute(queryFromUrl); | |
28 | + } | |
29 | + }, true); | |
30 | +</script> | ... | ... |
plugins/google_cse/views/google_cse_plugin/results.rhtml
... | ... | @@ -1,30 +0,0 @@ |
1 | -<% plugin = @plugins[:google_cse] %> | |
2 | -<div id="cse" style="width: 100%;"><%= _('Loading') %></div> | |
3 | -<script src="//www.google.com/jsapi" type="text/javascript"></script> | |
4 | -<script type="text/javascript"> | |
5 | - function parseQueryFromUrl () { | |
6 | - var queryParamName = "q"; | |
7 | - var search = window.location.search.substr(1); | |
8 | - var parts = search.split('&'); | |
9 | - for (var i = 0; i < parts.length; i++) { | |
10 | - var keyvaluepair = parts[i].split('='); | |
11 | - if (decodeURIComponent(keyvaluepair[0]) == queryParamName) { | |
12 | - return decodeURIComponent(keyvaluepair[1].replace(/\+/g, ' ')); | |
13 | - } | |
14 | - } | |
15 | - return ''; | |
16 | - } | |
17 | - google.load('search', '1', {style : google.loader.themes.MINIMALIST}); | |
18 | - google.setOnLoadCallback(function() { | |
19 | - var customSearchControl = new google.search.CustomSearchControl( | |
20 | - '<%= plugin && plugin.google_id %>'); | |
21 | - customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET); | |
22 | - var options = new google.search.DrawOptions(); | |
23 | - options.enableSearchResultsOnly(); | |
24 | - customSearchControl.draw('cse', options); | |
25 | - var queryFromUrl = parseQueryFromUrl(); | |
26 | - if (queryFromUrl) { | |
27 | - customSearchControl.execute(queryFromUrl); | |
28 | - } | |
29 | - }, true); | |
30 | -</script> |