card 1.18.3 → 1.18.4
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/VERSION +1 -1
- data/card.gemspec +5 -3
- data/db/schema.rb +1 -1
- data/lib/card/active_record_helper.rb +2 -1
- data/lib/card/core_ext.rb +8 -0
- data/lib/card/format/nest.rb +13 -2
- data/lib/card/format/render.rb +7 -1
- data/lib/card/migration.rb +2 -1
- data/lib/card/set.rb +55 -70
- data/lib/card/set/trait.rb +70 -0
- data/lib/card/stage.rb +33 -8
- data/lib/card/stage_director.rb +3 -1
- data/lib/cardio.rb +2 -1
- data/mod/01_core/chunk/link.rb +7 -6
- data/mod/01_core/set/all/collection.rb +15 -52
- data/mod/01_core/set/all/fetch.rb +26 -6
- data/mod/01_core/set/all/references.rb +11 -3
- data/mod/01_core/set/all/subcards.rb +2 -2
- data/mod/01_core/set/all/tracked_attributes.rb +5 -1
- data/mod/01_core/set/all/utils.rb +1 -1
- data/mod/01_core/spec/set/all/collection_spec.rb +2 -2
- data/mod/01_history/set/all/content_history.rb +10 -11
- data/mod/02_basic_types/set/abstract/code_file.rb +57 -0
- data/mod/02_basic_types/set/type/pointer.rb +9 -5
- data/mod/03_machines/lib/javascript/wagn.js.coffee +4 -1
- data/mod/03_machines/lib/javascript/wagn_mod.js.coffee +29 -24
- data/mod/03_machines/set/self/script_ace.rb +1 -11
- data/mod/03_machines/set/self/script_card_menu.rb +1 -10
- data/mod/03_machines/set/self/script_html5shiv_printshiv.rb +1 -2
- data/mod/03_machines/set/self/script_jquery.rb +1 -2
- data/mod/03_machines/set/self/script_jquery_helper.rb +4 -7
- data/mod/03_machines/set/self/script_slot.rb +4 -6
- data/mod/03_machines/set/self/script_tinymce.rb +1 -2
- data/mod/03_machines/set/self/style_bootstrap_compatible.rb +1 -5
- data/mod/03_machines/set/self/style_cards.rb +1 -6
- data/mod/03_machines/set/self/style_jquery_ui_smoothness.rb +1 -2
- data/mod/03_machines/set/type/coffee_script.rb +1 -1
- data/mod/03_machines/set/type/css.rb +10 -1
- data/mod/03_machines/set/type/java_script.rb +16 -1
- data/mod/03_machines/set/type/scss.rb +3 -2
- data/mod/05_standard/lib/image_uploader.rb +15 -0
- data/mod/05_standard/set/all/rich_html/editing.rb +2 -2
- data/mod/05_standard/set/all/rich_html/form.rb +40 -19
- data/mod/05_standard/set/all/rich_html/modal.rb +4 -2
- data/mod/05_standard/set/all/rich_html/toolbar.rb +88 -39
- data/mod/05_standard/set/type/search_type.rb +6 -3
- data/mod/06_bootstrap/set/all/bootstrap/table.rb +55 -0
- data/mod/06_bootstrap/set/all/bootstrap/tabs.rb +81 -0
- data/mod/06_bootstrap/set/self/bootstrap_cards.rb +1 -9
- data/mod/06_bootstrap/set/self/bootstrap_js.rb +4 -6
- data/mod/06_bootstrap/set/self/bootswatch_shared.rb +11 -3
- data/mod/06_bootstrap/set/self/smartmenu_css.rb +3 -5
- data/mod/06_bootstrap/set/self/smartmenu_js.rb +3 -5
- data/spec/lib/card/set/trait_spec.rb +62 -0
- metadata +24 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e23b9e82cf314afb35cdffb4bbbd0702ec4fd43
|
4
|
+
data.tar.gz: 0ec7fdb9104bd4a9a0e24477337d641deaaeb0b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62199dc7a8d4f352ecf7e0f6239379881200ce30b6c66968cb7509538322c82770b1dc70f6b1d6bb15b4cf5b18678fbd80d20030ae414d06f881e46101f62bcb
|
7
|
+
data.tar.gz: 127ba24fe1f23acb5ae669896c8255cb244245956481095846c175cd95471fbbb6e58a5cc4706e1485293959df5e177742e60fe3fb606bbe02ece2eb620a180c
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.18.
|
1
|
+
1.18.4
|
data/card.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
'Cards are data atoms grouped into Sets to which Rules can apply. '\
|
14
14
|
'Cards can formatted with Views and transformed with Events.'
|
15
15
|
s.homepage = 'http://wagn.org'
|
16
|
-
s.
|
16
|
+
s.licenses = ['GPL-2.0', 'GPL-3.0']
|
17
17
|
|
18
18
|
s.files = `git ls-files`.split $INPUT_RECORD_SEPARATOR
|
19
19
|
|
@@ -43,7 +43,6 @@ Gem::Specification.new do |s|
|
|
43
43
|
['mini_magick', '~> 4.2'],
|
44
44
|
['recaptcha', '~> 0.4.0'],
|
45
45
|
# 0.4.0 is last version that doesn't require ruby 2.0
|
46
|
-
|
47
46
|
['coderay', '~> 1.0'],
|
48
47
|
['sass', '~> 3.2'],
|
49
48
|
['coffee-script', '~> 2.2'],
|
@@ -53,7 +52,10 @@ Gem::Specification.new do |s|
|
|
53
52
|
['kaminari', '~> 0.16'],
|
54
53
|
|
55
54
|
['bootstrap-kaminari-views', '~> 0'],
|
56
|
-
['diff-lcs', '~> 1.2']
|
55
|
+
['diff-lcs', '~> 1.2'],
|
56
|
+
# mime-types can be removed if we drop support for ruby 1.9.3
|
57
|
+
# mime-types 3.0 uses mime-types-data which isn't compatible with 1.9.3
|
58
|
+
['mime-types', '2.99.1']
|
57
59
|
].each do |dep|
|
58
60
|
s.add_runtime_dependency(*dep)
|
59
61
|
end
|
data/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20160229134221) do
|
15
15
|
|
16
16
|
create_table "card_actions", force: :cascade do |t|
|
17
17
|
t.integer "card_id", limit: 4
|
@@ -5,8 +5,9 @@ class Card
|
|
5
5
|
Card.create! args
|
6
6
|
end
|
7
7
|
|
8
|
+
# if card with same name exists move it out of the way
|
8
9
|
def create_card! args
|
9
|
-
create_card args.reverse_merge(rename_if_conflict: :
|
10
|
+
create_card args.reverse_merge(rename_if_conflict: :old)
|
10
11
|
end
|
11
12
|
|
12
13
|
def update_card name, args
|
data/lib/card/core_ext.rb
CHANGED
data/lib/card/format/nest.rb
CHANGED
@@ -12,6 +12,19 @@ class Card
|
|
12
12
|
mainline: @mainline, form: @form
|
13
13
|
end
|
14
14
|
|
15
|
+
def field_subformat field
|
16
|
+
field = card.cardname.field(field) unless field.is_a?(Card)
|
17
|
+
subformat field
|
18
|
+
end
|
19
|
+
|
20
|
+
def field_nest field, opts={}
|
21
|
+
if field.is_a?(Card)
|
22
|
+
nest field, opts
|
23
|
+
else
|
24
|
+
prepare_nest opts.merge(inc_name: card.cardname.field(field))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
15
28
|
def with_nest_mode mode
|
16
29
|
if (switch_mode = INCLUSION_MODES[mode]) && @mode != switch_mode
|
17
30
|
old_mode = @mode
|
@@ -77,9 +90,7 @@ class Card
|
|
77
90
|
else
|
78
91
|
view
|
79
92
|
end
|
80
|
-
|
81
93
|
sub.optional_render view, opts
|
82
|
-
# end
|
83
94
|
end
|
84
95
|
|
85
96
|
def get_nest_content cardname
|
data/lib/card/format/render.rb
CHANGED
@@ -132,8 +132,14 @@ class Card
|
|
132
132
|
options[:class] = [options[:class], klass].flatten.compact * ' '
|
133
133
|
end
|
134
134
|
|
135
|
+
def id_counter
|
136
|
+
return @parent.id_counter if @parent
|
137
|
+
@id_counter ||= 0
|
138
|
+
@id_counter += 1
|
139
|
+
end
|
140
|
+
|
135
141
|
def unique_id
|
136
|
-
"#{card.key}-#{
|
142
|
+
"#{card.key}-#{id_counter}"
|
137
143
|
end
|
138
144
|
end
|
139
145
|
end
|
data/lib/card/migration.rb
CHANGED
@@ -44,7 +44,8 @@ class Card::Migration < ActiveRecord::Migration
|
|
44
44
|
|
45
45
|
ActiveRecord::Base.table_name_suffix = new_suffix
|
46
46
|
ActiveRecord::SchemaMigration.reset_table_name
|
47
|
-
|
47
|
+
paths = Cardio.migration_paths(type)
|
48
|
+
yield(paths)
|
48
49
|
ActiveRecord::Base.table_name_suffix = original_suffix
|
49
50
|
ActiveRecord::SchemaMigration.reset_table_name
|
50
51
|
end
|
data/lib/card/set.rb
CHANGED
@@ -3,8 +3,10 @@
|
|
3
3
|
class Card
|
4
4
|
module Set
|
5
5
|
include Event
|
6
|
+
include Trait
|
6
7
|
mattr_accessor :modules, :traits
|
7
|
-
@@modules = { base: [], base_format: {}, nonbase: {}, nonbase_format: {}
|
8
|
+
@@modules = { base: [], base_format: {}, nonbase: {}, nonbase_format: {},
|
9
|
+
abstract: {}, abstract_format: {} }
|
8
10
|
|
9
11
|
# A 'Set' is a group of Cards to which 'Rules' may be applied.
|
10
12
|
# Sets can be as specific as a single card, as general as all cards, or
|
@@ -129,6 +131,7 @@ class Card
|
|
129
131
|
def define_on_format format_name=:base, &block
|
130
132
|
# format class name, eg. HtmlFormat
|
131
133
|
klass = Card::Format.format_class_name format_name
|
134
|
+
|
132
135
|
# called on current set module, eg Card::Set::Type::Pointer
|
133
136
|
mod = const_get_or_set klass do
|
134
137
|
# yielding set format module, eg Card::Set::Type::Pointer::HtmlFormat
|
@@ -169,22 +172,49 @@ class Card
|
|
169
172
|
end
|
170
173
|
end
|
171
174
|
|
172
|
-
#
|
173
|
-
#
|
174
|
-
#
|
175
|
-
|
176
|
-
|
177
|
-
|
175
|
+
# include a set module and all its format modules
|
176
|
+
# @param [Module] set
|
177
|
+
# @param [Hash] opts choose the formats you want to include
|
178
|
+
# @option opts [Symbol, Array<Symbol>] :only include only these formats
|
179
|
+
# @option opts [Symbol, Array<Symbol>] :except don't include these formats
|
180
|
+
# @example
|
181
|
+
# include_set Type::Basic, except: :css
|
182
|
+
def include_set set, opts={}
|
183
|
+
set_type = set.abstract_set? ? :abstract : :nonbase
|
184
|
+
@@modules[set_type][set.shortname].each do |set_mod|
|
185
|
+
include set_mod
|
186
|
+
end
|
187
|
+
include_set_formats set, opts
|
178
188
|
end
|
179
189
|
|
180
|
-
def
|
181
|
-
|
182
|
-
|
190
|
+
def each_format set
|
191
|
+
set_type = set.abstract_set? ? :abstract : :nonbase
|
192
|
+
format_type = "#{set_type}_format".to_sym
|
193
|
+
@@modules[format_type].each_pair do |format, set_format_mod_hash|
|
194
|
+
next unless (format_mods = set_format_mod_hash[set.shortname])
|
195
|
+
yield format, format_mods
|
196
|
+
end
|
183
197
|
end
|
184
198
|
|
185
|
-
|
186
|
-
|
187
|
-
|
199
|
+
# include a format modules of a set
|
200
|
+
# @param [Module] set
|
201
|
+
# @param [Hash] opts choose the formats you want to include
|
202
|
+
# @option opts [Symbol, Array<Symbol>] :only include only these formats
|
203
|
+
# @option opts [Symbol, Array<Symbol>] :except don't include these formats
|
204
|
+
# @example
|
205
|
+
# include_set Type::Basic, except: :css
|
206
|
+
def include_set_formats set, opts={}
|
207
|
+
each_format set do |format, format_mods|
|
208
|
+
match = format.to_s.match(/::(?<format>[^:]+)Format/)
|
209
|
+
format_sym = match ? match[:format] : :base
|
210
|
+
next if opts[:except] && Array(opts[:except]).include?(format_sym)
|
211
|
+
next if opts[:only] && !Array(opts[:only]).include?(format_sym)
|
212
|
+
format_mods.each do |format_mod|
|
213
|
+
define_on_format format_sym do
|
214
|
+
include format_mod
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
188
218
|
end
|
189
219
|
|
190
220
|
def ensure_set &block
|
@@ -220,15 +250,14 @@ class Card
|
|
220
250
|
|
221
251
|
# make the set available for use
|
222
252
|
def register_set set_module
|
223
|
-
return if set_module.abstract_set? # noop; only used by explicit
|
224
|
-
# inclusion in other set modules
|
225
253
|
if set_module.all_set?
|
226
254
|
# automatically included in Card class
|
227
255
|
modules[:base] << set_module
|
228
256
|
else
|
257
|
+
set_type = set_module.abstract_set? ? :abstract : :nonbase
|
229
258
|
# made ready for dynamic loading via #include_set_modules
|
230
|
-
modules[
|
231
|
-
modules[
|
259
|
+
modules[set_type][set_module.shortname] ||= []
|
260
|
+
modules[set_type][set_module.shortname] << set_module
|
232
261
|
end
|
233
262
|
end
|
234
263
|
|
@@ -290,16 +319,14 @@ EOF
|
|
290
319
|
end
|
291
320
|
|
292
321
|
def register_set_format format_class, mod
|
293
|
-
return if abstract_set? # noop; only used by explicit inclusion in
|
294
|
-
# other set modules
|
295
|
-
|
296
322
|
if all_set?
|
297
323
|
# ready to include in base format classes
|
298
324
|
modules[:base_format][format_class] ||= []
|
299
325
|
modules[:base_format][format_class] << mod
|
300
326
|
else
|
327
|
+
format_type = abstract_set? ? :abstract_format : :nonbase_format
|
301
328
|
# ready to include dynamically in set members' format singletons
|
302
|
-
format_hash = modules[
|
329
|
+
format_hash = modules[format_type][format_class] ||= {}
|
303
330
|
format_hash[shortname] ||= []
|
304
331
|
format_hash[shortname] << mod
|
305
332
|
end
|
@@ -308,9 +335,13 @@ EOF
|
|
308
335
|
def shortname
|
309
336
|
parts = name.split '::'
|
310
337
|
first = 2 # shortname eliminates Card::Set
|
311
|
-
|
312
|
-
|
313
|
-
|
338
|
+
pattern_name = parts[first].underscore
|
339
|
+
last = if pattern_name == 'abstract'
|
340
|
+
first + 1
|
341
|
+
else
|
342
|
+
set_class = Card::SetPattern.find pattern_name
|
343
|
+
first + set_class.anchor_parts_count
|
344
|
+
end
|
314
345
|
parts[first..last].join '::'
|
315
346
|
end
|
316
347
|
|
@@ -324,52 +355,6 @@ EOF
|
|
324
355
|
|
325
356
|
private
|
326
357
|
|
327
|
-
def get_traits mod
|
328
|
-
Card::Set.traits ||= {}
|
329
|
-
Card::Set.traits[mod] || Card::Set.traits[mod] = {}
|
330
|
-
end
|
331
|
-
|
332
|
-
def add_traits args, options
|
333
|
-
mod = self
|
334
|
-
# raise "Can't define card traits on all set" if mod == Card
|
335
|
-
mod_traits = get_traits mod
|
336
|
-
|
337
|
-
new_opts = options[:type] ? { type: options[:type] } : {}
|
338
|
-
new_opts[:default_content] = options[:default] if options[:default]
|
339
|
-
|
340
|
-
args.each do |trait|
|
341
|
-
define_trait_card trait, new_opts
|
342
|
-
define_trait_reader trait if options[:reader]
|
343
|
-
define_trait_writer trait if options[:writer]
|
344
|
-
|
345
|
-
mod_traits[trait.to_sym] = options
|
346
|
-
end
|
347
|
-
end
|
348
|
-
|
349
|
-
def define_trait_card trait, opts
|
350
|
-
define_method "#{trait}_card" do
|
351
|
-
trait_var "@#{trait}_card" do
|
352
|
-
fetch trait: trait.to_sym, new: opts.clone
|
353
|
-
end
|
354
|
-
end
|
355
|
-
end
|
356
|
-
|
357
|
-
def define_trait_reader trait
|
358
|
-
define_method trait do
|
359
|
-
trait_var "@#{trait}" do
|
360
|
-
send("#{trait}_card").content
|
361
|
-
end
|
362
|
-
end
|
363
|
-
end
|
364
|
-
|
365
|
-
def define_trait_writer trait
|
366
|
-
define_method "#{trait}=" do |value|
|
367
|
-
card = send "#{trait}_card"
|
368
|
-
subcards.add name: card.name, type_id: card.type_id, content: value
|
369
|
-
instance_variable_set "@#{trait}", value
|
370
|
-
end
|
371
|
-
end
|
372
|
-
|
373
358
|
def set_specific_attributes *args
|
374
359
|
Card.set_specific_attributes ||= []
|
375
360
|
Card.set_specific_attributes += args.map(&:to_s)
|
@@ -0,0 +1,70 @@
|
|
1
|
+
class Card
|
2
|
+
module Set
|
3
|
+
#
|
4
|
+
# ActiveCard support: accessing plus cards as attributes
|
5
|
+
module Trait
|
6
|
+
def card_accessor *args
|
7
|
+
options = args.extract_options!
|
8
|
+
add_traits args, options.merge(reader: true, writer: true)
|
9
|
+
end
|
10
|
+
|
11
|
+
def card_reader *args
|
12
|
+
options = args.extract_options!
|
13
|
+
add_traits args, options.merge(reader: true)
|
14
|
+
end
|
15
|
+
|
16
|
+
def card_writer *args
|
17
|
+
options = args.extract_options!
|
18
|
+
add_traits args, options.merge(writer: true)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def get_traits mod
|
24
|
+
Card::Set.traits ||= {}
|
25
|
+
Card::Set.traits[mod] || Card::Set.traits[mod] = {}
|
26
|
+
end
|
27
|
+
|
28
|
+
def add_traits args, options
|
29
|
+
mod = self
|
30
|
+
# raise "Can't define card traits on all set" if mod == Card
|
31
|
+
mod_traits = get_traits mod
|
32
|
+
|
33
|
+
new_opts = options[:type] ? { type: options[:type] } : {}
|
34
|
+
new_opts[:default_content] = options[:default] if options[:default]
|
35
|
+
|
36
|
+
args.each do |trait|
|
37
|
+
define_trait_card trait, new_opts
|
38
|
+
define_trait_reader trait if options[:reader]
|
39
|
+
define_trait_writer trait if options[:writer]
|
40
|
+
|
41
|
+
mod_traits[trait.to_sym] = options
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def define_trait_card trait, opts
|
46
|
+
define_method "#{trait}_card" do
|
47
|
+
trait_var "@#{trait}_card" do
|
48
|
+
fetch trait: trait.to_sym, new: opts.clone
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def define_trait_reader trait
|
54
|
+
define_method trait do
|
55
|
+
trait_var "@#{trait}" do
|
56
|
+
send("#{trait}_card").content
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def define_trait_writer trait
|
62
|
+
define_method "#{trait}=" do |value|
|
63
|
+
card = send "#{trait}_card"
|
64
|
+
subcards.add name: card.name, type_id: card.type_id, content: value
|
65
|
+
instance_variable_set "@#{trait}", value
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/lib/card/stage.rb
CHANGED
@@ -3,18 +3,43 @@ class Card
|
|
3
3
|
# 8 stages that are grouped in 3 phases.
|
4
4
|
#
|
5
5
|
# 'validation phase'
|
6
|
-
# * initialize stage
|
7
|
-
# * prepare_to_validate stage
|
8
|
-
# * validate stage
|
6
|
+
# * initialize stage (I)
|
7
|
+
# * prepare_to_validate stage (P2V)
|
8
|
+
# * validate stage (V)
|
9
9
|
#
|
10
10
|
# 'storage phase'
|
11
|
-
# * prepare_to_store stage
|
12
|
-
# * store stage
|
13
|
-
# * finalize stage
|
11
|
+
# * prepare_to_store stage (P2S)
|
12
|
+
# * store stage (S)
|
13
|
+
# * finalize stage (F)
|
14
14
|
#
|
15
15
|
# 'integration phase'
|
16
|
-
# * integrate stage
|
17
|
-
# * integrate_with_delay stage
|
16
|
+
# * integrate stage (IG)
|
17
|
+
# * integrate_with_delay stage (IGwD)
|
18
|
+
#
|
19
|
+
#
|
20
|
+
# Explanation:
|
21
|
+
# yes! the recommended stage to do that
|
22
|
+
# yes ok to do it here if necessary
|
23
|
+
# no not recommended; chance to mess things up
|
24
|
+
# but if something forces you to do it here you can try
|
25
|
+
# no! never do it here. it won't work or will break things
|
26
|
+
#
|
27
|
+
# if there is only a single entry in a phase column it counts for all stages
|
28
|
+
# of that phase
|
29
|
+
#
|
30
|
+
# validation | storage | integrate
|
31
|
+
# I P2V V | P2S S F | IG IGwD
|
32
|
+
#----------------------------------------------------------------------
|
33
|
+
# add subcard yes! yes! yes | yes yes yes | yes
|
34
|
+
# remove subcard yes! yes! yes | yes no no! | no!
|
35
|
+
# validate yes yes yes! | no | no
|
36
|
+
# unsecure change yes yes! no | no! | no!
|
37
|
+
# secure change yes | yes! no! no! | no!
|
38
|
+
# abort yes! | yes | yes?
|
39
|
+
# fail
|
40
|
+
# create other cards
|
41
|
+
# has id no | no no? yes | yes
|
42
|
+
# dirty attributes yes | yes | no
|
18
43
|
#
|
19
44
|
#
|
20
45
|
module Stage
|