diff --git a/Gemfile b/Gemfile index 017dbd5..0fec91c 100644 --- a/Gemfile +++ b/Gemfile @@ -35,7 +35,7 @@ gem 'lingua_franca', git: 'https://github.com/lingua-franca/lingua_franca.git', gem 'marmara', git: 'https://github.com/lingua-franca/marmara.git', branch: 'master' # Bike!Bike! specific stuff -gem 'paypal-express', git: 'https://github.com/ianfleeton/paypal-express' +gem 'ianfleeton-paypal-express', require: 'paypal/express' gem 'geocoder' gem 'sitemap_generator' gem 'sass-json-vars' @@ -83,7 +83,10 @@ group :production, :preview do end group :production, :preview do - gem 'unicorn', require: false + platforms :ruby do + gem 'unicorn', require: false + end + gem 'daemon-spawn' gem 'daemons' end diff --git a/app/assets/javascripts/editor.js b/app/assets/javascripts/editor.js index 72cbdd4..5ba62e5 100644 --- a/app/assets/javascripts/editor.js +++ b/app/assets/javascripts/editor.js @@ -12,6 +12,7 @@ modules: { toolbar: [ [{ 'header': [1, 2, false] }], + ['link', 'image'], ['bold', 'italic', 'underline', 'strike'], [{ 'script': 'sub'}, { 'script': 'super' }], [{ 'list': 'ordered'}, { 'list': 'bullet' }, 'blockquote'] diff --git a/app/assets/stylesheets/_application.scss b/app/assets/stylesheets/_application.scss index d38248c..5ff7ea0 100644 --- a/app/assets/stylesheets/_application.scss +++ b/app/assets/stylesheets/_application.scss @@ -1205,7 +1205,7 @@ fieldset { } } - ul { + .locale-select, .text-editors { list-style: none; padding: 0; margin: 0; @@ -1253,7 +1253,7 @@ fieldset { position: relative; background-color: $white; - li { + li[data-locale] { display: none; &.selected { diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0831da0..29ae927 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -8,6 +8,10 @@ class ApplicationController < BaseController @@test_host @@test_location + def default_url_options + { host: "#{request.protocol}#{request.host_with_port}" } + end + def capture_page_info # capture request info in case an error occurs if request.method == "GET" && (params[:controller] != 'application' || params[:action] != 'contact') @@ -103,18 +107,28 @@ class ApplicationController < BaseController # log the error logger.info "A JavaScript error has occurred on #{params[:location]}:#{params[:lineNumber]}: #{params[:message]}" - UserMailer.send_mail(:error_report) do - [ - "A JavaScript error has occurred", - report, - params[:message], - nil, - request, - params, - current_user, - Time.now.strftime("%d/%m/%Y %H:%M") - ] - end if Rails.env.preview? || Rails.env.production? + if Rails.env.preview? || Rails.env.production? + requestHash = { + 'remote_ip' => arg.remote_ip, + 'uuid' => arg.uuid, + 'original_url' => arg.original_url, + 'env' => Hash.new + } + request.env.each do | key, value | + requestHash['env'][key.to_s] = value.to_s + end + + UserMailer.error_report( + "A JavaScript error has occurred", + report, + params[:message], + nil, + requestHash, + params, + current_user, + Time.now.strftime("%d/%m/%Y %H:%M") + ).deliver_later! + end rescue Exception => exception2 logger.info exception2.to_s logger.info exception2.backtrace.join("\n") @@ -168,19 +182,28 @@ class ApplicationController < BaseController logger.info exception.backtrace.join("\n") # send and email if this is production - suppress(Exception) do - UserMailer.send_mail(:error_report) do - [ - "An error has occurred in #{Rails.env}", - nil, - exception.to_s, - exception.backtrace.join("\n"), - request, - params, - current_user, - Time.now.strftime("%d/%m/%Y %H:%M") - ] - end if Rails.env.preview? || Rails.env.production? + if Rails.env.preview? || Rails.env.production? + suppress(Exception) do + requestHash = { + 'remote_ip' => arg.remote_ip, + 'uuid' => arg.uuid, + 'original_url' => arg.original_url, + 'env' => Hash.new + } + request.env.each do | key, value | + requestHash['env'][key.to_s] = value.to_s + end + UserMailer.error_report( + "An error has occurred in #{Rails.env}", + nil, + exception.to_s, + exception.backtrace.join("\n"), + requestHash, + params, + current_user, + Time.now.strftime("%d/%m/%Y %H:%M") + ).deliver_later! + end end # raise the error if we are in development so that we can debug it @@ -206,30 +229,26 @@ class ApplicationController < BaseController @conference.organizations.each do |org| org.users.each do |user| - email_list << user.named_email + # email_list << user.named_email end end end - UserMailer.send_mail(:contact) do - [ + UserMailer.contact( current_user || params[:email], params[:subject], params[:message], email_list - ] - end + ).deliver_later request_info = session['request_info'] || { 'request' => request, 'params' => params } - UserMailer.send_mail(:contact_details) do - [ + UserMailer.contact_details( current_user || params[:email], params[:subject], params[:message], request_info['request'], request_info['params'] - ] - end + ).deliver_later redirect_to contact_sent_path end @@ -303,8 +322,8 @@ class ApplicationController < BaseController if object.respond_to?(:get_translators) object.get_translators(data, locale).each do |id, user| if user.id != current_user.id && user.id != translator_id - UserMailer.send_mail mailer, user.locale do - { :args => [object, data, locale, user, translator] } + LinguaFranca.with_locale user.locale do + UserMailer.send(mailer, object.id, data, locale, user.id, translator.id).deliver_later end end end @@ -317,8 +336,8 @@ class ApplicationController < BaseController if object.respond_to?(:get_translators) object.get_translators(data).each do |id, user| if user.id != current_user.id - UserMailer.send_mail mailer, user.locale do - { :args => [object, data, user, current_user] } + LinguaFranca.with_locale user.locale do + UserMailer.send(mailer, object.id, data, user.id, current_user.id) end end end @@ -329,23 +348,32 @@ class ApplicationController < BaseController # log it logger.info "Missing translation found for: #{key}" - # send and email if this is production - begin - UserMailer.send_mail(:error_report) do - [ - "A missing translation found in #{Rails.env}", - "
A translation for #{key}
in #{locale.to_s}
was found. The text that was rendered to the user was:
#{str || 'nil'}", - exception.to_s, - nil, - request, - params, - current_user, - Time.now.strftime("%d/%m/%Y %H:%M") - ] - end if Rails.env.preview? || Rails.env.production? - rescue Exception => exception2 - logger.info exception2.to_s - logger.info exception2.backtrace.join("\n") + # send an email if this is production + if Rails.env.preview? || Rails.env.production? + begin + requestHash = { + 'remote_ip' => arg.remote_ip, + 'uuid' => arg.uuid, + 'original_url' => arg.original_url, + 'env' => Hash.new + } + request.env.each do | key, value | + requestHash['env'][key.to_s] = value.to_s + end + UserMailer.error_report( + "A missing translation found in #{Rails.env}", + "
A translation for #{key}
in #{locale.to_s}
was found. The text that was rendered to the user was:
#{str || 'nil'}", + exception.to_s, + nil, + requestHash, + params, + current_user.id, + Time.now.strftime("%d/%m/%Y %H:%M") + ).deliver_later! + rescue Exception => exception2 + logger.info exception2.to_s + logger.info exception2.backtrace.join("\n") + end end end @@ -608,6 +636,6 @@ class ApplicationController < BaseController # send the confirmation email and make sure it get sent as quickly as possible def send_confirmation(confirmation) - UserMailer.send_mail(:email_confirmation) { confirmation } + UserMailer.email_confirmation(confirmation.id).deliver_now end end diff --git a/app/controllers/conference_administration_controller.rb b/app/controllers/conference_administration_controller.rb index 2fef5c8..432d21a 100644 --- a/app/controllers/conference_administration_controller.rb +++ b/app/controllers/conference_administration_controller.rb @@ -1015,15 +1015,13 @@ class ConferenceAdministrationController < ApplicationController @register_template = :administration if params[:button] == 'send' view_context.broadcast_to(@send_to).each do |user| - UserMailer.send_mail :broadcast do - [ + UserMailer.broadcast( "#{request.protocol}#{request.host_with_port}", @subject, @body, - user, - @this_conference - ] - end + user.id, + @this_conference.id + ).deliver_later end redirect_to administration_step_path(@this_conference.slug, :broadcast_sent) return true @@ -1032,15 +1030,13 @@ class ConferenceAdministrationController < ApplicationController @broadcast_step = :preview elsif params[:button] == 'test' @broadcast_step = :test - UserMailer.send_mail :broadcast do - [ + UserMailer.broadcast( "#{request.protocol}#{request.host_with_port}", @subject, @body, - current_user, - @this_conference - ] - end + current_user.id, + @this_conference.id + ).deliver_later @send_to_count = view_context.broadcast_to(@send_to).size end return false diff --git a/app/controllers/workshops_controller.rb b/app/controllers/workshops_controller.rb index ea7a64b..e835e70 100644 --- a/app/controllers/workshops_controller.rb +++ b/app/controllers/workshops_controller.rb @@ -217,11 +217,7 @@ class WorkshopsController < ApplicationController # create the request by making the user a facilitator but making their role 'requested' WorkshopFacilitator.create(user_id: current_user.id, workshop_id: workshop.id, role: :requested) - UserMailer.send_mail :workshop_facilitator_request do - { - :args => [ workshop, current_user, params[:message] ] - } - end + UserMailer.workshop_facilitator_request(workshop.id, current_user.id, params[:message]).deliver_later redirect_to sent_facilitate_workshop_url(@this_conference.slug, workshop.id) end @@ -254,18 +250,18 @@ class WorkshopsController < ApplicationController workshop.id, user_id) f.role = :collaborator f.save - UserMailer.send_mail :workshop_facilitator_request_approved, user.locale do - [ workshop, user ] + LinguaFranca.with_locale(user.locale) do + UserMailer.workshop_facilitator_request_approved(workshop.id, user.id).deliver_later end - return redirect_to view_workshop_url(@this_conference.slug, workshop.id) + return redirect_to view_workshop_url(@this_conference.slug, workshop.id) end when :deny if workshop.active_facilitator?(current_user) && workshop.requested_collaborator?(User.find(user_id)) WorkshopFacilitator.delete_all( :workshop_id => workshop.id, :user_id => user_id) - UserMailer.send_mail :workshop_facilitator_request_denied, user.locale do - [ workshop, user ] + LinguaFranca.with_locale user.locale do + UserMailer.workshop_facilitator_request_denied(workshop.id, user.id).deliver_later end return redirect_to view_workshop_url(@this_conference.slug, workshop.id) end @@ -312,8 +308,8 @@ class WorkshopsController < ApplicationController unless workshop.facilitator?(user) WorkshopFacilitator.create(user_id: user.id, workshop_id: workshop.id, role: :collaborator) - UserMailer.send_mail :workshop_facilitator_request_approved, user.locale do - [ workshop, user ] + LinguaFranca.with_locale user.locale do + UserMailer.workshop_facilitator_request_approved(workshop.id, user.id).deliver_later end end @@ -332,8 +328,8 @@ class WorkshopsController < ApplicationController new_comment = comment.add_comment(current_user, params[:reply]) unless comment.user.id == current_user.id - UserMailer.send_mail :workshop_comment, comment.user.locale do - [ workshop, new_comment, comment.user ] + LinguaFranca.with_locale comment.user.locale do + UserMailer.workshop_comment(workshop.id, new_comment.id, comment.user.id).deliver_later end end elsif params[:button] = 'add_comment' @@ -341,8 +337,8 @@ class WorkshopsController < ApplicationController workshop.active_facilitators.each do | u | unless u.id == current_user.id - UserMailer.send_mail :workshop_comment, u.locale do - [ workshop, new_comment, u ] + LinguaFranca.with_locale u.locale do + UserMailer.workshop_comment(workshop.id, new_comment.id, u.id).deliver_later end end end diff --git a/config/environments/production.rb b/config/environments/production.rb index c10c435..4bc609a 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -88,14 +88,14 @@ BikeBike::Application.configure do config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { - :address => 'mail.bikebike.org', - :domain => 'preview.bikebike.org', + :address => 'smtp.gmail.com', + :domain => 'bikebike.org', :port => 587, :authentication => :plain, :enable_starttls_auto => true, :openssl_verify_mode => 'none', - :user_name => 'info@preview.bikebike.org', - :password => 'test' + :user_name => '', + :password => '' } config.action_mailer.raise_delivery_errors = true config.action_mailer.perform_deliveries = true diff --git a/features/support/location_cache.yml b/features/support/location_cache.yml index 02508d1..9badcd9 100644 --- a/features/support/location_cache.yml +++ b/features/support/location_cache.yml @@ -251,6 +251,54 @@ Portland OR: !ruby/object:Geocoder::Result::Google - locality - political cache_hit: +Prince Rupert BC: !ruby/object:Geocoder::Result::Google + data: + address_components: + - long_name: Prince Rupert + short_name: Prince Rupert + types: + - locality + - political + - long_name: Skeena-Queen Charlotte + short_name: Skeena-Queen Charlotte + types: + - administrative_area_level_2 + - political + - long_name: British Columbia + short_name: BC + types: + - administrative_area_level_1 + - political + - long_name: Canada + short_name: CA + types: + - country + - political + formatted_address: Prince Rupert, BC, Canada + geometry: + bounds: + northeast: + lat: 54.338083 + lng: -130.2437961 + southwest: + lat: 54.19392 + lng: -130.3634291 + location: + lat: 54.3150367 + lng: -130.3208187 + location_type: APPROXIMATE + viewport: + northeast: + lat: 54.3343706 + lng: -130.2478032 + southwest: + lat: 54.202669 + lng: -130.3608029 + place_id: ChIJaUV_axPVclQRElbZTQ_jB3E + types: + - locality + - political + cache_hit: Regina, SK: !ruby/object:Geocoder::Result::Google data: address_components: @@ -453,51 +501,3 @@ Eldorado, MX: !ruby/object:Geocoder::Result::Google - locality - political cache_hit: -Prince Rupert BC: !ruby/object:Geocoder::Result::Google - data: - address_components: - - long_name: Prince Rupert - short_name: Prince Rupert - types: - - locality - - political - - long_name: Skeena-Queen Charlotte - short_name: Skeena-Queen Charlotte - types: - - administrative_area_level_2 - - political - - long_name: British Columbia - short_name: BC - types: - - administrative_area_level_1 - - political - - long_name: Canada - short_name: CA - types: - - country - - political - formatted_address: Prince Rupert, BC, Canada - geometry: - bounds: - northeast: - lat: 54.338083 - lng: -130.2437961 - southwest: - lat: 54.19392 - lng: -130.3634291 - location: - lat: 54.3150367 - lng: -130.3208187 - location_type: APPROXIMATE - viewport: - northeast: - lat: 54.3343706 - lng: -130.2478032 - southwest: - lat: 54.202669 - lng: -130.3608029 - place_id: ChIJaUV_axPVclQRElbZTQ_jB3E - types: - - locality - - political - cache_hit: