Commit 305736e575bc83704abc9a8f1c3954613c42beb4
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branch 'master' into AI3283-integration_with_dspace
Showing
144 changed files
with
82700 additions
and
84850 deletions
Show diff stats
Too many changes.
To preserve performance only 100 of 144 files displayed.
.ackrc
AUTHORS.md
... | ... | @@ -41,6 +41,7 @@ Alessandro Palmeira + Paulo Meirelles <alessandro.palmeira@gmail.com> |
41 | 41 | Alessandro Palmeira + Paulo Meirelles + João M. M. da Silva <alessandro.palmeira@gmail.com> |
42 | 42 | Alessandro Palmeira + Rafael Manzo <alessandro.palmeira@gmail.com> |
43 | 43 | Ana Losnak <analosnak@gmail.com> |
44 | +Andre Bernardes <andrebsguedes@gmail.com> | |
44 | 45 | Antonio Terceiro + Carlos Morais <terceiro@colivre.coop.br> |
45 | 46 | Antonio Terceiro + Paulo Meirelles <terceiro@colivre.coop.br> |
46 | 47 | Antonio Terceiro <terceiro@colivre.coop.br> |
... | ... | @@ -132,6 +133,7 @@ Francisco Marcelo de Araújo Lima Júnior <maljunior@gmail.com> |
132 | 133 | Gabriela Navarro <navarro1703@gmail.com> |
133 | 134 | Grazieno Pellegrino <grazieno@gmail.com> |
134 | 135 | Gust <darksshades@hotmail.com> |
136 | +Hebert Douglas <hebertdougl@gmail.com> | |
135 | 137 | Hugo Melo <hugo@riseup.net> |
136 | 138 | Isaac Canan <isaac@intelletto.com.br> |
137 | 139 | Italo Valcy <italo@dcc.ufba.br> |
... | ... | @@ -230,6 +232,8 @@ Rodrigo Souto <rodrigo@colivre.coop.br> |
230 | 232 | Ronny Kursawe <kursawe.ronny@googlemail.com> |
231 | 233 | root <root@debian.sdr.serpro> |
232 | 234 | Samuel R. C. Vale <srcvale@holoscopio.com> |
235 | +Tallys Martins <tallysmartins@gmail.com> | |
236 | +tallys <tallys@tallys.(none)> | |
233 | 237 | Valessio Brito <contato@valessiobrito.com.br> |
234 | 238 | Valessio Brito <contato@valessiobrito.info> |
235 | 239 | Valessio Brito <valessio@gmail.com> | ... | ... |
Gemfile
1 | 1 | source "https://rubygems.org" |
2 | -gem 'rails' | |
3 | -gem 'fast_gettext' | |
4 | -gem 'acts-as-taggable-on' | |
5 | -gem 'prototype-rails' | |
6 | -gem 'prototype_legacy_helper', '0.0.0', :path => 'vendor/prototype_legacy_helper' | |
7 | -gem 'rails_autolink' | |
8 | -gem 'pg' | |
9 | -gem 'rmagick' | |
10 | -gem 'RedCloth' | |
11 | -gem 'will_paginate' | |
12 | -gem 'ruby-feedparser' | |
13 | -gem 'daemons' | |
14 | -gem 'thin' | |
15 | -gem 'hpricot' | |
16 | -gem 'nokogiri' | |
2 | +gem 'rails', '~> 3.2.19' | |
3 | +gem 'fast_gettext', '~> 0.6.8' | |
4 | +gem 'acts-as-taggable-on', '~> 3.0.2' | |
5 | +gem 'prototype-rails', '~> 3.2.1' | |
6 | +gem 'prototype_legacy_helper', '0.0.0', :path => 'vendor/prototype_legacy_helper' | |
7 | +gem 'rails_autolink', '~> 1.1.5' | |
8 | +gem 'pg', '~> 0.13.2' | |
9 | +gem 'rmagick', '~> 2.13.1' | |
10 | +gem 'RedCloth', '~> 4.2.9' | |
11 | +gem 'will_paginate', '~> 3.0.3' | |
12 | +gem 'ruby-feedparser', '~> 0.7' | |
13 | +gem 'daemons', '~> 1.1.5' | |
14 | +gem 'thin', '~> 1.3.1' | |
15 | +gem 'hpricot', '~> 0.8.6' | |
16 | +gem 'nokogiri', '~> 1.5.5' | |
17 | 17 | gem 'rake', :require => false |
18 | -gem 'rest-client' | |
19 | -gem 'exception_notification' | |
18 | +gem 'rest-client', '~> 1.6.7' | |
19 | +gem 'exception_notification', '~> 4.0.1' | |
20 | +gem 'gettext', '~> 2.2.1', :require => false, :group => :development | |
20 | 21 | |
21 | 22 | # FIXME list here all actual dependencies (i.e. the ones in debian/control), |
22 | 23 | # with their GEM names (not the Debian package names) |
23 | 24 | |
24 | 25 | group :production do |
25 | - gem 'dalli' | |
26 | + gem 'dalli', '~> 2.7.0' | |
26 | 27 | end |
27 | 28 | |
28 | 29 | group :test do |
29 | - gem 'rspec' | |
30 | - gem 'rspec-rails' | |
31 | - gem 'mocha', :require => false | |
30 | + gem 'rspec', '~> 2.10.0' | |
31 | + gem 'rspec-rails', '~> 2.10.1' | |
32 | + gem 'mocha', '~> 1.1.0', :require => false | |
32 | 33 | end |
33 | 34 | |
34 | 35 | group :cucumber do |
35 | - gem 'cucumber-rails', :require => false | |
36 | - gem 'capybara' | |
37 | - gem 'cucumber' | |
38 | - gem 'database_cleaner' | |
39 | - gem 'selenium-webdriver' | |
36 | + gem 'cucumber-rails', '~> 1.0.6', :require => false | |
37 | + gem 'capybara', '~> 2.1.0' | |
38 | + gem 'cucumber', '~> 1.0.6' | |
39 | + gem 'database_cleaner', '~> 1.2.0' | |
40 | + gem 'selenium-webdriver', '~> 2.39.0' | |
40 | 41 | end |
41 | 42 | |
42 | 43 | # include plugin gemfiles | ... | ... |
Gemfile.lock
... | ... | @@ -1,191 +0,0 @@ |
1 | -PATH | |
2 | - remote: vendor/prototype_legacy_helper | |
3 | - specs: | |
4 | - prototype_legacy_helper (0.0.0) | |
5 | - | |
6 | -GEM | |
7 | - remote: https://rubygems.org/ | |
8 | - specs: | |
9 | - RedCloth (4.2.9) | |
10 | - actionmailer (3.2.6) | |
11 | - actionpack (= 3.2.6) | |
12 | - mail (~> 2.4.4) | |
13 | - actionpack (3.2.6) | |
14 | - activemodel (= 3.2.6) | |
15 | - activesupport (= 3.2.6) | |
16 | - builder (~> 3.0.0) | |
17 | - erubis (~> 2.7.0) | |
18 | - journey (~> 1.0.1) | |
19 | - rack (~> 1.4.0) | |
20 | - rack-cache (~> 1.2) | |
21 | - rack-test (~> 0.6.1) | |
22 | - sprockets (~> 2.1.3) | |
23 | - activemodel (3.2.6) | |
24 | - activesupport (= 3.2.6) | |
25 | - builder (~> 3.0.0) | |
26 | - activerecord (3.2.6) | |
27 | - activemodel (= 3.2.6) | |
28 | - activesupport (= 3.2.6) | |
29 | - arel (~> 3.0.2) | |
30 | - tzinfo (~> 0.3.29) | |
31 | - activeresource (3.2.6) | |
32 | - activemodel (= 3.2.6) | |
33 | - activesupport (= 3.2.6) | |
34 | - activesupport (3.2.6) | |
35 | - i18n (~> 0.6) | |
36 | - multi_json (~> 1.0) | |
37 | - acts-as-taggable-on (3.0.2) | |
38 | - rails (>= 3, < 5) | |
39 | - arel (3.0.2) | |
40 | - builder (3.0.0) | |
41 | - capybara (2.1.0) | |
42 | - mime-types (>= 1.16) | |
43 | - nokogiri (>= 1.3.3) | |
44 | - rack (>= 1.0.0) | |
45 | - rack-test (>= 0.5.4) | |
46 | - xpath (~> 2.0) | |
47 | - childprocess (0.3.3) | |
48 | - ffi (~> 1.0.6) | |
49 | - cucumber (1.0.6) | |
50 | - builder (>= 2.1.2) | |
51 | - diff-lcs (>= 1.1.2) | |
52 | - gherkin (~> 2.4.18) | |
53 | - json (>= 1.4.6) | |
54 | - term-ansicolor (>= 1.0.6) | |
55 | - cucumber-rails (1.0.6) | |
56 | - capybara (>= 1.1.1) | |
57 | - cucumber (>= 1.0.6) | |
58 | - nokogiri (>= 1.5.0) | |
59 | - daemons (1.1.5) | |
60 | - dalli (2.7.0) | |
61 | - database_cleaner (1.2.0) | |
62 | - diff-lcs (1.1.3) | |
63 | - erubis (2.7.0) | |
64 | - eventmachine (0.12.10) | |
65 | - exception_notification (4.0.1) | |
66 | - actionmailer (>= 3.0.4) | |
67 | - activesupport (>= 3.0.4) | |
68 | - fast_gettext (0.6.8) | |
69 | - ffi (1.0.11) | |
70 | - gherkin (2.4.21) | |
71 | - json (>= 1.4.6) | |
72 | - hike (1.2.1) | |
73 | - hpricot (0.8.6) | |
74 | - i18n (0.6.0) | |
75 | - journey (1.0.3) | |
76 | - json (1.7.3) | |
77 | - mail (2.4.4) | |
78 | - i18n (>= 0.4.0) | |
79 | - mime-types (~> 1.16) | |
80 | - treetop (~> 1.4.8) | |
81 | - metaclass (0.0.1) | |
82 | - mime-types (1.19) | |
83 | - mocha (0.11.3) | |
84 | - metaclass (~> 0.0.1) | |
85 | - multi_json (1.3.6) | |
86 | - nokogiri (1.5.5) | |
87 | - pg (0.13.2) | |
88 | - polyglot (0.3.3) | |
89 | - prototype-rails (3.2.1) | |
90 | - rails (~> 3.2) | |
91 | - rack (1.4.1) | |
92 | - rack-cache (1.2) | |
93 | - rack (>= 0.4) | |
94 | - rack-ssl (1.3.2) | |
95 | - rack | |
96 | - rack-test (0.6.1) | |
97 | - rack (>= 1.0) | |
98 | - rails (3.2.6) | |
99 | - actionmailer (= 3.2.6) | |
100 | - actionpack (= 3.2.6) | |
101 | - activerecord (= 3.2.6) | |
102 | - activeresource (= 3.2.6) | |
103 | - activesupport (= 3.2.6) | |
104 | - bundler (~> 1.0) | |
105 | - railties (= 3.2.6) | |
106 | - rails_autolink (1.1.5) | |
107 | - rails (> 3.1) | |
108 | - railties (3.2.6) | |
109 | - actionpack (= 3.2.6) | |
110 | - activesupport (= 3.2.6) | |
111 | - rack-ssl (~> 1.3.2) | |
112 | - rake (>= 0.8.7) | |
113 | - rdoc (~> 3.4) | |
114 | - thor (>= 0.14.6, < 2.0) | |
115 | - rake (0.9.2.2) | |
116 | - rdoc (3.9.4) | |
117 | - rest-client (1.6.7) | |
118 | - mime-types (>= 1.16) | |
119 | - rmagick (2.13.1) | |
120 | - rspec (2.10.0) | |
121 | - rspec-core (~> 2.10.0) | |
122 | - rspec-expectations (~> 2.10.0) | |
123 | - rspec-mocks (~> 2.10.0) | |
124 | - rspec-core (2.10.1) | |
125 | - rspec-expectations (2.10.0) | |
126 | - diff-lcs (~> 1.1.3) | |
127 | - rspec-mocks (2.10.1) | |
128 | - rspec-rails (2.10.1) | |
129 | - actionpack (>= 3.0) | |
130 | - activesupport (>= 3.0) | |
131 | - railties (>= 3.0) | |
132 | - rspec (~> 2.10.0) | |
133 | - ruby-feedparser (0.7) | |
134 | - rubyzip (1.1.2) | |
135 | - selenium-webdriver (2.39.0) | |
136 | - childprocess (>= 0.2.5) | |
137 | - multi_json (~> 1.0) | |
138 | - rubyzip (~> 1.0) | |
139 | - websocket (~> 1.0.4) | |
140 | - sprockets (2.1.3) | |
141 | - hike (~> 1.2) | |
142 | - multi_json (~> 1.0) | |
143 | - rack (~> 1.0) | |
144 | - tilt (~> 1.1, != 1.3.0) | |
145 | - term-ansicolor (1.0.7) | |
146 | - thin (1.3.1) | |
147 | - daemons (>= 1.0.9) | |
148 | - eventmachine (>= 0.12.6) | |
149 | - rack (>= 1.0.0) | |
150 | - thor (0.15.3) | |
151 | - tilt (1.3.3) | |
152 | - treetop (1.4.10) | |
153 | - polyglot | |
154 | - polyglot (>= 0.3.1) | |
155 | - tzinfo (0.3.33) | |
156 | - websocket (1.0.7) | |
157 | - will_paginate (3.0.3) | |
158 | - xpath (2.0.0) | |
159 | - nokogiri (~> 1.3) | |
160 | - | |
161 | -PLATFORMS | |
162 | - ruby | |
163 | - | |
164 | -DEPENDENCIES | |
165 | - RedCloth | |
166 | - acts-as-taggable-on | |
167 | - capybara | |
168 | - cucumber | |
169 | - cucumber-rails | |
170 | - daemons | |
171 | - dalli | |
172 | - database_cleaner | |
173 | - exception_notification | |
174 | - fast_gettext | |
175 | - hpricot | |
176 | - mocha | |
177 | - nokogiri | |
178 | - pg | |
179 | - prototype-rails | |
180 | - prototype_legacy_helper (= 0.0.0)! | |
181 | - rails | |
182 | - rails_autolink | |
183 | - rake | |
184 | - rest-client | |
185 | - rmagick | |
186 | - rspec | |
187 | - rspec-rails | |
188 | - ruby-feedparser | |
189 | - selenium-webdriver | |
190 | - thin | |
191 | - will_paginate |
Rakefile
... | ... | @@ -6,3 +6,13 @@ |
6 | 6 | require File.expand_path('../config/application', __FILE__) |
7 | 7 | |
8 | 8 | Noosfero::Application.load_tasks |
9 | + | |
10 | +[ | |
11 | + "baseplugins/*/{tasks,lib/tasks,rails/tasks}/**/*.rake", | |
12 | + "config/plugins/*/{tasks,lib/tasks,rails/tasks}/**/*.rake", | |
13 | + "config/plugins/*/vendor/plugins/*/{tasks,lib/tasks,rails/tasks}/**/*.rake", | |
14 | +].map do |pattern| | |
15 | + Dir.glob(pattern).sort | |
16 | +end.flatten.each do |taskfile| | |
17 | + load taskfile | |
18 | +end | ... | ... |
Vagrantfile
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | |
4 | 4 | VAGRANTFILE_API_VERSION = "2" |
5 | 5 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| |
6 | - config.vm.box = "debian-wheezy" | |
6 | + config.vm.box = ENV.fetch('VAGRANT_BOX', "debian-wheezy") | |
7 | 7 | config.vm.network :forwarded_port, host: 3000, guest: 3000 |
8 | 8 | config.vm.provision :shell do |shell| |
9 | 9 | shell.inline = 'su vagrant -c /vagrant/script/vagrant' | ... | ... |
app/controllers/admin/environment_design_controller.rb
... | ... | @@ -3,9 +3,7 @@ class EnvironmentDesignController < BoxOrganizerController |
3 | 3 | protect 'edit_environment_design', :environment |
4 | 4 | |
5 | 5 | def available_blocks |
6 | - # TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from | |
7 | - # the Noosfero core soon, see ActionItem3045 | |
8 | - @available_blocks ||= [ ArticleBlock, LoginBlock, EnvironmentStatisticsBlock, RecentDocumentsBlock, EnterprisesBlock, CommunitiesBlock, SellersSearchBlock, LinkListBlock, FeedReaderBlock, SlideshowBlock, HighlightsBlock, FeaturedProductsBlock, CategoriesBlock, RawHTMLBlock, TagsBlock ] | |
6 | + @available_blocks ||= [ ArticleBlock, LoginBlock, RecentDocumentsBlock, EnterprisesBlock, CommunitiesBlock, SellersSearchBlock, LinkListBlock, FeedReaderBlock, SlideshowBlock, HighlightsBlock, FeaturedProductsBlock, CategoriesBlock, RawHTMLBlock, TagsBlock ] | |
9 | 7 | @available_blocks += plugins.dispatch(:extra_blocks, :type => Environment) |
10 | 8 | end |
11 | 9 | ... | ... |
app/controllers/application_controller.rb
... | ... | @@ -8,7 +8,7 @@ class ApplicationController < ActionController::Base |
8 | 8 | before_filter :init_noosfero_plugins |
9 | 9 | before_filter :allow_cross_domain_access |
10 | 10 | before_filter :login_required, :if => :private_environment? |
11 | - before_filter :verify_members_whitelist, :if => :user | |
11 | + before_filter :verify_members_whitelist, :if => [:private_environment?, :user] | |
12 | 12 | |
13 | 13 | def verify_members_whitelist |
14 | 14 | render_access_denied unless user.is_admin? || environment.in_whitelist?(user) |
... | ... | @@ -40,7 +40,7 @@ class ApplicationController < ActionController::Base |
40 | 40 | |
41 | 41 | theme_layout = theme_option(:layout) |
42 | 42 | if theme_layout |
43 | - theme_view_file('layouts/'+theme_layout) || theme_layout | |
43 | + (theme_view_file('layouts/'+theme_layout) || theme_layout).to_s | |
44 | 44 | else |
45 | 45 | 'application' |
46 | 46 | end | ... | ... |
app/controllers/my_profile/cms_controller.rb
... | ... | @@ -4,6 +4,12 @@ class CmsController < MyProfileController |
4 | 4 | |
5 | 5 | include ArticleHelper |
6 | 6 | |
7 | + def search_tags | |
8 | + arg = params[:term].downcase | |
9 | + result = ActsAsTaggableOn::Tag.find(:all, :conditions => ['LOWER(name) LIKE ?', "%#{arg}%"]) | |
10 | + render :text => prepare_to_token_input_by_label(result).to_json, :content_type => 'application/json' | |
11 | + end | |
12 | + | |
7 | 13 | def self.protect_if(*args) |
8 | 14 | before_filter(*args) do |c| |
9 | 15 | user, profile = c.send(:user), c.send(:profile) |
... | ... | @@ -221,7 +227,7 @@ class CmsController < MyProfileController |
221 | 227 | @article = profile.articles.find(params[:id]) |
222 | 228 | if request.post? |
223 | 229 | @article.destroy |
224 | - session[:notice] = _("\"#{@article.name}\" was removed.") | |
230 | + session[:notice] = _("\"%s\" was removed." % @article.name) | |
225 | 231 | referer = Rails.application.routes.recognize_path URI.parse(request.referer).path rescue nil |
226 | 232 | if referer and referer[:controller] == 'cms' and referer[:action] != 'edit' |
227 | 233 | redirect_to referer | ... | ... |
app/controllers/my_profile/memberships_controller.rb
... | ... | @@ -21,6 +21,9 @@ class MembershipsController < MyProfileController |
21 | 21 | @back_to = params[:back_to] || url_for(:action => 'index') |
22 | 22 | if request.post? && @community.valid? |
23 | 23 | @community = Community.create_after_moderation(user, params[:community].merge({:environment => environment})) |
24 | + if @community.new_record? | |
25 | + session[:notice] = _('Your new community creation request will be evaluated by an administrator. You will be notified.') | |
26 | + end | |
24 | 27 | redirect_to @back_to |
25 | 28 | return |
26 | 29 | end | ... | ... |
app/controllers/my_profile/tasks_controller.rb
... | ... | @@ -4,6 +4,7 @@ class TasksController < MyProfileController |
4 | 4 | |
5 | 5 | def index |
6 | 6 | @filter = params[:filter_type].blank? ? nil : params[:filter_type] |
7 | + @task_types = Task.pending_types_for(profile) | |
7 | 8 | @tasks = Task.to(profile).without_spam.pending.of(@filter).order_by('created_at', 'asc').paginate(:per_page => Task.per_page, :page => params[:page]) |
8 | 9 | @failed = params ? params[:failed] : {} |
9 | 10 | end | ... | ... |
app/controllers/public/account_controller.rb
... | ... | @@ -15,11 +15,23 @@ class AccountController < ApplicationController |
15 | 15 | |
16 | 16 | def activate |
17 | 17 | @user = User.find_by_activation_code(params[:activation_code]) if params[:activation_code] |
18 | - if @user and @user.activate | |
19 | - @message = _("Your account has been activated, now you can log in!") | |
20 | - check_redirection | |
21 | - session[:join] = params[:join] unless params[:join].blank? | |
22 | - render :action => 'login', :userlogin => @user.login | |
18 | + if @user | |
19 | + unless @user.environment.enabled?('admin_must_approve_new_users') | |
20 | + if @user.activate | |
21 | + @message = _("Your account has been activated, now you can log in!") | |
22 | + check_redirection | |
23 | + session[:join] = params[:join] unless params[:join].blank? | |
24 | + render :action => 'login', :userlogin => @user.login | |
25 | + end | |
26 | + else | |
27 | + if @user.create_moderate_task | |
28 | + session[:notice] = _('Thanks for registering. The administrators were notified.') | |
29 | + @register_pending = true | |
30 | + @user.activation_code = nil | |
31 | + @user.save! | |
32 | + redirect_to :controller => :home | |
33 | + end | |
34 | + end | |
23 | 35 | else |
24 | 36 | session[:notice] = _("It looks like you're trying to activate an account. Perhaps have already activated this account?") |
25 | 37 | redirect_to :controller => :home |
... | ... | @@ -85,6 +97,7 @@ class AccountController < ApplicationController |
85 | 97 | @user.return_to = session[:return_to] |
86 | 98 | @person = Person.new(params[:profile_data]) |
87 | 99 | @person.environment = @user.environment |
100 | + | |
88 | 101 | if request.post? |
89 | 102 | if may_be_a_bot |
90 | 103 | set_signup_start_time_for_now |
... | ... | @@ -103,11 +116,20 @@ class AccountController < ApplicationController |
103 | 116 | invitation.update_attributes!({:friend => @user.person}) |
104 | 117 | invitation.finish |
105 | 118 | end |
119 | + | |
120 | + unless params[:file].nil? | |
121 | + image = Image::new :uploaded_data=> params[:file][:image] | |
122 | + | |
123 | + @user.person.image = image | |
124 | + @user.person.save | |
125 | + end | |
126 | + | |
106 | 127 | if @user.activated? |
107 | 128 | self.current_user = @user |
108 | 129 | check_join_in_community(@user) |
109 | 130 | go_to_signup_initial_page |
110 | 131 | else |
132 | + session[:notice] = _('Thanks for registering!') | |
111 | 133 | @register_pending = true |
112 | 134 | end |
113 | 135 | end | ... | ... |
app/controllers/public/chat_controller.rb
... | ... | @@ -19,9 +19,13 @@ class ChatController < PublicController |
19 | 19 | def avatar |
20 | 20 | profile = environment.profiles.find_by_identifier(params[:id]) |
21 | 21 | filename, mimetype = profile_icon(profile, :minor, true) |
22 | - data = File.read(File.join(Rails.root, 'public', filename)) | |
23 | - render :text => data, :layout => false, :content_type => mimetype | |
24 | - expires_in 24.hours | |
22 | + if filename =~ /^https?:/ | |
23 | + redirect_to filename | |
24 | + else | |
25 | + data = File.read(File.join(Rails.root, 'public', filename)) | |
26 | + render :text => data, :layout => false, :content_type => mimetype | |
27 | + expires_in 24.hours | |
28 | + end | |
25 | 29 | end |
26 | 30 | |
27 | 31 | def index | ... | ... |
app/controllers/public/content_viewer_controller.rb
... | ... | @@ -216,8 +216,6 @@ class ContentViewerController < ApplicationController |
216 | 216 | if @page.has_posts? |
217 | 217 | posts = get_posts(params[:year], params[:month]) |
218 | 218 | |
219 | - posts = posts.includes(:parent, {:profile => [:domains, :environment]}, :author) | |
220 | - | |
221 | 219 | #FIXME Need to run this before the pagination because this version of |
222 | 220 | # will_paginate returns a will_paginate collection instead of a |
223 | 221 | # relation. | ... | ... |
app/helpers/application_helper.rb
... | ... | @@ -482,7 +482,12 @@ module ApplicationHelper |
482 | 482 | '/images/icons-app/enterprise-'+ size.to_s() +'.png' |
483 | 483 | end |
484 | 484 | else |
485 | - '/images/icons-app/person-'+ size.to_s() +'.png' | |
485 | + pixels = Image.attachment_options[:thumbnails][size].split('x').first | |
486 | + gravatar_profile_image_url( | |
487 | + profile.email, | |
488 | + :size => pixels, | |
489 | + :d => gravatar_default | |
490 | + ) | |
486 | 491 | end |
487 | 492 | filename = default_or_themed_icon(icon) |
488 | 493 | end |
... | ... | @@ -602,7 +607,7 @@ module ApplicationHelper |
602 | 607 | end |
603 | 608 | |
604 | 609 | def gravatar_default |
605 | - (respond_to?(:theme_option) && theme_option.present? && theme_option['gravatar']) || NOOSFERO_CONF['gravatar'] | |
610 | + (respond_to?(:theme_option) && theme_option.present? && theme_option['gravatar']) || NOOSFERO_CONF['gravatar'] || 'mm' | |
606 | 611 | end |
607 | 612 | |
608 | 613 | attr_reader :environment |
... | ... | @@ -1281,9 +1286,9 @@ module ApplicationHelper |
1281 | 1286 | |
1282 | 1287 | def delete_article_message(article) |
1283 | 1288 | if article.folder? |
1284 | - _("Are you sure that you want to remove the folder \"#{article.name}\"? Note that all the items inside it will also be removed!") | |
1289 | + _("Are you sure that you want to remove the folder \"%s\"? Note that all the items inside it will also be removed!") % article.name | |
1285 | 1290 | else |
1286 | - _("Are you sure that you want to remove the item \"#{article.name}\"?") | |
1291 | + _("Are you sure that you want to remove the item \"%s\"?") % article.name | |
1287 | 1292 | end |
1288 | 1293 | end |
1289 | 1294 | ... | ... |
app/helpers/article_helper.rb
... | ... | @@ -83,6 +83,10 @@ module ArticleHelper |
83 | 83 | array.map { |object| {:id => object.id, :name => object.name} } |
84 | 84 | end |
85 | 85 | |
86 | + def prepare_to_token_input_by_label(array) | |
87 | + array.map { |object| {:label => object.name, :value => object.name} } | |
88 | + end | |
89 | + | |
86 | 90 | def cms_label_for_new_children |
87 | 91 | _('New article') |
88 | 92 | end | ... | ... |
app/helpers/layout_helper.rb
... | ... | @@ -27,6 +27,7 @@ module LayoutHelper |
27 | 27 | 'thickbox', |
28 | 28 | 'lightbox', |
29 | 29 | 'colorbox', |
30 | + 'inputosaurus', | |
30 | 31 | pngfix_stylesheet_path, |
31 | 32 | ] + tokeninput_stylesheets |
32 | 33 | plugins_stylesheets = @plugins.select(&:stylesheet?).map { |plugin| plugin.class.public_path('style.css') } | ... | ... |
app/models/article.rb
... | ... | @@ -157,14 +157,17 @@ class Article < ActiveRecord::Base |
157 | 157 | self.profile |
158 | 158 | end |
159 | 159 | |
160 | - def self.human_attribute_name(attrib, options = {}) | |
160 | + def self.human_attribute_name_with_customization(attrib, options={}) | |
161 | 161 | case attrib.to_sym |
162 | 162 | when :name |
163 | 163 | _('Title') |
164 | 164 | else |
165 | - _(self.superclass.human_attribute_name(attrib)) | |
165 | + _(self.human_attribute_name_without_customization(attrib)) | |
166 | 166 | end |
167 | 167 | end |
168 | + class << self | |
169 | + alias_method_chain :human_attribute_name, :customization | |
170 | + end | |
168 | 171 | |
169 | 172 | def css_class_list |
170 | 173 | [self.class.name.to_css_class] | ... | ... |
app/models/box.rb
... | ... | @@ -28,9 +28,6 @@ class Box < ActiveRecord::Base |
28 | 28 | CategoriesBlock, |
29 | 29 | CommunitiesBlock, |
30 | 30 | EnterprisesBlock, |
31 | - # TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from | |
32 | - # the Noosfero core soon, see ActionItem3045 | |
33 | - EnvironmentStatisticsBlock, | |
34 | 31 | FansBlock, |
35 | 32 | FavoriteEnterprisesBlock, |
36 | 33 | FeedReaderBlock, |
... | ... | @@ -53,9 +50,6 @@ class Box < ActiveRecord::Base |
53 | 50 | CommunitiesBlock, |
54 | 51 | DisabledEnterpriseMessageBlock, |
55 | 52 | EnterprisesBlock, |
56 | - # TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from | |
57 | - # the Noosfero core soon, see ActionItem3045 | |
58 | - EnvironmentStatisticsBlock, | |
59 | 53 | FansBlock, |
60 | 54 | FavoriteEnterprisesBlock, |
61 | 55 | FeaturedProductsBlock, | ... | ... |
app/models/change_password.rb
... | ... | @@ -2,16 +2,19 @@ class ChangePassword < Task |
2 | 2 | |
3 | 3 | attr_accessor :password, :password_confirmation |
4 | 4 | |
5 | - def self.human_attribute_name(attrib, options = {}) | |
5 | + def self.human_attribute_name_with_customization(attrib, options={}) | |
6 | 6 | case attrib.to_sym |
7 | 7 | when :password |
8 | 8 | _('Password') |
9 | 9 | when :password_confirmation |
10 | 10 | _('Password Confirmation') |
11 | 11 | else |
12 | - _(self.superclass.human_attribute_name(attrib)) | |
12 | + _(self.human_attribute_name_without_customization(attrib)) | |
13 | 13 | end |
14 | 14 | end |
15 | + class << self | |
16 | + alias_method_chain :human_attribute_name, :customization | |
17 | + end | |
15 | 18 | |
16 | 19 | validates_presence_of :requestor |
17 | 20 | ... | ... |
app/models/environment.rb
... | ... | @@ -124,6 +124,7 @@ class Environment < ActiveRecord::Base |
124 | 124 | 'organizations_are_moderated_by_default' => _("Organizations have moderated publication by default"), |
125 | 125 | 'enable_organization_url_change' => _("Allow organizations to change their URL"), |
126 | 126 | 'admin_must_approve_new_communities' => _("Admin must approve creation of communities"), |
127 | + 'admin_must_approve_new_users' => _("Admin must approve registration of new users"), | |
127 | 128 | 'show_balloon_with_profile_links_when_clicked' => _('Show a balloon with profile links when a profile image is clicked'), |
128 | 129 | 'xmpp_chat' => _('XMPP/Jabber based chat'), |
129 | 130 | 'show_zoom_button_on_article_images' => _('Show a zoom link on all article images'), |
... | ... | @@ -176,9 +177,6 @@ class Environment < ActiveRecord::Base |
176 | 177 | |
177 | 178 | # "left" area |
178 | 179 | env.boxes[1].blocks << LoginBlock.new |
179 | - # TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from | |
180 | - # the Noosfero core soon, see ActionItem3045 | |
181 | - env.boxes[1].blocks << EnvironmentStatisticsBlock.new | |
182 | 180 | env.boxes[1].blocks << RecentDocumentsBlock.new |
183 | 181 | |
184 | 182 | # "right" area |
... | ... | @@ -806,7 +804,7 @@ class Environment < ActiveRecord::Base |
806 | 804 | end |
807 | 805 | |
808 | 806 | def notification_emails |
809 | - [noreply_email.blank? ? nil : noreply_email].compact + admins.map(&:email) | |
807 | + [contact_email].select(&:present?) + admins.map(&:email) | |
810 | 808 | end |
811 | 809 | |
812 | 810 | after_create :create_templates | ... | ... |
app/models/environment_statistics_block.rb
... | ... | @@ -1,33 +0,0 @@ |
1 | -# TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from | |
2 | -# the Noosfero core soon, see ActionItem3045 | |
3 | - | |
4 | -class EnvironmentStatisticsBlock < Block | |
5 | - | |
6 | - def self.description | |
7 | - _('Environment stastistics (DEPRECATED)') | |
8 | - end | |
9 | - | |
10 | - def default_title | |
11 | - _('Statistics for %s') % owner.name | |
12 | - end | |
13 | - | |
14 | - def help | |
15 | - _('This block presents some statistics about your environment.') | |
16 | - end | |
17 | - | |
18 | - def content(args={}) | |
19 | - users = owner.people.visible.count | |
20 | - enterprises = owner.enterprises.visible.count | |
21 | - communities = owner.communities.visible.count | |
22 | - | |
23 | - info = [] | |
24 | - info << (n_('One user', '%{num} users', users) % { :num => users }) | |
25 | - unless owner.enabled?('disable_asset_enterprises') | |
26 | - info << (n_('One enterprise', '%{num} enterprises', enterprises) % { :num => enterprises }) | |
27 | - end | |
28 | - info << (n_('One community', '%{num} communities', communities) % { :num => communities }) | |
29 | - | |
30 | - block_title(title) + content_tag('ul', info.map {|item| content_tag('li', item) }.join("\n")) | |
31 | - end | |
32 | - | |
33 | -end |
app/models/external_feed.rb
... | ... | @@ -30,6 +30,7 @@ class ExternalFeed < ActiveRecord::Base |
30 | 30 | article.source = link |
31 | 31 | article.profile = blog.profile |
32 | 32 | article.parent = blog |
33 | + article.author_name = self.feed_title | |
33 | 34 | unless blog.children.exists?(:slug => article.slug) |
34 | 35 | article.save! |
35 | 36 | article.delay.create_activity | ... | ... |
app/models/feed_reader_block.rb
app/models/link_list_block.rb
app/models/main_block.rb
... | ... | @@ -0,0 +1,59 @@ |
1 | +class ModerateUserRegistration < Task | |
2 | + | |
3 | + settings_items :user_id, :type => String | |
4 | + settings_items :name, :type => String | |
5 | + settings_items :author_name, :type => String | |
6 | + settings_items :email, :type => String | |
7 | + | |
8 | + after_create :schedule_spam_checking | |
9 | + | |
10 | + alias :environment :target | |
11 | + alias :environment= :target= | |
12 | + | |
13 | + def schedule_spam_checking | |
14 | + self.delay.check_for_spam | |
15 | + end | |
16 | + | |
17 | + include Noosfero::Plugin::HotSpot | |
18 | + | |
19 | + def sender | |
20 | + "#{name} (#{email})" | |
21 | + end | |
22 | + | |
23 | + def perform | |
24 | + user=environment.users.find_by_id(user_id) | |
25 | + user.activate | |
26 | + end | |
27 | + | |
28 | + def title | |
29 | + _("New user") | |
30 | + end | |
31 | + | |
32 | + def subject | |
33 | + name | |
34 | + end | |
35 | + | |
36 | + def information | |
37 | + { :message => _('%{sender} wants to register.'), | |
38 | + :variables => {:sender => sender} } | |
39 | + end | |
40 | + | |
41 | + def icon | |
42 | + result = {:type => :defined_image, :src => '/images/icons-app/person-minor.png', :name => name} | |
43 | + end | |
44 | + | |
45 | + def target_notification_description | |
46 | + _('%{sender} tried to register.') % | |
47 | + {:sender => sender} | |
48 | + end | |
49 | + | |
50 | + def target_notification_message | |
51 | + target_notification_description + "\n\n" + | |
52 | + _('You need to login on %{system} in order to approve or reject this user.') % { :environment => self.environment } | |
53 | + end | |
54 | + | |
55 | + def target_notification_message | |
56 | + _("User \"%{user}\" just requested to register. You have to approve or reject it through the \"Pending Validations\" section in your control panel.\n") % { :user => self.name } | |
57 | + end | |
58 | + | |
59 | +end | |
0 | 60 | \ No newline at end of file | ... | ... |
app/models/organization.rb
... | ... | @@ -135,7 +135,11 @@ class Organization < Profile |
135 | 135 | end |
136 | 136 | |
137 | 137 | def notification_emails |
138 | - [contact_email.blank? ? nil : contact_email].compact + admins.map(&:email) | |
138 | + emails = [contact_email].select(&:present?) + admins.map(&:email) | |
139 | + if emails.empty? | |
140 | + emails << environment.contact_email | |
141 | + end | |
142 | + emails | |
139 | 143 | end |
140 | 144 | |
141 | 145 | def already_request_membership?(person) | ... | ... |
app/models/profile_image_block.rb
app/models/profile_info_block.rb
app/models/profile_search_block.rb
app/models/task.rb
... | ... | @@ -73,10 +73,6 @@ class Task < ActiveRecord::Base |
73 | 73 | end |
74 | 74 | end |
75 | 75 | |
76 | - def self.all_types | |
77 | - %w[Invitation EnterpriseActivation AddMember Ticket SuggestArticle AddFriend CreateCommunity AbuseComplaint ApproveComment ApproveArticle CreateEnterprise ChangePassword EmailActivation InviteFriend InviteMember] | |
78 | - end | |
79 | - | |
80 | 76 | # this method finished the task. It calls #perform, which must be overriden |
81 | 77 | # by subclasses. At the end a message (as returned by #finish_message) is |
82 | 78 | # sent to the requestor with #notify_requestor. |
... | ... | @@ -254,6 +250,10 @@ class Task < ActiveRecord::Base |
254 | 250 | { :conditions => [environment_condition, profile_condition].compact.join(' OR ') } |
255 | 251 | } |
256 | 252 | |
253 | + def self.pending_types_for(profile) | |
254 | + Task.to(profile).pending.select('distinct type').map { |t| [t.class.name, t.title] } | |
255 | + end | |
256 | + | |
257 | 257 | def opened? |
258 | 258 | status == Task::Status::ACTIVE || status == Task::Status::HIDDEN |
259 | 259 | end | ... | ... |
app/models/user.rb
... | ... | @@ -16,15 +16,18 @@ class User < ActiveRecord::Base |
16 | 16 | end |
17 | 17 | |
18 | 18 | # FIXME ugly workaround |
19 | - def self.human_attribute_name(attrib, options={}) | |
19 | + def self.human_attribute_name_with_customization(attrib, options={}) | |
20 | 20 | case attrib.to_sym |
21 | 21 | when :login |
22 | 22 | return [_('Username'), _('Email')].join(' / ') |
23 | 23 | when :email |
24 | 24 | return _('e-Mail') |
25 | - else _(self.superclass.human_attribute_name(attrib)) | |
25 | + else _(self.human_attribute_name_without_customization(attrib)) | |
26 | 26 | end |
27 | 27 | end |
28 | + class << self | |
29 | + alias_method_chain :human_attribute_name, :customization | |
30 | + end | |
28 | 31 | |
29 | 32 | before_create do |user| |
30 | 33 | if user.environment.nil? |
... | ... | @@ -47,8 +50,12 @@ class User < ActiveRecord::Base |
47 | 50 | |
48 | 51 | user.person = p |
49 | 52 | end |
50 | - if user.environment.enabled?('skip_new_user_email_confirmation') | |
51 | - user.activate | |
53 | + if user.environment.enabled?('skip_new_user_email_confirmation') | |
54 | + if user.environment.enabled?('admin_must_approve_new_users') | |
55 | + create_moderate_task | |
56 | + else | |
57 | + user.activate | |
58 | + end | |
52 | 59 | end |
53 | 60 | end |
54 | 61 | after_create :deliver_activation_code |
... | ... | @@ -137,6 +144,15 @@ class User < ActiveRecord::Base |
137 | 144 | end |
138 | 145 | end |
139 | 146 | |
147 | + def create_moderate_task | |
148 | + @task = ModerateUserRegistration.new | |
149 | + @task.user_id = self.id | |
150 | + @task.name = self.name | |
151 | + @task.email = self.email | |
152 | + @task.target = self.environment | |
153 | + @task.save | |
154 | + end | |
155 | + | |
140 | 156 | def activated? |
141 | 157 | self.activation_code.nil? && !self.activated_at.nil? |
142 | 158 | end | ... | ... |
app/sweepers/profile_sweeper.rb
... | ... | @@ -8,9 +8,6 @@ class ProfileSweeper # < ActiveRecord::Observer |
8 | 8 | end |
9 | 9 | |
10 | 10 | def after_create(profile) |
11 | - # TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from | |
12 | - # the Noosfero core soon, see ActionItem3045 | |
13 | - expire_statistics_block_cache(profile) | |
14 | 11 | end |
15 | 12 | |
16 | 13 | protected |
... | ... | @@ -31,13 +28,6 @@ protected |
31 | 28 | expire_blogs(profile) if profile.organization? |
32 | 29 | end |
33 | 30 | |
34 | - # TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from | |
35 | - # the Noosfero core soon, see ActionItem3045 | |
36 | - def expire_statistics_block_cache(profile) | |
37 | - blocks = profile.environment.blocks.select { |b| b.kind_of?(EnvironmentStatisticsBlock) } | |
38 | - BlockSweeper.expire_blocks(blocks) | |
39 | - end | |
40 | - | |
41 | 31 | def expire_blogs(profile) |
42 | 32 | profile.blogs.select{|b| !b.empty?}.each do |blog| |
43 | 33 | pages = blog.posts.count / blog.posts_per_page + 1 | ... | ... |
app/views/account/signup.html.erb
... | ... | @@ -2,18 +2,36 @@ |
2 | 2 | <div id='thanks-for-signing'> |
3 | 3 | <% if environment.has_custom_welcome_screen? %> |
4 | 4 | <%= environment.settings[:signup_welcome_screen_body].html_safe %> |
5 | - <% else %> | |
6 | - <h1><%= _("Welcome to %s!") % environment.name %></h1> | |
7 | - <h3><%= _("Thanks for signing up, we're thrilled to have you on our social network!") %></h3> | |
8 | - <p><%= _("Firstly, some tips for getting started:") %></p> | |
9 | - <h4><%= _("Confirm your account!") %></h4> | |
5 | + <% elsif environment.enabled?('admin_must_approve_new_users')%> | |
6 | + <h1><%= _("Welcome to %s!") % environment.name %></h1> | |
7 | + <h3><%= _("Thanks for signing up, we're thrilled to have you on our social network!") %></h3> | |
8 | + <p><%= _("Firstly, some tips for getting started:") %></p> | |
9 | + <% unless environment.enabled?('skip_new_user_email_confirmation') %> | |
10 | + <h4><%= _("Confirm your account and wait for admin approvement!") %></h4> | |
10 | 11 | <p><%= _("You should receive a welcome email from us shortly. Please take a second to follow the link within to confirm your account.") %></p> |
11 | - <p><%= _("You won't appear as %s until your account is confirmed.") % link_to(_('user'), {:controller => :search, :action => :people, :filter => 'more_recent'}, :target => '_blank') %></p> | |
12 | - <h4><%= _("What to do next?") %></h4> | |
13 | - <p><%= _("%s. Upload an avatar and let your friends find you easily :)") % link_to(_('Customize your profile'), {:controller => 'doc', :section => 'user', :topic => 'editing-person-info'}, :target => '_blank') %></p> | |
14 | - <p><%= _("Learn the guidelines. Read the %s for more details on how to use this social network!") % link_to(_('Documentation'), {:controller => 'doc'}, :target => '_blank') %></p> | |
15 | - <p><%= _("%s your Gmail, Yahoo and Hotmail contacts!") % link_to(_('Invite and find'), {:controller => 'doc', :section => 'user', :topic => 'invite-contacts'}, :target => '_blank') %></p> | |
16 | - <p><%= _("Start exploring and have fun!") %></p> | |
12 | + <p><%= _("You won't appear as %s until your account is confirmed and approved.") % link_to(_('user'), {:controller => :search, :action => :people, :filter => 'more_recent'}, :target => '_blank') %></p> | |
13 | + <% else %> | |
14 | + <h4><%= _("Wait for admin approvement!") %></h4> | |
15 | + <p><%= _("The administrators will evaluate your signup request for approvement.") %></p> | |
16 | + <p><%= _("You won't appear as %s until your account is approved.") % link_to(_('user'), {:controller => :search, :action => :people, :filter => 'more_recent'}, :target => '_blank') %></p> | |
17 | + <% end %> | |
18 | + <h4><%= _("What to do next?") %></h4> | |
19 | + <p><%= _("%s. Upload an avatar and let your friends find you easily :)") % link_to(_('Customize your profile'), {:controller => 'doc', :section => 'user', :topic => 'editing-person-info'}, :target => '_blank') %></p> | |
20 | + <p><%= _("Learn the guidelines. Read the %s for more details on how to use this social network!") % link_to(_('Documentation'), {:controller => 'doc'}, :target => '_blank') %></p> | |
21 | + <p><%= _("%s your Gmail, Yahoo and Hotmail contacts!") % link_to(_('Invite and find'), {:controller => 'doc', :section => 'user', :topic => 'invite-contacts'}, :target => '_blank') %></p> | |
22 | + <p><%= _("Start exploring and have fun!") %></p> | |
23 | + <% else %> | |
24 | + <h1><%= _("Welcome to %s!") % environment.name %></h1> | |
25 | + <h3><%= _("Thanks for signing up, we're thrilled to have you on our social network!") %></h3> | |
26 | + <p><%= _("Firstly, some tips for getting started:") %></p> | |
27 | + <h4><%= _("Confirm your account!") %></h4> | |
28 | + <p><%= _("You should receive a welcome email from us shortly. Please take a second to follow the link within to confirm your account.") %></p> | |
29 | + <p><%= _("You won't appear as %s until your account is confirmed.") % link_to(_('user'), {:controller => :search, :action => :people, :filter => 'more_recent'}, :target => '_blank') %></p> | |
30 | + <h4><%= _("What to do next?") %></h4> | |
31 | + <p><%= _("%s. Upload an avatar and let your friends find you easily :)") % link_to(_('Customize your profile'), {:controller => 'doc', :section => 'user', :topic => 'editing-person-info'}, :target => '_blank') %></p> | |
32 | + <p><%= _("Learn the guidelines. Read the %s for more details on how to use this social network!") % link_to(_('Documentation'), {:controller => 'doc'}, :target => '_blank') %></p> | |
33 | + <p><%= _("%s your Gmail, Yahoo and Hotmail contacts!") % link_to(_('Invite and find'), {:controller => 'doc', :section => 'user', :topic => 'invite-contacts'}, :target => '_blank') %></p> | |
34 | + <p><%= _("Start exploring and have fun!") %></p> | |
17 | 35 | <% end %> |
18 | 36 | </div> |
19 | 37 | <% else %> | ... | ... |
app/views/catalog/index.html.erb
... | ... | @@ -14,8 +14,8 @@ |
14 | 14 | |
15 | 15 | <ul id="product-list"> |
16 | 16 | <% @products.each do |product| %> |
17 | - <% extra_content = @plugins.dispatch(:catalog_item_extras, product).collect { |content| instance_eval(&content) } %> | |
18 | - <% extra_content_list = @plugins.dispatch(:catalog_list_item_extras, product).collect { |content| instance_eval(&content) } %> | |
17 | + <% extra_content = @plugins.dispatch(:catalog_item_extras, product).collect { |content| instance_exec(&content) } %> | |
18 | + <% extra_content_list = @plugins.dispatch(:catalog_list_item_extras, product).collect { |content| instance_exec(&content) } %> | |
19 | 19 | |
20 | 20 | <% status = [] %> |
21 | 21 | <% status << 'not-available' if !product.available %> | ... | ... |
app/views/cms/edit.html.erb
... | ... | @@ -31,9 +31,18 @@ |
31 | 31 | |
32 | 32 | <%= select_categories(:article, _('Categorize your article')) %> |
33 | 33 | |
34 | + <br /> | |
35 | + | |
34 | 36 | <%= f.text_field('tag_list', :size => 64) %> |
35 | 37 | <%= content_tag( 'small', _('Separate tags with commas') ) %> |
36 | 38 | |
39 | + <script> | |
40 | + jQuery('#article_tag_list').inputosaurus({ | |
41 | + autoCompleteSource: <%= "'/myprofile/#{profile.identifier}/cms/search_tags'," %> | |
42 | + activateFinalResult : true | |
43 | + }) | |
44 | + </script> | |
45 | + | |
37 | 46 | <div id='edit-article-options'> |
38 | 47 | <%= options_for_article(@article, @tokenized_children) %> |
39 | 48 | </div> | ... | ... |
app/views/layouts/_javascript.html.erb
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | 'jquery-ui-1.10.4/js/jquery-ui-1.10.4.min', 'jquery.scrollTo', 'jquery.form.js', 'jquery-validation/jquery.validate', |
5 | 5 | 'jquery.cookie', 'jquery.ba-bbq.min.js', 'reflection', 'jquery.tokeninput', |
6 | 6 | 'add-and-join', 'report-abuse', 'catalog', 'manage-products', 'autogrow', |
7 | -'jquery-timepicker-addon/dist/jquery-ui-timepicker-addon', 'application.js', 'rails.js', :cache => 'cache/application' %> | |
7 | +'jquery-timepicker-addon/dist/jquery-ui-timepicker-addon', 'application.js', 'rails.js', 'inputosaurus.js', :cache => 'cache/application' %> | |
8 | 8 | |
9 | 9 | <% language = FastGettext.locale %> |
10 | 10 | <% %w{messages methods}.each do |type| %> | ... | ... |
app/views/manage_products/show.html.erb
... | ... | @@ -13,7 +13,7 @@ |
13 | 13 | <%= render :partial => 'manage_products/display_image' %> |
14 | 14 | </div> |
15 | 15 | <div id='product-extra-content'> |
16 | - <% extra_content = @plugins.dispatch(:product_info_extras, @product).collect { |content| instance_eval(&content) } %> | |
16 | + <% extra_content = @plugins.dispatch(:product_info_extras, @product).collect { |content| instance_exec(&content) } %> | |
17 | 17 | <%= extra_content.join("\n") %> |
18 | 18 | </div> |
19 | 19 | <div id='product-info'> | ... | ... |
app/views/profile_editor/_person_form.html.erb
... | ... | @@ -25,6 +25,7 @@ |
25 | 25 | <%= optional_field(@person, 'address', labelled_form_field(_('Address (street and number)'), text_field(:profile_data, :address, :rel => _('Address')))) %> |
26 | 26 | <%= optional_field(@person, 'address_reference', labelled_form_field(_('Address reference'), text_field(:profile_data, :address_reference, :rel => _('Address reference')))) %> |
27 | 27 | <%= optional_field(@person, 'district', labelled_form_field(_('District'), text_field(:profile_data, :district, :rel => _('District')))) %> |
28 | +<%= optional_field(@person, 'image', labelled_form_field(_('Image'), file_field(:file, :image, :rel => _('Image')))) %> | |
28 | 29 | |
29 | 30 | <% optional_field(@person, 'schooling') do %> |
30 | 31 | <div class="formfieldline"> | ... | ... |
app/views/tasks/index.html.erb
... | ... | @@ -3,10 +3,9 @@ |
3 | 3 | <h1><%= _("%s's pending tasks") % profile.name %></h1> |
4 | 4 | <p> |
5 | 5 | |
6 | -<% type_collection = [[nil, _('All')]] %> | |
7 | -<% type_collection += Task.all_types.sort_by {|klass| klass.constantize.new.title}.map{|s| [s, s.constantize.new.title] } %> | |
8 | - | |
9 | - | |
6 | +<% | |
7 | + type_collection = [[nil, _('All')]] + @task_types | |
8 | +%> | |
10 | 9 | |
11 | 10 | <% if !@failed.blank? %> |
12 | 11 | <div id="errorExplanation"> |
... | ... | @@ -39,7 +38,7 @@ |
39 | 38 | |
40 | 39 | <ul class='task-list'> |
41 | 40 | <p> |
42 | - <%= labelled_select(_('Filter')+': ', :filter_type, :first, :last, @filter, type_collection, :onchange => 'document.location.href = "?filter_type="+this.value')%> | |
41 | + <%= labelled_select(_('Filter')+': ', :filter_type, :first, :last, @filter, type_collection, :onchange => "document.location.href = '?filter_type='+this.value") %> | |
43 | 42 | </p> |
44 | 43 | <p> |
45 | 44 | <%= labelled_select(_("Set all to: "), 'set-decisions', 'first', 'last', nil, [['',""],['accept',_("Accept")],['reject',_("Reject")],['skip',_("Skip")]], :id => "up-set-all-tasks-to") %> | ... | ... |
config/application.rb
... | ... | @@ -108,7 +108,7 @@ module Noosfero |
108 | 108 | |
109 | 109 | # Your secret key for verifying cookie session data integrity. |
110 | 110 | # If you change this key, all old sessions will become invalid! |
111 | - # Make sure the secret is at least 30 characters and all random, | |
111 | + # Make sure the secret is at least 30 characters and all random, | |
112 | 112 | # no regular words or you'll be exposed to dictionary attacks. |
113 | 113 | config.secret_token = noosfero_session_secret |
114 | 114 | config.action_dispatch.session = { | ... | ... |
config/cucumber.yml
1 | 1 | <% base_requires = '-r features/support -r features/step_definitions' %> |
2 | -<% default_options = "--color --format progress --strict --tags ~@selenium --tags ~@selenium-fixme --tags ~@fixme --exclude features/support/selenium.rb #{base_requires}" %> | |
2 | +<% default_options = "--format progress --strict --tags ~@selenium --tags ~@selenium-fixme --tags ~@fixme --exclude features/support/selenium.rb #{base_requires}" %> | |
3 | +<% | |
4 | + default_options += ' --color' if $stdout.isatty | |
5 | +%> | |
3 | 6 | <% selenium_options = "--strict --tags @selenium #{base_requires}" %> |
4 | 7 | |
5 | 8 | default: <%= default_options %> | ... | ... |
config/initializers/activities_counter_cache.rb
1 | -if Delayed::Backend::ActiveRecord::Job.table_exists? | |
1 | +if Delayed::Backend::ActiveRecord::Job.table_exists? && | |
2 | + Delayed::Backend::ActiveRecord::Job.attribute_names.include?('queue') | |
2 | 3 | job = Delayed::Backend::ActiveRecord::Job.all :conditions => ['handler LIKE ?', "%ActivitiesCounterCacheJob%"] |
3 | 4 | if job.blank? |
4 | 5 | Delayed::Backend::ActiveRecord::Job.enqueue(ActivitiesCounterCacheJob.new, {:priority => -3}) | ... | ... |
config/initializers/log_memory_consumption.rb
... | ... | @@ -1,5 +0,0 @@ |
1 | -if Delayed::Backend::ActiveRecord::Job.table_exists? | |
2 | - jobs = Delayed::Backend::ActiveRecord::Job.all :conditions => ['handler LIKE ?', "%LogMemoryConsumptionJob%"] | |
3 | - jobs.map(&:destroy) if jobs.present? | |
4 | - Delayed::Backend::ActiveRecord::Job.enqueue(LogMemoryConsumptionJob.new) | |
5 | -end |
... | ... | @@ -0,0 +1,9 @@ |
1 | +if defined? PhusionPassenger | |
2 | + | |
3 | + # from http://russbrooks.com/2010/10/20/rails-cache-memcache-on-passenger-with-smart-spawning | |
4 | + PhusionPassenger.on_event :starting_worker_process do |forked| | |
5 | + if forked | |
6 | + Rails.cache.instance_variable_get(:@data).reset if Rails.cache.class == ActiveSupport::Cache::MemCacheStore | |
7 | + end | |
8 | + end | |
9 | +end | ... | ... |
config/initializers/person_notification.rb
db/migrate/20140708115518_index_domains_filtered_fields.rb
0 → 100644
... | ... | @@ -0,0 +1,10 @@ |
1 | +class IndexDomainsFilteredFields < ActiveRecord::Migration | |
2 | + | |
3 | + def self.up | |
4 | + add_index :domains, [:name] | |
5 | + add_index :domains, [:is_default] | |
6 | + add_index :domains, [:owner_id, :owner_type] | |
7 | + add_index :domains, [:owner_id, :owner_type, :is_default] | |
8 | + end | |
9 | + | |
10 | +end | ... | ... |
db/migrate/20140708121356_index_articles_filtered_fields.rb
0 → 100644
... | ... | @@ -0,0 +1,12 @@ |
1 | +class IndexArticlesFilteredFields < ActiveRecord::Migration | |
2 | + def self.up | |
3 | + %w[articles article_versions].each do |table| | |
4 | + add_index table, [:path] | |
5 | + add_index table, [:path, :profile_id] | |
6 | + end | |
7 | + add_index :articles, [:type] | |
8 | + add_index :articles, [:type, :parent_id] | |
9 | + add_index :articles, [:type, :profile_id] | |
10 | + end | |
11 | + | |
12 | +end | ... | ... |
db/migrate/20140724180943_add_index_to_blog_posts_sort.rb
0 → 100644
... | ... | @@ -0,0 +1,13 @@ |
1 | +class AddIndexToBlogPostsSort < ActiveRecord::Migration | |
2 | + def self.up | |
3 | + %w[articles article_versions].each do |table| | |
4 | + add_index table, [:published_at, :id] | |
5 | + end | |
6 | + end | |
7 | + | |
8 | + def self.down | |
9 | + %w[articles article_versions].each do |table| | |
10 | + remove_index table, [:published_at, :id] | |
11 | + end | |
12 | + end | |
13 | +end | ... | ... |
db/migrate/20140827191326_remove_environment_statistics_block.rb
0 → 100644
... | ... | @@ -0,0 +1,9 @@ |
1 | +class RemoveEnvironmentStatisticsBlock < ActiveRecord::Migration | |
2 | + def self.up | |
3 | + update("UPDATE blocks SET type = 'StatisticsBlock' WHERE type = 'EnvironmentStatisticsBlock'") | |
4 | + end | |
5 | + | |
6 | + def self.down | |
7 | + say("Nothing to undo (cannot recover the data)") | |
8 | + end | |
9 | +end | ... | ... |
db/schema.rb
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | # |
12 | 12 | # It's strongly recommended to check this file into your version control system. |
13 | 13 | |
14 | -ActiveRecord::Schema.define(:version => 20140808185510) do | |
14 | +ActiveRecord::Schema.define(:version => 20140827191326) do | |
15 | 15 | |
16 | 16 | create_table "abuse_reports", :force => true do |t| |
17 | 17 | t.integer "reporter_id" |
... | ... | @@ -95,12 +95,15 @@ ActiveRecord::Schema.define(:version => 20140808185510) do |
95 | 95 | t.integer "license_id" |
96 | 96 | t.integer "image_id" |
97 | 97 | t.integer "position" |
98 | - t.integer "created_by_id" | |
99 | 98 | t.integer "spam_comments_count", :default => 0 |
100 | 99 | t.integer "author_id" |
100 | + t.integer "created_by_id" | |
101 | 101 | end |
102 | 102 | |
103 | 103 | add_index "article_versions", ["article_id"], :name => "index_article_versions_on_article_id" |
104 | + add_index "article_versions", ["path", "profile_id"], :name => "index_article_versions_on_path_and_profile_id" | |
105 | + add_index "article_versions", ["path"], :name => "index_article_versions_on_path" | |
106 | + add_index "article_versions", ["published_at", "id"], :name => "index_article_versions_on_published_at_and_id" | |
104 | 107 | |
105 | 108 | create_table "articles", :force => true do |t| |
106 | 109 | t.string "name" |
... | ... | @@ -143,9 +146,9 @@ ActiveRecord::Schema.define(:version => 20140808185510) do |
143 | 146 | t.integer "license_id" |
144 | 147 | t.integer "image_id" |
145 | 148 | t.integer "position" |
146 | - t.integer "created_by_id" | |
147 | 149 | t.integer "spam_comments_count", :default => 0 |
148 | 150 | t.integer "author_id" |
151 | + t.integer "created_by_id" | |
149 | 152 | end |
150 | 153 | |
151 | 154 | add_index "articles", ["comments_count"], :name => "index_articles_on_comments_count" |
... | ... | @@ -153,9 +156,15 @@ ActiveRecord::Schema.define(:version => 20140808185510) do |
153 | 156 | add_index "articles", ["hits"], :name => "index_articles_on_hits" |
154 | 157 | add_index "articles", ["name"], :name => "index_articles_on_name" |
155 | 158 | add_index "articles", ["parent_id"], :name => "index_articles_on_parent_id" |
159 | + add_index "articles", ["path", "profile_id"], :name => "index_articles_on_path_and_profile_id" | |
160 | + add_index "articles", ["path"], :name => "index_articles_on_path" | |
156 | 161 | add_index "articles", ["profile_id"], :name => "index_articles_on_profile_id" |
162 | + add_index "articles", ["published_at", "id"], :name => "index_articles_on_published_at_and_id" | |
157 | 163 | add_index "articles", ["slug"], :name => "index_articles_on_slug" |
158 | 164 | add_index "articles", ["translation_of_id"], :name => "index_articles_on_translation_of_id" |
165 | + add_index "articles", ["type", "parent_id"], :name => "index_articles_on_type_and_parent_id" | |
166 | + add_index "articles", ["type", "profile_id"], :name => "index_articles_on_type_and_profile_id" | |
167 | + add_index "articles", ["type"], :name => "index_articles_on_type" | |
159 | 168 | |
160 | 169 | create_table "articles_categories", :id => false, :force => true do |t| |
161 | 170 | t.integer "article_id" |
... | ... | @@ -277,6 +286,11 @@ ActiveRecord::Schema.define(:version => 20140808185510) do |
277 | 286 | t.string "google_maps_key" |
278 | 287 | end |
279 | 288 | |
289 | + add_index "domains", ["is_default"], :name => "index_domains_on_is_default" | |
290 | + add_index "domains", ["name"], :name => "index_domains_on_name" | |
291 | + add_index "domains", ["owner_id", "owner_type", "is_default"], :name => "index_domains_on_owner_id_and_owner_type_and_is_default" | |
292 | + add_index "domains", ["owner_id", "owner_type"], :name => "index_domains_on_owner_id_and_owner_type" | |
293 | + | |
280 | 294 | create_table "environments", :force => true do |t| |
281 | 295 | t.string "name" |
282 | 296 | t.string "contact_email" | ... | ... |
debian/changelog
1 | +noosfero (1.0~rc3) wheezy-test; urgency=low | |
2 | + | |
3 | + * Third release candidate to Noosfero 1.0 | |
4 | + | |
5 | + -- Antonio Terceiro <terceiro@debian.org> Fri, 12 Sep 2014 16:20:58 -0300 | |
6 | + | |
7 | +noosfero (1.0~rc2) wheezy-test; urgency=low | |
8 | + | |
9 | + * Second 1.0 release candidate | |
10 | + | |
11 | + -- Antonio Terceiro <terceiro@debian.org> Fri, 12 Sep 2014 13:01:11 -0300 | |
12 | + | |
1 | 13 | noosfero (1.0~rc1) wheezy-test; urgency=low |
2 | 14 | |
3 | 15 | * First 1.0 release candidate |
... | ... | @@ -10,6 +22,12 @@ noosfero (0.99.0~rc20140618202455) wheezy-test; urgency=low |
10 | 22 | |
11 | 23 | -- Rodrigo Souto <rodrigo@colivre.coop.br> Wed, 18 Jun 2014 20:25:01 +0000 |
12 | 24 | |
25 | +noosfero (0.47.4) unstable; urgency=low | |
26 | + | |
27 | + * Bugfixes and performance optimizations | |
28 | + | |
29 | + -- Rodrigo Souto <rodrigo@colivre.coop.br> Thu, 21 Aug 2014 19:25:37 +0000 | |
30 | + | |
13 | 31 | noosfero (0.47.3) unstable; urgency=low |
14 | 32 | |
15 | 33 | * Bugfixes release | ... | ... |
debian/control
... | ... | @@ -9,7 +9,7 @@ Build-Depends: |
9 | 9 | ruby-gettext, |
10 | 10 | ruby-sqlite3, |
11 | 11 | rake, |
12 | - rails3 (>= 3.2.6-1~), | |
12 | + rails3 (>= 3.2.19-1~), | |
13 | 13 | ruby-rspec, |
14 | 14 | ruby-rspec-rails, |
15 | 15 | ruby-will-paginate, |
... | ... | @@ -30,12 +30,14 @@ Vcs-Browser: http://git.colivre.coop.br/?p=noosfero.git |
30 | 30 | |
31 | 31 | Package: noosfero |
32 | 32 | Architecture: all |
33 | +Pre-Depends: ruby1.8 (>= 1.8.7.358) | |
33 | 34 | Depends: |
34 | 35 | rails3 (>= 3.2.6-1~), |
35 | 36 | ruby (>= 1:1.9.3), |
36 | 37 | rake, |
37 | 38 | ruby-dalli, |
38 | 39 | ruby-exception-notification, |
40 | + ruby-gettext, | |
39 | 41 | ruby-fast-gettext, |
40 | 42 | ruby-pg, |
41 | 43 | ruby-rmagick, | ... | ... |
debian/noosfero.install
debian/noosfero.links
... | ... | @@ -15,3 +15,4 @@ var/lib/noosfero-data/public/thumbnails usr/share/noosfero/public/th |
15 | 15 | usr/share/noosfero/public/designs/themes/noosfero usr/share/noosfero/public/designs/themes/default |
16 | 16 | usr/share/noosfero/public/designs/icons/tango usr/share/noosfero/public/designs/icons/default |
17 | 17 | usr/share/noosfero/script/noosfero-plugins usr/sbin/noosfero-plugins |
18 | +usr/share/noosfero/Gemfile.lock /dev/null | ... | ... |
etc/init.d/noosfero
... | ... | @@ -45,7 +45,7 @@ if [ -z "$NOOSFERO_DIR" ] || [ -z "$NOOSFERO_USER" ]; then |
45 | 45 | fi |
46 | 46 | |
47 | 47 | if test -x /usr/sbin/noosfero-check-dbconfig ; then |
48 | - if ! noosfero-check-dbconfig; then | |
48 | + if ! /usr/sbin/noosfero-check-dbconfig; then | |
49 | 49 | echo "Noosfero database access not configured, service disabled." |
50 | 50 | exit 0 |
51 | 51 | fi | ... | ... |
features/signup.feature
... | ... | @@ -298,3 +298,55 @@ Feature: signup |
298 | 298 | And wait for the captcha signup time |
299 | 299 | And I press "Create my account" |
300 | 300 | Then "José da Silva" should be a member of "Free Software" |
301 | + | |
302 | + @selenium | |
303 | + Scenario: user registration is moderated by admin | |
304 | + Given feature "admin_must_approve_new_users" is enabled on environment | |
305 | + And feature "skip_new_user_email_confirmation" is disabled on environment | |
306 | + And I go to /account/signup | |
307 | + And I fill in "Username" with "teste" | |
308 | + And I fill in "Password" with "123456" | |
309 | + And I fill in "Password confirmation" with "123456" | |
310 | + And I fill in "e-Mail" with "teste@teste.com" | |
311 | + And I fill in "Full name" with "Teste da Silva" | |
312 | + And wait for the captcha signup time | |
313 | + And I press "Create my account" | |
314 | + And I go to teste's confirmation URL | |
315 | + And I am logged in as admin | |
316 | + And I follow "Control panel" | |
317 | + And I follow "Tasks" | |
318 | + And I choose "Accept" | |
319 | + And I press "Apply!" | |
320 | + And I follow "Logout" | |
321 | + And Teste da Silva's account is activated | |
322 | + And I follow "Login" | |
323 | + And I fill in "Username / Email" with "teste" | |
324 | + And I fill in "Password" with "123456" | |
325 | + And I press "Log in" | |
326 | + Then I should see "teste" | |
327 | + | |
328 | + | |
329 | + @selenium | |
330 | + Scenario: user registration is not accepted by the admin | |
331 | + Given feature "admin_must_approve_new_users" is enabled on environment | |
332 | + And feature "skip_new_user_email_confirmation" is disabled on environment | |
333 | + And I go to /account/signup | |
334 | + And I fill in "Username" with "teste" | |
335 | + And I fill in "Password" with "123456" | |
336 | + And I fill in "Password confirmation" with "123456" | |
337 | + And I fill in "e-Mail" with "teste@teste.com" | |
338 | + And I fill in "Full name" with "Teste da Silva" | |
339 | + And wait for the captcha signup time | |
340 | + And I press "Create my account" | |
341 | + And I go to teste's confirmation URL | |
342 | + And I am logged in as admin | |
343 | + And I follow "Control panel" | |
344 | + And I follow "Tasks" | |
345 | + And I choose "Reject" | |
346 | + And I press "Apply!" | |
347 | + And I follow "Logout" | |
348 | + And I follow "Login" | |
349 | + And I fill in "Username / Email" with "teste" | |
350 | + And I fill in "Password" with "123456" | |
351 | + And I press "Log in" | |
352 | + Then I should not see "teste" | |
301 | 353 | \ No newline at end of file | ... | ... |
gitignore.example
lib/acts_as_having_posts.rb
lib/log_memory_consumption_job.rb
lib/noosfero/i18n.rb
... | ... | @@ -20,5 +20,5 @@ if File.exists?(locale_dir) |
20 | 20 | repos << FastGettext::TranslationRepository.build('iso_3166', :type => 'mo', :path => locale_dir) |
21 | 21 | end |
22 | 22 | |
23 | -FastGettext.add_text_domain 'noosferofull', :type => :chain, :chain => repos | |
24 | -FastGettext.default_text_domain = 'noosferofull' | |
23 | +FastGettext.add_text_domain 'noosfero', :type => :chain, :chain => repos | |
24 | +FastGettext.default_text_domain = 'noosfero' | ... | ... |
lib/noosfero/plugin.rb
... | ... | @@ -62,14 +62,16 @@ class Noosfero::Plugin |
62 | 62 | path << File.join(dir, 'lib') |
63 | 63 | # load vendor/plugins |
64 | 64 | Dir.glob(File.join(dir, '/vendor/plugins/*')).each do |vendor_plugin| |
65 | - path << "#{vendor_plugin}/lib" | |
66 | - init = "#{vendor_plugin}/init.rb" | |
67 | - require init.gsub(/.rb$/, '') if File.file? init | |
68 | - end | |
65 | + path << "#{vendor_plugin}/lib" | |
66 | + end | |
67 | + end | |
68 | + Dir.glob(File.join(dir, '/vendor/plugins/*')).each do |vendor_plugin| | |
69 | + init = "#{vendor_plugin}/init.rb" | |
70 | + require init.gsub(/.rb$/, '') if File.file? init | |
69 | 71 | end |
70 | 72 | |
71 | 73 | # add view path |
72 | - ActionController::Base.view_paths.unshift(File.join(dir, 'views')) | |
74 | + config.paths['app/views'].unshift File.join(dir, 'views') | |
73 | 75 | end |
74 | 76 | end |
75 | 77 | |
... | ... | @@ -237,7 +239,7 @@ class Noosfero::Plugin |
237 | 239 | nil |
238 | 240 | end |
239 | 241 | |
240 | - # -> Adds content to calalog item | |
242 | + # -> Adds content to catalog item | |
241 | 243 | # returns = lambda block that creates html code |
242 | 244 | def catalog_item_extras(item) |
243 | 245 | nil |
... | ... | @@ -249,7 +251,7 @@ class Noosfero::Plugin |
249 | 251 | nil |
250 | 252 | end |
251 | 253 | |
252 | - # -> Adds content to calalog list item | |
254 | + # -> Adds content to catalog list item | |
253 | 255 | # returns = lambda block that creates html code |
254 | 256 | def catalog_list_item_extras(item) |
255 | 257 | nil | ... | ... |
lib/noosfero/version.rb
lib/tasks/doc.rake
... | ... | @@ -5,7 +5,7 @@ namespace :noosfero do |
5 | 5 | end |
6 | 6 | task :link_plugins_textiles do |
7 | 7 | plugins_textiles.each do |file| |
8 | - ln_sf Rails.root.join(file), 'doc/noosfero/plugins/' | |
8 | + ln_sf File.join('../../../', file), 'doc/noosfero/plugins/' | |
9 | 9 | end |
10 | 10 | end |
11 | 11 | task :unlink_plugins_textiles do | ... | ... |
lib/tasks/gettext.rake
... | ... | @@ -6,8 +6,16 @@ makemo_stamp = 'tmp/makemo.stamp' |
6 | 6 | desc "Create mo-files for L10n" |
7 | 7 | task :makemo => makemo_stamp |
8 | 8 | file makemo_stamp => Dir.glob('po/*/noosfero.po') do |
9 | - ruby '-I. -rconfig/boot -e \'require "gettext"; require "gettext/utils"; GetText.create_mofiles(true, "po", "locale")\'' | |
10 | 9 | Rake::Task['symlinkmo'].invoke |
10 | + | |
11 | + require 'gettext' | |
12 | + require 'gettext/tools' | |
13 | + GetText.create_mofiles( | |
14 | + verbose: true, | |
15 | + po_root: 'po', | |
16 | + mo_root: 'locale', | |
17 | + ) | |
18 | + | |
11 | 19 | FileUtils.mkdir_p 'tmp' |
12 | 20 | FileUtils.touch makemo_stamp |
13 | 21 | end |
... | ... | @@ -22,7 +30,7 @@ task :symlinkmo do |
22 | 30 | 'pt' => 'pt_BR', |
23 | 31 | } |
24 | 32 | mkdir_p(Rails.root.join('locale')) |
25 | - Dir.glob(Rails.root.join('locale/*')).each do |dir| | |
33 | + Dir.glob(Rails.root.join('po/*/')).each do |dir| | |
26 | 34 | lang = File.basename(dir) |
27 | 35 | orig_lang = langmap[lang] || lang |
28 | 36 | mkdir_p(Rails.root.join('locale', "#{lang}", 'LC_MESSAGES')) |
... | ... | @@ -38,21 +46,28 @@ end |
38 | 46 | |
39 | 47 | desc "Update pot/po files to match new version." |
40 | 48 | task :updatepo do |
41 | - require 'gettext_rails/tools' | |
42 | - require_dependency 'noosfero' | |
43 | - | |
44 | - GetText::RubyParser::ID << '__' | |
45 | - GetText::RubyParser::PLURAL_ID << 'n__' | |
46 | - GetText::ActiveRecordParser.init(:use_classname => false) | |
47 | 49 | |
48 | 50 | puts 'Extracting strings from source. This may take a while ...' |
49 | - sources = | |
50 | - Dir.glob("{app,lib}/**/*.{rb,rhtml,erb}") + | |
51 | - Dir.glob('config/initializers/*.rb') + | |
52 | - Dir.glob('public/*.html.erb') + | |
53 | - Dir.glob('public/designs/themes/{base,noosfero,profile-base}/*.{rhtml,html.erb}') + | |
54 | - Dir.glob('plugins/**/{controllers,models,lib,views}/**/*.{rhtml,html.erb,rb}') | |
55 | - GetText.update_pofiles(Noosfero::PROJECT, sources, "#{Noosfero::PROJECT} #{Noosfero::VERSION}") | |
51 | + | |
52 | + files_to_translate = [ | |
53 | + "{app,lib}/**/*.{rb,rhtml,erb}", | |
54 | + 'config/initializers/*.rb', | |
55 | + 'public/*.html.erb', | |
56 | + 'public/designs/themes/{base,noosfero,profile-base}/*.{rhtml,html.erb}', | |
57 | + 'plugins/**/{controllers,models,lib,views}/**/*.{rhtml,html.erb,rb}', | |
58 | + ].map { |pattern| Dir.glob(pattern) }.flatten | |
59 | + | |
60 | + require 'gettext' | |
61 | + require 'gettext/tools' | |
62 | + GetText.update_pofiles( | |
63 | + 'noosfero', | |
64 | + files_to_translate, | |
65 | + Noosfero::VERSION, | |
66 | + { | |
67 | + po_root: 'po', | |
68 | + } | |
69 | + ) | |
70 | + | |
56 | 71 | end |
57 | 72 | |
58 | 73 | task :checkpo do | ... | ... |
lib/tasks/package.rake
... | ... | @@ -9,7 +9,7 @@ task :package => 'package:clobber' do |
9 | 9 | fail |
10 | 10 | end |
11 | 11 | |
12 | - release = "#{Noosfero::PROJECT}-#{Noosfero::VERSION}" | |
12 | + release = "#{Noosfero::PROJECT}-#{$version}" | |
13 | 13 | target = "pkg/#{release}" |
14 | 14 | mkdir_p target |
15 | 15 | sh "git archive HEAD | (cd #{target} && tar x)" | ... | ... |
lib/tasks/plugins.rake
... | ... | @@ -7,7 +7,11 @@ namespace :noosfero do |
7 | 7 | plugin_migration_dirs = Dir.glob(Rails.root.join('{baseplugins,config/plugins}', '*', 'db', 'migrate')) |
8 | 8 | |
9 | 9 | task :load_config do |
10 | - dirs = Dir.glob("{baseplugins,config/plugins}/*/db/migrate") | |
10 | + dirs = Dir.glob("{baseplugins,config/plugins}/*").uniq do |dir| | |
11 | + File.basename(dir) | |
12 | + end.map do |dir| | |
13 | + File.join(dir, 'db/migrate') | |
14 | + end | |
11 | 15 | dirs.each do |dir| |
12 | 16 | ActiveRecord::Migrator.migrations_paths << dir |
13 | 17 | end | ... | ... |
lib/tasks/release.rake
... | ... | @@ -131,7 +131,7 @@ EOF |
131 | 131 | new_version = $version.dup |
132 | 132 | |
133 | 133 | if target =~ /-test$/ |
134 | - if new_version =~ /~rc\d\+/ | |
134 | + if new_version =~ /~rc\d+/ | |
135 | 135 | new_version.sub!(/\~rc([0-9]+)/) { "~rc#{$1.to_i + 1}" } |
136 | 136 | else |
137 | 137 | new_version += '~rc1' |
... | ... | @@ -141,7 +141,7 @@ EOF |
141 | 141 | end |
142 | 142 | |
143 | 143 | puts "Current version: #{$version}" |
144 | - ask("Version to release" % new_version, new_version) | |
144 | + new_version = ask("Version to release", new_version) | |
145 | 145 | release_message = ask("Release message") |
146 | 146 | |
147 | 147 | sh 'git checkout debian/changelog lib/noosfero/version.rb' |
... | ... | @@ -205,14 +205,17 @@ EOF |
205 | 205 | puts "==> Preparing debian packages..." |
206 | 206 | Rake::Task['noosfero:debian_packages'].invoke |
207 | 207 | |
208 | - sh "git tag #{$version.gsub('~','-')}" | |
209 | - if confirm('Push new version tag') | |
210 | - repository = ask('Repository name', 'origin') | |
211 | - puts "==> Uploading tags..." | |
212 | - sh "git push #{repository} #{$version.gsub('~','-')}" | |
208 | + if confirm("Create tag for version #{$version}") | |
209 | + sh "git tag #{$version.gsub('~','-')}" | |
210 | + | |
211 | + if confirm('Push new version tag') | |
212 | + repository = ask('Repository name', 'origin') | |
213 | + puts "==> Uploading tags..." | |
214 | + sh "git push #{repository} #{$version.gsub('~','-')}" | |
215 | + end | |
213 | 216 | end |
214 | 217 | |
215 | - if confirm('Do you want to upload the packages') | |
218 | + if confirm('Upload the packages') | |
216 | 219 | puts "==> Uploading debian packages..." |
217 | 220 | Rake::Task['noosfero:upload_packages'].invoke(target) |
218 | 221 | else | ... | ... |
plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb
1 | 1 | <div id='cart-request-box'> |
2 | - <% form_for(:customer, :url => {:action => 'send_request'}, | |
3 | - :html => {:onsubmit => "return Cart.send_request(this)", :id => 'cart-request-form' }) do |f| %> | |
2 | + <%= form_for(:customer, :url => {:action => 'send_request'}, | |
3 | + :html => {:onsubmit => "return Cart.send_request(this)", :id => 'cart-request-form'}) do |f| %> | |
4 | 4 | <div id="cart-form-main"> |
5 | 5 | <%= labelled_form_field('* ' + _("Name"), f.text_field(:name, :class => 'required') ) %> |
6 | 6 | <%= labelled_form_field('* ' + _("Email"), f.text_field(:email, :class => 'required email') ) %> | ... | ... |
plugins/solr/config/solr.yml.dist
... | ... | @@ -9,18 +9,18 @@ |
9 | 9 | production: |
10 | 10 | url: http://127.0.0.1:8983/solr |
11 | 11 | jvm_options: -server -Xmx192M -Xms64M |
12 | - timeout: 0 | |
12 | + timeout: 600 | |
13 | 13 | data_path: /var/lib/noosfero-data/solr/index |
14 | 14 | |
15 | 15 | development: |
16 | 16 | url: http://0.0.0.0:8982/solr |
17 | 17 | jvm_options: -server -Xmx128M -Xms16M |
18 | - timeout: 0 | |
18 | + timeout: 600 | |
19 | 19 | |
20 | 20 | test: &TEST |
21 | 21 | url: http://0.0.0.0:8981/solr |
22 | 22 | jvm_options: -server -Xmx128M -Xms16M |
23 | - timeout: 0 | |
23 | + timeout: 600 | |
24 | 24 | |
25 | 25 | cucumber: |
26 | 26 | <<: *TEST | ... | ... |
plugins/solr/install.rb
plugins/solr/lib/ext/product.rb
... | ... | @@ -27,7 +27,8 @@ class Product |
27 | 27 | {:name => {:type => :text, :boost => 2.0}}, |
28 | 28 | {:description => :text}, {:category_full_name => :text}, |
29 | 29 | # filtered fields |
30 | - {:solr_plugin_public => :boolean}, {:environment_id => :integer}, | |
30 | + {:solr_plugin_public => :boolean}, | |
31 | + {:environment_id => :integer}, {:profile_id => :integer}, | |
31 | 32 | {:enabled => :boolean}, {:solr_plugin_category_filter => :integer}, |
32 | 33 | # ordered/query-boosted fields |
33 | 34 | {:solr_plugin_price_sortable => :decimal}, {:solr_plugin_name_sortable => :string}, | ... | ... |
plugins/solr/lib/ext/profile.rb
... | ... | @@ -42,7 +42,7 @@ class Profile |
42 | 42 | handle_asynchronously :solr_save |
43 | 43 | handle_asynchronously :solr_destroy |
44 | 44 | |
45 | - class_inheritable_accessor :solr_plugin_extra_index_methods | |
45 | + class_attribute :solr_plugin_extra_index_methods | |
46 | 46 | self.solr_plugin_extra_index_methods = [] |
47 | 47 | |
48 | 48 | def solr_plugin_extra_data_for_index | ... | ... |
plugins/solr/lib/solr_plugin.rb
... | ... | @@ -33,8 +33,8 @@ class SolrPlugin < Noosfero::Plugin |
33 | 33 | |
34 | 34 | solr_options = solr_options(class_asset(klass), category) |
35 | 35 | solr_options[:filter_queries] ||= [] |
36 | - solr_options[:filter_queries] += scopes_to_solr_filters scope, klass, options | |
37 | - solr_options.merge! products_options(user) if klass == Product and empty_query | |
36 | + solr_options[:filter_queries] += scopes_to_solr_options scope, klass, options | |
37 | + solr_options.merge! products_options(user) if asset == :products and empty_query | |
38 | 38 | solr_options.merge! options.except(:category, :filter) |
39 | 39 | |
40 | 40 | scope.find_by_contents query, paginate_options, solr_options |
... | ... | @@ -42,14 +42,14 @@ class SolrPlugin < Noosfero::Plugin |
42 | 42 | |
43 | 43 | protected |
44 | 44 | |
45 | - def scopes_to_solr_filters scope, klass = nil, options = {} | |
45 | + def scopes_to_solr_options scope, klass = nil, options = {} | |
46 | 46 | filter_queries = [] |
47 | 47 | klass ||= scope.base_class |
48 | 48 | solr_fields = klass.configuration[:solr_fields].keys |
49 | 49 | scopes_applied = scope.scopes_applied.dup rescue [] #rescue association and class direct filtering |
50 | 50 | |
51 | - scope.current_scoped_methods[:create].each do |attr, value| | |
52 | - next unless solr_fields.include? attr.to_sym | |
51 | + scope.scope_attributes.each do |attr, value| | |
52 | + raise "Non-indexed attribute '#{attr}' speficied in scope_attributes" unless solr_fields.include? attr.to_sym | |
53 | 53 | |
54 | 54 | # if the filter is present here, then prefer it |
55 | 55 | scopes_applied.reject!{ |name| name == attr.to_sym } | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/.travis.yml
1 | +services: | |
2 | + - mongodb | |
3 | + | |
4 | +language: ruby | |
5 | +rvm: | |
6 | + - 1.8.7 | |
7 | + | |
8 | +before_install: | |
9 | + - sudo apt-get update | |
10 | + - sudo apt-get install default-jdk | |
11 | + | |
1 | 12 | before_script: |
2 | 13 | - mongo mydb_test --eval 'db.addUser("travis", "test");' |
3 | 14 | - gem update --system 1.4.1 > /dev/null 2>&1 |
4 | 15 | - rake solr:download |
5 | 16 | - RAILS_ENV=test rake solr:start |
6 | 17 | |
7 | -script: "bundle exec rake $TASK --trace" | |
18 | +script: | |
19 | + - bundle exec rake test --trace | |
20 | + - bundle exec rake test:functional --trace | |
8 | 21 | |
9 | -rvm: | |
10 | - - 1.8.7 | |
11 | -env: | |
12 | - - TASK=test | |
13 | - - TASK=test:functional | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/Gemfile
plugins/solr/vendor/plugins/acts_as_solr_reloaded/Rakefile
1 | 1 | require 'rubygems' |
2 | 2 | require 'rake' |
3 | 3 | require 'rake/testtask' |
4 | -require 'rake/rdoctask' | |
4 | +require 'rdoc/task' | |
5 | 5 | |
6 | 6 | ENV['RAILS_ENV'] = "test" |
7 | 7 | require File.expand_path("#{File.dirname(__FILE__)}/config/solr_environment") |
8 | 8 | |
9 | 9 | Dir["#{File.dirname(__FILE__)}/lib/tasks/*.rake"].sort.each { |ext| load ext } |
10 | 10 | |
11 | -desc "Default Task" | |
12 | -task :default => [:test] | |
13 | - | |
14 | -desc "Runs the unit tests" | |
15 | -task :test => "test:unit" | |
16 | - | |
17 | -namespace :test do | |
18 | - task :setup do | |
19 | - DB ||= 'sqlite' | |
20 | - puts "Using " + DB | |
21 | - %x(mysql -u#{MYSQL_USER} < #{File.dirname(__FILE__) + "/test/fixtures/db_definitions/mysql.sql"}) if DB == 'mysql' | |
22 | - | |
23 | - Rake::Task["test:migrate"].invoke | |
24 | - end | |
25 | - | |
26 | - desc 'Measures test coverage using rcov' | |
27 | - task :rcov => :setup do | |
28 | - rm_f "coverage" | |
29 | - rm_f "coverage.data" | |
30 | - rcov = "rcov --rails --aggregate coverage.data --text-summary -Ilib" | |
31 | - | |
32 | - system("#{rcov} --html #{Dir.glob('test/**/*_shoulda.rb').join(' ')}") | |
33 | - system("open coverage/index.html") if PLATFORM['darwin'] | |
34 | - end | |
35 | - | |
36 | - desc 'Runs the functional tests, testing integration with Solr' | |
37 | - Rake::TestTask.new(:functional => :setup) do |t| | |
38 | - t.pattern = "test/functional/*_test.rb" | |
39 | - t.verbose = true | |
40 | - end | |
41 | - | |
42 | - desc "Unit tests" | |
43 | - Rake::TestTask.new(:unit => :setup) do |t| | |
44 | - t.libs << 'test/unit' | |
45 | - t.pattern = "test/unit/*_shoulda.rb" | |
46 | - t.verbose = true | |
47 | - end | |
48 | -end | |
49 | - | |
50 | -Rake::RDocTask.new do |rd| | |
51 | - rd.main = "README.rdoc" | |
52 | - rd.rdoc_dir = "rdoc" | |
53 | - rd.rdoc_files.exclude("lib/solr/**/*.rb", "lib/solr.rb") | |
54 | - rd.rdoc_files.include("README.rdoc", "lib/**/*.rb") | |
55 | -end | |
56 | - | |
57 | -begin | |
58 | - require 'jeweler' | |
59 | - Jeweler::Tasks.new do |s| | |
60 | - s.name = "acts_as_solr_reloaded" | |
61 | - s.summary = "This gem adds full text search capabilities and many other nifty features from Apache Solr to any Rails model." | |
62 | - s.email = "dc.rec1@gmail.com" | |
63 | - s.homepage = "http://github.com/dcrec1/acts_as_solr_reloaded" | |
64 | - s.description = "This gem adds full text search capabilities and many other nifty features from Apache Solr to any Rails model." | |
65 | - s.authors = ["Diego Carrion"] | |
66 | - s.files = FileList["[A-Z]*", "{bin,generators,config,lib,solr}/**/*"] + | |
67 | - FileList["test/**/*"].reject {|f| f.include?("test/log")}.reject {|f| f.include?("test/tmp")} | |
68 | - end | |
69 | -rescue LoadError | |
70 | - puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install jeweler" | |
71 | -end | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/config/solr_environment.rb
... | ... | @@ -6,23 +6,19 @@ require 'net/http' |
6 | 6 | |
7 | 7 | dir = File.dirname(__FILE__) |
8 | 8 | SOLR_PATH = File.expand_path("#{dir}/../solr") unless defined? SOLR_PATH |
9 | -config = YAML::load_file(RAILS_ROOT+'/plugins/solr/config/solr.yml') | |
9 | +config = YAML::load_file("#{Rails.root}/plugins/solr/config/solr.yml") | |
10 | 10 | |
11 | -unless defined? RAILS_ROOT | |
12 | - # define RAILS_ROOT for test environment | |
13 | - RAILS_ROOT = defined?(Rails) ? Rails.root : File.expand_path("#{File.dirname(__FILE__)}/../test") | |
14 | -end | |
15 | 11 | unless defined? RAILS_ENV |
16 | 12 | RAILS_ENV = ENV['RAILS_ENV'] |
17 | 13 | end |
18 | 14 | unless defined? SOLR_LOGS_PATH |
19 | - SOLR_LOGS_PATH = ENV["SOLR_LOGS_PATH"] || "#{RAILS_ROOT}/log" | |
15 | + SOLR_LOGS_PATH = ENV["SOLR_LOGS_PATH"] || "#{Rails.root}/log" | |
20 | 16 | end |
21 | 17 | unless defined? SOLR_PIDS_PATH |
22 | - SOLR_PIDS_PATH = ENV["SOLR_PIDS_PATH"] || "#{RAILS_ROOT}/tmp/pids" | |
18 | + SOLR_PIDS_PATH = ENV["SOLR_PIDS_PATH"] || "#{Rails.root}/tmp/pids" | |
23 | 19 | end |
24 | 20 | unless defined? SOLR_DATA_PATH |
25 | - SOLR_DATA_PATH = ENV["SOLR_DATA_PATH"] || config[ENV['RAILS_ENV']]['data_path'] || "#{RAILS_ROOT}/solr/#{ENV['RAILS_ENV']}" | |
21 | + SOLR_DATA_PATH = ENV["SOLR_DATA_PATH"] || config[ENV['RAILS_ENV']]['data_path'] || "#{Rails.root}/solr/#{ENV['RAILS_ENV']}" | |
26 | 22 | end |
27 | 23 | unless defined? SOLR_CONFIG_PATH |
28 | 24 | SOLR_CONFIG_PATH = ENV["SOLR_CONFIG_PATH"] || "#{SOLR_PATH}/solr" | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr.rb
... | ... | @@ -20,6 +20,7 @@ require File.dirname(__FILE__) + '/acts_as_solr/search_results' |
20 | 20 | require File.dirname(__FILE__) + '/acts_as_solr/lazy_document' |
21 | 21 | require File.dirname(__FILE__) + '/acts_as_solr/mongo_mapper' |
22 | 22 | require File.dirname(__FILE__) + '/acts_as_solr/post' |
23 | +require File.dirname(__FILE__) + '/acts_as_solr/scope_with_applied_names' | |
23 | 24 | |
24 | 25 | # reopen ActiveRecord and include the acts_as_solr method |
25 | 26 | ActiveRecord::Base.extend ActsAsSolr::ActsMethods | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/acts_methods.rb
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/common_methods.rb
1 | 1 | module ActsAsSolr #:nodoc: |
2 | - | |
2 | + | |
3 | 3 | module CommonMethods |
4 | 4 | |
5 | 5 | TypeMapping = { |
... | ... | @@ -14,6 +14,7 @@ module ActsAsSolr #:nodoc: |
14 | 14 | :range_integer => "ri", |
15 | 15 | :facet => "facet", |
16 | 16 | :text => "t", |
17 | + :ngram_text => "nt", | |
17 | 18 | } |
18 | 19 | |
19 | 20 | # Converts field types into Solr types |
... | ... | @@ -39,39 +40,39 @@ module ActsAsSolr #:nodoc: |
39 | 40 | result = [result] unless result.is_a?(Array) |
40 | 41 | solr_batch_add result |
41 | 42 | end |
42 | - | |
43 | + | |
43 | 44 | # Sends an add command to Solr |
44 | 45 | def solr_add(add_xml) |
45 | 46 | ActsAsSolr::Post.execute(Solr::Request::AddDocument.new(add_xml)) |
46 | 47 | end |
47 | - | |
48 | + | |
48 | 49 | # Sends the delete command to Solr |
49 | 50 | def solr_delete(solr_ids) |
50 | 51 | ActsAsSolr::Post.execute(Solr::Request::Delete.new(:id => solr_ids)) |
51 | 52 | end |
52 | - | |
53 | + | |
53 | 54 | # Sends the commit command to Solr |
54 | 55 | def solr_commit |
55 | 56 | ActsAsSolr::Post.execute(Solr::Request::Commit.new) |
56 | 57 | end |
57 | - | |
58 | + | |
58 | 59 | # Optimizes the Solr index. Solr says: |
59 | - # | |
60 | - # Optimizations can take nearly ten minutes to run. | |
61 | - # We are presuming optimizations should be run once following large | |
60 | + # | |
61 | + # Optimizations can take nearly ten minutes to run. | |
62 | + # We are presuming optimizations should be run once following large | |
62 | 63 | # batch-like updates to the collection and/or once a day. |
63 | - # | |
64 | - # One of the solutions for this would be to create a cron job that | |
64 | + # | |
65 | + # One of the solutions for this would be to create a cron job that | |
65 | 66 | # runs every day at midnight and optmizes the index: |
66 | 67 | # 0 0 * * * /your_rails_dir/script/runner -e production "Model.solr_optimize" |
67 | - # | |
68 | + # | |
68 | 69 | def solr_optimize |
69 | 70 | ActsAsSolr::Post.execute(Solr::Request::Optimize.new) |
70 | 71 | end |
71 | - | |
72 | + | |
72 | 73 | # Returns the id for the given instance |
73 | - def record_id(object) | |
74 | - eval "object.#{object.class.primary_key}" | |
74 | + def record_id object | |
75 | + object.send object.class.primary_key | |
75 | 76 | end |
76 | 77 | end |
77 | 78 | end | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/parser_methods.rb
... | ... | @@ -4,12 +4,16 @@ module ActsAsSolr #:nodoc: |
4 | 4 | |
5 | 5 | # Method used by mostly all the ClassMethods when doing a search |
6 | 6 | def parse_query(query=nil, options={}) |
7 | - valid_options = [:models, :lazy, :core, :results_format, :sql_options, | |
7 | + valid_options = [ | |
8 | + :models, :lazy, :core, :results_format, :sql_options, | |
8 | 9 | :alternate_query, :boost_functions, :filter_queries, :facets, :sort, |
9 | 10 | :scores, :operator, :latitude, :longitude, :radius, :relevance, :highlight, |
10 | - :offset, :per_page, :limit, :page,] | |
11 | + :offset, :per_page, :limit, :page, | |
12 | + :query_fields, :default_field, | |
13 | + ] | |
11 | 14 | query_options = {} |
12 | 15 | options[:results_format] ||= :objects |
16 | + options[:default_field] ||= 'text' | |
13 | 17 | |
14 | 18 | return if query.nil? |
15 | 19 | raise "Query should be a string" unless query.is_a?(String) |
... | ... | @@ -49,77 +53,95 @@ module ActsAsSolr #:nodoc: |
49 | 53 | query_options[:rows] = per_page |
50 | 54 | query_options[:start] = offset |
51 | 55 | |
56 | + query_options[:boost_functions] = replace_types([*options[:boost_functions]], '').join(' ') if options[:boost_functions] | |
57 | + | |
58 | + parse_facets query_options, options | |
59 | + parse_highlight query_options, options | |
60 | + parse_sort query_options, options | |
61 | + parse_location query_options, options | |
62 | + parse_query_fields query_options, options | |
63 | + | |
52 | 64 | query_options[:operator] = options[:operator] |
65 | + not_dismax = query_options[:operator] == :or | |
66 | + request = if not_dismax then Solr::Request::Standard.new(query_options) else Solr::Request::Dismax.new query_options end | |
67 | + ActsAsSolr::Post.execute request, options[:core] | |
68 | + rescue | |
69 | + raise "#{$query} There was a problem executing your search\n#{query_options.inspect}\n: #{$!} in #{$!.backtrace.first}" | |
70 | + end | |
71 | + end | |
53 | 72 | |
54 | - query_options[:boost_functions] = replace_types([*options[:boost_functions]], '').join(' ') if options[:boost_functions] | |
73 | + def parse_query_fields query_options, options | |
74 | + options[:query_fields] ||= [] | |
75 | + query_options[:query_fields] = replace_types([*options[:query_fields]], '').join ' ' | |
76 | + end | |
77 | + | |
78 | + def parse_sort query_options, options | |
79 | + query_options[:sort] = replace_types([*options[:sort]], '')[0] if options[:sort] | |
80 | + end | |
55 | 81 | |
56 | - # first steps on the facet parameter processing | |
57 | - if options[:facets] | |
58 | - query_options[:facets] = {} | |
59 | - query_options[:facets][:limit] = -1 # TODO: make this configurable | |
60 | - query_options[:facets][:sort] = :count if options[:facets][:sort] | |
61 | - query_options[:facets][:mincount] = 0 | |
62 | - query_options[:facets][:mincount] = 1 if options[:facets][:zeros] == false | |
63 | - # override the :zeros (it's deprecated anyway) if :mincount exists | |
64 | - query_options[:facets][:mincount] = options[:facets][:mincount] if options[:facets][:mincount] | |
65 | - query_options[:facets][:fields] = options[:facets][:fields].map{ |k| "#{k}_facet" } if options[:facets][:fields] | |
66 | - query_options[:filter_queries] += replace_types([*options[:facets][:browse]]) if options[:facets][:browse] | |
67 | - query_options[:facets][:queries] = replace_types([*options[:facets][:query]]) if options[:facets][:query] | |
68 | - | |
69 | - if options[:facets][:dates] | |
70 | - query_options[:date_facets] = {} | |
71 | - # if options[:facets][:dates][:fields] exists then :start, :end, and :gap must be there | |
72 | - if options[:facets][:dates][:fields] | |
73 | - [:start, :end, :gap].each { |k| raise "#{k} must be present in faceted date query" unless options[:facets][:dates].include?(k) } | |
74 | - query_options[:date_facets][:fields] = [] | |
75 | - options[:facets][:dates][:fields].each { |f| | |
76 | - if f.kind_of? Hash | |
77 | - key = f.keys[0] | |
78 | - query_options[:date_facets][:fields] << {"#{key}_d" => f[key]} | |
79 | - validate_date_facet_other_options(f[key][:other]) if f[key][:other] | |
80 | - else | |
81 | - query_options[:date_facets][:fields] << "#{f}_d" | |
82 | - end | |
83 | - } | |
84 | - end | |
85 | - | |
86 | - query_options[:date_facets][:start] = options[:facets][:dates][:start] if options[:facets][:dates][:start] | |
87 | - query_options[:date_facets][:end] = options[:facets][:dates][:end] if options[:facets][:dates][:end] | |
88 | - query_options[:date_facets][:gap] = options[:facets][:dates][:gap] if options[:facets][:dates][:gap] | |
89 | - query_options[:date_facets][:hardend] = options[:facets][:dates][:hardend] if options[:facets][:dates][:hardend] | |
90 | - query_options[:date_facets][:filter] = replace_types([*options[:facets][:dates][:filter]].collect{|k| "#{k.dup.sub!(/ *:(?!\d) */,"_d:")}"}) if options[:facets][:dates][:filter] | |
91 | - | |
92 | - if options[:facets][:dates][:other] | |
93 | - validate_date_facet_other_options(options[:facets][:dates][:other]) | |
94 | - query_options[:date_facets][:other] = options[:facets][:dates][:other] | |
95 | - end | |
82 | + def parse_location query_options, options | |
83 | + if options[:radius] | |
84 | + query_options[:radius] = options[:radius] | |
85 | + query_options[:filter_queries] << '{!geofilt}' | |
86 | + end | |
87 | + query_options[:latitude] = options[:latitude] | |
88 | + query_options[:longitude] = options[:longitude] | |
89 | + end | |
96 | 90 | |
91 | + def parse_highlight query_options, options | |
92 | + if options[:highlight] | |
93 | + query_options[:highlighting] = {} | |
94 | + query_options[:highlighting][:field_list] = replace_types([*options[:highlight][:fields]], '') if options[:highlight][:fields] | |
95 | + query_options[:highlighting][:require_field_match] = options[:highlight][:require_field_match] if options[:highlight][:require_field_match] | |
96 | + query_options[:highlighting][:max_snippets] = options[:highlight][:max_snippets] if options[:highlight][:max_snippets] | |
97 | + query_options[:highlighting][:prefix] = options[:highlight][:prefix] if options[:highlight][:prefix] | |
98 | + query_options[:highlighting][:suffix] = options[:highlight][:suffix] if options[:highlight][:suffix] | |
99 | + end | |
100 | + end | |
101 | + | |
102 | + def parse_facets query_options, options | |
103 | + # first steps on the facet parameter processing | |
104 | + if options[:facets] | |
105 | + query_options[:facets] = {} | |
106 | + query_options[:facets][:limit] = -1 # TODO: make this configurable | |
107 | + query_options[:facets][:sort] = :count if options[:facets][:sort] | |
108 | + query_options[:facets][:mincount] = 0 | |
109 | + query_options[:facets][:mincount] = 1 if options[:facets][:zeros] == false | |
110 | + # override the :zeros (it's deprecated anyway) if :mincount exists | |
111 | + query_options[:facets][:mincount] = options[:facets][:mincount] if options[:facets][:mincount] | |
112 | + query_options[:facets][:fields] = options[:facets][:fields].map{ |k| "#{k}_facet" } if options[:facets][:fields] | |
113 | + query_options[:filter_queries] += replace_types([*options[:facets][:browse]]) if options[:facets][:browse] | |
114 | + query_options[:facets][:queries] = replace_types([*options[:facets][:query]]) if options[:facets][:query] | |
115 | + | |
116 | + if options[:facets][:dates] | |
117 | + query_options[:date_facets] = {} | |
118 | + # if options[:facets][:dates][:fields] exists then :start, :end, and :gap must be there | |
119 | + if options[:facets][:dates][:fields] | |
120 | + [:start, :end, :gap].each { |k| raise "#{k} must be present in faceted date query" unless options[:facets][:dates].include?(k) } | |
121 | + query_options[:date_facets][:fields] = [] | |
122 | + options[:facets][:dates][:fields].each { |f| | |
123 | + if f.kind_of? Hash | |
124 | + key = f.keys[0] | |
125 | + query_options[:date_facets][:fields] << {"#{key}_d" => f[key]} | |
126 | + validate_date_facet_other_options(f[key][:other]) if f[key][:other] | |
127 | + else | |
128 | + query_options[:date_facets][:fields] << "#{f}_d" | |
129 | + end | |
130 | + } | |
97 | 131 | end |
98 | - end | |
99 | 132 | |
100 | - if options[:highlight] | |
101 | - query_options[:highlighting] = {} | |
102 | - query_options[:highlighting][:field_list] = replace_types([*options[:highlight][:fields]], '') if options[:highlight][:fields] | |
103 | - query_options[:highlighting][:require_field_match] = options[:highlight][:require_field_match] if options[:highlight][:require_field_match] | |
104 | - query_options[:highlighting][:max_snippets] = options[:highlight][:max_snippets] if options[:highlight][:max_snippets] | |
105 | - query_options[:highlighting][:prefix] = options[:highlight][:prefix] if options[:highlight][:prefix] | |
106 | - query_options[:highlighting][:suffix] = options[:highlight][:suffix] if options[:highlight][:suffix] | |
107 | - end | |
133 | + query_options[:date_facets][:start] = options[:facets][:dates][:start] if options[:facets][:dates][:start] | |
134 | + query_options[:date_facets][:end] = options[:facets][:dates][:end] if options[:facets][:dates][:end] | |
135 | + query_options[:date_facets][:gap] = options[:facets][:dates][:gap] if options[:facets][:dates][:gap] | |
136 | + query_options[:date_facets][:hardend] = options[:facets][:dates][:hardend] if options[:facets][:dates][:hardend] | |
137 | + query_options[:date_facets][:filter] = replace_types([*options[:facets][:dates][:filter]].collect{|k| "#{k.dup.sub!(/ *:(?!\d) */,"_d:")}"}) if options[:facets][:dates][:filter] | |
108 | 138 | |
109 | - query_options[:sort] = replace_types([*options[:sort]], '')[0] if options[:sort] | |
139 | + if options[:facets][:dates][:other] | |
140 | + validate_date_facet_other_options(options[:facets][:dates][:other]) | |
141 | + query_options[:date_facets][:other] = options[:facets][:dates][:other] | |
142 | + end | |
110 | 143 | |
111 | - if options[:radius] | |
112 | - query_options[:radius] = options[:radius] | |
113 | - query_options[:filter_queries] << '{!geofilt}' | |
114 | 144 | end |
115 | - query_options[:latitude] = options[:latitude] | |
116 | - query_options[:longitude] = options[:longitude] | |
117 | - | |
118 | - not_dismax = query_options[:operator] == :or | |
119 | - request = not_dismax ? Solr::Request::Standard.new(query_options) : Solr::Request::Dismax.new(query_options) | |
120 | - ActsAsSolr::Post.execute(request, options[:core]) | |
121 | - rescue | |
122 | - raise "#{$query} There was a problem executing your search\n#{query_options.inspect}\n: #{$!} in #{$!.backtrace.first}" | |
123 | 145 | end |
124 | 146 | end |
125 | 147 | |
... | ... | @@ -148,21 +170,21 @@ module ActsAsSolr #:nodoc: |
148 | 170 | results.update :start => header['params']['start'] |
149 | 171 | end |
150 | 172 | |
151 | - results.update(:facets => {'facet_fields' => []}) if options[:facets] | |
173 | + results.update(:facets => {'facet_fields' => {}}) if options[:facets] | |
152 | 174 | return SearchResults.new(results) if solr_data.total_hits == 0 |
153 | 175 | |
154 | 176 | results.update(:facets => solr_data.data['facet_counts']) if options[:facets] |
155 | 177 | |
156 | - ids = solr_data.hits.collect {|doc| doc["#{solr_configuration[:primary_key_field]}"]}.flatten | |
157 | - result = find_objects(ids, options) | |
158 | - results.update(:docs => result) | |
178 | + ids = solr_data.hits.collect{ |doc| doc["#{solr_configuration[:primary_key_field]}"] }.flatten | |
179 | + result = find_objects ids, options | |
180 | + results.update :ids => ids, :docs => result | |
159 | 181 | |
160 | 182 | add_scores(result, solr_data) if options[:results_format] == :objects and options[:scores] |
161 | 183 | |
162 | 184 | highlighted = {} |
163 | 185 | solr_data.highlighting.map do |x,y| |
164 | 186 | e={} |
165 | - y1=y.map{|x1,y1| e[x1.gsub(/_[^_]*/,"")]=y1} unless y.nil? | |
187 | + y.map{ |x1,y1| e[x1.gsub(/_[^_]*/,"")]=y1 } unless y.nil? | |
166 | 188 | highlighted[x.gsub(/[^:]*:/,"").to_i]=e |
167 | 189 | end unless solr_data.highlighting.nil? |
168 | 190 | results.update(:highlights => highlighted) |
... | ... | @@ -179,8 +201,12 @@ module ActsAsSolr #:nodoc: |
179 | 201 | ids.collect{ |id| ActsAsSolr::LazyDocument.new(id, self) } |
180 | 202 | elsif options[:results_format] == :objects |
181 | 203 | find_options = options[:sql_options] || {} |
182 | - find_options[:conditions] = self.send :merge_conditions, {self.primary_key => ids}, (find_options[:conditions] || []) | |
183 | - result = self.all(find_options) || [] | |
204 | + if Rails::VERSION::STRING >= '3.0' | |
205 | + result = self.scoped(find_options).where(self.primary_key => ids).all | |
206 | + else | |
207 | + find_options[:conditions] = self.send :merge_conditions, {self.primary_key => ids}, (find_options[:conditions] || []) | |
208 | + result = self.all(find_options) | |
209 | + end | |
184 | 210 | result = reorder(result, ids) unless find_options[:order] |
185 | 211 | result |
186 | 212 | elsif options[:results_format] == :none |
... | ... | @@ -226,22 +252,15 @@ module ActsAsSolr #:nodoc: |
226 | 252 | def add_scores(results, solr_data) |
227 | 253 | with_score = [] |
228 | 254 | solr_data.hits.each do |doc| |
229 | - with_score.push([doc["score"], | |
230 | - results.find {|record| scorable_record?(record, doc) }]) | |
231 | - end | |
232 | - with_score.each do |score, object| | |
233 | - class << object; attr_accessor :solr_score; end | |
234 | - object.solr_score = score | |
255 | + record = results.find do |result| | |
256 | + doc_id = doc["#{solr_configuration[:primary_key_field]}"].first rescue nil | |
257 | + record_id(result).to_s == doc_id | |
258 | + end | |
259 | + with_score.push [doc["score"], record] | |
235 | 260 | end |
236 | - end | |
237 | - | |
238 | - def scorable_record?(record, doc) | |
239 | - doc_id = doc["#{solr_configuration[:primary_key_field]}"] | |
240 | - if doc_id.nil? | |
241 | - doc_id = doc["id"] | |
242 | - "#{record.class.name}:#{record_id(record)}" == doc_id.first.to_s | |
243 | - else | |
244 | - record_id(record).to_s == doc_id.to_s | |
261 | + with_score.each do |score, record| | |
262 | + next unless record | |
263 | + record.solr_score = score | |
245 | 264 | end |
246 | 265 | end |
247 | 266 | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/scope_with_applied_names.rb
0 → 100644
... | ... | @@ -0,0 +1,91 @@ |
1 | + | |
2 | +if Rails::VERSION::STRING >= "3.2" | |
3 | + module ::ActiveRecord | |
4 | + | |
5 | + class Relation | |
6 | + attr_accessor :scopes_applied | |
7 | + end | |
8 | + | |
9 | + module Scoping | |
10 | + module Named | |
11 | + module ClassMethods | |
12 | + attr_accessor :scope_name, :scopes_applied | |
13 | + | |
14 | + def scope_with_applied_names name, scope_options = {} | |
15 | + name = name.to_sym | |
16 | + valid_scope_name?(name) | |
17 | + extension = Module.new(&Proc.new) if block_given? | |
18 | + | |
19 | + scope_proc = lambda do |*args| | |
20 | + options = scope_options.respond_to?(:call) ? unscoped { scope_options.call(*args) } : scope_options | |
21 | + options = scoped.apply_finder_options(options) if options.is_a?(Hash) | |
22 | + | |
23 | + relation = scoped.merge(options) | |
24 | + relation.scopes_applied ||= Set.new | |
25 | + relation.scopes_applied << name | |
26 | + | |
27 | + extension ? relation.extending(extension) : relation | |
28 | + end | |
29 | + | |
30 | + singleton_class.send(:redefine_method, name, &scope_proc) | |
31 | + end | |
32 | + alias_method_chain :scope, :applied_names | |
33 | + | |
34 | + end | |
35 | + end | |
36 | + end | |
37 | + end | |
38 | +else | |
39 | + require_dependency 'active_record/named_scope' | |
40 | + | |
41 | + module ::ActiveRecord | |
42 | + module NamedScope | |
43 | + module ClassMethods | |
44 | + | |
45 | + def named_scope_with_applied_names name, options = {}, &block | |
46 | + named_scope_without_applied_names name, options, &block | |
47 | + | |
48 | + name = name.to_sym | |
49 | + scopes[name] = lambda do |parent_scope, *args| | |
50 | + scope = Scope.new(parent_scope, case options | |
51 | + when Hash | |
52 | + options | |
53 | + when Proc | |
54 | + if self.model_name != parent_scope.model_name | |
55 | + options.bind(parent_scope).call(*args) | |
56 | + else | |
57 | + options.call(*args) | |
58 | + end | |
59 | + end, &block) | |
60 | + scope.scope_name = name | |
61 | + scope | |
62 | + end | |
63 | + end | |
64 | + alias_method_chain :named_scope, :applied_names | |
65 | + end | |
66 | + | |
67 | + class Scope | |
68 | + attr_accessor :scope_name, :scopes_applied | |
69 | + | |
70 | + def initialize_with_applied_names proxy_scope, options, &block | |
71 | + initialize_without_applied_names proxy_scope, options, &block | |
72 | + self.scopes_applied ||= [] | |
73 | + self.scopes_applied += proxy_scope.send :scopes_applied if Scope === proxy_scope | |
74 | + | |
75 | + # unrelated bugfix: use if instead of unless | |
76 | + if (Scope === proxy_scope || ActiveRecord::Associations::AssociationCollection === proxy_scope) | |
77 | + @current_scoped_methods_when_defined = proxy_scope.send(:current_scoped_methods) | |
78 | + end | |
79 | + end | |
80 | + alias_method_chain :initialize, :applied_names | |
81 | + | |
82 | + def scope_name= name | |
83 | + @scope_name = name | |
84 | + self.scopes_applied << @scope_name | |
85 | + end | |
86 | + | |
87 | + end | |
88 | + | |
89 | + end | |
90 | + end | |
91 | +end | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/dismax.rb
... | ... | @@ -12,13 +12,15 @@ |
12 | 12 | |
13 | 13 | class Solr::Request::Dismax < Solr::Request::Standard |
14 | 14 | |
15 | - VALID_PARAMS.replace(VALID_PARAMS + [:tie_breaker, :query_fields, :minimum_match, :phrase_fields, :phrase_slop, | |
16 | - :alternate_query, :boost_query, :boost_functions]) | |
15 | + VALID_PARAMS.replace VALID_PARAMS + [ | |
16 | + :tie_breaker, :query_fields, :minimum_match, :phrase_fields, :phrase_slop, | |
17 | + :alternate_query, :boost_query, :boost_functions, | |
18 | + ] | |
17 | 19 | |
18 | 20 | def initialize(params) |
19 | 21 | super |
20 | 22 | end |
21 | - | |
23 | + | |
22 | 24 | def to_hash |
23 | 25 | hash = super |
24 | 26 | hash[:defType] = 'edismax' | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/solr/request/standard.rb
... | ... | @@ -12,40 +12,42 @@ |
12 | 12 | |
13 | 13 | class Solr::Request::Standard < Solr::Request::Select |
14 | 14 | |
15 | - VALID_PARAMS = [:query, :sort, :default_field, :operator, :start, :rows, :shards, :date_facets, | |
16 | - :filter_queries, :field_list, :debug_query, :explain_other, :facets, :highlighting, :mlt, :radius, | |
17 | - :radius, :latitude, :longitude, :spellcheck] | |
18 | - | |
15 | + VALID_PARAMS = [ | |
16 | + :query, :sort, :default_field, :operator, :start, :rows, :shards, :date_facets, | |
17 | + :filter_queries, :field_list, :debug_query, :explain_other, :facets, :highlighting, :mlt, :radius, | |
18 | + :radius, :latitude, :longitude, :spellcheck, | |
19 | + ] | |
20 | + | |
19 | 21 | def initialize(params) |
20 | 22 | super 'search' |
21 | - | |
22 | - raise "Invalid parameters: #{(params.keys - VALID_PARAMS).join(',')}" unless | |
23 | + | |
24 | + raise "Invalid parameters: #{(params.keys - VALID_PARAMS).join(',')}" unless | |
23 | 25 | (params.keys - VALID_PARAMS).empty? |
24 | - | |
26 | + | |
25 | 27 | raise ":query parameter required" unless params[:query] |
26 | - | |
28 | + | |
27 | 29 | @params = params.dup |
28 | - | |
30 | + | |
29 | 31 | # Validate operator |
30 | 32 | if params[:operator] |
31 | - raise "Only :and/:or operators allowed" unless | |
33 | + raise "Only :and/:or operators allowed" unless | |
32 | 34 | [:and, :or].include?(params[:operator]) |
33 | - | |
35 | + | |
34 | 36 | @params[:operator] = params[:operator].to_s.upcase |
35 | 37 | end |
36 | 38 | |
37 | 39 | # Validate start, rows can be transformed to ints |
38 | 40 | @params[:start] = params[:start].to_i if params[:start] |
39 | 41 | @params[:rows] = params[:rows].to_i if params[:rows] |
40 | - | |
42 | + | |
41 | 43 | @params[:field_list] ||= ["*","score"] |
42 | - | |
44 | + | |
43 | 45 | @params[:shards] ||= [] |
44 | 46 | end |
45 | - | |
47 | + | |
46 | 48 | def to_hash |
47 | 49 | hash = {} |
48 | - | |
50 | + | |
49 | 51 | # standard request param processing |
50 | 52 | hash[:sort] = @params[:sort] |
51 | 53 | hash[:q] = @params[:query] |
... | ... | @@ -61,11 +63,11 @@ class Solr::Request::Standard < Solr::Request::Select |
61 | 63 | hash[:debugQuery] = @params[:debug_query] |
62 | 64 | hash[:explainOther] = @params[:explain_other] |
63 | 65 | hash[:shards] = @params[:shards].join(',') unless @params[:shards].empty? |
64 | - | |
66 | + | |
65 | 67 | hash[:sfield] = 'latlng' |
66 | 68 | hash[:d] = @params[:radius] |
67 | 69 | hash[:pt] = "#{@params[:latitude]}, #{@params[:longitude]}" if @params[:latitude] and @params[:longitude] |
68 | - | |
70 | + | |
69 | 71 | # facet parameter processing |
70 | 72 | if @params[:facets] |
71 | 73 | # TODO need validation of all that is under the :facets Hash too |
... | ... | @@ -95,7 +97,7 @@ class Solr::Request::Standard < Solr::Request::Select |
95 | 97 | end |
96 | 98 | end |
97 | 99 | end |
98 | - | |
100 | + | |
99 | 101 | if @params[:date_facets] |
100 | 102 | hash["facet.date"] = [] |
101 | 103 | if @params[:date_facets][:fields] |
... | ... | @@ -125,7 +127,7 @@ class Solr::Request::Standard < Solr::Request::Select |
125 | 127 | end |
126 | 128 | end |
127 | 129 | end |
128 | - | |
130 | + | |
129 | 131 | # highlighting parameter processing - http://wiki.apache.org/solr/HighlightingParameters |
130 | 132 | if @params[:highlighting] |
131 | 133 | hash[:hl] = true |
... | ... | @@ -385,7 +387,7 @@ class Solr::Request::Standard < Solr::Request::Select |
385 | 387 | end |
386 | 388 | |
387 | 389 | end |
388 | - | |
390 | + | |
389 | 391 | if @params[:mlt] |
390 | 392 | hash[:mlt] = true |
391 | 393 | hash["mlt.count"] = @params[:mlt][:count] |
... | ... | @@ -398,10 +400,10 @@ class Solr::Request::Standard < Solr::Request::Select |
398 | 400 | hash["mlt.maxntp"] = @params[:mlt][:max_tokens_parsed] |
399 | 401 | hash["mlt.boost"] = @params[:mlt][:boost] |
400 | 402 | end |
401 | - | |
403 | + | |
402 | 404 | hash[:spellcheck] = true |
403 | 405 | hash['spellcheck.collate'] = true |
404 | - | |
406 | + | |
405 | 407 | hash.merge(super.to_hash) |
406 | 408 | end |
407 | 409 | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/ruby.rb
... | ... | @@ -14,13 +14,14 @@ class Solr::Response::Ruby < Solr::Response::Base |
14 | 14 | attr_reader :data, :header |
15 | 15 | |
16 | 16 | def initialize(ruby_code) |
17 | + ruby_code.force_encoding('UTF-8') if RUBY_VERSION >= '1.9' | |
17 | 18 | super |
18 | 19 | begin |
19 | 20 | #TODO: what about pulling up data/header/response to ResponseBase, |
20 | 21 | # or maybe a new middle class like SelectResponseBase since |
21 | 22 | # all Select queries return this same sort of stuff?? |
22 | 23 | # XML (&wt=xml) and Ruby (&wt=ruby) responses contain exactly the same structure. |
23 | - # a goal of solrb is to make it irrelevant which gets used under the hood, | |
24 | + # a goal of solrb is to make it irrelevant which gets used under the hood, | |
24 | 25 | # but favor Ruby responses. |
25 | 26 | @data = eval(ruby_code) |
26 | 27 | @header = @data['responseHeader'] |
... | ... | @@ -38,5 +39,5 @@ class Solr::Response::Ruby < Solr::Response::Base |
38 | 39 | def query_time |
39 | 40 | @header['QTime'] |
40 | 41 | end |
41 | - | |
42 | + | |
42 | 43 | end | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/solr/response/xml.rb
... | ... | @@ -18,7 +18,7 @@ class Solr::Response::Xml < Solr::Response::Base |
18 | 18 | # parse the xml |
19 | 19 | @doc = REXML::Document.new(xml) |
20 | 20 | |
21 | - # look for the result code and string | |
21 | + # look for the result code and string | |
22 | 22 | # <?xml version="1.0" encoding="UTF-8"?> |
23 | 23 | # <response> |
24 | 24 | # <lst name="responseHeader"><int name="status">0</int><int name="QTime">2</int></lst> | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/tasks/database.rake
... | ... | @@ -5,12 +5,12 @@ namespace :db do |
5 | 5 | begin |
6 | 6 | ActsAsSolr::Post.execute(Solr::Request::Delete.new(:query => "*:*")) |
7 | 7 | ActsAsSolr::Post.execute(Solr::Request::Commit.new) |
8 | - (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'test', 'fixtures', '*.{yml,csv}'))).each do |fixture_file| | |
8 | + (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(Rails.root, 'test', 'fixtures', '*.{yml,csv}'))).each do |fixture_file| | |
9 | 9 | ActsAsSolr::SolrFixtures.load(File.basename(fixture_file, '.*')) |
10 | - end | |
11 | - puts "The fixtures loaded have been added to Solr" | |
10 | + end | |
11 | + puts "The fixtures loaded have been added to Solr" | |
12 | 12 | rescue |
13 | 13 | end |
14 | 14 | end |
15 | 15 | end |
16 | -end | |
17 | 16 | \ No newline at end of file |
17 | +end | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/tasks/jeweler.rake
0 → 100644
... | ... | @@ -0,0 +1,15 @@ |
1 | +begin | |
2 | + require 'jeweler' | |
3 | +rescue LoadError | |
4 | +end | |
5 | + | |
6 | +Jeweler::Tasks.new do |s| | |
7 | + s.name = "acts_as_solr_reloaded" | |
8 | + s.summary = "This gem adds full text search capabilities and many other nifty features from Apache Solr to any Rails model." | |
9 | + s.email = "dc.rec1@gmail.com" | |
10 | + s.homepage = "http://github.com/dcrec1/acts_as_solr_reloaded" | |
11 | + s.description = "This gem adds full text search capabilities and many other nifty features from Apache Solr to any Rails model." | |
12 | + s.authors = ["Diego Carrion"] | |
13 | + s.files = FileList["[A-Z]*", "{bin,generators,config,lib,solr}/**/*"] + | |
14 | + FileList["test/**/*"].reject {|f| f.include?("test/log")}.reject {|f| f.include?("test/tmp")} | |
15 | +end if defined? Jeweler | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/tasks/rdoc.rake
0 → 100644
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/tasks/solr.rake
... | ... | @@ -158,7 +158,7 @@ namespace :solr do |
158 | 158 | |
159 | 159 | logger = ActiveRecord::Base.logger = Logger.new(STDOUT) |
160 | 160 | logger.level = ActiveSupport::BufferedLogger::INFO unless debug_output |
161 | - Dir["#{RAILS_ROOT}/app/models/*.rb"].each{ |file| require file } | |
161 | + Dir["#{Rails.root}/app/models/*.rb"].each{ |file| require file } | |
162 | 162 | |
163 | 163 | if start_server |
164 | 164 | puts "Starting Solr server..." | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/tasks/test.rake
plugins/solr/vendor/plugins/acts_as_solr_reloaded/solr/solr/conf/schema.xml
... | ... | @@ -57,11 +57,9 @@ |
57 | 57 | <fieldType name="text" class="solr.TextField" autoGeneratePhraseQueries="false"> |
58 | 58 | <analyzer type="index"> |
59 | 59 | <tokenizer class="solr.StandardTokenizerFactory"/> |
60 | - <filter class="solr.RemoveDuplicatesTokenFilterFactory"/> | |
61 | - | |
62 | 60 | <filter class="solr.ASCIIFoldingFilterFactory"/> |
63 | 61 | <filter class="solr.LowerCaseFilterFactory"/> |
64 | - | |
62 | + <filter class="solr.RemoveDuplicatesTokenFilterFactory"/> | |
65 | 63 | <filter class="solr.StopFilterFactory" words="stopwords.pt.txt" /> |
66 | 64 | |
67 | 65 | <!-- stemming |
... | ... | @@ -73,18 +71,12 @@ |
73 | 71 | <filter class="solr.HunspellStemFilterFactory" dictionary="en_US.dic" affix="en_US.aff" ignoreCase="true" /> |
74 | 72 | <filter class="solr.HunspellStemFilterFactory" dictionary="pt_PT.dic" affix="pt_PT.aff" ignoreCase="true" /> |
75 | 73 | --> |
76 | - | |
77 | - <!-- improvised stemming | |
78 | - <filter class="solr.EdgeNGramFilterFactory" minGramSize="3" maxGramSize="20" side="front"/> | |
79 | - --> | |
80 | 74 | </analyzer> |
81 | 75 | <analyzer type="query"> |
82 | 76 | <tokenizer class="solr.StandardTokenizerFactory"/> |
83 | - <filter class="solr.RemoveDuplicatesTokenFilterFactory"/> | |
84 | - | |
85 | 77 | <filter class="solr.ASCIIFoldingFilterFactory"/> |
86 | 78 | <filter class="solr.LowerCaseFilterFactory"/> |
87 | - | |
79 | + <filter class="solr.RemoveDuplicatesTokenFilterFactory"/> | |
88 | 80 | <filter class="solr.StopFilterFactory" words="stopwords.pt.txt" /> |
89 | 81 | |
90 | 82 | <!-- stemming |
... | ... | @@ -96,10 +88,23 @@ |
96 | 88 | <filter class="solr.HunspellStemFilterFactory" dictionary="en_US.dic" affix="en_US.aff" ignoreCase="true" /> |
97 | 89 | <filter class="solr.HunspellStemFilterFactory" dictionary="pt_PT.dic" affix="pt_PT.aff" ignoreCase="true" /> |
98 | 90 | --> |
91 | + </analyzer> | |
92 | + </fieldType> | |
99 | 93 | |
100 | - <!-- improvised stemming | |
101 | - <filter class="solr.EdgeNGramFilterFactory" minGramSize="3" maxGramSize="20" side="front"/> | |
102 | - --> | |
94 | + <fieldType name="ngramText" class="solr.TextField" positionIncrementGap="100"> | |
95 | + <analyzer type="index"> | |
96 | + <tokenizer class="solr.StandardTokenizerFactory"/> | |
97 | + <filter class="solr.ASCIIFoldingFilterFactory"/> | |
98 | + <filter class="solr.LowerCaseFilterFactory"/> | |
99 | + <filter class="solr.RemoveDuplicatesTokenFilterFactory"/> | |
100 | + | |
101 | + <filter class="solr.EdgeNGramFilterFactory" minGramSize="1" maxGramSize="20" side="front"/> | |
102 | + </analyzer> | |
103 | + <analyzer type="query"> | |
104 | + <tokenizer class="solr.StandardTokenizerFactory"/> | |
105 | + <filter class="solr.ASCIIFoldingFilterFactory"/> | |
106 | + <filter class="solr.LowerCaseFilterFactory"/> | |
107 | + <filter class="solr.RemoveDuplicatesTokenFilterFactory"/> | |
103 | 108 | </analyzer> |
104 | 109 | </fieldType> |
105 | 110 | |
... | ... | @@ -151,6 +156,7 @@ |
151 | 156 | <dynamicField name="*sortable_do" type="sdouble" indexed="true" stored="false" multiValued="false"/> |
152 | 157 | |
153 | 158 | <dynamicField name="*_t" type="text" indexed="true" stored="true" multiValued="true"/> |
159 | + <dynamicField name="*_nt" type="ngramText" indexed="true" stored="true" multiValued="true"/> | |
154 | 160 | <dynamicField name="*_s" type="text" indexed="true" stored="true" multiValued="false"/> |
155 | 161 | <dynamicField name="*_i" type="integer" indexed="true" stored="false" multiValued="true"/> |
156 | 162 | <dynamicField name="*_f" type="float" indexed="true" stored="true" multiValued="false"/> |
... | ... | @@ -168,6 +174,7 @@ |
168 | 174 | <field name="geo_distance" type="sdouble"/> <!-- Optional but used for distributed searching --> |
169 | 175 | |
170 | 176 | <field name="text" type="text" indexed="true" stored="false" multiValued="true"/> |
177 | + <field name="ngramText" type="ngramText" indexed="true" stored="false" multiValued="true"/> | |
171 | 178 | <field name="spell" type="textSpell" indexed="true" stored="true" multiValued="true"/> |
172 | 179 | |
173 | 180 | <dynamicField name="*_s_mv" type="string" indexed="true" stored="false" multiValued="true"/> |
... | ... | @@ -187,6 +194,10 @@ |
187 | 194 | <copyField source="*_do" dest="text"/> |
188 | 195 | <copyField source="*_facet" dest="text"/> |
189 | 196 | |
197 | + <copyField source="*_s" dest="ngramText"/> | |
198 | + <copyField source="*_t" dest="ngramText"/> | |
199 | + <copyField source="*_nt" dest="ngramText"/> | |
200 | + | |
190 | 201 | <copyField source="*_s" dest="spell"/> |
191 | 202 | <copyField source="*_t" dest="spell"/> |
192 | 203 | <copyField source="*_facet" dest="spell"/> | ... | ... |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/solr_test_rakefile.rb
plugins/solr/vendor/plugins/acts_as_solr_reloaded/test/fixtures/locals.yml
0 → 100644
plugins/solr/vendor/plugins/acts_as_solr_reloaded/test/test_helper.rb
... | ... | @@ -16,7 +16,7 @@ require 'mongo_mapper' |
16 | 16 | |
17 | 17 | class Rails |
18 | 18 | def self.root |
19 | - RAILS_ROOT | |
19 | + Rails.root | |
20 | 20 | end |
21 | 21 | |
22 | 22 | def self.env |
... | ... | @@ -26,13 +26,14 @@ end |
26 | 26 | |
27 | 27 | MongoMapper.database = "acts_as_solr_reloaded-test" |
28 | 28 | |
29 | -RAILS_ROOT = File.dirname(__FILE__) unless defined? RAILS_ROOT | |
30 | -RAILS_ENV = 'test' unless defined? RAILS_ENV | |
29 | +RAILS_ENV = 'test' unless defined? RAILS_ENV | |
31 | 30 | ENV["RAILS_ENV"] = "test" |
32 | 31 | |
33 | 32 | require File.expand_path(File.dirname(__FILE__) + '/../config/solr_environment') |
34 | 33 | require File.expand_path(File.dirname(__FILE__) + '/../lib/acts_as_solr') |
35 | 34 | |
35 | +ActiveRecord::Base.logger = Logger.new('/dev/null') | |
36 | + | |
36 | 37 | # Load Models |
37 | 38 | models_dir = File.join(File.dirname( __FILE__ ), 'models') |
38 | 39 | require "#{models_dir}/book.rb" |
... | ... | @@ -60,10 +61,10 @@ class Test::Unit::TestCase |
60 | 61 | klass = instance_eval table_name.to_s.capitalize.singularize |
61 | 62 | klass.find(:all).each{|content| content.solr_save} |
62 | 63 | end |
63 | - | |
64 | + | |
64 | 65 | clear_from_solr(:novels) |
65 | 66 | end |
66 | - | |
67 | + | |
67 | 68 | private |
68 | 69 | def self.clear_from_solr(table_name) |
69 | 70 | ActsAsSolr::Post.execute(Solr::Request::Delete.new(:query => "type_s:#{table_name.to_s.capitalize.singularize}")) | ... | ... |