r_kit 0.5 → 1.0

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.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/lib/r_kit/active_record_utility/active_record_extend.rb +28 -12
  3. data/lib/r_kit/active_record_utility/utilities/series.rb +115 -77
  4. data/lib/r_kit/active_record_utility/utilities/tag.rb +6 -2
  5. data/lib/r_kit/active_record_utility.rb +2 -0
  6. data/lib/r_kit/core/loader.rb +1 -1
  7. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/base/typography/hr.scss +5 -0
  8. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/base/typography/links.scss +2 -0
  9. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/base/typography/paragraphs.scss +3 -1
  10. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/base/typography/titles.scss +4 -2
  11. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/base/typography.scss +1 -0
  12. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/components/btn.scss +3 -0
  13. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/mixins/alignments.scss +7 -0
  14. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/mixins/blocks.scss +4 -0
  15. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/mixins/box-shadows/curved-shadows.scss +1 -1
  16. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/mixins/box-shadows/straight-shadows.scss +1 -1
  17. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/mixins/links.scss +12 -0
  18. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/mixins/titles.scss +6 -10
  19. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/mixins.scss +2 -0
  20. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/variables/colors.scss +1 -1
  21. data/lib/r_kit/css/sass_extend.rb +1 -2
  22. data/lib/r_kit/css.rb +13 -11
  23. data/lib/r_kit/decoration/action_view_base_extend.rb +1 -2
  24. data/lib/r_kit/decoration/base/collection.rb +11 -11
  25. data/lib/r_kit/decoration/base/object.rb +0 -18
  26. data/lib/r_kit/decoration/base.rb +39 -2
  27. data/lib/r_kit/decoration/class.rb +26 -55
  28. data/lib/r_kit/decoration/dsl.rb +14 -83
  29. data/lib/r_kit/decoration/enumerable_extend.rb +5 -1
  30. data/lib/r_kit/decoration/object_extend.rb +5 -0
  31. data/lib/r_kit/decoration.rb +4 -7
  32. data/lib/r_kit/dsl/base/thrust.rb +6 -2
  33. data/lib/r_kit/dsl/base.rb +9 -3
  34. data/lib/r_kit/dsl/dsl_extend.rb +1 -1
  35. data/lib/r_kit/dsl/test.rb +81 -0
  36. data/lib/r_kit/dsl.rb +1 -6
  37. data/lib/r_kit/frame/collection_dsl.rb +24 -0
  38. data/lib/r_kit/frame/empty_frame.rb +7 -0
  39. data/lib/r_kit/frame/instance_dsl.rb +30 -0
  40. data/lib/r_kit/frame.rb +14 -0
  41. data/lib/r_kit/grid/base/grid.rb +69 -19
  42. data/lib/r_kit/grid/base/grid_col.rb +22 -19
  43. data/lib/r_kit/grid/base.rb +1 -15
  44. data/lib/r_kit/grid/binding.rb +3 -10
  45. data/lib/r_kit/grid/lib/assets/stylesheets/r_kit/base/grid.scss +15 -18
  46. data/lib/r_kit/grid/lib/assets/stylesheets/r_kit/base/grid_flex.scss +19 -0
  47. data/lib/r_kit/grid/lib/assets/stylesheets/r_kit/base/grid_items.scss +5 -0
  48. data/lib/r_kit/grid/lib/assets/stylesheets/r_kit/grid.scss +2 -0
  49. data/lib/r_kit/grid/lib/assets/stylesheets/r_kit/mixins/{gris.scss → grid.scss} +0 -0
  50. data/lib/r_kit/grid.rb +2 -3
  51. data/lib/r_kit/override/base.rb +125 -0
  52. data/lib/r_kit/override/method_extend.rb +8 -0
  53. data/lib/r_kit/override/module_extend.rb +53 -0
  54. data/lib/r_kit/override/pattern.rb +53 -0
  55. data/lib/r_kit/override/perfs.rb +117 -0
  56. data/lib/r_kit/override/test.rb +466 -0
  57. data/lib/r_kit/override/unbound_method_extend.rb +8 -0
  58. data/lib/r_kit/override.rb +15 -0
  59. data/lib/r_kit/pagination/base/page.rb +5 -23
  60. data/lib/r_kit/pagination/base.rb +32 -62
  61. data/lib/r_kit/pagination/dsl.rb +10 -0
  62. data/lib/r_kit/pagination/enumerable_extend.rb +7 -0
  63. data/lib/r_kit/pagination.rb +29 -2
  64. data/lib/r_kit/parser/base.rb +19 -0
  65. data/lib/r_kit/parser/leaf.rb +72 -0
  66. data/lib/r_kit/parser/test.rb +76 -0
  67. data/lib/r_kit/parser/tree.rb +22 -0
  68. data/lib/r_kit/parser.rb +8 -0
  69. data/lib/r_kit/struct/collection_delegator.rb +0 -6
  70. data/lib/r_kit/utility/basic_object_extend.rb +9 -0
  71. data/lib/r_kit/utility/kernel_extend.rb +9 -3
  72. data/lib/r_kit/utility/main_extend.rb +22 -0
  73. data/lib/r_kit/utility/module_extend.rb +18 -11
  74. data/lib/r_kit/utility/simple_delegator_extend.rb +1 -1
  75. data/lib/r_kit/utility/symbol_extend.rb +1 -1
  76. data/lib/r_kit/utility.rb +4 -2
  77. data/lib/r_kit/version.rb +1 -1
  78. metadata +29 -5
  79. data/lib/r_kit/grid/base/grid_row.rb +0 -29
  80. data/lib/r_kit/grid/kernel_extend.rb +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf5323abaf73afe8d62b58cb816884632fbdbdcf
4
- data.tar.gz: a67bb90a5cdfa7a0b8bd9264107c1e2f8c80ac7b
3
+ metadata.gz: bdb67eccab0559337e3ceb3ffac44abe7a5a0eb7
4
+ data.tar.gz: 97dbedfa706dcd908c2afa34a480c7fe3ea8cf0e
5
5
  SHA512:
6
- metadata.gz: 27e1256e0174889ca92e9283c207f07ed816fe6f7d4a8cc57defb009c0c4e0339ee5d206682dc9fbb67be275bdff60bb226b712abba852321f0d3fef348a12f6
7
- data.tar.gz: c1a6450e8c1ea08ff888dd50e18a8a58753266b98f1cd5e3e5bc23966455acba675af93a095c08e3b721205c0d7630a245f5a5984364b1da887ab678a1c5fac8
6
+ metadata.gz: fb8202557efbd77f2bbc38c993f5d3a0391bd8bb94272e2d078dedee01eb6b566c1a87a010bc2b27989372cad25c00b147754a3f2c540dda077fffd5407b8ef6
7
+ data.tar.gz: 55be195d767611126530b158969e4b7e151718e17d91c582d746048c70528863c78b2c3662904598df6927412c696a881290a5dfefdcd85f05bd7794a50730fd
@@ -1,20 +1,36 @@
1
- module RKit::ActiveRecordUtility::ActiveRecordExtend
1
+ class ActiveRecord::Base
2
2
 
3
- def collection_finder **options
4
- all
5
- .then(if: :acts_as_poolables?){ |collection| collection.pool options[:pool] }
6
- .then(if: :acts_as_publishables?){ |collection| collection.published.publication_desc }
7
- .then(if: :acts_as_seriables?){ |collection| collection.series options[:series] }
3
+ override_singleton_method :scope do |name, body, &block|
4
+ __olddef__(name, body, &block).tap do |scope_name|
5
+
6
+ override_singleton_method scope_name do |*args, &block|
7
+ __olddef__(*args, &block).tap do |collection|
8
+ collection.scopes << scope_name
9
+ end
10
+ end
11
+
12
+ end
8
13
  end
9
14
 
10
- def instance_finder **options
11
- if acts_as_taggables?
12
- tagged options[:tag]
13
- else
14
- find_by id: options[:id]
15
+
16
+ depend on: :frame do
17
+ def scoped? *args
18
+ frame.scoped? *args
15
19
  end
16
20
  end
17
21
 
22
+ end
23
+
24
+
25
+ class ActiveRecord::Relation
26
+
27
+ attr_reader :scopes, default: proc{ [] }
28
+
29
+ def scoped? name
30
+ scopes.include? name
31
+ end
32
+
33
+ RKit::Frame::CollectionDsl.domain self
34
+ acts_as_frameable_collection
18
35
 
19
- ActiveRecord::Base.extend self
20
36
  end
@@ -16,9 +16,8 @@ class RKit::ActiveRecordUtility::Series
16
16
 
17
17
  allowed? do
18
18
  table_exists? &&
19
- column_names.include_all?(["following_id", "series"]) &&
20
- columns_hash["following_id"].type == :integer &&
21
- columns_hash["series"].type == :string
19
+ column_names.include?("following_id") &&
20
+ columns_hash["following_id"].type == :integer
22
21
  end
23
22
 
24
23
  restricted do
@@ -31,10 +30,10 @@ class RKit::ActiveRecordUtility::Series
31
30
  has_one :followed, class_name: name, foreign_key: "following_id"
32
31
  belongs_to :following, class_name: name
33
32
 
34
- before_validation if: :following_id_changed? do
35
- self.title ||= following.title if __class__.column_exists? "title"
36
- self.series = following.series.name
37
- end
33
+ # before_validation if: :following_id_changed? do
34
+ # self.title ||= following.title if __class__.column_exists? "title"
35
+ # self.series = following.series.name
36
+ # end
38
37
 
39
38
 
40
39
 
@@ -47,15 +46,11 @@ class RKit::ActiveRecordUtility::Series
47
46
 
48
47
  # TODO: validates a record can only have one follower (or is it hadled by the "has_one" relation directly ?)
49
48
 
50
- validates_presence_of :series, if: :following
49
+ # validates_presence_of :series, if: :following
51
50
  validates_uniqueness_of :following_id, if: :following
52
51
 
53
- scope :series, ->(series){ series && where(series: series) }
54
-
55
- # TODO: adapter le scope pour intégrer les published (si interfered)
56
- # je laisse en commentaire parceque j'aime pas le nom du scope,
57
- # et j'ai pas d'idée là maintenant (à part 'pilotes', ou 'firsts')
58
- # scope :firsts_of_series, ->{ where(following_id: nil) }
52
+ # scope :series, ->(series){ series && where(series: series) }
53
+ scope :firsts_of_series, ->{ where(following_id: nil) }
59
54
 
60
55
  # TODO: scope pour l'ordre dans une serie (pour le decorator pagination_tag)
61
56
 
@@ -64,21 +59,37 @@ class RKit::ActiveRecordUtility::Series
64
59
 
65
60
 
66
61
  methods :instance do
62
+ def first_of_serie
63
+ following ? following.send(__method__) : self
64
+ end
65
+
67
66
  def series
68
- series_struct if read_attribute(:series)
69
- # @@_active_record_utilities_series[read_attribute(:series)] ||= series_struct if read_attribute(:series)
70
- # TODO: if series changes, or new element added, series must be re-calculated
71
- # maybe pre-calc this in after save
67
+ first_of_serie.nexts_of_serie if in_a_series?
72
68
  end
73
69
 
74
- def series_struct
75
- OpenStruct.new.tap do |series_struct|
76
- series_struct.name = read_attribute :series
77
- series_struct.collection = __class__.series series_struct.name
78
- series_struct.size = series_struct.collection.count
79
- end
70
+ def in_a_series?
71
+ following || followed
72
+ end
73
+
74
+ def nexts_of_serie
75
+ followed ? [self] + followed.send(__method__) : [self]
80
76
  end
81
77
 
78
+ # def series
79
+ # series_struct if read_attribute(:series)
80
+ # # @@_active_record_utilities_series[read_attribute(:series)] ||= series_struct if read_attribute(:series)
81
+ # # TODO: if series changes, or new element added, series must be re-calculated
82
+ # # maybe pre-calc this in after save
83
+ # end
84
+ #
85
+ # def series_struct
86
+ # OpenStruct.new.tap do |series_struct|
87
+ # series_struct.name = read_attribute :series
88
+ # series_struct.collection = __class__.series series_struct.name
89
+ # series_struct.size = series_struct.collection.count
90
+ # end
91
+ # end
92
+
82
93
  def position_in_series
83
94
  following ? following.send(__method__) + 1 : 1
84
95
  end
@@ -86,77 +97,104 @@ class RKit::ActiveRecordUtility::Series
86
97
 
87
98
 
88
99
  methods :decorator do
89
- after_initialize do
100
+ #after_initialize do
90
101
  # TODO: this can't stay this way, if "serie" is pre-calculated
91
102
  # & shared accros instances & kept in memory (class variable)
92
103
 
93
104
  # series.collection = series.collection.decorate if series
94
105
  # TODO: infinite loop, need a "unless" on the after_init, or smthng even more smart
95
106
  # ps: i'm not happy with this current decorate
96
- end
107
+ #end
97
108
 
98
- def series_url
99
- view.url_for [__class__, series: series.name]
100
- end
109
+ # depend on: :series do
110
+ # def series_url
111
+ # view.url_for [__class__, series: series.name]
112
+ # end
113
+ #
114
+ # def link_to_series
115
+ # view.link_to series.name, series_url, class: :btn
116
+ # end
117
+ # end
101
118
 
102
- def link_to_series
103
- view.link_to series.name, series_url, class: :btn
104
- end
105
119
 
106
120
  if decorated_class.columns_hash["title"]
107
- # TODO: I don't get this "showcase thing", we can delete that and just look into the view for the params
108
- # Or in the collection, to see if the scope is applied (second solution is better)
109
- def series_title
110
- "#{ __getobj__.title } <small><i class='no-warp'>(vol #{ position_in_series })</i></small>".html_safe
111
- end
112
-
113
- def showcase_title
114
- "#{ __getobj__.title } <small><i class='no-warp'>(#{ series.size } vols)</i></small>".html_safe
115
- end
116
-
117
- def title options = {}
118
- if series and false # and showcase
119
- showcase_title
120
- elsif series
121
- series_title
122
- else
123
- super()
121
+ depend on: :series, strict: false do
122
+
123
+ # TODO: I don't get this "showcase thing", we can delete that and just look into the view for the params
124
+ # Or in the collection, to see if the scope is applied (second solution is better)
125
+ # TODO: to make a decision, we need to know if 'first_of_Series' scope is applied
126
+ # for that, we need to add behavior to 'scope' (ActiveRecord::Scoping::Named::ClassMethods)
127
+ # and, on an instance, to keep the 'collection where it come from' intel (?? ennumerable first, etc ??)
128
+ def series_title
129
+ "#{ __getobj__.title } <small><i class='no-warp'>(vol #{ position_in_series })</i></small>".html_safe
124
130
  end
125
- end
126
- end
127
131
 
128
- # TODO: put default locales keys ("vol" is hard coded here) in cluster
129
- # same for the 'title' methods before
130
- # TODO: the "disabled" link for self doesn't work yet
131
- # in fact, the collection does not use the "self" object, so the singleton_class is lost
132
- def pagination_tag
133
- disable_pagination_link self
134
- series.collection.decorate.map(&:pagination_link_to).reduce(:safe_concat)
135
- end
132
+ def showcase_title
133
+ "#{ __getobj__.title } <small><i class='no-warp'>(#{ series.size } vols)</i></small>".html_safe
134
+ end
136
135
 
137
- def pagination_link_to
138
- view.link_to "vol #{ position_in_series }", self, class: :btn
139
- end
136
+ # TODO: title don't work if there is no series
137
+ # cause 'depend' stille define the method, but will return nil
138
+ def title options = {}
139
+ if showcase
140
+ showcase_title
141
+ else
142
+ series_title
143
+ end
144
+ end
140
145
 
141
- def disabled_pagination_link_to
142
- view.content_tag :span, "vol #{ position_in_series }", class: :'btn-disabled'
143
- end
146
+ # TODO: don't ssems to work in decorated obj
147
+ def showcase
148
+ scoped? :firsts_of_series
149
+ # collection_context.then{ |collection| collection.scoped? :firsts_of_series }
150
+ end
144
151
 
145
- def disable_pagination_link seriable_instance
146
- class << seriable_instance
147
- alias :pagination_link_to :disabled_pagination_link_to
148
152
  end
149
153
  end
150
154
 
151
-
152
- # TODO: put default locales keys (:previous, :next) in cluster
153
- def navigation_tag
154
- view.content_tag :p do
155
- safe_buffer = ActiveSupport::SafeBuffer.new
156
- safe_buffer += view.link_to view.t(:previous), following, class: :btn if following
157
- safe_buffer += " "
158
- safe_buffer += view.link_to view.t(:next), followed, class: :btn if followed
159
- safe_buffer
155
+ depend on: :series do
156
+
157
+ # # TODO: put default locales keys ("vol" is hard coded here) in cluster
158
+ # # same for the 'title' methods before
159
+ # # TODO: the "disabled" link for self doesn't work yet
160
+ # # in fact, the collection does not use the "self" object, so the singleton_class is lost
161
+ # def pagination_tag
162
+ # series.collection.decorate.map{ |x|
163
+ # if x === self
164
+ # x.disabled_pagination_link_to
165
+ # else
166
+ # x.pagination_link_to
167
+ # end
168
+ # }.reduce(:safe_concat)
169
+ # end
170
+ #
171
+ # def pagination_link_to
172
+ # view.link_to "vol #{ position_in_series }", self, class: :btn
173
+ # end
174
+ #
175
+ # def disabled_pagination_link_to
176
+ # view.content_tag :span, "vol #{ position_in_series }", class: :'btn-disabled'
177
+ # end
178
+
179
+
180
+ def navigation_tag
181
+ view.content_tag :p do
182
+ safe_buffer = ActiveSupport::SafeBuffer.new
183
+
184
+ if following
185
+ safe_buffer += view.link_to(following, class: :btn){ view.fa_icon('angle-left') + " Previous" }
186
+ end
187
+
188
+ if following && followed
189
+ safe_buffer += " "
190
+ end
191
+
192
+ if followed
193
+ safe_buffer += view.link_to(followed, class: :btn){ "Next ".html_safe + view.fa_icon('angle-right') }
194
+ end
195
+
196
+ safe_buffer
197
+ end
160
198
  end
161
199
  end
162
200
  end
@@ -20,11 +20,15 @@ class RKit::ActiveRecordUtility::Tag
20
20
  validates_presence_of :tag
21
21
  validates_uniqueness_of :tag
22
22
 
23
- def tagged(tag) find_by tag: tag end
23
+ def tagged(tag) find_by tag: tag.underscore end
24
24
  end
25
25
 
26
26
  methods :instance do
27
- def to_param() tag end
27
+ def to_param() tag.dasherize end
28
+ end
29
+
30
+ methods :decorator do
31
+ delegate :to_param, to: :__getobj__
28
32
  end
29
33
 
30
34
  end
@@ -1,6 +1,8 @@
1
1
  class RKit::ActiveRecordUtility
2
2
 
3
3
  dependency :dsl,
4
+ :frame,
5
+ :override,
4
6
  :utility
5
7
 
6
8
  load_path __FILE__,
@@ -44,7 +44,7 @@ class RKit::Core::Loader
44
44
 
45
45
 
46
46
  def loaded!
47
- __class__.instance_variable_get("@loaded") << _base.name
47
+ self.class.instance_variable_get("@loaded") << _base.name
48
48
  end
49
49
 
50
50
 
@@ -0,0 +1,5 @@
1
+ hr{
2
+ border: none {
3
+ top: solid 1px text-color();
4
+ };
5
+ }
@@ -2,6 +2,8 @@ a{
2
2
  color: link-color();
3
3
  text-decoration: none;
4
4
 
5
+ transition: all .2s;
6
+
5
7
  &:hover{
6
8
  text-decoration: underline;
7
9
  }
@@ -1,5 +1,7 @@
1
1
  p{
2
- font-weight: 200;
2
+ font-weight: 100;
3
+ letter-spacing: .0625rem;
4
+ word-spacing: .0625rem;
3
5
  line-height: 1.4em;
4
6
  text-align: justify;
5
7
 
@@ -1,10 +1,12 @@
1
1
  h1,
2
2
  h2,
3
3
  h3{
4
- font-weight: 200;
4
+ font-weight: 100;
5
+ letter-spacing: .0625rem;
6
+
5
7
  margin: 1em 0;
6
8
 
7
- @include link-styled-title;
9
+ @include link-title;
8
10
  }
9
11
 
10
12
  h1{
@@ -1,3 +1,4 @@
1
+ @import "typography/hr";
1
2
  @import "typography/links";
2
3
  @import "typography/lists";
3
4
  @import "typography/paragraphs";
@@ -4,6 +4,9 @@
4
4
 
5
5
  padding: .625em;
6
6
 
7
+ font-weight: 200;
8
+ letter-spacing: 0;
9
+
7
10
  background-color: btn-background-color();
8
11
  color: btn-color();
9
12
  }
@@ -0,0 +1,7 @@
1
+ @mixin verticaly-centered() {
2
+ display: flex;
3
+ flex-wrap: wrap;
4
+
5
+ align-content: center;
6
+ height: 100%;
7
+ }
@@ -0,0 +1,4 @@
1
+ @mixin highlighted-block() {
2
+ color: rgba(white-color(), .65);
3
+ background-color: rgba(black-color(), .85);
4
+ }
@@ -6,7 +6,7 @@
6
6
  border-radius: 50%;
7
7
  z-index: -1;
8
8
  content: "";
9
- box-shadow: 0 0 1em .25em black;
9
+ box-shadow: 0 0 1em .25em dark-black-color();
10
10
  }
11
11
 
12
12
 
@@ -1,3 +1,3 @@
1
1
  @mixin normal-box-shadow() {
2
- box-shadow: 0 0 1em black;
2
+ box-shadow: 0 0 1em dark-black-color();
3
3
  }
@@ -3,3 +3,15 @@
3
3
  text-decoration: inherit;
4
4
  cursor: inherit;
5
5
  }
6
+
7
+ @mixin highlighted-link() {
8
+
9
+ @include highlighted-block;
10
+
11
+ &:hover{
12
+ color: rgba(white-color(), .85);
13
+ background-color: rgba(black-color(), .80);
14
+
15
+ text-decoration: inherit;
16
+ }
17
+ }
@@ -1,18 +1,14 @@
1
- @mixin link-styled-title() {
1
+ @mixin link-title() {
2
2
  a{
3
3
  @include unstyled-link();
4
4
 
5
- &:hover{
6
- opacity: .75;
7
- text-decoration: none;
8
- }
9
- }
10
- }
5
+ display: block;
6
+
7
+ margin: -1em 0;
8
+ padding: 1em 0;
11
9
 
12
- @mixin link-unstyled-title() {
13
- a{
14
10
  &:hover{
15
- opacity: 1;
11
+ text-decoration: none;
16
12
  }
17
13
  }
18
14
  }
@@ -1,4 +1,6 @@
1
+ @import "mixins/alignments";
1
2
  @import "mixins/animation";
3
+ @import "mixins/blocks";
2
4
  @import "mixins/box-shadows";
3
5
  @import "mixins/keyframes";
4
6
  @import "mixins/links";
@@ -1,5 +1,5 @@
1
1
  // $black
2
- $white: white() !default;
2
+ $white-color: white-color() !default;
3
3
 
4
4
 
5
5
 
@@ -2,8 +2,7 @@ module Sass::Script::Functions
2
2
 
3
3
  RKit::Css.config.colors.each do |name, value|
4
4
  color = Sass::Script.parse value, 0, 0
5
-
6
- define_method name do
5
+ define_method "#{ name }_color" do
7
6
  color
8
7
  end
9
8
  end
data/lib/r_kit/css.rb CHANGED
@@ -8,18 +8,20 @@ class RKit::Css
8
8
  config :colors, :grey, '#888'
9
9
  config :colors, :light_black, '#181818'
10
10
  config :colors, :red, '#b62b2b'
11
+ config :colors, :goldenrod, '#daa520'
11
12
  config :colors, :white, '#fbfbfb'
12
13
 
13
- alias_config :colors, :primary_color, :red
14
- alias_config :colors, :text_color, :grey
15
- alias_config :colors, :text_alt_color, :dark_black
16
- alias_config :colors, :background_color, :black
17
- alias_config :colors, :background_alt_color, :light_black
14
+ alias_config :colors, :primary, :red
15
+ alias_config :colors, :link, :goldenrod
16
+ alias_config :colors, :text, :grey
17
+ alias_config :colors, :text_alt, :dark_black
18
+ alias_config :colors, :background, :black
19
+ alias_config :colors, :background_alt, :light_black
18
20
 
19
- alias_config :colors, :btn_color, :background_color
20
- alias_config :colors, :btn_background_color, :primary_color
21
- alias_config :colors, :btn_disabled_color, :text_alt_color
22
- alias_config :colors, :btn_disabled_background_color, :background_alt_color
21
+ alias_config :colors, :btn, :background
22
+ alias_config :colors, :btn_background, :primary
23
+ alias_config :colors, :btn_disabled, :text_alt
24
+ alias_config :colors, :btn_disabled_background, :background_alt
23
25
 
24
26
 
25
27
  # unused colors
@@ -28,8 +30,8 @@ class RKit::Css
28
30
 
29
31
  preset :light_colors,
30
32
  colors: {
31
- text_color: '#444',
32
- background_color: '#f9f9f9'
33
+ text: '#444',
34
+ background: '#f9f9f9'
33
35
 
34
36
  # $background-alt-color: #e6e6e6;
35
37
  # border color #eee
@@ -14,8 +14,7 @@ module RKit::Decoration::ActionViewBaseExtend
14
14
  end
15
15
 
16
16
  protected def decorate assign
17
- if assign.respond_to? :decorate
18
- p "go in decorate"
17
+ if assign.need_decoration?
19
18
  assign.decorate view_context: self
20
19
  else
21
20
  assign
@@ -1,20 +1,20 @@
1
1
  class RKit::Decoration::Collection < CollectionDelegator
2
2
  include RKit::Decoration::Base
3
3
 
4
+ def initialize *args
5
+ super
4
6
 
5
- attr_accessor :safe_mode
7
+ self.singleton_class.send :override_method, :each do |&block|
8
+ __olddef__ do |object|
9
+ if object.need_decoration?
10
+ block.call object.decorate(view_context: view)
11
+ else
12
+ block.call object
13
+ end
6
14
 
7
- def safe() tap{ @safe_mode = true } end
8
- def unsafe() tap{ @safe_mode = false } end
9
-
10
-
11
- def each &block
12
- collection.each do |object|
13
- if safe_mode && object.dont_respond_to?(:decorate)
14
- block.call object
15
- else
16
- block.call object.decorate(view_context: view)
17
15
  end
18
16
  end
17
+
18
+ self.extend Enumerable
19
19
  end
20
20
  end
@@ -1,21 +1,3 @@
1
1
  class RKit::Decoration::Object < SimpleDelegator
2
2
  include RKit::Decoration::Base
3
-
4
-
5
- singleton_attr_reader :decorated_class
6
- singleton_attr_reader :after_initialize_procs, default: proc{ [] }
7
-
8
- def self.after_initialize &block
9
- after_initialize_procs << block
10
- end
11
-
12
- def after_initialize!
13
- decorator_class.after_initialize_procs.each{ |after_initialize_proc| self.instance_eval &after_initialize_proc }
14
- end
15
-
16
-
17
- def initialize obj, view_context: nil
18
- super
19
- after_initialize!
20
- end
21
3
  end