card 1.15.7 → 1.16.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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/card.gemspec +3 -2
- data/config/initializers/inflections.rb +1 -1
- data/db/migrate_core_cards/20150528084659_add_session_cardtype.rb +0 -1
- data/db/migrate_core_cards/20150601133433_add_recent_setting_session_card.rb +12 -0
- data/db/migrate_core_cards/20150610171702_add_debugger_session_card.rb +11 -0
- data/db/migrate_core_cards/20150611203506_rails_inflection_updates.rb +82 -0
- data/db/migrate_core_cards/20150627205133_fix_script_bootstrap_card_type.rb +7 -0
- data/db/migrate_core_cards/20150702130543_remove_edit_toolbar_pinned.rb +9 -0
- data/db/schema.rb +81 -81
- data/db/seed/new/card_actions.yml +12581 -1647
- data/db/seed/new/card_acts.yml +1 -1
- data/db/seed/new/card_changes.yml +39326 -7569
- data/db/seed/new/card_references.yml +518 -455
- data/db/seed/new/cards.yml +1547 -1291
- data/db/seed/test/fixtures/card_actions.yml +13700 -2717
- data/db/seed/test/fixtures/card_acts.yml +314 -272
- data/db/seed/test/fixtures/card_changes.yml +45409 -13573
- data/db/seed/test/fixtures/card_references.yml +1223 -1125
- data/db/seed/test/fixtures/cards.yml +2694 -2433
- data/db/seed/test/fixtures/file1.txt +1 -0
- data/db/seed/test/fixtures/file2.txt +1 -0
- data/db/version_core_cards.txt +1 -1
- data/lib/card.rb +23 -13
- data/lib/card/auth.rb +6 -6
- data/lib/card/cache.rb +24 -5
- data/lib/card/env.rb +10 -10
- data/lib/card/format.rb +29 -12
- data/lib/card/log.rb +5 -3
- data/lib/card/migration.rb +17 -41
- data/lib/card/name.rb +12 -0
- data/lib/card/reference.rb +11 -12
- data/lib/card/set.rb +59 -6
- data/lib/card/simplecov_helper.rb +6 -1
- data/lib/card/spec_helper.rb +3 -2
- data/lib/card/view_cache.rb +77 -0
- data/lib/cardio.rb +30 -22
- data/mod/01_core/format/html_format.rb +17 -9
- data/mod/01_core/layout/blank.html +1 -1
- data/mod/01_core/layout/default.html +6 -16
- data/mod/01_core/layout/modal.html +9 -0
- data/mod/01_core/layout/noside.html +5 -12
- data/mod/01_core/layout/simple.html +1 -1
- data/mod/01_core/set/all/collection.rb +57 -5
- data/mod/01_core/set/all/content.rb +5 -7
- data/mod/01_core/set/all/name.rb +8 -10
- data/mod/01_core/set/all/permissions.rb +1 -2
- data/mod/01_core/set/all/phases.rb +5 -13
- data/mod/01_core/set/all/references.rb +10 -10
- data/mod/01_core/set/all/rules.rb +2 -2
- data/mod/01_core/set/all/tracked_attributes.rb +5 -3
- data/mod/01_core/set/all/utils.rb +79 -9
- data/mod/01_core/set/all/view_cache.rb +9 -0
- data/mod/01_core/spec/format/html_format_spec.rb +2 -2
- data/mod/01_core/spec/set/all/collection_spec.rb +1 -1
- data/mod/01_history/lib/card/act.rb +3 -1
- data/mod/01_history/lib/card/action.rb +20 -12
- data/mod/01_history/lib/card/change.rb +12 -8
- data/mod/01_history/set/all/actions.rb +2 -2
- data/mod/01_history/set/all/content_history.rb +3 -2
- data/mod/01_history/set/all/history.rb +57 -19
- data/mod/02_basic_types/set/all/rss.rb +5 -6
- data/mod/{05_standard → 02_basic_types}/set/type/html.rb +4 -3
- data/mod/02_basic_types/set/type/plain_text.rb +1 -1
- data/mod/02_basic_types/set/type/pointer.rb +7 -4
- data/mod/02_basic_types/spec/set/type/pointer_spec.rb +21 -17
- data/mod/03_machines/lib/card/machine.rb +33 -31
- data/mod/03_machines/lib/javascript/script_card_menu.js.coffee +2 -10
- data/mod/03_machines/lib/javascript/wagn.js.coffee +10 -10
- data/mod/03_machines/lib/javascript/wagn_mod.js.coffee +87 -40
- data/mod/03_machines/lib/stylesheets/style_cards.scss +26 -28
- data/mod/03_machines/set/right/machine_output.rb +3 -3
- data/mod/03_machines/set/type/coffee_script.rb +6 -6
- data/mod/03_machines/set/type/css.rb +1 -1
- data/mod/03_machines/set/type/java_script.rb +5 -6
- data/mod/03_machines/spec/lib/shared_machine_examples.rb +3 -1
- data/mod/03_machines/spec/set/type/scss_spec.rb +9 -10
- data/mod/04_settings/lib/card/setting.rb +16 -14
- data/mod/04_settings/set/right/structure.rb +6 -0
- data/mod/04_settings/set/self/add_help.rb +1 -1
- data/mod/04_settings/set/self/autoname.rb +1 -1
- data/mod/04_settings/set/self/captcha.rb +1 -1
- data/mod/04_settings/set/self/default.rb +1 -1
- data/mod/04_settings/set/self/help.rb +1 -1
- data/mod/04_settings/set/self/input.rb +1 -1
- data/mod/04_settings/set/self/layout.rb +1 -1
- data/mod/04_settings/set/self/on_create.rb +1 -1
- data/mod/04_settings/set/self/on_delete.rb +1 -1
- data/mod/04_settings/set/self/on_update.rb +1 -1
- data/mod/04_settings/set/self/options.rb +1 -1
- data/mod/04_settings/set/self/options_label.rb +1 -1
- data/mod/04_settings/set/self/script.rb +1 -1
- data/mod/04_settings/set/self/structure.rb +1 -1
- data/mod/04_settings/set/self/style.rb +1 -1
- data/mod/04_settings/set/self/table_of_contents.rb +1 -1
- data/mod/04_settings/set/self/thanks.rb +1 -1
- data/mod/05_email/set/all/follow.rb +3 -21
- data/mod/05_email/set/all/notify.rb +20 -4
- data/mod/05_email/set/right/follow.rb +16 -18
- data/mod/05_email/set/self/follow.rb +1 -1
- data/mod/05_email/spec/set/all/follow_spec.rb +6 -13
- data/mod/05_standard/set/all/attach.rb +23 -9
- data/mod/05_standard/set/all/error.rb +5 -7
- data/mod/05_standard/set/all/event_viz.rb +10 -6
- data/mod/05_standard/set/all/links.rb +37 -13
- data/mod/05_standard/set/all/rich_html/content.rb +46 -18
- data/mod/05_standard/set/all/rich_html/editing.rb +29 -25
- data/mod/05_standard/set/all/rich_html/form.rb +17 -10
- data/mod/05_standard/set/all/rich_html/header.rb +26 -4
- data/mod/05_standard/set/all/rich_html/menu.rb +17 -34
- data/mod/05_standard/set/all/rich_html/modal.rb +50 -12
- data/mod/05_standard/set/all/rich_html/toolbar.rb +178 -186
- data/mod/05_standard/set/all/rich_html/wrapper.rb +44 -21
- data/mod/05_standard/set/rstar/rules.rb +43 -53
- data/mod/05_standard/set/self/all.rb +2 -1
- data/mod/05_standard/set/self/head.rb +2 -2
- data/mod/05_standard/set/self/signin.rb +18 -18
- data/mod/05_standard/set/self/stats.rb +14 -2
- data/mod/05_standard/set/type/search_type.rb +9 -4
- data/mod/05_standard/set/type/session.rb +12 -7
- data/mod/05_standard/set/type/set.rb +135 -18
- data/mod/05_standard/spec/chunk/include_spec.rb +15 -16
- data/mod/05_standard/spec/set/all/account_spec.rb +21 -21
- data/mod/05_standard/spec/set/all/event_viz_spec.rb +7 -7
- data/mod/05_standard/spec/set/all/history_spec.rb +54 -24
- data/mod/05_standard/spec/set/all/rich_html/editing_spec.rb +42 -40
- data/mod/05_standard/spec/set/rstar/rules_spec.rb +1 -1
- data/mod/05_standard/spec/set/type/search_type_spec.rb +9 -1
- data/mod/05_standard/spec/set/type/signup_spec.rb +42 -42
- data/mod/06_bootstrap/lib/stylesheets/bootstrap_cards.scss +6 -0
- data/mod/06_bootstrap/set/all/bootstrap/form.rb +4 -5
- data/mod/06_bootstrap/set/all/bootstrap/helper.rb +145 -0
- data/mod/06_bootstrap/set/all/rich_bootstrap.rb +0 -59
- data/spec/lib/card/action_spec.rb +1 -1
- data/spec/lib/card/log_spec.rb +7 -7
- data/spec/models/card/cardtype_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +31 -6
- data/mod/04_settings/set/self/comment.rb +0 -2
@@ -1,16 +1,9 @@
|
|
1
1
|
<!DOCTYPE HTML>
|
2
2
|
<html>
|
3
|
-
<head>
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
<div id="menu">
|
9
|
-
[[/ | Home]] [[/recent | Recent]] {{*navbox}} {{*account links}}
|
10
|
-
</div>
|
11
|
-
|
12
|
-
<div>
|
13
|
-
{{_main}}
|
14
|
-
</div>
|
3
|
+
<head>{{*head|core}}</head>
|
4
|
+
<body>
|
5
|
+
<header>{{*header|core}}</header>
|
6
|
+
<article>{{_main|open}}</article>
|
7
|
+
<footer>{{*footer|core}}</footer>
|
15
8
|
</body>
|
16
9
|
</html>
|
@@ -48,6 +48,12 @@ def item_type
|
|
48
48
|
nil
|
49
49
|
end
|
50
50
|
|
51
|
+
def item_keys args={}
|
52
|
+
item_names(args).map do |item|
|
53
|
+
item.to_name.key
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
51
57
|
def include_item? item
|
52
58
|
key = if Card === item
|
53
59
|
item.cardname.key
|
@@ -177,15 +183,57 @@ format do
|
|
177
183
|
end
|
178
184
|
|
179
185
|
|
180
|
-
def
|
181
|
-
Card::Content.new(
|
186
|
+
def each_reference_with_args args={}
|
187
|
+
Card::Content.new(_render_raw(args), card).find_chunks( Card::Chunk::Reference ).each do |chunk|
|
182
188
|
yield(chunk.referee_name.to_s, nest_args(args,chunk))
|
183
189
|
end
|
184
190
|
end
|
185
191
|
|
186
|
-
|
192
|
+
|
193
|
+
def each_nested_chunk args={}
|
194
|
+
Card::Content.new(_render_raw(args), card).find_chunks( Card::Chunk::Include).each do |chunk|
|
195
|
+
yield(chunk) if chunk.referee_name # filter commented nests
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
|
200
|
+
def nested_fields args={}
|
201
|
+
result = []
|
202
|
+
each_nested_field(args) do |chunk|
|
203
|
+
result << chunk
|
204
|
+
end
|
205
|
+
result
|
206
|
+
end
|
207
|
+
|
208
|
+
def unique_chunks chunk, processed_set, &block
|
209
|
+
if !processed_set.include? chunk.referee_name.key
|
210
|
+
processed_set << chunk.referee_name.key
|
211
|
+
block.call(chunk)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
def each_nested_field args, &block
|
216
|
+
processed_chunk_keys = ::Set.new([card.key])
|
217
|
+
|
218
|
+
each_nested_chunk(args) do |chunk|
|
219
|
+
# TODO handle structures that are non-virtual
|
220
|
+
if chunk.referee_name.to_name.is_a_field_of? card.name
|
221
|
+
if chunk.referee_card && chunk.referee_card.virtual? && !processed_chunk_keys.include?(chunk.referee_name.key)
|
222
|
+
processed_chunk_keys << chunk.referee_name.key
|
223
|
+
subformat(chunk.referee_card).each_nested_field(args) do |sub_chunk|
|
224
|
+
unique_chunks sub_chunk, processed_chunk_keys, &block
|
225
|
+
end
|
226
|
+
else
|
227
|
+
unique_chunks chunk, processed_chunk_keys, &block
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
end
|
233
|
+
|
234
|
+
def map_references_with_args args={}, &block
|
187
235
|
result = []
|
188
|
-
|
236
|
+
each_reference_with_args args do |name, n_args|
|
189
237
|
result << block.call(name, n_args)
|
190
238
|
end
|
191
239
|
result
|
@@ -210,11 +258,15 @@ end
|
|
210
258
|
|
211
259
|
|
212
260
|
format :html do
|
261
|
+
view :count do |args|
|
262
|
+
card.item_names(args).size
|
263
|
+
end
|
264
|
+
|
213
265
|
view :tabs do |args|
|
214
266
|
tab_buttons = ''
|
215
267
|
tab_panes = ''
|
216
268
|
active_tab = true
|
217
|
-
|
269
|
+
each_reference_with_args(:item=>:content) do |name, nest_args|
|
218
270
|
id = "#{card.cardname.safe_key}-#{name.to_name.safe_key}"
|
219
271
|
url = nest_path name, nest_args
|
220
272
|
tab_name = nest_args[:title] || name
|
@@ -12,7 +12,6 @@ def raw_content
|
|
12
12
|
structure ? template.db_content : content
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
15
|
format do
|
17
16
|
def chunk_list #override to customize by set
|
18
17
|
:default
|
@@ -35,6 +34,10 @@ def clean_html?
|
|
35
34
|
true
|
36
35
|
end
|
37
36
|
|
37
|
+
def history?
|
38
|
+
false
|
39
|
+
end
|
40
|
+
|
38
41
|
def save_content_draft content
|
39
42
|
clear_drafts
|
40
43
|
end
|
@@ -51,14 +54,9 @@ event :save_draft, :before=>:store, :on=>:update, :when=>proc{ |c| Env.params['d
|
|
51
54
|
end
|
52
55
|
|
53
56
|
|
54
|
-
event :set_default_content, :on=>:create, :before=>:approve do
|
57
|
+
event :set_default_content, :on=>:create, :before=>:approve do
|
55
58
|
if !db_content_changed? and template and template.db_content.present?
|
56
59
|
self.db_content = template.db_content
|
57
60
|
end
|
58
61
|
end
|
59
62
|
|
60
|
-
event :detect_conflict, :before=>:approve, :on=>:update do
|
61
|
-
if last_action_id_before_edit and last_action_id_before_edit.to_i != last_action_id and last_action.act.actor_id != Auth.current_id
|
62
|
-
errors.add :conflict, "changes not based on latest revision"
|
63
|
-
end
|
64
|
-
end
|
data/mod/01_core/set/all/name.rb
CHANGED
@@ -8,20 +8,20 @@ def name= newname
|
|
8
8
|
@superleft = @supercard if relparts.size==2 && relparts.first.blank?
|
9
9
|
cardname = @relative_name.to_name.to_absolute_name @supercard.name
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
newkey = cardname.key
|
13
13
|
if key != newkey
|
14
14
|
self.key = newkey
|
15
15
|
reset_patterns_if_rule # reset the old name - should be handled in tracked_attributes!!
|
16
16
|
reset_patterns
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
subcards.each do |subkey, subcard|
|
20
20
|
next unless Card===subcard
|
21
21
|
subcard.name = subkey.to_name.to_absolute cardname
|
22
22
|
end
|
23
|
-
|
24
|
-
|
23
|
+
|
24
|
+
write_attribute :name, cardname.s
|
25
25
|
end
|
26
26
|
|
27
27
|
def cardname
|
@@ -55,7 +55,7 @@ def left *args
|
|
55
55
|
@superleft or begin
|
56
56
|
unless name_changed? and name.to_name.trunk_name.key == name_was.to_name.key
|
57
57
|
# prevent recursion when, eg, renaming A+B to A+B+C
|
58
|
-
Card.fetch cardname.left, *args
|
58
|
+
Card.fetch cardname.left, *args
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
@@ -140,11 +140,11 @@ end
|
|
140
140
|
|
141
141
|
event :validate_unique_codename, :after=>:permit_codename do
|
142
142
|
if codename.present? and errors.empty? and Card.find_by_codename(codename).present?
|
143
|
-
errors.add :codename, "codename #{codename} already in use"
|
143
|
+
errors.add :codename, "codename #{codename} already in use"
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
|
-
event :validate_name, :before=>:approve, :on=>:save do
|
147
|
+
event :validate_name, :before=>:approve, :on=>:save do
|
148
148
|
cdname = name.to_name
|
149
149
|
if name.length > 255
|
150
150
|
errors.add :name, "is too long (255 character maximum)"
|
@@ -168,7 +168,7 @@ event :validate_name, :before=>:approve, :on=>:save do
|
|
168
168
|
condition_sql << " AND cards.id <> ?"
|
169
169
|
condition_params << id
|
170
170
|
end
|
171
|
-
if c = Card.
|
171
|
+
if c = Card.find_by(condition_sql, *condition_params)
|
172
172
|
errors.add :name, "must be unique; '#{c.name}' already exists."
|
173
173
|
end
|
174
174
|
end
|
@@ -233,7 +233,6 @@ end
|
|
233
233
|
|
234
234
|
|
235
235
|
event :cascade_name_changes, :after=>:store, :on=>:update, :changed=>:name do
|
236
|
-
|
237
236
|
Rails.logger.debug "-------------------#{name_was}- CASCADE #{self.name} -------------------------------------"
|
238
237
|
|
239
238
|
self.update_referencers = false if self.update_referencers == 'false' #handle strings from cgi
|
@@ -252,7 +251,6 @@ event :cascade_name_changes, :after=>:store, :on=>:update, :changed=>:name do
|
|
252
251
|
Card::Reference.update_on_rename dep, newname, update_referencers
|
253
252
|
Card.expire newname
|
254
253
|
end
|
255
|
-
|
256
254
|
if update_referencers
|
257
255
|
Auth.as_bot do
|
258
256
|
[self.name_referencers(name_was)+(deps.map &:referencers)].flatten.uniq.each do |card|
|
@@ -76,7 +76,6 @@ def permitted? action
|
|
76
76
|
return true if action != :comment and Auth.always_ok?
|
77
77
|
|
78
78
|
permitted_ids = who_can action
|
79
|
-
|
80
79
|
if action == :comment && Auth.always_ok?
|
81
80
|
# admin can comment if anyone can
|
82
81
|
!permitted_ids.empty?
|
@@ -87,6 +86,7 @@ def permitted? action
|
|
87
86
|
end
|
88
87
|
|
89
88
|
def permit action, verb=nil
|
89
|
+
|
90
90
|
if Card.config.read_only # not called by ok_to_read
|
91
91
|
deny_because "Currently in read-only mode"
|
92
92
|
end
|
@@ -199,7 +199,6 @@ event :check_permissions, :after=>:approve do
|
|
199
199
|
else
|
200
200
|
@action
|
201
201
|
end
|
202
|
-
|
203
202
|
track_permission_errors do
|
204
203
|
ok? task
|
205
204
|
end
|
@@ -69,24 +69,13 @@ def identify_action
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
def store_changes
|
73
|
-
@changed_fields = Card::TRACKED_FIELDS.select{ |f| changed_attributes.member? f }
|
74
|
-
return unless @current_action
|
75
|
-
if @changed_fields.present?
|
76
|
-
@current_action.changed_fields(self, @changed_fields)
|
77
|
-
elsif @current_action and @current_action.changes.empty?
|
78
|
-
@current_action.delete
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
|
83
72
|
|
84
73
|
def store
|
85
74
|
run_callbacks :store do
|
86
75
|
yield #unless @draft
|
87
|
-
store_changes
|
88
76
|
@virtual = false
|
89
77
|
end
|
78
|
+
run_callbacks :stored
|
90
79
|
rescue =>e
|
91
80
|
rescue_event e
|
92
81
|
ensure
|
@@ -96,6 +85,7 @@ end
|
|
96
85
|
|
97
86
|
def extend
|
98
87
|
run_callbacks :extend
|
88
|
+
run_callbacks :subsequent
|
99
89
|
rescue =>e
|
100
90
|
rescue_event e
|
101
91
|
ensure
|
@@ -103,6 +93,8 @@ ensure
|
|
103
93
|
end
|
104
94
|
|
105
95
|
|
96
|
+
|
97
|
+
|
106
98
|
def rescue_event e
|
107
99
|
@action = nil
|
108
100
|
expire_pieces
|
@@ -149,7 +141,7 @@ event :process_subcards, :after=>:approve, :on=>:save do
|
|
149
141
|
opts['subcards'] = extract_subcard_args! opts
|
150
142
|
|
151
143
|
opts[:supercard] = self
|
152
|
-
|
144
|
+
|
153
145
|
subcard = if known_card = Card[ab_name]
|
154
146
|
known_card.refresh.assign_attributes opts
|
155
147
|
known_card
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
def name_referencers link_name=nil
|
3
3
|
link_name = link_name.nil? ? key : link_name.to_name.key
|
4
|
-
Card.
|
4
|
+
Card.joins( :references_to ).where card_references: { referee_key: link_name }
|
5
5
|
end
|
6
6
|
|
7
7
|
def extended_referencers
|
@@ -11,7 +11,7 @@ end
|
|
11
11
|
|
12
12
|
def replace_references old_name, new_name
|
13
13
|
obj_content = Card::Content.new raw_content, card=self
|
14
|
-
|
14
|
+
|
15
15
|
obj_content.find_chunks( Card::Chunk::Reference ).select do |chunk|
|
16
16
|
if old_ref_name = chunk.referee_name and new_ref_name = old_ref_name.replace_part(old_name, new_name)
|
17
17
|
chunk.referee_name = chunk.replace_reference old_name, new_name
|
@@ -31,28 +31,28 @@ def update_references rendered_content = nil, refresh = false
|
|
31
31
|
#Card.update( id, :references_expired=>nil )
|
32
32
|
# or just this and save it elsewhere?
|
33
33
|
#references_expired=nil
|
34
|
-
|
35
|
-
connection.execute("update cards set references_expired=NULL where id=#{id}")
|
34
|
+
|
35
|
+
Card.connection.execute("update cards set references_expired=NULL where id=#{id}")
|
36
36
|
# references_expired = nil
|
37
37
|
expire if refresh
|
38
38
|
|
39
39
|
rendered_content ||= Card::Content.new(raw_content, card=self)
|
40
|
-
|
40
|
+
|
41
41
|
rendered_content.find_chunks(Card::Chunk::Reference).each do |chunk|
|
42
42
|
if referee_name = chunk.referee_name # name is referenced (not true of commented inclusions)
|
43
|
-
referee_id = chunk.referee_id
|
43
|
+
referee_id = chunk.referee_id
|
44
44
|
if id != referee_id # not self reference
|
45
|
-
|
45
|
+
|
46
46
|
#update_references chunk.referee_name if Card::Content === chunk.referee_name
|
47
47
|
# for the above to work we will need to get past delete_all!
|
48
48
|
referee_name.piece_names.each do |name|
|
49
49
|
if name.key != key # don't create self reference
|
50
|
-
|
50
|
+
|
51
51
|
# reference types:
|
52
52
|
# L = link
|
53
53
|
# I = inclusion
|
54
54
|
# P = partial (i.e. the name is part of a compound name that is referenced by a link or inclusion)
|
55
|
-
# The partial type is needed to keep track of references of virtual cards.
|
55
|
+
# The partial type is needed to keep track of references of virtual cards.
|
56
56
|
# For example a link [[A+*self]] won't make it to the reference table because A+*self is virtual and
|
57
57
|
# doesn't have an id but when A's name is changed we have to find and update that link.
|
58
58
|
ref_type = if name == referee_name
|
@@ -70,7 +70,7 @@ def update_references rendered_content = nil, refresh = false
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
@@ -69,12 +69,12 @@ def rule_card_id setting_code, options={}
|
|
69
69
|
nil
|
70
70
|
end
|
71
71
|
|
72
|
-
def related_sets
|
72
|
+
def related_sets with_self = false
|
73
73
|
# refers to sets that users may configure from the current card - NOT to sets to which the current card belongs
|
74
74
|
|
75
75
|
sets = []
|
76
76
|
sets << ["#{name}+*type", Card::TypeSet.label( name) ] if known? && type_id==Card::CardtypeID
|
77
|
-
|
77
|
+
sets << ["#{name}+*self", Card::SelfSet.label( name) ] if with_self
|
78
78
|
sets << ["#{name}+*right", Card::RightSet.label(name) ] if known? && cardname.simple?
|
79
79
|
|
80
80
|
# Card.search(:type=>'Set',:left=>{:right=>name},:right=>'*type plus right',:return=>'name').each do |set_name|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#fixme -this is called by both initialize and update_attributes. really should be optimized for new!
|
2
|
-
def assign_attributes args={}
|
2
|
+
def assign_attributes args={}
|
3
3
|
if args
|
4
4
|
args = args.stringify_keys
|
5
5
|
if newtype = args.delete('type')
|
@@ -8,7 +8,9 @@ def assign_attributes args={}, options={}
|
|
8
8
|
@subcards = extract_subcard_args! args
|
9
9
|
reset_patterns
|
10
10
|
end
|
11
|
-
|
11
|
+
params = ActionController::Parameters.new(args)
|
12
|
+
params.permit!
|
13
|
+
super params
|
12
14
|
end
|
13
15
|
|
14
16
|
def extract_subcard_args! args={}
|
@@ -43,7 +45,7 @@ event :update_ruled_cards, :after=>:store do
|
|
43
45
|
self.class.clear_rule_cache
|
44
46
|
set = rule_set
|
45
47
|
set.reset_set_patterns
|
46
|
-
|
48
|
+
|
47
49
|
if right_id==Card::ReadID and (name_changed? or trash_changed?)
|
48
50
|
self.class.clear_read_rule_cache
|
49
51
|
Card.cache.reset # maybe be more surgical, just Auth.user related
|
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
module ClassMethods
|
3
|
-
|
3
|
+
|
4
4
|
def empty_trash
|
5
5
|
Card.delete_trashed_files
|
6
6
|
Card.where(:trash=>true).delete_all
|
@@ -8,7 +8,7 @@ module ClassMethods
|
|
8
8
|
Card::Reference.repair_missing_referees
|
9
9
|
Card::Reference.delete_missing_referers
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def delete_trashed_files #deletes any file not associated with a real card.
|
13
13
|
dir = Card.paths['files'].existent.first
|
14
14
|
trashed_card_sql = %{ select id from cards where trash is true }
|
@@ -21,7 +21,7 @@ module ClassMethods
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
def merge_list attribs, opts={}
|
26
26
|
unmerged = []
|
27
27
|
attribs.each do |row|
|
@@ -33,7 +33,7 @@ module ClassMethods
|
|
33
33
|
end
|
34
34
|
unmerged.push row unless result == true
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
if unmerged.empty?
|
38
38
|
Rails.logger.info "successfully merged all!"
|
39
39
|
else
|
@@ -47,13 +47,13 @@ module ClassMethods
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
unmerged
|
50
|
-
end
|
51
|
-
|
52
|
-
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
53
|
def merge name, attribs={}, opts={}
|
54
54
|
puts "merging #{ name }"
|
55
55
|
card = fetch name, :new=>{}
|
56
|
-
|
56
|
+
|
57
57
|
if opts[:pristine] && !card.pristine?
|
58
58
|
false
|
59
59
|
else
|
@@ -61,7 +61,7 @@ module ClassMethods
|
|
61
61
|
card.save!
|
62
62
|
end
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
end
|
66
66
|
|
67
67
|
def debug_type
|
@@ -84,3 +84,73 @@ def inspect
|
|
84
84
|
'>'
|
85
85
|
end
|
86
86
|
|
87
|
+
format :html do
|
88
|
+
view :views_by_format do |args|
|
89
|
+
format_views = self.class.ancestors.each_with_object({}) do |format_class, hash|
|
90
|
+
views =
|
91
|
+
format_class.instance_methods.map do |method|
|
92
|
+
if method.to_s.match /^_view_(.+)$/
|
93
|
+
"<li>#{$1}</li>"
|
94
|
+
end
|
95
|
+
end.compact.join "\n"
|
96
|
+
if views.present?
|
97
|
+
format_class.name.match /^Card(::Set)?::(.+?)$/ #::(\w+Format)
|
98
|
+
hash[$2] = views
|
99
|
+
end
|
100
|
+
end
|
101
|
+
accordion_group format_views
|
102
|
+
end
|
103
|
+
|
104
|
+
view :views_by_name do |args|
|
105
|
+
views = methods.map do |method|
|
106
|
+
if method.to_s.match /^_view_(.+)$/
|
107
|
+
$1
|
108
|
+
end
|
109
|
+
end.compact.sort
|
110
|
+
"<ul>
|
111
|
+
#{ wrap_each_with :li, views }
|
112
|
+
</ul>"
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
def accordion_group list, collapse_id=card.cardname.safe_key
|
119
|
+
accordions = ''
|
120
|
+
index = 1
|
121
|
+
list.each_pair do |title, content|
|
122
|
+
accordions << accordion(title, content, "#{collapse_id}-#{index}")
|
123
|
+
index += 1
|
124
|
+
end
|
125
|
+
content_tag :div, accordions.html_safe, :class=>"panel-group", :id=>"accordion-#{collapse_id}", :role=>"tablist", 'aria-multiselectable'=>"true"
|
126
|
+
end
|
127
|
+
|
128
|
+
def accordion title, content, collapse_id=card.cardname.safe_key
|
129
|
+
panel_body =
|
130
|
+
case content
|
131
|
+
when Hash
|
132
|
+
accordion_group accordion(content, collapse_id)
|
133
|
+
when Array
|
134
|
+
content.join "\n"
|
135
|
+
else
|
136
|
+
content
|
137
|
+
end
|
138
|
+
%{
|
139
|
+
<div class="panel panel-default">
|
140
|
+
<div class="panel-heading" role="tab" id="heading-#{collapse_id}">
|
141
|
+
<h4 class="panel-title">
|
142
|
+
<a data-toggle="collapse" data-parent="#accordion-#{collapse_id}" href="##{collapse_id}" aria-expanded="true" aria-controls="#{collapse_id}">
|
143
|
+
#{ title }
|
144
|
+
</a>
|
145
|
+
</h4>
|
146
|
+
</div>
|
147
|
+
<div id="#{collapse_id}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-#{collapse_id}">
|
148
|
+
<div class="panel-body">
|
149
|
+
#{ panel_body }
|
150
|
+
</div>
|
151
|
+
</div>
|
152
|
+
</div>
|
153
|
+
}.html_safe
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|