Commit 976e1399fad09f4194e3a952d13deffb62038bc8
1 parent
639cfbc2
Exists in
master
and in
29 other branches
environment.rb and application.rb loading looks good
Showing
4 changed files
with
66 additions
and
76 deletions
Show diff stats
MIGRATION_ISSUES
... | ... | @@ -8,4 +8,10 @@ |
8 | 8 | |
9 | 9 | * initializers session_store.rb inflections.rb... don't exist |
10 | 10 | |
11 | -* rails gems version have to be forced on Gemfile or it will use incompatible pre3vious versions (3.1.3) | |
12 | 11 | \ No newline at end of file |
12 | +* rails gems version have to be forced on Gemfile or it will use incompatible pre3vious versions (3.1.3) | |
13 | + | |
14 | +* Sweepers are now natively supported on Rails 3. Would be nice to refactor it | |
15 | + | |
16 | +* On Rails 3 it is no more possible to add allowed tags to avoid scape. The html_safe initializer is an option. | |
17 | + | |
18 | +* controller_paths are no more supported on Rails 3 | |
13 | 19 | \ No newline at end of file | ... | ... |
config/application.rb
... | ... | @@ -11,19 +11,47 @@ end |
11 | 11 | |
12 | 12 | module Rails3 |
13 | 13 | class Application < Rails::Application |
14 | + def noosfero_session_secret | |
15 | + require 'fileutils' | |
16 | + target_dir = File.join(File.dirname(__FILE__), '/../tmp') | |
17 | + FileUtils.mkdir_p(target_dir) | |
18 | + file = File.join(target_dir, 'session.secret') | |
19 | + if !File.exists?(file) | |
20 | + secret = (1..128).map { %w[0 1 2 3 4 5 6 7 8 9 a b c d e f][rand(16)] }.join('') | |
21 | + File.open(file, 'w') do |f| | |
22 | + f.puts secret | |
23 | + end | |
24 | + end | |
25 | + File.read(file).strip | |
26 | + end | |
27 | + | |
14 | 28 | # Settings in config/environments/* take precedence over those specified here. |
15 | 29 | # Application configuration should go into files in config/initializers |
16 | 30 | # -- all .rb files in that directory are automatically loaded. |
17 | 31 | |
18 | 32 | # Custom directories with classes and modules you want to be autoloadable. |
19 | - # config.autoload_paths += %W(#{config.root}/extras) | |
33 | + config.autoload_paths += %W( #{Rails.root}/app/sweepers ) | |
20 | 34 | |
21 | 35 | # Only load the plugins named here, in the order given (default is alphabetical). |
22 | 36 | # :all can be used as a placeholder for all plugins not explicitly named. |
23 | 37 | # config.plugins = [ :exception_notification, :ssl_requirement, :all ] |
24 | 38 | |
25 | 39 | # Activate observers that should always be running. |
26 | - # config.active_record.observers = :cacher, :garbage_collector, :forum_observer | |
40 | + # Sweepers are observers | |
41 | + # don't load the sweepers while loading the database | |
42 | + ignore_rake_commands = %w[ | |
43 | + db:schema:load | |
44 | + gems:install | |
45 | + clobber | |
46 | + noosfero:translations:compile | |
47 | + makemo | |
48 | + ] | |
49 | + if $PROGRAM_NAME =~ /rake$/ && (ignore_rake_commands.include?(ARGV.first)) | |
50 | + $NOOSFERO_LOAD_PLUGINS = false | |
51 | + else | |
52 | + $NOOSFERO_LOAD_PLUGINS = true | |
53 | + config.active_record.observers = :article_sweeper, :role_assignment_sweeper, :friendship_sweeper, :category_sweeper, :block_sweeper | |
54 | + end | |
27 | 55 | |
28 | 56 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. |
29 | 57 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. |
... | ... | @@ -31,7 +59,7 @@ module Rails3 |
31 | 59 | |
32 | 60 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. |
33 | 61 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] |
34 | - # config.i18n.default_locale = :de | |
62 | + config.i18n.default_locale = nil | |
35 | 63 | |
36 | 64 | # Configure the default encoding used in templates for Ruby 1.9. |
37 | 65 | config.encoding = "utf-8" |
... | ... | @@ -58,5 +86,14 @@ module Rails3 |
58 | 86 | |
59 | 87 | # Version of your assets, change this if you want to expire all your assets |
60 | 88 | config.assets.version = '1.0' |
89 | + | |
90 | + # Your secret key for verifying cookie session data integrity. | |
91 | + # If you change this key, all old sessions will become invalid! | |
92 | + # Make sure the secret is at least 30 characters and all random, | |
93 | + # no regular words or you'll be exposed to dictionary attacks. | |
94 | + config.action_dispatch.session = { | |
95 | + :key => '_noosfero_session', | |
96 | + :secret => noosfero_session_secret() | |
97 | + } | |
61 | 98 | end |
62 | 99 | end | ... | ... |
config/environment.rb
... | ... | @@ -27,74 +27,14 @@ def noosfero_session_secret |
27 | 27 | File.read(file).strip |
28 | 28 | end |
29 | 29 | |
30 | -Rails::Initializer.run do |config| | |
31 | - # Settings in config/environments/* take precedence those specified here | |
32 | - | |
33 | - # Skip frameworks you're not going to use (only works if using vendor/rails) | |
34 | - # config.frameworks -= [ :action_web_service, :action_mailer ] | |
35 | - | |
36 | - # Add additional load paths for your own custom dirs | |
37 | - # config.load_paths += %W( #{Rails.root}/extras ) | |
38 | - config.load_paths += %W( #{Rails.root}/app/sweepers ) | |
39 | - | |
40 | - # Force all environments to use the same logger level | |
41 | - # (by default production uses :info, the others :debug) | |
42 | - # config.log_level = :debug | |
43 | - | |
44 | - # Use the database for sessions instead of the file system | |
45 | - # (create the session table with 'rake db:sessions:create') | |
46 | - # config.action_controller.session_store = :active_record_store | |
47 | - | |
48 | - # Use SQL instead of Active Record's schema dumper when creating the test database. | |
49 | - # This is necessary if your schema can't be completely dumped by the schema dumper, | |
50 | - # like if you have constraints or database-specific column types | |
51 | - # config.active_record.schema_format = :sql | |
52 | - | |
53 | - # Activate observers that should always be running | |
54 | - # config.active_record.observers = :cacher, :garbage_collector | |
55 | - | |
56 | - # don't load the sweepers while loading the database | |
57 | - ignore_rake_commands = %w[ | |
58 | - db:schema:load | |
59 | - gems:install | |
60 | - clobber | |
61 | - noosfero:translations:compile | |
62 | - makemo | |
63 | - ] | |
64 | - if $PROGRAM_NAME =~ /rake$/ && (ignore_rake_commands.include?(ARGV.first)) | |
65 | - $NOOSFERO_LOAD_PLUGINS = false | |
66 | - else | |
67 | - $NOOSFERO_LOAD_PLUGINS = true | |
68 | - config.active_record.observers = :article_sweeper, :role_assignment_sweeper, :friendship_sweeper, :category_sweeper, :block_sweeper | |
69 | - end | |
70 | - # Make Active Record use UTC-base instead of local time | |
71 | - # config.active_record.default_timezone = :utc | |
72 | - | |
73 | - # Your secret key for verifying cookie session data integrity. | |
74 | - # If you change this key, all old sessions will become invalid! | |
75 | - # Make sure the secret is at least 30 characters and all random, | |
76 | - # no regular words or you'll be exposed to dictionary attacks. | |
77 | - config.action_controller.session = { | |
78 | - :session_key => '_noosfero_session', | |
79 | - :secret => noosfero_session_secret(), | |
80 | - } | |
81 | - | |
82 | - # Adds custom attributes to the Set of allowed html attributes for the #sanitize helper | |
83 | - config.action_view.sanitized_allowed_attributes = 'align', 'border', 'alt', 'vspace', 'hspace', 'width', 'heigth', 'value', 'type', 'data', 'style', 'target', 'codebase', 'archive', 'classid', 'code', 'flashvars', 'scrolling', 'frameborder' | |
84 | - | |
85 | - # Adds custom tags to the Set of allowed html tags for the #sanitize helper | |
86 | - config.action_view.sanitized_allowed_tags = 'object', 'embed', 'param', 'table', 'tr', 'th', 'td', 'applet', 'comment', 'iframe' | |
87 | - | |
88 | - # See Rails::Configuration for more options | |
89 | - | |
90 | - extra_controller_dirs.each do |item| | |
91 | - $LOAD_PATH << item | |
92 | - config.controller_paths << item | |
93 | - end | |
94 | -end | |
95 | -extra_controller_dirs.each do |item| | |
96 | - (ActiveSupport.const_defined?('Dependencies') ? ActiveSupport::Dependencies : ::Dependencies).load_paths << item | |
97 | -end | |
30 | +#FIXME controller_paths are no more supported on Rails 3 | |
31 | +#extra_controller_dirs.each do |item| | |
32 | +# $LOAD_PATH << item | |
33 | +# config.controller_paths << item | |
34 | +#end | |
35 | +#extra_controller_dirs.each do |item| | |
36 | +# (ActiveSupport.const_defined?('Dependencies') ? ActiveSupport::Dependencies : ::Dependencies).load_paths << item | |
37 | +#end | |
98 | 38 | |
99 | 39 | # Add new inflection rules using the following format |
100 | 40 | # (all these examples are active by default): |
... | ... | @@ -109,10 +49,8 @@ end |
109 | 49 | |
110 | 50 | ActiveRecord::Base.store_full_sti_class = true |
111 | 51 | |
112 | -# if you want to override this, do it in config/local.rb ! | |
113 | -Noosfero.default_locale = nil | |
114 | - | |
115 | -Tag.hierarchical = true | |
52 | +#FIXME: Probably act_as_taggable_on is not being loaded or this should be on another place | |
53 | +#Tag.hierarchical = true | |
116 | 54 | |
117 | 55 | # several local libraries |
118 | 56 | require 'noosfero' | ... | ... |
... | ... | @@ -0,0 +1,9 @@ |
1 | +#From: https://github.com/coletivoEITA/noosfero-ecosol/blob/57908cde4fe65dfe22298a8a7f6db5dba1e7cc75/config/initializers/html_safe.rb | |
2 | + | |
3 | +# Disable Rails html autoescaping. This is due to noosfero using too much helpers/models to output html. | |
4 | +# It it would change too much code and make it hard to maintain. | |
5 | +class Object | |
6 | + def html_safe? | |
7 | + true | |
8 | + end | |
9 | +end | |
0 | 10 | \ No newline at end of file | ... | ... |