revelry_content 0.0.1.1 → 0.0.1.2

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: bef437f3c11d55256e157563635ffc4310b268c1
4
- data.tar.gz: 53f2dd0abaf1fe847a88b7647b6530b9bbf858ec
3
+ metadata.gz: d57f008f016c584fc60768a5c49a53ebdb5ba404
4
+ data.tar.gz: ff49d78be60b93f65f80bddad50fd5d3831349fe
5
5
  SHA512:
6
- metadata.gz: 79e9d46095a0c15a7d0d919180da3fb20d2f400e065c0e9faf86fa4c87d32ff14a9dcadb686182cf7960badba8676d4260d2c83443a018da268d2233165953d0
7
- data.tar.gz: fe731925368b398e67ee3822d51ea4f0907bddb7117197335777321980a1bda58e4656e1b844770f9d0f0090daa958d3eb3b43a23a6108c6f532bdcec332482d
6
+ metadata.gz: e61ebb2af92ac13c2054557738082162d8e1066b43f81e32d63a6566955de141b3ed86cf79f7b8e07559d202f26bc2d9d33af901c50d25b534a949490eeb8014
7
+ data.tar.gz: 21387b6aaf8c2c34d83585636742bc8fab9991f8447d715357c5d02b64b6800638c0a8b67a25180feed669d2d2360f9d98ae1643309205a866dad6d24a782647
data/README.md CHANGED
@@ -5,71 +5,29 @@ RevelryContent is a gem for managing admin-editable content within Rails applica
5
5
 
6
6
  # Installation
7
7
 
8
- Add it to your gemfile.
8
+ Either install from a rails template:
9
9
 
10
- Then run:
11
-
12
- ```bash
13
- bundle install
14
- rails g revelry_content:install
15
- rake db:migrate
10
+ ```shell
11
+ rails new APPNAME -m https://raw.githubusercontent.com/revelrylabs/revelry_content/master/template.rb
16
12
  ```
17
13
 
18
- Mount the engine in your routes.rb file:
14
+ Or add it to your gemfile:
19
15
 
20
16
  ```ruby
21
- mount RevelryContent::Engine => "/revelry_content"
17
+ gem 'revelry_content'
22
18
  ```
23
19
 
24
- Include RevelryContent::WithRevelryContent in any controllers which need to show editable
25
- content. You probably want to include it in ApplicationController like so:
26
-
27
- ```ruby
28
- class ApplicationController
29
- include RevelryContent::WithRevelryContent
30
- def index; end
31
- end
32
- ```
20
+ and install it:
33
21
 
34
- And include the editor javascript:
35
- ```javascript
36
- //= require revelry_content
37
- ```
38
-
39
- Add include the editor stylesheet:
40
- ```css
41
- /*
42
- *= require revelry_content/application
43
- */
22
+ ```shell
23
+ bundle
24
+ rails g revelry_content:install
44
25
  ```
45
26
 
46
-
47
27
  # Configuration
48
28
 
49
- ## Configuring authentication
50
-
51
- ```ruby
52
- RevelryContent.configure do |config|
53
- config.user_for_content do |controller|
54
- # Your authentication logic here
55
- controller.current_user
56
- end
57
- end
58
- ```
59
-
60
- ## Configuring authorization
61
-
62
- You can set a block which takes two params `user` and `content` to handle authorization.
63
- True is authorized, false is unauthorized.
64
-
65
- ```ruby
66
- RevelryContent.configure do |config|
67
- config.authorization_policy do |user|
68
- # Your authorization logic here
69
- user.admin?
70
- end
71
- end
72
- ```
29
+ The installer makes an initializer in `config/initializer.rb`. You can edit it
30
+ to customize authenticiation, authorization or javascript export settings.
73
31
 
74
32
  ## Configuring file uploads
75
33
 
@@ -0,0 +1,47 @@
1
+ module RevelryContent
2
+ module Generators
3
+ class CssGenerator < ::Rails::Generators::Base
4
+ CSS_FILE_EXTENSIONS = %w(
5
+ .css
6
+ .css.sass
7
+ .css.scss
8
+ .sass
9
+ .scss
10
+ )
11
+
12
+ def add_css_assets
13
+ if using_sass?
14
+ append_to_file css_app_bundle do
15
+ '@import "revelry_content";'
16
+ end
17
+ else
18
+ insert_into_file css_app_bundle, before: %r{(//|\*)= require_self} do
19
+ "*= require revelry_content\n "
20
+ end
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def using_sass?
27
+ /s(c|a)ss/.match(css_file_extname)
28
+ end
29
+
30
+ def css_app_bundle
31
+ File.join(css_base_dir, "application#{ css_file_extname }")
32
+ end
33
+
34
+ def css_base_dir
35
+ File.join('app', 'assets', 'stylesheets')
36
+ end
37
+
38
+ def test_css_format(fmt)
39
+ File.exist?(File.join(css_base_dir, "application#{ fmt }"))
40
+ end
41
+
42
+ def css_file_extname
43
+ CSS_FILE_EXTENSIONS.find { |fmt| test_css_format(fmt) }
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,11 @@
1
+ module RevelryContent
2
+ module Generators
3
+ class InitializerGenerator < ::Rails::Generators::Base
4
+ source_root File.expand_path('../templates', __FILE__)
5
+
6
+ def add_initializer
7
+ template 'initializer.rb', 'config/initializers/revelry_content.rb'
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,24 +1,37 @@
1
- require 'rails/generators/migration'
2
-
3
1
  module RevelryContent
4
2
  module Generators
5
3
  class InstallGenerator < ::Rails::Generators::Base
6
- include Rails::Generators::Migration
7
- source_root File.expand_path('../templates', __FILE__)
8
- desc "add the migrations"
4
+ def add_migrations
5
+ generate 'revelry_content:migrations'
6
+ rake 'db:migrate'
7
+ end
8
+
9
+ def add_js_assets
10
+ generate 'revelry_content:js'
11
+ end
12
+
13
+ def add_css_assets
14
+ generate 'revelry_content:css'
15
+ end
9
16
 
10
- def self.next_migration_number(path)
11
- unless @prev_migration_nr
12
- @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
13
- else
14
- @prev_migration_nr += 1
17
+ def add_initializer
18
+ generate 'revelry_content:initializer'
19
+ end
20
+
21
+ def add_route
22
+ route 'mount RevelryContent::Engine => "/revelry_content"'
23
+ end
24
+
25
+ def add_controller_concern
26
+ insert_into_file app_controller, after: 'ApplicationController' do
27
+ 'include RevelryContent::WithRevelryContent'
15
28
  end
16
- @prev_migration_nr.to_s
17
29
  end
18
30
 
19
- def copy_migrations
20
- migration_template "create_revelry_content_contents.rb", "db/migrate/create_revelry_content_contents.rb"
21
- migration_template "create_versions.rb", "db/migrate/create_versions.rb"
31
+ private
32
+
33
+ def app_controller
34
+ File.join('app', 'controllers', 'application_controller.rb')
22
35
  end
23
36
  end
24
37
  end
@@ -0,0 +1,43 @@
1
+ module RevelryContent
2
+ module Generators
3
+ class JsGenerator < ::Rails::Generators::Base
4
+ JS_FILE_EXTENSIONS = %w(
5
+ .coffee
6
+ .coffee.erb
7
+ .js.coffee
8
+ .js.coffee.rb
9
+ .js
10
+ .js.rb
11
+ )
12
+
13
+ def add_js_assets
14
+ insert_into_file js_app_bundle, before: %r{(//|#)= require_tree \.} do
15
+ "#{ js_require_marker }= require revelry_content\n"
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def js_app_bundle
22
+ File.join(js_base_dir, "application#{ js_file_extname }")
23
+ end
24
+
25
+ def test_js_format(fmt)
26
+ File.exist?(File.join(js_base_dir, "application#{ fmt }"))
27
+ end
28
+
29
+ def js_base_dir
30
+ File.join('app', 'assets', 'javascripts')
31
+ end
32
+
33
+ def js_file_extname
34
+ JS_FILE_EXTENSIONS.find { |fmt| test_js_format(fmt) }
35
+ end
36
+
37
+ def js_require_marker
38
+ '#' if js_file_extname.include?('coffee')
39
+ '//'
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,25 @@
1
+ require 'rails/generators/migration'
2
+
3
+ module RevelryContent
4
+ module Generators
5
+ class MigrationsGenerator < ::Rails::Generators::Base
6
+ include Rails::Generators::Migration
7
+ source_root File.expand_path('../templates', __FILE__)
8
+ desc "add the migrations"
9
+
10
+ def self.next_migration_number(path)
11
+ unless @prev_migration_nr
12
+ @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
13
+ else
14
+ @prev_migration_nr += 1
15
+ end
16
+ @prev_migration_nr.to_s
17
+ end
18
+
19
+ def copy_migrations
20
+ migration_template "create_revelry_content_contents.rb", "db/migrate/create_revelry_content_contents.rb"
21
+ migration_template "create_versions.rb", "db/migrate/create_versions.rb"
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,13 @@
1
+ RevelryContent.configure do |config|
2
+ config.user_for_content do |controller|
3
+ # Your authentication logic here
4
+ controller.current_user
5
+ end
6
+
7
+ config.authorization_policy do |user|
8
+ # Your authorization logic here
9
+ user.admin?
10
+ end
11
+
12
+ config.js_export = true
13
+ end
@@ -1,3 +1,3 @@
1
1
  module RevelryContent
2
- VERSION = "0.0.1.1"
2
+ VERSION = "0.0.1.2"
3
3
  end
@@ -8,7 +8,6 @@
8
8
  * You're free to add application-wide styles to this file and they'll appear at the top of the
9
9
  * compiled file, but it's generally better to create a new file per style scope.
10
10
  *
11
+ *= require revelry_content
11
12
  *= require_self
12
13
  */
13
-
14
- @import "revelry_content/application";
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: revelry_content
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.1
4
+ version: 0.0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Revelry Labs, LLC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-04 00:00:00.000000000 Z
11
+ date: 2015-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -332,9 +332,14 @@ files:
332
332
  - app/views/revelry_content/contents/_menus.html.erb
333
333
  - app/views/revelry_content/contents/index.html.erb
334
334
  - config/routes.rb
335
+ - lib/generators/revelry_content/css_generator.rb
336
+ - lib/generators/revelry_content/initializer_generator.rb
335
337
  - lib/generators/revelry_content/install_generator.rb
338
+ - lib/generators/revelry_content/js_generator.rb
339
+ - lib/generators/revelry_content/migrations_generator.rb
336
340
  - lib/generators/revelry_content/templates/create_revelry_content_contents.rb
337
341
  - lib/generators/revelry_content/templates/create_versions.rb
342
+ - lib/generators/revelry_content/templates/initializer.rb
338
343
  - lib/revelry_content.rb
339
344
  - lib/revelry_content/configuration.rb
340
345
  - lib/revelry_content/controller_concern.rb
@@ -582,7 +587,6 @@ files:
582
587
  - test/dummy/tmp/cache/assets/development/sprockets/v3.0/y_4IIBYH_ItxQoEeXjWm9Igwn6hAkl669CNtYfo0fyI.cache
583
588
  - test/dummy/tmp/cache/assets/development/sprockets/v3.0/zF_lfa7oUNjRgtepm9Ufi0DCzN_IXCJTDHRrH-JHu7Q.cache
584
589
  - test/dummy/tmp/cache/assets/development/sprockets/v3.0/zeqXKQA7lKQnvEaJsDO404ZaYCV0dk57z-SXUkfmz24.cache
585
- - test/dummy/tmp/pids/server.pid
586
590
  - test/dummy/vendor/assets/javascripts/revelry_content/content.js
587
591
  - test/fixtures/rev_content/contents.yml
588
592
  - test/helpers/rev_content/contents_helper_test.rb
@@ -853,7 +857,6 @@ test_files:
853
857
  - test/dummy/tmp/cache/assets/development/sprockets/v3.0/ZBbRPnK9QPeL_bLmZNttUrL0MMH6DtrYDpD4f1DbYtc.cache
854
858
  - test/dummy/tmp/cache/assets/development/sprockets/v3.0/zeqXKQA7lKQnvEaJsDO404ZaYCV0dk57z-SXUkfmz24.cache
855
859
  - test/dummy/tmp/cache/assets/development/sprockets/v3.0/zF_lfa7oUNjRgtepm9Ufi0DCzN_IXCJTDHRrH-JHu7Q.cache
856
- - test/dummy/tmp/pids/server.pid
857
860
  - test/dummy/vendor/assets/javascripts/revelry_content/content.js
858
861
  - test/fixtures/rev_content/contents.yml
859
862
  - test/helpers/rev_content/contents_helper_test.rb
@@ -1 +0,0 @@
1
- 68157