contents_core 0.1.1 → 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 +4 -4
- data/README.md +30 -23
- data/app/models/contents_core/block.rb +1 -1
- data/config/locales/active_record.en.yml +2 -3
- data/lib/contents_core/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6367cfc8e67b02049fd7d75ed0bdac7e43c9a0cd
|
4
|
+
data.tar.gz: 3d220698df40f8579fea74a50045b4fc5716a052
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e9914344d032c962943f84e41ea468494d8b3bcd5367e6f7aea9f615eb9614aeb97f04d5268ad5fec21237e2ce54b54a649624ae26ac4f81b68dd72e177073e
|
7
|
+
data.tar.gz: 4567b1453c5da946b092515b82d1b6ee060800adbf8644eae84390bd0438362f86794b596fc9e4e65a8f72d06bbca2d2df8a3483b9d227554b56127477ac7f16
|
data/README.md
CHANGED
@@ -6,11 +6,11 @@ _NOTE_: this is an **ALPHA** version, major changes could happens - this is a re
|
|
6
6
|
|
7
7
|
Goals:
|
8
8
|
|
9
|
-
- attach the
|
9
|
+
- attach the contents structure to a model transparently
|
10
10
|
|
11
|
-
-
|
11
|
+
- improve block views management
|
12
12
|
|
13
|
-
- add
|
13
|
+
- add fields to blocks without migrations
|
14
14
|
|
15
15
|
### Install
|
16
16
|
|
@@ -34,9 +34,9 @@ conf = ContentsCore.config
|
|
34
34
|
conf[:cc_blocks][:custom] = {
|
35
35
|
name: 'Custom block',
|
36
36
|
items: {
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
title: :item_string,
|
38
|
+
content: :item_text,
|
39
|
+
image: :item_file
|
40
40
|
}
|
41
41
|
}
|
42
42
|
ContentsCore.config( { components: conf[:cc_blocks] } )
|
@@ -44,20 +44,31 @@ ContentsCore.config( { components: conf[:cc_blocks] } )
|
|
44
44
|
|
45
45
|
Create the new view blocks: `app/views/contents_core/_block_custom.html.erb`
|
46
46
|
|
47
|
-
```
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
- 2nd number: <span class="num2"<%= block.props.integers[1].editable %>><%= block.props.integers[1] %></span><br/>
|
53
|
-
A float: <span <%= block.props.float.editable %>><%= block.props.float %></span><br/>
|
54
|
-
</div>
|
55
|
-
<% end %>
|
47
|
+
```slim
|
48
|
+
- if block
|
49
|
+
.title = block.get( 'title' )
|
50
|
+
.text == block.get( 'content' )
|
51
|
+
.image = image_tag block.get( 'image' ).url( :thumb )
|
56
52
|
```
|
57
53
|
|
58
|
-
|
54
|
+
#### Images
|
59
55
|
|
60
|
-
To add support for images add CarrierWave gem to your Gemfile and execute: `rails generate uploader
|
56
|
+
To add support for images add CarrierWave gem to your Gemfile and execute: `rails generate uploader Image` and update che config file *config/initializers/contents_core.rb* with:
|
57
|
+
|
58
|
+
```rb
|
59
|
+
module ContentsCore
|
60
|
+
ItemFile.class_eval do
|
61
|
+
mount_uploader :data_file, ImageUploader
|
62
|
+
|
63
|
+
def init
|
64
|
+
self.data_file = File.open( Rails.root.join( 'public', 'images', 'original', 'missing.jpg' ) )
|
65
|
+
self
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
```
|
70
|
+
|
71
|
+
Another way is to override the *ItemFile* model (*app/models/contents_core/item_file.rb*):
|
61
72
|
|
62
73
|
```rb
|
63
74
|
module ContentsCore
|
@@ -66,10 +77,6 @@ module ContentsCore
|
|
66
77
|
|
67
78
|
alias_attribute :data, :data_file
|
68
79
|
|
69
|
-
def editable
|
70
|
-
false
|
71
|
-
end
|
72
|
-
|
73
80
|
def init
|
74
81
|
self.data_file = File.open( Rails.root.join( 'public', 'images', 'original', 'missing.jpg' ) )
|
75
82
|
self
|
@@ -82,13 +89,13 @@ module ContentsCore
|
|
82
89
|
end
|
83
90
|
```
|
84
91
|
|
85
|
-
|
92
|
+
#### Custom blocks
|
86
93
|
|
87
94
|
To create a "free form" block just use: `Page.first.create_block :intro, name: 'IntroBlock', schema: { intro: :item_string, subtitle: :item_string }`
|
88
95
|
|
89
96
|
### Dev Notes
|
90
97
|
|
91
|
-
|
98
|
+
#### Structure
|
92
99
|
|
93
100
|
- Including the Editable concern to a model will add `has_many :ec_blocks` relationship (the list of blocks attached to a container) and some utility methods
|
94
101
|
|