Browse Source

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

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

7
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

1
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']

4
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 {

140
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}",
"<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,
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}",
"<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,
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

20
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

28
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

8
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

96
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:

Loading…
Cancel
Save