Browse Source

Merge branch 'development' of github.com:bikebike/BikeBike into development

development
LinguaFrancaTranslator 8 years ago
parent
commit
a776870a6f
  1. 5
      Gemfile
  2. 1
      app/assets/javascripts/editor.js
  3. 4
      app/assets/stylesheets/_application.scss
  4. 90
      app/controllers/application_controller.rb
  5. 20
      app/controllers/conference_administration_controller.rb
  6. 26
      app/controllers/workshops_controller.rb
  7. 8
      config/environments/production.rb
  8. 96
      features/support/location_cache.yml

5
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' gem 'marmara', git: 'https://github.com/lingua-franca/marmara.git', branch: 'master'
# Bike!Bike! specific stuff # Bike!Bike! specific stuff
gem 'paypal-express', git: 'https://github.com/ianfleeton/paypal-express' gem 'ianfleeton-paypal-express', require: 'paypal/express'
gem 'geocoder' gem 'geocoder'
gem 'sitemap_generator' gem 'sitemap_generator'
gem 'sass-json-vars' gem 'sass-json-vars'
@ -83,7 +83,10 @@ group :production, :preview do
end end
group :production, :preview do group :production, :preview do
platforms :ruby do
gem 'unicorn', require: false gem 'unicorn', require: false
end
gem 'daemon-spawn' gem 'daemon-spawn'
gem 'daemons' gem 'daemons'
end end

1
app/assets/javascripts/editor.js

@ -12,6 +12,7 @@
modules: { modules: {
toolbar: [ toolbar: [
[{ 'header': [1, 2, false] }], [{ 'header': [1, 2, false] }],
['link', 'image'],
['bold', 'italic', 'underline', 'strike'], ['bold', 'italic', 'underline', 'strike'],
[{ 'script': 'sub'}, { 'script': 'super' }], [{ 'script': 'sub'}, { 'script': 'super' }],
[{ 'list': 'ordered'}, { 'list': 'bullet' }, 'blockquote'] [{ 'list': 'ordered'}, { 'list': 'bullet' }, 'blockquote']

4
app/assets/stylesheets/_application.scss

@ -1205,7 +1205,7 @@ fieldset {
} }
} }
ul { .locale-select, .text-editors {
list-style: none; list-style: none;
padding: 0; padding: 0;
margin: 0; margin: 0;
@ -1253,7 +1253,7 @@ fieldset {
position: relative; position: relative;
background-color: $white; background-color: $white;
li { li[data-locale] {
display: none; display: none;
&.selected { &.selected {

90
app/controllers/application_controller.rb

@ -8,6 +8,10 @@ class ApplicationController < BaseController
@@test_host @@test_host
@@test_location @@test_location
def default_url_options
{ host: "#{request.protocol}#{request.host_with_port}" }
end
def capture_page_info def capture_page_info
# capture request info in case an error occurs # capture request info in case an error occurs
if request.method == "GET" && (params[:controller] != 'application' || params[:action] != 'contact') if request.method == "GET" && (params[:controller] != 'application' || params[:action] != 'contact')
@ -103,18 +107,28 @@ class ApplicationController < BaseController
# log the error # log the error
logger.info "A JavaScript error has occurred on #{params[:location]}:#{params[:lineNumber]}: #{params[:message]}" logger.info "A JavaScript error has occurred on #{params[:location]}:#{params[:lineNumber]}: #{params[:message]}"
UserMailer.send_mail(:error_report) do 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", "A JavaScript error has occurred",
report, report,
params[:message], params[:message],
nil, nil,
request, requestHash,
params, params,
current_user, current_user,
Time.now.strftime("%d/%m/%Y %H:%M") Time.now.strftime("%d/%m/%Y %H:%M")
] ).deliver_later!
end if Rails.env.preview? || Rails.env.production? end
rescue Exception => exception2 rescue Exception => exception2
logger.info exception2.to_s logger.info exception2.to_s
logger.info exception2.backtrace.join("\n") logger.info exception2.backtrace.join("\n")
@ -168,19 +182,28 @@ class ApplicationController < BaseController
logger.info exception.backtrace.join("\n") logger.info exception.backtrace.join("\n")
# send and email if this is production # send and email if this is production
if Rails.env.preview? || Rails.env.production?
suppress(Exception) do suppress(Exception) do
UserMailer.send_mail(:error_report) 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}", "An error has occurred in #{Rails.env}",
nil, nil,
exception.to_s, exception.to_s,
exception.backtrace.join("\n"), exception.backtrace.join("\n"),
request, requestHash,
params, params,
current_user, current_user,
Time.now.strftime("%d/%m/%Y %H:%M") Time.now.strftime("%d/%m/%Y %H:%M")
] ).deliver_later!
end if Rails.env.preview? || Rails.env.production? end
end end
# raise the error if we are in development so that we can debug it # 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| @conference.organizations.each do |org|
org.users.each do |user| org.users.each do |user|
email_list << user.named_email # email_list << user.named_email
end end
end end
end end
UserMailer.send_mail(:contact) do UserMailer.contact(
[
current_user || params[:email], current_user || params[:email],
params[:subject], params[:subject],
params[:message], params[:message],
email_list email_list
] ).deliver_later
end
request_info = session['request_info'] || { 'request' => request, 'params' => params } request_info = session['request_info'] || { 'request' => request, 'params' => params }
UserMailer.send_mail(:contact_details) do UserMailer.contact_details(
[
current_user || params[:email], current_user || params[:email],
params[:subject], params[:subject],
params[:message], params[:message],
request_info['request'], request_info['request'],
request_info['params'] request_info['params']
] ).deliver_later
end
redirect_to contact_sent_path redirect_to contact_sent_path
end end
@ -303,8 +322,8 @@ class ApplicationController < BaseController
if object.respond_to?(:get_translators) if object.respond_to?(:get_translators)
object.get_translators(data, locale).each do |id, user| object.get_translators(data, locale).each do |id, user|
if user.id != current_user.id && user.id != translator_id if user.id != current_user.id && user.id != translator_id
UserMailer.send_mail mailer, user.locale do LinguaFranca.with_locale user.locale do
{ :args => [object, data, locale, user, translator] } UserMailer.send(mailer, object.id, data, locale, user.id, translator.id).deliver_later
end end
end end
end end
@ -317,8 +336,8 @@ class ApplicationController < BaseController
if object.respond_to?(:get_translators) if object.respond_to?(:get_translators)
object.get_translators(data).each do |id, user| object.get_translators(data).each do |id, user|
if user.id != current_user.id if user.id != current_user.id
UserMailer.send_mail mailer, user.locale do LinguaFranca.with_locale user.locale do
{ :args => [object, data, user, current_user] } UserMailer.send(mailer, object.id, data, user.id, current_user.id)
end end
end end
end end
@ -329,25 +348,34 @@ class ApplicationController < BaseController
# log it # log it
logger.info "Missing translation found for: #{key}" logger.info "Missing translation found for: #{key}"
# send and email if this is production # send an email if this is production
if Rails.env.preview? || Rails.env.production?
begin begin
UserMailer.send_mail(:error_report) 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(
"A missing translation found in #{Rails.env}", "A missing translation found in #{Rails.env}",
"<p>A translation for <code>#{key}</code> in <code>#{locale.to_s}</code> was found. The text that was rendered to the user was:</p><blockquote>#{str || 'nil'}</blockquote>", "<p>A translation for <code>#{key}</code> in <code>#{locale.to_s}</code> was found. The text that was rendered to the user was:</p><blockquote>#{str || 'nil'}</blockquote>",
exception.to_s, exception.to_s,
nil, nil,
request, requestHash,
params, params,
current_user, current_user.id,
Time.now.strftime("%d/%m/%Y %H:%M") Time.now.strftime("%d/%m/%Y %H:%M")
] ).deliver_later!
end if Rails.env.preview? || Rails.env.production?
rescue Exception => exception2 rescue Exception => exception2
logger.info exception2.to_s logger.info exception2.to_s
logger.info exception2.backtrace.join("\n") logger.info exception2.backtrace.join("\n")
end end
end end
end
def set_success_message(message, is_ajax = false) def set_success_message(message, is_ajax = false)
if is_ajax if is_ajax
@ -608,6 +636,6 @@ class ApplicationController < BaseController
# send the confirmation email and make sure it get sent as quickly as possible # send the confirmation email and make sure it get sent as quickly as possible
def send_confirmation(confirmation) def send_confirmation(confirmation)
UserMailer.send_mail(:email_confirmation) { confirmation } UserMailer.email_confirmation(confirmation.id).deliver_now
end end
end end

20
app/controllers/conference_administration_controller.rb

@ -1015,15 +1015,13 @@ class ConferenceAdministrationController < ApplicationController
@register_template = :administration @register_template = :administration
if params[:button] == 'send' if params[:button] == 'send'
view_context.broadcast_to(@send_to).each do |user| view_context.broadcast_to(@send_to).each do |user|
UserMailer.send_mail :broadcast do UserMailer.broadcast(
[
"#{request.protocol}#{request.host_with_port}", "#{request.protocol}#{request.host_with_port}",
@subject, @subject,
@body, @body,
user, user.id,
@this_conference @this_conference.id
] ).deliver_later
end
end end
redirect_to administration_step_path(@this_conference.slug, :broadcast_sent) redirect_to administration_step_path(@this_conference.slug, :broadcast_sent)
return true return true
@ -1032,15 +1030,13 @@ class ConferenceAdministrationController < ApplicationController
@broadcast_step = :preview @broadcast_step = :preview
elsif params[:button] == 'test' elsif params[:button] == 'test'
@broadcast_step = :test @broadcast_step = :test
UserMailer.send_mail :broadcast do UserMailer.broadcast(
[
"#{request.protocol}#{request.host_with_port}", "#{request.protocol}#{request.host_with_port}",
@subject, @subject,
@body, @body,
current_user, current_user.id,
@this_conference @this_conference.id
] ).deliver_later
end
@send_to_count = view_context.broadcast_to(@send_to).size @send_to_count = view_context.broadcast_to(@send_to).size
end end
return false return false

26
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' # 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) WorkshopFacilitator.create(user_id: current_user.id, workshop_id: workshop.id, role: :requested)
UserMailer.send_mail :workshop_facilitator_request do UserMailer.workshop_facilitator_request(workshop.id, current_user.id, params[:message]).deliver_later
{
:args => [ workshop, current_user, params[:message] ]
}
end
redirect_to sent_facilitate_workshop_url(@this_conference.slug, workshop.id) redirect_to sent_facilitate_workshop_url(@this_conference.slug, workshop.id)
end end
@ -254,8 +250,8 @@ class WorkshopsController < ApplicationController
workshop.id, user_id) workshop.id, user_id)
f.role = :collaborator f.role = :collaborator
f.save f.save
UserMailer.send_mail :workshop_facilitator_request_approved, user.locale do LinguaFranca.with_locale(user.locale) do
[ workshop, user ] UserMailer.workshop_facilitator_request_approved(workshop.id, user.id).deliver_later
end end
return redirect_to view_workshop_url(@this_conference.slug, workshop.id) return redirect_to view_workshop_url(@this_conference.slug, workshop.id)
end end
@ -264,8 +260,8 @@ class WorkshopsController < ApplicationController
WorkshopFacilitator.delete_all( WorkshopFacilitator.delete_all(
:workshop_id => workshop.id, :workshop_id => workshop.id,
:user_id => user_id) :user_id => user_id)
UserMailer.send_mail :workshop_facilitator_request_denied, user.locale do LinguaFranca.with_locale user.locale do
[ workshop, user ] UserMailer.workshop_facilitator_request_denied(workshop.id, user.id).deliver_later
end end
return redirect_to view_workshop_url(@this_conference.slug, workshop.id) return redirect_to view_workshop_url(@this_conference.slug, workshop.id)
end end
@ -312,8 +308,8 @@ class WorkshopsController < ApplicationController
unless workshop.facilitator?(user) unless workshop.facilitator?(user)
WorkshopFacilitator.create(user_id: user.id, workshop_id: workshop.id, role: :collaborator) WorkshopFacilitator.create(user_id: user.id, workshop_id: workshop.id, role: :collaborator)
UserMailer.send_mail :workshop_facilitator_request_approved, user.locale do LinguaFranca.with_locale user.locale do
[ workshop, user ] UserMailer.workshop_facilitator_request_approved(workshop.id, user.id).deliver_later
end end
end end
@ -332,8 +328,8 @@ class WorkshopsController < ApplicationController
new_comment = comment.add_comment(current_user, params[:reply]) new_comment = comment.add_comment(current_user, params[:reply])
unless comment.user.id == current_user.id unless comment.user.id == current_user.id
UserMailer.send_mail :workshop_comment, comment.user.locale do LinguaFranca.with_locale comment.user.locale do
[ workshop, new_comment, comment.user ] UserMailer.workshop_comment(workshop.id, new_comment.id, comment.user.id).deliver_later
end end
end end
elsif params[:button] = 'add_comment' elsif params[:button] = 'add_comment'
@ -341,8 +337,8 @@ class WorkshopsController < ApplicationController
workshop.active_facilitators.each do | u | workshop.active_facilitators.each do | u |
unless u.id == current_user.id unless u.id == current_user.id
UserMailer.send_mail :workshop_comment, u.locale do LinguaFranca.with_locale u.locale do
[ workshop, new_comment, u ] UserMailer.workshop_comment(workshop.id, new_comment.id, u.id).deliver_later
end end
end end
end end

8
config/environments/production.rb

@ -88,14 +88,14 @@ BikeBike::Application.configure do
config.action_mailer.delivery_method = :smtp config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { config.action_mailer.smtp_settings = {
:address => 'mail.bikebike.org', :address => 'smtp.gmail.com',
:domain => 'preview.bikebike.org', :domain => 'bikebike.org',
:port => 587, :port => 587,
:authentication => :plain, :authentication => :plain,
:enable_starttls_auto => true, :enable_starttls_auto => true,
:openssl_verify_mode => 'none', :openssl_verify_mode => 'none',
:user_name => 'info@preview.bikebike.org', :user_name => '',
:password => 'test' :password => ''
} }
config.action_mailer.raise_delivery_errors = true config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true config.action_mailer.perform_deliveries = true

96
features/support/location_cache.yml

@ -251,6 +251,54 @@ Portland OR: !ruby/object:Geocoder::Result::Google
- locality - locality
- political - political
cache_hit: 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 Regina, SK: !ruby/object:Geocoder::Result::Google
data: data:
address_components: address_components:
@ -453,51 +501,3 @@ Eldorado, MX: !ruby/object:Geocoder::Result::Google
- locality - locality
- political - political
cache_hit: 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:

Loading…
Cancel
Save