card 1.16.15 → 1.17.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/config/initializers/recaptcha.rb +21 -4
- data/db/migrate_core_cards/20130823192433_add_style_cards.rb +1 -1
- data/db/migrate_core_cards/20140512155840_add_script_cards.rb +1 -1
- data/db/migrate_core_cards/20140629222005_add_email_cards.rb +2 -2
- data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +1 -1
- data/db/migrate_core_cards/20150528084659_add_session_cardtype.rb +1 -1
- data/db/migrate_core_cards/20150610180019_add_recaptcha_key_and_admin_info_cards.rb +63 -0
- data/db/migrate_core_cards/20150724123438_update_file_and_image_cards.rb +1 -1
- data/db/migrate_core_cards/20150903130006_attachment_upload_cards.rb +1 -1
- data/db/schema.rb +1 -1
- data/db/seed/new/card_actions.yml +602 -394
- data/db/seed/new/card_acts.yml +595 -1
- data/db/seed/new/card_changes.yml +26282 -10262
- data/db/seed/new/card_references.yml +1252 -1084
- data/db/seed/new/cards.yml +1899 -1423
- data/db/seed/test/fixtures/card_actions.yml +1653 -1413
- data/db/seed/test/fixtures/card_acts.yml +1063 -445
- data/db/seed/test/fixtures/card_changes.yml +29674 -13637
- data/db/seed/test/fixtures/card_references.yml +1976 -1815
- data/db/seed/test/fixtures/cards.yml +3194 -2719
- data/lib/card.rb +14 -13
- data/lib/card/auth.rb +10 -6
- data/lib/card/cache.rb +58 -120
- data/lib/card/cache/persistent.rb +50 -0
- data/lib/card/cache/temporary.rb +38 -0
- data/lib/card/chunk.rb +34 -25
- data/lib/card/content.rb +3 -3
- data/lib/card/env.rb +3 -0
- data/lib/card/format.rb +56 -53
- data/lib/card/migration.rb +6 -2
- data/lib/card/name.rb +9 -1
- data/lib/card/query.rb +1 -1
- data/lib/card/reference.rb +17 -11
- data/lib/card/set.rb +1 -1
- data/lib/card/subcards.rb +6 -6
- data/lib/card/view_cache.rb +45 -28
- data/lib/generators/card/migration/templates/card_migration.erb +1 -2
- data/mod/01_core/chunk/include.rb +71 -48
- data/mod/01_core/chunk/link.rb +6 -3
- data/mod/01_core/chunk/query_reference.rb +38 -29
- data/mod/01_core/chunk/reference.rb +23 -24
- data/mod/01_core/set/all/collection.rb +1 -1
- data/mod/01_core/set/all/fetch.rb +39 -12
- data/mod/01_core/set/all/permissions.rb +2 -4
- data/mod/01_core/set/all/references.rb +50 -75
- data/mod/01_core/set/all/rules.rb +19 -18
- data/mod/01_core/set/all/subcards.rb +1 -1
- data/mod/01_core/set/all/templating.rb +31 -88
- data/mod/01_core/set/all/tracked_attributes.rb +7 -14
- data/mod/01_core/set/all/utils.rb +77 -66
- data/mod/01_core/set_pattern/07_type_plus_right.rb +6 -3
- data/mod/01_core/spec/set/all/fetch_spec.rb +148 -96
- data/mod/01_core/spec/set/all/templating_spec.rb +49 -40
- data/mod/01_core/spec/set/all/trash_spec.rb +1 -1
- data/mod/01_history/set/all/actions.rb +1 -1
- data/mod/02_basic_types/set/all/base.rb +13 -7
- data/mod/02_basic_types/set/all/rss.rb +17 -22
- data/mod/02_basic_types/set/type/plain_text.rb +5 -2
- data/mod/02_basic_types/spec/set/all/base_spec.rb +1 -0
- data/mod/02_basic_types/spec/set/all/rss_spec.rb +7 -6
- data/mod/03_machines/lib/javascript/wagn.js.coffee +22 -9
- data/mod/03_machines/set/right/machine_output.rb +1 -1
- data/mod/04_settings/lib/card/setting.rb +45 -31
- data/mod/04_settings/set/right/structure.rb +47 -1
- data/mod/04_settings/set/self/default_html_view.rb +2 -0
- data/mod/04_settings/set/self/follow_fields.rb +2 -0
- data/mod/04_settings/set/self/recent_settings.rb +1 -1
- data/mod/05_standard/file/favicon/image-icon.png +0 -0
- data/mod/05_standard/file/favicon/image-large.png +0 -0
- data/mod/05_standard/file/favicon/image-medium.png +0 -0
- data/mod/05_standard/file/favicon/image-original.png +0 -0
- data/mod/05_standard/file/favicon/image-small.png +0 -0
- data/mod/05_standard/set/all/links.rb +27 -26
- data/mod/05_standard/set/all/rich_html/editing.rb +1 -1
- data/mod/05_standard/set/all/rich_html/toolbar.rb +1 -1
- data/mod/05_standard/set/rstar/rules.rb +20 -325
- data/mod/05_standard/set/rstar/rules_editor.rb +362 -0
- data/mod/05_standard/set/self/admin_info.rb +82 -0
- data/mod/05_standard/set/self/all.rb +16 -10
- data/mod/05_standard/set/self/head.rb +20 -19
- data/mod/05_standard/set/type/signup.rb +0 -1
- data/mod/05_standard/spec/set/all/account_spec.rb +44 -43
- data/mod/05_standard/spec/set/right/account_spec.rb +4 -2
- data/mod/05_standard/spec/set/type/search_type_spec.rb +8 -0
- data/mod/05_standard/spec/set/type/signup_spec.rb +24 -17
- data/mod/06_bootstrap/set/all/bootstrap/helper.rb +1 -1
- data/spec/lib/card/cache_spec.rb +64 -70
- data/spec/lib/card/content_spec.rb +236 -150
- data/spec/lib/card/reference_spec.rb +22 -38
- data/spec/lib/card/subcards_spec.rb +38 -0
- data/spec/lib/card/view_cache_spec.rb +8 -0
- data/spec/spec_helper.rb +1 -1
- data/tmpsets/set/mod001-01_core/all/collection.rb +77 -74
- data/tmpsets/set/mod001-01_core/all/content.rb +14 -16
- data/tmpsets/set/mod001-01_core/all/fetch.rb +137 -110
- data/tmpsets/set/mod001-01_core/all/name.rb +58 -40
- data/tmpsets/set/mod001-01_core/all/pattern.rb +12 -11
- data/tmpsets/set/mod001-01_core/all/permissions.rb +125 -117
- data/tmpsets/set/mod001-01_core/all/phases.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/references.rb +52 -77
- data/tmpsets/set/mod001-01_core/all/rules.rb +47 -53
- data/tmpsets/set/mod001-01_core/all/templating.rb +31 -87
- data/tmpsets/set/mod001-01_core/all/tracked_attributes.rb +12 -21
- data/tmpsets/set/mod001-01_core/all/trash.rb +4 -1
- data/tmpsets/set/mod001-01_core/all/type.rb +23 -21
- data/tmpsets/set/mod001-01_core/all/utils.rb +80 -64
- data/tmpsets/set/mod002-01_history/all/actions.rb +20 -16
- data/tmpsets/set/mod002-01_history/all/history.rb +18 -13
- data/tmpsets/set/mod003-02_basic_types/all/base.rb +37 -10
- data/tmpsets/set/mod003-02_basic_types/all/rss.rb +17 -22
- data/tmpsets/set/mod003-02_basic_types/type/plain_text.rb +5 -2
- data/tmpsets/set/mod003-02_basic_types/type/pointer.rb +51 -39
- data/tmpsets/set/mod004-03_machines/right/machine_output.rb +10 -6
- data/tmpsets/set/mod005-04_settings/abstract/permission.rb +10 -5
- data/tmpsets/set/mod005-04_settings/right/structure.rb +47 -1
- data/tmpsets/set/mod005-04_settings/self/recent_settings.rb +1 -0
- data/tmpsets/set/mod005-04_settings/type/setting.rb +4 -1
- data/tmpsets/set/mod006-05_email/all/follow.rb +45 -54
- data/tmpsets/set/mod006-05_email/all/notify.rb +88 -73
- data/tmpsets/set/mod006-05_email/right/followers.rb +17 -14
- data/tmpsets/set/mod006-05_email/self/follow_defaults.rb +22 -18
- data/tmpsets/set/mod006-05_email/type/email_template.rb +1 -1
- data/tmpsets/set/mod007-05_standard/abstract/attachment.rb +94 -67
- data/tmpsets/set/mod007-05_standard/all/account.rb +18 -20
- data/tmpsets/set/mod007-05_standard/all/comment.rb +51 -29
- data/tmpsets/set/mod007-05_standard/all/error.rb +129 -99
- data/tmpsets/set/mod007-05_standard/all/links.rb +27 -26
- data/tmpsets/set/mod007-05_standard/all/rich_html/content.rb +115 -103
- data/tmpsets/set/mod007-05_standard/all/rich_html/editing.rb +112 -78
- data/tmpsets/set/mod007-05_standard/all/rich_html/form.rb +123 -81
- data/tmpsets/set/mod007-05_standard/all/rich_html/modal.rb +15 -58
- data/tmpsets/set/mod007-05_standard/all/rich_html/toolbar.rb +2 -2
- data/tmpsets/set/mod007-05_standard/right/account.rb +71 -75
- data/tmpsets/set/mod007-05_standard/right/email.rb +16 -13
- data/tmpsets/set/mod007-05_standard/right/password.rb +20 -12
- data/tmpsets/set/mod007-05_standard/right/status.rb +2 -2
- data/tmpsets/set/mod007-05_standard/right/token.rb +49 -2
- data/tmpsets/set/mod007-05_standard/rstar/rules.rb +20 -325
- data/tmpsets/set/mod007-05_standard/self/all.rb +16 -10
- data/tmpsets/set/mod007-05_standard/self/head.rb +76 -62
- data/tmpsets/set/mod007-05_standard/self/search.rb +45 -22
- data/tmpsets/set/mod007-05_standard/self/signin.rb +14 -12
- data/tmpsets/set/mod007-05_standard/type/cardtype.rb +13 -11
- data/tmpsets/set/mod007-05_standard/type/file.rb +1 -1
- data/tmpsets/set/mod007-05_standard/type/search_type.rb +3 -2
- data/tmpsets/set/mod007-05_standard/type/set.rb +20 -16
- data/tmpsets/set/mod007-05_standard/type/signup.rb +19 -25
- data/tmpsets/set/mod007-05_standard/type/user.rb +1 -1
- data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/helper.rb +1 -1
- data/tmpsets/set_pattern/106-type_plus_right.rb +6 -3
- metadata +11 -2
@@ -26,18 +26,22 @@ event :assign_action, after: :assign_act do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
def finalize_action?
|
30
|
+
(history? || respond_to?(:attachment)) && current_action
|
31
|
+
end
|
32
|
+
|
29
33
|
# stores changes in the changes table and assigns them to the current action
|
30
34
|
# removes the action if there are no changes
|
31
|
-
event :finalize_action,
|
32
|
-
after: :stored,
|
33
|
-
when: proc { |c|
|
34
|
-
(c.history? || c.respond_to?(:attachment)) && c.current_action
|
35
|
-
} do
|
35
|
+
event :finalize_action, after: :stored, when: proc { |c| c.finalize_action? } do
|
36
36
|
@changed_fields = Card::TRACKED_FIELDS.select do |f|
|
37
37
|
changed_attributes.member? f
|
38
38
|
end
|
39
39
|
if @changed_fields.present?
|
40
|
-
@changed_fields.each
|
40
|
+
@changed_fields.each do |f|
|
41
|
+
Card::Change.create field: f,
|
42
|
+
value: self[f],
|
43
|
+
card_action_id: @current_action.id
|
44
|
+
end
|
41
45
|
@current_action.update_attributes! card_id: id
|
42
46
|
elsif @current_action.card_changes(true).empty?
|
43
47
|
@current_action.delete
|
@@ -201,8 +205,10 @@ format :html do
|
|
201
205
|
card.current_rev_nr
|
202
206
|
hide_diff = (params['hide_diff'] == ' true') || args[:hide_diff]
|
203
207
|
args[:slot_class] = "revision-#{act.id} history-slot list-group-item"
|
208
|
+
draft = (last_action = act.actions.last) && last_action.draft
|
209
|
+
|
204
210
|
wrap(args) do
|
205
|
-
render_haml card: card, act: act, act_view: act_view,
|
211
|
+
render_haml card: card, act: act, act_view: act_view, draft: draft,
|
206
212
|
current_rev_nr: current_rev_nr, rev_nr: rev_nr,
|
207
213
|
hide_diff: hide_diff do
|
208
214
|
<<-HAML
|
@@ -216,7 +222,7 @@ format :html do
|
|
216
222
|
.time.timeago
|
217
223
|
= time_ago_in_words(act.acted_at)
|
218
224
|
ago
|
219
|
-
- if
|
225
|
+
- if draft
|
220
226
|
|
|
221
227
|
%em.info
|
222
228
|
Autosave
|
@@ -224,14 +230,14 @@ format :html do
|
|
224
230
|
%em.label.label-info
|
225
231
|
Current
|
226
232
|
- elsif act_view == :expanded
|
227
|
-
= rollback_link act.relevant_actions_for(card,
|
233
|
+
= rollback_link act.relevant_actions_for(card, draft)
|
228
234
|
= show_or_hide_changes_link hide_diff, act_id: act.id, act_view: act_view, rev_nr: rev_nr, current_rev_nr: current_rev_nr
|
229
235
|
.toggle
|
230
236
|
= fold_or_unfold_link act_id: act.id, act_view: act_view, rev_nr: rev_nr, current_rev_nr: current_rev_nr
|
231
237
|
|
232
238
|
.action-container{style: ("clear: left;" if act_view == :expanded)}
|
233
239
|
- act.relevant_actions_for(card).each do |action|
|
234
|
-
= send("_render_action_#{
|
240
|
+
= send("_render_action_#{act_view}", action: action )
|
235
241
|
HAML
|
236
242
|
end
|
237
243
|
end
|
@@ -245,7 +251,6 @@ HAML
|
|
245
251
|
render_action :expanded, args
|
246
252
|
end
|
247
253
|
|
248
|
-
|
249
254
|
def render_action action_view, args
|
250
255
|
action = args[:action] || card.last_action
|
251
256
|
hide_diff = Env.params['hide_diff'] == 'true' || args[:hide_diff]
|
@@ -350,8 +355,8 @@ HAML
|
|
350
355
|
toggled_view = args[:act_view] == :expanded ? :act_summary : :act_expanded
|
351
356
|
arrow_dir = args[:act_view] == :expanded ? 'arrow-down' : 'arrow-right'
|
352
357
|
link_to '', args.merge(view: toggled_view),
|
353
|
-
|
354
|
-
|
358
|
+
class: "slotter revision-#{args[:act_id]} #{arrow_dir}",
|
359
|
+
remote: true
|
355
360
|
end
|
356
361
|
|
357
362
|
def show_or_hide_changes_link hide_diff, args
|
@@ -9,14 +9,41 @@ format do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
# NAME VIEWS
|
12
|
+
view :name, closed: true, perms: :none do |args|
|
13
|
+
return card.name unless args[:variant]
|
14
|
+
args[:variant].split(/[\s,]+/).inject(card.name) do |name, variant|
|
15
|
+
case variant.to_sym
|
16
|
+
when :capitalized
|
17
|
+
name.capitalize
|
18
|
+
when :singular
|
19
|
+
name.singularize
|
20
|
+
when :plural
|
21
|
+
name.pluralize
|
22
|
+
when :title
|
23
|
+
name.titleize
|
24
|
+
else
|
25
|
+
if ::Set.new([
|
26
|
+
:downcase, :upcase, :swapcase, :reverse, :succ
|
27
|
+
]).include?(variant.to_sym)
|
28
|
+
name.send variant
|
29
|
+
else
|
30
|
+
name
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
12
35
|
|
13
|
-
|
14
|
-
view(:
|
15
|
-
view(:
|
16
|
-
|
17
|
-
view
|
18
|
-
|
19
|
-
|
36
|
+
view(:key, closed: true, perms: :none) { card.key }
|
37
|
+
view(:linkname, closed: true, perms: :none) { card.cardname.url_key }
|
38
|
+
view(:url, closed: true, perms: :none) { card_url _render_linkname }
|
39
|
+
|
40
|
+
view :title, closed: true, perms: :none do |args|
|
41
|
+
args[:title] || card.name
|
42
|
+
end
|
43
|
+
|
44
|
+
view :url_link, closed: true, perms: :none do
|
45
|
+
web_link card_url(_render_linkname)
|
46
|
+
end
|
20
47
|
|
21
48
|
view :link, closed: true, perms: :none do |args|
|
22
49
|
card_link(
|
@@ -95,9 +122,9 @@ format do
|
|
95
122
|
# FIXME: - relativity should be handled in smartname
|
96
123
|
return '' unless args[:inc_name]
|
97
124
|
name = args[:inc_name].to_name
|
98
|
-
|
125
|
+
stripped = name.stripped
|
99
126
|
|
100
|
-
if name.relative? && !
|
127
|
+
if name.relative? && !stripped.to_name.starts_with_joint?
|
101
128
|
# not a simple relative name; just return the original syntax
|
102
129
|
"{{#{args[:inc_syntax]}}}"
|
103
130
|
else
|
@@ -108,7 +135,7 @@ format do
|
|
108
135
|
when type = on_type_set
|
109
136
|
"#{type}#{name}+#{Card[:type_plus_right].name}" # *type plus right
|
110
137
|
else
|
111
|
-
"#{
|
138
|
+
"#{stripped.gsub(/^\+/, '')}+#{Card[:right].name}" # *right
|
112
139
|
end
|
113
140
|
subformat(Card.fetch set_name).render_template_link args
|
114
141
|
end
|
@@ -1,10 +1,7 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
class Card; module Set; module All; module Rss; extend Card::Set
|
3
3
|
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/02_basic_types/set/all/rss.rb ~~~~~~~~~~~
|
4
|
-
|
5
|
-
|
6
4
|
format :rss do
|
7
|
-
|
8
5
|
attr_accessor :xml
|
9
6
|
|
10
7
|
def initialize card, args
|
@@ -18,10 +15,10 @@ format :rss do
|
|
18
15
|
end
|
19
16
|
|
20
17
|
# FIXME: integrate this with common XML features when it is added
|
21
|
-
view :feed do
|
18
|
+
view :feed do
|
22
19
|
begin
|
23
|
-
@xml.instruct! :xml, version:
|
24
|
-
@xml.rss version:
|
20
|
+
@xml.instruct! :xml, version: '1.0'
|
21
|
+
@xml.rss version: '2.0' do
|
25
22
|
@xml.channel do
|
26
23
|
@xml.title render_feed_title
|
27
24
|
@xml.description render_feed_description
|
@@ -38,43 +35,41 @@ format :rss do
|
|
38
35
|
[card]
|
39
36
|
end
|
40
37
|
|
41
|
-
view :feed_body do |
|
38
|
+
view :feed_body do |_args|
|
42
39
|
render_feed_item_list
|
43
40
|
end
|
44
41
|
|
45
42
|
view :feed_item_list do |args|
|
46
43
|
raw_feed_items(args).each do |item|
|
47
44
|
@xml.item do
|
48
|
-
|
45
|
+
# FIXME: yuck.
|
46
|
+
subformat(item).render_feed_item view_changes: (card.id == RecentID)
|
49
47
|
end
|
50
48
|
end
|
51
49
|
end
|
52
50
|
|
53
|
-
|
54
|
-
|
55
|
-
Card.setting(:title) + " : " + card.name.gsub(/^\*/,'')
|
51
|
+
view :feed_title do
|
52
|
+
Card.global_setting(:title) + ' : ' + card.name.gsub(/^\*/,'')
|
56
53
|
end
|
57
54
|
|
58
55
|
view :feed_item do |args|
|
59
56
|
@xml.title card.name
|
60
57
|
add_name_context
|
61
58
|
@xml.description render((args[:view_changes] ? :change : :open_content))
|
62
|
-
@xml.pubDate card.revised_at.to_s(:rfc822) #updated_at fails on virtual
|
59
|
+
@xml.pubDate card.revised_at.to_s(:rfc822) # updated_at fails on virtual
|
60
|
+
# cards, because not all to_s's take args (just actual dates)
|
63
61
|
@xml.link render_url
|
64
62
|
@xml.guid render_url
|
65
63
|
end
|
66
64
|
|
65
|
+
view :feed_description do '' end
|
66
|
+
view :comment_box do '' end
|
67
|
+
view :menu do '' end
|
67
68
|
|
68
|
-
view :
|
69
|
-
view :
|
70
|
-
view :
|
71
|
-
|
72
|
-
|
73
|
-
view :open, { view: :titled, mod: All::Base::Format }
|
74
|
-
view :content, { view: :core, mod: All::Base::Format }
|
75
|
-
view :open_content, { view: :core, mod: All::Base::Format }
|
76
|
-
view :closed, { view: :link, mod: All::Base::Format }
|
77
|
-
|
69
|
+
view :open, view: :titled, mod: All::Base::Format
|
70
|
+
view :content, view: :core, mod: All::Base::Format
|
71
|
+
view :open_content, view: :core, mod: All::Base::Format
|
72
|
+
view :closed, view: :link, mod: All::Base::Format
|
78
73
|
end
|
79
74
|
|
80
75
|
|
@@ -4,11 +4,14 @@ class Card; module Set; module Type; module PlainText; extend Card::Set
|
|
4
4
|
format :html do
|
5
5
|
|
6
6
|
view :editor do |args|
|
7
|
-
text_area :content,
|
7
|
+
text_area :content,
|
8
|
+
rows: 5,
|
9
|
+
class: 'card-content',
|
10
|
+
'data-card-type-code' => card.type_code
|
8
11
|
end
|
9
12
|
|
10
13
|
view :core do |args|
|
11
|
-
process_content_object(
|
14
|
+
process_content_object(CGI.escapeHTML _render_raw)
|
12
15
|
end
|
13
16
|
end
|
14
17
|
|
@@ -2,9 +2,12 @@
|
|
2
2
|
class Card; module Set; module Type; module Pointer; extend Card::Set
|
3
3
|
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/02_basic_types/set/type/pointer.rb ~~~~~~~~~~~
|
4
4
|
|
5
|
+
|
5
6
|
event :add_and_drop_items, before: :approve, on: :save do
|
6
|
-
|
7
|
-
|
7
|
+
adds = Env.params['add_item']
|
8
|
+
drops = Env.params['drop_item']
|
9
|
+
Array.wrap(adds).each { |i| add_item i } if adds
|
10
|
+
Array.wrap(drops).each { |i| drop_item i } if drops
|
8
11
|
end
|
9
12
|
|
10
13
|
event :insert_item_event, before: :approve, on: :save, when: proc {|c| Env.params['insert_item']} do
|
@@ -12,6 +15,20 @@ event :insert_item_event, before: :approve, on: :save, when: proc {|c| Env.param
|
|
12
15
|
self.insert_item index.to_i, Env.params['insert_item']
|
13
16
|
end
|
14
17
|
|
18
|
+
phase_method :changed_item_names do
|
19
|
+
dropped_item_names + added_item_names
|
20
|
+
end
|
21
|
+
|
22
|
+
phase_method :dropped_item_names do
|
23
|
+
old_items = item_names content: db_content_was
|
24
|
+
old_items - item_names
|
25
|
+
end
|
26
|
+
|
27
|
+
phase_method :added_item_names do
|
28
|
+
old_items = item_names content: db_content_was
|
29
|
+
item_names - old_items
|
30
|
+
end
|
31
|
+
|
15
32
|
format do
|
16
33
|
def item_links args={}
|
17
34
|
card.item_cards(args).map do |item_card|
|
@@ -290,37 +307,38 @@ def item_type
|
|
290
307
|
end
|
291
308
|
|
292
309
|
def items= array
|
293
|
-
self.content=''
|
310
|
+
self.content = ''
|
294
311
|
array.each { |i| self << i }
|
295
312
|
save!
|
296
313
|
end
|
297
314
|
|
298
315
|
def << item
|
299
|
-
newname =
|
300
|
-
|
301
|
-
when
|
302
|
-
|
316
|
+
newname =
|
317
|
+
case item
|
318
|
+
when Card then item.name
|
319
|
+
when Integer then (c = Card[item]) && c.name
|
320
|
+
else item
|
303
321
|
end
|
304
322
|
add_item newname
|
305
323
|
end
|
306
324
|
|
307
325
|
def add_item name
|
308
|
-
|
309
|
-
|
310
|
-
end
|
326
|
+
return if include_item? name
|
327
|
+
self.content = "[[#{(item_names << name).reject(&:blank?) * "]]\n[["}]]"
|
311
328
|
end
|
329
|
+
|
312
330
|
def add_item! name
|
313
331
|
add_item name
|
314
332
|
save!
|
315
333
|
end
|
316
334
|
|
317
335
|
def drop_item name
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
end
|
336
|
+
return unless include_item? name
|
337
|
+
key = name.to_name.key
|
338
|
+
new_names = item_names.reject { |n| n.to_name.key == key }
|
339
|
+
self.content = new_names.empty? ? '' : "[[#{new_names * "]]\n[["}]]"
|
323
340
|
end
|
341
|
+
|
324
342
|
def drop_item! name
|
325
343
|
drop_item name
|
326
344
|
save!
|
@@ -328,45 +346,39 @@ end
|
|
328
346
|
|
329
347
|
def insert_item index, name
|
330
348
|
new_names = item_names
|
331
|
-
new_names.delete
|
332
|
-
new_names.insert
|
333
|
-
self.content =
|
349
|
+
new_names.delete name
|
350
|
+
new_names.insert index, name
|
351
|
+
self.content = new_names.map { |new_name| "[[#{new_name}]]" }.join "\n"
|
334
352
|
end
|
353
|
+
|
335
354
|
def insert_item! index, name
|
336
355
|
insert_item index, name
|
337
356
|
save!
|
338
357
|
end
|
339
358
|
|
340
|
-
|
341
359
|
def options_rule_card
|
342
|
-
|
360
|
+
rule_card :options
|
343
361
|
end
|
344
362
|
|
345
363
|
def option_names
|
346
|
-
|
347
|
-
oc
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
364
|
+
result_names =
|
365
|
+
if (oc = options_rule_card)
|
366
|
+
oc.item_names default_limit: 50, context: name
|
367
|
+
else
|
368
|
+
Card.search({ sort: 'name', limit: 50, return: :name },
|
369
|
+
"option names for pointer: #{name}")
|
370
|
+
end
|
371
|
+
if (selected_options = item_names)
|
372
|
+
result_names += selected_options
|
373
|
+
result_names.uniq!
|
353
374
|
end
|
354
|
-
|
375
|
+
result_names
|
355
376
|
end
|
356
377
|
|
357
378
|
def option_cards
|
358
|
-
|
359
|
-
|
360
|
-
else
|
361
|
-
Card.search sort: 'alpha', limit: 50
|
362
|
-
end
|
363
|
-
if selected_options = item_names
|
364
|
-
selected_options.each do |item|
|
365
|
-
result_cards.push Card.fetch(item,new: {})
|
366
|
-
end
|
367
|
-
result_cards.uniq!
|
379
|
+
option_names.map do |name|
|
380
|
+
Card.fetch name, new: {}
|
368
381
|
end
|
369
|
-
result_cards
|
370
382
|
end
|
371
383
|
|
372
384
|
|
@@ -12,7 +12,7 @@ end
|
|
12
12
|
format do
|
13
13
|
view :not_found do |args|
|
14
14
|
if update_machine_output_live?
|
15
|
-
Card::Cache.
|
15
|
+
Card::Cache.reset_all # FIXME: wow, this is overkill, no?
|
16
16
|
root.error_status = 302
|
17
17
|
card.left.update_machine_output
|
18
18
|
card_path card.left.machine_output_url
|
@@ -22,12 +22,16 @@ format do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def update_machine_output_live?
|
25
|
-
|
26
|
-
card.left.
|
27
|
-
|
28
|
-
|
25
|
+
case
|
26
|
+
when !card.left.is_a?(Machine) then false # must be a machine
|
27
|
+
when card.left.locked? then false # machine must not be running
|
28
|
+
when card.new_card? then true # always update if new
|
29
|
+
else
|
30
|
+
# must want current output (won't re-output old stuff)
|
31
|
+
(selected_id = card.selected_action_id) &&
|
32
|
+
selected_id == card.last_action_id
|
33
|
+
end
|
29
34
|
end
|
30
|
-
|
31
35
|
end
|
32
36
|
|
33
37
|
|
@@ -6,13 +6,16 @@ def standardize_items
|
|
6
6
|
end
|
7
7
|
|
8
8
|
format :html do
|
9
|
-
|
10
|
-
|
11
|
-
%{<div class="pointer-list">#{ render_pointer_items args }</div>}
|
9
|
+
view :pointer_core do |args| # view: :core, mod: Type::Pointer::HtmlFormat
|
10
|
+
%{<div class="pointer-list">#{render_pointer_items args}</div>}
|
12
11
|
end
|
13
12
|
|
14
13
|
view :core do |args|
|
15
|
-
card.content=='_left'
|
14
|
+
if card.content == '_left'
|
15
|
+
core_inherit_content args
|
16
|
+
else
|
17
|
+
render :pointer_core, args
|
18
|
+
end
|
16
19
|
end
|
17
20
|
|
18
21
|
view :closed_content do |args|
|
@@ -25,7 +28,9 @@ format :html do
|
|
25
28
|
set_card = Card.fetch(set_name)
|
26
29
|
not_set = set_card && set_card.type_id != SetID
|
27
30
|
|
28
|
-
group_options = Auth.as_bot
|
31
|
+
group_options = Auth.as_bot do
|
32
|
+
Card.search({ type_id: RoleID, sort: 'name' }, 'roles by name')
|
33
|
+
end
|
29
34
|
|
30
35
|
inheritable = not_set ? false : set_card.inheritable?
|
31
36
|
inheriting = inheritable && card.content=='_left'
|