contour 1.3.0 → 2.0.0.beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. checksums.yaml +8 -8
  2. data/CHANGELOG.md +6 -0
  3. data/README.md +9 -30
  4. data/Rakefile +14 -25
  5. data/app/assets/javascripts/contour/global.js.coffee +16 -15
  6. data/app/controllers/contour/authentications_controller.rb +2 -0
  7. data/app/models/authentication.rb +2 -5
  8. data/app/models/concerns/contour_authenticatable.rb +12 -0
  9. data/app/models/concerns/contourable.rb +19 -0
  10. data/app/views/contour/layouts/application.html.erb +2 -2
  11. data/config/routes.rb +4 -4
  12. data/contour.gemspec +4 -2
  13. data/lib/contour/version.rb +3 -3
  14. data/lib/generators/contour/scaffold/templates/_paginate.html.erb +1 -1
  15. data/lib/generators/contour/scaffold/templates/controller.rb +31 -52
  16. data/lib/generators/contour/scaffold/templates/index.html.erb +1 -1
  17. data/test/{functional → controllers}/authentications_controller_test.rb +0 -0
  18. data/test/{functional → controllers}/passwords_controller_test.rb +0 -0
  19. data/test/{functional → controllers}/registrations_controller_test.rb +0 -0
  20. data/test/dummy/app/models/user.rb +6 -20
  21. data/test/dummy/config/application.rb +3 -24
  22. data/test/dummy/config/boot.rb +1 -1
  23. data/test/dummy/config/environments/development.rb +10 -13
  24. data/test/dummy/config/environments/production.rb +44 -24
  25. data/test/dummy/config/environments/test.rb +14 -17
  26. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  27. data/test/dummy/config/initializers/inflections.rb +9 -3
  28. data/test/dummy/config/initializers/secret_token.rb +6 -1
  29. data/test/dummy/config/initializers/session_store.rb +1 -6
  30. data/test/dummy/config/initializers/wrap_parameters.rb +6 -6
  31. data/test/dummy/config/locales/en.yml +20 -2
  32. data/test/dummy/config/routes.rb +1 -1
  33. data/test/dummy/db/test.sqlite3 +0 -0
  34. data/test/dummy/log/test.log +3178 -0
  35. data/test/dummy/tmp/cache/assets/test/sprockets/015542ca3fee2683eedd21c586e8f4d7 +0 -0
  36. data/test/dummy/tmp/cache/assets/test/sprockets/04f8cd84302394fd96a5a1837da2c435 +0 -0
  37. data/test/dummy/tmp/cache/assets/test/sprockets/097505e114b875201dffa335d293ea3f +0 -0
  38. data/test/dummy/tmp/cache/assets/test/sprockets/09eb485019a1180e44fa6e443aa47503 +0 -0
  39. data/test/dummy/tmp/cache/assets/test/sprockets/0b793dc498fe65856d1b31a805f114dc +0 -0
  40. data/test/dummy/tmp/cache/assets/test/sprockets/0e3daa6e1f20f19c7f6f41a866d36e37 +0 -0
  41. data/test/dummy/tmp/cache/assets/test/sprockets/10912716ee41871536663637aac9d90b +0 -0
  42. data/test/dummy/tmp/cache/assets/test/sprockets/10b862dc2fcb57e871b350f99445089a +0 -0
  43. data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  44. data/test/dummy/tmp/cache/assets/test/sprockets/1421ef9eb96cc5dd00cd50105a186f79 +0 -0
  45. data/test/dummy/tmp/cache/assets/test/sprockets/2316c3ab821288d9cc78527e3b6272a9 +0 -0
  46. data/test/dummy/tmp/cache/assets/test/sprockets/25129d82803be264eda19543144ce764 +0 -0
  47. data/test/dummy/tmp/cache/assets/test/sprockets/25e897b572b78b9e7872682d1a1722e0 +0 -0
  48. data/test/dummy/tmp/cache/assets/test/sprockets/29e65a0b15bf594999939014080494b0 +0 -0
  49. data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  50. data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  51. data/test/dummy/tmp/cache/assets/test/sprockets/3ed734f0003effb5248235744ea7cfbf +0 -0
  52. data/test/dummy/tmp/cache/assets/test/sprockets/408c90980fca5a250881bafa3ef0ca63 +0 -0
  53. data/test/dummy/tmp/cache/assets/test/sprockets/42bbea7a13ce140463a5486a3ae03c94 +0 -0
  54. data/test/dummy/tmp/cache/assets/test/sprockets/4556873bdb635e908edb1b44651d42e4 +0 -0
  55. data/test/dummy/tmp/cache/assets/test/sprockets/484869e0e90da89451d284b6ea1b97ea +0 -0
  56. data/test/dummy/tmp/cache/assets/test/sprockets/4c1f9630c371980e45f3ae2dfaec8a28 +0 -0
  57. data/test/dummy/tmp/cache/assets/test/sprockets/4e7d7c035444f1095fa7dc67721581db +0 -0
  58. data/test/dummy/tmp/cache/assets/test/sprockets/501011855a4cc902996843acadb9c797 +0 -0
  59. data/test/dummy/tmp/cache/assets/test/sprockets/52cdaf963c787c0aa7e2741ce4340be0 +0 -0
  60. data/test/dummy/tmp/cache/assets/test/sprockets/565a4c5a5681bc36489ea1beae4553b0 +0 -0
  61. data/test/dummy/tmp/cache/assets/test/sprockets/5735b70ef1f983b248a47ab1f71fe267 +0 -0
  62. data/test/dummy/tmp/cache/assets/test/sprockets/5aa48c4b9b88fd0c67e1480c677ac489 +0 -0
  63. data/test/dummy/tmp/cache/assets/test/sprockets/6565915e91061b9bb42eda9dfa4cf3fc +0 -0
  64. data/test/dummy/tmp/cache/assets/test/sprockets/6666059cb20313a69e518d351e00eb1f +0 -0
  65. data/test/dummy/tmp/cache/assets/test/sprockets/6836a9eb9975c10c93f447fc315b8349 +0 -0
  66. data/test/dummy/tmp/cache/assets/test/sprockets/6897902b615db6d106af2822a6e2eb62 +0 -0
  67. data/test/dummy/tmp/cache/assets/test/sprockets/715b9d65172e5d82f05fe7f179e4f641 +0 -0
  68. data/test/dummy/tmp/cache/assets/test/sprockets/768fc2641c0e22c57679e02ed8543d36 +0 -0
  69. data/test/dummy/tmp/cache/assets/test/sprockets/7d06b47b0fa66ce19b154d2355b1ccd1 +0 -0
  70. data/test/dummy/tmp/cache/assets/test/sprockets/7e0eb4be88d9d9a70cd09bbf4007f4a4 +0 -0
  71. data/test/dummy/tmp/cache/assets/test/sprockets/807cd6bd5e0c02ec0772daa3868f9d61 +0 -0
  72. data/test/dummy/tmp/cache/assets/test/sprockets/80cc7db99ad2b64556de9b8229a8f3e7 +0 -0
  73. data/test/dummy/tmp/cache/assets/test/sprockets/844ae5de3828b76089f39336c6f3f6c8 +0 -0
  74. data/test/dummy/tmp/cache/assets/test/sprockets/864e4f1898b310dcf0316a99ba0a3067 +0 -0
  75. data/test/dummy/tmp/cache/assets/test/sprockets/87f0cc2881f608195fdaec58ee54fbfe +0 -0
  76. data/test/dummy/tmp/cache/assets/test/sprockets/884005c51eb580c211fdf86f83cbd7d4 +0 -0
  77. data/test/dummy/tmp/cache/assets/test/sprockets/8c0ac229a3088e0cd0d9db95df428103 +0 -0
  78. data/test/dummy/tmp/cache/assets/test/sprockets/8e0772a1c692d481d2e5ef800602c9b3 +0 -0
  79. data/test/dummy/tmp/cache/assets/test/sprockets/8f0d12234b16caea73d930c4658554e8 +0 -0
  80. data/test/dummy/tmp/cache/assets/test/sprockets/8fdd783b1b18cf2bf735a31f68b32131 +0 -0
  81. data/test/dummy/tmp/cache/assets/test/sprockets/939a36ef1c8fe174ef51ff8a4c5322a8 +0 -0
  82. data/test/dummy/tmp/cache/assets/test/sprockets/950cf58a7bd174e827f4a73f6996e8bd +0 -0
  83. data/test/dummy/tmp/cache/assets/test/sprockets/98e808b2266a0668a608206151fa43d9 +0 -0
  84. data/test/dummy/tmp/cache/assets/test/sprockets/a049654e5ab2df058699bd8968c0f493 +0 -0
  85. data/test/dummy/tmp/cache/assets/test/sprockets/a143a0bc0632c5cb89f596cf5272528e +0 -0
  86. data/test/dummy/tmp/cache/assets/test/sprockets/a3041faa4e334801f4f495371a8cced2 +0 -0
  87. data/test/dummy/tmp/cache/assets/test/sprockets/a3a6cd207915c1867e51fa92ea7827b8 +0 -0
  88. data/test/dummy/tmp/cache/assets/test/sprockets/a4faa95d6bafec287fc59ff59eec9625 +0 -0
  89. data/test/dummy/tmp/cache/assets/test/sprockets/a7b222735fc6d94f5713fa8e4c00feec +0 -0
  90. data/test/dummy/tmp/cache/assets/test/sprockets/ac9180e2a5edc87eec65cd47141d2e80 +0 -0
  91. data/test/dummy/tmp/cache/assets/test/sprockets/ae168f5fd9c4439b289abdb476b026b7 +0 -0
  92. data/test/dummy/tmp/cache/assets/test/sprockets/b0b29e7227617890cf734f30d2ec810e +0 -0
  93. data/test/dummy/tmp/cache/assets/test/sprockets/b3b0b443293be8cc1ebeefa441c1d56f +0 -0
  94. data/test/dummy/tmp/cache/assets/test/sprockets/bd73f0158510de99a53a18f4aeb1fb90 +0 -0
  95. data/test/dummy/tmp/cache/assets/test/sprockets/bec5edffa453a85a42afd4849f868e81 +0 -0
  96. data/test/dummy/tmp/cache/assets/test/sprockets/c04795d4fdfb36d2041fd2ee97edfdfe +0 -0
  97. data/test/dummy/tmp/cache/assets/test/sprockets/c16b6da8711e06b53e78abd01064762c +0 -0
  98. data/test/dummy/tmp/cache/assets/test/sprockets/c1ccccbc73ad9c18a4f6e82a196a2fc2 +0 -0
  99. data/test/dummy/tmp/cache/assets/test/sprockets/c8030c204c8e82370802bab4d708040d +0 -0
  100. data/test/dummy/tmp/cache/assets/test/sprockets/cc7bd06bb71f2155aeeb684d0d880988 +0 -0
  101. data/test/dummy/tmp/cache/assets/test/sprockets/cd0653a7baafdb4f0f1d06fd848a93ad +0 -0
  102. data/test/dummy/tmp/cache/assets/test/sprockets/cd0d14bed7965532879e84a4b6df7188 +0 -0
  103. data/test/dummy/tmp/cache/assets/test/sprockets/ce2d46fba538c6756b32019ae8500047 +0 -0
  104. data/test/dummy/tmp/cache/assets/test/sprockets/cfd79f791d02847181f8fcf1dcf2763e +0 -0
  105. data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  106. data/test/dummy/tmp/cache/assets/test/sprockets/d3d217eee875712c702e7b5aa7f61a5f +0 -0
  107. data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  108. data/test/dummy/tmp/cache/assets/test/sprockets/dda16ed9cc1e54fd0d97a6036e928d8d +0 -0
  109. data/test/dummy/tmp/cache/assets/test/sprockets/e07c4addcee44a21398170318c44a63c +0 -0
  110. data/test/dummy/tmp/cache/assets/test/sprockets/e26d2dade8b9049db6fe17631d69c20e +0 -0
  111. data/test/dummy/tmp/cache/assets/test/sprockets/e988f9e2cbcefc5fc9b5d9961bb5da0d +0 -0
  112. data/test/dummy/tmp/cache/assets/test/sprockets/f1555999bb69d971b3a4a7128e83efea +0 -0
  113. data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  114. data/test/dummy/tmp/cache/assets/test/sprockets/fc1a71f26b662f0fdb7dc872c0d12cc2 +0 -0
  115. data/test/{unit/helpers → helpers}/contour_helper_test.rb +0 -0
  116. data/test/{unit → models}/authentication_test.rb +0 -0
  117. data/test/{unit → models}/user_test.rb +0 -0
  118. metadata +186 -21
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OGRmNTYzMzNhNzdmZTkwZGU2YjdmZTVmNWRhZjdjYjQyMjZmZDlmNQ==
4
+ MDJhYTFmMzI2ZjY4MzA5YjRjYTA4MTFmY2VkMTY1YTgyZTc3ZWExYw==
5
5
  data.tar.gz: !binary |-
6
- Zjk5MTZiMjI0MTNjZDM3Y2Q0NGNmYzBjMGNkMmU3MTc3NmRjMjUxNA==
6
+ MTI5ZmNlODk1NjM3NmVjMTNlOWY1OTI4NDNjN2RmZTVhMjNhOTAwNw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NDIxM2JiYTI3Njg3ODFjYThjNjY0YmJkMGVlMGZhM2MyZjdjM2QyZTg1Njkx
10
- NTA2NjhmZTQyYjc5ZWU2OTI2NTdjOWZiNDFjODIwMmExZDJkN2ZiNjVjN2Nj
11
- YjE4OTEwMDkyMGNiYjk5ZTZkNGEzYWFmYTEwZTEzMTBlMjk5OTM=
9
+ NmQxZjZlNWNlOGNiNjgyMGRjOTE1NzhjODQzMWNkMDJiNjc4ZDI4NDIxMjgz
10
+ YzEzOTE4ZmZmMGE2ZGJiNjgzYjg1MjBkYjY5OTA5ZjY4ODFlOWQzZDc2MjEw
11
+ MjA5ZDQ3NmVmZjdiMTcyZmRjYWNlNDdiMjhhOWM0MzMzZGE3NTA=
12
12
  data.tar.gz: !binary |-
13
- NTU3ZDg0NmE2MzA5YTVjNDVhZDA5ZjM5YWI0NjI1ODBhMDdkMTdkYjk1ZGE0
14
- ODdhMTE3MWIzYTJjMmJjMTk1NjEzOWNlYmJmMTZmMmYwY2NhY2YxMGY1YjBh
15
- YzM5MDk1NzFmMmE0NTg1NTg3NDlmZDNmZGNhMDJkNjMyN2UzMjc=
13
+ YjUyOTRhYTRiZmQ5ZTM2ZWNhN2IxOTE0YTQzZDdmMmI2MGY3MTU1MzBhYWQ4
14
+ YTkwZTY2N2QzZTY5MDRlMmI1ZjE4M2I0ZTU1ZjA0NzZmMjQ2NDM0YTRhMzdi
15
+ NDY2MDNmNGVmNjI4MmVjMDEwZmIwYjJlNjg5YmNkMGZiYTQ3ZDE=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 2.0.0
2
+
3
+ ### Enhancements
4
+ - **Gem Changes**
5
+ - Updated to Rails 4.0.0.beta1
6
+
1
7
  ## 1.3.0 (February 26, 2013)
2
8
 
3
9
  ### Breaking Changes
data/README.md CHANGED
@@ -22,7 +22,7 @@ gem 'contour'
22
22
 
23
23
  ## Getting started
24
24
 
25
- Make sure you have Rails 3.2.12
25
+ Make sure you have Rails 4.0.0
26
26
 
27
27
  ```console
28
28
  rails -v
@@ -35,7 +35,7 @@ cd blank_rails_project
35
35
  Modify `Gemfile` and add
36
36
 
37
37
  ```ruby
38
- gem 'contour', '~> 1.2.1'
38
+ gem 'contour', '~> 2.0.0'
39
39
  ```
40
40
 
41
41
  Run Bundle install
@@ -70,12 +70,6 @@ Create a sample controller
70
70
  rails generate controller welcome index --skip-stylesheets
71
71
  ```
72
72
 
73
- Remove the `public/index.html`
74
-
75
- ```console
76
- rm public/index.html
77
- ```
78
-
79
73
  Add the following line to your `app/controllers/application_controller.rb`
80
74
 
81
75
  ```ruby
@@ -111,36 +105,21 @@ root to: 'welcome#index'
111
105
  Add the following to the top of your `app/controllers/welcome_controller.rb`
112
106
 
113
107
  ```ruby
114
- before_filter :authenticate_user!
108
+ before_action :authenticate_user!
115
109
  ```
116
110
 
117
111
  Add the following to your `app/models/user.rb`
118
112
 
119
113
  ```ruby
120
- # Model Relationships
121
- has_many :authentications
122
-
123
- def apply_omniauth(omniauth)
124
- unless omniauth['info'].blank?
125
- self.email = omniauth['info']['email'] if email.blank?
126
- end
127
- self.password = Devise.friendly_token[0,20] if self.password.blank?
128
- authentications.build( provider: omniauth['provider'], uid: omniauth['uid'] )
129
- end
130
-
131
- def password_required?
132
- (authentications.empty? || !password.blank?) && super
133
- end
114
+ # Concerns
115
+ include Contourable
134
116
  ```
135
117
 
136
118
  Add the following to your `app/models/authentication.rb`
137
119
 
138
120
  ```ruby
139
- belongs_to :user
140
-
141
- def provider_name
142
- OmniAuth.config.camelizations[provider.to_s.downcase] || provider.to_s.titleize
143
- end
121
+ # Concerns
122
+ include ContourAuthenticatable
144
123
  ```
145
124
 
146
125
  Edit `config/initializers/devise.rb` to use `:get` for devise `sign_out_via`
@@ -181,7 +160,7 @@ rails g scaffold Item name:string description:text user_id:integer bought_date:d
181
160
  Add a current `scope` and `belongs_to` relationship to `app/models/item.rb`
182
161
 
183
162
  ```ruby
184
- scope :current, conditions: { }
163
+ scope :current, -> { all }
185
164
 
186
165
  belongs_to :user
187
166
  ```
@@ -189,7 +168,7 @@ belongs_to :user
189
168
  Add a current `scope` and `has_many` relationship to `app/models/user.rb` along with name placeholder
190
169
 
191
170
  ```ruby
192
- scope :current, conditions: { }
171
+ scope :current, -> { all }
193
172
 
194
173
  has_many :items
195
174
 
data/Rakefile CHANGED
@@ -1,35 +1,17 @@
1
1
  #!/usr/bin/env rake
2
- begin
3
- require 'bundler/setup'
4
- rescue LoadError
5
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
- end
7
- begin
8
- require 'rdoc/task'
9
- rescue LoadError
10
- require 'rdoc/rdoc'
11
- require 'rake/rdoctask'
12
- RDoc::Task = Rake::RDocTask
13
- end
14
2
 
15
- RDoc::Task.new(:rdoc) do |rdoc|
16
- rdoc.rdoc_dir = 'rdoc'
17
- rdoc.title = 'Contour'
18
- rdoc.options << '--line-numbers'
19
- rdoc.rdoc_files.include('CHANGELOG.rdoc')
20
- rdoc.rdoc_files.include('README.rdoc')
21
- rdoc.rdoc_files.include('lib/**/*.rb')
22
- end
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
5
+ require 'rdoc/task'
6
+
7
+ desc 'Default: run contour tests'
8
+ task default: :test
23
9
 
24
10
  APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
25
11
  load 'rails/tasks/engine.rake'
26
12
 
27
-
28
-
29
13
  Bundler::GemHelper.install_tasks
30
14
 
31
- require 'rake/testtask'
32
-
33
15
  Rake::TestTask.new(:test) do |t|
34
16
  t.libs << 'lib'
35
17
  t.libs << 'test'
@@ -37,5 +19,12 @@ Rake::TestTask.new(:test) do |t|
37
19
  t.verbose = false
38
20
  end
39
21
 
22
+ desc 'Generate documentation for Contour'
23
+ Rake::RDocTask.new(:rdoc) do |rdoc|
24
+ rdoc.rdoc_dir = 'rdoc'
25
+ rdoc.title = 'Contour'
26
+ rdoc.options << '--line-numbers' << '--inline-source'
27
+ rdoc.rdoc_files.include('README.md')
28
+ rdoc.rdoc_files.include('lib/**/*.rb')
29
+ end
40
30
 
41
- task default: :test
@@ -17,38 +17,39 @@
17
17
  @nonStandardClick = (event) ->
18
18
  event.which > 1 or event.metaKey or event.ctrlKey or event.shiftKey or event.altKey
19
19
 
20
- jQuery ->
21
- $(".timepicker").timepicker
22
- showMeridian: false
23
- showSeconds: true
24
- defaultTime: false
25
- $(".datepicker").datepicker('remove')
26
- $(".datepicker").datepicker( autoclose: true )
27
-
28
- $(document).on('change', '.datepicker', () ->
20
+ $(document)
21
+ .on('change', '.datepicker', () ->
29
22
  try
30
23
  $(this).val($.datepicker.formatDate('mm/dd/yy', $.datepicker.parseDate('mm/dd/yy', $(this).val())))
31
24
  catch error
32
25
  # Nothing
33
26
  )
34
-
35
- $(document).on('click', ".pagination a, .page a, .next a, .prev a", () ->
27
+ .on('click', ".pagination a, .page a, .next a, .prev a", () ->
36
28
  return false if $(this).parent().is('.active, .disabled, .per_page')
37
29
  $.get(this.href, null, null, "script")
38
30
  false
39
31
  )
40
-
41
- $(document).on("click", ".per_page a", () ->
32
+ .on("click", ".per_page a", () ->
42
33
  object_class = $(this).data('object')
43
34
  $.get($("#"+object_class+"_search").attr("action"), $("#"+object_class+"_search").serialize() + "&"+object_class+"_per_page="+ $(this).data('count'), null, "script")
44
35
  false
45
36
  )
46
-
47
- $(document).on('click', '[data-object~="order"]', () ->
37
+ .on('click', '[data-object~="order"]', () ->
48
38
  $('#order').val($(this).data('order'))
49
39
  $($(this).data('form')).submit()
50
40
  false
51
41
  )
52
42
 
43
+ @ready = () ->
44
+ $(".timepicker").timepicker
45
+ showMeridian: false
46
+ showSeconds: true
47
+ defaultTime: false
48
+ $(".datepicker").datepicker('remove')
49
+ $(".datepicker").datepicker( autoclose: true )
50
+
53
51
  # Load forms on page load
54
52
  $('[data-object~="form-load"]').submit()
53
+
54
+ $(document).ready(ready)
55
+ # $(document).on('page:load', ready)
@@ -1,4 +1,6 @@
1
1
  class Contour::AuthenticationsController < ApplicationController
2
+ skip_before_action :verify_authenticity_token, only: :create
3
+
2
4
  def index
3
5
  @authentications = current_user.authentications if current_user
4
6
  end
@@ -1,7 +1,4 @@
1
1
  class Authentication < ActiveRecord::Base
2
- belongs_to :user
3
-
4
- def provider_name
5
- OmniAuth.config.camelizations[provider.to_s.downcase] || provider.to_s.titleize
6
- end
2
+ # Concerns
3
+ include ContourAuthenticatable
7
4
  end
@@ -0,0 +1,12 @@
1
+ module ContourAuthenticatable
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ belongs_to :user
6
+ end
7
+
8
+ def provider_name
9
+ OmniAuth.config.camelizations[provider.to_s.downcase] || provider.to_s.titleize
10
+ end
11
+
12
+ end
@@ -0,0 +1,19 @@
1
+ module Contourable
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ has_many :authentications
6
+ end
7
+
8
+ def apply_omniauth(omniauth)
9
+ unless omniauth['info'].blank?
10
+ self.email = omniauth['info']['email'] if email.blank?
11
+ end
12
+ self.password = Devise.friendly_token[0,20] if self.password.blank?
13
+ authentications.build( provider: omniauth['provider'], uid: omniauth['uid'] )
14
+ end
15
+
16
+ def password_required?
17
+ (authentications.empty? || !password.blank?) && super
18
+ end
19
+ end
@@ -12,7 +12,7 @@
12
12
  <script src="//html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
13
13
  <![endif]-->
14
14
 
15
- <%= stylesheet_link_tag "application", media: "all" %>
15
+ <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
16
16
  </head>
17
17
  <body>
18
18
  <div class="navbar navbar-inverse navbar-fixed-top">
@@ -29,7 +29,7 @@
29
29
  <%= yield %>
30
30
  </div>
31
31
 
32
- <%= javascript_include_tag "application" %>
32
+ <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
33
33
  <%= javascript_tag "var root_url='#{request.script_name + '/'}';var auth_token='#{form_authenticity_token}';" %>
34
34
  </body>
35
35
  </html>
data/config/routes.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  Rails.application.routes.draw do
2
2
 
3
- match '/auth/failure' => 'contour/authentications#failure'
4
- match '/auth/:provider/callback' => 'contour/authentications#create'
5
- match '/auth/:provider' => 'contour/authentications#passthru'
6
- match '/contour' => 'contour/samples#index'
3
+ get '/auth/failure' => 'contour/authentications#failure'
4
+ post '/auth/:provider/callback' => 'contour/authentications#create'
5
+ get '/auth/:provider' => 'contour/authentications#passthru'
6
+ get '/contour' => 'contour/samples#index'
7
7
 
8
8
  resources :authentications, controller: 'contour/authentications'
9
9
 
data/contour.gemspec CHANGED
@@ -17,15 +17,17 @@ Gem::Specification.new do |s|
17
17
  s.homepage = 'https://github.com/remomueller'
18
18
  s.summary = 'Basic Rails framework files and assets for layout and authentication'
19
19
  s.description = 'Basic Rails Framework files and assets for layout and authentication'
20
+ s.license = 'CC BY-NC-SA 3.0'
20
21
 
21
22
  s.platform = Gem::Platform::RUBY
22
23
 
23
24
  s.files = Dir["{app,config,db,lib}/**/*"] + ["CHANGELOG.md", "contour.gemspec", "LICENSE", "Rakefile", "README.md"]
24
25
  s.test_files = Dir["test/**/*"]
25
26
 
26
- s.add_dependency 'rails', '~> 3.2.12'
27
+ s.add_dependency 'rails', '~> 4.0.0.beta1'
27
28
  s.add_dependency 'jquery-rails', '~> 2.2.1'
28
- s.add_dependency 'devise', '~> 2.2.3'
29
+ s.add_dependency 'coffee-rails', '~> 4.0.0.beta1'
30
+ # s.add_dependency 'devise', '~> 2.2.3' # Currently in Gemfile
29
31
  s.add_dependency 'omniauth', '~> 1.1.3'
30
32
  s.add_dependency 'omniauth-cas', '~> 1.0.1'
31
33
  s.add_dependency 'omniauth-facebook', '~> 1.4.1'
@@ -1,9 +1,9 @@
1
1
  module Contour
2
2
  module VERSION #:nodoc:
3
- MAJOR = 1
4
- MINOR = 3
3
+ MAJOR = 2
4
+ MINOR = 0
5
5
  TINY = 0
6
- BUILD = nil # nil, "pre", "rc", "rc2"
6
+ BUILD = "beta.1" # nil, "pre", "rc", "rc2"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
9
9
  end
@@ -1,4 +1,4 @@
1
- <%%= render partial: 'contour/layouts/per_page', locals: { type: '<%= resource_name_plural %>', per_page: 20, object_count: @<%= resource_name %>_count } %>
1
+ <%%= render partial: 'contour/layouts/per_page', locals: { type: '<%= resource_name_plural %>', per_page: 20, object_count: @<%= resource_name_plural %>.total_count } %>
2
2
 
3
3
  <table class="table table-striped table-bordered" style="width:100%">
4
4
  <thead>
@@ -1,60 +1,39 @@
1
1
  class <%= resource_class_name_plural %>Controller < ApplicationController
2
- before_filter :authenticate_user!
2
+ before_action :authenticate_user!
3
+ before_action :set_<%= resource_name %>, only: [:show, :edit, :update, :destroy]
3
4
 
4
5
  # GET /<%= resource_name_plural %>
5
6
  # GET /<%= resource_name_plural %>.json
6
7
  def index
7
- <%= resource_name %>_scope = <%= resource_class_name %>.current
8
8
  @order = scrub_order(<%= resource_class_name %>, params[:order], "<%= resource_name_plural %>.name")
9
- <%= resource_name %>_scope = <%= resource_name %>_scope.order(@order)
10
- @<%= resource_name %>_count = <%= resource_name %>_scope.count
11
- @<%= resource_name_plural %> = <%= resource_name %>_scope.page(params[:page]).per( 20 )
12
-
13
- respond_to do |format|
14
- format.html # index.html.erb
15
- format.js
16
- format.json { render json: @<%= resource_name_plural %> }
17
- end
9
+ @<%= resource_name_plural %> = <%= resource_class_name %>.current.order(@order).page(params[:page]).per( 20 )
18
10
  end
19
11
 
20
12
  # GET /<%= resource_name_plural %>/1
21
13
  # GET /<%= resource_name_plural %>/1.json
22
14
  def show
23
- @<%= resource_name %> = <%= resource_class_name %>.current.find(params[:id])
24
-
25
- respond_to do |format|
26
- format.html # show.html.erb
27
- format.json { render json: @<%= resource_name %> }
28
- end
29
15
  end
30
16
 
31
17
  # GET /<%= resource_name_plural %>/new
32
- # GET /<%= resource_name_plural %>/new.json
33
18
  def new
34
19
  @<%= resource_name %> = <%= resource_class_name %>.new
35
-
36
- respond_to do |format|
37
- format.html # new.html.erb
38
- format.json { render json: @<%= resource_name %> }
39
- end
40
20
  end
41
21
 
42
22
  # GET /<%= resource_name_plural %>/1/edit
43
23
  def edit
44
- @<%= resource_name %> = <%= resource_class_name %>.current.find(params[:id])
45
24
  end
46
25
 
47
26
  # POST /<%= resource_name_plural %>
48
27
  # POST /<%= resource_name_plural %>.json
49
28
  def create
50
- @<%= resource_name %> = <%= resource_class_name %>.new(post_params)
29
+ @<%= resource_name %> = <%= resource_class_name %>.new(<%= resource_name %>_params)
51
30
 
52
31
  respond_to do |format|
53
32
  if @<%= resource_name %>.save
54
33
  format.html { redirect_to @<%= resource_name %>, notice: '<%= resource_class_name %> was successfully created.' }
55
- format.json { render json: @<%= resource_name %>, status: :created, location: @<%= resource_name %> }
34
+ format.json { render action: 'show', status: :created, location: @<%= resource_name %> }
56
35
  else
57
- format.html { render action: "new" }
36
+ format.html { render action: 'new' }
58
37
  format.json { render json: @<%= resource_name %>.errors, status: :unprocessable_entity }
59
38
  end
60
39
  end
@@ -63,14 +42,12 @@ class <%= resource_class_name_plural %>Controller < ApplicationController
63
42
  # PUT /<%= resource_name_plural %>/1
64
43
  # PUT /<%= resource_name_plural %>/1.json
65
44
  def update
66
- @<%= resource_name %> = <%= resource_class_name %>.current.find(params[:id])
67
-
68
45
  respond_to do |format|
69
- if @<%= resource_name %>.update_attributes(post_params)
46
+ if @<%= resource_name %>.update(<%= resource_name %>_params)
70
47
  format.html { redirect_to @<%= resource_name %>, notice: '<%= resource_class_name %> was successfully updated.' }
71
48
  format.json { head :no_content }
72
49
  else
73
- format.html { render action: "edit" }
50
+ format.html { render action: 'edit' }
74
51
  format.json { render json: @<%= resource_name %>.errors, status: :unprocessable_entity }
75
52
  end
76
53
  end
@@ -79,7 +56,6 @@ class <%= resource_class_name_plural %>Controller < ApplicationController
79
56
  # DELETE /<%= resource_name_plural %>/1
80
57
  # DELETE /<%= resource_name_plural %>/1.json
81
58
  def destroy
82
- @<%= resource_name %> = <%= resource_class_name %>.current.find(params[:id])
83
59
  @<%= resource_name %>.destroy
84
60
 
85
61
  respond_to do |format|
@@ -89,29 +65,32 @@ class <%= resource_class_name_plural %>Controller < ApplicationController
89
65
  end
90
66
 
91
67
  private
68
+ # Use callbacks to share common setup or constraints between actions.
69
+ def set_<%= resource_name %>
70
+ @<%= resource_name %> = <%= resource_class_name %>.current.find(params[:id])
71
+ end
92
72
 
93
- def post_params
94
- params[:<%= resource_name %>] ||= {}
73
+ # Never trust parameters from the scary internet, only allow the white list through.
74
+ def <%= resource_name %>_params
75
+ params[:<%= resource_name %>] ||= {}
95
76
 
96
- [<%= date_columns.collect{|c| ":#{c.name}"}.join(', ') %>].each do |date|
97
- params[:<%= resource_name %>][date] = parse_date(params[:<%= resource_name %>][date])
98
- end
77
+ [<%= date_columns.collect{|c| ":#{c.name}"}.join(', ') %>].each do |date|
78
+ params[:<%= resource_name %>][date] = parse_date(params[:<%= resource_name %>][date])
79
+ end
99
80
 
100
- params[:<%= resource_name %>].slice(
101
- <%= columns.collect{|c| ":#{c.name}"}.join(', ') %>
102
- )
103
- end
81
+ params.require(:<%= resource_name %>).permit(<%= columns.collect{|c| ":#{c.name}"}.join(', ') %>)
82
+ end
104
83
 
105
- # Scrub order and parse_date can be moved to your ApplicationController
106
- def scrub_order(model, params_order, default_order)
107
- (params_column, params_direction) = params_order.to_s.strip.downcase.split(' ')
108
- direction = (params_direction == 'desc' ? 'DESC' : nil)
109
- column_name = (model.column_names.collect{|c| model.table_name + "." + c}.select{|c| c == params_column}.first)
110
- order = column_name.blank? ? default_order : [column_name, direction].compact.join(' ')
111
- order
112
- end
84
+ # Scrub order and parse_date can be moved to your ApplicationController
85
+ def scrub_order(model, params_order, default_order)
86
+ (params_column, params_direction) = params_order.to_s.strip.downcase.split(' ')
87
+ direction = (params_direction == 'desc' ? 'DESC' : nil)
88
+ column_name = (model.column_names.collect{|c| model.table_name + "." + c}.select{|c| c == params_column}.first)
89
+ order = column_name.blank? ? default_order : [column_name, direction].compact.join(' ')
90
+ order
91
+ end
113
92
 
114
- def parse_date(date_string, default_date = '')
115
- date_string.to_s.split('/').last.size == 2 ? Date.strptime(date_string, "%m/%d/%y") : Date.strptime(date_string, "%m/%d/%Y") rescue default_date
116
- end
93
+ def parse_date(date_string, default_date = '')
94
+ date_string.to_s.split('/').last.size == 2 ? Date.strptime(date_string, "%m/%d/%y") : Date.strptime(date_string, "%m/%d/%Y") rescue default_date
95
+ end
117
96
  end