Skip to content
Browse files

initial commit

  • Loading branch information...
0 parents commit 3577f0347cfe5023e78d8a46feb83d4bd43e0785 @ryanb ryanb committed Jul 13, 2012
Showing with 3,211 additions and 0 deletions.
  1. +13 −0 README.md
  2. +15 −0 blog-after/.gitignore
  3. +41 −0 blog-after/Gemfile
  4. +133 −0 blog-after/Gemfile.lock
  5. +11 −0 blog-after/README.md
  6. +7 −0 blog-after/Rakefile
  7. +15 −0 blog-after/app/assets/javascripts/application.js
  8. +3 −0 blog-after/app/assets/javascripts/articles.js.coffee
  9. +3 −0 blog-after/app/assets/javascripts/omniauth_callbacks.js.coffee
  10. +13 −0 blog-after/app/assets/stylesheets/application.css
  11. +11 −0 blog-after/app/assets/stylesheets/articles.css.scss
  12. +84 −0 blog-after/app/assets/stylesheets/layout.css.scss
  13. +3 −0 blog-after/app/assets/stylesheets/omniauth_callbacks.css.scss
  14. +3 −0 blog-after/app/controllers/application_controller.rb
  15. +43 −0 blog-after/app/controllers/articles_controller.rb
  16. +13 −0 blog-after/app/controllers/omniauth_callbacks_controller.rb
  17. +2 −0 blog-after/app/helpers/application_helper.rb
  18. +2 −0 blog-after/app/helpers/articles_helper.rb
  19. +2 −0 blog-after/app/helpers/omniauth_callbacks_helper.rb
  20. 0 blog-after/app/mailers/.gitkeep
  21. 0 blog-after/app/models/.gitkeep
  22. +3 −0 blog-after/app/models/article.rb
  23. +40 −0 blog-after/app/models/user.rb
  24. +25 −0 blog-after/app/views/articles/_form.html.erb
  25. +6 −0 blog-after/app/views/articles/edit.html.erb
  26. +10 −0 blog-after/app/views/articles/index.html.erb
  27. +5 −0 blog-after/app/views/articles/new.html.erb
  28. +8 −0 blog-after/app/views/articles/show.html.erb
  29. +12 −0 blog-after/app/views/devise/confirmations/new.html.erb
  30. +5 −0 blog-after/app/views/devise/mailer/confirmation_instructions.html.erb
  31. +8 −0 blog-after/app/views/devise/mailer/reset_password_instructions.html.erb
  32. +7 −0 blog-after/app/views/devise/mailer/unlock_instructions.html.erb
  33. +16 −0 blog-after/app/views/devise/passwords/edit.html.erb
  34. +12 −0 blog-after/app/views/devise/passwords/new.html.erb
  35. +30 −0 blog-after/app/views/devise/registrations/edit.html.erb
  36. +23 −0 blog-after/app/views/devise/registrations/new.html.erb
  37. +17 −0 blog-after/app/views/devise/sessions/new.html.erb
  38. +25 −0 blog-after/app/views/devise/shared/_links.erb
  39. +12 −0 blog-after/app/views/devise/unlocks/new.html.erb
  40. +30 −0 blog-after/app/views/layouts/application.html.erb
  41. +4 −0 blog-after/config.ru
  42. +62 −0 blog-after/config/application.rb
  43. +6 −0 blog-after/config/boot.rb
  44. +25 −0 blog-after/config/database.yml
  45. +5 −0 blog-after/config/environment.rb
  46. +39 −0 blog-after/config/environments/development.rb
  47. +67 −0 blog-after/config/environments/production.rb
  48. +37 −0 blog-after/config/environments/test.rb
  49. +7 −0 blog-after/config/initializers/backtrace_silencers.rb
  50. +233 −0 blog-after/config/initializers/devise.rb
  51. +15 −0 blog-after/config/initializers/inflections.rb
  52. +5 −0 blog-after/config/initializers/mime_types.rb
  53. +7 −0 blog-after/config/initializers/secret_token.rb
  54. +8 −0 blog-after/config/initializers/session_store.rb
  55. +14 −0 blog-after/config/initializers/wrap_parameters.rb
  56. +58 −0 blog-after/config/locales/devise.en.yml
  57. +5 −0 blog-after/config/locales/en.yml
  58. +6 −0 blog-after/config/routes.rb
  59. +10 −0 blog-after/db/migrate/20120706211416_create_articles.rb
  60. +46 −0 blog-after/db/migrate/20120706223746_devise_create_users.rb
  61. +5 −0 blog-after/db/migrate/20120707002932_add_username_to_users.rb
  62. +6 −0 blog-after/db/migrate/20120711233744_add_omniauth_to_users.rb
  63. +44 −0 blog-after/db/schema.rb
  64. +19 −0 blog-after/db/seeds.rb
  65. +2 −0 blog-after/doc/README_FOR_APP
  66. 0 blog-after/lib/assets/.gitkeep
  67. 0 blog-after/lib/tasks/.gitkeep
  68. 0 blog-after/log/.gitkeep
  69. +26 −0 blog-after/public/404.html
  70. +26 −0 blog-after/public/422.html
  71. +25 −0 blog-after/public/500.html
  72. 0 blog-after/public/favicon.ico
  73. +5 −0 blog-after/public/robots.txt
  74. +6 −0 blog-after/script/rails
  75. 0 blog-after/test/fixtures/.gitkeep
  76. +9 −0 blog-after/test/fixtures/articles.yml
  77. +11 −0 blog-after/test/fixtures/users.yml
  78. 0 blog-after/test/functional/.gitkeep
  79. +49 −0 blog-after/test/functional/articles_controller_test.rb
  80. +7 −0 blog-after/test/functional/omniauth_callbacks_controller_test.rb
  81. 0 blog-after/test/integration/.gitkeep
  82. +12 −0 blog-after/test/performance/browsing_test.rb
  83. +13 −0 blog-after/test/test_helper.rb
  84. 0 blog-after/test/unit/.gitkeep
  85. +7 −0 blog-after/test/unit/article_test.rb
  86. +4 −0 blog-after/test/unit/helpers/articles_helper_test.rb
  87. +4 −0 blog-after/test/unit/helpers/omniauth_callbacks_helper_test.rb
  88. +7 −0 blog-after/test/unit/user_test.rb
  89. 0 blog-after/vendor/assets/javascripts/.gitkeep
  90. 0 blog-after/vendor/assets/stylesheets/.gitkeep
  91. 0 blog-after/vendor/plugins/.gitkeep
  92. +15 −0 blog-before/.gitignore
  93. +40 −0 blog-before/Gemfile
  94. +121 −0 blog-before/Gemfile.lock
  95. +11 −0 blog-before/README.md
  96. +7 −0 blog-before/Rakefile
  97. +15 −0 blog-before/app/assets/javascripts/application.js
  98. +3 −0 blog-before/app/assets/javascripts/articles.js.coffee
  99. +13 −0 blog-before/app/assets/stylesheets/application.css
  100. +11 −0 blog-before/app/assets/stylesheets/articles.css.scss
  101. +84 −0 blog-before/app/assets/stylesheets/layout.css.scss
  102. +3 −0 blog-before/app/controllers/application_controller.rb
  103. +43 −0 blog-before/app/controllers/articles_controller.rb
  104. +2 −0 blog-before/app/helpers/application_helper.rb
  105. +2 −0 blog-before/app/helpers/articles_helper.rb
  106. 0 blog-before/app/mailers/.gitkeep
  107. 0 blog-before/app/models/.gitkeep
  108. +3 −0 blog-before/app/models/article.rb
  109. +9 −0 blog-before/app/models/user.rb
  110. +25 −0 blog-before/app/views/articles/_form.html.erb
  111. +6 −0 blog-before/app/views/articles/edit.html.erb
  112. +10 −0 blog-before/app/views/articles/index.html.erb
  113. +5 −0 blog-before/app/views/articles/new.html.erb
  114. +8 −0 blog-before/app/views/articles/show.html.erb
  115. +12 −0 blog-before/app/views/devise/confirmations/new.html.erb
  116. +5 −0 blog-before/app/views/devise/mailer/confirmation_instructions.html.erb
  117. +8 −0 blog-before/app/views/devise/mailer/reset_password_instructions.html.erb
  118. +7 −0 blog-before/app/views/devise/mailer/unlock_instructions.html.erb
  119. +16 −0 blog-before/app/views/devise/passwords/edit.html.erb
  120. +12 −0 blog-before/app/views/devise/passwords/new.html.erb
  121. +28 −0 blog-before/app/views/devise/registrations/edit.html.erb
  122. +21 −0 blog-before/app/views/devise/registrations/new.html.erb
  123. +17 −0 blog-before/app/views/devise/sessions/new.html.erb
  124. +25 −0 blog-before/app/views/devise/shared/_links.erb
  125. +12 −0 blog-before/app/views/devise/unlocks/new.html.erb
  126. +29 −0 blog-before/app/views/layouts/application.html.erb
  127. +4 −0 blog-before/config.ru
  128. +62 −0 blog-before/config/application.rb
  129. +6 −0 blog-before/config/boot.rb
  130. +25 −0 blog-before/config/database.yml
  131. +5 −0 blog-before/config/environment.rb
  132. +39 −0 blog-before/config/environments/development.rb
  133. +67 −0 blog-before/config/environments/production.rb
  134. +37 −0 blog-before/config/environments/test.rb
  135. +7 −0 blog-before/config/initializers/backtrace_silencers.rb
  136. +232 −0 blog-before/config/initializers/devise.rb
  137. +15 −0 blog-before/config/initializers/inflections.rb
  138. +5 −0 blog-before/config/initializers/mime_types.rb
  139. +7 −0 blog-before/config/initializers/secret_token.rb
  140. +8 −0 blog-before/config/initializers/session_store.rb
  141. +14 −0 blog-before/config/initializers/wrap_parameters.rb
  142. +58 −0 blog-before/config/locales/devise.en.yml
  143. +5 −0 blog-before/config/locales/en.yml
  144. +6 −0 blog-before/config/routes.rb
  145. +10 −0 blog-before/db/migrate/20120706211416_create_articles.rb
  146. +46 −0 blog-before/db/migrate/20120706223746_devise_create_users.rb
  147. +5 −0 blog-before/db/migrate/20120707002932_add_username_to_users.rb
  148. +42 −0 blog-before/db/schema.rb
  149. +19 −0 blog-before/db/seeds.rb
  150. +2 −0 blog-before/doc/README_FOR_APP
  151. 0 blog-before/lib/assets/.gitkeep
  152. 0 blog-before/lib/tasks/.gitkeep
  153. 0 blog-before/log/.gitkeep
  154. +26 −0 blog-before/public/404.html
  155. +26 −0 blog-before/public/422.html
  156. +25 −0 blog-before/public/500.html
  157. 0 blog-before/public/favicon.ico
  158. +5 −0 blog-before/public/robots.txt
  159. +6 −0 blog-before/script/rails
  160. 0 blog-before/test/fixtures/.gitkeep
  161. +9 −0 blog-before/test/fixtures/articles.yml
  162. +11 −0 blog-before/test/fixtures/users.yml
  163. 0 blog-before/test/functional/.gitkeep
  164. +49 −0 blog-before/test/functional/articles_controller_test.rb
  165. 0 blog-before/test/integration/.gitkeep
  166. +12 −0 blog-before/test/performance/browsing_test.rb
  167. +13 −0 blog-before/test/test_helper.rb
  168. 0 blog-before/test/unit/.gitkeep
  169. +7 −0 blog-before/test/unit/article_test.rb
  170. +4 −0 blog-before/test/unit/helpers/articles_helper_test.rb
  171. +7 −0 blog-before/test/unit/user_test.rb
  172. 0 blog-before/vendor/assets/javascripts/.gitkeep
  173. 0 blog-before/vendor/assets/stylesheets/.gitkeep
  174. 0 blog-before/vendor/plugins/.gitkeep
13 README.md
@@ -0,0 +1,13 @@
+# RailsCasts Episode #235: Devise and OmniAuth (revised)
+
+http://railscasts.com/episodes/235-devise-and-omniauth-revised
+
+Requires Ruby 1.9.2 or higher.
+
+
+### Commands used in this episode
+
+```
+rails g migration add_omniauth_to_users provider uid
+rake db:migrate
+```
15 blog-after/.gitignore
@@ -0,0 +1,15 @@
+# See http://help.github.com/ignore-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
+
+# Ignore all logfiles and tempfiles.
+/log/*.log
+/tmp
41 blog-after/Gemfile
@@ -0,0 +1,41 @@
+source 'https://rubygems.org'
+
+gem 'rails', '3.2.6'
+
+# Bundle edge Rails instead:
+# gem 'rails', :git => 'git://github.com/rails/rails.git'
+
+gem 'sqlite3'
+
+
+# Gems used only for assets and not required
+# in production environments by default.
+group :assets do
+ gem 'sass-rails', '~> 3.2.3'
+ gem 'coffee-rails', '~> 3.2.1'
+
+ # See https://github.com/sstephenson/execjs#readme for more supported runtimes
+ # gem 'therubyracer', :platforms => :ruby
+
+ gem 'uglifier', '>= 1.0.3'
+end
+
+gem 'jquery-rails'
+
+# To use ActiveModel has_secure_password
+# gem 'bcrypt-ruby', '~> 3.0.0'
+
+# To use Jbuilder templates for JSON
+# gem 'jbuilder'
+
+# Use unicorn as the app server
+# gem 'unicorn'
+
+# Deploy with Capistrano
+# gem 'capistrano'
+
+# To use debugger
+# gem 'debugger'
+
+gem 'devise'
+gem 'omniauth-twitter'
133 blog-after/Gemfile.lock
@@ -0,0 +1,133 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ actionmailer (3.2.6)
+ actionpack (= 3.2.6)
+ mail (~> 2.4.4)
+ actionpack (3.2.6)
+ activemodel (= 3.2.6)
+ activesupport (= 3.2.6)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ journey (~> 1.0.1)
+ rack (~> 1.4.0)
+ rack-cache (~> 1.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.1.3)
+ activemodel (3.2.6)
+ activesupport (= 3.2.6)
+ builder (~> 3.0.0)
+ activerecord (3.2.6)
+ activemodel (= 3.2.6)
+ activesupport (= 3.2.6)
+ arel (~> 3.0.2)
+ tzinfo (~> 0.3.29)
+ activeresource (3.2.6)
+ activemodel (= 3.2.6)
+ activesupport (= 3.2.6)
+ activesupport (3.2.6)
+ i18n (~> 0.6)
+ multi_json (~> 1.0)
+ arel (3.0.2)
+ bcrypt-ruby (3.0.1)
+ builder (3.0.0)
+ coffee-rails (3.2.2)
+ coffee-script (>= 2.2.0)
+ railties (~> 3.2.0)
+ coffee-script (2.2.0)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.3.3)
+ devise (2.1.2)
+ bcrypt-ruby (~> 3.0)
+ orm_adapter (~> 0.1)
+ railties (~> 3.1)
+ warden (~> 1.2.1)
+ erubis (2.7.0)
+ execjs (1.4.0)
+ multi_json (~> 1.0)
+ hashie (1.2.0)
+ hike (1.2.1)
+ i18n (0.6.0)
+ journey (1.0.4)
+ jquery-rails (2.0.2)
+ railties (>= 3.2.0, < 5.0)
+ thor (~> 0.14)
+ json (1.7.3)
+ mail (2.4.4)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.19)
+ multi_json (1.3.6)
+ oauth (0.4.6)
+ omniauth (1.1.0)
+ hashie (~> 1.2)
+ rack
+ omniauth-oauth (1.0.1)
+ oauth
+ omniauth (~> 1.0)
+ omniauth-twitter (0.0.11)
+ multi_json (~> 1.3)
+ omniauth-oauth (~> 1.0)
+ orm_adapter (0.3.0)
+ polyglot (0.3.3)
+ rack (1.4.1)
+ rack-cache (1.2)
+ rack (>= 0.4)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rails (3.2.6)
+ actionmailer (= 3.2.6)
+ actionpack (= 3.2.6)
+ activerecord (= 3.2.6)
+ activeresource (= 3.2.6)
+ activesupport (= 3.2.6)
+ bundler (~> 1.0)
+ railties (= 3.2.6)
+ railties (3.2.6)
+ actionpack (= 3.2.6)
+ activesupport (= 3.2.6)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (>= 0.14.6, < 2.0)
+ rake (0.9.2.2)
+ rdoc (3.12)
+ json (~> 1.4)
+ sass (3.1.20)
+ sass-rails (3.2.5)
+ railties (~> 3.2.0)
+ sass (>= 3.1.10)
+ tilt (~> 1.3)
+ sprockets (2.1.3)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
+ sqlite3 (1.3.6)
+ thor (0.15.4)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.33)
+ uglifier (1.2.6)
+ execjs (>= 0.3.0)
+ multi_json (~> 1.3)
+ warden (1.2.1)
+ rack (>= 1.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ coffee-rails (~> 3.2.1)
+ devise
+ jquery-rails
+ omniauth-twitter
+ rails (= 3.2.6)
+ sass-rails (~> 3.2.3)
+ sqlite3
+ uglifier (>= 1.0.3)
11 blog-after/README.md
@@ -0,0 +1,11 @@
+# RailsCasts Example Application
+
+Run these commands to try it out.
+
+```
+bundle
+rake db:setup
+rails s
+```
+
+Requires Ruby 1.9.2 or later to run.
7 blog-after/Rakefile
@@ -0,0 +1,7 @@
+#!/usr/bin/env rake
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require File.expand_path('../config/application', __FILE__)
+
+Blog::Application.load_tasks
15 blog-after/app/assets/javascripts/application.js
@@ -0,0 +1,15 @@
+// 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
+// the compiled file.
+//
+// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
+// GO AFTER THE REQUIRES BELOW.
+//
+//= require jquery
+//= require jquery_ujs
+//= require_tree .
3 blog-after/app/assets/javascripts/articles.js.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
3 blog-after/app/assets/javascripts/omniauth_callbacks.js.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
13 blog-after/app/assets/stylesheets/application.css
@@ -0,0 +1,13 @@
+/*
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
+ * listed below.
+ *
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
+ *
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
+ * compiled file, but it's generally better to create a new file per style scope.
+ *
+ *= require_self
+ *= require_tree .
+ */
11 blog-after/app/assets/stylesheets/articles.css.scss
@@ -0,0 +1,11 @@
+// Place all the styles related to the articles controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
+#articles {
+ h2 {
+ font-size: 18px;
+ margin-top: 20px;
+ margin-bottom: 5px;
+ }
+ p { margin: 5px 0; }
+}
84 blog-after/app/assets/stylesheets/layout.css.scss
@@ -0,0 +1,84 @@
+html, body {
+ background-color: #4B7399;
+ font-family: Verdana, Helvetica, Arial;
+ font-size: 14px;
+}
+
+a img {
+ border: none;
+}
+
+a {
+ color: #0000FF;
+}
+
+.clear {
+ clear: both;
+ height: 0;
+ overflow: hidden;
+}
+
+#container {
+ width: 80%;
+ margin: 0 auto;
+ background-color: #FFF;
+ padding: 20px 40px;
+ border: solid 1px black;
+ margin-top: 20px;
+}
+
+#flash_notice, #flash_error, #flash_alert {
+ padding: 5px 8px;
+ margin: 10px 0;
+ width: 320px;
+}
+
+#flash_notice {
+ background-color: #CFC;
+ border: solid 1px #6C6;
+}
+
+#flash_error, #flash_alert {
+ background-color: #FCC;
+ border: solid 1px #C66;
+}
+
+.field_with_errors {
+ display: inline;
+}
+
+#error_explanation {
+ width: 400px;
+ border: 2px solid #CF0000;
+ padding: 0px;
+ padding-bottom: 12px;
+ margin-bottom: 20px;
+ background-color: #f0f0f0;
+ font-size: 12px;
+}
+
+#error_explanation h2 {
+ text-align: left;
+ font-weight: bold;
+ padding: 5px 10px;
+ font-size: 12px;
+ margin: 0;
+ background-color: #c00;
+ color: #fff;
+}
+
+#error_explanation p {
+ margin: 8px 10px;
+}
+
+#error_explanation ul {
+ margin-bottom: 0;
+}
+
+form .field, form .actions {
+ margin: 12px 0;
+}
+
+#user_nav {
+ float: right;
+}
3 blog-after/app/assets/stylesheets/omniauth_callbacks.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the omniauth_callbacks controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
3 blog-after/app/controllers/application_controller.rb
@@ -0,0 +1,3 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery
+end
43 blog-after/app/controllers/articles_controller.rb
@@ -0,0 +1,43 @@
+class ArticlesController < ApplicationController
+ before_filter :authenticate_user!, except: [:index, :show]
+
+ def index
+ @articles = Article.all
+ end
+
+ def show
+ @article = Article.find(params[:id])
+ end
+
+ def new
+ @article = Article.new
+ end
+
+ def edit
+ @article = Article.find(params[:id])
+ end
+
+ def create
+ @article = Article.new(params[:article])
+ if @article.save
+ redirect_to @article, notice: "Article was successfully created."
+ else
+ render "new"
+ end
+ end
+
+ def update
+ @article = Article.find(params[:id])
+ if @article.update_attributes(params[:article])
+ redirect_to @article, notice: "Article was successfully updated."
+ else
+ render "edit"
+ end
+ end
+
+ def destroy
+ @article = Article.find(params[:id])
+ @article.destroy
+ redirect_to articles_url
+ end
+end
13 blog-after/app/controllers/omniauth_callbacks_controller.rb
@@ -0,0 +1,13 @@
+class OmniauthCallbacksController < Devise::OmniauthCallbacksController
+ def all
+ user = User.from_omniauth(request.env["omniauth.auth"])
+ if user.persisted?
+ flash.notice = "Signed in!"
+ sign_in_and_redirect user
+ else
+ session["devise.user_attributes"] = user.attributes
+ redirect_to new_user_registration_url
+ end
+ end
+ alias_method :twitter, :all
+end
2 blog-after/app/helpers/application_helper.rb
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
2 blog-after/app/helpers/articles_helper.rb
@@ -0,0 +1,2 @@
+module ArticlesHelper
+end
2 blog-after/app/helpers/omniauth_callbacks_helper.rb
@@ -0,0 +1,2 @@
+module OmniauthCallbacksHelper
+end
0 blog-after/app/mailers/.gitkeep
No changes.
0 blog-after/app/models/.gitkeep
No changes.
3 blog-after/app/models/article.rb
@@ -0,0 +1,3 @@
+class Article < ActiveRecord::Base
+ attr_accessible :content, :name
+end
40 blog-after/app/models/user.rb
@@ -0,0 +1,40 @@
+class User < ActiveRecord::Base
+ devise :database_authenticatable, :registerable, :omniauthable,
+ :recoverable, :rememberable, :trackable, :validatable
+
+ attr_accessible :email, :password, :password_confirmation, :remember_me, :username
+
+ validates_presence_of :username
+ validates_uniqueness_of :username
+
+ def self.from_omniauth(auth)
+ where(auth.slice(:provider, :uid)).first_or_create do |user|
+ user.provider = auth.provider
+ user.uid = auth.uid
+ user.username = auth.info.nickname
+ end
+ end
+
+ def self.new_with_session(params, session)
+ if session["devise.user_attributes"]
+ new(session["devise.user_attributes"], without_protection: true) do |user|
+ user.attributes = params
+ user.valid?
+ end
+ else
+ super
+ end
+ end
+
+ def password_required?
+ super && provider.blank?
+ end
+
+ def update_with_password(params, *options)
+ if encrypted_password.blank?
+ update_attributes(params, *options)
+ else
+ super
+ end
+ end
+end
25 blog-after/app/views/articles/_form.html.erb
@@ -0,0 +1,25 @@
+<%= form_for(@article) do |f| %>
+ <% if @article.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@article.errors.count, "error") %> prohibited this article from being saved:</h2>
+
+ <ul>
+ <% @article.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="field">
+ <%= f.label :name %><br />
+ <%= f.text_field :name %>
+ </div>
+ <div class="field">
+ <%= f.label :content %><br />
+ <%= f.text_area :content %>
+ </div>
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+<% end %>
6 blog-after/app/views/articles/edit.html.erb
@@ -0,0 +1,6 @@
+<h1>Editing article</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Show', @article %> |
+<%= link_to 'Back', articles_path %>
10 blog-after/app/views/articles/index.html.erb
@@ -0,0 +1,10 @@
+<h1>Articles</h1>
+
+<div id="articles">
+<% @articles.each do |article| %>
+ <h2><%= link_to article.name, article %></h2>
+ <%= simple_format article.content %>
+<% end %>
+</div>
+
+<p><%= link_to "New Article", new_article_path %></p>
5 blog-after/app/views/articles/new.html.erb
@@ -0,0 +1,5 @@
+<h1>New Article</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Back', articles_path %>
8 blog-after/app/views/articles/show.html.erb
@@ -0,0 +1,8 @@
+<h1><%= @article.name %></h1>
+
+<%= simple_format @article.content %>
+
+<p>
+ <%= link_to "Edit", edit_article_path(@article) %> |
+ <%= link_to "Back to Articles", articles_path %>
+</p>
12 blog-after/app/views/devise/confirmations/new.html.erb
@@ -0,0 +1,12 @@
+<h2>Resend confirmation instructions</h2>
+
+<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
+ <%= devise_error_messages! %>
+
+ <div class="field"><%= f.label :email %><br />
+ <%= f.email_field :email %></div>
+
+ <div class="field"><%= f.submit "Resend confirmation instructions" %></div>
+<% end %>
+
+<%= render "devise/shared/links" %>
5 blog-after/app/views/devise/mailer/confirmation_instructions.html.erb
@@ -0,0 +1,5 @@
+<p>Welcome <%= @resource.email %>!</p>
+
+<p>You can confirm your account email through the link below:</p>
+
+<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
8 blog-after/app/views/devise/mailer/reset_password_instructions.html.erb
@@ -0,0 +1,8 @@
+<p>Hello <%= @resource.email %>!</p>
+
+<p>Someone has requested a link to change your password, and you can do this through the link below.</p>
+
+<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
+
+<p>If you didn't request this, please ignore this email.</p>
+<p>Your password won't change until you access the link above and create a new one.</p>
7 blog-after/app/views/devise/mailer/unlock_instructions.html.erb
@@ -0,0 +1,7 @@
+<p>Hello <%= @resource.email %>!</p>
+
+<p>Your account has been locked due to an excessive amount of unsuccessful sign in attempts.</p>
+
+<p>Click the link below to unlock your account:</p>
+
+<p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %></p>
16 blog-after/app/views/devise/passwords/edit.html.erb
@@ -0,0 +1,16 @@
+<h2>Change your password</h2>
+
+<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
+ <%= devise_error_messages! %>
+ <%= f.hidden_field :reset_password_token %>
+
+ <div class="field"><%= f.label :password, "New password" %><br />
+ <%= f.password_field :password %></div>
+
+ <div class="field"><%= f.label :password_confirmation, "Confirm new password" %><br />
+ <%= f.password_field :password_confirmation %></div>
+
+ <div class="field"><%= f.submit "Change my password" %></div>
+<% end %>
+
+<%= render "devise/shared/links" %>
12 blog-after/app/views/devise/passwords/new.html.erb
@@ -0,0 +1,12 @@
+<h2>Forgot your password?</h2>
+
+<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
+ <%= devise_error_messages! %>
+
+ <div class="field"><%= f.label :email %><br />
+ <%= f.email_field :email %></div>
+
+ <div class="field"><%= f.submit "Send me reset password instructions" %></div>
+<% end %>
+
+<%= render "devise/shared/links" %>
30 blog-after/app/views/devise/registrations/edit.html.erb
@@ -0,0 +1,30 @@
+<h2>Edit <%= resource_name.to_s.humanize %></h2>
+
+<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
+ <%= devise_error_messages! %>
+
+ <div class="field"><%= f.label :email %><br />
+ <%= f.email_field :email %></div>
+
+ <div class="field"><%= f.label :username %><br />
+ <%= f.email_field :username %></div>
+
+ <div class="field"><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
+ <%= f.password_field :password, :autocomplete => "off" %></div>
+
+ <div class="field"><%= f.label :password_confirmation %><br />
+ <%= f.password_field :password_confirmation %></div>
+
+ <% if f.object.encrypted_password.present? %>
+ <div class="field"><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
+ <%= f.password_field :current_password %></div>
+ <% end %>
+
+ <div class="field"><%= f.submit "Update" %></div>
+<% end %>
+
+<h3>Cancel my account</h3>
+
+<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %>.</p>
+
+<%= link_to "Back", :back %>
23 blog-after/app/views/devise/registrations/new.html.erb
@@ -0,0 +1,23 @@
+<h2>Sign up</h2>
+
+<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
+ <%= devise_error_messages! %>
+
+ <div class="field"><%= f.label :email %><br />
+ <%= f.email_field :email %></div>
+
+ <div class="field"><%= f.label :username %><br />
+ <%= f.email_field :username %></div>
+
+ <% if f.object.password_required? %>
+ <div class="field"><%= f.label :password %><br />
+ <%= f.password_field :password %></div>
+
+ <div class="field"><%= f.label :password_confirmation %><br />
+ <%= f.password_field :password_confirmation %></div>
+ <% end %>
+
+ <div class="field"><%= f.submit "Sign up" %></div>
+<% end %>
+
+<%= render "devise/shared/links" %>
17 blog-after/app/views/devise/sessions/new.html.erb
@@ -0,0 +1,17 @@
+<h2>Login</h2>
+
+<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
+ <div class="field"><%= f.label :username %><br />
+ <%= f.text_field :username %></div>
+
+ <div class="field"><%= f.label :password %><br />
+ <%= f.password_field :password %></div>
+
+ <% if devise_mapping.rememberable? -%>
+ <div class="field"><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
+ <% end -%>
+
+ <div class="field"><%= f.submit "Login" %></div>
+<% end %>
+
+<%= render "devise/shared/links" %>
25 blog-after/app/views/devise/shared/_links.erb
@@ -0,0 +1,25 @@
+<%- if controller_name != 'sessions' %>
+ <%= link_to "Login", new_session_path(resource_name) %><br />
+<% end -%>
+
+<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
+ <%= link_to "Sign up", new_registration_path(resource_name) %><br />
+<% end -%>
+
+<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
+ <%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
+<% end -%>
+
+<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
+ <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
+<% end -%>
+
+<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
+ <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
+<% end -%>
+
+<%- if devise_mapping.omniauthable? %>
+ <%- resource_class.omniauth_providers.each do |provider| %>
+ <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
+ <% end -%>
+<% end -%>
12 blog-after/app/views/devise/unlocks/new.html.erb
@@ -0,0 +1,12 @@
+<h2>Resend unlock instructions</h2>
+
+<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %>
+ <%= devise_error_messages! %>
+
+ <div class="field"><%= f.label :email %><br />
+ <%= f.email_field :email %></div>
+
+ <div class="field"><%= f.submit "Resend unlock instructions" %></div>
+<% end %>
+
+<%= render "devise/shared/links" %>
30 blog-after/app/views/layouts/application.html.erb
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Blog</title>
+ <%= stylesheet_link_tag "application", media: "all" %>
+ <%= javascript_include_tag "application" %>
+ <%= csrf_meta_tag %>
+ </head>
+ <body>
+ <div id="container">
+ <div id="user_nav">
+ <% if user_signed_in? %>
+ Logged in as <strong><%= current_user.email %></strong>.
+ <%= link_to 'Edit profile', edit_user_registration_path %> |
+ <%= link_to "Logout", destroy_user_session_path, method: :delete %>
+ <% else %>
+ <%= link_to "Sign up", new_user_registration_path %> |
+ <%= link_to "Login", new_user_session_path %> |
+ <%= link_to "Sign in with Twitter", user_omniauth_authorize_path(:twitter) %>
+ <% end %>
+ </div>
+
+ <% flash.each do |name, msg| %>
+ <%= content_tag :div, msg, id: "flash_#{name}" %>
+ <% end %>
+
+ <%= yield %>
+ </div>
+ </body>
+</html>
4 blog-after/config.ru
@@ -0,0 +1,4 @@
+# This file is used by Rack-based servers to start the application.
+
+require ::File.expand_path('../config/environment', __FILE__)
+run Blog::Application
62 blog-after/config/application.rb
@@ -0,0 +1,62 @@
+require File.expand_path('../boot', __FILE__)
+
+require 'rails/all'
+
+if defined?(Bundler)
+ # If you precompile assets before deploying to production, use this line
+ Bundler.require(*Rails.groups(:assets => %w(development test)))
+ # If you want your assets lazily compiled in production, use this line
+ # Bundler.require(:default, :assets, Rails.env)
+end
+
+module Blog
+ class Application < Rails::Application
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+
+ # 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)'
+
+ # 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
+
+ # 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]
+
+ # Enable escaping HTML in JSON.
+ config.active_support.escape_html_entities_in_json = true
+
+ # Use SQL instead of Active Record's schema dumper when creating the 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
+
+ # Enforce whitelist mode for mass assignment.
+ # This will create an empty whitelist of attributes available for mass-assignment for all models
+ # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
+ # parameters by using an attr_accessible or attr_protected declaration.
+ config.active_record.whitelist_attributes = true
+
+ # Enable the asset pipeline
+ config.assets.enabled = true
+
+ # Version of your assets, change this if you want to expire all your assets
+ config.assets.version = '1.0'
+ end
+end
6 blog-after/config/boot.rb
@@ -0,0 +1,6 @@
+require 'rubygems'
+
+# Set up gems listed in the Gemfile.
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
+
+require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
25 blog-after/config/database.yml
@@ -0,0 +1,25 @@
+# SQLite version 3.x
+# gem install sqlite3
+#
+# Ensure the SQLite 3 gem is defined in your Gemfile
+# gem 'sqlite3'
+development:
+ adapter: sqlite3
+ database: db/development.sqlite3
+ pool: 5
+ timeout: 5000
+
+# 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
+ database: db/test.sqlite3
+ pool: 5
+ timeout: 5000
+
+production:
+ adapter: sqlite3
+ database: db/production.sqlite3
+ pool: 5
+ timeout: 5000
5 blog-after/config/environment.rb
@@ -0,0 +1,5 @@
+# Load the rails application
+require File.expand_path('../application', __FILE__)
+
+# Initialize the rails application
+Blog::Application.initialize!
39 blog-after/config/environments/development.rb
@@ -0,0 +1,39 @@
+Blog::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 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
+
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Don't care if the mailer can't send
+ config.action_mailer.raise_delivery_errors = false
+
+ # 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
+
+ # Raise exception on mass assignment protection for Active Record models
+ config.active_record.mass_assignment_sanitizer = :strict
+
+ # Log the query plan for queries taking more than this (works
+ # with SQLite, MySQL, and PostgreSQL)
+ config.active_record.auto_explain_threshold_in_seconds = 0.5
+
+ # Do not compress assets
+ config.assets.compress = false
+
+ # Expands the lines which load the assets
+ config.assets.debug = true
+
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
+end
67 blog-after/config/environments/production.rb
@@ -0,0 +1,67 @@
+Blog::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
+
+ # Code is not reloaded between requests
+ config.cache_classes = true
+
+ # Full error reports are disabled and caching is turned on
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = true
+
+ # Disable Rails's static asset server (Apache or nginx will already do this)
+ config.serve_static_assets = false
+
+ # Compress JavaScripts and CSS
+ config.assets.compress = true
+
+ # Don't fallback to assets pipeline if a precompiled asset is missed
+ config.assets.compile = false
+
+ # Generate digests for assets URLs
+ config.assets.digest = true
+
+ # Defaults to nil and saved in location specified by config.assets.prefix
+ # config.assets.manifest = YOUR_PATH
+
+ # 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
+
+ # See everything in the log (default is :info)
+ # config.log_level = :debug
+
+ # Prepend all log lines with the following tags
+ # config.log_tags = [ :subdomain, :uuid ]
+
+ # Use a different logger for distributed setups
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
+
+ # 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"
+
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
+ # config.assets.precompile += %w( search.js )
+
+ # Disable delivery errors, bad email addresses will be ignored
+ # 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)
+ config.i18n.fallbacks = true
+
+ # Send deprecation notices to registered listeners
+ config.active_support.deprecation = :notify
+
+ # Log the query plan for queries taking more than this (works
+ # with SQLite, MySQL, and PostgreSQL)
+ # config.active_record.auto_explain_threshold_in_seconds = 0.5
+end
37 blog-after/config/environments/test.rb
@@ -0,0 +1,37 @@
+Blog::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
+ # 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!
+ config.cache_classes = true
+
+ # Configure static asset server for tests with Cache-Control for performance
+ config.serve_static_assets = true
+ config.static_cache_control = "public, max-age=3600"
+
+ # Log error messages when you accidentally call methods on nil
+ config.whiny_nils = true
+
+ # 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
+ config.action_dispatch.show_exceptions = 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
+
+ # Raise exception on mass assignment protection for Active Record models
+ config.active_record.mass_assignment_sanitizer = :strict
+
+ # Print deprecation notices to the stderr
+ config.active_support.deprecation = :stderr
+end
7 blog-after/config/initializers/backtrace_silencers.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
233 blog-after/config/initializers/devise.rb
@@ -0,0 +1,233 @@
+# 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|
+ # ==> Mailer Configuration
+ # 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"
+
+ # ==> ORM configuration
+ # Load and configure the ORM. Supports :active_record (default) and
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
+ # available as additional gems.
+ require 'devise/orm/active_record'
+
+ # ==> Configuration for any authentication mechanism
+ # Configure which keys are used when authenticating a user. The default is
+ # just :email. You can configure it to use [:username, :subdomain], so for
+ # authenticating a user, both parameters are required. Remember that those
+ # parameters are used only when authenticating and not when retrieving from
+ # session. If you need permissions, you should implement that in a before filter.
+ # You can also supply a hash where the value is a boolean determining whether
+ # or not authentication should be aborted when the value is not present.
+ config.authentication_keys = [ :username ]
+
+ # Configure parameters from the request object used for authentication. Each entry
+ # given should be a request method and it will automatically be passed to the
+ # find_for_authentication method and considered in your model lookup. For instance,
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
+ # config.request_keys = []
+
+ # Configure which authentication keys should be case-insensitive.
+ # These keys will be downcased upon creating or modifying a user and when used
+ # to authenticate or find a user. Default is :email.
+ config.case_insensitive_keys = [ :username ]
+
+ # 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 = [ :username ]
+
+ # 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.
+ # It can be set to an array that will enable http authentication only for the
+ # given strategies, for example, `config.http_authenticatable = [:token]` will
+ # enable it only for token authentication.
+ # config.http_authenticatable = false
+
+ # If http headers 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"
+
+ # 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
+ # :http_auth and :token_auth by adding those symbols to the array below.
+ # 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]
+
+ # ==> 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.
+ #
+ # 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.
+ config.stretches = Rails.env.test? ? 1 : 10
+
+ # Setup a pepper to generate the encrypted password.
+ # config.pepper = "9eb8995012287527333b41b2711cf4c9ff59b4f6aaa827ca73381bbfa8048057b24efa9ddb96a8c7ab0080a3ea64b426132c1a2d5a3ce0ad157d19110b9066f8"
+
+ # ==> Configuration for :confirmable
+ # A period that the user is allowed to access the website even without
+ # confirming his account. For instance, if set to 2.days, the user will be
+ # able to access the website for two days without confirming his account,
+ # access will be blocked just in the third day. Default is 0.days, meaning
+ # the user cannot access the website without confirming his account.
+ # config.allow_unconfirmed_access_for = 2.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 ]
+
+ # ==> Configuration for :rememberable
+ # The time the user will be remembered without asking for credentials again.
+ # config.remember_for = 2.weeks
+
+ # If true, extends the user's remember period when remembered via cookie.
+ # config.extend_remember_period = false
+
+ # 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..128.
+ # config.password_length = 6..128
+
+ # Email regex used to validate email formats. It simply asserts that
+ # an 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.
+ # :none = No lock strategy. You should handle locking by yourself.
+ # config.lock_strategy = :failed_attempts
+
+ # Defines which key will be used when locking and unlocking an account
+ # config.unlock_keys = [ :email ]
+
+ # Defines which strategy will be used to unlock an account.
+ # :email = Sends an unlock link to the user email
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
+ # :both = Enables both strategies
+ # :none = No unlock strategy. You should handle unlocking by yourself.
+ # config.unlock_strategy = :both
+
+ # Number of authentication tries before locking an account if lock_strategy
+ # is failed attempts.
+ # config.maximum_attempts = 20
+
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
+ # config.unlock_in = 1.hour
+
+ # ==> 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)
+ # config.encryptor = :sha512
+
+ # ==> Configuration for :token_authenticatable
+ # Defines name of the authentication token params key
+ # config.token_authentication_key = :auth_token
+
+ # ==> 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
+ # are using only default views.
+ # config.scoped_views = false
+
+ # Configure the default scope given to Warden. By default it's the first
+ # devise role declared in your routes (usually :user).
+ # config.default_scope = :user
+
+ # 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
+ # Lists the formats that should be treated as navigational. Formats like
+ # :html, should redirect to the sign in page when the user does not have
+ # access, but formats like :xml or :json, should return 401.
+ #
+ # If you have any extra navigational formats, like :iphone or :mobile, you
+ # should add them to the navigational formats lists.
+ #
+ # 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 :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 :twitter, ENV["TWITTER_CONSUMER_KEY"], ENV["TWITTER_CONSUMER_SECRET"]
+
+ # ==> 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.intercept_401 = false
+ # 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
15 blog-after/config/initializers/inflections.rb
@@ -0,0 +1,15 @@
+# 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|
+# 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 do |inflect|
+# inflect.acronym 'RESTful'
+# end
5 blog-after/config/initializers/mime_types.rb
@@ -0,0 +1,5 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new mime types for use in respond_to blocks:
+# Mime::Type.register "text/richtext", :rtf
+# Mime::Type.register_alias "text/html", :iphone
7 blog-after/config/initializers/secret_token.rb
@@ -0,0 +1,7 @@
+# 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.
+Blog::Application.config.secret_token = 'd66fdd22fd7222649e6f9ec8015162994d1b509a9926cd3ff50f64a2edffa574fe7d13771bbd1f40becc264312755c46c53ff22d7cd26a1471ce1a2b3d77ba2a'
8 blog-after/config/initializers/session_store.rb
@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+Blog::Application.config.session_store :cookie_store, key: '_blog_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 "rails generate session_migration")
+# Blog::Application.config.session_store :active_record_store
14 blog-after/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]
+end
+
+# Disable root element in JSON by default.
+ActiveSupport.on_load(:active_record) do
+ self.include_root_in_json = false
+end
58 blog-after/config/locales/devise.en.yml
@@ -0,0 +1,58 @@
+# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
+
+en:
+ errors:
+ messages:
+ expired: "has expired, please request a new one"
+ not_found: "not found"
+ already_confirmed: "was already confirmed, please try logging in"
+ 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:
+ already_authenticated: 'You are already logged in.'
+ unauthenticated: 'You need to login 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 login again to continue.'
+ inactive: 'Your account was not activated yet.'
+ sessions:
+ signed_in: 'Logged in successfully.'
+ signed_out: 'Logged 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 logged in.'
+ updated_not_active: 'Your password was changed successfully.'
+ 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."
+ 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."
+ confirmations:
+ send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
+ send_paranoid_instructions: 'If your email address exists in our database, 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 logged in.'
+ registrations:
+ signed_up: 'Welcome! You have signed up successfully.'
+ signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'
+ signed_up_but_inactive: 'You have signed up successfully. However, we could not log you in because your account is not yet activated.'
+ signed_up_but_locked: 'You have signed up successfully. However, we could not log you in because your account is locked.'
+ updated: 'You updated your account successfully.'
+ update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address."
+ 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 has been unlocked successfully. Please login to continue.'
+ send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.'
+ omniauth_callbacks:
+ success: 'Successfully authenticated from %{kind} account.'
+ failure: 'Could not authenticate you from %{kind} because "%{reason}".'
+ mailer:
+ confirmation_instructions:
+ subject: 'Confirmation instructions'
+ reset_password_instructions:
+ subject: 'Reset password instructions'
+ unlock_instructions:
+ subject: 'Unlock Instructions'
5 blog-after/config/locales/en.yml
@@ -0,0 +1,5 @@
+# Sample localization file for English. Add more files in this directory for other locales.
+# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
+
+en:
+ hello: "Hello world"
6 blog-after/config/routes.rb
@@ -0,0 +1,6 @@
+Blog::Application.routes.draw do
+ devise_for :users, path_names: {sign_in: "login", sign_out: "logout"},
+ controllers: {omniauth_callbacks: "omniauth_callbacks"}
+ resources :articles
+ root to: 'articles#index'
+end
10 blog-after/db/migrate/20120706211416_create_articles.rb
@@ -0,0 +1,10 @@
+class CreateArticles < ActiveRecord::Migration
+ def change
+ create_table :articles do |t|
+ t.string :name
+ t.text :content
+
+ t.timestamps
+ end
+ end
+end
46 blog-after/db/migrate/20120706223746_devise_create_users.rb
@@ -0,0 +1,46 @@
+class DeviseCreateUsers < ActiveRecord::Migration
+ def change
+ create_table(:users) do |t|
+ ## Database authenticatable
+ t.string :email, :null => false, :default => ""
+ t.string :encrypted_password, :null => false, :default => ""
+
+ ## Recoverable
+ t.string :reset_password_token
+ t.datetime :reset_password_sent_at
+
+ ## Rememberable
+ t.datetime :remember_created_at
+
+ ## Trackable
+ t.integer :sign_in_count, :default => 0
+ t.datetime :current_sign_in_at
+ t.datetime :last_sign_in_at
+ t.string :current_sign_in_ip
+ t.string :last_sign_in_ip
+
+ ## Confirmable
+ # t.string :confirmation_token
+ # t.datetime :confirmed_at
+ # t.datetime :confirmation_sent_at
+ # t.string :unconfirmed_email # Only if using reconfirmable
+
+ ## Lockable
+ # t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
+ # t.datetime :locked_at
+
+ ## Token authenticatable
+ # t.string :authentication_token
+
+
+ t.timestamps
+ end
+
+ add_index :users, :email, :unique => true
+ add_index :users, :reset_password_token, :unique => true
+ # add_index :users, :confirmation_token, :unique => true
+ # add_index :users, :unlock_token, :unique => true
+ # add_index :users, :authentication_token, :unique => true
+ end
+end
5 blog-after/db/migrate/20120707002932_add_username_to_users.rb
@@ -0,0 +1,5 @@
+class AddUsernameToUsers < ActiveRecord::Migration
+ def change
+ add_column :users, :username, :string
+ end
+end
6 blog-after/db/migrate/20120711233744_add_omniauth_to_users.rb
@@ -0,0 +1,6 @@
+class AddOmniauthToUsers < ActiveRecord::Migration
+ def change
+ add_column :users, :provider, :string
+ add_column :users, :uid, :string
+ end
+end
44 blog-after/db/schema.rb
@@ -0,0 +1,44 @@
+# 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.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# 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.
+
+ActiveRecord::Schema.define(:version => 20120711233744) do
+
+ create_table "articles", :force => true do |t|
+ t.string "name"
+ t.text "content"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ create_table "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.datetime "current_sign_in_at"
+ t.datetime "last_sign_in_at"
+ t.string "current_sign_in_ip"
+ t.string "last_sign_in_ip"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.string "username"
+ t.string "provider"
+ t.string "uid"
+ end
+
+ add_index "users", ["email"], :name => "index_users_on_email", :unique => true
+ add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
+
+end
19 blog-after/db/seeds.rb
@@ -0,0 +1,19 @@
+batman = Article.create! name: "Batman", content: <<-ARTICLE
+Batman is a fictional character created by the artist Bob Kane and writer Bill Finger. A comic book superhero, Batman first appeared in Detective Comics #27 (May 1939), and since then has appeared primarily in publications by DC Comics. Originally referred to as "The Bat-Man" and still referred to at times as "The Batman", he is additionally known as "The Caped Crusader", "The Dark Knight", and the "World's Greatest Detective," among other titles. (from Wikipedia)
+ARTICLE
+
+superman = Article.create! name: "Superman", content: <<-ARTICLE
+Superman is a fictional comic book superhero appearing in publications by DC Comics, widely considered to be an American cultural icon. Created by American writer Jerry Siegel and Canadian-born American artist Joe Shuster in 1932 while both were living in Cleveland, Ohio, and sold to Detective Comics, Inc. (later DC Comics) in 1938, the character first appeared in Action Comics #1 (June 1938) and subsequently appeared in various radio serials, television programs, films, newspaper strips, and video games. (from Wikipedia)
+ARTICLE
+
+krypton = Article.create! name: "Krypton", content: <<-ARTICLE
+Krypton is a fictional planet in the DC Comics universe, and the native world of the super-heroes Superman and, in some tellings, Supergirl and Krypto the Superdog. Krypton has been portrayed consistently as having been destroyed just after Superman's flight from the planet, with exact details of its destruction varying by time period, writers and franchise. Kryptonians were the dominant people of Krypton. (from Wikipedia)
+ARTICLE
+
+lex_luthor = Article.create! name: "Lex Luthor", content: <<-ARTICLE
+Lex Luthor is a fictional character, a supervillain who appears in comic books published by DC Comics. He is the archenemy of Superman, and is also a major adversary of Batman and other superheroes in the DC Universe. Created by Jerry Siegel and Joe Shuster, he first appeared in Action Comics #23 (April 1940). Luthor is described as "a power-mad, evil scientist" of high intelligence and incredible technological prowess. (from Wikipedia)
+ARTICLE
+
+robin = Article.create! name: "Robin", content: <<-ARTICLE
+Robin is the name of several fictional characters appearing in comic books published by DC Comics, originally created by Bob Kane, Bill Finger and Jerry Robinson, as a junior counterpart to DC Comics superhero Batman. The team of Batman and Robin is commonly referred to as the Dynamic Duo or the Caped Crusaders. (from Wikipedia)
+ARTICLE
2 blog-after/doc/README_FOR_APP
@@ -0,0 +1,2 @@
+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.
0 blog-after/lib/assets/.gitkeep
No changes.
0 blog-after/lib/tasks/.gitkeep
No changes.
0 blog-after/log/.gitkeep
No changes.
26 blog-after/public/404.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>The page you were looking for doesn't exist (404)</title>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
+</head>
+
+<body>
+ <!-- This file lives in public/404.html -->
+ <div class="dialog">
+ <h1>The page you were looking for doesn't exist.</h1>
+ <p>You may have mistyped the address or the page may have moved.</p>
+ </div>
+</body>
+</html>
26 blog-after/public/422.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>The change you wanted was rejected (422)</title>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
+</head>
+
+<body>
+ <!-- This file lives in public/422.html -->
+ <div class="dialog">
+ <h1>The change you wanted was rejected.</h1>
+ <p>Maybe you tried to change something you didn't have access to.</p>
+ </div>
+</body>
+</html>
25 blog-after/public/500.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>We're sorry, but something went wrong (500)</title>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
+</head>
+
+<body>
+ <!-- This file lives in public/500.html -->
+ <div class="dialog">
+ <h1>We're sorry, but something went wrong.</h1>
+ </div>
+</body>
+</html>
0 blog-after/public/favicon.ico
No changes.
5 blog-after/public/robots.txt
@@ -0,0 +1,5 @@
+# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
+#
+# To ban all spiders from the entire site uncomment the next two lines:
+# User-Agent: *
+# Disallow: /
6 blog-after/script/rails
@@ -0,0 +1,6 @@
+#!/usr/bin/env ruby
+# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
+
+APP_PATH = File.expand_path('../../config/application', __FILE__)
+require File.expand_path('../../config/boot', __FILE__)
+require 'rails/commands'
0 blog-after/test/fixtures/.gitkeep
No changes.
9 blog-after/test/fixtures/articles.yml
@@ -0,0 +1,9 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+ name: MyString
+ content: MyText
+
+two:
+ name: MyString
+ content: MyText
11 blog-after/test/fixtures/users.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
0 blog-after/test/functional/.gitkeep
No changes.
49 blog-after/test/functional/articles_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class ArticlesControllerTest < ActionController::TestCase
+ setup do
+ @article = articles(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:articles)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create article" do
+ assert_difference('Article.count') do
+ post :create, article: { content: @article.content, name: @article.name }
+ end
+
+ assert_redirected_to article_path(assigns(:article))
+ end
+
+ test "should show article" do
+ get :show, id: @article
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @article
+ assert_response :success
+ end
+
+ test "should update article" do
+ put :update, id: @article, article: { content: @article.content, name: @article.name }
+ assert_redirected_to article_path(assigns(:article))
+ end
+
+ test "should destroy article" do
+ assert_difference('Article.count', -1) do
+ delete :destroy, id: @article
+ end
+
+ assert_redirected_to articles_path
+ end
+end
7 blog-after/test/functional/omniauth_callbacks_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class OmniauthCallbacksControllerTest < ActionController::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
0 blog-after/test/integration/.gitkeep
No changes.
12 blog-after/test/performance/browsing_test.rb
@@ -0,0 +1,12 @@
+require 'test_helper'
+require 'rails/performance_test_help'
+
+class BrowsingTest < ActionDispatch::PerformanceTest
+ # Refer to the documentation for all available options
+ # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
+ # :output => 'tmp/performance', :formats => [:flat] }
+
+ def test_homepage
+ get '/'
+ end
+end
13 blog-after/test/test_helper.rb
@@ -0,0 +1,13 @@
+ENV["RAILS_ENV"] = "test"
+require File.expand_path('../../config/environment', __FILE__)
+require 'rails/test_help'
+
+class ActiveSupport::TestCase
+ # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
+ #
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
+ # -- they do not yet inherit this setting
+ fixtures :all
+
+ # Add more helper methods to be used by all tests here...
+end
0 blog-after/test/unit/.gitkeep
No changes.
7 blog-after/test/unit/article_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class ArticleTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
4 blog-after/test/unit/helpers/articles_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class ArticlesHelperTest < ActionView::TestCase
+end
4 blog-after/test/unit/helpers/omniauth_callbacks_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class OmniauthCallbacksHelperTest < ActionView::TestCase
+end
7 blog-after/test/unit/user_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class UserTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
0 blog-after/vendor/assets/javascripts/.gitkeep
No changes.
0 blog-after/vendor/assets/stylesheets/.gitkeep
No changes.