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
@@ -24,7 +24,7 @@ def assign_attributes args={}
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def assign_set_specific_attributes
|
27
|
-
return unless @set_specific
|
27
|
+
return unless @set_specific.present?
|
28
28
|
@set_specific.each_pair do |name, value|
|
29
29
|
send "#{name}=", value
|
30
30
|
end
|
@@ -68,7 +68,7 @@ event :set_content, before: :store, on: :save do
|
|
68
68
|
self.db_content = Card::Content.clean!(db_content) if clean_html?
|
69
69
|
@selected_action_id = @selected_content = nil
|
70
70
|
clear_drafts
|
71
|
-
reset_patterns_if_rule
|
71
|
+
reset_patterns_if_rule true
|
72
72
|
end
|
73
73
|
|
74
74
|
# FIXME: the following don't really belong here, but they have to come after
|
@@ -104,11 +104,6 @@ event :update_ruled_cards, after: :store do
|
|
104
104
|
item_card.update_read_rule
|
105
105
|
end
|
106
106
|
end
|
107
|
-
# elsif rule_class_index = rule_class_ids.index( 0 )
|
108
|
-
# in_set[trunk.key] = true
|
109
|
-
# #warn "self rule update: #{trunk.inspect}, #{rule_class_index},
|
110
|
-
# #{cur_index}"
|
111
|
-
# trunk.update_read_rule if cur_index > rule_class_index
|
112
107
|
else warn "No current rule index #{class_id}, " \
|
113
108
|
"#{rule_class_ids.inspect}"
|
114
109
|
end
|
@@ -119,10 +114,10 @@ event :update_ruled_cards, after: :store do
|
|
119
114
|
|
120
115
|
# then find all cards with me as read_rule_id that were not just updated
|
121
116
|
# and regenerate their read_rules
|
122
|
-
if !
|
123
|
-
Card.
|
124
|
-
in_set[
|
125
|
-
end
|
117
|
+
if !new_card?
|
118
|
+
Card.search(read_rule_id: self.id) do |card|
|
119
|
+
card.update_read_rule unless in_set[card.key]
|
120
|
+
end
|
126
121
|
end
|
127
122
|
end
|
128
123
|
end
|
@@ -133,27 +128,23 @@ event :process_read_rule_update_queue, after: :store do
|
|
133
128
|
@read_rule_update_queue = []
|
134
129
|
end
|
135
130
|
|
136
|
-
# set_callback :store, :after, :process_read_rule_update_queue, prepend: true
|
137
|
-
|
138
131
|
event :expire_related, after: :store do
|
139
132
|
subcards.keys.each do |key|
|
140
|
-
Card.cache.
|
133
|
+
Card.cache.soft.delete key
|
141
134
|
end
|
142
135
|
expire true
|
143
136
|
|
144
|
-
if
|
137
|
+
if is_structure?
|
145
138
|
structuree_names.each do |name|
|
146
139
|
Card.expire name, true
|
147
140
|
end
|
148
141
|
end
|
142
|
+
end
|
149
143
|
|
150
|
-
|
151
|
-
#
|
152
|
-
|
153
|
-
dependents.each { |c| c.expire(true) }
|
154
|
-
# self.referencers.each { |c| c.expire(true) }
|
144
|
+
event :expire_related_names, before: :expire_related, changed: :name do
|
145
|
+
# FIXME: look for opportunities to avoid instantiating the following
|
146
|
+
descendants.each { |c| c.expire(true) }
|
155
147
|
name_referencers.each { |c| c.expire(true) }
|
156
|
-
# FIXME: this will need review when we do the new defaults/templating system
|
157
148
|
end
|
158
149
|
|
159
150
|
|
@@ -31,7 +31,10 @@ event :validate_delete, before: :approve, on: :delete do
|
|
31
31
|
errors.add :delete, "#{name} is is a system card. (#{codename})"
|
32
32
|
end
|
33
33
|
|
34
|
-
undeletable_all_rules_tags =
|
34
|
+
undeletable_all_rules_tags =
|
35
|
+
%w{ default style layout create read update delete }
|
36
|
+
# FIXME: HACK! should be configured in the rule
|
37
|
+
|
35
38
|
if junction? && (l = left) && l.codename == 'all' &&
|
36
39
|
undeletable_all_rules_tags.member?(right.codename)
|
37
40
|
errors.add :delete, "#{name} is an indestructible rule"
|
@@ -4,23 +4,27 @@ class Card; module Set; module All; module Type; extend Card::Set
|
|
4
4
|
|
5
5
|
module ClassMethods
|
6
6
|
def default_type_id
|
7
|
-
@@default_type_id ||= Card[:all].fetch(
|
7
|
+
@@default_type_id ||= Card[:all].fetch(trait: :default).type_id
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
def type_card
|
12
12
|
return if type_id.nil?
|
13
|
-
Card.
|
13
|
+
Card.quick_fetch type_id.to_i
|
14
14
|
end
|
15
15
|
|
16
16
|
def type_code
|
17
|
-
Card::Codename[
|
17
|
+
Card::Codename[type_id.to_i]
|
18
18
|
end
|
19
19
|
|
20
20
|
def type_name
|
21
21
|
type_card.try :name
|
22
22
|
end
|
23
23
|
|
24
|
+
def type_name_or_default
|
25
|
+
type_card.try(:name) || Card.quick_fetch(Card.default_type_id).name
|
26
|
+
end
|
27
|
+
|
24
28
|
def type_cardname
|
25
29
|
type_card.try :cardname
|
26
30
|
end
|
@@ -30,42 +34,40 @@ def type= type_name
|
|
30
34
|
end
|
31
35
|
|
32
36
|
def get_type_id_from_structure
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
+
return unless name && (t = template)
|
38
|
+
reset_patterns # still necessary even with new template handling?
|
39
|
+
t.type_id
|
37
40
|
end
|
38
41
|
|
39
42
|
event :validate_type_change, before: :approve, on: :update, changed: :type_id do
|
40
|
-
if c = dup
|
41
|
-
errors.add :type, "of #{ name } can't be changed; errors creating new
|
43
|
+
if (c = dup) && c.action == :create && !c.valid?
|
44
|
+
errors.add :type, "of #{ name } can't be changed; errors creating new " \
|
45
|
+
"#{ type_id }: #{ c.errors.full_messages * ', ' }"
|
42
46
|
end
|
43
47
|
end
|
44
48
|
|
45
49
|
event :validate_type, before: :approve, changed: :type_id do
|
46
50
|
if !type_name
|
47
|
-
errors.add :type,
|
51
|
+
errors.add :type, 'No such type'
|
48
52
|
end
|
49
53
|
|
50
|
-
if rt = structure
|
51
|
-
errors.add :type, "can't be changed because #{name} is hard templated
|
54
|
+
if (rt = structure) && rt.assigns_type? && type_id != rt.type_id
|
55
|
+
errors.add :type, "can't be changed because #{name} is hard templated " \
|
56
|
+
"to #{rt.type_name}"
|
52
57
|
end
|
53
58
|
end
|
54
59
|
|
55
60
|
event :reset_type_specific_fields, after: :store do
|
61
|
+
wql = { left: { left_id: type_id },
|
62
|
+
right: { codename: 'type_plus_right' }
|
63
|
+
}
|
64
|
+
wql_comment = "sets with a type_plus_right rule for #{name}"
|
65
|
+
|
56
66
|
Auth.as_bot do
|
57
|
-
Card.search
|
58
|
-
set_card.reset_set_patterns
|
59
|
-
end
|
67
|
+
Card.search(wql, wql_comment).each &:reset_set_patterns
|
60
68
|
end
|
61
69
|
end
|
62
70
|
|
63
|
-
# Card.search left_plus: [ type_name, right_plus: {codename: 'type_plus_right'}] do |right_anchor|
|
64
|
-
# Card["#{lef}"]
|
65
|
-
# set_card.reset_set_patterns
|
66
|
-
# end
|
67
|
-
|
68
|
-
|
69
71
|
|
70
72
|
# ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/type.rb ~~~~~~~~~~~
|
71
73
|
end;end;end;end;
|
@@ -3,7 +3,6 @@ class Card; module Set; module All; module Utils; extend Card::Set
|
|
3
3
|
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/utils.rb ~~~~~~~~~~~
|
4
4
|
|
5
5
|
module ClassMethods
|
6
|
-
|
7
6
|
def empty_trash
|
8
7
|
Card.delete_trashed_files
|
9
8
|
Card.where(trash: true).delete_all
|
@@ -13,25 +12,39 @@ module ClassMethods
|
|
13
12
|
Card.delete_tmp_files_of_cached_uploads
|
14
13
|
end
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
file_ids = Dir.entries( dir )[2..-1].map( &:to_i )
|
15
|
+
# deletes any file not associated with a real card.
|
16
|
+
def delete_trashed_files
|
17
|
+
trashed_card_ids = all_trashed_card_ids
|
18
|
+
file_ids = all_file_ids
|
21
19
|
file_ids.each do |file_id|
|
22
20
|
if trashed_card_ids.member?(file_id)
|
23
|
-
|
21
|
+
if Card.exists?(file_id) # double check!
|
22
|
+
fail Card::Error, 'Narrowly averted deleting current file'
|
23
|
+
end
|
24
24
|
FileUtils.rm_rf "#{dir}/#{file_id}", secure: true
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
def all_file_ids
|
30
|
+
dir = Card.paths['files'].existent.first
|
31
|
+
Dir.entries(dir)[2..-1].map(&:to_i)
|
32
|
+
end
|
33
|
+
|
34
|
+
def all_trashed_card_ids
|
35
|
+
trashed_card_sql = %{ select id from cards where trash is true }
|
36
|
+
sql_results = Card.connection.select_all(trashed_card_sql)
|
37
|
+
sql_results.map(&:values).flatten.map(&:to_i)
|
38
|
+
end
|
39
|
+
|
29
40
|
def delete_tmp_files_of_cached_uploads
|
30
41
|
actions = Card::Action.find_by_sql "SELECT * FROM card_actions
|
31
42
|
INNER JOIN cards ON card_actions.card_id = cards.id
|
32
|
-
WHERE cards.type_id IN (#{Card::FileID}, #{Card::ImageID})
|
43
|
+
WHERE cards.type_id IN (#{Card::FileID}, #{Card::ImageID})
|
44
|
+
AND card_actions.draft = true"
|
33
45
|
actions.each do |action|
|
34
|
-
if older_than_five_days?
|
46
|
+
if older_than_five_days?(action.created_at) && (card = action.card)
|
47
|
+
# we don't want to delete uploads in progress
|
35
48
|
card.delete_files_for_action action
|
36
49
|
end
|
37
50
|
end
|
@@ -42,31 +55,31 @@ module ClassMethods
|
|
42
55
|
attribs.each do |row|
|
43
56
|
result = begin
|
44
57
|
merge row['name'], row, opts
|
45
|
-
# rescue => e
|
46
|
-
# Rails.logger.info "merge_list problem: #{ e.message }"
|
47
|
-
# false
|
48
58
|
end
|
49
59
|
unmerged.push row unless result == true
|
50
60
|
end
|
51
61
|
|
52
62
|
if unmerged.empty?
|
53
|
-
Rails.logger.info
|
63
|
+
Rails.logger.info 'successfully merged all!'
|
54
64
|
else
|
55
65
|
unmerged_json = JSON.pretty_generate unmerged
|
56
|
-
|
57
|
-
::File.open output_file, 'w' do |f|
|
58
|
-
f.write unmerged_json
|
59
|
-
end
|
60
|
-
else
|
61
|
-
Rails.logger.info "failed to merge:\n\n#{ unmerged_json }"
|
62
|
-
end
|
66
|
+
report_unmerged_json unmerged_json, opts[:output_file]
|
63
67
|
end
|
64
68
|
unmerged
|
65
69
|
end
|
66
70
|
|
71
|
+
def report_unmerged_json unmerged_json, output_file
|
72
|
+
if output_file
|
73
|
+
::File.open output_file, 'w' do |f|
|
74
|
+
f.write unmerged_json
|
75
|
+
end
|
76
|
+
else
|
77
|
+
Rails.logger.info "failed to merge:\n\n#{unmerged_json}"
|
78
|
+
end
|
79
|
+
end
|
67
80
|
|
68
81
|
def merge name, attribs={}, opts={}
|
69
|
-
puts "merging #{
|
82
|
+
puts "merging #{name}"
|
70
83
|
card = fetch name, new: {}
|
71
84
|
|
72
85
|
if opts[:pristine] && !card.pristine?
|
@@ -77,59 +90,60 @@ module ClassMethods
|
|
77
90
|
end
|
78
91
|
end
|
79
92
|
|
93
|
+
def older_than_five_days? time
|
94
|
+
Time.now - time > 432000
|
95
|
+
end
|
80
96
|
end
|
81
97
|
|
82
98
|
def debug_type
|
83
|
-
"#{type_code||'no code'}:#{type_id}"
|
99
|
+
"#{type_code || 'no code'}:#{type_id}"
|
84
100
|
end
|
85
101
|
|
86
102
|
def to_s
|
87
|
-
"#<#{self.class.name}[#{debug_type}]#{
|
103
|
+
"#<#{self.class.name}[#{debug_type}]#{attributes['name']}>"
|
88
104
|
end
|
89
105
|
|
90
106
|
def inspect
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
'
|
107
|
+
tags = []
|
108
|
+
tags << 'trash' if trash
|
109
|
+
tags << 'new' if new_card?
|
110
|
+
tags << 'frozen' if frozen?
|
111
|
+
tags << 'readonly' if readonly?
|
112
|
+
tags << 'virtual' if @virtual
|
113
|
+
tags << 'set_mods_loaded' if @set_mods_loaded
|
114
|
+
|
115
|
+
error_messages = errors.any? ? "<E*#{errors.full_messages * ', '}*>" : ''
|
116
|
+
|
117
|
+
"#<Card##{id}[#{debug_type}](#{name})#{error_messages}{#{tags * ','}}"
|
100
118
|
end
|
101
119
|
|
102
120
|
format :html do
|
103
|
-
view :views_by_format do
|
104
|
-
format_views =
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
121
|
+
view :views_by_format do
|
122
|
+
format_views =
|
123
|
+
self.class.ancestors.each_with_object({}) do |format_class, hash|
|
124
|
+
views =
|
125
|
+
format_class.instance_methods.map do |method|
|
126
|
+
if method.to_s.match(/^_view_(.+)$/)
|
127
|
+
"<li>#{$1}</li>"
|
128
|
+
end
|
129
|
+
end.compact.join "\n"
|
130
|
+
if views.present?
|
131
|
+
format_class.name.match(/^Card(::Set)?::(.+?)$/) #::(\w+Format)
|
132
|
+
hash[$2] = views
|
133
|
+
end
|
114
134
|
end
|
115
|
-
end
|
116
135
|
accordion_group format_views
|
117
136
|
end
|
118
137
|
|
119
|
-
view :views_by_name do
|
138
|
+
view :views_by_name do
|
120
139
|
views = methods.map do |method|
|
121
|
-
if method.to_s.match
|
140
|
+
if method.to_s.match(/^_view_(.+)$/)
|
122
141
|
$1
|
123
142
|
end
|
124
143
|
end.compact.sort
|
125
|
-
"<ul>
|
126
|
-
#{ wrap_each_with :li, views }
|
127
|
-
</ul>"
|
144
|
+
"<ul>#{wrap_each_with :li, views}</ul>"
|
128
145
|
end
|
129
146
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
147
|
def accordion_group list, collapse_id=card.cardname.safe_key
|
134
148
|
accordions = ''
|
135
149
|
index = 1
|
@@ -137,31 +151,34 @@ format :html do
|
|
137
151
|
accordions << accordion(title, content, "#{collapse_id}-#{index}")
|
138
152
|
index += 1
|
139
153
|
end
|
140
|
-
content_tag :div, accordions.html_safe, class:
|
154
|
+
content_tag :div, accordions.html_safe, class: 'panel-group',
|
155
|
+
id: "accordion-#{collapse_id}",
|
156
|
+
role: 'tablist',
|
157
|
+
'aria-multiselectable' => 'true'
|
141
158
|
end
|
142
159
|
|
143
160
|
def accordion title, content, collapse_id=card.cardname.safe_key
|
144
161
|
panel_body =
|
145
162
|
case content
|
146
|
-
when Hash
|
147
|
-
|
148
|
-
|
149
|
-
content.join "\n"
|
150
|
-
else
|
151
|
-
content
|
163
|
+
when Hash then accordion_group accordion(content, collapse_id)
|
164
|
+
when Array then content.join "\n"
|
165
|
+
else content
|
152
166
|
end
|
153
167
|
%{
|
154
168
|
<div class="panel panel-default">
|
155
169
|
<div class="panel-heading" role="tab" id="heading-#{collapse_id}">
|
156
170
|
<h4 class="panel-title">
|
157
|
-
<a data-toggle="collapse" data-parent="#accordion-#{collapse_id}"
|
158
|
-
|
171
|
+
<a data-toggle="collapse" data-parent="#accordion-#{collapse_id}" \
|
172
|
+
href="##{collapse_id}" aria-expanded="true" \
|
173
|
+
aria-controls="#{collapse_id}">
|
174
|
+
#{title}
|
159
175
|
</a>
|
160
176
|
</h4>
|
161
177
|
</div>
|
162
|
-
<div id="#{collapse_id}" class="panel-collapse collapse"
|
178
|
+
<div id="#{collapse_id}" class="panel-collapse collapse" \
|
179
|
+
role="tabpanel" aria-labelledby="heading-#{collapse_id}">
|
163
180
|
<div class="panel-body">
|
164
|
-
#{
|
181
|
+
#{panel_body}
|
165
182
|
</div>
|
166
183
|
</div>
|
167
184
|
</div>
|
@@ -170,6 +187,5 @@ format :html do
|
|
170
187
|
end
|
171
188
|
|
172
189
|
|
173
|
-
|
174
190
|
# ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/utils.rb ~~~~~~~~~~~
|
175
191
|
end;end;end;end;
|
@@ -4,10 +4,9 @@ class Card; module Set; module All; module Actions; extend Card::Set
|
|
4
4
|
# -*- encoding : utf-8 -*-
|
5
5
|
|
6
6
|
def select_action_by_params params
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
7
|
+
return unless (action = find_action_by_params(params))
|
8
|
+
run_callbacks :select_action do
|
9
|
+
self.selected_action_id = action.id
|
11
10
|
end
|
12
11
|
end
|
13
12
|
|
@@ -15,28 +14,32 @@ def find_action_by_params args
|
|
15
14
|
if args[:rev]
|
16
15
|
nth_action args[:rev]
|
17
16
|
elsif Integer === args[:rev_id] || args[:rev_id] =~ /^\d+$/
|
18
|
-
if action = Action.fetch(args[:rev_id])
|
17
|
+
if (action = Action.fetch(args[:rev_id])) && action.card_id == id
|
19
18
|
action
|
20
19
|
end
|
21
|
-
|
20
|
+
# revision id is probalby a mod (e.g. if you request
|
21
|
+
# files/:logo/05_standard.png)
|
22
|
+
elsif args[:rev_id]
|
22
23
|
last_action
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
27
|
def nth_action index
|
27
28
|
index = index.to_i
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
return unless id && index > 0
|
30
|
+
Action.where("draft is not true AND card_id = #{id}")
|
31
|
+
.order(:id).limit(1).offset(index - 1).first
|
31
32
|
end
|
32
33
|
|
33
34
|
def revision action
|
34
|
-
# a "revision" refers to the state of all tracked fields
|
35
|
+
# a "revision" refers to the state of all tracked fields
|
36
|
+
# at the time of a given action
|
35
37
|
if action.is_a? Integer
|
36
38
|
action = Card::Action.fetch(action)
|
37
39
|
end
|
38
|
-
action
|
39
|
-
last_change = action.card_changes.find_by_field_name(field) ||
|
40
|
+
action && Card::TRACKED_FIELDS.inject({}) do |attr_changes, field|
|
41
|
+
last_change = action.card_changes.find_by_field_name(field) ||
|
42
|
+
last_change_on(field, not_after: action)
|
40
43
|
attr_changes[field.to_sym] = (last_change ? last_change.value : self[field])
|
41
44
|
attr_changes
|
42
45
|
end
|
@@ -45,15 +48,16 @@ end
|
|
45
48
|
def delete_old_actions
|
46
49
|
Card::TRACKED_FIELDS.each do |field|
|
47
50
|
# assign previous changes on each tracked field to the last action
|
48
|
-
if (la = last_action) && !la.change_for(field).present?
|
49
|
-
|
51
|
+
if (la = last_action) && !la.change_for(field).present? &&
|
52
|
+
(last_change = last_change_on field)
|
53
|
+
# last_change comes as readonly record
|
54
|
+
last_change = Card::Change.find(last_change.id)
|
50
55
|
last_change.update_attributes!(card_action_id: last_action_id)
|
51
56
|
end
|
52
57
|
end
|
53
|
-
actions.where('id != ?', last_action_id
|
58
|
+
actions.where('id != ?', last_action_id).delete_all
|
54
59
|
end
|
55
60
|
|
56
61
|
|
57
|
-
|
58
62
|
# ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/01_history/set/all/actions.rb ~~~~~~~~~~~
|
59
63
|
end;end;end;end;
|