contents_core 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc9416651ae6d9f75bb33c14607fa16ace8aa6f9
4
- data.tar.gz: 486a68493f20dbd00004ff947e7bfe39d55d9fd7
3
+ metadata.gz: 6367cfc8e67b02049fd7d75ed0bdac7e43c9a0cd
4
+ data.tar.gz: 3d220698df40f8579fea74a50045b4fc5716a052
5
5
  SHA512:
6
- metadata.gz: 0c823da0a430285eadc65585195f882ca96d4353d7fc950f5b3224f5ea9d102204739c3ca68972f642043fbc728efbe59b6622996988f780b81bc6ffd34d44d9
7
- data.tar.gz: dc42ba513c2f4f0af97c8a2905fa9795419be57864d39dcef6a4c3f1152f24831f17bdb4199f90784b44218912c1bf47b5d71f10dd97aebc0d519c4144de647d
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 necessary data to a model transparently
9
+ - attach the contents structure to a model transparently
10
10
 
11
- - simplify the components development in views
11
+ - improve block views management
12
12
 
13
- - add blocks / items (= fields) without migrations
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
- int1: :item_integer,
38
- int2: :item_integer,
39
- a_float: :item_float
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
- ```erb
48
- <% if local_assigns[:block] %>
49
- <% block = local_assigns[:block] %>
50
- <div <%= block.editable %>>
51
- 1st number: <span class="num1"<%= block.props.integers[0].editable %>><%= block.props.integers[0] %></span>
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
- ##### Images
54
+ #### Images
59
55
 
60
- To add support for images add CarrierWave gem to your Gemfile and execute: `rails generate uploader File` and mount it in the model *app/models/contents_core/item_file.rb*:
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
- ##### Custom blocks
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
- ##### Structure
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
 
@@ -83,7 +83,7 @@ module ContentsCore
83
83
  @_items = {}
84
84
  items.each { |item| @_items[item.name] = item }
85
85
  end
86
- @_items[name]
86
+ @_items[name] ? @_items[name].data : nil
87
87
  end
88
88
 
89
89
  def has_parent?
@@ -8,11 +8,10 @@ en:
8
8
  one: Item
9
9
  other: Items
10
10
  attributes:
11
- contents_core/block:
11
+ contents_core/item:
12
12
  column: Column
13
13
  content: Content
14
+ data: Data
14
15
  img: Image
15
16
  slide: Slide
16
17
  title: Title
17
- contents_core/item:
18
- data: Data
@@ -1,3 +1,3 @@
1
1
  module ContentsCore
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contents_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mat