Commit 4e34a473f90b72953141d94b9887a81cfe82e2e7
Exists in
master
and in
22 other branches
Merge branch 'master' of gitorious.org:noosfero/noosfero
Showing
40 changed files
with
208 additions
and
52 deletions
Show diff stats
INSTALL
@@ -237,6 +237,10 @@ Create the database structure: | @@ -237,6 +237,10 @@ Create the database structure: | ||
237 | 237 | ||
238 | $ RAILS_ENV=production rake db:schema:load | 238 | $ RAILS_ENV=production rake db:schema:load |
239 | 239 | ||
240 | +Compile the translations: | ||
241 | + | ||
242 | +$ RAILS_ENV=production rake noosfero:translations:compile | ||
243 | + | ||
240 | Now we have to create some initial data. To create your default environment | 244 | Now we have to create some initial data. To create your default environment |
241 | (the first one), run the command below: | 245 | (the first one), run the command below: |
242 | 246 | ||
@@ -258,10 +262,6 @@ $ RAILS_ENV=production ./script/runner "User.create(:login => 'adminuser', :emai | @@ -258,10 +262,6 @@ $ RAILS_ENV=production ./script/runner "User.create(:login => 'adminuser', :emai | ||
258 | (replace "adminuser", "admin@example.com", "admin" with the login, email | 262 | (replace "adminuser", "admin@example.com", "admin" with the login, email |
259 | and password of your environment admin) | 263 | and password of your environment admin) |
260 | 264 | ||
261 | -Compile the translations: | ||
262 | - | ||
263 | -$ RAILS_ENV=production rake noosfero:translations:compile | ||
264 | - | ||
265 | To start the Noosfero application servers: | 265 | To start the Noosfero application servers: |
266 | 266 | ||
267 | $ ./script/production start | 267 | $ ./script/production start |
app/helpers/application_helper.rb
@@ -1154,7 +1154,7 @@ module ApplicationHelper | @@ -1154,7 +1154,7 @@ module ApplicationHelper | ||
1154 | def render_environment_features(folder) | 1154 | def render_environment_features(folder) |
1155 | result = '' | 1155 | result = '' |
1156 | environment.enabled_features.keys.each do |feature| | 1156 | environment.enabled_features.keys.each do |feature| |
1157 | - file = File.join(@controller.view_paths, 'shared', folder.to_s, "#{feature}.rhtml") | 1157 | + file = File.join(@controller.view_paths.last, 'shared', folder.to_s, "#{feature}.rhtml") |
1158 | if File.exists?(file) | 1158 | if File.exists?(file) |
1159 | result << render(:file => file, :use_full_path => false) | 1159 | result << render(:file => file, :use_full_path => false) |
1160 | end | 1160 | end |
app/models/feed_reader_block.rb
@@ -13,6 +13,7 @@ class FeedReaderBlock < Block | @@ -13,6 +13,7 @@ class FeedReaderBlock < Block | ||
13 | old_address = address | 13 | old_address = address |
14 | orig_set_address(new_address) | 14 | orig_set_address(new_address) |
15 | self.enabled = (new_address && new_address != old_address) || (new_address && self.enabled) || false | 15 | self.enabled = (new_address && new_address != old_address) || (new_address && self.enabled) || false |
16 | + self.fetched_at = nil | ||
16 | end | 17 | end |
17 | 18 | ||
18 | settings_items :limit, :type => :integer | 19 | settings_items :limit, :type => :integer |
@@ -71,6 +72,7 @@ class FeedReaderBlock < Block | @@ -71,6 +72,7 @@ class FeedReaderBlock < Block | ||
71 | self.feed_title = nil | 72 | self.feed_title = nil |
72 | self.error_message = nil | 73 | self.error_message = nil |
73 | end | 74 | end |
75 | + | ||
74 | def finish_fetch | 76 | def finish_fetch |
75 | self.fetched_at = Time.now | 77 | self.fetched_at = Time.now |
76 | self.save! | 78 | self.save! |
app/models/person.rb
@@ -403,7 +403,7 @@ class Person < Profile | @@ -403,7 +403,7 @@ class Person < Profile | ||
403 | end | 403 | end |
404 | 404 | ||
405 | def control_panel_settings_button | 405 | def control_panel_settings_button |
406 | - {:title => _('Profile Info and settings'), :icon => 'edit-profile'} | 406 | + {:title => _('Edit Profile'), :icon => 'edit-profile'} |
407 | end | 407 | end |
408 | 408 | ||
409 | def disable | 409 | def disable |
app/models/product.rb
@@ -184,7 +184,7 @@ class Product < ActiveRecord::Base | @@ -184,7 +184,7 @@ class Product < ActiveRecord::Base | ||
184 | end | 184 | end |
185 | 185 | ||
186 | def price_described? | 186 | def price_described? |
187 | - return false if price.nil? | 187 | + return false if price.blank? or price == 0 |
188 | (price - total_production_cost).zero? | 188 | (price - total_production_cost).zero? |
189 | end | 189 | end |
190 | 190 |
app/models/profile.rb
@@ -810,7 +810,7 @@ private :generate_url, :url_options | @@ -810,7 +810,7 @@ private :generate_url, :url_options | ||
810 | end | 810 | end |
811 | 811 | ||
812 | def control_panel_settings_button | 812 | def control_panel_settings_button |
813 | - {:title => _('Profile Info and settings'), :icon => 'edit-profile'} | 813 | + {:title => _('Edit Profile'), :icon => 'edit-profile'} |
814 | end | 814 | end |
815 | 815 | ||
816 | def self.identification | 816 | def self.identification |
app/views/layouts/application-ng.rhtml
@@ -63,7 +63,7 @@ | @@ -63,7 +63,7 @@ | ||
63 | <%= render :file => 'account/login', :locals => { :is_thickbox => true } %> | 63 | <%= render :file => 'account/login', :locals => { :is_thickbox => true } %> |
64 | </div> | 64 | </div> |
65 | </span> | 65 | </span> |
66 | - <form action="/search" class="search_form" method="get" class="clean"> | 66 | + <form action="/search" class="search_form clean" method="get" id="top-search"> |
67 | <input name="query" size="15" value="<%=_('Search...')%>" | 67 | <input name="query" size="15" value="<%=_('Search...')%>" |
68 | onfocus="this.form.className='focused'; | 68 | onfocus="this.form.className='focused'; |
69 | if(this.value=='<%=_('Search...')%>'){this.value=''}" | 69 | if(this.value=='<%=_('Search...')%>'){this.value=''}" |
app/views/profile_editor/edit.rhtml
@@ -73,8 +73,6 @@ | @@ -73,8 +73,6 @@ | ||
73 | </table> | 73 | </table> |
74 | <% end %> | 74 | <% end %> |
75 | 75 | ||
76 | - <%= select_categories(:profile_data, _('Select the categories of your interest'), 2) %> | ||
77 | - | ||
78 | <h2><%= _('Translations') %></h2> | 76 | <h2><%= _('Translations') %></h2> |
79 | <%= labelled_check_box( | 77 | <%= labelled_check_box( |
80 | _('Automatic redirect the visitor to the translated article of him language'), | 78 | _('Automatic redirect the visitor to the translated article of him language'), |
@@ -87,11 +85,7 @@ | @@ -87,11 +85,7 @@ | ||
87 | end.join("\n") | 85 | end.join("\n") |
88 | %> | 86 | %> |
89 | 87 | ||
90 | - <%= | ||
91 | - @plugins.map(:profile_editor_extras).each do |content| | ||
92 | - content.respond_to?(:call) ? content.call : content | ||
93 | - end.join("\n") | ||
94 | - %> | 88 | + <%= select_categories(:profile_data, _('Select the categories of your interest'), 2) %> |
95 | 89 | ||
96 | <% button_bar do %> | 90 | <% button_bar do %> |
97 | <%= submit_button('save', _('Save'), :cancel => {:action => 'index'}) %> | 91 | <%= submit_button('save', _('Save'), :cancel => {:action => 'index'}) %> |
features/browse_catalogs.feature
@@ -73,6 +73,19 @@ Feature: browse catalogs | @@ -73,6 +73,19 @@ Feature: browse catalogs | ||
73 | And I should not see "qualifiers" | 73 | And I should not see "qualifiers" |
74 | And I should not see "price composition" | 74 | And I should not see "price composition" |
75 | 75 | ||
76 | + Scenario: don't display the price when it's not defined | ||
77 | + Given the following products | ||
78 | + | owner | category | name | | ||
79 | + | artebonito | categ1 | Produto1 | | ||
80 | + And I am on /catalog/artebonito | ||
81 | + Then I should see "Produto1" within "li.product-link" | ||
82 | + And I should not see "0.00" | ||
83 | + And I should see "No image" within ".no-image" | ||
84 | + And I should not see "product unavailable" | ||
85 | + And I should not see "description" | ||
86 | + And I should not see "qualifiers" | ||
87 | + And I should not see "price composition" | ||
88 | + | ||
76 | Scenario: product name links to product page | 89 | Scenario: product name links to product page |
77 | Given the following products | 90 | Given the following products |
78 | | owner | category | name | price | | 91 | | owner | category | name | price | |
features/delete_profile.feature
@@ -16,7 +16,7 @@ Feature: delete profile | @@ -16,7 +16,7 @@ Feature: delete profile | ||
16 | Scenario: deleting profile | 16 | Scenario: deleting profile |
17 | Given I am logged in as "joaosilva" | 17 | Given I am logged in as "joaosilva" |
18 | And I am on Joao Silva's control panel | 18 | And I am on Joao Silva's control panel |
19 | - And I follow "Profile Info and settings" | 19 | + And I follow "Edit Profile" |
20 | And I follow "Delete profile" | 20 | And I follow "Delete profile" |
21 | Then I should see "Are you sure you want to delete this profile?" | 21 | Then I should see "Are you sure you want to delete this profile?" |
22 | When I follow "Yes, I am sure" | 22 | When I follow "Yes, I am sure" |
@@ -32,7 +32,7 @@ Feature: delete profile | @@ -32,7 +32,7 @@ Feature: delete profile | ||
32 | Scenario: giving up of deleting profile | 32 | Scenario: giving up of deleting profile |
33 | Given I am logged in as "joaosilva" | 33 | Given I am logged in as "joaosilva" |
34 | And I am on Joao Silva's control panel | 34 | And I am on Joao Silva's control panel |
35 | - And I follow "Profile Info and settings" | 35 | + And I follow "Edit Profile" |
36 | And I follow "Delete profile" | 36 | And I follow "Delete profile" |
37 | Then I should see "Are you sure you want to delete this profile?" | 37 | Then I should see "Are you sure you want to delete this profile?" |
38 | When I follow "No, I gave up" | 38 | When I follow "No, I gave up" |
@@ -108,7 +108,7 @@ Feature: delete profile | @@ -108,7 +108,7 @@ Feature: delete profile | ||
108 | Scenario: environment admin deletes profile | 108 | Scenario: environment admin deletes profile |
109 | Given I am logged in as admin | 109 | Given I am logged in as admin |
110 | And I am on Joao Silva's control panel | 110 | And I am on Joao Silva's control panel |
111 | - And I follow "Profile Info and settings" | 111 | + And I follow "Edit Profile" |
112 | And I follow "Delete profile" | 112 | And I follow "Delete profile" |
113 | Then I should see "Are you sure you want to delete this profile?" | 113 | Then I should see "Are you sure you want to delete this profile?" |
114 | When I follow "Yes, I am sure" | 114 | When I follow "Yes, I am sure" |
features/edit_article.feature
@@ -91,7 +91,7 @@ Feature: edit article | @@ -91,7 +91,7 @@ Feature: edit article | ||
91 | Given I am on Joao Silva's sitemap | 91 | Given I am on Joao Silva's sitemap |
92 | When I follow "Save the whales" and wait | 92 | When I follow "Save the whales" and wait |
93 | And I follow "Edit" and wait | 93 | And I follow "Edit" and wait |
94 | - And I follow "Cancel" within ".main-block" and wait | 94 | + And I follow "Cancel" and wait |
95 | Then I should be on /joaosilva/save-the-whales | 95 | Then I should be on /joaosilva/save-the-whales |
96 | 96 | ||
97 | @selenium | 97 | @selenium |
features/edit_profile.feature
@@ -11,7 +11,7 @@ Feature: edit profile | @@ -11,7 +11,7 @@ Feature: edit profile | ||
11 | | display_name | | 11 | | display_name | |
12 | | birth_date | | 12 | | birth_date | |
13 | When I go to joao's control panel | 13 | When I go to joao's control panel |
14 | - And I follow "Profile Info and settings" | 14 | + And I follow "Edit Profile" |
15 | And I select "November" | 15 | And I select "November" |
16 | And I select "15" | 16 | And I select "15" |
17 | And I press "Save" | 17 | And I press "Save" |
@@ -23,7 +23,7 @@ Feature: edit profile | @@ -23,7 +23,7 @@ Feature: edit profile | ||
23 | | display_name | | 23 | | display_name | |
24 | | birth_date | | 24 | | birth_date | |
25 | When I go to joao's control panel | 25 | When I go to joao's control panel |
26 | - And I follow "Profile Info and settings" | 26 | + And I follow "Edit Profile" |
27 | And I select "November" | 27 | And I select "November" |
28 | And I select "15" | 28 | And I select "15" |
29 | And I press "Save" | 29 | And I press "Save" |
@@ -35,7 +35,7 @@ Feature: edit profile | @@ -35,7 +35,7 @@ Feature: edit profile | ||
35 | | display_name | | 35 | | display_name | |
36 | | birth_date | | 36 | | birth_date | |
37 | When I go to joao's control panel | 37 | When I go to joao's control panel |
38 | - And I follow "Profile Info and settings" | 38 | + And I follow "Edit Profile" |
39 | And I select "November" | 39 | And I select "November" |
40 | And I select "15" | 40 | And I select "15" |
41 | And I select "1980" | 41 | And I select "1980" |
@@ -48,7 +48,7 @@ Feature: edit profile | @@ -48,7 +48,7 @@ Feature: edit profile | ||
48 | | display_name | | 48 | | display_name | |
49 | | birth_date | | 49 | | birth_date | |
50 | When I go to joao's control panel | 50 | When I go to joao's control panel |
51 | - And I follow "Profile Info and settings" | 51 | + And I follow "Edit Profile" |
52 | And I select "November" | 52 | And I select "November" |
53 | And I select "15" | 53 | And I select "15" |
54 | And I select "1980" | 54 | And I select "1980" |
features/manage_product_price_details.feature
@@ -80,7 +80,7 @@ Feature: manage product price details | @@ -80,7 +80,7 @@ Feature: manage product price details | ||
80 | And I should not see "Taxes" within "#display-price-details" | 80 | And I should not see "Taxes" within "#display-price-details" |
81 | And I should see "Energy" within "#display-price-details" | 81 | And I should see "Energy" within "#display-price-details" |
82 | 82 | ||
83 | - Scenario: not display product detail button if product does not have input | 83 | + Scenario: not display price composition if product does not have input |
84 | Given the following product | 84 | Given the following product |
85 | | owner | category | name | | 85 | | owner | category | name | |
86 | | redemoinho | rock | Yellow Submarine | | 86 | | redemoinho | rock | Yellow Submarine | |
@@ -89,13 +89,12 @@ Feature: manage product price details | @@ -89,13 +89,12 @@ Feature: manage product price details | ||
89 | | mariasouza | Maria Souza | | 89 | | mariasouza | Maria Souza | |
90 | And I am logged in as "mariasouza" | 90 | And I am logged in as "mariasouza" |
91 | When I go to Rede Moinho's page of product Yellow Submarine | 91 | When I go to Rede Moinho's page of product Yellow Submarine |
92 | - And I follow "Price composition" | ||
93 | - Then I should not see "Describe here the cost of production" | 92 | + Then I should not see "Price composition" |
94 | 93 | ||
95 | - Scenario: not display price details if price is not fully described | 94 | + Scenario: not display price composition if price is not fully described |
96 | Given I am not logged in | 95 | Given I am not logged in |
97 | And I go to Rede Moinho's page of product Abbey Road | 96 | And I go to Rede Moinho's page of product Abbey Road |
98 | - Then I should not see "60.0" | 97 | + Then I should not see "Price composition" |
99 | 98 | ||
100 | @selenium | 99 | @selenium |
101 | Scenario: display price details if price is fully described | 100 | Scenario: display price details if price is fully described |
features/signup.feature
@@ -53,7 +53,7 @@ Feature: signup | @@ -53,7 +53,7 @@ Feature: signup | ||
53 | | joaosilva | Joao Silva | | 53 | | joaosilva | Joao Silva | |
54 | Given I am logged in as "joaosilva" | 54 | Given I am logged in as "joaosilva" |
55 | And I am on Joao Silva's control panel | 55 | And I am on Joao Silva's control panel |
56 | - And I follow "Profile Info and settings" | 56 | + And I follow "Edit Profile" |
57 | And I fill in "Name" with "" | 57 | And I fill in "Name" with "" |
58 | When I press "Save" | 58 | When I press "Save" |
59 | Then I should see "Name can't be blank" | 59 | Then I should see "Name can't be blank" |
lib/noosfero/plugin.rb
@@ -7,6 +7,10 @@ class Noosfero::Plugin | @@ -7,6 +7,10 @@ class Noosfero::Plugin | ||
7 | 7 | ||
8 | class << self | 8 | class << self |
9 | 9 | ||
10 | + def klass(dir) | ||
11 | + (dir.to_s.camelize + 'Plugin').constantize # load the plugin | ||
12 | + end | ||
13 | + | ||
10 | def init_system | 14 | def init_system |
11 | Dir.glob(File.join(Rails.root, 'config', 'plugins', '*')).select do |entry| | 15 | Dir.glob(File.join(Rails.root, 'config', 'plugins', '*')).select do |entry| |
12 | File.directory?(entry) | 16 | File.directory?(entry) |
@@ -18,8 +22,7 @@ class Noosfero::Plugin | @@ -18,8 +22,7 @@ class Noosfero::Plugin | ||
18 | path << File.join(dir, 'lib') | 22 | path << File.join(dir, 'lib') |
19 | end | 23 | end |
20 | 24 | ||
21 | - plugin_name = File.basename(dir).camelize + 'Plugin' | ||
22 | - plugin_name.constantize # load the plugin | 25 | + klass(File.basename(dir)) |
23 | end | 26 | end |
24 | end | 27 | end |
25 | 28 |
lib/noosfero/plugin/manager.rb
@@ -22,4 +22,11 @@ class Noosfero::Plugin::Manager | @@ -22,4 +22,11 @@ class Noosfero::Plugin::Manager | ||
22 | end | 22 | end |
23 | end | 23 | end |
24 | 24 | ||
25 | + def [](name) | ||
26 | + klass = Noosfero::Plugin.klass(name) | ||
27 | + enabled_plugins.select do |plugin| | ||
28 | + plugin.kind_of?(klass) | ||
29 | + end.first | ||
30 | + end | ||
31 | + | ||
25 | end | 32 | end |
lib/tasks/doc.rake
@@ -13,7 +13,7 @@ namespace :noosfero do | @@ -13,7 +13,7 @@ namespace :noosfero do | ||
13 | [File.join(RAILS_ROOT, 'doc/noosfero/plugins/index.textile')] | 13 | [File.join(RAILS_ROOT, 'doc/noosfero/plugins/index.textile')] |
14 | end | 14 | end |
15 | input = Dir.glob('doc/noosfero/**/*.textile') + plugins_textiles.map{|i| "doc/noosfero/plugins/#{File.basename(i)}"} | 15 | input = Dir.glob('doc/noosfero/**/*.textile') + plugins_textiles.map{|i| "doc/noosfero/plugins/#{File.basename(i)}"} |
16 | - topics_xhtml = input.map { |item| item.sub('.textile', '.en.xhtml') } | 16 | + topics_xhtml = input.map { |item| item.sub('.textile', '.en.xhtml') }.uniq |
17 | sections = Dir.glob('doc/noosfero/*').select {|item| File.directory?(item) } | 17 | sections = Dir.glob('doc/noosfero/*').select {|item| File.directory?(item) } |
18 | toc_sections = sections.map {|item| File.join(item, 'toc.en.xhtml')} | 18 | toc_sections = sections.map {|item| File.join(item, 'toc.en.xhtml')} |
19 | index_sections = sections.map {|item| File.join(item, 'index.en.xhtml')} | 19 | index_sections = sections.map {|item| File.join(item, 'index.en.xhtml')} |
@@ -104,11 +104,10 @@ namespace :noosfero do | @@ -104,11 +104,10 @@ namespace :noosfero do | ||
104 | desc "Build Noosfero online documentation" | 104 | desc "Build Noosfero online documentation" |
105 | task :build => [:link_plugins_textiles, po4a_conf] do | 105 | task :build => [:link_plugins_textiles, po4a_conf] do |
106 | sh "po4a #{po4a_conf}" | 106 | sh "po4a #{po4a_conf}" |
107 | - Rake::Task['noosfero:doc:unlink_plugins_textiles'].invoke | ||
108 | end | 107 | end |
109 | 108 | ||
110 | desc "Cleans Noosfero online documentation" | 109 | desc "Cleans Noosfero online documentation" |
111 | - task :clean do | 110 | + task :clean => :unlink_plugins_textiles do |
112 | sh 'rm -f doc/noosfero/*.xhtml' | 111 | sh 'rm -f doc/noosfero/*.xhtml' |
113 | sh 'rm -f doc/noosfero/*/*.xhtml' | 112 | sh 'rm -f doc/noosfero/*/*.xhtml' |
114 | rm_f po4a_conf | 113 | rm_f po4a_conf |
plugins/google_analytics/doc/google_analytics.textile
1 | h1. Google Analytics | 1 | h1. Google Analytics |
2 | 2 | ||
3 | -Tracking and web analytics to people and communities. | 3 | +Tracking and web analytics for people and communities. |
4 | 4 | ||
5 | h2. Usage | 5 | h2. Usage |
6 | 6 | ||
7 | -* Create a "Google Analytics":http://www.google.com/analytics/ account | ||
8 | -* Configure your Google Analytics account following these steps | 7 | +Create and configure Google Analytics account following these steps: |
9 | 8 | ||
9 | +# Open "Google Analytics":http://www.google.com/analytics/ | ||
10 | !=/plugins/google_analytics/images/doc/google-analytics-setup-step1.en.png(Google Setup - Step 1)! | 10 | !=/plugins/google_analytics/images/doc/google-analytics-setup-step1.en.png(Google Setup - Step 1)! |
11 | - | 11 | +# Sign in to Google Analytics |
12 | !=/plugins/google_analytics/images/doc/google-analytics-setup-step2.en.png(Google Setup - Step 2)! | 12 | !=/plugins/google_analytics/images/doc/google-analytics-setup-step2.en.png(Google Setup - Step 2)! |
13 | - | 13 | +# Follow signup instructions |
14 | !=/plugins/google_analytics/images/doc/google-analytics-setup-step3.en.png(Google Setup - Step 3)! | 14 | !=/plugins/google_analytics/images/doc/google-analytics-setup-step3.en.png(Google Setup - Step 3)! |
15 | - | 15 | +# Fill in _Website's URL_ with your profile address (eg.: softwarelivre.org/joenio), _Account Name_ with your name and read and accept terms of use |
16 | !=/plugins/google_analytics/images/doc/google-analytics-setup-step4.en.png(Google Setup - Step 4)! | 16 | !=/plugins/google_analytics/images/doc/google-analytics-setup-step4.en.png(Google Setup - Step 4)! |
17 | - | 17 | +# Accept default options, save and take note of your _Web Property ID_ (eg.: UA-23455430-3) |
18 | !=/plugins/google_analytics/images/doc/google-analytics-setup-step5.en.png(Google Setup - Step 5)! | 18 | !=/plugins/google_analytics/images/doc/google-analytics-setup-step5.en.png(Google Setup - Step 5)! |
19 | - | 19 | +# Login to Noosfero, go to your control panel, follow _Profile Info and Settings_ and fill in _Google Analytics Profile ID_ with ID above |
20 | !=/plugins/google_analytics/images/doc/google-analytics-setup-step6.en.png(Google Setup - Step 6)! | 20 | !=/plugins/google_analytics/images/doc/google-analytics-setup-step6.en.png(Google Setup - Step 6)! |
21 | 21 | ||
22 | -* Take note of your Google Analytics Profile ID | ||
23 | -* Login to Noosfero and go to your control panel | ||
24 | -* Follow Profile Info and Settings and fill in Google Analytics Profile ID | ||
25 | - | ||
26 | h2. Info | 22 | h2. Info |
27 | 23 | ||
28 | * "Google Analytics Support":http://support.google.com/analytics | 24 | * "Google Analytics Support":http://support.google.com/analytics |
plugins/google_analytics/lib/google_analytics_plugin.rb
@@ -4,6 +4,8 @@ class GoogleAnalyticsPlugin < Noosfero::Plugin | @@ -4,6 +4,8 @@ class GoogleAnalyticsPlugin < Noosfero::Plugin | ||
4 | 4 | ||
5 | include ActionView::Helpers::JavaScriptHelper | 5 | include ActionView::Helpers::JavaScriptHelper |
6 | include ActionView::Helpers::FormHelper | 6 | include ActionView::Helpers::FormHelper |
7 | + include ActionView::Helpers::UrlHelper | ||
8 | + include ActionView::Helpers::TagHelper | ||
7 | include ApplicationHelper | 9 | include ApplicationHelper |
8 | 10 | ||
9 | def self.plugin_name | 11 | def self.plugin_name |
@@ -15,7 +17,7 @@ class GoogleAnalyticsPlugin < Noosfero::Plugin | @@ -15,7 +17,7 @@ class GoogleAnalyticsPlugin < Noosfero::Plugin | ||
15 | end | 17 | end |
16 | 18 | ||
17 | def profile_id | 19 | def profile_id |
18 | - context.profile && context.profile.data[:google_analytics_profile_id] | 20 | + context.profile && context.profile.google_analytics_profile_id |
19 | end | 21 | end |
20 | 22 | ||
21 | def head_ending | 23 | def head_ending |
@@ -25,7 +27,7 @@ class GoogleAnalyticsPlugin < Noosfero::Plugin | @@ -25,7 +27,7 @@ class GoogleAnalyticsPlugin < Noosfero::Plugin | ||
25 | end | 27 | end |
26 | 28 | ||
27 | def profile_editor_extras | 29 | def profile_editor_extras |
28 | - labelled_form_field(_('Google Analytics Profile ID'), text_field(:profile_data, :google_analytics_profile_id, :value => context.profile.google_analytics_profile_id)) | 30 | + expanded_template('profile-editor-extras.rhtml',{:profile_id => profile_id}) |
29 | end | 31 | end |
30 | 32 | ||
31 | end | 33 | end |
plugins/google_analytics/public/images/doc/google-analytics-setup-step1.en.png
plugins/google_analytics/public/images/doc/google-analytics-setup-step1.pt.png
116 KB
plugins/google_analytics/public/images/doc/google-analytics-setup-step2.en.png
plugins/google_analytics/public/images/doc/google-analytics-setup-step2.pt.png
86.2 KB
plugins/google_analytics/public/images/doc/google-analytics-setup-step3.en.png
plugins/google_analytics/public/images/doc/google-analytics-setup-step3.pt.png
56 KB
plugins/google_analytics/public/images/doc/google-analytics-setup-step4.en.png
plugins/google_analytics/public/images/doc/google-analytics-setup-step4.pt.png
119 KB
plugins/google_analytics/public/images/doc/google-analytics-setup-step5.en.png
plugins/google_analytics/public/images/doc/google-analytics-setup-step5.pt.png
83.2 KB
plugins/google_analytics/public/images/doc/google-analytics-setup-step6.en.png
plugins/google_analytics/views/profile-editor-extras.rhtml
0 → 100644
@@ -0,0 +1,3 @@ | @@ -0,0 +1,3 @@ | ||
1 | +<h2><%= _('Statistics') %></h2> | ||
2 | +<%= labelled_form_field(_('Google Analytics Profile ID'), text_field(:profile_data, :google_analytics_profile_id, :value => profile_id)) %> | ||
3 | +<%= link_to(_('See how to configure statistics for your profile'), '/doc/plugins/google_analytics', :target => '_blank') %> |
plugins/google_cse/controllers/google_cse_plugin_environment_controller.rb
0 → 100644
@@ -0,0 +1,13 @@ | @@ -0,0 +1,13 @@ | ||
1 | +h1. GoogleCsePlugin | ||
2 | + | ||
3 | +A plugin that uses the Google Custom Search as Noosfero general search engine. | ||
4 | + | ||
5 | +h2. Usage | ||
6 | + | ||
7 | +* Register a Google Custom Search ID at http://www.google.com/cse | ||
8 | +* Set at least basic config, site list and look and fell of your Google Cse ID | ||
9 | +* Configure Noosfero environment with this ID | ||
10 | +** >> env = Environment.find( ... ) | ||
11 | +** >> env.settings[:google_cse_id] = '<PUT ID HERE>' | ||
12 | +** >> env.save! | ||
13 | +* That's all! The top search text-field of Noosfero will be used to make searches |
@@ -0,0 +1,25 @@ | @@ -0,0 +1,25 @@ | ||
1 | +class GoogleCsePlugin < Noosfero::Plugin | ||
2 | + | ||
3 | + def self.plugin_name | ||
4 | + "GoogleCsePlugin" | ||
5 | + end | ||
6 | + | ||
7 | + def self.plugin_description | ||
8 | + _("A plugin that uses the Google Custom Search as Noosfero general search engine.") | ||
9 | + end | ||
10 | + | ||
11 | + def google_id | ||
12 | + context.environment.settings[:google_cse_id] | ||
13 | + end | ||
14 | + | ||
15 | + def self.results_url_path | ||
16 | + '/plugin/google_cse/results' | ||
17 | + end | ||
18 | + | ||
19 | + def body_beginning | ||
20 | + unless google_id.blank? | ||
21 | + expanded_template('search-box.rhtml', {:selector => '#top-search, #footer-search', :plugin => self}) | ||
22 | + end | ||
23 | + end | ||
24 | + | ||
25 | +end |
plugins/google_cse/test/functional/google_cse_plugin_environment_controller_test.rb
0 → 100644
@@ -0,0 +1,20 @@ | @@ -0,0 +1,20 @@ | ||
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | ||
2 | +require File.dirname(__FILE__) + '/../../controllers/google_cse_plugin_environment_controller' | ||
3 | + | ||
4 | +# Re-raise errors caught by the controller. | ||
5 | +class GoogleCsePluginEnvironmentController; def rescue_action(e) raise e end; end | ||
6 | + | ||
7 | +class GoogleCsePluginEnvironmentControllerTest < Test::Unit::TestCase | ||
8 | + | ||
9 | + def setup | ||
10 | + @controller = GoogleCsePluginEnvironmentController.new | ||
11 | + @request = ActionController::TestRequest.new | ||
12 | + @response = ActionController::TestResponse.new | ||
13 | + end | ||
14 | + | ||
15 | + should 'get results page' do | ||
16 | + get :results | ||
17 | + assert_response :success | ||
18 | + end | ||
19 | + | ||
20 | +end |
@@ -0,0 +1,25 @@ | @@ -0,0 +1,25 @@ | ||
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | ||
2 | + | ||
3 | +class GoogleCsePluginTest < Test::Unit::TestCase | ||
4 | + | ||
5 | + def setup | ||
6 | + @plugin = GoogleCsePlugin.new | ||
7 | + @context = mock() | ||
8 | + @plugin.context = @context | ||
9 | + @env = Environment.new | ||
10 | + @plugin.context.stubs(:environment).returns(@env) | ||
11 | + end | ||
12 | + | ||
13 | + should 'get google_id from environment' do | ||
14 | + @env.stubs(:settings).returns({:google_cse_id => 10}) | ||
15 | + assert_equal 10, @plugin.google_id | ||
16 | + end | ||
17 | + | ||
18 | + should 'not use custom search if google_cse_id isnt set' do | ||
19 | + @env.stubs(:settings).returns({}) | ||
20 | + assert_nil @plugin.body_beginning | ||
21 | + @env.stubs(:settings).returns({:google_cse_id => 11}) | ||
22 | + assert_not_nil @plugin.body_beginning | ||
23 | + end | ||
24 | + | ||
25 | +end |
plugins/google_cse/views/google_cse_plugin_environment/results.rhtml
0 → 100644
@@ -0,0 +1,30 @@ | @@ -0,0 +1,30 @@ | ||
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> |
@@ -0,0 +1,10 @@ | @@ -0,0 +1,10 @@ | ||
1 | +<script type="text/javascript"> | ||
2 | + jQuery(function($) { | ||
3 | + $('<%= locals[:selector] %>') | ||
4 | + .attr({class: "cse-search-box", action: "<%= GoogleCsePlugin.results_url_path %>"}) | ||
5 | + .append('<input type="hidden" name="cx" value="<%= locals[:plugin].google_id %>" /><input type="hidden" name="cof" value="FORID:10" /><input type="hidden" name="ie" value="UTF-8" /><input type="hidden" name="siteurl" value="<%= context.environment.default_hostname %>">') | ||
6 | + .children("input[name='query']") | ||
7 | + .attr('name', 'q') | ||
8 | + .attr('id', 'q'); | ||
9 | + }); | ||
10 | +</script> |
test/unit/application_helper_test.rb
@@ -603,7 +603,7 @@ class ApplicationHelperTest < Test::Unit::TestCase | @@ -603,7 +603,7 @@ class ApplicationHelperTest < Test::Unit::TestCase | ||
603 | 603 | ||
604 | @controller = ApplicationController.new | 604 | @controller = ApplicationController.new |
605 | path = File.join(RAILS_ROOT, 'app', 'views') | 605 | path = File.join(RAILS_ROOT, 'app', 'views') |
606 | - @controller.stubs(:view_paths).returns(path) | 606 | + @controller.stubs(:view_paths).returns([path]) |
607 | 607 | ||
608 | file = path + '/shared/usermenu/xmpp_chat.rhtml' | 608 | file = path + '/shared/usermenu/xmpp_chat.rhtml' |
609 | expects(:render).with(:file => file, :use_full_path => false).returns('Open chat') | 609 | expects(:render).with(:file => file, :use_full_path => false).returns('Open chat') |
test/unit/feed_reader_block_test.rb
@@ -127,7 +127,7 @@ class FeedReaderBlockTest < ActiveSupport::TestCase | @@ -127,7 +127,7 @@ class FeedReaderBlockTest < ActiveSupport::TestCase | ||
127 | Time.stubs(:now).returns(now - 3.hours) | 127 | Time.stubs(:now).returns(now - 3.hours) |
128 | not_expired.finish_fetch | 128 | not_expired.finish_fetch |
129 | 129 | ||
130 | - # now one block should be expired and the not the other | 130 | + # now one block should be expired and not the other |
131 | Time.stubs(:now).returns(now) | 131 | Time.stubs(:now).returns(now) |
132 | expired_list = FeedReaderBlock.expired | 132 | expired_list = FeedReaderBlock.expired |
133 | assert_includes expired_list, expired | 133 | assert_includes expired_list, expired |
@@ -156,6 +156,17 @@ class FeedReaderBlockTest < ActiveSupport::TestCase | @@ -156,6 +156,17 @@ class FeedReaderBlockTest < ActiveSupport::TestCase | ||
156 | assert_equal true, reader.enabled | 156 | assert_equal true, reader.enabled |
157 | end | 157 | end |
158 | 158 | ||
159 | + should 'be expired when address is updated' do | ||
160 | + reader = build(:feed_reader_block, :address => 'http://www.example.com/feed') | ||
161 | + reader.finish_fetch | ||
162 | + expired_list = FeedReaderBlock.expired | ||
163 | + assert_not_includes expired_list, reader | ||
164 | + reader.address = "http://www.example.com/new-feed" | ||
165 | + reader.save! | ||
166 | + expired_list = FeedReaderBlock.expired | ||
167 | + assert_includes expired_list, reader | ||
168 | + end | ||
169 | + | ||
159 | should 'be disabled when address is empty' do | 170 | should 'be disabled when address is empty' do |
160 | reader = build(:feed_reader_block, :enabled => true, :address => 'http://www.example.com/feed') | 171 | reader = build(:feed_reader_block, :enabled => true, :address => 'http://www.example.com/feed') |
161 | reader.address = nil | 172 | reader.address = nil |
@@ -173,7 +184,7 @@ class FeedReaderBlockTest < ActiveSupport::TestCase | @@ -173,7 +184,7 @@ class FeedReaderBlockTest < ActiveSupport::TestCase | ||
173 | assert_equal true, reader.enabled, 'must enable when setting to new address' | 184 | assert_equal true, reader.enabled, 'must enable when setting to new address' |
174 | end | 185 | end |
175 | 186 | ||
176 | - should 'kepp enable when address is not changed' do | 187 | + should 'keep enable when address is not changed' do |
177 | reader = build(:feed_reader_block, :address => 'http://www.example.com/feed') | 188 | reader = build(:feed_reader_block, :address => 'http://www.example.com/feed') |
178 | reader.address = 'http://www.example.com/feed' | 189 | reader.address = 'http://www.example.com/feed' |
179 | assert_equal true, reader.enabled | 190 | assert_equal true, reader.enabled |