micro_cms 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +35 -2
- data/app/assets/javascripts/micro_cms.js +1 -0
- data/app/helpers/micro_cms/application_helper.rb +14 -0
- data/lib/micro_cms/engine.rb +15 -1
- data/lib/micro_cms/version.rb +1 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -1
- data/spec/dummy/log/test.log +277 -404
- data/spec/dummy/tmp/development_secret.txt +1 -1
- data/spec/examples.txt +29 -28
- data/spec/helpers/micro_cms/application_helper_spec.rb +13 -0
- metadata +10 -10
- data/spec/dummy/db/development.sqlite3 +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c07cc5c21d44d0bde6dfa7bde4e7b5688e7b91d89dde60cf0bdd0fd6e9f9968
|
4
|
+
data.tar.gz: fc83030b2ec6e131e1e06c7973cc310646494ebcdcc000e1445502231123a721
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc5e6115395ff2ecf1f73cf4858eebd16278577d4e6429abd1ed3588c1ed48bf6ee8e0294b45e5ab4d83d688f5b6ec9986133b8c20a6378b785ffbb9f881e4ab
|
7
|
+
data.tar.gz: e4a8ddbfd248205257603b2da075bebf683f7eaa4fee68e458ba3e63c969aa81a08444d81fd88d566219afcd6eb7b8c77528a6fd121154a568461604c5f36612
|
data/README.md
CHANGED
@@ -54,13 +54,46 @@ bin/rails db:migrate
|
|
54
54
|
```
|
55
55
|
to copy the migrations.
|
56
56
|
|
57
|
-
Require the JavaScript (e.g. `//= require micro_cms`) and all styles (e.g. `@import 'micro_cms';'`).
|
58
|
-
|
59
57
|
Mount the engine routes in you `config/routes.rb` file:
|
60
58
|
```ruby
|
61
59
|
mount MicroCms::Engine => '/micro_cms'
|
62
60
|
```
|
63
61
|
|
62
|
+
### Usage with Sprockets
|
63
|
+
|
64
|
+
Require the JavaScript (e.g. `//= require micro_cms`) and all styles (e.g. `@import 'micro_cms';'`).
|
65
|
+
|
66
|
+
### Usage with Webpacker
|
67
|
+
|
68
|
+
Make sure that you import `rails/ujs` like that in your `application.js`:
|
69
|
+
|
70
|
+
```js
|
71
|
+
import Rails from '@rails/ujs';
|
72
|
+
Rails.start();
|
73
|
+
...
|
74
|
+
window.Rails = Rails;
|
75
|
+
```
|
76
|
+
|
77
|
+
The last line makes the Rails scope global (since we inline the script, this is needed).
|
78
|
+
|
79
|
+
Now you have to include the helper to your ApplicationHelper:
|
80
|
+
|
81
|
+
```rb
|
82
|
+
module ApplicationHelper
|
83
|
+
include MicroCms::ApplicationHelper
|
84
|
+
...
|
85
|
+
end
|
86
|
+
```
|
87
|
+
|
88
|
+
Now you can use the helper to inline the needed scripts via `app/views/layouts/application.html.slim`. It's strongly
|
89
|
+
recommended to check first, if the user is allowed to edit (but this is not part of this gem):
|
90
|
+
|
91
|
+
```rb
|
92
|
+
- if user_signed_in? # not part of this gem!
|
93
|
+
= micro_cms_asset_tags
|
94
|
+
```
|
95
|
+
|
96
|
+
|
64
97
|
## Configuration
|
65
98
|
`app/config/initializers/micro_cms.rb`:
|
66
99
|
|
@@ -2,5 +2,19 @@
|
|
2
2
|
|
3
3
|
module MicroCms
|
4
4
|
module ApplicationHelper
|
5
|
+
# rubocop:disable Rails/OutputSafety
|
6
|
+
def micro_cms_asset_tags
|
7
|
+
js = load_gem_file 'micro_cms', 'app/assets/javascripts/micro_cms.js'
|
8
|
+
css = load_gem_file 'micro_cms', 'app/assets/stylesheets/micro_cms/micro_cms.css'
|
9
|
+
tag.script(js.html_safe) + tag.style(css)
|
10
|
+
end
|
11
|
+
# rubocop:enable Rails/OutputSafety
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def load_gem_file(gem_name, assets_path)
|
16
|
+
path = File.join(Gem.loaded_specs[gem_name].full_gem_path, assets_path)
|
17
|
+
File.read(path)
|
18
|
+
end
|
5
19
|
end
|
6
20
|
end
|
data/lib/micro_cms/engine.rb
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
begin
|
4
|
+
require 'factory_bot_rails'
|
5
|
+
rescue LoadError # rubocop:disable Lint/HandleExceptions
|
6
|
+
end
|
7
|
+
|
3
8
|
module MicroCms
|
4
9
|
class Engine < ::Rails::Engine
|
10
|
+
FACTORIES = File.expand_path('../../spec/factories', __dir__).freeze
|
11
|
+
|
5
12
|
isolate_namespace MicroCms
|
13
|
+
config.autoload_once_paths << "#{root}/app/helpers"
|
6
14
|
|
7
15
|
config.generators do |generators|
|
8
16
|
generators.test_framework :rspec
|
@@ -12,7 +20,7 @@ module MicroCms
|
|
12
20
|
|
13
21
|
initializer 'micro_cms.include_view_helpers' do |_app|
|
14
22
|
ActiveSupport.on_load :action_view do
|
15
|
-
|
23
|
+
include MicroCms::CmsBlockHelper
|
16
24
|
end
|
17
25
|
end
|
18
26
|
|
@@ -21,5 +29,11 @@ module MicroCms
|
|
21
29
|
config.authorization_token = SecureRandom.urlsafe_base64
|
22
30
|
end
|
23
31
|
end
|
32
|
+
|
33
|
+
if defined? FactoryBotRails
|
34
|
+
initializer 'mirco_cms.set_factory_paths', after: 'factory_bot.set_factory_paths' do |_app|
|
35
|
+
FactoryBot.definition_file_paths << FACTORIES
|
36
|
+
end
|
37
|
+
end
|
24
38
|
end
|
25
39
|
end
|
data/lib/micro_cms/version.rb
CHANGED
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
[1m[35m (1.7ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|