Browse Source

Some updates to translation engine, added dotenv but have not yet set it up.

development
Godwin 10 years ago
parent
commit
cc948937bc
  1. 2
      .rspec
  2. 27
      Gemfile
  3. 141
      Gemfile.lock
  4. 24
      Guardfile
  5. BIN
      Thumbs.db
  6. 63
      app/assets/stylesheets/foundation_and_overrides.scss
  7. 10
      app/assets/stylesheets/sass/_layout.scss
  8. 12
      app/controllers/application_controller.rb
  9. 6
      app/controllers/organizations_controller.rb
  10. 5
      app/controllers/user_sessions_controller.rb
  11. 39
      app/helpers/application_helper.rb
  12. 8
      app/models/user.rb
  13. 1
      app/views/layouts/application.html.haml
  14. 3
      app/views/organizations/_form.html.haml
  15. 26
      app/views/shared/_navbar.html.haml
  16. 2
      app/views/user_sessions/_form.html.haml
  17. 6
      app/views/user_sessions/new.html.haml
  18. 25
      config/application.rb
  19. 11
      config/boot.rb
  20. 2
      config/environments/development.rb
  21. 135
      config/initializers/i18n.rb
  22. 2
      config/initializers/locale.rb
  23. 15
      config/initializers/request_global.rb
  24. 6
      config/initializers/sorcery.rb
  25. 78
      config/locales/translations.yml
  26. 6
      db/schema.rb
  27. 14
      lib/tasks/translations.rake
  28. 2
      nbproject/project.properties
  29. 29
      spec/features/pages/home_spec.rb
  30. 72
      spec/features/pages/login_spec.rb
  31. 21
      spec/features/pages/organization_registration_spec.rb
  32. 81
      spec/spec_helper.rb
  33. 12
      spec/support/authentication.rb
  34. 8
      spec/support/delorean.rb
  35. 11
      test/factories/users.rb

2
.rspec

@ -1,3 +1 @@
--color
--format documentation
--drb

27
Gemfile

@ -3,11 +3,11 @@ source 'http://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.0'
#gem 'nokogiri', :git => '/nokogiri/'
# Servers
# gem 'puma'
# gem 'unicorn'
# gem 'openssl', '~> 1.1.0'
gem 'eventmachine'
# Multi-environment configuration
@ -19,12 +19,9 @@ gem 'eventmachine'
# ORM
gem 'pg'
# Performance and Exception management
# gem 'airbrake'
# gem 'newrelic_rpm'
# Security
# gem 'secure_headers'
gem 'dotenv-rails', :groups => [:development, :test]
# Miscellanea
# gem 'google-analytics-rails'
@ -55,11 +52,10 @@ gem 'redis'
gem 'carrierwave'
gem 'carrierwave-imageoptimizer'
gem 'mini_magick'
#gem 'carmen-rails'#, '~> 1.0.0', github: 'jim/carmen-rails'
#gem 'carmen', :path => '../carmen /'
gem 'carmen-rails'
gem 'nested_form'
gem 'acts_as_list'
##gem 'jcrop-rails'
##gem 'rmagick'
gem 'geocoder'
gem 'forgery'
@ -67,17 +63,13 @@ gem 'paper_trail'
group :development, :test do
#gem 'thin'
gem 'debugger'
gem 'delorean'
gem 'factory_girl_rails'
#gem 'faker'
#gem 'pry'
#gem 'pry-rails'
gem 'rspec'
gem 'rspec-rails'
end
group :development do
#gem 'perftools.rb'
gem 'bullet'
gem 'better_errors'
gem 'binding_of_caller'
@ -89,15 +81,16 @@ end
group :test do
gem 'capybara'
gem 'guard-rspec'
gem 'factory_girl_rails'
gem 'coveralls', require: false
gem 'database_cleaner'
gem 'email_spec'
gem 'launchy'
gem 'rspec'
gem 'rspec-rails'
gem 'selenium-webdriver'
gem 'simplecov', require: false
gem 'webmock', require: false
gem 'wdm', '>= 0.1.0' if RbConfig::CONFIG['target_os'] =~ /mswin|mingw|cygwin/i
end
group :staging, :production do

141
Gemfile.lock

@ -1,9 +1,9 @@
GIT
remote: git://github.com/josevalim/rails-footnotes.git
revision: 3a6ac1971e91d822f057650cc5916ebfcbd6ee37
revision: 8411b4cec668b133ec3f7d3be6d39e77ee3abe9e
specs:
rails-footnotes (3.7.9)
rails (>= 3.0.0)
rails-footnotes (4.0.0)
rails (>= 3.2)
GIT
remote: git://github.com/svenfuchs/i18n-active_record.git
@ -41,9 +41,8 @@ GEM
tzinfo (~> 0.3.37)
acts_as_list (0.4.0)
activerecord (>= 3.0)
addressable (2.3.5)
addressable (2.3.6)
arel (4.0.2)
atomic (1.1.14)
awesome_print (1.2.0)
bcrypt (3.1.7)
bcrypt (3.1.7-x86-mingw32)
@ -67,14 +66,25 @@ GEM
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
carrierwave (0.9.0)
carmen (1.0.1)
unicode_utils (~> 1.4.0)
carmen-rails (1.0.1)
carmen (~> 1.0.0)
rails
carrierwave (0.10.0)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
json (>= 1.7)
mime-types (>= 1.16)
carrierwave-imageoptimizer (1.2.1)
carrierwave (~> 0.8)
image_optimizer (~> 1.2)
childprocess (0.5.1)
celluloid (0.15.2)
timers (~> 1.1.0)
celluloid-io (0.15.0)
celluloid (>= 0.15.0)
nio4r (>= 0.5.0)
childprocess (0.5.2)
ffi (~> 1.0, >= 1.0.11)
chronic (0.10.2)
chunky_png (1.3.0)
@ -87,12 +97,13 @@ GEM
execjs
coffee-script-source (1.7.0)
columnize (0.3.6)
compass (0.12.2)
compass (0.12.5)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.1)
compass-rails (1.1.3)
sass (~> 3.2.19)
compass-rails (1.1.7)
compass (>= 0.12.2)
sprockets (<= 2.11.0)
coveralls (0.7.0)
multi_json (~> 1.3)
rest-client
@ -103,25 +114,31 @@ GEM
safe_yaml (~> 1.0.0)
database_cleaner (1.2.0)
debug_inspector (0.0.2)
debugger (1.6.5)
debugger (1.6.6)
columnize (>= 0.3.1)
debugger-linecache (~> 1.2.0)
debugger-ruby_core_source (~> 1.3.1)
debugger-ruby_core_source (~> 1.3.2)
debugger-linecache (1.2.0)
debugger-ruby_core_source (1.3.1)
debugger-ruby_core_source (1.3.2)
delorean (2.1.0)
chronic
diff-lcs (1.2.5)
docile (1.1.3)
dotenv (0.11.1)
dotenv-deployment (~> 0.0.2)
dotenv-deployment (0.0.2)
dotenv-rails (0.11.1)
dotenv (= 0.11.1)
email_spec (1.5.0)
launchy (~> 2.1)
mail (~> 2.2)
erubis (2.7.0)
eventmachine (1.0.3)
eventmachine (1.0.3-x86-mingw32)
execjs (2.0.2)
factory_girl (4.4.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.4.0)
factory_girl_rails (4.4.1)
factory_girl (~> 4.4.0)
railties (>= 3.0.0)
faraday (0.9.0)
@ -129,11 +146,21 @@ GEM
ffi (1.9.3)
ffi (1.9.3-x86-mingw32)
forgery (0.5.0)
foundation-rails (5.1.1.0)
formatador (0.2.4)
foundation-rails (5.2.2.0)
railties (>= 3.1.0)
sass (>= 3.2.0)
fssm (0.2.10)
geocoder (1.1.9)
guard (2.6.0)
formatador (>= 0.2.4)
listen (~> 2.7)
lumberjack (~> 1.0)
pry (>= 0.9.12)
thor (>= 0.18.1)
guard-rspec (4.2.8)
guard (~> 2.1)
rspec (>= 2.14, < 4.0)
haml (4.0.5)
tilt
haml-rails (0.5.1)
@ -168,21 +195,31 @@ GEM
multi_json (>= 1.5)
launchy (2.4.2)
addressable (~> 2.3)
listen (2.7.1)
celluloid (>= 0.15.2)
celluloid-io (>= 0.15.0)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
lumberjack (1.0.5)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
meta_request (0.2.8)
meta_request (0.2.9)
callsite
rack-contrib
railties
method_source (0.8.2)
mime-types (1.25.1)
mini_magick (3.7.0)
subexec (~> 0.2.1)
mini_portile (0.5.2)
mini_portile (0.5.3)
minitest (4.7.5)
multi_json (1.8.4)
multi_json (1.9.2)
multipart-post (2.0.0)
nested_form (0.3.2)
nio4r (1.0.0)
nokogiri (1.6.1)
mini_portile (~> 0.5.0)
nokogiri (1.6.1-x86-mingw32)
mini_portile (~> 0.5.0)
oauth (0.4.7)
@ -192,12 +229,21 @@ GEM
jwt (~> 0.1.4)
multi_json (~> 1.0)
rack (~> 1.2)
paper_trail (3.0.0)
paper_trail (3.0.1)
activerecord (>= 3.0, < 5.0)
activesupport (>= 3.0, < 5.0)
pg (0.17.1)
pg (0.17.1-x86-mingw32)
polyglot (0.3.3)
polyglot (0.3.4)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
pry (0.9.12.6-x86-mingw32)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
win32console (~> 1.3)
rack (1.5.2)
rack-contrib (1.1.0)
rack (>= 0.9.1)
@ -221,7 +267,10 @@ GEM
activesupport (= 4.0.0)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.1.1)
rake (10.2.2)
rb-fsevent (0.9.4)
rb-inotify (0.9.3)
ffi (>= 0.5.0)
redis (3.0.7)
rest-client (1.6.7)
mime-types (>= 1.16)
@ -229,11 +278,11 @@ GEM
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.7)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.5)
rspec-rails (2.14.1)
rspec-mocks (2.14.6)
rspec-rails (2.14.2)
actionpack (>= 3.0)
activemodel (>= 3.0)
activesupport (>= 3.0)
@ -242,15 +291,16 @@ GEM
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
ruby-drupal-hash (0.0.3)
rubyzip (1.1.0)
safe_yaml (1.0.1)
sass (3.2.14)
sass-rails (4.0.1)
rubyzip (1.1.3)
safe_yaml (1.0.2)
sass (3.2.19)
sass-rails (4.0.3)
railties (>= 4.0.0, < 5.0)
sass (>= 3.1.10)
sprockets-rails (~> 2.0.0)
selenium-webdriver (2.39.0)
childprocess (>= 0.2.5)
sass (~> 3.2.0)
sprockets (~> 2.8, <= 2.11.0)
sprockets-rails (~> 2.0)
selenium-webdriver (2.41.0)
childprocess (>= 0.5.0)
multi_json (~> 1.0)
rubyzip (~> 1.0)
websocket (~> 1.0.4)
@ -259,11 +309,12 @@ GEM
multi_json
simplecov-html (~> 0.8.0)
simplecov-html (0.8.0)
slop (3.5.0)
sorcery (0.8.5)
bcrypt-ruby (>= 3.0)
oauth (~> 0.4.4)
oauth2 (>= 0.8.0, < 1.0.0)
sprockets (2.10.1)
sprockets (2.11.0)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
@ -275,25 +326,29 @@ GEM
subexec (0.2.3)
term-ansicolor (1.3.0)
tins (~> 1.0)
thor (0.18.1)
thread_safe (0.1.3)
atomic
thor (0.19.1)
thread_safe (0.3.3)
tilt (1.4.1)
tins (1.0.0)
timers (1.1.0)
tins (1.1.0)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
turbolinks (2.2.1)
turbolinks (2.2.2)
coffee-rails
tzinfo (0.3.38)
uglifier (2.4.0)
tzinfo (0.3.39)
uglifier (2.5.0)
execjs (>= 0.3.0)
json (>= 1.8.0)
unicode_utils (1.4.0)
uniform_notifier (1.4.0)
webmock (1.17.3)
wdm (0.1.0)
webmock (1.17.4)
addressable (>= 2.2.7)
crack (>= 0.3.2)
websocket (1.0.7)
win32console (1.3.2)
win32console (1.3.2-x86-mingw32)
xpath (2.0.0)
nokogiri (~> 1.3)
@ -308,6 +363,7 @@ DEPENDENCIES
binding_of_caller
bullet
capybara
carmen-rails
carrierwave
carrierwave-imageoptimizer
coffee-rails (~> 4.0.0)
@ -316,12 +372,14 @@ DEPENDENCIES
database_cleaner
debugger
delorean
dotenv-rails
email_spec
eventmachine
factory_girl_rails
forgery
foundation-rails
geocoder
guard-rspec
haml
haml-rails
haml_assets
@ -351,4 +409,5 @@ DEPENDENCIES
sorcery (>= 0.8.1)
turbolinks
uglifier (>= 1.3.0)
wdm (>= 0.1.0)
webmock

24
Guardfile

@ -0,0 +1,24 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard :rspec do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
# Capybara features specs
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end

BIN
Thumbs.db

Binary file not shown.

63
app/assets/stylesheets/foundation_and_overrides.scss

@ -91,36 +91,31 @@ $info-color: $color-3;
// $shiny-edge-active-color: rgba(#000, .2);
// Media Query Ranges
// $small-range: (0em, 40em);
// $medium-range: (40.063em, 64em);
// $large-range: (64.063em, 90em);
// $xlarge-range: (90.063em, 120em);
// $xxlarge-range: (120.063em);
// $screen: "only screen";
// $landscape: "#{$screen} and (orientation: landscape)";
// $portrait: "#{$screen} and (orientation: portrait)";
// $small-up: $screen;
// $small-only: "#{$screen} and (max-width: #{upper-bound($small-range)})";
// $medium-up: "#{$screen} and (min-width:#{lower-bound($medium-range)})";
// $medium-only: "#{$screen} and (min-width:#{lower-bound($medium-range)}) and (max-width:#{upper-bound($medium-range)})";
// $large-up: "#{$screen} and (min-width:#{lower-bound($large-range)})";
// $large-only: "#{$screen} and (min-width:#{lower-bound($large-range)}) and (max-width:#{upper-bound($large-range)})";
// $xlarge-up: "#{$screen} and (min-width:#{lower-bound($xlarge-range)})";
// $xlarge-only: "#{$screen} and (min-width:#{lower-bound($xlarge-range)}) and (max-width:#{upper-bound($xlarge-range)})";
// $xxlarge-up: "#{$screen} and (min-width:#{lower-bound($xxlarge-range)})";
// $xxlarge-only: "#{$screen} and (min-width:#{lower-bound($xxlarge-range)}) and (max-width:#{upper-bound($xxlarge-range)})";
$small-range: (0em, 45em);
$medium-range: (45.063em, 64em);
$large-range: (64.063em, 90em);
$xlarge-range: (90.063em, 120em);
$xxlarge-range: (120.063em);
$screen: "only screen";
$landscape: "#{$screen} and (orientation: landscape)";
$portrait: "#{$screen} and (orientation: portrait)";
$small-up: $screen;
$small-only: "#{$screen} and (max-width: #{upper-bound($small-range)})";
$medium-up: "#{$screen} and (min-width:#{lower-bound($medium-range)})";
$medium-only: "#{$screen} and (min-width:#{lower-bound($medium-range)}) and (max-width:#{upper-bound($medium-range)})";
$large-up: "#{$screen} and (min-width:#{lower-bound($large-range)})";
$large-only: "#{$screen} and (min-width:#{lower-bound($large-range)}) and (max-width:#{upper-bound($large-range)})";
$xlarge-up: "#{$screen} and (min-width:#{lower-bound($xlarge-range)})";
$xlarge-only: "#{$screen} and (min-width:#{lower-bound($xlarge-range)}) and (max-width:#{upper-bound($xlarge-range)})";
$xxlarge-up: "#{$screen} and (min-width:#{lower-bound($xxlarge-range)})";
$xxlarge-only: "#{$screen} and (min-width:#{lower-bound($xxlarge-range)}) and (max-width:#{upper-bound($xxlarge-range)})";
// Legacy
// $small: $medium-up;
// $medium: $medium-up;
// $large: $large-up;
$small: $medium-up;
$medium: $medium-up;
$large: $large-up;
//We use this as cursors values for enabling the option of having custom cursors in the whole site's stylesheet
// $cursor-crosshair-value: crosshair;
@ -1036,6 +1031,8 @@ $label-font-sizing: 1em;//rem-calc(11);
// $include-html-top-bar-classes: false;//$include-html-classes;
// Background color for the top bar
$topbar-arrows: false;
$topbar-bg-color: $black;
$topbar-bg: transparent;//$black;
@ -1050,7 +1047,7 @@ $topbar-title-font-size: 2em;
// Style the top bar dropdown elements
$topbar-dropdown-bg: transparent;
// $topbar-dropdown-link-color: #fff;
$topbar-dropdown-link-bg: transparent;
$topbar-dropdown-link-bg: $black;
// $topbar-dropdown-link-weight: normal;
// $topbar-dropdown-toggle-size: 5px;
// $topbar-dropdown-toggle-color: #fff;
@ -1063,9 +1060,9 @@ $topbar-link-color-active: $white;
// $topbar-link-weight: normal;
// $topbar-link-font-size: rem-calc(13);
// $topbar-link-hover-lightness: -10%; // Darken by 10%
$topbar-link-bg-hover: transparent;
$topbar-link-bg-active: transparent;
$topbar-link-bg-active-hover: transparent; // scale-color($primary-color, $lightness: -14%);
$topbar-link-bg-hover: lighten($black, 25);
$topbar-link-bg-active: $black;
$topbar-link-bg-active-hover: $topbar-link-bg-hover; // scale-color($primary-color, $lightness: -14%);
$topbar-link-font-family: $header-font-family;
// $topbar-button-font-size: 0.75rem;
@ -1088,7 +1085,7 @@ $topbar-menu-icon-color: $white;
// Transitions and breakpoint styles
// $topbar-transition-speed: 300ms;
// Using rem-calc for the below breakpoint causes issues with top bar
// $topbar-breakpoint: #{upper-bound($medium-range)}; // Change to 9999px for always mobile layout
$topbar-breakpoint: #{upper-bound($small-range)}; // Change to 9999px for always mobile layout
// $topbar-media-query: "only screen and (min-width: #{upper-bound($medium-range)})";
// Divider Styles

10
app/assets/stylesheets/sass/_layout.scss

@ -370,4 +370,12 @@ body.organizations-show {
color: #FFF;
background-color: rgba(#000, 0.5);
}
}
}
.small-text-centered {
text-align: center;
@media #{$medium-up} {
text-align: inherit;
}
}

12
app/controllers/application_controller.rb

@ -1,5 +1,11 @@
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :capture_page_info
def capture_page_info
$page_info = {:path => request.env['PATH_INFO'], :controller => params['controller'], :action => params['action']}
end
end

6
app/controllers/organizations_controller.rb

@ -1,3 +1,5 @@
include ApplicationHelper
class OrganizationsController < ApplicationController
before_action :set_organization, only: [:show, :edit, :update, :destroy]
@ -17,6 +19,10 @@ class OrganizationsController < ApplicationController
@organization = Organization.new
#@organization.location = Location.new
@organization.locations.build
@user_location = lookup_ip_location
@organization.locations[0].city = @user_location.city
@organization.locations[0].country = @user_location.country_code
@organization.locations[0].territory = @user_location.state_code
@organization.locations_organization.build
@organization.user_organization_relationships.build
end

5
app/controllers/user_sessions_controller.rb

@ -1,13 +1,12 @@
class UserSessionsController < ApplicationController
def new
session[:return_to] ||= request.referer
session[:return_to] ||= request.referer
@user = User.new
end
def create
if @user = login(params[:email], params[:password])
#redirect_back_or_to(:users, notice: 'Login successful')
redirect_to session.delete(:return_to)
redirect_to session.delete(:return_to) || 'pages#home'
else
flash.now[:alert] = "Login failed"
render action: "new"

39
app/helpers/application_helper.rb

@ -178,8 +178,8 @@ module ApplicationHelper
translation['untranslated'] = I18n.translate!(config.i18n.default_locale, key, vars)
translation['lang'] = config.i18n.default_locale.to_s
rescue
puts _lorem_ipsum(behavior, behavior_size)
translation['untranslated'] = behavior ? _lorem_ipsum(behavior, behavior_size) || key.gsub(/^.*\.(.+)?$/, '\1') : key.gsub(/^.*\.(.+)?$/, '\1')
default_translation = I18n::MissingTranslationExceptionHandler.note(key, behavior, behavior_size)
translation['untranslated'] = default_translation
end
end
return translation
@ -232,7 +232,7 @@ module ApplicationHelper
if /select(_tag)?$/.match(type.to_s)
if !label
select_prompt = placeholder || (form ? 'Select a ' + name.to_s : 'Select one')
select_prompt = placeholder || (form ? 'Select a ' + (_ ('form.select_' + name.to_s)) : 'form.Select_one')
label_html = ''
show_label = false
end
@ -254,12 +254,12 @@ module ApplicationHelper
if /^password/.match(type.to_s)
placeholder = nil
elsif !placeholder
placeholder = 'Type in a ' + name.to_s
placeholder = (_ 'form.Enter_your_' + name.to_s)
end
end
if show_label
label_html = eval("(" + (form ? 'form.label' : 'label_tag') + " name, '<span>#{label ? CGI.escapeHTML(label) : name}</span>'.html_safe)")
label_html = eval("(" + (form ? 'form.label' : 'label_tag') + " name, '<span>#{CGI.escapeHTML(_ (label || name.to_s))}</span>'.html_safe)")
end
if label === false || !show_label
@ -370,8 +370,21 @@ module ApplicationHelper
return ("<div class=\"field #{type.to_s.gsub('_', '-').gsub(/\-tag$/, '')} field-#{name.to_s.gsub('_', '-')}#{classes.length > 0 ? ' ' + classes.join(' ') : ''}\">" + (label_after ? '' : label_html) + form_html + (label_after ? label_html : '') + "</div>").html_safe
end
def actions(action)
('<div class="actions"><button name="' + action.to_s + '" type="submit">' + action.to_s + '</button></div>').html_safe
def actions(actions = [])
if !actions.is_a?(Array)
actions = [actions]
end
html = '<div class="actions">'
actions.each { |action|
if action == :facebook_sign_in
html += '<a href="' + url_for(auth_at_provider_path(:provider => :facebook)) + '" class="facebook-sign-in button">' + (_ action.to_s) + '</a>'
else
html += '<button id="' + action.to_s + '" name="' + action.to_s + '" type="submit">' + (_ action.to_s) + '</button>'
end
}
html += '</div>'
html.html_safe
end
def sortable(objects, id = 'id', url: nil, &block)
@ -521,4 +534,16 @@ module ApplicationHelper
html.html_safe
end
def t(*a)
_(*a)
end
def lookup_ip_location
if request.remote_ip == '127.0.0.1'
Geocoder.search(session['remote_ip'] || (session['remote_ip'] = open("http://checkip.dyndns.org").first.gsub(/^.*\s([\d\.]+).*$/s, '\1').gsub(/[^\.\d]/, ''))).first
else
request.location
end
end
end

8
app/models/user.rb

@ -1,7 +1,7 @@
class User < ActiveRecord::Base
authenticates_with_sorcery! do |config|
config.authentications_class = Authentication
end
config.authentications_class = Authentication
end
validates :password, presence: true, confirmation: true, length: { minimum: 3 }, unless: ("id?" || "password_confirmation?")
validates :password_confirmation, presence: true, unless: ("id?" || "password?")
@ -18,7 +18,7 @@ class User < ActiveRecord::Base
has_many :user_organization_relationships
has_many :organizations, through: :user_organization_relationships
has_many :authentications, :dependent => :destroy
accepts_nested_attributes_for :authentications
has_many :authentications, :dependent => :destroy
accepts_nested_attributes_for :authentications
end

1
app/views/layouts/application.html.haml

@ -28,7 +28,6 @@
= javascript_include_tag '//use.typekit.net/iqv7hcg.js'
= javascript_include_tag 'application'
= javascript_include_tag 'nested_form'
= javascript_include_tag '//use.edgefonts.net/abel;amatic-sc.js'
%body{ class: (yield_or_default :page_style) }
= render 'shared/translation_control'

3
app/views/organizations/_form.html.haml

@ -9,7 +9,7 @@
= field f, :name, :text_field
= field f, :slug, :text_field
.columns.medium-4
.columns.medium-4.small-text-centered
-#%h2=_'organization.create.intro-title', :t
-#%p=_'organization.create.intro', :p
=# field f, :avatar, :image_field
@ -21,7 +21,6 @@
=# = f.hidden_field :avatar_cache
.columns.medium-8
= field f, :email_address, :email_field
-#= field f, :url, :text_field
= f.fields_for :locations do |b|
= field_set_tag 'Location' do
= field b, :country, :country_select, {help: 'Select a Country'}

26
app/views/shared/_navbar.html.haml

@ -1,5 +1,5 @@
%nav.top-bar.row
%nav.top-bar.row{ data: { :topbar => '' } }
#nav-inner
%ul.title-area
/ Title Area
@ -10,22 +10,28 @@
%li.toggle-topbar.menu-icon
%a{href: "#"}
%span Menu
.top-bar-section
%section.top-bar-section
/ Left Nav Section
%ul.left
%li.active
%a{href: "/conferences/"} Conferences
= link_to (_'Conferences'), :controller => :conferences
%li
%a{href: "/organizations/"} Organizations
= link_to (_'Organizations'), :controller => :organizations
%li
%a{href: "/resources/"} Resources
= link_to (_'Resources'), '/resources'
/ Right Nav Section
%ul.right
- if current_user
%li.has-form.sign-out
= link_to "Sign Out", :logout, method: :post, :class => 'button'
%li.user-profile
= link_to image_tag(current_user.avatar_url(:icon)), current_user
%li.has-form.sign-out.hide-for-small
= link_to (_"Sign_Out"), :logout, method: :post, :class => 'button'
%li.user-profile.has-dropdown
= link_to current_user do
= image_tag(current_user.avatar_url(:icon))
%span
%span.show-for-small=current_user.username
%ul.dropdown
%li= link_to 'View Profile', current_user
%li= link_to 'Edit Profile', edit_user_path(current_user.id)
- else
%li.has-form.sign-in
= link_to "Sign In", :login, :class => 'button'
= link_to (_"Sign_In"), :login, :class => 'button'

2
app/views/user_sessions/_form.html.haml

@ -1,4 +1,4 @@
= form_tag user_sessions_path, :method => :post do
= field :email, :email_field
= field :password, :password_field_tag
= actions :sign_in
= actions [:sign_in, :facebook_sign_in]

6
app/views/user_sessions/new.html.haml

@ -4,10 +4,8 @@
.columns.medium-6
= render 'form'
.columns.medium-6
%h2
Create an Account
%h2 #{_ 'user.Create_Account'}
%p #{_ 'user.why_register', 'paragraph'}
%p
#{_ 'user.why_register', 'paragraph'}
= link_to 'Login with Facebook', auth_at_provider_path(:provider => :facebook)
= render '/users/form'

25
config/application.rb

@ -1,7 +1,8 @@
require File.expand_path('../boot', __FILE__)
require 'rails/all'
require 'pry'
# require 'carmen'
# require 'pry'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
@ -11,18 +12,20 @@ ENV['JPEGOPTIM_BIN'] = 'jpegoptim'
ENV['OPTIPNG_BIN'] = 'optipng'
module BikeBike
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
config.i18n.default_locale = :en #:de
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
config.i18n.default_locale = :en #:de
config.i18n.enforce_available_locales = false
#config.middleware.swap 'Rack::MethodOverride', 'Rack::MethodOverrideWithParams'
#config.i18n.exception_handler = I18n::MissingTranslationExceptionHandler.new
end
end

11
config/boot.rb

@ -2,3 +2,14 @@
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
require'rails/commands/server'
module Rails
class Server
alias:default_options_alias :default_options
def default_options
default_options_alias.merge!(:Port=>80)
end
end
end

2
config/environments/development.rb

@ -1,5 +1,7 @@
#require 'perftools'
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
BikeBike::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.

135
config/initializers/i18n.rb

@ -0,0 +1,135 @@
require 'i18n/backend/active_record'
require 'yaml'
class DevTranslation < Translation
self.table_name = 'translations'
establish_connection :development
end
module I18n
class MissingTranslationExceptionHandler < ExceptionHandler
def self.lorem_ipsum(method, size)
options = {:random => true}
case method.to_s
when 'c', 'char', 'character', 'characters'
if size
return Forgery::LoremIpsum.characters size, options
end
return Forgery::LoremIpsum.character, options
when 'w', 'word', 'words'
if size
return Forgery::LoremIpsum.words size, options
end
#return'LOREM'
return Forgery::LoremIpsum.word options
when 's', 'sentence', 'sentences'
if size
return Forgery::LoremIpsum.sentences size, options
end
return Forgery::LoremIpsum.sentence options
when 'p', 'paragraph', 'paragraphs'
if size
return Forgery::LoremIpsum.paragraphs size, options.merge({:sentences => 10})
end
return Forgery::LoremIpsum.sentences 10, options
when 't', 'title'
return Forgery::LoremIpsum.sentences 1, options
end
return nil
end
def self.note(key, behavior = nil, behavior_size = nil)
I18n.backend.needs_translation(key)
if behavior
return self.lorem_ipsum(behavior, behavior_size)
end
key.to_s.gsub(/^world\..*\.(.+)\.name$/, '\1').gsub(/^.*\.(.+)?$/, '\1').gsub('_', ' ')
end
def call(exception, locale, key, options)
if exception.is_a?(MissingTranslation)
I18n::MissingTranslationExceptionHandler.note(key, options[:behavior] || nil, options[:behavior_size] || nil)
else
super
end
end
end
module Backend
class BikeBike < I18n::Backend::ActiveRecord
@@needs_translation
@@translations_file = 'config/locales/.translations.yml'
@@translation_cache_file = 'config/locales/.translation-cache.yml'
@@translation_cache
def needs_translation(key)
@@needs_translation ||= Array.new
@@needs_translation << key
end
def initialized?
begin
super
rescue
return false
end
end
def initialize
if Rails.env.test?
File.open(@@translations_file, 'w+')
File.open(@@translation_cache_file, 'w+')
end
@@translation_cache = YAML.load(File.read(@@translation_cache_file)) || Hash.new
super
end
protected
def lookup(locale, key, scope = [], options = {})
result = nil
if @@translation_cache && @@translation_cache.has_key?(locale.to_s) && @@translation_cache[locale.to_s].has_key?(key.to_s)
result = @@translation_cache[locale.to_s][key.to_s]
end
if !result
result = super(locale, key, scope, options)
if Rails.env.test?
if result
@@translation_cache[locale.to_s] ||= Hash.new
@@translation_cache[locale.to_s][key.to_s] = result
File.open(@@translation_cache_file, 'w') { |f| f.write @@translation_cache.to_yaml }
end
translations = YAML.load_file(@@translations_file)
translations ||= Hash.new
translations[key.to_s] ||= Hash.new
translations[key.to_s]['langauges'] ||= Hash.new
if result != nil
translations[key.to_s]['langauges'][locale.to_s] = result
end
translations[key.to_s]['pages'] ||= Array.new
unless translations[key.to_s].has_key?('data')
translations[key.to_s]['data'] = Array.new
DevTranslation.where("key = '#{key.to_s}' OR key LIKE '#{key.to_s}#{I18n::Backend::Flatten::FLATTEN_SEPARATOR}%'").each { |t|
translations[key.to_s]['data'] << t.becomes(Translation)
}
end
path = $page_info[:path]
unless translations[key.to_s]['pages'].include?(path)
translations[key.to_s]['pages'] << path
end
File.open(@@translations_file, 'w') { |f| f.write translations.to_yaml }
end
end
if Rails.env.test?
end
result
end
end
end
end
I18n.exception_handler = I18n::MissingTranslationExceptionHandler.new

2
config/initializers/locale.rb

@ -1,4 +1,4 @@
require 'i18n/backend/active_record'
I18n.backend = I18n::Backend::ActiveRecord.new
I18n.backend = I18n::Backend::BikeBike.new
# I18n::Backend::ActiveRecord.send(:include, I18n::Backend::Memoize)
# I18n::Backend::ActiveRecord.send(:include, I18n::Backend::Flatten)

15
config/initializers/request_global.rb

@ -0,0 +1,15 @@
module Rack
class MethodOverrideWithParams < Rack::MethodOverride
def call(env)
#puts "\n\nENV: " + env.to_json.to_s + "\n\n"
#puts "\n\nTT: "
#puts I18n::Backend::BikeBike.translations_file + "\n\n"
$request = Rack::Request.new(env)
#Rails.I18n.translations_file ||= 'config/locales/.translations.yml'
#if Rails.env.test?
# File.open(Rails.I18n.translations_file, 'w+')# { |f| f.write {}.to_yaml }
#end
super(env)
end
end
end

6
config/initializers/sorcery.rb

@ -110,9 +110,9 @@ Rails.application.config.sorcery.configure do |config|
# config.twitter.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=twitter"
# config.twitter.user_info_mapping = {:email => "screen_name"}
config.facebook.key = "726202304080642"
config.facebook.secret = "386a7b717d348af4120aeb1bb0ca3516"
config.facebook.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=facebook"
config.facebook.key = "257350517701074"
config.facebook.secret = "2f6ab1fd7eeff9aee73140991fc68314"
config.facebook.callback_url = "http://dev.bikebike.org/oauth/callback?provider=facebook"
config.facebook.user_info_mapping = {:email => "email", :username => "username", :avatar => "picture/data/url"}
config.facebook.scope = "email"
config.facebook.display = "popup"

78
config/locales/translations.yml

@ -0,0 +1,78 @@
---
nola_2013.about:
langauges: {}
pages:
- "/"
home.its_awesome:
langauges: {}
pages:
- "/"
Conferences:
langauges: {}
pages:
- "/"
- "/login"
Organizations:
langauges: {}
pages:
- "/"
- "/login"
Resources:
langauges: {}
pages:
- "/"
- "/login"
Sign_In:
langauges: {}
pages:
- "/"
- "/login"
missing.translation:
langauges: {}
pages:
- "/"
- "/login"
form.Enter_your_email:
langauges: {}
pages:
- "/login"
email:
langauges: {}
pages:
- "/login"
password:
langauges: {}
pages:
- "/login"
sign_in:
langauges: {}
pages:
- "/login"
facebook_sign_in:
langauges: {}
pages:
- "/login"
user.Create_Account:
langauges: {}
pages:
- "/login"
user.why_register:
langauges: {}
pages:
- "/login"
form.Enter_your_username:
langauges: {}
pages:
- "/login"
username:
langauges: {}
pages:
- "/login"
password_confirmation:
langauges: {}
pages:
- "/login"
register:
langauges: {}
pages:
- "/login"

6
db/schema.rb

@ -182,8 +182,8 @@ ActiveRecord::Schema.define(version: 20140315183241) do
end
create_table "user_organization_relationships", force: true do |t|
t.integer "user_id"
t.integer "organization_id"
t.integer "user_id", null: false
t.integer "organization_id", null: false
t.string "relationship"
t.datetime "created_at"
t.datetime "updated_at"
@ -221,7 +221,7 @@ ActiveRecord::Schema.define(version: 20140315183241) do
t.string "whodunnit"
t.text "object"
t.datetime "created_at"
t.string "value"
t.text "value"
end
create_table "workshop_facilitators", force: true do |t|

14
lib/tasks/translations.rake

@ -0,0 +1,14 @@
namespace :translations do
desc "Migrates collected translations from the dev and testing environments"
task migrate: :environment do
#File.open('config/locales/.translations.yml', 'w')
#File.open('config/locales/.translation-cache.yml', 'w+')
translations = YAML.load(File.read('config/locales/.translations.yml')) || Hash.new
translations.each { |k,t|
if t['data']
t['data'].each { |tt| tt.save }
end
}
end
end

2
nbproject/project.properties

@ -1,3 +1,3 @@
platform.active=Ruby
rails.port=3000
rails.port=80
source.encoding=UTF-8

29
spec/features/pages/home_spec.rb

@ -0,0 +1,29 @@
require 'spec_helper'
describe 'Home' do
it "has a title which is Bike!Bike!" do
visit root_path
expect(page).to have_link 'Bike!Bike!'
end
it "has a link to login" do
visit root_path
expect(page).to have_link 'Sign In', :href => '/login'
end
it "has a link to conferences" do
visit root_path
expect(find '.top-bar-section a[href$="/conferences"]').to have_text 'Conferences'
end
it "has a link to organizations" do
visit root_path
expect(find '.top-bar-section a[href$="/organizations"]').to have_text 'Organizations'
end
it "has a link to resources" do
visit root_path
expect(find '.top-bar-section a[href$="/resources"]').to have_text 'Resources'
end
end

72
spec/features/pages/login_spec.rb

@ -0,0 +1,72 @@
require 'spec_helper'
describe 'Login' do
it "has a title which is Bike!Bike!" do
visit login_path
expect(page).to have_link 'Bike!Bike!'
end
it "has a link to login" do
visit login_path
expect(page).to have_link 'Sign In', :href => '/login'
end
it "has a link to conferences" do
visit login_path
expect(find '.top-bar-section a[href$="/conferences"]').to have_text 'Conferences'
end
it "has a link to organizations" do
visit login_path
expect(find '.top-bar-section a[href$="/organizations"]').to have_text 'Organizations'
end
it "has a link to resources" do
visit login_path
expect(find '.top-bar-section a[href$="/resources"]').to have_text 'Resources'
end
it "has a login form" do
visit login_path
form = find 'form[action$="/user_sessions"]'
expect(form).to have_button 'sign in'
expect(form).to have_field 'email_'
expect(form).to have_field 'password'
expect(form).to have_link 'facebook'
end
it "has a register form" do
visit login_path
form = find 'form[action$="/users"]'
expect(form).to have_button 'register'
expect(form).to have_field 'user_username'
expect(form).to have_field 'user_email'
expect(form).to have_field 'user_password'
expect(form).to have_field 'user_password_confirmation'
end
it "allows you to register" do
visit login_path
fill_in "user_username", :with => "John"
fill_in "user_email", :with => "johnsemail@example.com"
fill_in "user_password", :with => "johnspassword"
fill_in "user_password_confirmation", :with => "johnspassword"
click_button "register"
end
describe "can actually happen" do
let(:user) { FactoryGirl.create(:user) }
it "allows you to login" do
visit login_path
form = find 'form[action$="/user_sessions"]'
form.find("#email_").set(user.email)
form.find("#password").set('secret')
click_button "sign_in"
end
end
end

21
spec/features/pages/organization_registration_spec.rb

@ -0,0 +1,21 @@
require 'spec_helper'
describe 'Organization Registration' do
let(:user) { FactoryGirl.create(:user) }
before(:each) do
visit login_path
form = find 'form[action$="/user_sessions"]'
form.find("#email_").set(user.email)
form.find("#password").set('secret')
click_button "sign_in"
visit new_organization_path
end
it "works as expected" do
fill_in 'organization_name', :with => 'Bike Kitchen'
fill_in 'organization_slug', :with => 'bike-kitchen'
fill_in 'organization_email_address', :with => 'bikekitchen@example.com'
end
end

81
spec/spec_helper.rb

@ -1,16 +1,6 @@
if ENV['CI']
require 'coveralls'
Coveralls.wear! 'rails'
end
unless ENV['DRB']
require 'simplecov'
SimpleCov.start 'rails'
end
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
@ -18,28 +8,51 @@ require 'rspec/autorun'
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
require 'webmock/rspec'
require 'capybara/rspec'
#Capybara.ignore_hidden_elements = false # testing hidden fields
include Sorcery::TestHelpers::Rails
# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
RSpec.configure do |config|
# == Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
# config.mock_with :rspec
config.include AuthenticationForFeatureRequest, type: :feature
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = 'random'
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = "random"
config.before(:each) do
Translation.connection.execute("TRUNCATE TABLE translations RESTART IDENTITY;")
translations = DevTranslation.connection.select_all("SELECT * FROM translations")
translations.each { |t|
Translation.connection.execute("
INSERT INTO
translations
(id, locale, key, value, interpolations, is_proc, created_at, updated_at)
VALUES
(#{t['id']}, #{Translation.sanitize(t['locale'])}, #{Translation.sanitize(t['key'])}, #{Translation.sanitize(t['value'])}, #{Translation.sanitize(t['interpolations'])}, #{Translation.sanitize(t['is_proc'])}, #{Translation.sanitize(t['created_at'])}, #{Translation.sanitize(t['updated_at'])})
;")
}
end
end

12
spec/support/authentication.rb

@ -1,8 +1,8 @@
module AuthenticationForFeatureRequest
def login user, password = 'login'
user.update_attribute :password, password
def login user, password = 'login'
user.update_attribute :password, password
page.driver.post sessions_url, {email: user.email, password: password}
visit root_url
end
end
page.driver.post sessions_url, {email: user.email, password: password}
visit root_url
end
end

8
spec/support/delorean.rb

@ -1,7 +1,7 @@
RSpec.configure do |config|
config.include Delorean
config.include Delorean
config.before(:each) do
back_to_the_present
end
config.before(:each) do
back_to_the_present
end
end

11
test/factories/users.rb

@ -1,6 +1,13 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :user do
end
sequence(:email) { |n| "person-#{n}@example.com" }
sequence(:username) { |n| "person-#{n}" }
factory :user, class: User do
username
email
password "secret"
password_confirmation "secret"
end
end

Loading…
Cancel
Save