nocms-blocks 1.1.0 → 1.1.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.
- checksums.yaml +4 -4
- data/CHANGELOG +6 -0
- data/README.md +15 -0
- data/lib/generators/nocms/blocks/layout_generator.rb +28 -0
- data/lib/generators/nocms/blocks/templates/app/assets/stylesheets/no_cms/blocks/layout.scss.erb +3 -0
- data/lib/generators/nocms/blocks/templates/app/views/no_cms/admin/blocks/blocks/layout.html.erb +9 -0
- data/lib/generators/nocms/blocks/templates/app/views/no_cms/blocks/blocks/layout.html.erb +3 -0
- data/lib/generators/nocms/blocks/templates/config/initializers/nocms/blocks/layout.rb +23 -0
- data/lib/no_cms/blocks/version.rb +1 -1
- data/spec/dummy/app/views/layouts/application.html.erb +0 -2
- data/spec/lib/generators/layout_spec.rb +58 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2cf66257239f30210aaadbb2f8d432f895785c7
|
4
|
+
data.tar.gz: 06c8698cc183e064d03e964bc7a33079f3b5acf9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e3007d50167b177705f8122dbe6794d76cd2653756ee1e637efc45ead948a9b041ce9c11c5a49eacbbfa83954bfe768912c4ba4e42bdab0e73230c3120c07df
|
7
|
+
data.tar.gz: ff4fb7284e5b4fe7324361f3c6c0e51a74b2f374d955eb5f9811b9564bb43df6cde058e881806b8bc4810c6110f3fe211c234278654b5b501606d1562aa92d07
|
data/CHANGELOG
CHANGED
@@ -1,9 +1,15 @@
|
|
1
|
+
1.1.1
|
2
|
+
|
3
|
+
- Layout generator: It creates the initializer and views for one layout
|
4
|
+
|
1
5
|
1.1.0
|
2
6
|
|
3
7
|
- I18n behaviour fixed
|
4
8
|
* Separated objects cache for translations
|
5
9
|
* fields info both in the block and the translation
|
6
10
|
|
11
|
+
- Block duplication enabled
|
12
|
+
|
7
13
|
- Globalize dependency correctly specified in the gemspec
|
8
14
|
|
9
15
|
- Latest versions of awesome-nested-set (3.0.2) and globalize (5.0.1)
|
data/README.md
CHANGED
@@ -34,6 +34,21 @@ rails g nocms:blocks
|
|
34
34
|
|
35
35
|
Blocks are thought to be independent and customizable modules of content that can be created, edited or removed on their own, without dependency of any other module or class.
|
36
36
|
|
37
|
+
### Creating a new block layout
|
38
|
+
|
39
|
+
In the following sections some files will be mentioned (initializers, views, assets...). You can create them by hand or you can use a layout generator by typing:
|
40
|
+
|
41
|
+
```
|
42
|
+
rails g nocms:blocks:layout LAYOUT_NAME
|
43
|
+
```
|
44
|
+
|
45
|
+
This will create the following files:
|
46
|
+
|
47
|
+
1. `config/initializers/nocms/blocks/LAYOUT_NAME.rb`: An initializer where you can configure the layout (more info on next section).
|
48
|
+
2. `app/views/no_cms/blocks/blocks/_LAYOUT_NAME.html.erb`: Public template for the block (more info on next section).
|
49
|
+
3. `app/views/no_cms/admin/blocks/blocks/_LAYOUT_NAME.html.erb`: Template for block administration. You can choose not to use it depending on which admin interface you're using.
|
50
|
+
4. `app/assets/stylesheets/no_cms/blocks/_LAYOUT_NAME.scss`: Stylesheet asset so you can organize your SCSS code. Of course, you can not use it, but we strongly recommend trying to maintain styles from a block in a separated stylesheet. Notice that you must import (`@import "app/assets/stylesheets/no_cms/blocks/_LAYOUT_NAME.scss"`) it from your application.css.scss or where it should be used.
|
51
|
+
|
37
52
|
### Block layouts
|
38
53
|
|
39
54
|
In NoCMS Blocks, block layouts define two main things:
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module NoCms
|
2
|
+
module Blocks
|
3
|
+
class LayoutGenerator < Rails::Generators::Base
|
4
|
+
|
5
|
+
source_root File.expand_path("../templates/", __FILE__)
|
6
|
+
|
7
|
+
argument :name, required: true, banner: '<layout name>', desc: 'Name for the block layout'
|
8
|
+
|
9
|
+
def generate_stylesheets
|
10
|
+
template "app/assets/stylesheets/no_cms/blocks/layout.scss.erb", File.join(destination_root, "app/assets/stylesheets/no_cms/blocks", "_#{name}.scss")
|
11
|
+
end
|
12
|
+
|
13
|
+
def generate_views
|
14
|
+
template "app/views/no_cms/blocks/blocks/layout.html.erb", File.join(destination_root, "app/views/no_cms/blocks/blocks", "_#{name}.html.erb")
|
15
|
+
template "app/views/no_cms/admin/blocks/blocks/layout.html.erb", File.join(destination_root, "app/views/no_cms/admin/blocks/blocks", "_#{name}.html.erb")
|
16
|
+
end
|
17
|
+
|
18
|
+
def generate_initializer
|
19
|
+
template "config/initializers/nocms/blocks/layout.rb", File.join(destination_root, "config/initializers/nocms/blocks", "#{name}.rb")
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.namespace
|
23
|
+
"nocms:blocks:layout"
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
NoCms::Blocks.configure do |config|
|
2
|
+
|
3
|
+
config.block_layouts['<%= name %>'] = {
|
4
|
+
template: '<%= name %>', # This is the template of this block,
|
5
|
+
# used as a partial both in the front
|
6
|
+
# and the admin (if you use the nocms-admin gem)
|
7
|
+
fields: { # This is the list of fields a block with this layout would have
|
8
|
+
text: :string,
|
9
|
+
# long_text: :text,
|
10
|
+
# image: Image, # You may use another ActiveRecord classes of your own
|
11
|
+
},
|
12
|
+
allow_nested_blocks: true, # A block with this layout may include a list of nested blocks
|
13
|
+
# This setting is actually used by nocms-admin gem to show
|
14
|
+
# nested forms
|
15
|
+
nest_levels: [0], # Some layout may not be nestable, or useful only in certain nesting level
|
16
|
+
# Once again, this setting is used by nocms-admin gem to hide certain
|
17
|
+
# in nested blocks. When blank, it's assumed there's no restriction.
|
18
|
+
cache_enabled: false # When setting cache_enabled you will be **overriding** the global cache_enabled
|
19
|
+
# setting. If you don't set a cache setting then it will use the global cache
|
20
|
+
# setting specified above
|
21
|
+
}
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require "generator_spec"
|
4
|
+
|
5
|
+
require_relative '../../../lib/generators/nocms/blocks/layout_generator.rb'
|
6
|
+
|
7
|
+
describe NoCms::Blocks::LayoutGenerator, type: :generator do
|
8
|
+
|
9
|
+
TMP_ROOT = File.expand_path("../../../../tmp", __FILE__)
|
10
|
+
destination TMP_ROOT
|
11
|
+
|
12
|
+
arguments %w(test_name)
|
13
|
+
|
14
|
+
before do
|
15
|
+
prepare_destination
|
16
|
+
run_generator
|
17
|
+
end
|
18
|
+
|
19
|
+
after do
|
20
|
+
FileUtils.rm_rf(TMP_ROOT)
|
21
|
+
end
|
22
|
+
|
23
|
+
specify "should create the structure" do
|
24
|
+
expect(destination_root).to have_structure {
|
25
|
+
directory "config" do
|
26
|
+
directory "initializers" do
|
27
|
+
directory "nocms" do
|
28
|
+
directory "blocks" do
|
29
|
+
file "test_name.rb" do
|
30
|
+
contains "'test_name'"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
directory "app" do
|
37
|
+
directory "views" do
|
38
|
+
directory "no_cms" do
|
39
|
+
directory "blocks" do
|
40
|
+
directory "blocks" do
|
41
|
+
file "_test_name.html.erb" do
|
42
|
+
contains 'class="block test_name"'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
directory "admin" do
|
47
|
+
directory "blocks" do
|
48
|
+
directory "blocks" do
|
49
|
+
file "_test_name.html.erb"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
}
|
57
|
+
end
|
58
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nocms-blocks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodrigo Garcia Suarez
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2015-08-
|
15
|
+
date: 2015-08-20 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rails
|
@@ -117,6 +117,11 @@ files:
|
|
117
117
|
- db/migrate/20140618150651_add_position_to_no_cms_blocks_block.rb
|
118
118
|
- db/migrate/20150709132202_add_non_translated_fields_info_to_no_cms_blocks_block.rb
|
119
119
|
- db/migrate/20150710112549_move_layout_from_no_cms_blocks_block_translations_to_no_cms_blocks_blocks.rb
|
120
|
+
- lib/generators/nocms/blocks/layout_generator.rb
|
121
|
+
- lib/generators/nocms/blocks/templates/app/assets/stylesheets/no_cms/blocks/layout.scss.erb
|
122
|
+
- lib/generators/nocms/blocks/templates/app/views/no_cms/admin/blocks/blocks/layout.html.erb
|
123
|
+
- lib/generators/nocms/blocks/templates/app/views/no_cms/blocks/blocks/layout.html.erb
|
124
|
+
- lib/generators/nocms/blocks/templates/config/initializers/nocms/blocks/layout.rb
|
120
125
|
- lib/generators/nocms/blocks_generator.rb
|
121
126
|
- lib/generators/nocms/templates/config/initializers/nocms/blocks.rb
|
122
127
|
- lib/no_cms/blocks/configuration.rb
|
@@ -349,6 +354,7 @@ files:
|
|
349
354
|
- spec/factories/test_image.rb
|
350
355
|
- spec/fixtures/images/logo.png
|
351
356
|
- spec/fixtures/images/logo2.png
|
357
|
+
- spec/lib/generators/layout_spec.rb
|
352
358
|
- spec/models/no_cms/blocks/block_spec.rb
|
353
359
|
- spec/models/no_cms/blocks/duplicating_blocks_spec.rb
|
354
360
|
- spec/models/no_cms/blocks/i18n_blocks_spec.rb
|
@@ -612,5 +618,6 @@ test_files:
|
|
612
618
|
- spec/dummy/db/test.sqlite3
|
613
619
|
- spec/dummy/db/development.sqlite3
|
614
620
|
- spec/dummy/db/migrate/20140304094052_create_test_images.rb
|
621
|
+
- spec/lib/generators/layout_spec.rb
|
615
622
|
- spec/factories/test_image.rb
|
616
623
|
- spec/factories/no_cms/blocks/block.rb
|