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