card 1.95.3 → 1.96.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/card.rb +10 -2
- data/lib/card/migration/import.rb +1 -1
- data/lib/card/set.rb +1 -1
- data/lib/card/set/event.rb +63 -65
- data/lib/card/set/event/callbacks.rb +21 -0
- data/lib/card/set/event/delayed_event.rb +11 -16
- data/lib/card/set/event/options.rb +78 -0
- data/lib/card/set/format.rb +5 -93
- data/lib/card/set/format/abstract_format.rb +104 -0
- data/mod/Modfile +1 -0
- data/mod/basic_formats/set/all/all_csv.rb +1 -1
- data/mod/basic_formats/set/all/json.rb +61 -4
- data/mod/basic_formats/spec/set/all/json_spec.rb +51 -1
- data/mod/basic_formats/spec/shared_context/json_shared_context.rb +40 -0
- data/mod/bootstrap/lib/stylesheets/style_bootstrap_cards.scss +17 -1
- data/mod/bootstrap/set/abstract/bootswatch_theme.rb +2 -12
- data/mod/bootstrap/set/abstract/bootswatch_theme/html_views.rb +31 -0
- data/mod/bootstrap/set/type/customized_bootswatch_skin.rb +12 -0
- data/mod/bootstrap/set/type/customized_bootswatch_skin/core.haml +5 -0
- data/mod/bootstrap/set/type/customized_bootswatch_skin/html_views.rb +36 -0
- data/mod/bootstrap/set/type_plus_right/customized_bootswatch_skin/colors.rb +14 -10
- data/mod/bootstrap/set/type_plus_right/customized_bootswatch_skin/colors/_colorpicker.haml +1 -1
- data/mod/bootstrap/set/type_plus_right/customized_bootswatch_skin/colors/editor.haml +13 -9
- data/mod/core/chunk/link.rb +8 -0
- data/mod/core/set/abstract/code_file.rb +5 -0
- data/mod/core/set/all/chunk.rb +46 -24
- data/mod/core/set/all/event_conditions.rb +32 -11
- data/mod/core/set/all/export.rb +3 -5
- data/mod/core/set/all/item.rb +16 -0
- data/mod/core/set/all/name.rb +1 -0
- data/mod/core/set/all/references.rb +25 -16
- data/mod/core/set/all/rename.rb +20 -21
- data/mod/core/set/all/trash.rb +13 -4
- data/mod/core/spec/set/all/actify_spec.rb +4 -4
- data/mod/core/spec/set/all/event_conditions_spec.rb +68 -10
- data/mod/core/spec/set/all/export_spec.rb +7 -4
- data/mod/core/spec/set/all/references_spec.rb +38 -1
- data/mod/core/spec/set/all/rename_spec.rb +15 -9
- data/mod/follow/spec/set/right/followers_spec.rb +1 -1
- data/mod/follow/spec/set/right/following_spec.rb +4 -8
- data/mod/follow/spec/set/type/notification_template_spec.rb +1 -1
- data/mod/history/set/all/act_view.rb +2 -2
- data/mod/item/set/all/bar.haml +12 -0
- data/mod/item/set/all/bar.rb +77 -0
- data/mod/item/set/all/box.haml +10 -0
- data/mod/item/set/all/box.rb +8 -0
- data/mod/item/set/all/expanded_bar.haml +10 -0
- data/mod/machines/file/all_script_machine_output/file.js +30622 -66
- data/mod/machines/file/all_style_machine_output/file.css +3 -3
- data/mod/machines/file/script_html5shiv_printshiv_machine_output/file.js +1 -1
- data/mod/machines/lib/javascript/decko_slot.js.coffee +18 -13
- data/mod/machines/set/abstract/skin_box.rb +34 -0
- data/mod/machines/set/abstract/skin_box/box_bottom.haml +4 -0
- data/mod/machines/set/type/skin.rb +1 -1
- data/mod/pointer/set/abstract/01_paging.rb +49 -4
- data/mod/pointer/set/abstract/01_paging/paging_links.rb +6 -6
- data/mod/pointer/set/abstract/02_pointer/html_views.rb +10 -0
- data/mod/pointer/set/abstract/02_pointer/other_views.rb +9 -5
- data/mod/pointer/spec/set/abstract/pointer/html_views_spec.rb +4 -10
- data/mod/pointer/spec/set/abstract/pointer/other_views_spec.rb +20 -1
- data/mod/search/set/abstract/01_filter_form_helper.rb +4 -4
- data/mod/search/set/abstract/02_search_params.rb +1 -1
- data/mod/search/set/abstract/03_filter.rb +8 -0
- data/mod/search/set/abstract/search.rb +10 -0
- data/mod/settings/set/right/style.rb +13 -0
- data/mod/settings/set/right/style/editor.haml +4 -4
- data/mod/standard/set/all/path.rb +6 -0
- data/mod/standard/set/type/list.rb +3 -2
- data/mod/standard/set/type/listed_by.rb +5 -1
- data/mod/standard/spec/content/chunk/include_spec.rb +2 -2
- data/mod/standard/spec/set/all/rich_html/editing_spec.rb +4 -69
- data/mod/standard/spec/set/type/listed_by_spec.rb +2 -2
- data/mod/standard/spec/set/type/search_type_spec.rb +56 -0
- data/mod/standard/spec/set/type/set/html_views_spec.rb +5 -9
- data/mod/utility/set/abstract/bs_badge.rb +21 -0
- data/mod/utility/set/abstract/bs_badge/bs_badge.haml +5 -0
- data/mod/utility/set/abstract/bs_badge/labeled_badge.haml +5 -0
- data/mod/utility/set/abstract/bs_badge/tab_badge.haml +5 -0
- data/mod/utility/set/abstract/media.rb +27 -0
- data/mod/utility/set/abstract/media/media_snippet.haml +9 -0
- metadata +28 -10
- data/mod/machines/set/abstract/skin_thumbnail.rb +0 -28
- data/mod/machines/set/abstract/skin_thumbnail/thumbnail.haml +0 -10
@@ -0,0 +1,36 @@
|
|
1
|
+
include_set Abstract::Media
|
2
|
+
include_set Abstract::BsBadge
|
3
|
+
|
4
|
+
format :html do
|
5
|
+
view :bar_middle do
|
6
|
+
labeled_badge card.item_count, "items"
|
7
|
+
end
|
8
|
+
|
9
|
+
view :core, template: :haml do
|
10
|
+
end
|
11
|
+
|
12
|
+
view :bar_right do
|
13
|
+
""
|
14
|
+
end
|
15
|
+
|
16
|
+
before :bar do
|
17
|
+
super()
|
18
|
+
voo.show :edit_button
|
19
|
+
class_up "bar-middle",
|
20
|
+
"col-3 d-none d-md-flex p-3 border-left d-flex align-items-center p-0",
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
24
|
+
view :bar_left do
|
25
|
+
class_up "card-title", "mb-0"
|
26
|
+
render :title
|
27
|
+
end
|
28
|
+
|
29
|
+
view :bar_bottom do
|
30
|
+
render_core
|
31
|
+
end
|
32
|
+
|
33
|
+
def edit_slot
|
34
|
+
haml :edit_slot
|
35
|
+
end
|
36
|
+
end
|
@@ -70,17 +70,21 @@ format :html do
|
|
70
70
|
class: "tags form-control"
|
71
71
|
end
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
path: { action: :update, card: { content: "[[#{card.name}]]" } },
|
76
|
-
class: "btn btn-sm btn-outline-primary"
|
73
|
+
before :bar_right do
|
74
|
+
voo.show :edit_button
|
77
75
|
end
|
78
76
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
77
|
+
view :bar_middle do
|
78
|
+
<<-HTML
|
79
|
+
<div class="colorpicker-element">
|
80
|
+
<div class="input-group-addon">
|
81
|
+
<span class="bg-body border p-1">Text</span>
|
82
|
+
<span class="bg-dark text-light border p-1">Nav</span>
|
83
|
+
<i class="bg-primary"></i>
|
84
|
+
<i class="bg-secondary"></i>
|
85
|
+
</div>
|
86
|
+
</div>
|
87
|
+
HTML
|
84
88
|
end
|
85
89
|
end
|
86
90
|
|
@@ -101,5 +105,5 @@ def replace_values group, prefix=""
|
|
101
105
|
end
|
102
106
|
|
103
107
|
def variable_values_from_params group
|
104
|
-
Env.params.dig(
|
108
|
+
Env.params.dig(group)&.slice(*VARIABLE_NAMES[group]) || {}
|
105
109
|
end
|
@@ -1,9 +1,13 @@
|
|
1
|
-
|
2
|
-
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
.
|
7
|
-
%
|
8
|
-
|
9
|
-
|
1
|
+
.row
|
2
|
+
.col-6
|
3
|
+
%h4 Palette
|
4
|
+
- colors.each do |name, color|
|
5
|
+
= haml_partial :colorpicker, color_name: name, color: color
|
6
|
+
.col-6
|
7
|
+
%h4 Uses
|
8
|
+
- theme_colors.each do |name, value|
|
9
|
+
.form-group.row
|
10
|
+
%label.col-sm-4.col-form-label
|
11
|
+
= name
|
12
|
+
= theme_color_picker name, value
|
13
|
+
|
data/mod/core/chunk/link.rb
CHANGED
@@ -59,6 +59,11 @@ format :html do
|
|
59
59
|
"Content is stored in file and can't be edited."
|
60
60
|
end
|
61
61
|
|
62
|
+
view :bar_middle do
|
63
|
+
fa_icon("exclamation-circle", class: "text-muted pr-2") +
|
64
|
+
wrap_with(:span, "file", class: "text-muted")
|
65
|
+
end
|
66
|
+
|
62
67
|
def standard_submit_button
|
63
68
|
multi_card_editor? ? super : ""
|
64
69
|
end
|
data/mod/core/set/all/chunk.rb
CHANGED
@@ -1,31 +1,27 @@
|
|
1
1
|
|
2
|
-
def chunks content, type
|
2
|
+
def chunks content, type, named=false
|
3
3
|
content ||= self.content
|
4
4
|
type ||= Card::Content::Chunk
|
5
|
-
Card::Content.new(content, self).find_chunks type
|
5
|
+
all_chunks = Card::Content.new(content, self).find_chunks type
|
6
|
+
named ? all_chunks.select(&:referee_name) : all_chunks
|
6
7
|
end
|
7
8
|
|
8
|
-
def
|
9
|
-
chunks
|
10
|
-
next unless chunk.referee_name # filter commented nests
|
11
|
-
yield chunk
|
12
|
-
end
|
9
|
+
def reference_chunks content=nil, named=true
|
10
|
+
chunks content, Card::Content::Chunk::Reference, named
|
13
11
|
end
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
13
|
+
# named=true rejects commented nests
|
14
|
+
def nest_chunks content=nil, named=true
|
15
|
+
chunks content, Card::Content::Chunk::Nest, named
|
19
16
|
end
|
20
17
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
18
|
+
# named=true rejects external links (since the don't refer to a card name)
|
19
|
+
def link_chunks content=nil, named=false
|
20
|
+
chunks content, Card::Content::Chunk::Link, named
|
25
21
|
end
|
26
22
|
|
27
23
|
def each_item_name_with_options content=nil
|
28
|
-
|
24
|
+
reference_chunks(content).each do |chunk|
|
29
25
|
options = chunk.respond_to?(:options) ? chunk.options : {}
|
30
26
|
yield chunk.referee_name, options
|
31
27
|
end
|
@@ -34,12 +30,18 @@ end
|
|
34
30
|
format do
|
35
31
|
def nested_fields content=nil
|
36
32
|
result = []
|
37
|
-
each_nested_card(content) do |chunk|
|
33
|
+
each_nested_card(content, true) do |chunk|
|
38
34
|
result << [chunk.referee_name, chunk.options]
|
39
35
|
end
|
40
36
|
result
|
41
37
|
end
|
42
38
|
|
39
|
+
def nested_field_cards content=nil
|
40
|
+
nested_fields(content).map do |name, _options|
|
41
|
+
Card.fetch name
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
43
45
|
def nested_cards_for_edit fields_only=false
|
44
46
|
return normalized_edit_fields if edit_fields.present?
|
45
47
|
result = []
|
@@ -72,26 +74,34 @@ format do
|
|
72
74
|
card.name.field cardish
|
73
75
|
end
|
74
76
|
|
75
|
-
def process_field chunk, processed
|
77
|
+
def process_field chunk, processed
|
76
78
|
return unless process_unique_field? chunk, processed
|
77
|
-
yield chunk
|
79
|
+
yield chunk if block_given?
|
78
80
|
end
|
79
81
|
|
80
82
|
def each_nested_field content=nil, &block
|
81
83
|
each_nested_card content, true, &block
|
82
84
|
end
|
83
85
|
|
84
|
-
def each_nested_card content=nil, fields_only=
|
86
|
+
def each_nested_card content=nil, fields_only=false, &block
|
85
87
|
processed = process_tally
|
86
|
-
|
88
|
+
nest_chunks(content).each do |chunk|
|
87
89
|
next if fields_only && !field_chunk?(chunk)
|
88
90
|
process_nested_chunk chunk, processed, &block
|
89
91
|
end
|
90
92
|
end
|
91
93
|
|
92
|
-
def
|
94
|
+
def uniq_nested_cards content: nil
|
95
|
+
with_unique_chunks do
|
96
|
+
nest_chunks(content).map do |chunk|
|
97
|
+
chunk.referee_card if unique_chunk? chunk
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def nest_chunks content=nil
|
93
103
|
content ||= _render_raw
|
94
|
-
card.
|
104
|
+
card.nest_chunks content
|
95
105
|
end
|
96
106
|
|
97
107
|
def process_tally
|
@@ -102,8 +112,20 @@ format do
|
|
102
112
|
chunk.referee_name.to_name.field_of? card.name
|
103
113
|
end
|
104
114
|
|
115
|
+
def unique_chunk? chunk
|
116
|
+
key = chunk.referee_name.key
|
117
|
+
return false if @processed.include? key
|
118
|
+
@processed << key
|
119
|
+
true
|
120
|
+
end
|
121
|
+
|
122
|
+
def with_unique_chunks
|
123
|
+
@processed = ::Set.new [card.key]
|
124
|
+
yield
|
125
|
+
end
|
126
|
+
|
105
127
|
def process_nested_chunk chunk, processed, &block
|
106
|
-
virtual = chunk.referee_card
|
128
|
+
virtual = chunk.referee_card&.virtual?
|
107
129
|
# TODO: handle structures that are non-virtual
|
108
130
|
method = virtual ? :process_virtual_field : :process_field
|
109
131
|
send method, chunk, processed, &block
|
@@ -1,15 +1,16 @@
|
|
1
|
-
|
1
|
+
def event_applies? event
|
2
|
+
return unless set_condition_applies? event.set_module
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
send "#{key}_condition_applies?", event, opts[key]
|
4
|
+
Card::Set::Event::CONDITIONS.all? do |key|
|
5
|
+
send "#{key}_condition_applies?", event, event.opts[key]
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
9
|
private
|
10
10
|
|
11
|
-
def set_condition_applies?
|
12
|
-
|
11
|
+
def set_condition_applies? set_module
|
12
|
+
# events on Card are used for testing
|
13
|
+
set_module == Card || singleton_class.include?(set_module)
|
13
14
|
end
|
14
15
|
|
15
16
|
def on_condition_applies? _event, actions
|
@@ -32,9 +33,14 @@ def when_condition_applies? _event, block
|
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
35
|
-
def
|
36
|
-
return true unless
|
37
|
-
skip_event? event
|
36
|
+
def skip_condition_applies? event, allowed
|
37
|
+
return true unless allowed == :allowed
|
38
|
+
!skip_event? event
|
39
|
+
end
|
40
|
+
|
41
|
+
def trigger_condition_applies? event, required
|
42
|
+
return true unless required == :required
|
43
|
+
trigger_event? event
|
38
44
|
end
|
39
45
|
|
40
46
|
def single_changed_condition_applies? db_column
|
@@ -63,6 +69,21 @@ def wrong_action action
|
|
63
69
|
end
|
64
70
|
|
65
71
|
def skip_event? event
|
66
|
-
@names_of_skipped_events ||=
|
67
|
-
|
72
|
+
@names_of_skipped_events ||= skipped_events
|
73
|
+
@names_of_skipped_events.include? event.name
|
74
|
+
end
|
75
|
+
|
76
|
+
def skipped_events
|
77
|
+
events = Array.wrap(skip_event_in_action) + Array.wrap(act_card.skip_event)
|
78
|
+
::Set.new events.map(&:to_sym)
|
79
|
+
end
|
80
|
+
|
81
|
+
def trigger_event? event
|
82
|
+
@names_of_triggered_events ||= triggered_events
|
83
|
+
@names_of_triggered_events.include? event.name
|
84
|
+
end
|
85
|
+
|
86
|
+
def triggered_events
|
87
|
+
events = Array.wrap(trigger_event_in_action) + Array.wrap(act_card.trigger_event)
|
88
|
+
::Set.new events.map(&:to_sym)
|
68
89
|
end
|
data/mod/core/set/all/export.rb
CHANGED
@@ -26,12 +26,10 @@ format :json do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def items_for_export
|
29
|
-
|
30
|
-
each_nested_chunk(nil) do |chunk|
|
29
|
+
nest_chunks.map do |chunk|
|
31
30
|
next if main_nest_chunk? chunk
|
32
|
-
|
33
|
-
end
|
34
|
-
items
|
31
|
+
chunk.referee_card
|
32
|
+
end.compact
|
35
33
|
end
|
36
34
|
|
37
35
|
def valid_items_for_export
|
data/mod/core/set/all/item.rb
CHANGED
@@ -16,6 +16,10 @@ def item_keys args={}
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
def item_count args={}
|
20
|
+
item_names(args).size
|
21
|
+
end
|
22
|
+
|
19
23
|
def include_item? item
|
20
24
|
key = item.is_a?(Card) ? item.name.key : item.to_name.key
|
21
25
|
item_names.map { |name| name.to_name.key }.member? key
|
@@ -89,4 +93,16 @@ format do
|
|
89
93
|
type_from_rule = card.item_type
|
90
94
|
options[:type] = type_from_rule if type_from_rule
|
91
95
|
end
|
96
|
+
|
97
|
+
def listing listing_cards, item_args={}
|
98
|
+
listing_cards.map do |item_card|
|
99
|
+
nest_item item_card, item_args do |rendered, item_view|
|
100
|
+
wrap_item rendered, item_view
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def wrap_item rendered, item_view
|
106
|
+
%(<div class="item-#{item_view}">#{rendered}</div>)
|
107
|
+
end
|
92
108
|
end
|
data/mod/core/set/all/name.rb
CHANGED
@@ -9,24 +9,30 @@ PARTIAL_REF_CODE = "P".freeze
|
|
9
9
|
|
10
10
|
# cards that refer to self
|
11
11
|
def referers
|
12
|
-
references_in
|
12
|
+
referer_cards_from_references references_in
|
13
13
|
end
|
14
14
|
|
15
15
|
# cards that include self
|
16
|
-
def
|
17
|
-
|
18
|
-
|
16
|
+
def nesters
|
17
|
+
referer_cards_from_references references_in.where(ref_type: "I")
|
18
|
+
end
|
19
|
+
|
20
|
+
def referer_cards_from_references references
|
21
|
+
references.map(&:referer_id).uniq.map(&Card.method(:fetch)).compact
|
19
22
|
end
|
20
23
|
|
21
24
|
# cards that self refers to
|
22
25
|
def referees
|
23
|
-
references_out
|
26
|
+
referees_from_references references_out
|
24
27
|
end
|
25
28
|
|
26
29
|
# cards that self includes
|
27
|
-
def
|
28
|
-
|
29
|
-
|
30
|
+
def nestees
|
31
|
+
referees_from_references references_out.where(ref_type: "I")
|
32
|
+
end
|
33
|
+
|
34
|
+
def referees_from_references references
|
35
|
+
references.map(&:referee_key).uniq.map { |key| Card.fetch key, new: {} }
|
30
36
|
end
|
31
37
|
|
32
38
|
# cards that refer to self by name
|
@@ -38,7 +44,7 @@ end
|
|
38
44
|
# cards that refer to self or any descendant
|
39
45
|
def family_referers
|
40
46
|
@family_referers ||= ([self] + descendants).map(&:referers).flatten.uniq
|
41
|
-
# TODO: make this more efficient!
|
47
|
+
# TODO: make this more efficient using partial references!
|
42
48
|
end
|
43
49
|
|
44
50
|
# replace references in card content
|
@@ -157,14 +163,13 @@ end
|
|
157
163
|
# on rename, update names in cards that refer to self by name (as directed)
|
158
164
|
event :update_referer_content, :finalize,
|
159
165
|
on: :update, after: :name_change_finalized,
|
160
|
-
when:
|
166
|
+
when: :update_referers do
|
161
167
|
# FIXME: break into correct stages
|
162
168
|
Auth.as_bot do
|
163
|
-
|
169
|
+
referers.each do |card|
|
164
170
|
next if card == self || card.structure
|
165
|
-
|
166
|
-
card.
|
167
|
-
card.save!
|
171
|
+
new_content = card.replace_reference_syntax name_before_last_save, name
|
172
|
+
card.refresh.update_attributes! content: new_content
|
168
173
|
end
|
169
174
|
end
|
170
175
|
end
|
@@ -175,6 +180,10 @@ end
|
|
175
180
|
# then we need to be sure that A has a partial reference
|
176
181
|
event :update_referer_references_out, :finalize,
|
177
182
|
on: :update, after: :name_change_finalized,
|
178
|
-
when:
|
179
|
-
|
183
|
+
when: :not_update_referers do
|
184
|
+
referers.map(&:update_references_out)
|
185
|
+
end
|
186
|
+
|
187
|
+
def not_update_referers
|
188
|
+
!update_referers
|
180
189
|
end
|