Commit 8ea55342bb4173dea04678e3c3f8aad8877ddf0f
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branch 'master' into AI3279-new_block_store
Showing
12 changed files
with
48 additions
and
27 deletions
Show diff stats
app/helpers/dates_helper.rb
... | ... | @@ -2,13 +2,15 @@ require 'noosfero/i18n' |
2 | 2 | |
3 | 3 | module DatesHelper |
4 | 4 | |
5 | - MONTHS = I18n.t('date.month_names') | |
5 | + def months | |
6 | + I18n.t('date.month_names') | |
7 | + end | |
6 | 8 | |
7 | 9 | def month_name(n, abbreviated = false) |
8 | 10 | if abbreviated |
9 | 11 | I18n.t('date.abbr_month_names')[n] |
10 | 12 | else |
11 | - MONTHS[n] | |
13 | + months[n] | |
12 | 14 | end |
13 | 15 | end |
14 | 16 | |
... | ... | @@ -37,7 +39,7 @@ module DatesHelper |
37 | 39 | end |
38 | 40 | end |
39 | 41 | |
40 | - # formats a datetime for displaying. | |
42 | + # formats a datetime for displaying. | |
41 | 43 | def show_time(time) |
42 | 44 | if time |
43 | 45 | _('%{day} %{month} %{year}, %{hour}:%{minutes}') % { :year => time.year, :month => month_name(time.month), :day => time.day, :hour => time.hour, :minutes => time.strftime("%M") } |
... | ... | @@ -138,7 +140,7 @@ module DatesHelper |
138 | 140 | else |
139 | 141 | order = [:day, :month, :year] |
140 | 142 | end |
141 | - date_select(object, method, html_options.merge(options.merge(:include_blank => true, :order => order, :use_month_names => MONTHS))) | |
143 | + date_select(object, method, html_options.merge(options.merge(:include_blank => true, :order => order, :use_month_names => months))) | |
142 | 144 | end |
143 | 145 | |
144 | 146 | end | ... | ... |
app/models/event.rb
... | ... | @@ -145,11 +145,9 @@ class Event < Article |
145 | 145 | ((self.end_date || self.start_date) - self.start_date).to_i |
146 | 146 | end |
147 | 147 | |
148 | + alias_method :article_lead, :lead | |
148 | 149 | def lead |
149 | - content_tag('div', | |
150 | - show_period(start_date, end_date), | |
151 | - :class => 'event-dates' | |
152 | - ) + super | |
150 | + self.class.action_view.render 'content_viewer/event_lead', event: self | |
153 | 151 | end |
154 | 152 | |
155 | 153 | def event? | ... | ... |
lib/noosfero/core_ext/active_record.rb
... | ... | @@ -6,6 +6,22 @@ class ActiveRecord::Base |
6 | 6 | ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' |
7 | 7 | end |
8 | 8 | |
9 | + # an ActionView instance for rendering views on models | |
10 | + def self.action_view | |
11 | + @action_view ||= begin | |
12 | + view_paths = ActionController::Base.view_paths | |
13 | + action_view = ActionView::Base.new view_paths | |
14 | + # for using Noosfero helpers inside render calls | |
15 | + action_view.extend ApplicationHelper | |
16 | + action_view | |
17 | + end | |
18 | + end | |
19 | + | |
20 | + # default value needed for the above ActionView | |
21 | + def to_partial_path | |
22 | + self.class.name.underscore | |
23 | + end | |
24 | + | |
9 | 25 | alias :meta_cache_key :cache_key |
10 | 26 | def cache_key |
11 | 27 | key = [Noosfero::VERSION, meta_cache_key] | ... | ... |
lib/tasks/doc.rake
... | ... | @@ -26,7 +26,8 @@ namespace :noosfero do |
26 | 26 | begin |
27 | 27 | require 'redcloth' |
28 | 28 | File.open(output ,'w') do |output_file| |
29 | - output_file.write(RedCloth.new(File.read(input)).to_html) | |
29 | + text = File.read(input, encoding: Encoding::UTF_8) | |
30 | + output_file.write(RedCloth.new(text).to_html) | |
30 | 31 | puts "#{input} -> #{output}" |
31 | 32 | end |
32 | 33 | rescue Exception => e | ... | ... |
plugins/container_block/public/container_block.js
1 | 1 | function enableMoveContainerChildren(container, box) { |
2 | 2 | var div = jQuery('#box-'+box+' > .block-outer > .block'); |
3 | 3 | if(!div.is('.ui-resizable')) { |
4 | + div.removeClass('ui-draggable'); | |
4 | 5 | div.resizable({ |
5 | 6 | handles: 'e, w', |
6 | 7 | containment: '#block-'+container+' .block-inner-2', |
... | ... | @@ -14,6 +15,7 @@ function enableMoveContainerChildren(container, box) { |
14 | 15 | function disableMoveContainerChildren(container, box) { |
15 | 16 | var div = jQuery('#box-'+box+' > .block-outer > .block'); |
16 | 17 | if(div.is('.ui-resizable')) { |
18 | + div.addClass('ui-draggable'); | |
17 | 19 | div.resizable('destroy'); |
18 | 20 | } |
19 | 21 | } | ... | ... |
plugins/remote_user/lib/remote_user_plugin.rb
... | ... | @@ -16,10 +16,7 @@ class RemoteUserPlugin < Noosfero::Plugin |
16 | 16 | user_data = request.env['HTTP_REMOTE_USER_DATA'] |
17 | 17 | |
18 | 18 | if remote_user.blank? |
19 | - if logged_in? | |
20 | - self.current_user.forget_me | |
21 | - reset_session | |
22 | - end | |
19 | + self.current_user = nil | |
23 | 20 | else |
24 | 21 | if user_data.blank? |
25 | 22 | remote_user_email = remote_user + '@remote.user' | ... | ... |
script/noosfero-plugins
... | ... | @@ -8,7 +8,7 @@ if [ -e /etc/default/noosfero ]; then |
8 | 8 | . /etc/default/noosfero |
9 | 9 | fi |
10 | 10 | |
11 | -if [ -z "$NOOSFERO_DIR"]; then | |
11 | +if [ -z "$NOOSFERO_DIR" ]; then | |
12 | 12 | this_script=$(readlink -f $0) |
13 | 13 | NOOSFERO_DIR=$(dirname $this_script | xargs dirname) |
14 | 14 | fi |
... | ... | @@ -82,7 +82,6 @@ _enable(){ |
82 | 82 | |
83 | 83 | if [ -d "$available_plugins_dir/$plugin" ]; then |
84 | 84 | source="$available_plugins_dir/$plugin" |
85 | - linksource="../../plugins/$plugin" | |
86 | 85 | else |
87 | 86 | if [ ! -d "$plugin" ]; then |
88 | 87 | echo "E: $plugin not found (needs to be an existing directory)" |
... | ... | @@ -91,7 +90,6 @@ _enable(){ |
91 | 90 | |
92 | 91 | # out-of-tree plugins |
93 | 92 | source="$plugin" |
94 | - linksource="$source" | |
95 | 93 | plugin=$(basename "$plugin") |
96 | 94 | fi |
97 | 95 | |
... | ... | @@ -114,7 +112,7 @@ _enable(){ |
114 | 112 | dependencies_file="$source/dependencies.rb" |
115 | 113 | if [ -e $source/Gemfile ]; then |
116 | 114 | gemfile=$(mktemp --tmpdir=.) |
117 | - cat Gemfile $source/Gemfile > $gemfile | |
115 | + cat $NOOSFERO_DIR/Gemfile $source/Gemfile > $gemfile | |
118 | 116 | if ! RUBYOPT='' BUNDLE_GEMFILE="$gemfile" bundle --local --quiet; then |
119 | 117 | dependencies_ok=false |
120 | 118 | fi |
... | ... | @@ -125,7 +123,7 @@ _enable(){ |
125 | 123 | fi |
126 | 124 | fi |
127 | 125 | if [ "$installation_ok" = true ] && [ "$dependencies_ok" = true ]; then |
128 | - ln -s "$linksource" "$target" | |
126 | + ln -s "$source" "$target" | |
129 | 127 | plugins_public_dir="$NOOSFERO_DIR/public/plugins" |
130 | 128 | plugins_features_dir="$NOOSFERO_DIR/features/plugins" |
131 | 129 | test -d "$target/public" && ln -s "$target/public" "$plugins_public_dir/$plugin" | ... | ... |
script/production
... | ... | @@ -71,11 +71,11 @@ stop_via_pid_file() { |
71 | 71 | |
72 | 72 | environments_loop() { |
73 | 73 | action="$1" |
74 | - environments=$(find ./config/environments -name *_$RAILS_ENV.rb) | |
74 | + environments=$(find ./config/environments -name "*_${RAILS_ENV}.rb") | |
75 | 75 | if [ "$environments" ]; then |
76 | 76 | for environment in $environments; do |
77 | 77 | env=$(basename $environment | cut -d. -f1) |
78 | - RAILS_ENV=$env ./script/delayed_job -i $env "$action" | |
78 | + RAILS_ENV=$env bundle exec ./script/delayed_job -i $env "$action" | |
79 | 79 | RAILS_ENV=$env bundle exec ./script/feed-updater "$action" -i $env |
80 | 80 | done |
81 | 81 | else | ... | ... |
script/sample-data
test/unit/application_helper_test.rb
... | ... | @@ -571,7 +571,7 @@ class ApplicationHelperTest < ActionView::TestCase |
571 | 571 | env = Environment.default |
572 | 572 | env.stubs(:enabled?).with(:show_balloon_with_profile_links_when_clicked).returns(true) |
573 | 573 | stubs(:environment).returns(env) |
574 | - person = Person.new | |
574 | + person = Person.new identifier: 'person' | |
575 | 575 | person.stubs(:url).returns('url for person') |
576 | 576 | person.stubs(:public_profile_url).returns('url for person') |
577 | 577 | links = links_for_balloon(person) |
... | ... | @@ -582,7 +582,7 @@ class ApplicationHelperTest < ActionView::TestCase |
582 | 582 | env = Environment.default |
583 | 583 | env.stubs(:enabled?).with(:show_balloon_with_profile_links_when_clicked).returns(true) |
584 | 584 | stubs(:environment).returns(env) |
585 | - community = Community.new | |
585 | + community = Community.new identifier: 'comm' | |
586 | 586 | community.stubs(:url).returns('url for community') |
587 | 587 | community.stubs(:public_profile_url).returns('url for community') |
588 | 588 | links = links_for_balloon(community) |
... | ... | @@ -593,7 +593,7 @@ class ApplicationHelperTest < ActionView::TestCase |
593 | 593 | env = Environment.default |
594 | 594 | env.stubs(:enabled?).with(:show_balloon_with_profile_links_when_clicked).returns(true) |
595 | 595 | stubs(:environment).returns(env) |
596 | - enterprise = Enterprise.new | |
596 | + enterprise = Enterprise.new identifier: 'coop' | |
597 | 597 | enterprise.stubs(:url).returns('url for enterprise') |
598 | 598 | enterprise.stubs(:public_profile_url).returns('url for enterprise') |
599 | 599 | stubs(:catalog_path) | ... | ... |
test/unit/dates_helper_test.rb
... | ... | @@ -99,20 +99,20 @@ class DatesHelperTest < ActiveSupport::TestCase |
99 | 99 | |
100 | 100 | should 'provide an intertionalized date selector pass month names' do |
101 | 101 | expects(:language).returns('en') |
102 | - expects(:date_select).with(:object, :method, { :include_blank => true, :order => [:month, :day, :year], :use_month_names => MONTHS }).returns("KKKKKKKK") | |
102 | + expects(:date_select).with(:object, :method, { :include_blank => true, :order => [:month, :day, :year], :use_month_names => months }).returns("KKKKKKKK") | |
103 | 103 | assert_equal 'KKKKKKKK', pick_date(:object, :method) |
104 | 104 | end |
105 | 105 | |
106 | 106 | should 'order date in english like month day year' do |
107 | 107 | expects(:language).returns('en') |
108 | - expects(:date_select).with(:object, :method, { :include_blank => true, :order => [:month, :day, :year], :use_month_names => MONTHS }).returns("KKKKKKKK") | |
108 | + expects(:date_select).with(:object, :method, { :include_blank => true, :order => [:month, :day, :year], :use_month_names => months }).returns("KKKKKKKK") | |
109 | 109 | |
110 | 110 | assert_equal 'KKKKKKKK', pick_date(:object, :method) |
111 | 111 | end |
112 | 112 | |
113 | 113 | should 'order date in other languages like day month year' do |
114 | 114 | expects(:language).returns('pt_BR') |
115 | - expects(:date_select).with(:object, :method, { :include_blank => true, :order => [:day, :month, :year], :use_month_names => MONTHS }).returns("KKKKKKKK") | |
115 | + expects(:date_select).with(:object, :method, { :include_blank => true, :order => [:day, :month, :year], :use_month_names => months }).returns("KKKKKKKK") | |
116 | 116 | |
117 | 117 | assert_equal 'KKKKKKKK', pick_date(:object, :method) |
118 | 118 | end | ... | ... |