Commit 555171514783ca260cd963f911be31d44a694d9c
1 parent
19a038f4
Exists in
master
and in
29 other branches
Random fixes to get the initial page loading
plus login and signup screens being displayed. They don't work yet, though.
Showing
17 changed files
with
87 additions
and
57 deletions
Show diff stats
MIGRATION_ISSUES
@@ -22,7 +22,7 @@ | @@ -22,7 +22,7 @@ | ||
22 | 22 | ||
23 | * check FIXME's in Gemfile | 23 | * check FIXME's in Gemfile |
24 | 24 | ||
25 | -* rewrite config/routes.rb | 25 | +* Finish rewriting config/routes.rb (look for __END__) |
26 | 26 | ||
27 | * rewrite conditional routing. See FIXME in lib/route_if.rb and re-implement using the Rails 3 mechanism - http://guides.rubyonrails.org/routing.html#advanced-constraints | 27 | * rewrite conditional routing. See FIXME in lib/route_if.rb and re-implement using the Rails 3 mechanism - http://guides.rubyonrails.org/routing.html#advanced-constraints |
28 | 28 | ||
@@ -30,4 +30,12 @@ | @@ -30,4 +30,12 @@ | ||
30 | 30 | ||
31 | * xss_terminate sucks. We should replace it with the builtin mechanism in Rails 3 | 31 | * xss_terminate sucks. We should replace it with the builtin mechanism in Rails 3 |
32 | 32 | ||
33 | -* instance_eval on Ruby 1.9 yields self, so lambdas that are passed to instance_eval and do not accept exactly 1 argument will blow up. See http://www.ruby-forum.com/topic/213313 ... search for instance_eval and fix where necessary. | 33 | +* instance_eval on Ruby 1.9 yields self, so lambdas that are passed to instance_eval and do not accept exactly 1 argument will blow up. See http://www.ruby-forum.com/topic/213313 ... search for instance_eval and fix where necessary. In special, most of the blocks still need fixing. |
34 | + | ||
35 | +* all instances of <% *_form_for ... %> must be changed to <%= instead of <% | ||
36 | + | ||
37 | +* all ActiveRecord models have to declare explicitly which attributes must be allowed for mass assignment with attr_accessible. | ||
38 | + | ||
39 | +* check if we need to update config/locales/* | ||
40 | + | ||
41 | +* check observe_field and labelled_form_for in app/helpers/application_helper.rb |
app/helpers/application_helper.rb
@@ -826,8 +826,8 @@ module ApplicationHelper | @@ -826,8 +826,8 @@ module ApplicationHelper | ||
826 | end | 826 | end |
827 | 827 | ||
828 | def labelled_form_for(name, object = nil, options = {}, &proc) | 828 | def labelled_form_for(name, object = nil, options = {}, &proc) |
829 | - object ||= instance_variable_get("@#{name}") | ||
830 | - form_for(name, object, { :builder => NoosferoFormBuilder }.merge(options), &proc) | 829 | + # FIXME remove the =object= argument and adapt the calling code |
830 | + form_for(name, { :builder => NoosferoFormBuilder }.merge(options), &proc) | ||
831 | end | 831 | end |
832 | 832 | ||
833 | def optional_field(profile, name, field_html = nil, only_required = false, &block) | 833 | def optional_field(profile, name, field_html = nil, only_required = false, &block) |
@@ -1409,4 +1409,28 @@ module ApplicationHelper | @@ -1409,4 +1409,28 @@ module ApplicationHelper | ||
1409 | options[:class] = "comment-footer comment-footer-link comment-footer-hide" | 1409 | options[:class] = "comment-footer comment-footer-link comment-footer-hide" |
1410 | expirable_content_reference content, action, text, url, options | 1410 | expirable_content_reference content, action, text, url, options |
1411 | end | 1411 | end |
1412 | + | ||
1413 | + def error_messages_for(*args) | ||
1414 | + options = args.pop if args.last.is_a?(Hash) | ||
1415 | + errors = [] | ||
1416 | + args.each do |name| | ||
1417 | + object = instance_variable_get("@#{name}") | ||
1418 | + object.errors.full_messages.each do |msg| | ||
1419 | + errors << msg | ||
1420 | + end | ||
1421 | + end | ||
1422 | + return '' if errors.empty? | ||
1423 | + | ||
1424 | + content_tag(:div, :class => 'errorExplanation', :id => 'errorExplanation') do | ||
1425 | + content_tag(:h2, _('Errors while saving')) + | ||
1426 | + content_tag(:ul) do | ||
1427 | + errors.map { |err| content_tag(:li, err) } | ||
1428 | + end | ||
1429 | + end | ||
1430 | + end | ||
1431 | + | ||
1432 | + # FIXME | ||
1433 | + def observe_field(*args) | ||
1434 | + '' | ||
1435 | + end | ||
1412 | end | 1436 | end |
app/helpers/countries_helper.rb
@@ -267,7 +267,7 @@ module CountriesHelper | @@ -267,7 +267,7 @@ module CountriesHelper | ||
267 | end | 267 | end |
268 | 268 | ||
269 | def countries | 269 | def countries |
270 | - self.class.countries.map {|item| [gettext(item[0]), item[1] ]}.sort_by { |entry| entry.first.transliterate } | 270 | + CountriesHelper.countries.map {|item| [gettext(item[0]), item[1] ]}.sort_by { |entry| entry.first.transliterate } |
271 | end | 271 | end |
272 | 272 | ||
273 | def lookup(code) | 273 | def lookup(code) |
app/models/article.rb
@@ -219,13 +219,6 @@ class Article < ActiveRecord::Base | @@ -219,13 +219,6 @@ class Article < ActiveRecord::Base | ||
219 | limit(limit). | 219 | limit(limit). |
220 | order(['articles.published_at desc', 'articles.id desc']) | 220 | order(['articles.published_at desc', 'articles.id desc']) |
221 | 221 | ||
222 | - if !( scoped_methods && scoped_methods.last && | ||
223 | - scoped_methods.last[:find] && | ||
224 | - scoped_methods.last[:find][:joins] && | ||
225 | - scoped_methods.last[:find][:joins].index('profiles') ) | ||
226 | - result = result.includes(:profile) | ||
227 | - end | ||
228 | - | ||
229 | pagination ? result.paginate({:page => 1, :per_page => limit}) : result | 222 | pagination ? result.paginate({:page => 1, :per_page => limit}) : result |
230 | end | 223 | end |
231 | 224 |
app/models/communities_block.rb
@@ -16,11 +16,11 @@ class CommunitiesBlock < ProfileListBlock | @@ -16,11 +16,11 @@ class CommunitiesBlock < ProfileListBlock | ||
16 | owner = self.owner | 16 | owner = self.owner |
17 | case owner | 17 | case owner |
18 | when Profile | 18 | when Profile |
19 | - lambda do | 19 | + lambda do |context| |
20 | link_to s_('communities|View all'), :profile => owner.identifier, :controller => 'profile', :action => 'communities' | 20 | link_to s_('communities|View all'), :profile => owner.identifier, :controller => 'profile', :action => 'communities' |
21 | end | 21 | end |
22 | when Environment | 22 | when Environment |
23 | - lambda do | 23 | + lambda do |context| |
24 | link_to s_('communities|View all'), :controller => 'search', :action => 'communities' | 24 | link_to s_('communities|View all'), :controller => 'search', :action => 'communities' |
25 | end | 25 | end |
26 | else | 26 | else |
app/models/domain.rb
app/models/login_block.rb
@@ -9,7 +9,7 @@ class LoginBlock < Block | @@ -9,7 +9,7 @@ class LoginBlock < Block | ||
9 | end | 9 | end |
10 | 10 | ||
11 | def content(args={}) | 11 | def content(args={}) |
12 | - lambda do | 12 | + lambda do |context| |
13 | render :file => 'blocks/login_block' | 13 | render :file => 'blocks/login_block' |
14 | end | 14 | end |
15 | end | 15 | end |
app/models/people_block.rb
@@ -17,7 +17,7 @@ class PeopleBlock < ProfileListBlock | @@ -17,7 +17,7 @@ class PeopleBlock < ProfileListBlock | ||
17 | end | 17 | end |
18 | 18 | ||
19 | def footer | 19 | def footer |
20 | - lambda do | 20 | + lambda do |context| |
21 | link_to _('View all'), :controller => 'search', :action => 'people' | 21 | link_to _('View all'), :controller => 'search', :action => 'people' |
22 | end | 22 | end |
23 | end | 23 | end |
app/models/profile_list_block.rb
@@ -44,7 +44,7 @@ class ProfileListBlock < Block | @@ -44,7 +44,7 @@ class ProfileListBlock < Block | ||
44 | profiles = self.profile_list | 44 | profiles = self.profile_list |
45 | title = self.view_title | 45 | title = self.view_title |
46 | nl = "\n" | 46 | nl = "\n" |
47 | - lambda do | 47 | + lambda do |context| |
48 | count=0 | 48 | count=0 |
49 | list = profiles.map {|item| | 49 | list = profiles.map {|item| |
50 | count+=1 | 50 | count+=1 |
app/views/account/_signup_form.html.erb
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | 2 | ||
3 | <%= error_messages_for :user, :person, :header_message => _('The account could not be created') %> | 3 | <%= error_messages_for :user, :person, :header_message => _('The account could not be created') %> |
4 | 4 | ||
5 | -<% labelled_form_for :user, @user, :html => { :multipart => true, :id => 'signup-form' } do |f| %> | 5 | +<%= labelled_form_for :user, @user, :html => { :multipart => true, :id => 'signup-form' } do |f| %> |
6 | 6 | ||
7 | <%= hidden_field_tag :invitation_code, @invitation_code %> | 7 | <%= hidden_field_tag :invitation_code, @invitation_code %> |
8 | 8 |
app/views/account/login.html.erb
@@ -7,7 +7,7 @@ | @@ -7,7 +7,7 @@ | ||
7 | 7 | ||
8 | <%= @message %> | 8 | <%= @message %> |
9 | 9 | ||
10 | -<% labelled_form_for :user, @user, :url => login_url do |f| %> | 10 | +<%= labelled_form_for :user, @user, :url => login_url do |f| %> |
11 | 11 | ||
12 | <%= f.text_field :login, :id => 'main_user_login', :onchange => 'this.value = convToValidLogin( this.value )', :value => params[:userlogin] %> | 12 | <%= f.text_field :login, :id => 'main_user_login', :onchange => 'this.value = convToValidLogin( this.value )', :value => params[:userlogin] %> |
13 | 13 |
app/views/account/login_block.html.erb
@@ -9,7 +9,7 @@ | @@ -9,7 +9,7 @@ | ||
9 | @user ||= User.new | 9 | @user ||= User.new |
10 | %> | 10 | %> |
11 | 11 | ||
12 | - <% labelled_form_for :user, @user, :url => login_url do |f| %> | 12 | + <%= labelled_form_for :user, @user, :url => login_url do |f| %> |
13 | 13 | ||
14 | <%= f.text_field :login, :onchange => 'this.value = convToValidLogin( this.value )' %> | 14 | <%= f.text_field :login, :onchange => 'this.value = convToValidLogin( this.value )' %> |
15 | 15 |
app/views/layouts/_javascript.html.erb
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | 'jquery-ui-1.8.2.custom.min', 'jquery.scrollTo', 'jquery.form.js', 'jquery-validation/jquery.validate', | 3 | 'jquery-ui-1.8.2.custom.min', 'jquery.scrollTo', 'jquery.form.js', 'jquery-validation/jquery.validate', |
4 | 'jquery.cookie', 'jquery.ba-bbq.min.js', 'reflection', 'jquery.tokeninput', | 4 | 'jquery.cookie', 'jquery.ba-bbq.min.js', 'reflection', 'jquery.tokeninput', |
5 | 'add-and-join', 'report-abuse', 'catalog', 'manage-products', | 5 | 'add-and-join', 'report-abuse', 'catalog', 'manage-products', |
6 | -'jquery-ui-timepicker-addon', :cache => 'cache-general' %> | 6 | +'jquery-ui-timepicker-addon', 'application.js', :cache => 'cache-general' %> |
7 | 7 | ||
8 | <% language = FastGettext.locale %> | 8 | <% language = FastGettext.locale %> |
9 | <% %w{messages methods}.each do |type| %> | 9 | <% %w{messages methods}.each do |type| %> |
app/views/layouts/application-ng.html.erb
@@ -9,14 +9,14 @@ | @@ -9,14 +9,14 @@ | ||
9 | <link rel="shortcut icon" href="<%= image_path(theme_favicon) %>" type="image/x-icon" /> | 9 | <link rel="shortcut icon" href="<%= image_path(theme_favicon) %>" type="image/x-icon" /> |
10 | <%= noosfero_javascript %> | 10 | <%= noosfero_javascript %> |
11 | <%= stylesheet_link_tag *noosfero_stylesheets, :cache => 'cache' %> | 11 | <%= stylesheet_link_tag *noosfero_stylesheets, :cache => 'cache' %> |
12 | - <%= stylesheet_link_tag template_stylesheet_path %> | ||
13 | - <%= stylesheet_link_tag icon_theme_stylesheet_path %> | ||
14 | - <%= stylesheet_link_tag jquery_ui_theme_stylesheet_path %> | 12 | + <%= stylesheet_link_tag *template_stylesheet_path %> |
13 | + <%= stylesheet_link_tag *icon_theme_stylesheet_path %> | ||
14 | + <%= stylesheet_link_tag *jquery_ui_theme_stylesheet_path %> | ||
15 | <% | 15 | <% |
16 | plugins_stylesheets = @plugins.select(&:stylesheet?).map { |plugin| plugin.class.public_path('style.css') } | 16 | plugins_stylesheets = @plugins.select(&:stylesheet?).map { |plugin| plugin.class.public_path('style.css') } |
17 | %> | 17 | %> |
18 | - <%= stylesheet_link_tag(plugins_stylesheets, :cache => 'cache/plugins-' + Digest::MD5.hexdigest(plugins_stylesheets.to_s)) unless plugins_stylesheets.empty? %> | ||
19 | - <%= stylesheet_link_tag theme_stylesheet_path %> | 18 | + <%= stylesheet_link_tag(*plugins_stylesheets, :cache => 'cache/plugins-' + Digest::MD5.hexdigest(plugins_stylesheets.to_s)) unless plugins_stylesheets.empty? %> |
19 | + <%= stylesheet_link_tag *theme_stylesheet_path %> | ||
20 | 20 | ||
21 | <%# Add custom tags/styles/etc via content_for %> | 21 | <%# Add custom tags/styles/etc via content_for %> |
22 | <%= yield :head %> | 22 | <%= yield :head %> |
@@ -24,7 +24,7 @@ | @@ -24,7 +24,7 @@ | ||
24 | <% | 24 | <% |
25 | plugins_javascripts = @plugins.map { |plugin| plugin.js_files.map { |js| plugin.class.public_path(js) } }.flatten | 25 | plugins_javascripts = @plugins.map { |plugin| plugin.js_files.map { |js| plugin.class.public_path(js) } }.flatten |
26 | %> | 26 | %> |
27 | - <%= javascript_include_tag(plugins_javascripts, :cache => 'cache/plugins-' + Digest::MD5.hexdigest(plugins_javascripts.to_s)) unless plugins_javascripts.empty? %> | 27 | + <%= javascript_include_tag(*plugins_javascripts, :cache => 'cache/plugins-' + Digest::MD5.hexdigest(plugins_javascripts.to_s)) unless plugins_javascripts.empty? %> |
28 | <%= | 28 | <%= |
29 | @plugins.dispatch(:head_ending).collect do |content| | 29 | @plugins.dispatch(:head_ending).collect do |content| |
30 | content.respond_to?(:call) ? content.call : content | 30 | content.respond_to?(:call) ? content.call : content |
config/application.rb
@@ -74,7 +74,7 @@ module Noosfero | @@ -74,7 +74,7 @@ module Noosfero | ||
74 | config.active_record.whitelist_attributes = true | 74 | config.active_record.whitelist_attributes = true |
75 | 75 | ||
76 | # Enable the asset pipeline | 76 | # Enable the asset pipeline |
77 | - config.assets.enabled = true | 77 | + config.assets.enabled = false |
78 | 78 | ||
79 | # Version of your assets, change this if you want to expire all your assets | 79 | # Version of your assets, change this if you want to expire all your assets |
80 | config.assets.version = '1.0' | 80 | config.assets.version = '1.0' |
config/routes.rb
1 | require 'noosfero' | 1 | require 'noosfero' |
2 | +require 'environment_domain_constraint' | ||
2 | 3 | ||
3 | Noosfero::Application.routes.draw do | 4 | Noosfero::Application.routes.draw do |
4 | # The priority is based upon order of creation: first created -> highest priority. | 5 | # The priority is based upon order of creation: first created -> highest priority. |
5 | - | ||
6 | # Sample of regular route: | 6 | # Sample of regular route: |
7 | # map.connect 'products/:id', :controller => 'catalog', :action => 'view' | 7 | # map.connect 'products/:id', :controller => 'catalog', :action => 'view' |
8 | # Keep in mind you can assign values other than :controller and :action | 8 | # Keep in mind you can assign values other than :controller and :action |
@@ -16,47 +16,45 @@ Noosfero::Application.routes.draw do | @@ -16,47 +16,45 @@ Noosfero::Application.routes.draw do | ||
16 | ###################################################### | 16 | ###################################################### |
17 | 17 | ||
18 | match 'test/:controller(/:action(/:id))' , :controller => /.*test.*/ | 18 | match 'test/:controller(/:action(/:id))' , :controller => /.*test.*/ |
19 | - | 19 | + |
20 | # -- just remember to delete public/index.html. | 20 | # -- just remember to delete public/index.html. |
21 | # You can have the root of your site routed by hooking up '' | 21 | # You can have the root of your site routed by hooking up '' |
22 | - root :to => 'home#index' | 22 | + root :to => 'home#index', :constraints => EnvironmentDomainConstraint.new |
23 | 23 | ||
24 | - # FIXME adapt the rest of the routes below | ||
25 | -end | ||
26 | -__END__ | ||
27 | - map.connect '', :controller => "home", :conditions => { :if => lambda { |env| !Domain.hosting_profile_at(env[:host]) } } | ||
28 | - map.home 'site/:action', :controller => 'home' | 24 | + match 'site(/:action)', :controller => 'home' |
29 | 25 | ||
30 | - map.connect 'images/*stuff', :controller => 'not_found', :action => 'nothing' | ||
31 | - map.connect 'stylesheets/*stuff', :controller => 'not_found', :action => 'nothing' | ||
32 | - map.connect 'designs/*stuff', :controller => 'not_found', :action => 'nothing' | ||
33 | - map.connect 'articles/*stuff', :controller => 'not_found', :action => 'nothing' | ||
34 | - map.connect 'javascripts/*stuff', :controller => 'not_found', :action => 'nothing' | ||
35 | - map.connect 'thumbnails/*stuff', :controller => 'not_found', :action => 'nothing' | ||
36 | - map.connect 'user_themes/*stuff', :controller => 'not_found', :action => 'nothing' | 26 | + match 'images/*stuff' => 'not_found#nothing' |
27 | + match 'stylesheets/*stuff' => 'not_found#nothing' | ||
28 | + match 'designs/*stuff' => 'not_found#nothing' | ||
29 | + match 'articles/*stuff' => 'not_found#nothing' | ||
30 | + match 'javascripts/*stuff' => 'not_found#nothing' | ||
31 | + match 'thumbnails/*stuff' => 'not_found#nothing' | ||
32 | + match 'user_themes/*stuff' => 'not_found#nothing' | ||
37 | 33 | ||
38 | # online documentation | 34 | # online documentation |
39 | - map.doc 'doc', :controller => 'doc', :action => 'index' | ||
40 | - map.doc_section 'doc/:section', :controller => 'doc', :action => 'section' | ||
41 | - map.doc_topic 'doc/:section/:topic', :controller => 'doc', :action => 'topic' | ||
42 | - | 35 | + match 'doc' => 'doc#index', :as => :doc |
36 | + match 'doc/:section' => 'doc#section', :as => :doc_section | ||
37 | + match 'doc/:section/:topic' => 'doc#topic', :as => :doc_topic | ||
38 | + | ||
43 | # user account controller | 39 | # user account controller |
44 | - map.connect 'account/new_password/:code', :controller => 'account', :action => 'new_password' | ||
45 | - map.connect 'account/:action', :controller => 'account' | 40 | + match 'account/new_password/:code' => 'account#new_password', :controller => 'account', :action => 'new_password' |
41 | + match 'account/:action', :controller => 'account' | ||
46 | 42 | ||
47 | # enterprise registration | 43 | # enterprise registration |
48 | - map.connect 'enterprise_registration/:action', :controller => 'enterprise_registration' | 44 | + match 'enterprise_registration/:action', :controller => 'enterprise_registration' |
49 | 45 | ||
50 | # tags | 46 | # tags |
51 | - map.tag 'tag', :controller => 'search', :action => 'tags' | ||
52 | - map.tag 'tag/:tag', :controller => 'search', :action => 'tag', :tag => /.*/ | ||
53 | - | 47 | + match 'tag', :controller => 'search', :action => 'tags' |
48 | + match 'tag/:tag', :controller => 'search', :action => 'tag', :tag => /.*/ | ||
49 | + | ||
54 | # categories index | 50 | # categories index |
55 | - map.category 'cat/*category_path', :controller => 'search', :action => 'category_index' | ||
56 | - map.assets 'assets/:asset/*category_path', :controller => 'search', :action => 'assets' | 51 | + match 'cat/*category_path' => 'search#category_index', :as => :category |
52 | + match 'assets/:asset(/*category_path)' => 'search#assets', :as => :assets | ||
57 | # search | 53 | # search |
58 | - map.connect 'search/:action/*category_path', :controller => 'search' | ||
59 | - | 54 | + match 'search/:action(/*category_path)', :controller => 'search' |
55 | + | ||
56 | +end # FIXME remove this line and the following and finish rewriting the routes | ||
57 | +__END__ | ||
60 | # events | 58 | # events |
61 | map.events 'profile/:profile/events_by_day', :controller => 'events', :action => 'events_by_day', :profile => /#{Noosfero.identifier_format}/ | 59 | map.events 'profile/:profile/events_by_day', :controller => 'events', :action => 'events_by_day', :profile => /#{Noosfero.identifier_format}/ |
62 | map.events 'profile/:profile/events/:year/:month/:day', :controller => 'events', :action => 'events', :year => /\d*/, :month => /\d*/, :day => /\d*/, :profile => /#{Noosfero.identifier_format}/ | 60 | map.events 'profile/:profile/events/:year/:month/:day', :controller => 'events', :action => 'events', :year => /\d*/, :month => /\d*/, :day => /\d*/, :profile => /#{Noosfero.identifier_format}/ |