onotole 1.1.8 → 1.1.9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 96de0029e7019c7a24baa11fe02c3dfbf2885791
4
- data.tar.gz: 4cb1572ff02d0488ac8233b88caa73416174340b
3
+ metadata.gz: 92b16a7eca73f72e3a44ca3ddd958196e07d5957
4
+ data.tar.gz: 5a77d6791467b354f9731dcefd3945aa96045b89
5
5
  SHA512:
6
- metadata.gz: 716dd82e55be8990e1da50ada07d866bd9989420693b5e42f35136b9333fa0cb6cfaa08a5ec4358f93b1a660bf24bf3f634db9106e11163700241df60f61c766
7
- data.tar.gz: 47047e1a1c61c793ed9f7a397c1444a13852f5b2a65d057d96e88910c766901db9cbd77cd11abef1372fa90b73d9f880d645078dd7092874a5dadd151c33f757
6
+ metadata.gz: 9d8155c1d60d556935d7cfb1ebc5e2775a25ab5b50df32402fdbaf5f1667025c980a5300c36bc5434dcc72bffcda9667a2bf9006a54361d88fd6c7abd24a9397
7
+ data.tar.gz: 1fb4f0f94ee7fbcd2e8d5edc163c161faf39d82923623cd82082ae5e67ac8b7927c998b78e81bb7b000bac970d282d15f8683671c04d532a0e3a4e94573165ce
data/README.md CHANGED
@@ -149,6 +149,8 @@ it through a dream. http://mailcatcher.me
149
149
  latin to cyrillic and vice versa
150
150
  * [fotoramajs](https://github.com/ai/fotoramajs) Fotorama JS gallery for Ruby
151
151
  on Rails http://fotorama.io/
152
+ * [rack-cors](https://github.com/cyu/rack-cors) Rack Middleware for handling
153
+ Cross-Origin Resource Sharing (CORS), which makes cross-origin AJAX possible.
152
154
 
153
155
  ##### XLS & PDF
154
156
 
@@ -0,0 +1,17 @@
1
+ ## Public errors customization (404,422,500...)
2
+
3
+ Today I got a task to customize errors, and found
4
+ [one useful article](https://wearestac.com/blog/dynamic-error-pages-in-rails),
5
+ but with `Onotole` it is much easyer. You need a very little part of code.
6
+ In default pack you actually have `Hight voltage` gem, witch will make all work.
7
+ Add in your `config/application.rb` this line:
8
+ ```
9
+ module MyAwesome
10
+ class Application < Rails::Application
11
+ ...
12
+ config.exceptions_app = self.routes
13
+ end
14
+ end
15
+ ```
16
+ And now `Hight voltage` is in play! Make in `app/views/pages/404.html.erb` (or
17
+ any other template) and here it is.
@@ -7,6 +7,7 @@ module Onotole
7
7
  :underscore_rails,
8
8
  :gmaps4rails,
9
9
  :mailcatcher,
10
+ :rack_cors,
10
11
  :devise,
11
12
  :validates_timeliness,
12
13
  :paper_trail,
@@ -222,20 +223,17 @@ end
222
223
  end
223
224
 
224
225
  def after_install_fotoramajs
225
- return unless user_choose? :fotoramajs
226
226
  inject_into_file(AppBuilder.js_file, "\n//= require fotorama",
227
227
  after: '//= require jquery_ujs')
228
228
  append_file(AppBuilder.app_file_scss, "\n@import 'fotorama'")
229
229
  end
230
230
 
231
231
  def after_install_underscore_rails
232
- return unless user_choose? :underscore_rails
233
232
  inject_into_file(AppBuilder.js_file, "\n//= require underscore",
234
233
  after: '//= require jquery_ujs')
235
234
  end
236
235
 
237
236
  def after_install_gmaps4rails
238
- return unless user_choose? :gmaps4rails
239
237
  inject_into_file(AppBuilder.js_file, "\n//= require gmaps/google",
240
238
  after: '//= require underscore')
241
239
  end
@@ -255,5 +253,20 @@ end
255
253
  replace_in_file 'config/environments/development.rb',
256
254
  'config.action_mailer.delivery_method = :file', config
257
255
  end
256
+
257
+ def after_install_rack_cors
258
+ config = <<-RUBY
259
+
260
+ config.middleware.insert_before 0, "Rack::Cors" do
261
+ allow do
262
+ origins '*'
263
+ resource '*', :headers => :any, :methods => [:get, :post, :options]
264
+ end
265
+ end
266
+
267
+ RUBY
268
+
269
+ inject_into_class 'config/application.rb', 'Application', config
270
+ end
258
271
  end
259
272
  end
@@ -290,5 +290,9 @@ module Onotole
290
290
  def add_mailcatcher_gem
291
291
  inject_into_file('Gemfile', "\n gem 'mailcatcher'", after: 'group :development do')
292
292
  end
293
+
294
+ def add_rack_cors_gem
295
+ inject_into_file('Gemfile', "\ngem 'rack-cors', :require => 'rack/cors'", after: '# user_choice')
296
+ end
293
297
  end
294
298
  end
@@ -114,7 +114,8 @@ module Onotole
114
114
  prawn: 'Prawn gem for PDF support vs prawn-table for easy tables',
115
115
  axlsx_rails: 'XLS support, cyrillic support, good support at all',
116
116
  geocoder: 'Complete Ruby geocoding solution. http://www.rubygeocoder.com',
117
- gmaps4rails: 'Enables easy Google map + overlays creation. http://apneadiving.github.io/'
117
+ gmaps4rails: 'Enables easy Google map + overlays creation. http://apneadiving.github.io/',
118
+ rack_cors: 'Rack Middleware for handling Cross-Origin Resource Sharing (CORS).'
118
119
  }
119
120
  multiple_choice('Write numbers of all preferred gems.', variants).each do |gem|
120
121
  add_to_user_choise gem
@@ -6,6 +6,7 @@ module Onotole
6
6
  airbrake_check
7
7
  graphviz_check
8
8
  image_optim_check
9
+ rack_cors_check
9
10
  say_color BOLDGREEN, "Congratulations! Onotole gives you: 'Intellect+= 1'"
10
11
  end
11
12
 
@@ -31,5 +32,10 @@ module Onotole
31
32
  say_color YELLOW, "You may install 'svgo' for 'image_optim' by `npm install -g svgo`"
32
33
  say_color YELLOW, "You may install 'pngout' for 'image_optim' from http://www.jonof.id.au/kenutils"
33
34
  end
35
+
36
+ def rack_cors_check
37
+ return unless user_choose? :rack_cors
38
+ say_color YELLOW, 'Check your config/application.rb file for rack-cors settings for security.'
39
+ end
34
40
  end
35
41
  end
@@ -77,7 +77,9 @@ module Onotole
77
77
  end
78
78
 
79
79
  def add_vendor_css_path
80
- vendor_css_path = "\nRails.application.config.assets.paths += Dir[(Rails.root.join('vendor/assets/stylesheets'))]"
80
+ vendor_css_path = "\nRails.application.config.assets.paths += Dir"\
81
+ "[(Rails.root.join('vendor/assets/stylesheets'))]\n"\
82
+ "Rails.application.config.assets.paths += Dir[(Rails.root.join('vendor/assets/images'))]"
81
83
  append_file 'config/initializers/assets.rb', vendor_css_path
82
84
  end
83
85
 
@@ -2,5 +2,5 @@
2
2
  module Onotole
3
3
  RAILS_VERSION = '~> 4.2.0'
4
4
  RUBY_VERSION = IO.read("#{File.dirname(__FILE__)}/../../.ruby-version").strip
5
- VERSION = '1.1.8'
5
+ VERSION = '1.1.9'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onotole
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.8
4
+ version: 1.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - kvokka
@@ -80,6 +80,7 @@ files:
80
80
  - bin/rake
81
81
  - bin/rspec
82
82
  - bin/setup
83
+ - goodies/custom_404_and_others_in_1_minute.md
83
84
  - goodies/mailcatcher_loading_patch.md
84
85
  - lib/onotole.rb
85
86
  - lib/onotole/actions.rb