diff --git a/.gitignore b/.gitignore index af64fae5..6a502e99 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,16 @@ -.bundle -db/*.sqlite3 -log/*.log -tmp/**/* +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-journal + +# Ignore all logfiles and tempfiles. +/log/*.log +/tmp diff --git a/.rspec b/.rspec new file mode 100644 index 00000000..0d786ba0 --- /dev/null +++ b/.rspec @@ -0,0 +1,3 @@ +--color +--warnings +--require spec_helper diff --git a/Gemfile b/Gemfile index 23d050ec..9585da70 100644 --- a/Gemfile +++ b/Gemfile @@ -1,19 +1,40 @@ -source 'http://rubygems.org' +source 'https://rubygems.org' +ruby '2.2.0' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '4.1.8' + +# Use SCSS for stylesheets +gem 'sass-rails', '~> 4.0.3' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# Use CoffeeScript for .js.coffee assets and views +gem 'coffee-rails', '~> 4.0.0' +# See https://github.com/sstephenson/execjs#readme for more supported runtimes +# gem 'therubyracer', platforms: :ruby + +# Use jquery as the JavaScript library +gem 'jquery-rails' +# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks +gem 'turbolinks' + +# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring +gem 'spring', group: :development + +gem 'activeadmin', github: 'activeadmin' +gem 'inherited_resources', '~> 1.4.1' +gem "devise" -gem 'rails', '3.0.10' -gem 'sqlite3-ruby', :require => 'sqlite3' -gem 'nifty-generators' -gem "activeadmin", '0.5.0' gem "faker" -gem 'newrelic_rpm', '3.1.1' +#gem 'newrelic_rpm', '3.1.1' gem 'hoptoad_notifier', '2.4.11' -gem 'rack-throttle' group :development do - gem 'mechanize' + gem 'mechanize','2.7.3' end group :production do + gem 'pg' gem 'unicorn' # Enable gzip compression on heroku, but don't compress images. @@ -21,4 +42,23 @@ group :production do # Heroku injects it if it's not in there already gem 'rails_12factor' + + gem 'rack-throttle' + gem 'rack-cache' end + +group :development, :test do + gem 'sqlite3' + gem 'factory_girl_rails' + gem 'rspec-rails', '~> 3.0.0' + gem 'spork', '~> 1.0rc' +end + +group :test do + gem "shoulda" + gem "shoulda-matchers" + gem "webmock", "~> 1.11.0" + gem "webrat" + gem 'simplecov', :require => false +end + diff --git a/Gemfile.lock b/Gemfile.lock index e29517b4..3e59d3ef 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,164 +1,280 @@ +GIT + remote: git://github.com/activeadmin/activeadmin.git + revision: 74799b8652c6c09d632b5bd50b52027507aace3c + specs: + activeadmin (1.0.0.pre) + arbre (~> 1.0, >= 1.0.2) + bourbon + coffee-rails + formtastic (~> 3.1) + formtastic_i18n + inherited_resources (~> 1.4, != 1.5.0) + jquery-rails + jquery-ui-rails (~> 5.0) + kaminari (~> 0.15) + rails (>= 3.2, < 4.2) + ransack (~> 1.3) + sass-rails + GEM - remote: http://rubygems.org/ + remote: https://rubygems.org/ specs: - abstract (1.0.0) - actionmailer (3.0.10) - actionpack (= 3.0.10) - mail (~> 2.2.19) - actionpack (3.0.10) - activemodel (= 3.0.10) - activesupport (= 3.0.10) - builder (~> 2.1.2) - erubis (~> 2.6.6) - i18n (~> 0.5.0) - rack (~> 1.2.1) - rack-mount (~> 0.6.14) - rack-test (~> 0.5.7) - tzinfo (~> 0.3.23) - activeadmin (0.5.0) - arbre (>= 1.0.1) - bourbon (>= 1.0.0) - devise (>= 1.1.2) - fastercsv - formtastic (>= 2.0.0) - inherited_resources (>= 1.3.1) - jquery-rails (>= 1.0.0) - kaminari (>= 0.13.0) - meta_search (>= 0.9.2) - rails (>= 3.0.0) - sass (>= 3.1.0) - activemodel (3.0.10) - activesupport (= 3.0.10) - builder (~> 2.1.2) - i18n (~> 0.5.0) - activerecord (3.0.10) - activemodel (= 3.0.10) - activesupport (= 3.0.10) - arel (~> 2.0.10) - tzinfo (~> 0.3.23) - activeresource (3.0.10) - activemodel (= 3.0.10) - activesupport (= 3.0.10) - activesupport (3.0.10) - arbre (1.0.1) + actionmailer (4.1.8) + actionpack (= 4.1.8) + actionview (= 4.1.8) + mail (~> 2.5, >= 2.5.4) + actionpack (4.1.8) + actionview (= 4.1.8) + activesupport (= 4.1.8) + rack (~> 1.5.2) + rack-test (~> 0.6.2) + actionview (4.1.8) + activesupport (= 4.1.8) + builder (~> 3.1) + erubis (~> 2.7.0) + activemodel (4.1.8) + activesupport (= 4.1.8) + builder (~> 3.1) + activerecord (4.1.8) + activemodel (= 4.1.8) + activesupport (= 4.1.8) + arel (~> 5.0.0) + activesupport (4.1.8) + i18n (~> 0.6, >= 0.6.9) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.1) + tzinfo (~> 1.1) + addressable (2.3.6) + arbre (1.0.2) activesupport (>= 3.0.0) - arel (2.0.10) - bcrypt-ruby (3.0.1) - bourbon (2.1.1) - sass (>= 3.1) - builder (2.1.2) - devise (1.5.3) - bcrypt-ruby (~> 3.0) - orm_adapter (~> 0.0.3) - warden (~> 1.1) - erubis (2.6.6) - abstract (>= 1.0.0) - faker (0.9.5) - i18n (~> 0.4) - fastercsv (1.5.5) - formtastic (2.2.1) - actionpack (>= 3.0) - has_scope (0.5.1) - heroku-deflater (0.2.0) + arel (5.0.1.20140414130214) + bcrypt (3.1.9) + bourbon (3.2.3) + sass (~> 3.2) + thor + builder (3.2.2) + coffee-rails (4.0.1) + coffee-script (>= 2.2.0) + railties (>= 4.0.0, < 5.0) + coffee-script (2.3.0) + coffee-script-source + execjs + coffee-script-source (1.8.0) + crack (0.4.2) + safe_yaml (~> 1.0.0) + devise (3.4.1) + bcrypt (~> 3.0) + orm_adapter (~> 0.1) + railties (>= 3.2.6, < 5) + responders + thread_safe (~> 0.1) + warden (~> 1.2.3) + diff-lcs (1.2.5) + docile (1.1.5) + domain_name (0.5.23) + unf (>= 0.0.5, < 1.0.0) + erubis (2.7.0) + execjs (2.2.2) + factory_girl (4.5.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.5.0) + factory_girl (~> 4.5.0) + railties (>= 3.0.0) + faker (1.4.3) + i18n (~> 0.5) + formtastic (3.1.2) + actionpack (>= 3.2.13) + formtastic_i18n (0.1.1) + has_scope (0.6.0.rc) + actionpack (>= 3.2, < 5) + activesupport (>= 3.2, < 5) + heroku-deflater (0.5.3) + rack (>= 1.4.5) + hike (1.2.3) hoptoad_notifier (2.4.11) activesupport builder - i18n (0.5.0) - inherited_resources (1.3.1) - has_scope (~> 0.5.0) - responders (~> 0.6) - jquery-rails (1.0.19) - railties (~> 3.0) - thor (~> 0.14) - kaminari (0.13.0) + http-cookie (1.0.2) + domain_name (~> 0.5) + i18n (0.7.0) + inherited_resources (1.4.1) + has_scope (~> 0.6.0.rc) + responders (~> 1.0.0.rc) + jquery-rails (3.1.2) + railties (>= 3.0, < 5.0) + thor (>= 0.14, < 2.0) + jquery-ui-rails (5.0.3) + railties (>= 3.2.16) + json (1.8.1) + kaminari (0.16.1) actionpack (>= 3.0.0) activesupport (>= 3.0.0) - railties (>= 3.0.0) - kgio (2.8.1) - mail (2.2.19) - activesupport (>= 2.3.6) - i18n (>= 0.4.0) - mime-types (~> 1.16) - treetop (~> 1.4.8) - mechanize (2.0.1) + kgio (2.9.2) + mail (2.6.3) + mime-types (>= 1.16, < 3) + mechanize (2.7.3) + domain_name (~> 0.5, >= 0.5.1) + http-cookie (~> 1.0) + mime-types (~> 2.0) net-http-digest_auth (~> 1.1, >= 1.1.1) - net-http-persistent (~> 1.8) + net-http-persistent (~> 2.5, >= 2.5.2) nokogiri (~> 1.4) - webrobots (~> 0.0, >= 0.0.9) - meta_search (1.0.6) - actionpack (~> 3.0.2) - activerecord (~> 3.0.2) - activesupport (~> 3.0.2) - arel (~> 2.0.2) - mime-types (1.16) - net-http-digest_auth (1.1.1) - net-http-persistent (1.9) - newrelic_rpm (3.1.1) - nifty-generators (0.4.6) - nokogiri (1.5.0) - orm_adapter (0.0.7) - polyglot (0.3.2) - rack (1.2.3) - rack-mount (0.6.14) - rack (>= 1.0.0) - rack-test (0.5.7) + ntlm-http (~> 0.1, >= 0.1.1) + webrobots (>= 0.0.9, < 0.2) + mime-types (2.4.3) + mini_portile (0.6.1) + minitest (5.5.0) + multi_json (1.10.1) + net-http-digest_auth (1.4) + net-http-persistent (2.9.4) + nokogiri (1.6.5) + mini_portile (~> 0.6.0) + ntlm-http (0.1.1) + orm_adapter (0.5.0) + pg (0.17.1) + polyamorous (1.1.0) + activerecord (>= 3.0) + rack (1.5.2) + rack-cache (1.2) + rack (>= 0.4) + rack-test (0.6.2) rack (>= 1.0) - rack-throttle (0.3.0) + rack-throttle (0.4.0) rack (>= 1.0.0) - rails (3.0.10) - actionmailer (= 3.0.10) - actionpack (= 3.0.10) - activerecord (= 3.0.10) - activeresource (= 3.0.10) - activesupport (= 3.0.10) - bundler (~> 1.0) - railties (= 3.0.10) - rails_12factor (0.0.2) + rails (4.1.8) + actionmailer (= 4.1.8) + actionpack (= 4.1.8) + actionview (= 4.1.8) + activemodel (= 4.1.8) + activerecord (= 4.1.8) + activesupport (= 4.1.8) + bundler (>= 1.3.0, < 2.0) + railties (= 4.1.8) + sprockets-rails (~> 2.0) + rails_12factor (0.0.3) rails_serve_static_assets rails_stdout_logging - rails_serve_static_assets (0.0.1) + rails_serve_static_assets (0.0.2) rails_stdout_logging (0.0.3) - railties (3.0.10) - actionpack (= 3.0.10) - activesupport (= 3.0.10) + railties (4.1.8) + actionpack (= 4.1.8) + activesupport (= 4.1.8) rake (>= 0.8.7) - rdoc (~> 3.4) - thor (~> 0.14.4) - raindrops (0.12.0) - rake (0.9.2) - rdoc (3.9.4) - responders (0.6.5) - sass (3.2.1) - sqlite3 (1.3.4) - sqlite3-ruby (1.3.3) - sqlite3 (>= 1.3.3) - thor (0.14.6) - treetop (1.4.10) - polyglot - polyglot (>= 0.3.1) - tzinfo (0.3.29) - unicorn (4.7.0) + thor (>= 0.18.1, < 2.0) + raindrops (0.13.0) + rake (10.4.2) + ransack (1.5.1) + actionpack (>= 3.0) + activerecord (>= 3.0) + activesupport (>= 3.0) + i18n + polyamorous (~> 1.1) + responders (1.0.0) + railties (>= 3.2, < 5) + rspec-core (3.0.3) + rspec-support (~> 3.0.0) + rspec-expectations (3.0.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.0.0) + rspec-mocks (3.0.3) + rspec-support (~> 3.0.0) + rspec-rails (3.0.2) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 3.0.0) + rspec-expectations (~> 3.0.0) + rspec-mocks (~> 3.0.0) + rspec-support (~> 3.0.0) + rspec-support (3.0.3) + safe_yaml (1.0.4) + sass (3.2.19) + sass-rails (4.0.5) + railties (>= 4.0.0, < 5.0) + sass (~> 3.2.2) + sprockets (~> 2.8, < 3.0) + sprockets-rails (~> 2.0) + shoulda (3.5.0) + shoulda-context (~> 1.0, >= 1.0.1) + shoulda-matchers (>= 1.4.1, < 3.0) + shoulda-context (1.2.1) + shoulda-matchers (2.6.2) + activesupport (>= 3.0.0) + simplecov (0.9.0) + docile (~> 1.1.0) + multi_json + simplecov-html (~> 0.8.0) + simplecov-html (0.8.0) + spork (1.0.0rc4) + spring (1.2.0) + sprockets (2.12.3) + hike (~> 1.2) + multi_json (~> 1.0) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + sprockets-rails (2.2.2) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (>= 2.8, < 4.0) + sqlite3 (1.3.10) + thor (0.19.1) + thread_safe (0.3.4) + tilt (1.4.1) + turbolinks (2.5.3) + coffee-rails + tzinfo (1.2.2) + thread_safe (~> 0.1) + uglifier (2.6.0) + execjs (>= 0.3.0) + json (>= 1.8.0) + unf (0.1.4) + unf_ext + unf_ext (0.0.6) + unicorn (4.8.3) kgio (~> 2.6) rack raindrops (~> 0.7) - warden (1.2.1) + warden (1.2.3) + rack (>= 1.0) + webmock (1.11.0) + addressable (>= 2.2.7) + crack (>= 0.3.2) + webrat (0.7.3) + nokogiri (>= 1.2.0) rack (>= 1.0) - webrobots (0.0.11) - nokogiri (>= 1.4.4) + rack-test (>= 0.5.3) + webrobots (0.1.1) PLATFORMS ruby DEPENDENCIES - activeadmin (= 0.5.0) + activeadmin! + coffee-rails (~> 4.0.0) + devise + factory_girl_rails faker heroku-deflater hoptoad_notifier (= 2.4.11) - mechanize - newrelic_rpm (= 3.1.1) - nifty-generators + inherited_resources (~> 1.4.1) + jquery-rails + mechanize (= 2.7.3) + pg + rack-cache rack-throttle - rails (= 3.0.10) + rails (= 4.1.8) rails_12factor - sqlite3-ruby + rspec-rails (~> 3.0.0) + sass-rails (~> 4.0.3) + shoulda + shoulda-matchers + simplecov + spork (~> 1.0rc) + spring + sqlite3 + turbolinks + uglifier (>= 1.3.0) unicorn + webmock (~> 1.11.0) + webrat diff --git a/README.md b/README.md index b8e44537..356b955b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # The Active Admin Store -This is a test application to show off the power of Active Admin. +This is a test application to demo Active Admin. + +http://demo.activeadmin.info diff --git a/Rakefile b/Rakefile index 5ce9ffef..ba6b733d 100644 --- a/Rakefile +++ b/Rakefile @@ -2,6 +2,5 @@ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require File.expand_path('../config/application', __FILE__) -require 'rake' -ActiveadminDepot::Application.load_tasks +Rails.application.load_tasks diff --git a/app/admin/dashboards.rb b/app/admin/dashboard.rb similarity index 85% rename from app/admin/dashboards.rb rename to app/admin/dashboard.rb index cc21afb9..2eece35a 100644 --- a/app/admin/dashboards.rb +++ b/app/admin/dashboard.rb @@ -1,5 +1,5 @@ ActiveAdmin.register_page "Dashboard" do - + menu :priority => 1 content :title => proc{ I18n.t("active_admin.dashboard") } do columns do @@ -7,9 +7,9 @@ column do panel "Recent Orders" do table_for Order.complete.order('id desc').limit(10) do - column("State") {|order| status_tag(order.state) } - column("Customer"){|order| link_to(order.user.email, admin_customer_path(order.user)) } - column("Total") {|order| number_to_currency order.total_price } + column("State") {|order| status_tag(order.state) } + column("Customer"){|order| link_to(order.user.email, admin_customer_path(order.user)) } + column("Total") {|order| number_to_currency order.total_price } end end end @@ -26,16 +26,18 @@ columns do + column do + div do + br + text_node %{}.html_safe + end + end + column do panel "ActiveAdmin Demo" do div do render('/admin/sidebar_links', :model => 'dashboards') end - - div do - br - text_node %{}.html_safe - end end end @@ -44,7 +46,7 @@ # Define your dashboard sections here. Each block will be # rendered on the dashboard in the context of the view. So just # return the content which you would like to display. - + # The dashboard is organized in rows and columns, where each row # divides the space for its child columns equally. @@ -64,7 +66,7 @@ # end # end # end - + # == Render Partials # The block is rendererd within the context of the view, so you can # easily render a partial rather than build content in ruby. diff --git a/app/admin/orders.rb b/app/admin/orders.rb index b70cafef..237de259 100644 --- a/app/admin/orders.rb +++ b/app/admin/orders.rb @@ -1,4 +1,5 @@ ActiveAdmin.register Order do + menu :priority => 3 actions :index, :show filter :total_price @@ -27,8 +28,6 @@ end end end - - active_admin_comments end sidebar :customer_information, :only => :show do diff --git a/app/admin/products.rb b/app/admin/products.rb index 5c563a67..c9ede7ec 100644 --- a/app/admin/products.rb +++ b/app/admin/products.rb @@ -1,4 +1,6 @@ ActiveAdmin.register Product do + menu :priority => 2 + permit_params :title, :description,:author,:price, :featured, :available_on,:image_file_name scope :all, :default => true scope :available do |products| @@ -38,4 +40,6 @@ sidebar "Active Admin Demo" do render('/admin/sidebar_links', :model => 'products') end + + end diff --git a/app/admin/users.rb b/app/admin/users.rb index e410ff74..60f4a93a 100644 --- a/app/admin/users.rb +++ b/app/admin/users.rb @@ -1,5 +1,6 @@ ActiveAdmin.register User, :as => "Customer" do + menu :priority => 4 config.batch_actions = true filter :username @@ -12,7 +13,7 @@ column :username column :email column :created_at - default_actions + actions end show :title => :username do @@ -24,7 +25,6 @@ column("Total") {|order| number_to_currency order.total_price } end end - active_admin_comments end sidebar "Customer Details", :only => :show do diff --git a/public/stylesheets/.gitkeep b/app/assets/images/.keep similarity index 100% rename from public/stylesheets/.gitkeep rename to app/assets/images/.keep diff --git a/app/assets/javascripts/active_admin.js.coffee b/app/assets/javascripts/active_admin.js.coffee new file mode 100644 index 00000000..3752dcef --- /dev/null +++ b/app/assets/javascripts/active_admin.js.coffee @@ -0,0 +1 @@ +#= require active_admin/base diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js new file mode 100644 index 00000000..d6925fa4 --- /dev/null +++ b/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. +// +// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require jquery +//= require jquery_ujs +//= require turbolinks +//= require_tree . diff --git a/app/assets/stylesheets/active_admin.css.scss b/app/assets/stylesheets/active_admin.css.scss new file mode 100644 index 00000000..90ba1d47 --- /dev/null +++ b/app/assets/stylesheets/active_admin.css.scss @@ -0,0 +1,17 @@ +// SASS variable overrides must be declared before loading up Active Admin's styles. +// +// To view the variables that Active Admin provides, take a look at +// `app/assets/stylesheets/active_admin/mixins/_variables.css.scss` in the +// Active Admin source. +// +// For example, to change the sidebar width: +// $sidebar-width: 242px; + +// Active Admin's got SASS! +@import "active_admin/mixins"; +@import "active_admin/base"; + +// Overriding any non-variable SASS must be done after the fact. +// For example, to change the default status-tag color: +// +// .status_tag { background: #6090DB; } diff --git a/public/stylesheets/application.css b/app/assets/stylesheets/application.css similarity index 100% rename from public/stylesheets/application.css rename to app/assets/stylesheets/application.css diff --git a/vendor/plugins/.gitkeep b/app/controllers/concerns/.keep similarity index 100% rename from vendor/plugins/.gitkeep rename to app/controllers/concerns/.keep diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f5a20ee0..20a39a08 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -4,7 +4,7 @@ def new end def create - @user = User.new(params[:user]) + @user = User.new(user_params) if @user.save session[:user_id] = @user.id flash[:notice] = "Thank you for signing up! You are now logged in." @@ -13,4 +13,8 @@ def create render :action => 'new' end end + + def user_params + params.require(:user).permit(:username, :email, :password, :salt, :encrypted_password) + end end diff --git a/app/mailers/.keep b/app/mailers/.keep new file mode 100644 index 00000000..e69de29b diff --git a/app/models/.keep b/app/models/.keep new file mode 100644 index 00000000..e69de29b diff --git a/app/models/admin_user.rb b/app/models/admin_user.rb index 039464fa..318ec397 100644 --- a/app/models/admin_user.rb +++ b/app/models/admin_user.rb @@ -1,9 +1,6 @@ class AdminUser < ActiveRecord::Base # Include default devise modules. Others available are: - # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable + # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable - - # Setup accessible (or protected) attributes for your model - attr_accessible :email, :password, :password_confirmation, :remember_me end diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep new file mode 100644 index 00000000..e69de29b diff --git a/app/models/order.rb b/app/models/order.rb index ed02d01e..0eac3018 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -2,17 +2,17 @@ class Order < ActiveRecord::Base has_many :line_items, :dependent => :destroy belongs_to :user - scope :in_progress, where("orders.checked_out_at IS NULL") - scope :complete, where("orders.checked_out_at IS NOT NULL") + scope :in_progress, ->{where("orders.checked_out_at IS NULL")} + scope :complete, -> {where("orders.checked_out_at IS NOT NULL")} COMPLETE = "complete" IN_PROGRESS = "in_progress" def self.find_with_product(product) return [] unless product - complete.includes(:line_items). - where(["line_items.product_id = ?", product.id]). - order("orders.checked_out_at DESC") + complete.joins(:line_items). + where(["line_items.product_id = ?", product.id]). + order("orders.checked_out_at DESC") end def checkout! @@ -30,8 +30,7 @@ def state end def display_name - ActionController::Base.helpers.number_to_currency(total_price) + - " - Order ##{id} (#{user.username})" + ActionController::Base.helpers.number_to_currency(total_price) + + " - Order ##{id} (#{user.username})" end - end diff --git a/app/models/user.rb b/app/models/user.rb index 78e46e6c..9392d7fb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,17 +1,14 @@ class User < ActiveRecord::Base - has_many :orders, :dependent => :destroy - # new columns need to be added here to be writable through mass assignment - attr_accessible :username, :email, :password, :password_confirmation attr_accessor :password before_save :prepare_password validates_presence_of :username validates_uniqueness_of :username, :email, :allow_blank => true - validates_format_of :username, :with => /^[-\w\._@]+$/i, :allow_blank => true, :message => "should only contain letters, numbers, or .-_@" - validates_format_of :email, :with => /^[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}$/i + validates_format_of :username, :with => /(?=.*[A-Za-z._@])/, :allow_blank => true, :message => "should only contain letters, numbers, or .-_@" + validates_format_of :email, :with => /\A[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}\z/i validates_presence_of :password, :on => :create validates_confirmation_of :password validates_length_of :password, :minimum => 4, :allow_blank => true diff --git a/bin/bundle b/bin/bundle new file mode 100755 index 00000000..66e9889e --- /dev/null +++ b/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/bin/rails b/bin/rails new file mode 100755 index 00000000..7feb6a30 --- /dev/null +++ b/bin/rails @@ -0,0 +1,8 @@ +#!/usr/bin/env ruby +begin + load File.expand_path("../spring", __FILE__) +rescue LoadError +end +APP_PATH = File.expand_path('../../config/application', __FILE__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/bin/rake b/bin/rake new file mode 100755 index 00000000..8017a027 --- /dev/null +++ b/bin/rake @@ -0,0 +1,8 @@ +#!/usr/bin/env ruby +begin + load File.expand_path("../spring", __FILE__) +rescue LoadError +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/bin/spring b/bin/spring new file mode 100755 index 00000000..7f24d96f --- /dev/null +++ b/bin/spring @@ -0,0 +1,18 @@ +#!/usr/bin/env ruby + +# This file loads spring without using Bundler, in order to be fast +# It gets overwritten when you run the `spring binstub` command + +unless defined?(Spring) + require "rubygems" + require "bundler" + + if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m) + ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR) + ENV["GEM_HOME"] = "" + Gem.paths = ENV + + gem "spring", match[1] + require "spring/binstub" + end +end diff --git a/config.ru b/config.ru index 9b3188c2..5bc2a619 100644 --- a/config.ru +++ b/config.ru @@ -1,4 +1,4 @@ # This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) -run ActiveadminDepot::Application +run Rails.application diff --git a/config/application.rb b/config/application.rb index 52af8b39..4ce40927 100644 --- a/config/application.rb +++ b/config/application.rb @@ -2,32 +2,17 @@ require 'rails/all' -# If you have a Gemfile, require the gems listed there, including any gems +# Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. -Bundler.require(:default, Rails.env) if defined?(Bundler) - -require 'rack/throttle' +Bundler.require(*Rails.groups) module ActiveadminDepot class Application < Rails::Application - - config.middleware.use Rack::Throttle::Hourly, :max => 50 - config.middleware.use Rack::Throttle::Daily, :max => 300 - - config.autoload_paths << "#{config.root}/lib" # Settings in config/environments/* take precedence over those specified here. + config.autoload_paths << "#{config.root}/lib" + # 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. - # Custom directories with classes and modules you want to be autoloadable. - # config.autoload_paths += %W(#{config.root}/extras) - - # Only load the plugins named here, in the order given (default is alphabetical). - # :all can be used as a placeholder for all plugins not explicitly named. - # config.plugins = [ :exception_notification, :ssl_requirement, :all ] - - # Activate observers that should always be running. - # config.active_record.observers = :cacher, :garbage_collector, :forum_observer - # 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)' @@ -35,14 +20,5 @@ class Application < Rails::Application # 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 = :de - - # JavaScript files you want as :defaults (application.js is always included). - # config.action_view.javascript_expansions[:defaults] = %w(jquery rails) - - # Configure the default encoding used in templates for Ruby 1.9. - config.encoding = "utf-8" - - # Configure sensitive parameters which will be filtered from the log file. - config.filter_parameters += [:password] end end diff --git a/config/boot.rb b/config/boot.rb index ab6cb374..5e5f0c1f 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,13 +1,4 @@ -require 'rubygems' - # Set up gems listed in the Gemfile. -gemfile = File.expand_path('../../Gemfile', __FILE__) -begin - ENV['BUNDLE_GEMFILE'] = gemfile - require 'bundler' - Bundler.setup -rescue Bundler::GemNotFound => e - STDERR.puts e.message - STDERR.puts "Try running `bundle install`." - exit! -end if File.exist?(gemfile) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) + +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) diff --git a/config/database.yml b/config/database.yml index 025d62a8..1c1a37ca 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,22 +1,25 @@ # SQLite version 3.x -# gem install sqlite3-ruby (not necessary on OS X Leopard) -development: +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default adapter: sqlite3 - database: db/development.sqlite3 pool: 5 timeout: 5000 +development: + <<: *default + database: db/development.sqlite3 + # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: - adapter: sqlite3 + <<: *default database: db/test.sqlite3 - pool: 5 - timeout: 5000 production: - adapter: sqlite3 + <<: *default database: db/production.sqlite3 - pool: 5 - timeout: 5000 diff --git a/config/environment.rb b/config/environment.rb index cad20960..ee8d90dc 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,5 @@ -# Load the rails application +# Load the Rails application. require File.expand_path('../application', __FILE__) -# Initialize the rails application -ActiveadminDepot::Application.initialize! +# Initialize the Rails application. +Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index b1f959d5..ddf0e90c 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,26 +1,37 @@ -ActiveadminDepot::Application.configure do - # Settings specified here will take precedence over those in config/environment.rb +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on - # every request. This slows down response time but is perfect for development - # since you don't have to restart the webserver when you make code changes. + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. config.cache_classes = false - # Log error messages when you accidentally call methods on nil. - config.whiny_nils = true + # Do not eager load code on boot. + config.eager_load = false - # Show full error reports and disable caching + # Show full error reports and disable caching. config.consider_all_requests_local = true - config.action_view.debug_rjs = true config.action_controller.perform_caching = false - # Don't care if the mailer can't send + # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false - # Print deprecation notices to the Rails logger + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log - # Only use best-standards-support built into browsers - config.action_dispatch.best_standards_support = :builtin -end + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + config.assets.raise_runtime_errors = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/config/environments/production.rb b/config/environments/production.rb index ccbc8ff4..59c3fb90 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,51 +1,81 @@ -ActiveadminDepot::Application.configure do - # Settings specified here will take precedence over those in config/environment.rb +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. - # The production environment is meant for finished, "live" apps. - # Code is not reloaded between requests + # Code is not reloaded between requests. config.cache_classes = true - # Full error reports are disabled and caching is turned on + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Specifies the header that your server uses for sending files - config.action_dispatch.x_sendfile_header = "X-Sendfile" + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. + config.action_dispatch.rack_cache = true - # For nginx: - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' + # Disable Rails's static asset server (Apache or nginx will already do this). + config.serve_static_assets = true - # If you have no front-end server that supports something like X-Sendfile, - # just comment this out and Rails will serve the files + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass - # See everything in the log (default is :info) - # config.log_level = :debug + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false - # Use a different logger for distributed setups - # config.logger = SyslogLogger.new + # Generate digests for assets URLs. + config.assets.digest = true - # Use a different cache store in production - # config.cache_store = :mem_cache_store + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb - # Enable Rails's static asset server for Heroku - config.serve_static_assets = true + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Set to :debug to see everything in the log. + config.log_level = :warn + + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] - # Set static assets cache header. rack-cache will cache those. - config.static_cache_control = "public, max-age=31536000" + # Use a different logger for distributed setups. + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) - # Enable serving of images, stylesheets, and javascripts from an asset server + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.action_controller.asset_host = "http://assets.example.com" - # Disable delivery errors, bad email addresses will be ignored + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false - # Enable threaded mode - # config.threadsafe! - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation can not be found) + # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true - # Send deprecation notices to registered listeners + # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify + + # Disable automatic flushing of the log to improve performance. + # config.autoflush_log = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false + + config.middleware.use Rack::Throttle::Daily, :max => 1000 # requests + config.middleware.use Rack::Throttle::Minute, :max => 60 # requests end diff --git a/config/environments/test.rb b/config/environments/test.rb index 812b79dc..053f5b66 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,35 +1,39 @@ -ActiveadminDepot::Application.configure do - # Settings specified here will take precedence over those in config/environment.rb +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's - # test suite. You never need to work with it otherwise. Remember that + # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped - # and recreated between test runs. Don't rely on the data there! + # and recreated between test runs. Don't rely on the data there! config.cache_classes = true - # Log error messages when you accidentally call methods on nil. - config.whiny_nils = true + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false - # Show full error reports and disable caching + # Configure static asset server for tests with Cache-Control for performance. + config.serve_static_assets = true + config.static_cache_control = 'public, max-age=3600' + + # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false - # Raise exceptions instead of rendering exception templates + # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false - # Disable request forgery protection in test environment - config.action_controller.allow_forgery_protection = false + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test - # Use SQL instead of Active Record's schema dumper when creating the test database. - # This is necessary if your schema can't be completely dumped by the schema dumper, - # like if you have constraints or database-specific column types - # config.active_record.schema_format = :sql - - # Print deprecation notices to the stderr + # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true end diff --git a/config/initializers/active_admin.rb b/config/initializers/active_admin.rb index 2fb72a4f..cd78971f 100644 --- a/config/initializers/active_admin.rb +++ b/config/initializers/active_admin.rb @@ -1,5 +1,4 @@ ActiveAdmin.setup do |config| - # == Site Title # # Set the title that is displayed on the main layout @@ -7,13 +6,24 @@ # config.site_title = "Active Admin Depot" + # Set the link url for the title. For example, to take + # users to your main site. Defaults to no link. + # + # config.site_title_link = "/" + + # Set an optional image to be displayed for the header + # instead of a string (overrides :site_title) + # + # Note: Aim for an image that's 21px high so it fits in the header. + # + # config.site_title_image = "logo.png" # == Default Namespace # # Set the default namespace each administration resource - # will be added to. + # will be added to. # - # eg: + # eg: # config.default_namespace = :hello_world # # This will create resources in the HelloWorld module and @@ -21,19 +31,53 @@ # # To set no namespace by default, use: # config.default_namespace = false - config.default_namespace = :admin - + # + # Default: + # config.default_namespace = :admin + # + # You can customize the settings for each namespace by using + # a namespace block. For example, to change the site title + # within a namespace: + # + # config.namespace :admin do |admin| + # admin.site_title = "Custom Admin Title" + # end + # + # This will ONLY change the title for the admin section. Other + # namespaces will continue to use the main "site_title" configuration. # == User Authentication # - # Active Admin will automatically call an authentication - # method in a before filter of all controller actions to + # Active Admin will automatically call an authentication + # method in a before filter of all controller actions to # ensure that there is a currently logged in admin user. # # This setting changes the method which Active Admin calls - # within the controller. - config.authentication_method = false # Disabled for demo + # within the application controller. + config.authentication_method = false + + # == User Authorization + # + # Active Admin will automatically call an authorization + # method in a before filter of all controller actions to + # ensure that there is a user with proper rights. You can use + # CanCanAdapter or make your own. Please refer to documentation. + # config.authorization_adapter = ActiveAdmin::CanCanAdapter + + # In case you prefer Pundit over other solutions you can here pass + # the name of default policy class. This policy will be used in every + # case when Pundit is unable to find suitable policy. + # config.pundit_default_policy = "MyDefaultPunditPolicy" + # You can customize your CanCan Ability class name here. + # config.cancan_ability_class = "Ability" + + # You can specify a method to be called on unauthorized access. + # This is necessary in order to prevent a redirect loop which happens + # because, by default, user gets redirected to Dashboard. If user + # doesn't have access to Dashboard, he'll end up in a redirect loop. + # Method provided here should be defined in application_controller.rb. + # config.on_unauthorized_access = :access_denied # == Current User # @@ -41,50 +85,149 @@ # user performing them. # # This setting changes the method which Active Admin calls - # to return the currently logged in user. - config.current_user_method = false # Disabled for demo - + # (within the application controller) to return the currently logged in user. + config.current_user_method = false - # == Admin Notes - # - # Admin notes allow you to add notes to any model + # == Logging Out + # + # Active Admin displays a logout link on each screen. These + # settings configure the location and method used for the link. # - # Admin notes are enabled by default, but can be disabled - # by uncommenting this line: + # This setting changes the path where the link points to. If it's + # a string, the strings is used as the path. If it's a Symbol, we + # will call the method to return the path. # - config.admin_notes = true + # Default: + config.logout_link_path = :destroy_admin_user_session_path + # This setting changes the http method used when rendering the + # link. For example :get, :delete, :put, etc.. + # + # Default: + # config.logout_link_method = :get + + # == Root + # + # Set the action to call for the root path. You can set different + # roots for each namespace. + # + # Default: + # config.root_to = 'dashboard#index' + + # == Admin Comments + # + # This allows your users to comment on any resource registered with Active Admin. + # + # You can completely disable comments: + config.comments = false + # + # You can disable the menu item for the comments index page: + # config.show_comments_in_menu = false + # + # You can change the name under which comments are registered: + # config.comments_registration_name = 'AdminComment' + + # == Batch Actions + # + # Enable and disable Batch Actions + # + config.batch_actions = true # == Controller Filters # # You can add before, after and around filters to all of your - # Active Admin resources from here. + # Active Admin resources and pages from here. # # config.before_filter :do_something_awesome + # == Setting a Favicon + # + # config.favicon = '/assets/favicon.ico' + + # == Removing Breadcrumbs + # + # Breadcrumbs are enabled by default. You can customize them for individual + # resources or you can disable them globally from here. + # + # config.breadcrumb = false # == Register Stylesheets & Javascripts # - # We recomend using the built in Active Admin layout and loading + # We recommend using the built in Active Admin layout and loading # up your own stylesheets / javascripts to customize the look # and feel. # # To load a stylesheet: - config.register_stylesheet 'admin.css' + # config.register_stylesheet 'my_stylesheet.css' + # + # You can provide an options hash for more control, which is passed along to stylesheet_link_tag(): + # config.register_stylesheet 'my_print_stylesheet.css', media: :print # # To load a javascript file: # config.register_javascript 'my_javascript.js' - # Set the action to call for the root path. You can set different - # roots for each namespace. - # Default: - # config.root_to = 'dashboard#index' + # == CSV options + # + # Set the CSV builder separator + # config.csv_options = { col_sep: ';' } + # + # Force the use of quotes + # config.csv_options = { force_quotes: true } - # == Batch Actions - # Enable and disable Batch Actions - config.batch_actions = false + # == Menu System + # + # You can add a navigation menu to be used in your application, or configure a provided menu + # + # To change the default utility navigation to show a link to your website & a logout btn + # + # config.namespace :admin do |admin| + # admin.build_menu :utility_navigation do |menu| + # menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank } + # admin.add_logout_button_to_menu menu + # end + # end + # + # If you wanted to add a static menu item to the default menu provided: + # + # config.namespace :admin do |admin| + # admin.build_menu :default do |menu| + # menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank } + # end + # end - # == CSV options - # Set the CSV builder separator (default is ",") - # config.csv_column_separator = ',' + # == Download Links + # + # You can disable download links on resource listing pages, + # or customize the formats shown per namespace/globally + # + # To disable/customize for the :admin namespace: + # + # config.namespace :admin do |admin| + # + # # Disable the links entirely + # admin.download_links = false + # + # # Only show XML & PDF options + # admin.download_links = [:xml, :pdf] + # + # # Enable/disable the links based on block + # # (for example, with cancan) + # admin.download_links = proc { can?(:view_download_links) } + # + # end + + # == Pagination + # + # Pagination is enabled by default for all resources. + # You can control the default per page count for all resources here. + # + # config.default_per_page = 30 + + # == Filters + # + # By default the index screen includes a "Filters" sidebar on the right + # hand side with a filter for each attribute of the registered model. + # You can enable or disable them for all resources here. + # + # config.filters = true end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb new file mode 100644 index 00000000..d2f4ec33 --- /dev/null +++ b/config/initializers/assets.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# Rails.application.config.assets.precompile += %w( search.js ) diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb new file mode 100644 index 00000000..7a06a89f --- /dev/null +++ b/config/initializers/cookies_serializer.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.action_dispatch.cookies_serializer = :json \ No newline at end of file diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index d67a16e4..664c956f 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -1,12 +1,19 @@ -# Use this hook to configure devise mailer, warden hooks and so forth. The first -# four configuration values can also be set straight in your models. +# Use this hook to configure devise mailer, warden hooks and so forth. +# Many of these configuration options can be set straight in your model. Devise.setup do |config| + # The secret key used by Devise. Devise uses this key to generate + # random tokens. Changing this key will render invalid all existing + # confirmation, reset password and unlock tokens in the database. + # config.secret_key = '5e2bafe98dc09b53b07e364767d74318e0e7be6f045b884bc864f711703071129a49742a3a3010d8985630b3759b3c75005c75e54903e2ead58bddb68543e326' + # ==> Mailer Configuration - # Configure the e-mail address which will be shown in DeviseMailer. - config.mailer_sender = "please-change-me@config-initializers-devise.com" + # Configure the e-mail address which will be shown in Devise::Mailer, + # note that it will be overwritten if you use your own mailer class + # with default "from" parameter. + config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com' # Configure the class responsible to send e-mails. - # config.mailer = "Devise::Mailer" + # config.mailer = 'Devise::Mailer' # ==> ORM configuration # Load and configure the ORM. Supports :active_record (default) and @@ -36,34 +43,83 @@ # to authenticate or find a user. Default is :email. config.case_insensitive_keys = [ :email ] + # Configure which authentication keys should have whitespace stripped. + # These keys will have whitespace before and after removed upon creating or + # modifying a user and when used to authenticate or find a user. Default is :email. + config.strip_whitespace_keys = [ :email ] + # Tell if authentication through request.params is enabled. True by default. + # It can be set to an array that will enable params authentication only for the + # given strategies, for example, `config.params_authenticatable = [:database]` will + # enable it only for database (email + password) authentication. # config.params_authenticatable = true - # Tell if authentication through HTTP Basic Auth is enabled. False by default. + # Tell if authentication through HTTP Auth is enabled. False by default. + # It can be set to an array that will enable http authentication only for the + # given strategies, for example, `config.http_authenticatable = [:database]` will + # enable it only for database authentication. The supported strategies are: + # :database = Support basic authentication with authentication key + password # config.http_authenticatable = false - # If http headers should be returned for AJAX requests. True by default. + # If 401 status code should be returned for AJAX requests. True by default. # config.http_authenticatable_on_xhr = true - # The realm used in Http Basic Authentication. "Application" by default. - # config.http_authentication_realm = "Application" + # The realm used in Http Basic Authentication. 'Application' by default. + # config.http_authentication_realm = 'Application' + + # It will change confirmation, password recovery and other workflows + # to behave the same regardless if the e-mail provided was right or wrong. + # Does not affect registerable. + # config.paranoid = true + + # By default Devise will store the user in session. You can skip storage for + # particular strategies by setting this option. + # Notice that if you are skipping storage for all authentication paths, you + # may want to disable generating routes to Devise's sessions controller by + # passing skip: :sessions to `devise_for` in your config/routes.rb + config.skip_session_storage = [:http_auth] + + # By default, Devise cleans up the CSRF token on authentication to + # avoid CSRF token fixation attacks. This means that, when using AJAX + # requests for sign in and sign up, you need to get a new CSRF token + # from the server. You can disable this option at your own risk. + # config.clean_up_csrf_token_on_authentication = true # ==> Configuration for :database_authenticatable # For bcrypt, this is the cost for hashing the password and defaults to 10. If # using other encryptors, it sets how many times you want the password re-encrypted. - config.stretches = 10 + # + # Limiting the stretches to just one in testing will increase the performance of + # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use + # a value less than 10 in other environments. Note that, for bcrypt (the default + # encryptor), the cost increases exponentially with the number of stretches (e.g. + # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation). + config.stretches = Rails.env.test? ? 1 : 10 # Setup a pepper to generate the encrypted password. - # config.pepper = "9718bf2f4e319216e2cf7915a6ba2ceae7de623250bb9654c7e4e607dd725447383c945da00588f66e4235340772e7735ef14b58f258c63c33c81c39a7fa05b2" + # config.pepper = 'f9b994aae36fa6e5d86a5215cb66b9fc09ccb9aa396f609618b6a99344f50f409f4673cd8ae9451b36ba3b6be26ebafc34940aabd67986b9aa1b83d780e6154d' # ==> Configuration for :confirmable - # The time you want to give your user to confirm his account. During this time - # he will be able to access your application without confirming. Default is 0.days - # When confirm_within is zero, the user won't be able to sign in without confirming. - # You can use this to let your user access some features of your application - # without confirming the account, but blocking it after a certain period - # (ie 2 days). - # config.confirm_within = 2.days + # A period that the user is allowed to access the website even without + # confirming their account. For instance, if set to 2.days, the user will be + # able to access the website for two days without confirming their account, + # access will be blocked just in the third day. Default is 0.days, meaning + # the user cannot access the website without confirming their account. + # config.allow_unconfirmed_access_for = 2.days + + # A period that the user is allowed to confirm their account before their + # token becomes invalid. For example, if set to 3.days, the user can confirm + # their account within 3 days after the mail was sent, but on the fourth day + # their account can't be confirmed with the token any more. + # Default is nil, meaning there is no restriction on how long a user can take + # before confirming their account. + # config.confirm_within = 3.days + + # If true, requires any email changes to be confirmed (exactly the same way as + # initial account confirmation) to be applied. Requires additional unconfirmed_email + # db field (see migrations). Until confirmed, new email is stored in + # unconfirmed_email column, and copied to email column on successful confirmation. + config.reconfirmable = true # Defines which key will be used when confirming an account # config.confirmation_keys = [ :email ] @@ -72,28 +128,33 @@ # The time the user will be remembered without asking for credentials again. # config.remember_for = 2.weeks - # If true, a valid remember token can be re-used between multiple browsers. - # config.remember_across_browsers = true + # Invalidates all the remember me tokens when the user signs out. + config.expire_all_remember_me_on_sign_out = true # If true, extends the user's remember period when remembered via cookie. # config.extend_remember_period = false - # If true, uses the password salt as remember token. This should be turned - # to false if you are not using database authenticatable. - config.use_salt_as_remember_token = true + # Options to be passed to the created cookie. For instance, you can set + # secure: true in order to force SSL only cookies. + # config.rememberable_options = {} # ==> Configuration for :validatable - # Range for password length. Default is 6..20. - # config.password_length = 6..20 + # Range for password length. + config.password_length = 8..128 - # Regex to use to validate the email address - # config.email_regexp = /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i + # Email regex used to validate email formats. It simply asserts that + # one (and only one) @ exists in the given string. This is mainly + # to give user feedback and not to assert the e-mail validity. + # config.email_regexp = /\A[^@]+@[^@]+\z/ # ==> Configuration for :timeoutable # The time you want to timeout the user session without activity. After this # time the user will be asked for credentials again. Default is 30 minutes. # config.timeout_in = 30.minutes + # If true, expires auth token on session timeout. + # config.expire_auth_token_on_timeout = false + # ==> Configuration for :lockable # Defines which strategy will be used to lock an account. # :failed_attempts = Locks an account after a number of failed attempts to sign in. @@ -117,27 +178,29 @@ # Time interval to unlock the account if :time is enabled as unlock_strategy. # config.unlock_in = 1.hour + # Warn on the last attempt before the account is locked. + # config.last_attempt_warning = true + # ==> Configuration for :recoverable # # Defines which key will be used when recovering the password for an account # config.reset_password_keys = [ :email ] + # Time interval you can reset your password with a reset password key. + # Don't put a too small interval or your users won't have the time to + # change their passwords. + config.reset_password_within = 6.hours + # ==> Configuration for :encryptable # Allow you to use another encryption algorithm besides bcrypt (default). You can use # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1, # :authlogic_sha512 (then you should set stretches above to 20 for default behavior) # and :restful_authentication_sha1 (then you should set stretches to 10, and copy - # REST_AUTH_SITE_KEY to pepper) + # REST_AUTH_SITE_KEY to pepper). + # + # Require the `devise-encryptable` gem when using anything other than bcrypt # config.encryptor = :sha512 - # ==> Configuration for :token_authenticatable - # Defines name of the authentication token params key - # config.token_authentication_key = :auth_token - - # If true, authentication through token does not store user in session and needs - # to be supplied on each request. Useful if you are using the token as API token. - # config.stateless_token = false - # ==> Scopes configuration # Turn scoped views on. Before rendering "sessions/new", it will first check for # "users/sessions/new". It's turned off by default because it's slower if you @@ -148,9 +211,8 @@ # devise role declared in your routes (usually :user). # config.default_scope = :user - # Configure sign_out behavior. - # Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope). - # The default is true, which means any logout action will sign out all active scopes. + # Set this configuration to false if you want /users/sign_out to sign out + # only the current scope. By default, Devise signs out all scopes. # config.sign_out_all_scopes = true # ==> Navigation configuration @@ -161,25 +223,37 @@ # If you have any extra navigational formats, like :iphone or :mobile, you # should add them to the navigational formats lists. # - # The :"*/*" and "*/*" formats below is required to match Internet - # Explorer requests. - # config.navigational_formats = [:"*/*", "*/*", :html] + # The "*/*" below is required to match Internet Explorer requests. + # config.navigational_formats = ['*/*', :html] - # The default HTTP method used to sign out a resource. Default is :get. - # config.sign_out_via = :get + # The default HTTP method used to sign out a resource. Default is :delete. + config.sign_out_via = :delete # ==> OmniAuth # Add a new OmniAuth provider. Check the wiki for more information on setting # up on your models and hooks. - # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo' + # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo' # ==> Warden configuration # If you want to use other strategies, that are not supported by Devise, or # change the failure app, you can configure them inside the config.warden block. # # config.warden do |manager| - # manager.failure_app = AnotherApp # manager.intercept_401 = false - # manager.default_strategies(:scope => :user).unshift :some_external_strategy + # manager.default_strategies(scope: :user).unshift :some_external_strategy # end + + # ==> Mountable engine configurations + # When using Devise inside an engine, let's call it `MyEngine`, and this engine + # is mountable, there are some extra configurations to be taken into account. + # The following options are available, assuming the engine is mounted as: + # + # mount MyEngine, at: '/my_engine' + # + # The router that invoked `devise_for`, in the example above, would be: + # config.router_name = :my_engine + # + # When using omniauth, Devise cannot automatically set Omniauth path, + # so you need to do it manually. For the users scope, it would be: + # config.omniauth_path_prefix = '/my_engine/users/auth' end diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 00000000..4a994e1e --- /dev/null +++ b/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/config/initializers/hoptoad.rb b/config/initializers/hoptoad.rb deleted file mode 100644 index bd25977d..00000000 --- a/config/initializers/hoptoad.rb +++ /dev/null @@ -1,3 +0,0 @@ -HoptoadNotifier.configure do |config| - config.api_key = '7c86674ea7d0f9d2b9328952f684da86' -end diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 9e8b0131..ac033bf9 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -1,10 +1,16 @@ # Be sure to restart your server when you modify this file. -# Add new inflection rules using the following format -# (all these examples are active by default): -# ActiveSupport::Inflector.inflections do |inflect| +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) # end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index 72aca7e4..dc189968 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -2,4 +2,3 @@ # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf -# Mime::Type.register_alias "text/html", :iphone diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb deleted file mode 100644 index 10bad977..00000000 --- a/config/initializers/secret_token.rb +++ /dev/null @@ -1,7 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Your secret key for verifying the integrity of signed cookies. -# If you change this key, all old signed cookies will become invalid! -# Make sure the secret is at least 30 characters and all random, -# no regular words or you'll be exposed to dictionary attacks. -ActiveadminDepot::Application.config.secret_token = '4b2194ea93095b4a467eeca458aba0fe63cef03e758c7521048930b8f06a807c34c23918cccb4b00fc66e3c4ac06ef1d290a05a71b20ad90b2e4fc4e99920030' diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 3e0ce815..0e3c0446 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,8 +1,3 @@ # Be sure to restart your server when you modify this file. -ActiveadminDepot::Application.config.session_store :cookie_store, :key => '_activeadmin-depot_session' - -# Use the database for sessions instead of the cookie-based default, -# which shouldn't be used to store highly confidential information -# (create the session table with "rake db:sessions:create") -# ActiveadminDepot::Application.config.session_store :active_record_store +Rails.application.config.session_store :cookie_store, key: '_activeadmin_depot_session' diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb new file mode 100644 index 00000000..33725e95 --- /dev/null +++ b/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] if respond_to?(:wrap_parameters) +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml index e70ad899..26a10f29 100644 --- a/config/locales/devise.en.yml +++ b/config/locales/devise.en.yml @@ -1,48 +1,60 @@ -# Additional translations at http://github.com/plataformatec/devise/wiki/I18n +# Additional translations at https://github.com/plataformatec/devise/wiki/I18n en: + devise: + confirmations: + confirmed: "Your email address has been successfully confirmed." + send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes." + send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes." + failure: + already_authenticated: "You are already signed in." + inactive: "Your account is not activated yet." + invalid: "Invalid %{authentication_keys} or password." + locked: "Your account is locked." + last_attempt: "You have one more attempt before your account is locked." + not_found_in_database: "Invalid %{authentication_keys} or password." + timeout: "Your session expired. Please sign in again to continue." + unauthenticated: "You need to sign in or sign up before continuing." + unconfirmed: "You have to confirm your email address before continuing." + mailer: + confirmation_instructions: + subject: "Confirmation instructions" + reset_password_instructions: + subject: "Reset password instructions" + unlock_instructions: + subject: "Unlock instructions" + omniauth_callbacks: + failure: "Could not authenticate you from %{kind} because \"%{reason}\"." + success: "Successfully authenticated from %{kind} account." + passwords: + no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided." + send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes." + send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes." + updated: "Your password has been changed successfully. You are now signed in." + updated_not_active: "Your password has been changed successfully." + registrations: + destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon." + signed_up: "Welcome! You have signed up successfully." + signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated." + signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked." + signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account." + update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirm link to confirm your new email address." + updated: "Your account has been updated successfully." + sessions: + signed_in: "Signed in successfully." + signed_out: "Signed out successfully." + already_signed_out: "Signed out successfully." + unlocks: + send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes." + send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes." + unlocked: "Your account has been unlocked successfully. Please sign in to continue." errors: messages: - not_found: "not found" already_confirmed: "was already confirmed, please try signing in" + confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one" + expired: "has expired, please request a new one" + not_found: "not found" not_locked: "was not locked" not_saved: one: "1 error prohibited this %{resource} from being saved:" other: "%{count} errors prohibited this %{resource} from being saved:" - - devise: - failure: - unauthenticated: 'You need to sign in or sign up before continuing.' - unconfirmed: 'You have to confirm your account before continuing.' - locked: 'Your account is locked.' - invalid: 'Invalid email or password.' - invalid_token: 'Invalid authentication token.' - timeout: 'Your session expired, please sign in again to continue.' - inactive: 'Your account was not activated yet.' - sessions: - signed_in: 'Signed in successfully.' - signed_out: 'Signed out successfully.' - passwords: - send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.' - updated: 'Your password was changed successfully. You are now signed in.' - confirmations: - send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.' - confirmed: 'Your account was successfully confirmed. You are now signed in.' - registrations: - signed_up: 'Welcome! You have signed up successfully.' - inactive_signed_up: 'You have signed up successfully. However, we could not sign you in because your account is %{reason}.' - updated: 'You updated your account successfully.' - destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.' - unlocks: - send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.' - unlocked: 'Your account was successfully unlocked. You are now signed in.' - omniauth_callbacks: - success: 'Successfully authorized from %{kind} account.' - failure: 'Could not authorize you from %{kind} because "%{reason}".' - mailer: - confirmation_instructions: - subject: 'Confirmation instructions' - reset_password_instructions: - subject: 'Reset password instructions' - unlock_instructions: - subject: 'Unlock Instructions' diff --git a/config/locales/en.yml b/config/locales/en.yml index a747bfa6..06539571 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,5 +1,23 @@ -# Sample localization file for English. Add more files in this directory for other locales. -# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. en: hello: "Hello world" diff --git a/config/newrelic.yml b/config/newrelic.yml index a841f225..92691739 100644 --- a/config/newrelic.yml +++ b/config/newrelic.yml @@ -15,7 +15,7 @@ common: &default_settings # account. This key binds your Agent's data to your account in the # New Relic service. license_key: '7e5d5ad840f8474c589df050633543adbee7f351' - + # Agent Enabled (Rails Only) # Use this setting to force the agent to run or not run. # Default is 'auto' which means the agent will install and run only @@ -24,20 +24,20 @@ common: &default_settings # completely turn the agent off regardless of the other settings. # Valid values are true, false and auto. # agent_enabled: auto - + # Application Name # Set this to be the name of your application as you'd like it show # up in New Relic. New Relic will then auto-map instances of your application # into a New Relic "application" on your home dashboard page. If you want # to map this instance into multiple apps, like "AJAX Requests" and # "All UI" then specify a semicolon separated list of up to three - # distinct names. If you comment this out, it defaults to the + # distinct names. If you comment this out, it defaults to the # capitalized RAILS_ENV (i.e., Production, Staging, etc) app_name: Active Admin Demo - # When "true", the agent collects performance data about your + # When "true", the agent collects performance data about your # application and reports this data to the New Relic service at - # newrelic.com. This global switch is normally overridden for each + # newrelic.com. This global switch is normally overridden for each # environment below. (formerly called 'enabled') monitor_mode: true @@ -49,7 +49,7 @@ common: &default_settings # information separate from that of your application. Specify its # log level here. log_level: info - + # The newrelic agent communicates with the New Relic service via http by # default. If you want to communicate via https to increase # security, then turn on SSL by setting this value to true. Note, @@ -69,14 +69,14 @@ common: &default_settings # use a non-blocking lookup, so in a worst case, if you have DNS # problems, your app may block indefinitely. # verify_certificate: true - + # Set your application's Apdex threshold value with the 'apdex_t' # setting, in seconds. The apdex_t value determines the buckets used - # to compute your overall Apdex score. + # to compute your overall Apdex score. # Requests that take less than apdex_t seconds to process will be # classified as Satisfying transactions; more than apdex_t seconds # as Tolerating transactions; and more than four times the apdex_t - # value as Frustrating transactions. + # value as Frustrating transactions. # For more about the Apdex standard, see # http://support.newrelic.com/faqs/general/apdex @@ -92,14 +92,14 @@ common: &default_settings # proxy_user: # proxy_pass: - + # Tells transaction tracer and error collector (when enabled) # whether or not to capture HTTP params. When true, frameworks can # exclude HTTP parameters from being captured. # Rails: the RoR filter_parameter_logging excludes parameters # Java: create a config setting called "ignored_params" and set it to # a comma separated list of HTTP parameter names. - # ex: ignored_params: credit_card, ssn, password + # ex: ignored_params: credit_card, ssn, password capture_params: false @@ -108,12 +108,12 @@ common: &default_settings # minute. Included in the transaction is the exact call sequence of # the transactions including any SQL statements issued. transaction_tracer: - + # Transaction tracer is enabled by default. Set this to false to # turn it off. This feature is only available at the Silver and # above product levels. enabled: true - + # Threshold in seconds for when to collect a transaction # trace. When the response time of a controller action exceeds # this threshold, a transaction trace will be recorded and sent to @@ -121,13 +121,13 @@ common: &default_settings # which will use the threshold for an dissatisfying Apdex # controller action - four times the Apdex T value. transaction_threshold: apdex_f - + # When transaction tracer is on, SQL statements can optionally be # recorded. The recorder has three modes, "off" which sends no # SQL, "raw" which sends the SQL statement in its original form, # and "obfuscated", which strips out numeric and string literals record_sql: obfuscated - + # Threshold in seconds for when to collect stack trace for a SQL # call. In other words, when SQL statements exceed this threshold, # then capture and send to New Relic the current stack trace. This is @@ -139,24 +139,24 @@ common: &default_settings # set to false when using other adapters. # explain_enabled: true - # Threshold for query execution time below which query plans will not + # Threshold for query execution time below which query plans will not # not be captured. Relevant only when `explain_enabled` is true. # explain_threshold: 0.5 - + # Error collector captures information about uncaught exceptions and # sends them to New Relic for viewing error_collector: - + # Error collector is enabled by default. Set this to false to turn # it off. This feature is only available at the Silver and above # product levels enabled: true - - # Rails Only - tells error collector whether or not to capture a - # source snippet around the place of the error when errors are View + + # Rails Only - tells error collector whether or not to capture a + # source snippet around the place of the error when errors are View # related. - capture_source: true - + capture_source: true + # To stop specific errors from reporting to New Relic, set this property # to comma separated values. Default is to ignore routing errors # which are how 404's get triggered. @@ -167,7 +167,7 @@ common: &default_settings # won't run. Useful when you are using the agent to monitor an # external resource # disable_samplers: true - + # If you aren't interested in visibility in these areas, you can # disable the instrumentation to reduce overhead. # @@ -175,8 +175,8 @@ common: &default_settings # disable_activerecord_instrumentation: true # disable_memcache_instrumentation: true # disable_dj: true - - # Certain types of instrumentation such as GC stats will not work if + + # Certain types of instrumentation such as GC stats will not work if # you are running multi-threaded. Please let us know. # multi_threaded = false @@ -194,17 +194,17 @@ development: <<: *default_settings # Turn off communication to New Relic service in development mode (also # 'enabled'). - # NOTE: for initial evaluation purposes, you may want to temporarily + # NOTE: for initial evaluation purposes, you may want to temporarily # turn the agent on in development mode. monitor_mode: false - # Rails Only - when running in Developer Mode, the New Relic Agent will + # Rails Only - when running in Developer Mode, the New Relic Agent will # present performance information on the last 100 transactions you have # executed since starting the mongrel. # NOTE: There is substantial overhead when running in developer mode. - # Do not use for production or load testing. + # Do not use for production or load testing. developer_mode: true - + # Enable textmate links # textmate: true diff --git a/config/routes.rb b/config/routes.rb index 2f452978..a910a9bf 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,17 +1,16 @@ -ActiveadminDepot::Application.routes.draw do - +Rails.application.routes.draw do + devise_for :admin_users, ActiveAdmin::Devise.config ActiveAdmin.routes(self) - devise_for :admin_users, ActiveAdmin::Devise.config get "cart" => "cart#show" get "cart/add/:id" => "cart#add", :as => :add_to_cart post "cart/remove/:id" => "cart#remove", :as => :remove_from_cart post "cart/checkout" => "cart#checkout", :as => :checkout - match 'signup' => 'users#new', :as => :signup - match 'logout' => 'sessions#destroy', :as => :logout - match 'login' => 'sessions#new', :as => :login + get 'signup' => 'users#new', :as => :signup + get 'logout' => 'sessions#destroy', :as => :logout + get 'login' => 'sessions#new', :as => :login resources :sessions resources :users resources :products diff --git a/config/secrets.yml b/config/secrets.yml new file mode 100644 index 00000000..0660bf98 --- /dev/null +++ b/config/secrets.yml @@ -0,0 +1,22 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rake secret` to generate a secure secret key. + +# Make sure the secrets in this file are kept private +# if you're sharing your code publicly. + +development: + secret_key_base: 4ba6ea84254b1ace36aa06befe42d66ac6361d8698f5b22879f9efc766d012c88cf3abfb1f8802cab80df57a632dc3f31c1cede30200e83fb4080d624eb263e1 + +test: + secret_key_base: 067ec02525df5709cd639a62f9663ba9d14702a2f5d8b83929807bc0e076a1bc6cefa59f30cd83c44009640dede2f94533e071dba4ab02f7bca367ac11e7b01e + +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/config/unicorn.rb b/config/unicorn.rb index 0a45441c..11d92ce2 100644 --- a/config/unicorn.rb +++ b/config/unicorn.rb @@ -1,35 +1,19 @@ -# config/unicorn.rb - worker_processes 3 timeout 30 preload_app true before_fork do |server, worker| - # Replace with MongoDB or whatever if defined?(ActiveRecord::Base) ActiveRecord::Base.connection.disconnect! Rails.logger.info('Disconnected from ActiveRecord') end - # If you are using Redis but not Resque, change this - if defined?(Resque) - Resque.redis.quit - Rails.logger.info('Disconnected from Redis') - end - sleep 1 end after_fork do |server, worker| - # Replace with MongoDB or whatever if defined?(ActiveRecord::Base) ActiveRecord::Base.establish_connection Rails.logger.info('Connected to ActiveRecord') end - - # If you are using Redis but not Resque, change this - if defined?(Resque) - Resque.redis = ENV['REDIS_URI'] - Rails.logger.info('Connected to Redis') - end end diff --git a/db/migrate/20101005233926_create_products.rb b/db/migrate/20101005233926_create_products.rb index 8041b5bf..59a1f3d9 100644 --- a/db/migrate/20101005233926_create_products.rb +++ b/db/migrate/20101005233926_create_products.rb @@ -1,20 +1,17 @@ class CreateProducts < ActiveRecord::Migration - def self.up + def change create_table :products do |t| t.string :title t.text :description t.string :author - t.decimal :price, :precision => 8, :scale => 2 + t.decimal :price t.boolean :featured t.date :available_on t.string :image_file_name + t.timestamps end add_index :products, :featured add_index :products, :available_on end - - def self.down - drop_table :products - end end diff --git a/db/migrate/20101005234527_create_users.rb b/db/migrate/20101005234527_create_users.rb index 8401e8ad..51d25e0f 100644 --- a/db/migrate/20101005234527_create_users.rb +++ b/db/migrate/20101005234527_create_users.rb @@ -1,15 +1,12 @@ class CreateUsers < ActiveRecord::Migration - def self.up + def change create_table :users do |t| t.string :username t.string :email t.string :password_hash t.string :password_salt + t.timestamps end end - - def self.down - drop_table :users - end end diff --git a/db/migrate/20101005235210_create_orders.rb b/db/migrate/20101005235210_create_orders.rb index 4c6f7e10..b4f2b0ea 100644 --- a/db/migrate/20101005235210_create_orders.rb +++ b/db/migrate/20101005235210_create_orders.rb @@ -1,16 +1,13 @@ class CreateOrders < ActiveRecord::Migration - def self.up + def change create_table :orders do |t| t.integer :user_id t.datetime :checked_out_at - t.decimal :total_price, :precision => 8, :scale => 2, :default => 0 + t.decimal :total_price ,:precision => 8, :scale => 2, :default => 0.0 + t.timestamps end add_index :orders, :user_id add_index :orders, :checked_out_at end - - def self.down - drop_table :orders - end end diff --git a/db/migrate/20101005235320_create_line_items.rb b/db/migrate/20101005235320_create_line_items.rb index 5c617ecc..c3bf1950 100644 --- a/db/migrate/20101005235320_create_line_items.rb +++ b/db/migrate/20101005235320_create_line_items.rb @@ -1,16 +1,13 @@ class CreateLineItems < ActiveRecord::Migration - def self.up + def change create_table :line_items do |t| t.integer :order_id t.integer :product_id t.decimal :price + t.timestamps end add_index :line_items, :order_id add_index :line_items, :product_id end - - def self.down - drop_table :line_items - end end diff --git a/db/migrate/201104120621_create_admin_notes.rb b/db/migrate/201104120621_create_admin_notes.rb deleted file mode 100644 index a2d3247e..00000000 --- a/db/migrate/201104120621_create_admin_notes.rb +++ /dev/null @@ -1,16 +0,0 @@ -class CreateAdminNotes < ActiveRecord::Migration - def self.up - create_table :admin_notes do |t| - t.references :resource, :polymorphic => true, :null => false - t.references :admin_user, :polymorphic => true - t.text :body - t.timestamps - end - add_index :admin_notes, [:resource_type, :resource_id] - add_index :admin_notes, [:admin_user_type, :admin_user_id] - end - - def self.down - drop_table :admin_notes - end -end diff --git a/db/migrate/20110412132112_devise_create_admin_users.rb b/db/migrate/20110412132112_devise_create_admin_users.rb index 5585441b..9674a875 100644 --- a/db/migrate/20110412132112_devise_create_admin_users.rb +++ b/db/migrate/20110412132112_devise_create_admin_users.rb @@ -1,31 +1,48 @@ class DeviseCreateAdminUsers < ActiveRecord::Migration - def self.up + def migrate(direction) + super + # Create a default user + AdminUser.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password') if direction == :up + end + + def change create_table(:admin_users) do |t| - t.database_authenticatable :null => false - t.recoverable - t.rememberable - t.trackable + ## Database authenticatable + t.string :email, null: false, default: "" + t.string :encrypted_password, null: false, default: "" - # t.encryptable - # t.confirmable - # t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both - # t.token_authenticatable + ## Recoverable + t.string :reset_password_token + t.datetime :reset_password_sent_at + ## Rememberable + t.datetime :remember_created_at - t.timestamps - end + ## Trackable + t.integer :sign_in_count, default: 0, null: false + t.datetime :current_sign_in_at + t.datetime :last_sign_in_at + t.string :current_sign_in_ip + t.string :last_sign_in_ip - # Create a default admin user - AdminUser.create!(:email => 'admin@example.com', :password => 'password', :password_confirmation => 'password') + ## Confirmable + # t.string :confirmation_token + # t.datetime :confirmed_at + # t.datetime :confirmation_sent_at + # t.string :unconfirmed_email # Only if using reconfirmable - add_index :admin_users, :email, :unique => true - add_index :admin_users, :reset_password_token, :unique => true - # add_index :admin_users, :confirmation_token, :unique => true - # add_index :admin_users, :unlock_token, :unique => true - # add_index :admin_users, :authentication_token, :unique => true - end + ## Lockable + # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts + # t.string :unlock_token # Only if unlock strategy is :email or :both + # t.datetime :locked_at + + + t.timestamps + end - def self.down - drop_table :admin_users + add_index :admin_users, :email, unique: true + add_index :admin_users, :reset_password_token, unique: true + # add_index :admin_users, :confirmation_token, unique: true + # add_index :admin_users, :unlock_token, unique: true end end diff --git a/db/migrate/20110426072324_create_active_admin_comments.rb b/db/migrate/20110426072324_create_active_admin_comments.rb new file mode 100644 index 00000000..9efd1478 --- /dev/null +++ b/db/migrate/20110426072324_create_active_admin_comments.rb @@ -0,0 +1,19 @@ +class CreateActiveAdminComments < ActiveRecord::Migration + def self.up + create_table :active_admin_comments do |t| + t.string :namespace + t.text :body + t.string :resource_id, null: false + t.string :resource_type, null: false + t.references :author, polymorphic: true + t.timestamps + end + add_index :active_admin_comments, [:namespace] + add_index :active_admin_comments, [:author_type, :author_id] + add_index :active_admin_comments, [:resource_type, :resource_id] + end + + def self.down + drop_table :active_admin_comments + end +end diff --git a/db/migrate/20110426072324_move_admin_notes_to_comments.rb b/db/migrate/20110426072324_move_admin_notes_to_comments.rb deleted file mode 100644 index 8e37ec46..00000000 --- a/db/migrate/20110426072324_move_admin_notes_to_comments.rb +++ /dev/null @@ -1,25 +0,0 @@ -class MoveAdminNotesToComments < ActiveRecord::Migration - def self.up - remove_index :admin_notes, [:admin_user_type, :admin_user_id] - rename_table :admin_notes, :active_admin_comments - rename_column :active_admin_comments, :admin_user_type, :author_type - rename_column :active_admin_comments, :admin_user_id, :author_id - add_column :active_admin_comments, :namespace, :string - add_index :active_admin_comments, [:namespace] - add_index :active_admin_comments, [:author_type, :author_id] - - # Update all the existing comments to the default namespace - say "Updating any existing comments to the #{ActiveAdmin.default_namespace} namespace." - execute "UPDATE active_admin_comments SET namespace='#{ActiveAdmin.default_namespace}'" - end - - def self.down - remove_index :active_admin_comments, :column => [:author_type, :author_id] - remove_index :active_admin_comments, :column => [:namespace] - remove_column :active_admin_comments, :namespace - rename_column :active_admin_comments, :author_id, :admin_user_id - rename_column :active_admin_comments, :author_type, :admin_user_type - rename_table :active_admin_comments, :admin_notes - add_index :admin_notes, [:admin_user_type, :admin_user_id] - end -end diff --git a/db/schema.rb b/db/schema.rb index d527016a..16261598 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. @@ -8,31 +9,32 @@ # from scratch. The latter is a flawed and unsustainable approach (the more migrations # you'll amass, the slower it'll run and the greater likelihood for issues). # -# It's strongly recommended to check this file into your version control system. +# It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(:version => 20110426072324) do +ActiveRecord::Schema.define(version: 20110426072324) do - create_table "active_admin_comments", :force => true do |t| - t.integer "resource_id", :null => false - t.string "resource_type", :null => false + create_table "active_admin_comments", force: true do |t| + t.string "namespace" + t.text "body" + t.string "resource_id", null: false + t.string "resource_type", null: false t.integer "author_id" t.string "author_type" - t.text "body" t.datetime "created_at" t.datetime "updated_at" - t.string "namespace" end - add_index "active_admin_comments", ["author_type", "author_id"], :name => "index_active_admin_comments_on_author_type_and_author_id" - add_index "active_admin_comments", ["namespace"], :name => "index_active_admin_comments_on_namespace" - add_index "active_admin_comments", ["resource_type", "resource_id"], :name => "index_admin_notes_on_resource_type_and_resource_id" + add_index "active_admin_comments", ["author_type", "author_id"], name: "index_active_admin_comments_on_author_type_and_author_id" + add_index "active_admin_comments", ["namespace"], name: "index_active_admin_comments_on_namespace" + add_index "active_admin_comments", ["resource_type", "resource_id"], name: "index_active_admin_comments_on_resource_type_and_resource_id" - create_table "admin_users", :force => true do |t| - t.string "email", :default => "", :null => false - t.string "encrypted_password", :limit => 128, :default => "", :null => false + create_table "admin_users", force: true do |t| + t.string "email", default: "", null: false + t.string "encrypted_password", default: "", null: false t.string "reset_password_token" + t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", :default => 0 + t.integer "sign_in_count", default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" @@ -41,10 +43,10 @@ t.datetime "updated_at" end - add_index "admin_users", ["email"], :name => "index_admin_users_on_email", :unique => true - add_index "admin_users", ["reset_password_token"], :name => "index_admin_users_on_reset_password_token", :unique => true + add_index "admin_users", ["email"], name: "index_admin_users_on_email", unique: true + add_index "admin_users", ["reset_password_token"], name: "index_admin_users_on_reset_password_token", unique: true - create_table "line_items", :force => true do |t| + create_table "line_items", force: true do |t| t.integer "order_id" t.integer "product_id" t.decimal "price" @@ -52,25 +54,25 @@ t.datetime "updated_at" end - add_index "line_items", ["order_id"], :name => "index_line_items_on_order_id" - add_index "line_items", ["product_id"], :name => "index_line_items_on_product_id" + add_index "line_items", ["order_id"], name: "index_line_items_on_order_id" + add_index "line_items", ["product_id"], name: "index_line_items_on_product_id" - create_table "orders", :force => true do |t| + create_table "orders", force: true do |t| t.integer "user_id" t.datetime "checked_out_at" - t.decimal "total_price", :precision => 8, :scale => 2, :default => 0.0 + t.decimal "total_price", precision: 8, scale: 2, default: 0.0 t.datetime "created_at" t.datetime "updated_at" end - add_index "orders", ["checked_out_at"], :name => "index_orders_on_checked_out_at" - add_index "orders", ["user_id"], :name => "index_orders_on_user_id" + add_index "orders", ["checked_out_at"], name: "index_orders_on_checked_out_at" + add_index "orders", ["user_id"], name: "index_orders_on_user_id" - create_table "products", :force => true do |t| + create_table "products", force: true do |t| t.string "title" t.text "description" t.string "author" - t.decimal "price", :precision => 8, :scale => 2 + t.decimal "price" t.boolean "featured" t.date "available_on" t.string "image_file_name" @@ -78,10 +80,10 @@ t.datetime "updated_at" end - add_index "products", ["available_on"], :name => "index_products_on_available_on" - add_index "products", ["featured"], :name => "index_products_on_featured" + add_index "products", ["available_on"], name: "index_products_on_available_on" + add_index "products", ["featured"], name: "index_products_on_featured" - create_table "users", :force => true do |t| + create_table "users", force: true do |t| t.string "username" t.string "email" t.string "password_hash" diff --git a/db/seeds.rb b/db/seeds.rb index 9d446695..286e70d6 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -7,19 +7,6 @@ # Mayor.create(:name => 'Daley', :city => cities.first) # -# Create default admin user -AdminUser.create! do |a| - a.email = 'admin@example.com' - a.password = a.password_confirmation = 'password' -end - -# Create default user -User.create! do |u| - u.username = 'user' - u.email = 'user@example.com' - u.password = u.password_confirmation = 'password' -end - # Load each product from the yaml file YAML.load_file(File.expand_path("../seeds/products.yml", __FILE__)).each do |product| Product.create! product diff --git a/db/seeds/products.yml b/db/seeds/products.yml index 9562cfa6..1f4fd219 100644 --- a/db/seeds/products.yml +++ b/db/seeds/products.yml @@ -167,4 +167,4 @@ :author: "Russ Olsen " :title: Eloquent Ruby (Addison-Wesley Professional Ruby Series) :image_file_name: eloquent-ruby-addison-wesley-professional-ruby-series-.jpg - :available_on: 2011-02-16 + :available_on: 2011-02-16 \ No newline at end of file diff --git a/doc/README_FOR_APP b/doc/README_FOR_APP deleted file mode 100644 index fe41f5cc..00000000 --- a/doc/README_FOR_APP +++ /dev/null @@ -1,2 +0,0 @@ -Use this README file to introduce your application and point to useful places in the API for learning more. -Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries. diff --git a/lib/assets/.keep b/lib/assets/.keep new file mode 100644 index 00000000..e69de29b diff --git a/lib/authentication.rb b/lib/authentication.rb index 94fd2955..de854ac7 100644 --- a/lib/authentication.rb +++ b/lib/authentication.rb @@ -43,6 +43,6 @@ def redirect_to_target_or_default(default) private def store_target_location - session[:return_to] = request.request_uri + session[:return_to] = request.url end end diff --git a/lib/tasks/.keep b/lib/tasks/.keep new file mode 100644 index 00000000..e69de29b diff --git a/log/.keep b/log/.keep new file mode 100644 index 00000000..e69de29b diff --git a/public/404.html b/public/404.html index 9a48320a..b612547f 100644 --- a/public/404.html +++ b/public/404.html @@ -2,25 +2,66 @@
You may have mistyped the address or the page may have moved.
+You may have mistyped the address or the page may have moved.
+If you are the application owner check the logs for more information.
Maybe you tried to change something you didn't have access to.
+Maybe you tried to change something you didn't have access to.
+If you are the application owner check the logs for more information.
We've been notified about this issue and we'll take a look at it shortly.
+If you are the application owner check the logs for more information.
=0))l||m.push(v);else if(l)h[p]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()}, -CHILD:function(g){if(g[1]==="nth"){var h=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=h[1]+(h[2]||1)-0;g[3]=h[3]-0}g[0]=e++;return g},ATTR:function(g,h,l,m,q,p){h=g[1].replace(/\\/g,"");if(!p&&n.attrMap[h])g[1]=n.attrMap[h];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,h,l,m,q){if(g[1]==="not")if((f.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=k(g[3],null,null,h);else{g=k.filter(g[3],h,l,true^q);l||m.push.apply(m, -g);return false}else if(n.match.POS.test(g[0])||n.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,h,l){return!!k(l[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)}, -text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}}, -setFilters:{first:function(g,h){return h===0},last:function(g,h,l,m){return h===m.length-1},even:function(g,h){return h%2===0},odd:function(g,h){return h%2===1},lt:function(g,h,l){return hl[3]-0},nth:function(g,h,l){return l[3]-0===h},eq:function(g,h,l){return l[3]-0===h}},filter:{PSEUDO:function(g,h,l,m){var q=h[1],p=n.filters[q];if(p)return p(g,l,h,m);else if(q==="contains")return(g.textContent||g.innerText||a([g])||"").indexOf(h[3])>=0;else if(q==="not"){h= -h[3];l=0;for(m=h.length;l =0}},ID:function(g,h){return g.nodeType===1&&g.getAttribute("id")===h},TAG:function(g,h){return h==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===h},CLASS:function(g,h){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(h)>-1},ATTR:function(g,h){var l=h[1];g=n.attrHandle[l]?n.attrHandle[l](g):g[l]!=null?g[l]:g.getAttribute(l);l=g+"";var m=h[2];h=h[4];return g==null?m==="!=":m=== -"="?l===h:m==="*="?l.indexOf(h)>=0:m==="~="?(" "+l+" ").indexOf(h)>=0:!h?l&&g!==false:m==="!="?l!==h:m==="^="?l.indexOf(h)===0:m==="$="?l.substr(l.length-h.length)===h:m==="|="?l===h||l.substr(0,h.length+1)===h+"-":false},POS:function(g,h,l,m){var q=n.setFilters[h[2]];if(q)return q(g,l,h,m)}}},r=n.match.POS;for(var u in n.match){n.match[u]=new RegExp(n.match[u].source+/(?![^\[]*\])(?![^\(]*\))/.source);n.leftMatch[u]=new RegExp(/(^(?:.|\r|\n)*?)/.source+n.match[u].source.replace(/\\(\d+)/g,function(g, -h){return"\\"+(h-0+1)}))}var z=function(g,h){g=Array.prototype.slice.call(g,0);if(h){h.push.apply(h,g);return h}return g};try{Array.prototype.slice.call(s.documentElement.childNodes,0)}catch(C){z=function(g,h){h=h||[];if(j.call(g)==="[object Array]")Array.prototype.push.apply(h,g);else if(typeof g.length==="number")for(var l=0,m=g.length;l ";var l=s.documentElement;l.insertBefore(g,l.firstChild);if(s.getElementById(h)){n.find.ID=function(m,q,p){if(typeof q.getElementById!=="undefined"&&!p)return(q=q.getElementById(m[1]))?q.id===m[1]||typeof q.getAttributeNode!=="undefined"&& -q.getAttributeNode("id").nodeValue===m[1]?[q]:w:[]};n.filter.ID=function(m,q){var p=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&p&&p.nodeValue===q}}l.removeChild(g);l=g=null})();(function(){var g=s.createElement("div");g.appendChild(s.createComment(""));if(g.getElementsByTagName("*").length>0)n.find.TAG=function(h,l){l=l.getElementsByTagName(h[1]);if(h[1]==="*"){h=[];for(var m=0;l[m];m++)l[m].nodeType===1&&h.push(l[m]);l=h}return l};g.innerHTML=""; -if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")n.attrHandle.href=function(h){return h.getAttribute("href",2)};g=null})();s.querySelectorAll&&function(){var g=k,h=s.createElement("div");h.innerHTML="";if(!(h.querySelectorAll&&h.querySelectorAll(".TEST").length===0)){k=function(m,q,p,v){q=q||s;if(!v&&q.nodeType===9&&!x(q))try{return z(q.querySelectorAll(m),p)}catch(t){}return g(m,q,p,v)};for(var l in g)k[l]=g[l];h=null}}(); -(function(){var g=s.createElement("div");g.innerHTML="";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){n.order.splice(1,0,"CLASS");n.find.CLASS=function(h,l,m){if(typeof l.getElementsByClassName!=="undefined"&&!m)return l.getElementsByClassName(h[1])};g=null}}})();var E=s.compareDocumentPosition?function(g,h){return!!(g.compareDocumentPosition(h)&16)}: -function(g,h){return g!==h&&(g.contains?g.contains(h):true)},x=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false},ga=function(g,h){var l=[],m="",q;for(h=h.nodeType?[h]:h;q=n.match.PSEUDO.exec(g);){m+=q[0];g=g.replace(n.match.PSEUDO,"")}g=n.relative[g]?g+"*":g;q=0;for(var p=h.length;q =0===d})};c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,f=0,e=this.length;f
0)for(var j=d;j 0},closest:function(a,b){if(c.isArray(a)){var d=[],f=this[0],e,j= -{},i;if(f&&a.length){e=0;for(var o=a.length;e -1:c(f).is(e)){d.push({selector:i,elem:f});delete j[i]}}f=f.parentNode}}return d}var k=c.expr.match.POS.test(a)?c(a,b||this.context):null;return this.map(function(n,r){for(;r&&r.ownerDocument&&r!==b;){if(k?k.index(r)>-1:c(r).is(a))return r;r=r.parentNode}return null})},index:function(a){if(!a||typeof a=== -"string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){a=typeof a==="string"?c(a,b||this.context):c.makeArray(a);b=c.merge(this.get(),a);return this.pushStack(qa(a[0])||qa(b[0])?b:c.unique(b))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode", -d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")? -a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,f){var e=c.map(this,b,d);eb.test(a)||(f=d);if(f&&typeof f==="string")e=c.filter(f,e);e=this.length>1?c.unique(e):e;if((this.length>1||gb.test(f))&&fb.test(a))e=e.reverse();return this.pushStack(e,a,R.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return c.find.matches(a,b)},dir:function(a,b,d){var f=[];for(a=a[b];a&&a.nodeType!==9&&(d===w||a.nodeType!==1||!c(a).is(d));){a.nodeType=== -1&&f.push(a);a=a[b]}return f},nth:function(a,b,d){b=b||1;for(var f=0;a;a=a[d])if(a.nodeType===1&&++f===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var Ja=/ jQuery\d+="(?:\d+|null)"/g,V=/^\s+/,Ka=/(<([\w:]+)[^>]*?)\/>/g,hb=/^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,La=/<([\w:]+)/,ib=/"+d+">"},F={option:[1,""],legend:[1,""],thead:[1," ","
"],tr:[2,"","
"],td:[3,""],col:[2,"
"," "],area:[1,""],_default:[0,"",""]};F.optgroup=F.option;F.tbody=F.tfoot=F.colgroup=F.caption=F.thead;F.th=F.td;if(!c.support.htmlSerialize)F._default=[1,"div
"," ",""];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d= -c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==w)return this.empty().append((this[0]&&this[0].ownerDocument||s).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this}, -wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})}, -prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b, -this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,f;(f=this[d])!=null;d++)if(!a||c.filter(a,[f]).length){if(!b&&f.nodeType===1){c.cleanData(f.getElementsByTagName("*"));c.cleanData([f])}f.parentNode&&f.parentNode.removeChild(f)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild); -return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,f=this.ownerDocument;if(!d){d=f.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(Ja,"").replace(/=([^="'>\s]+\/)>/g,'="$1">').replace(V,"")],f)[0]}else return this.cloneNode(true)});if(a===true){ra(this,b);ra(this.find("*"),b.find("*"))}return b},html:function(a){if(a===w)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(Ja, -""):null;else if(typeof a==="string"&&!ta.test(a)&&(c.support.leadingWhitespace||!V.test(a))&&!F[(La.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Ka,Ma);try{for(var b=0,d=this.length;b0||e.cacheable||this.length>1?k.cloneNode(true):k)}o.length&&c.each(o,Qa)}return this}});c.fragments={};c.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var f=[];d=c(d);var e=this.length===1&&this[0].parentNode;if(e&&e.nodeType===11&&e.childNodes.length===1&&d.length===1){d[b](this[0]); -return this}else{e=0;for(var j=d.length;e 0?this.clone(true):this).get();c.fn[b].apply(c(d[e]),i);f=f.concat(i)}return this.pushStack(f,a,d.selector)}}});c.extend({clean:function(a,b,d,f){b=b||s;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||s;for(var e=[],j=0,i;(i=a[j])!=null;j++){if(typeof i==="number")i+="";if(i){if(typeof i==="string"&&!jb.test(i))i=b.createTextNode(i);else if(typeof i==="string"){i=i.replace(Ka,Ma);var o=(La.exec(i)||["", -""])[1].toLowerCase(),k=F[o]||F._default,n=k[0],r=b.createElement("div");for(r.innerHTML=k[1]+i+k[2];n--;)r=r.lastChild;if(!c.support.tbody){n=ib.test(i);o=o==="table"&&!n?r.firstChild&&r.firstChild.childNodes:k[1]===" "&&!n?r.childNodes:[];for(k=o.length-1;k>=0;--k)c.nodeName(o[k],"tbody")&&!o[k].childNodes.length&&o[k].parentNode.removeChild(o[k])}!c.support.leadingWhitespace&&V.test(i)&&r.insertBefore(b.createTextNode(V.exec(i)[0]),r.firstChild);i=r.childNodes}if(i.nodeType)e.push(i);else e= -c.merge(e,i)}}if(d)for(j=0;e[j];j++)if(f&&c.nodeName(e[j],"script")&&(!e[j].type||e[j].type.toLowerCase()==="text/javascript"))f.push(e[j].parentNode?e[j].parentNode.removeChild(e[j]):e[j]);else{e[j].nodeType===1&&e.splice.apply(e,[j+1,0].concat(c.makeArray(e[j].getElementsByTagName("script"))));d.appendChild(e[j])}return e},cleanData:function(a){for(var b,d,f=c.cache,e=c.event.special,j=c.support.deleteExpando,i=0,o;(o=a[i])!=null;i++)if(d=o[c.expando]){b=f[d];if(b.events)for(var k in b.events)e[k]? -c.event.remove(o,k):Ca(o,k,b.handle);if(j)delete o[c.expando];else o.removeAttribute&&o.removeAttribute(c.expando);delete f[d]}}});var kb=/z-?index|font-?weight|opacity|zoom|line-?height/i,Na=/alpha\([^)]*\)/,Oa=/opacity=([^)]*)/,ha=/float/i,ia=/-([a-z])/ig,lb=/([A-Z])/g,mb=/^-?\d+(?:px)?$/i,nb=/^-?\d/,ob={position:"absolute",visibility:"hidden",display:"block"},pb=["Left","Right"],qb=["Top","Bottom"],rb=s.defaultView&&s.defaultView.getComputedStyle,Pa=c.support.cssFloat?"cssFloat":"styleFloat",ja= -function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){return X(this,a,b,true,function(d,f,e){if(e===w)return c.curCSS(d,f);if(typeof e==="number"&&!kb.test(f))e+="px";c.style(d,f,e)})};c.extend({style:function(a,b,d){if(!a||a.nodeType===3||a.nodeType===8)return w;if((b==="width"||b==="height")&&parseFloat(d)<0)d=w;var f=a.style||a,e=d!==w;if(!c.support.opacity&&b==="opacity"){if(e){f.zoom=1;b=parseInt(d,10)+""==="NaN"?"":"alpha(opacity="+d*100+")";a=f.filter||c.curCSS(a,"filter")||"";f.filter= -Na.test(a)?a.replace(Na,b):b}return f.filter&&f.filter.indexOf("opacity=")>=0?parseFloat(Oa.exec(f.filter)[1])/100+"":""}if(ha.test(b))b=Pa;b=b.replace(ia,ja);if(e)f[b]=d;return f[b]},css:function(a,b,d,f){if(b==="width"||b==="height"){var e,j=b==="width"?pb:qb;function i(){e=b==="width"?a.offsetWidth:a.offsetHeight;f!=="border"&&c.each(j,function(){f||(e-=parseFloat(c.curCSS(a,"padding"+this,true))||0);if(f==="margin")e+=parseFloat(c.curCSS(a,"margin"+this,true))||0;else e-=parseFloat(c.curCSS(a, -"border"+this+"Width",true))||0})}a.offsetWidth!==0?i():c.swap(a,ob,i);return Math.max(0,Math.round(e))}return c.curCSS(a,b,d)},curCSS:function(a,b,d){var f,e=a.style;if(!c.support.opacity&&b==="opacity"&&a.currentStyle){f=Oa.test(a.currentStyle.filter||"")?parseFloat(RegExp.$1)/100+"":"";return f===""?"1":f}if(ha.test(b))b=Pa;if(!d&&e&&e[b])f=e[b];else if(rb){if(ha.test(b))b="float";b=b.replace(lb,"-$1").toLowerCase();e=a.ownerDocument.defaultView;if(!e)return null;if(a=e.getComputedStyle(a,null))f= -a.getPropertyValue(b);if(b==="opacity"&&f==="")f="1"}else if(a.currentStyle){d=b.replace(ia,ja);f=a.currentStyle[b]||a.currentStyle[d];if(!mb.test(f)&&nb.test(f)){b=e.left;var j=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;e.left=d==="fontSize"?"1em":f||0;f=e.pixelLeft+"px";e.left=b;a.runtimeStyle.left=j}}return f},swap:function(a,b,d){var f={};for(var e in b){f[e]=a.style[e];a.style[e]=b[e]}d.call(a);for(e in b)a.style[e]=f[e]}});if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b= -a.offsetWidth,d=a.offsetHeight,f=a.nodeName.toLowerCase()==="tr";return b===0&&d===0&&!f?true:b>0&&d>0&&!f?false:c.curCSS(a,"display")==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var sb=J(),tb=/