diff --git a/MIGRATION_ISSUES b/MIGRATION_ISSUES index f1a8e98..de92de6 100644 --- a/MIGRATION_ISSUES +++ b/MIGRATION_ISSUES @@ -22,7 +22,7 @@ * check FIXME's in Gemfile -* rewrite config/routes.rb +* Finish rewriting config/routes.rb (look for __END__) * 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 @@ -30,4 +30,12 @@ * xss_terminate sucks. We should replace it with the builtin mechanism in Rails 3 -* 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. +* 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. + +* all instances of <% *_form_for ... %> must be changed to <%= instead of <% + +* all ActiveRecord models have to declare explicitly which attributes must be allowed for mass assignment with attr_accessible. + +* check if we need to update config/locales/* + +* check observe_field and labelled_form_for in app/helpers/application_helper.rb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 54309bf..68752a0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -826,8 +826,8 @@ module ApplicationHelper end def labelled_form_for(name, object = nil, options = {}, &proc) - object ||= instance_variable_get("@#{name}") - form_for(name, object, { :builder => NoosferoFormBuilder }.merge(options), &proc) + # FIXME remove the =object= argument and adapt the calling code + form_for(name, { :builder => NoosferoFormBuilder }.merge(options), &proc) end def optional_field(profile, name, field_html = nil, only_required = false, &block) @@ -1409,4 +1409,28 @@ module ApplicationHelper options[:class] = "comment-footer comment-footer-link comment-footer-hide" expirable_content_reference content, action, text, url, options end + + def error_messages_for(*args) + options = args.pop if args.last.is_a?(Hash) + errors = [] + args.each do |name| + object = instance_variable_get("@#{name}") + object.errors.full_messages.each do |msg| + errors << msg + end + end + return '' if errors.empty? + + content_tag(:div, :class => 'errorExplanation', :id => 'errorExplanation') do + content_tag(:h2, _('Errors while saving')) + + content_tag(:ul) do + errors.map { |err| content_tag(:li, err) } + end + end + end + + # FIXME + def observe_field(*args) + '' + end end diff --git a/app/helpers/countries_helper.rb b/app/helpers/countries_helper.rb index 461824a..2f21e60 100644 --- a/app/helpers/countries_helper.rb +++ b/app/helpers/countries_helper.rb @@ -267,7 +267,7 @@ module CountriesHelper end def countries - self.class.countries.map {|item| [gettext(item[0]), item[1] ]}.sort_by { |entry| entry.first.transliterate } + CountriesHelper.countries.map {|item| [gettext(item[0]), item[1] ]}.sort_by { |entry| entry.first.transliterate } end def lookup(code) diff --git a/app/models/article.rb b/app/models/article.rb index 1a4f94a..a4f1060 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -219,13 +219,6 @@ class Article < ActiveRecord::Base limit(limit). order(['articles.published_at desc', 'articles.id desc']) - if !( scoped_methods && scoped_methods.last && - scoped_methods.last[:find] && - scoped_methods.last[:find][:joins] && - scoped_methods.last[:find][:joins].index('profiles') ) - result = result.includes(:profile) - end - pagination ? result.paginate({:page => 1, :per_page => limit}) : result end diff --git a/app/models/communities_block.rb b/app/models/communities_block.rb index 570738e..6498d55 100644 --- a/app/models/communities_block.rb +++ b/app/models/communities_block.rb @@ -16,11 +16,11 @@ class CommunitiesBlock < ProfileListBlock owner = self.owner case owner when Profile - lambda do + lambda do |context| link_to s_('communities|View all'), :profile => owner.identifier, :controller => 'profile', :action => 'communities' end when Environment - lambda do + lambda do |context| link_to s_('communities|View all'), :controller => 'search', :action => 'communities' end else diff --git a/app/models/domain.rb b/app/models/domain.rb index 00c113c..9be2e9d 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -1,3 +1,5 @@ +require 'noosfero/multi_tenancy' + class Domain < ActiveRecord::Base attr_accessible :name diff --git a/app/models/login_block.rb b/app/models/login_block.rb index 1ab82da..2f6adfe 100644 --- a/app/models/login_block.rb +++ b/app/models/login_block.rb @@ -9,7 +9,7 @@ class LoginBlock < Block end def content(args={}) - lambda do + lambda do |context| render :file => 'blocks/login_block' end end diff --git a/app/models/people_block.rb b/app/models/people_block.rb index 3b6e60a..d3f2627 100644 --- a/app/models/people_block.rb +++ b/app/models/people_block.rb @@ -17,7 +17,7 @@ class PeopleBlock < ProfileListBlock end def footer - lambda do + lambda do |context| link_to _('View all'), :controller => 'search', :action => 'people' end end diff --git a/app/models/profile_list_block.rb b/app/models/profile_list_block.rb index 12db537..88613b3 100644 --- a/app/models/profile_list_block.rb +++ b/app/models/profile_list_block.rb @@ -44,7 +44,7 @@ class ProfileListBlock < Block profiles = self.profile_list title = self.view_title nl = "\n" - lambda do + lambda do |context| count=0 list = profiles.map {|item| count+=1 diff --git a/app/views/account/_signup_form.html.erb b/app/views/account/_signup_form.html.erb index 560be5b..9b5536b 100644 --- a/app/views/account/_signup_form.html.erb +++ b/app/views/account/_signup_form.html.erb @@ -2,7 +2,7 @@ <%= error_messages_for :user, :person, :header_message => _('The account could not be created') %> -<% labelled_form_for :user, @user, :html => { :multipart => true, :id => 'signup-form' } do |f| %> +<%= labelled_form_for :user, @user, :html => { :multipart => true, :id => 'signup-form' } do |f| %> <%= hidden_field_tag :invitation_code, @invitation_code %> diff --git a/app/views/account/login.html.erb b/app/views/account/login.html.erb index 5ab7e8c..dbff603 100644 --- a/app/views/account/login.html.erb +++ b/app/views/account/login.html.erb @@ -7,7 +7,7 @@ <%= @message %> -<% labelled_form_for :user, @user, :url => login_url do |f| %> +<%= labelled_form_for :user, @user, :url => login_url do |f| %> <%= f.text_field :login, :id => 'main_user_login', :onchange => 'this.value = convToValidLogin( this.value )', :value => params[:userlogin] %> diff --git a/app/views/account/login_block.html.erb b/app/views/account/login_block.html.erb index aea20a1..fc0ea33 100644 --- a/app/views/account/login_block.html.erb +++ b/app/views/account/login_block.html.erb @@ -9,7 +9,7 @@ @user ||= User.new %> - <% labelled_form_for :user, @user, :url => login_url do |f| %> + <%= labelled_form_for :user, @user, :url => login_url do |f| %> <%= f.text_field :login, :onchange => 'this.value = convToValidLogin( this.value )' %> diff --git a/app/views/layouts/_javascript.html.erb b/app/views/layouts/_javascript.html.erb index 9bcf78d..8f82b2b 100644 --- a/app/views/layouts/_javascript.html.erb +++ b/app/views/layouts/_javascript.html.erb @@ -3,7 +3,7 @@ 'jquery-ui-1.8.2.custom.min', 'jquery.scrollTo', 'jquery.form.js', 'jquery-validation/jquery.validate', 'jquery.cookie', 'jquery.ba-bbq.min.js', 'reflection', 'jquery.tokeninput', 'add-and-join', 'report-abuse', 'catalog', 'manage-products', -'jquery-ui-timepicker-addon', :cache => 'cache-general' %> +'jquery-ui-timepicker-addon', 'application.js', :cache => 'cache-general' %> <% language = FastGettext.locale %> <% %w{messages methods}.each do |type| %> diff --git a/app/views/layouts/application-ng.html.erb b/app/views/layouts/application-ng.html.erb index 6a42fed..6b0078e 100644 --- a/app/views/layouts/application-ng.html.erb +++ b/app/views/layouts/application-ng.html.erb @@ -9,14 +9,14 @@ <%= noosfero_javascript %> <%= stylesheet_link_tag *noosfero_stylesheets, :cache => 'cache' %> - <%= stylesheet_link_tag template_stylesheet_path %> - <%= stylesheet_link_tag icon_theme_stylesheet_path %> - <%= stylesheet_link_tag jquery_ui_theme_stylesheet_path %> + <%= stylesheet_link_tag *template_stylesheet_path %> + <%= stylesheet_link_tag *icon_theme_stylesheet_path %> + <%= stylesheet_link_tag *jquery_ui_theme_stylesheet_path %> <% plugins_stylesheets = @plugins.select(&:stylesheet?).map { |plugin| plugin.class.public_path('style.css') } %> - <%= stylesheet_link_tag(plugins_stylesheets, :cache => 'cache/plugins-' + Digest::MD5.hexdigest(plugins_stylesheets.to_s)) unless plugins_stylesheets.empty? %> - <%= stylesheet_link_tag theme_stylesheet_path %> + <%= stylesheet_link_tag(*plugins_stylesheets, :cache => 'cache/plugins-' + Digest::MD5.hexdigest(plugins_stylesheets.to_s)) unless plugins_stylesheets.empty? %> + <%= stylesheet_link_tag *theme_stylesheet_path %> <%# Add custom tags/styles/etc via content_for %> <%= yield :head %> @@ -24,7 +24,7 @@ <% plugins_javascripts = @plugins.map { |plugin| plugin.js_files.map { |js| plugin.class.public_path(js) } }.flatten %> - <%= javascript_include_tag(plugins_javascripts, :cache => 'cache/plugins-' + Digest::MD5.hexdigest(plugins_javascripts.to_s)) unless plugins_javascripts.empty? %> + <%= javascript_include_tag(*plugins_javascripts, :cache => 'cache/plugins-' + Digest::MD5.hexdigest(plugins_javascripts.to_s)) unless plugins_javascripts.empty? %> <%= @plugins.dispatch(:head_ending).collect do |content| content.respond_to?(:call) ? content.call : content diff --git a/config/application.rb b/config/application.rb index 48cebf0..7eedef9 100644 --- a/config/application.rb +++ b/config/application.rb @@ -74,7 +74,7 @@ module Noosfero config.active_record.whitelist_attributes = true # Enable the asset pipeline - config.assets.enabled = true + config.assets.enabled = false # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' diff --git a/config/routes.rb b/config/routes.rb index 78a4419..9a687e1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,8 +1,8 @@ require 'noosfero' +require 'environment_domain_constraint' Noosfero::Application.routes.draw do # The priority is based upon order of creation: first created -> highest priority. - # Sample of regular route: # map.connect 'products/:id', :controller => 'catalog', :action => 'view' # Keep in mind you can assign values other than :controller and :action @@ -16,47 +16,45 @@ Noosfero::Application.routes.draw do ###################################################### match 'test/:controller(/:action(/:id))' , :controller => /.*test.*/ - + # -- just remember to delete public/index.html. # You can have the root of your site routed by hooking up '' - root :to => 'home#index' + root :to => 'home#index', :constraints => EnvironmentDomainConstraint.new - # FIXME adapt the rest of the routes below -end -__END__ - map.connect '', :controller => "home", :conditions => { :if => lambda { |env| !Domain.hosting_profile_at(env[:host]) } } - map.home 'site/:action', :controller => 'home' + match 'site(/:action)', :controller => 'home' - map.connect 'images/*stuff', :controller => 'not_found', :action => 'nothing' - map.connect 'stylesheets/*stuff', :controller => 'not_found', :action => 'nothing' - map.connect 'designs/*stuff', :controller => 'not_found', :action => 'nothing' - map.connect 'articles/*stuff', :controller => 'not_found', :action => 'nothing' - map.connect 'javascripts/*stuff', :controller => 'not_found', :action => 'nothing' - map.connect 'thumbnails/*stuff', :controller => 'not_found', :action => 'nothing' - map.connect 'user_themes/*stuff', :controller => 'not_found', :action => 'nothing' + match 'images/*stuff' => 'not_found#nothing' + match 'stylesheets/*stuff' => 'not_found#nothing' + match 'designs/*stuff' => 'not_found#nothing' + match 'articles/*stuff' => 'not_found#nothing' + match 'javascripts/*stuff' => 'not_found#nothing' + match 'thumbnails/*stuff' => 'not_found#nothing' + match 'user_themes/*stuff' => 'not_found#nothing' # online documentation - map.doc 'doc', :controller => 'doc', :action => 'index' - map.doc_section 'doc/:section', :controller => 'doc', :action => 'section' - map.doc_topic 'doc/:section/:topic', :controller => 'doc', :action => 'topic' - + match 'doc' => 'doc#index', :as => :doc + match 'doc/:section' => 'doc#section', :as => :doc_section + match 'doc/:section/:topic' => 'doc#topic', :as => :doc_topic + # user account controller - map.connect 'account/new_password/:code', :controller => 'account', :action => 'new_password' - map.connect 'account/:action', :controller => 'account' + match 'account/new_password/:code' => 'account#new_password', :controller => 'account', :action => 'new_password' + match 'account/:action', :controller => 'account' # enterprise registration - map.connect 'enterprise_registration/:action', :controller => 'enterprise_registration' + match 'enterprise_registration/:action', :controller => 'enterprise_registration' # tags - map.tag 'tag', :controller => 'search', :action => 'tags' - map.tag 'tag/:tag', :controller => 'search', :action => 'tag', :tag => /.*/ - + match 'tag', :controller => 'search', :action => 'tags' + match 'tag/:tag', :controller => 'search', :action => 'tag', :tag => /.*/ + # categories index - map.category 'cat/*category_path', :controller => 'search', :action => 'category_index' - map.assets 'assets/:asset/*category_path', :controller => 'search', :action => 'assets' + match 'cat/*category_path' => 'search#category_index', :as => :category + match 'assets/:asset(/*category_path)' => 'search#assets', :as => :assets # search - map.connect 'search/:action/*category_path', :controller => 'search' - + match 'search/:action(/*category_path)', :controller => 'search' + +end # FIXME remove this line and the following and finish rewriting the routes +__END__ # events map.events 'profile/:profile/events_by_day', :controller => 'events', :action => 'events_by_day', :profile => /#{Noosfero.identifier_format}/ map.events 'profile/:profile/events/:year/:month/:day', :controller => 'events', :action => 'events', :year => /\d*/, :month => /\d*/, :day => /\d*/, :profile => /#{Noosfero.identifier_format}/ diff --git a/lib/environment_domain_constraint.rb b/lib/environment_domain_constraint.rb new file mode 100644 index 0000000..214083e --- /dev/null +++ b/lib/environment_domain_constraint.rb @@ -0,0 +1,5 @@ +class EnvironmentDomainConstraint + def matches?(request) + !Domain.hosting_profile_at(request.host) + end +end -- libgit2 0.21.2