card 1.103.2 → 1.104.1
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/environments/development.rb +4 -2
- data/config/environments/production.rb +9 -9
- data/config/environments/test.rb +1 -1
- data/config/initializers/01_core_extensions/array.rb +4 -1
- data/config/initializers/01_core_extensions/object.rb +1 -1
- data/config/initializers/02_patches/active_record.rb +16 -17
- data/config/locales/de.yml +8 -564
- data/config/locales/es.yml +2 -3
- data/db/migrate/20110511221913_require_earlier_migrations.rb +1 -1
- data/db/migrate/20120105203350_require_1_8_migrations.rb +1 -1
- data/db/migrate/20121111025347_require_1_10_migrations.rb +1 -1
- data/db/migrate/20211128040849_virtuals_updated_at.rb +11 -0
- data/db/migrate_core_cards/20130411191151_renaming_for_menu.rb +0 -1
- data/db/migrate_core_cards/20140317035504_account_requests_to_signups.rb +0 -2
- data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +0 -2
- data/db/migrate_core_cards/20190417142612_reorganize_scripts_2.rb +1 -3
- data/db/migrate_core_cards/20190502130029_add_shark_and_help_desk_role.rb +1 -2
- data/db/migrate_core_cards/20190710090209_homepage_tweaks.rb +3 -7
- data/db/migrate_core_cards/20190823220018_cleanup_for_decko_1_0.rb +2 -4
- data/db/migrate_core_cards/20190902193208_input_type.rb +3 -8
- data/db/migrate_core_cards/20190904174403_token_upgrade.rb +1 -1
- data/db/migrate_core_cards/data/1.12_stylesheets/traditional.scss +1 -2
- data/db/schema.rb +19 -16
- data/db/seed/new/card_actions.yml +2615 -3383
- data/db/seed/new/card_acts.yml +3 -3
- data/db/seed/new/card_references.yml +1588 -1707
- data/db/seed/new/cards.yml +5450 -8416
- data/db/seed/new/schema_migrations.yml +2 -0
- data/db/seed/new/schema_migrations_core_cards.yml +8 -0
- data/db/seed/test/fixtures/card_actions.yml +4304 -5144
- data/db/seed/test/fixtures/card_acts.yml +780 -840
- data/db/seed/test/fixtures/card_changes.yml +110 -110
- data/db/seed/test/fixtures/card_references.yml +2908 -2992
- data/db/seed/test/fixtures/cards.yml +8775 -11955
- data/db/seed/test/fixtures/schema_migrations.yml +2 -0
- data/db/seed/test/fixtures/schema_migrations_core_cards.yml +8 -0
- data/db/test_seed.rb +2 -5
- data/db/version.txt +1 -1
- data/db/version_core_cards.txt +1 -1
- data/lib/card/auth/current.rb +1 -1
- data/lib/card/auth/permissions.rb +37 -35
- data/lib/card/content/all.rb +3 -3
- data/lib/card/content/chunk.rb +1 -1
- data/lib/card/content/diff/summary.rb +14 -18
- data/lib/card/content.rb +9 -1
- data/lib/card/director/act_direction.rb +6 -6
- data/lib/card/director/card_methods.rb +0 -1
- data/lib/card/director/phases.rb +1 -0
- data/lib/card/director/stages.rb +2 -0
- data/lib/card/director.rb +1 -0
- data/lib/card/fetch/all.rb +3 -3
- data/lib/card/fetch/card_class.rb +5 -11
- data/lib/card/fetch/results.rb +8 -8
- data/lib/card/{tasks/card/file_card_creator → file_card_creator}/abstract_file_card/migration_file.rb +0 -0
- data/lib/card/{tasks/card/file_card_creator → file_card_creator}/abstract_file_card/ruby_file.rb +0 -0
- data/lib/card/{tasks/card/file_card_creator → file_card_creator}/abstract_file_card/source_file.rb +0 -0
- data/lib/card/{tasks/card/file_card_creator → file_card_creator}/abstract_file_card.rb +0 -5
- data/lib/card/{tasks/card/file_card_creator → file_card_creator}/haml_card.rb +0 -0
- data/lib/card/{tasks/card/file_card_creator → file_card_creator}/output_helper.rb +0 -0
- data/lib/card/{tasks/card/file_card_creator → file_card_creator}/script_card.rb +0 -0
- data/lib/card/{tasks/card/file_card_creator → file_card_creator}/style_card.rb +0 -0
- data/lib/card/{tasks/card/file_card_creator.rb → file_card_creator.rb} +0 -5
- data/lib/card/format/content.rb +5 -7
- data/lib/card/format/error.rb +2 -2
- data/lib/card/format/render.rb +10 -10
- data/lib/card/format.rb +3 -8
- data/lib/card/lexicon.rb +30 -7
- data/lib/card/model/save_helper/save_arguments.rb +2 -2
- data/lib/card/model/save_helper.rb +3 -3
- data/lib/card/name/all/descendants.rb +9 -7
- data/lib/card/name/all/parts.rb +1 -1
- data/lib/card/name/all.rb +4 -3
- data/lib/card/name/card_class.rb +2 -1
- data/lib/card/name/fields_and_traits.rb +6 -30
- data/lib/card/name/name_variants.rb +5 -1
- data/lib/card/name.rb +6 -14
- data/lib/card/query/abstract_query/tie.rb +2 -3
- data/lib/card/query/card_query/normalization.rb +1 -1
- data/lib/card/query/sql_statement/order.rb +5 -6
- data/lib/card/query/value.rb +10 -7
- data/lib/card/reference/all.rb +9 -7
- data/lib/card/reference.rb +36 -41
- data/lib/card/rule/all.rb +3 -3
- data/lib/card/set/advanced_api.rb +5 -0
- data/lib/card/set/card_methods.rb +13 -0
- data/lib/card/set/event/delayed_event.rb +8 -1
- data/lib/card/set/event/skip_and_trigger.rb +8 -0
- data/lib/card/set/event.rb +1 -0
- data/lib/card/set/format/abstract_format/wrapper.rb +1 -1
- data/lib/card/set/format/abstract_format.rb +2 -1
- data/lib/card/set/format.rb +2 -3
- data/lib/card/set/helpers.rb +68 -0
- data/lib/card/set/inheritance.rb +1 -1
- data/lib/card/set/pattern/all.rb +20 -10
- data/lib/card/set/pattern/base.rb +12 -18
- data/lib/card/set/pattern/class_methods.rb +13 -13
- data/lib/card/set/pattern.rb +46 -24
- data/lib/card/set/registrar.rb +8 -2
- data/lib/card/set/trait.rb +16 -1
- data/lib/card/set/type.rb +3 -0
- data/lib/card/set.rb +14 -7
- data/lib/card/subcards/add.rb +1 -3
- data/lib/card/subcards/all.rb +30 -56
- data/lib/card/view/classy.rb +15 -27
- data/lib/card/view/options/voo_api.rb +3 -1
- data/lib/card/view/options.rb +7 -5
- data/lib/card/view/permission.rb +4 -11
- data/lib/card/view.rb +1 -0
- data/lib/card.rb +9 -11
- data/lib/cardio/cli.rb +1 -0
- data/lib/cardio/commands/custom.rb +60 -0
- data/lib/cardio/commands/rake_command/parser.rb +49 -48
- data/lib/cardio/commands/rake_command.rb +17 -15
- data/lib/cardio/commands/rspec_command.rb +2 -0
- data/lib/cardio/commands.rb +69 -69
- data/lib/cardio/generators/deck_helper.rb +0 -4
- data/lib/cardio/generators.rb +56 -3
- data/lib/cardio/migration/deck.rb +0 -0
- data/lib/cardio/migration/deck_structure.rb +2 -0
- data/lib/cardio/migration/import/import_data/card_content.rb +1 -1
- data/lib/cardio/migration/import.rb +2 -2
- data/lib/cardio/migration.rb +26 -2
- data/lib/cardio/mod/class_methods.rb +112 -0
- data/lib/cardio/mod/dirs.rb +15 -11
- data/lib/cardio/mod/eat/edibles.rb +92 -0
- data/lib/cardio/mod/eat.rb +81 -0
- data/lib/cardio/mod/load_strategy/set_tmp_files.rb +10 -4
- data/lib/cardio/mod/load_strategy/tmp_files.rb +1 -1
- data/lib/cardio/mod/load_strategy.rb +3 -4
- data/lib/cardio/mod/loader/set_loader.rb +13 -13
- data/lib/cardio/mod/loader.rb +1 -1
- data/lib/cardio/mod/modfile_api.rb +5 -0
- data/lib/cardio/mod/poop.rb +135 -0
- data/lib/cardio/mod.rb +20 -80
- data/lib/cardio/railtie.rb +24 -6
- data/lib/cardio/schema.rb +11 -10
- data/lib/cardio/version.rb +35 -0
- data/lib/cardio.rb +4 -0
- data/lib/generators/deck/deck_generator.rb +3 -2
- data/lib/generators/deck/templates/Gemfile.erb +1 -5
- data/lib/generators/deck/templates/Rakefile.erb +6 -2
- data/lib/generators/deck/templates/rspec.erb +1 -1
- data/lib/generators/deck/templates/simplecov.rb.erb +7 -11
- data/lib/generators/deck/templates/spec/javascripts/support/decko_jasmine.yml.erb +0 -1
- data/lib/generators/mod/USAGE +1 -0
- data/lib/{card/tasks → tasks}/card/create.rake +0 -0
- data/lib/{card/tasks → tasks}/card/migrate.rake +41 -1
- data/lib/{card/tasks → tasks}/card/mod.rake +15 -8
- data/lib/tasks/card.rake +65 -0
- data/mod/admin/locales/de.yml +4 -0
- data/mod/admin/set/all/admin.rb +16 -0
- data/mod/admin/set/self/admin.rb +12 -14
- data/mod/admin/set/self/admin_info.rb +2 -5
- data/mod/core/data/production.yml +7 -0
- data/mod/core/data/test.yml +30 -0
- data/mod/core/locales/de.yml +28 -0
- data/mod/core/locales/en.yml +4 -5
- data/mod/core/set/all/assign_attributes.rb +1 -33
- data/mod/core/set/all/content.rb +3 -1
- data/mod/core/set/all/initialize.rb +1 -4
- data/mod/core/set/all/name_events.rb +3 -18
- data/mod/core/set/all/reference_events.rb +32 -36
- data/mod/core/set/all/subcards.rb +6 -2
- data/mod/core/set/all/trash.rb +4 -6
- data/mod/core/set/all/type.rb +67 -18
- data/mod/core/set/self/version.rb +1 -1
- data/mod/core/spec/set/all/name_events_spec.rb +10 -10
- data/mod/core/spec/set/all/trash_spec.rb +1 -1
- data/mod/core/spec/set/self/trash_spec.rb +1 -1
- data/mod/standard/{file → data/files}/favicon/image-icon.png +0 -0
- data/mod/standard/{file → data/files}/favicon/image-large.png +0 -0
- data/mod/standard/{file → data/files}/favicon/image-medium.png +0 -0
- data/mod/standard/{file → data/files}/favicon/image-original.png +0 -0
- data/mod/standard/{file → data/files}/favicon/image-small.png +0 -0
- data/mod/standard/{file → data/files}/logo/image-original.svg +0 -0
- metadata +52 -42
- data/db/migrate_core_cards/20150605115802_add_performance_log_card.rb +0 -7
- data/lib/card/set/basket.rb +0 -59
- data/lib/card/set/code_nest.rb +0 -15
- data/lib/card/tasks/card/asset.rake +0 -22
- data/lib/card/tasks/card.rake +0 -105
- data/lib/card/version.rb +0 -11
- data/lib/cardio/commands/USAGE +0 -28
- data/lib/cardio/generators/class_methods.rb +0 -35
- data/mod/core/spec/set/all/clean_me_spec.rb +0 -258
- data/mod/core/spec/set/all/export_spec.rb +0 -71
- data/tmpsets/set_pattern/100-all.rb +0 -22
- data/tmpsets/set_pattern/101-all_plus.rb +0 -24
- data/tmpsets/set_pattern/102-type.rb +0 -40
- data/tmpsets/set_pattern/103-star.rb +0 -26
- data/tmpsets/set_pattern/104-rstar.rb +0 -28
- data/tmpsets/set_pattern/105-rule.rb +0 -28
- data/tmpsets/set_pattern/106-right.rb +0 -35
- data/tmpsets/set_pattern/107-type_plus_right.rb +0 -43
- data/tmpsets/set_pattern/108-self.rb +0 -34
@@ -1,12 +1,9 @@
|
|
1
|
-
basket :
|
2
|
-
|
1
|
+
basket[:warnings] = [:no_email_delivery]
|
3
2
|
# For each warning in the basket (eg :my_warning), the core view
|
4
3
|
# will run a test by appending a question mark (eg #my_warning?).
|
5
4
|
# If it fails it will generate a message by appending message
|
6
5
|
# (eg #my_warning_message).
|
7
6
|
|
8
|
-
add_to_basket :warnings, :no_email_delivery
|
9
|
-
|
10
7
|
def no_email_delivery?
|
11
8
|
Card.config.action_mailer.perform_deliveries == false
|
12
9
|
end
|
@@ -17,7 +14,7 @@ end
|
|
17
14
|
|
18
15
|
format :html do
|
19
16
|
view :core do
|
20
|
-
warnings =
|
17
|
+
warnings = basket[:warnings].map do |warning|
|
21
18
|
card.send("#{warning}?") ? send("#{warning}_message") : nil
|
22
19
|
end
|
23
20
|
warnings.compact!
|
@@ -0,0 +1,30 @@
|
|
1
|
+
- :name: Author
|
2
|
+
:type: :cardtype
|
3
|
+
- :name: Fruit
|
4
|
+
:type: :cardtype
|
5
|
+
- :name: self aware
|
6
|
+
:type: :cardtype
|
7
|
+
- :name: Cardtype A
|
8
|
+
:type: :cardtype
|
9
|
+
:codename: :cardtype_a
|
10
|
+
- :name: Cardtype B
|
11
|
+
:type: :cardtype
|
12
|
+
:codename: :cardtype_b
|
13
|
+
- :name: Cardtype C
|
14
|
+
:type: :cardtype
|
15
|
+
:codename: :cardtype_c
|
16
|
+
- :name: Cardtype D
|
17
|
+
:type: :cardtype
|
18
|
+
:codename: :cardtype_d
|
19
|
+
- :name: Cardtype E
|
20
|
+
:type: :cardtype
|
21
|
+
:codename: :cardtype_e
|
22
|
+
- :name: Cardtype F
|
23
|
+
:type: :cardtype
|
24
|
+
:codename: :cardtype_f
|
25
|
+
- :name: UserForm
|
26
|
+
:type: :cardtype
|
27
|
+
- :name: Book
|
28
|
+
:type: :cardtype
|
29
|
+
- :name: Sample Cardtype
|
30
|
+
:type: :cardtype
|
@@ -0,0 +1,28 @@
|
|
1
|
+
de:
|
2
|
+
core_cannot_change_content: Inhalt kann nicht geändert werden, während der Name geändert wird
|
3
|
+
core_cannot_change_type: Typ kann nicht geändert werden, während der Name geändert wird
|
4
|
+
core_cards_exist: Sorry, diese Karten muss ein Kartentyp bleiben, solange es noch %{cardname}-Karten gibt.
|
5
|
+
core_error_banned_characters: "die folgenden Zeichen sind nicht erlaubt: %{banned}"
|
6
|
+
core_error_blank_key: darf nicht frei bleiben
|
7
|
+
core_error_blank_name: darf nicht frei bleiben
|
8
|
+
core_error_cant_alter: Typ kann nicht geändert werden; es gibt noch %{name} Karten
|
9
|
+
core_error_cant_change_errors: "von %{name} kann nicht geändert werden; Fehler beim Erstellen von neuen %{type_id}: %{error_messages}"
|
10
|
+
core_error_code_in_use: Codename %{codename} ist bereits vergeben
|
11
|
+
core_error_hard_templated: kann nicht geändert werden, weil %{name} ist eine Vorlage für %{type_name}
|
12
|
+
core_error_indestructible: "%{name} ist eine unzerstörbare Regel"
|
13
|
+
core_error_invalid_character_in_cardtype: "folgende Zeichen sind nicht erlaubt: %{banned}"
|
14
|
+
core_error_name_exists: muss eindeutig sein; '%{name}' gibt es bereits.
|
15
|
+
core_error_name_tag: "%{name} wird als Tag benutzt"
|
16
|
+
core_error_no_such_type: diesen Typ gibt es nicht
|
17
|
+
core_error_system_card: "%{name} ist eine Systemkarte. (%{codename})"
|
18
|
+
core_error_too_long: ist zu lang (%{length} Zeichen; erlaubt sind maximal 255)
|
19
|
+
core_error_user_edits: "Wurde bearbeitet mit %{name}s Account.\nLöschen würde den Verlauf durcheinander bringen."
|
20
|
+
core_error_wrong_key: falscher Schlüssel '%{key}' für Name %{name}
|
21
|
+
core_exception_almost_deleted: Löschen der aktuellen Datei knapp abgewendet
|
22
|
+
core_is_incomplete: ist unvollständig
|
23
|
+
core_only_admins_codename: nur Administratoren können Codenamen festlegen
|
24
|
+
core_renaming: "Wird umbenannt"
|
25
|
+
core_rename: "Umbenennen"
|
26
|
+
core_rename_confirm: "Sind Sie sicher, dass Sie die Karte umbenennen wollen?"
|
27
|
+
skip_update_referer_content:
|
28
|
+
Verweise auf diesen Namen nicht aktualisieren
|
data/mod/core/locales/en.yml
CHANGED
@@ -21,10 +21,9 @@ en:
|
|
21
21
|
core_exception_almost_deleted: Narrowly averted deleting current file
|
22
22
|
core_is_incomplete: is incomplete
|
23
23
|
core_only_admins_codename: only admins can set codename
|
24
|
-
core_rename_and_update: "Rename and Update"
|
25
24
|
core_renaming: "Renaming"
|
26
25
|
core_rename: "Rename"
|
27
|
-
core_rename_confirm: "Are you sure you want to rename"
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
core_rename_confirm: "Are you sure you want to rename?"
|
27
|
+
|
28
|
+
skip_update_referer_content:
|
29
|
+
do not update references to this name
|
@@ -38,6 +38,7 @@ def prepare_assignment_params args
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def prepare_assignment_args args
|
41
|
+
@set_specific = {}
|
41
42
|
return {} unless args
|
42
43
|
|
43
44
|
args = args.symbolize_keys
|
@@ -66,44 +67,11 @@ def refresh_set_modules
|
|
66
67
|
end
|
67
68
|
|
68
69
|
def stash_set_specific_attributes args
|
69
|
-
@set_specific = {}
|
70
70
|
Card.set_specific_attributes.each do |key|
|
71
71
|
set_specific[key] = args.delete(key) if args.key?(key)
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
def normalize_type_attributes args
|
76
|
-
new_type_id = extract_type_id! args unless args.delete(:type_lookup) == :skip
|
77
|
-
args[:type_id] = new_type_id if new_type_id
|
78
|
-
end
|
79
|
-
|
80
|
-
def extract_type_id! args={}
|
81
|
-
case
|
82
|
-
when (type_id = args.delete(:type_id)&.to_i)
|
83
|
-
type_id.zero? ? nil : type_id
|
84
|
-
when (type_code = args.delete(:type_code)&.to_sym)
|
85
|
-
type_id_from_codename type_code
|
86
|
-
when (type_name = args.delete :type)
|
87
|
-
type_id_from_cardname type_name
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def type_id_from_codename type_code
|
92
|
-
type_id_or_error(type_code) { Card::Codename.id type_code }
|
93
|
-
end
|
94
|
-
|
95
|
-
def type_id_from_cardname type_name
|
96
|
-
type_id_or_error(type_name) { type_name.card_id }
|
97
|
-
end
|
98
|
-
|
99
|
-
def type_id_or_error val
|
100
|
-
type_id = yield
|
101
|
-
return type_id if type_id
|
102
|
-
|
103
|
-
errors.add :type, "#{val} is not a known type."
|
104
|
-
nil
|
105
|
-
end
|
106
|
-
|
107
75
|
# 'set' refers to the noun not the verb
|
108
76
|
def set_specific
|
109
77
|
@set_specific ||= {}
|
data/mod/core/set/all/content.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
event :set_content, :store, on: :save do
|
2
|
-
self.
|
2
|
+
self.content = prepare_db_content
|
3
3
|
@selected_action_id = @selected_content = nil
|
4
4
|
clear_drafts
|
5
5
|
end
|
@@ -37,6 +37,8 @@ end
|
|
37
37
|
|
38
38
|
def prepare_db_content
|
39
39
|
cont = standard_db_content || "" # necessary?
|
40
|
+
|
41
|
+
# TODO: move this html-specific code somewhere more appropriate
|
40
42
|
clean_html? ? Card::Content.clean!(cont) : cont
|
41
43
|
end
|
42
44
|
|
@@ -39,7 +39,6 @@ def initialize args={}
|
|
39
39
|
super args # ActiveRecord #initialize
|
40
40
|
end
|
41
41
|
end
|
42
|
-
self
|
43
42
|
end
|
44
43
|
|
45
44
|
def handle_set_modules args
|
@@ -49,11 +48,9 @@ def handle_set_modules args
|
|
49
48
|
end
|
50
49
|
|
51
50
|
def handle_type args
|
52
|
-
type_lookup = args[:type_lookup]
|
53
51
|
@supercard = args.delete :supercard
|
54
|
-
|
55
52
|
yield
|
56
|
-
|
53
|
+
ensure_type_id args[:type_lookup]
|
57
54
|
end
|
58
55
|
|
59
56
|
def initial_name name
|
@@ -76,10 +76,6 @@ event :update_lexicon, :finalize, changed: :name, on: :save do
|
|
76
76
|
Card::Lexicon.send lexicon_action, self
|
77
77
|
end
|
78
78
|
|
79
|
-
event :cascade_name_changes, :finalize, on: :update, changed: :name do
|
80
|
-
each_descendant { |d| d.rename_as_descendant update_referers }
|
81
|
-
end
|
82
|
-
|
83
79
|
protected
|
84
80
|
|
85
81
|
def rename_as_trash_obstacle
|
@@ -88,15 +84,6 @@ def rename_as_trash_obstacle
|
|
88
84
|
save!
|
89
85
|
end
|
90
86
|
|
91
|
-
def rename_as_descendant referers=true
|
92
|
-
self.action = :update
|
93
|
-
referers ? update_referer_content : update_referer_references_out
|
94
|
-
refresh_references_in
|
95
|
-
refresh_references_out
|
96
|
-
expire
|
97
|
-
Card::Lexicon.update self
|
98
|
-
end
|
99
|
-
|
100
87
|
private
|
101
88
|
|
102
89
|
def name_incomplete?
|
@@ -114,9 +101,7 @@ def detect_illegal_compound_names
|
|
114
101
|
end
|
115
102
|
|
116
103
|
def changing_existing_tag_to_compound?
|
117
|
-
|
118
|
-
|
119
|
-
name_in_use_as_tag?
|
104
|
+
changing_name_to_compound? && name_in_use_as_tag?
|
120
105
|
end
|
121
106
|
|
122
107
|
def name_in_use_as_tag?
|
@@ -150,7 +135,7 @@ end
|
|
150
135
|
def prepare_new_side side, side_id, sidename
|
151
136
|
return unless side_id == -1 || !Card[side_id]&.real?
|
152
137
|
|
153
|
-
sidecard = Director.card(sidename) ||
|
138
|
+
sidecard = Director.card(sidename) || subcard(sidename)
|
154
139
|
send "#{side}_id=", sidecard
|
155
140
|
end
|
156
141
|
|
@@ -158,6 +143,6 @@ def prepare_obstructed_side side, side_id, sidename
|
|
158
143
|
return unless side_id && side_id == id
|
159
144
|
|
160
145
|
clear_name sidename
|
161
|
-
send "#{side}_id=",
|
146
|
+
send "#{side}_id=", subcard(sidename)
|
162
147
|
true
|
163
148
|
end
|
@@ -1,17 +1,12 @@
|
|
1
|
-
#
|
2
|
-
event :
|
3
|
-
|
1
|
+
# when content changes, update references to other cards
|
2
|
+
event :refresh_references_out, :finalize, on: :save, changed: :content do
|
3
|
+
update_references_out
|
4
4
|
end
|
5
5
|
|
6
6
|
# on rename, update names in cards that refer to self by name (as directed)
|
7
|
-
event :update_referer_content, :finalize, on: :update,
|
8
|
-
referers.each
|
9
|
-
|
10
|
-
|
11
|
-
card.skip_event! :validate_renaming, :check_permissions
|
12
|
-
card.content = card.replace_references name_before_act, name
|
13
|
-
attach_subcard card
|
14
|
-
end
|
7
|
+
event :update_referer_content, :finalize, on: :update, changed: :name, skip: :allowed do
|
8
|
+
referers.each { |r| r.replace_references name_before_act, name }
|
9
|
+
each_descendant { |d| d.rename_as_descendant !skip_update_referers? }
|
15
10
|
end
|
16
11
|
|
17
12
|
# on rename, when NOT updating referer content, update references to ensure
|
@@ -19,51 +14,52 @@ end
|
|
19
14
|
# eg. A links to X+Y. if X+Y is renamed and we're not updating the link in A,
|
20
15
|
# then we need to be sure that A has a partial reference
|
21
16
|
event :update_referer_references_out, :finalize,
|
22
|
-
changed: :name, on: :update, when: :
|
17
|
+
changed: :name, on: :update, when: :skip_update_referers? do
|
23
18
|
referers.map(&:update_references_out)
|
24
19
|
end
|
25
20
|
|
26
21
|
# when name changes, update references to card
|
27
22
|
event :refresh_references_in, :finalize, changed: :name, on: :save do
|
28
|
-
Reference.unmap_referees id if action == :update &&
|
23
|
+
Reference.unmap_referees id if action == :update && skip_update_referers?
|
29
24
|
Reference.map_referees key, id
|
30
25
|
end
|
31
26
|
|
32
|
-
# when content changes, update references to other cards
|
33
|
-
event :refresh_references_out, :finalize, on: :save, changed: :content do
|
34
|
-
update_references_out
|
35
|
-
end
|
36
|
-
|
37
27
|
# clean up reference table when card is deleted
|
38
28
|
event :clear_references, :finalize, on: :delete do
|
39
29
|
delete_references_out
|
40
30
|
Reference.unmap_referees id
|
41
31
|
end
|
42
32
|
|
43
|
-
# replace references in card content
|
44
|
-
def replace_references old_name, new_name
|
45
|
-
cont = content_object
|
46
|
-
cont.find_chunks(:Reference).each do |chunk|
|
47
|
-
next unless replace_reference chunk, old_name, new_name
|
48
|
-
end
|
49
|
-
cont.to_s
|
50
|
-
end
|
51
|
-
|
52
33
|
protected
|
53
34
|
|
54
|
-
def
|
55
|
-
|
35
|
+
def skip_update_referers?
|
36
|
+
skip_event? :update_referer_content
|
56
37
|
end
|
57
38
|
|
58
|
-
|
39
|
+
def rename_as_descendant referers=true
|
40
|
+
self.action = :update
|
41
|
+
referers ? update_referer_content : update_referer_references_out
|
42
|
+
# refresh_references_in
|
43
|
+
# refresh_references_out
|
44
|
+
expire
|
45
|
+
Card::Lexicon.update self
|
46
|
+
end
|
47
|
+
|
48
|
+
def replace_references old_name, new_name
|
49
|
+
self.content_quietly = swap_names(old_name, new_name) unless structure
|
50
|
+
end
|
59
51
|
|
60
|
-
def
|
61
|
-
|
52
|
+
def content_quietly= new_content
|
53
|
+
self.content = new_content
|
54
|
+
return unless db_content_changed? # prevents loops
|
62
55
|
|
63
|
-
|
64
|
-
|
56
|
+
update_column :db_content, db_content
|
57
|
+
update_references_out
|
65
58
|
end
|
66
59
|
|
67
|
-
|
68
|
-
|
60
|
+
private
|
61
|
+
|
62
|
+
# delete references from this card
|
63
|
+
def delete_references_out
|
64
|
+
Reference.where(referer_id: id).delete_all if id.present?
|
69
65
|
end
|
@@ -1,8 +1,12 @@
|
|
1
|
+
def card
|
2
|
+
self
|
3
|
+
end
|
4
|
+
|
1
5
|
event :reject_empty_subcards, :prepare_to_validate do
|
2
6
|
subcards.each_with_key do |subcard, key|
|
3
|
-
next unless subcard.new? && subcard.unfilled?
|
7
|
+
next unless subcard.new? && subcard.unfilled? && !trigger.present?
|
4
8
|
|
5
|
-
|
9
|
+
drop_subcard(key)
|
6
10
|
director.subdirectors.delete(subcard)
|
7
11
|
end
|
8
12
|
end
|
data/mod/core/set/all/trash.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
:tasks,
|
1
|
+
basket[:tasks] << {
|
3
2
|
name: :empty_trash,
|
4
3
|
irreversible: true,
|
5
4
|
execute_policy: -> { Card.empty_trash },
|
@@ -9,7 +8,7 @@ Self::Admin.add_to_basket(
|
|
9
8
|
link_text: "empty trash",
|
10
9
|
task: "empty_trash"
|
11
10
|
}
|
12
|
-
|
11
|
+
}
|
13
12
|
|
14
13
|
module ClassMethods
|
15
14
|
def empty_trash
|
@@ -19,8 +18,7 @@ module ClassMethods
|
|
19
18
|
Card::Action.delete_cardless
|
20
19
|
Card::Change.delete_actionless
|
21
20
|
Card::Act.delete_actionless
|
22
|
-
Card::Reference.
|
23
|
-
Card::Reference.delete_if_referer_missing
|
21
|
+
Card::Reference.clean
|
24
22
|
end
|
25
23
|
|
26
24
|
# deletes any file not associated with a real card.
|
@@ -129,5 +127,5 @@ end
|
|
129
127
|
|
130
128
|
def delete_as_subcard subcard
|
131
129
|
subcard.trash = true
|
132
|
-
|
130
|
+
subcard subcard
|
133
131
|
end
|
data/mod/core/set/all/type.rb
CHANGED
@@ -1,13 +1,29 @@
|
|
1
1
|
module ClassMethods
|
2
2
|
def default_type_id
|
3
|
-
|
3
|
+
@default_type_id ||= Card.fetch_type_id %i[all default]
|
4
4
|
end
|
5
5
|
end
|
6
6
|
|
7
|
-
|
8
|
-
return
|
7
|
+
event :validate_type_change, :validate, on: :update, changed: :type_id do
|
8
|
+
return unless (c = dup) && c.action == :create && !c.valid?
|
9
9
|
|
10
|
-
|
10
|
+
errors.add :type, t(:core_error_cant_change_errors,
|
11
|
+
name: name,
|
12
|
+
type_id: type_id,
|
13
|
+
error_messages: c.errors.full_messages)
|
14
|
+
end
|
15
|
+
|
16
|
+
event :validate_type, :validate, changed: :type_id, on: :save do
|
17
|
+
errors.add :type, t(:core_error_no_such_type) unless type_name
|
18
|
+
|
19
|
+
if structure&.assigns_type? && type_id != structure.type_id
|
20
|
+
errors.add :type,
|
21
|
+
t(:core_error_hard_templated, name: name, type_name: structure.type_name)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def type_card
|
26
|
+
Card.quick_fetch type_id.to_i unless type_id.nil?
|
11
27
|
end
|
12
28
|
|
13
29
|
def type_code
|
@@ -36,26 +52,59 @@ def type_id= card_or_id
|
|
36
52
|
write_card_or_id :type_id, card_or_id
|
37
53
|
end
|
38
54
|
|
39
|
-
|
40
|
-
|
55
|
+
private
|
56
|
+
|
57
|
+
def ensure_type_id lookup
|
58
|
+
return if lookup == :skip || (type_id && (lookup != :force))
|
59
|
+
|
60
|
+
old_type_id = type_id
|
61
|
+
new_type_id = type_id_from_code || type_id_from_template
|
41
62
|
|
42
|
-
reset_patterns
|
43
|
-
self.type_id =
|
63
|
+
reset_patterns if new_type_id != old_type_id
|
64
|
+
self.type_id = new_type_id
|
44
65
|
end
|
45
66
|
|
46
|
-
|
47
|
-
return
|
67
|
+
def type_id_from_code
|
68
|
+
return if simple?
|
69
|
+
each_type_assigning_module_key do |module_key|
|
70
|
+
type_id = Card::Set::Type.assignment[module_key]
|
71
|
+
return type_id if type_id
|
72
|
+
end
|
73
|
+
nil
|
74
|
+
end
|
48
75
|
|
49
|
-
|
50
|
-
|
51
|
-
type_id: type_id,
|
52
|
-
error_messages: c.errors.full_messages)
|
76
|
+
def type_id_from_template
|
77
|
+
name && template&.type_id
|
53
78
|
end
|
54
79
|
|
55
|
-
|
56
|
-
|
80
|
+
def normalize_type_attributes args
|
81
|
+
new_type_id = extract_type_id! args unless args.delete(:type_lookup) == :skip
|
82
|
+
args[:type_id] = new_type_id if new_type_id
|
83
|
+
end
|
57
84
|
|
58
|
-
|
59
|
-
|
85
|
+
def extract_type_id! args={}
|
86
|
+
case
|
87
|
+
when (type_id = args.delete(:type_id)&.to_i)
|
88
|
+
type_id.zero? ? nil : type_id
|
89
|
+
when (type_code = args.delete(:type_code)&.to_sym)
|
90
|
+
type_id_from_codename type_code
|
91
|
+
when (type_name = args.delete :type)
|
92
|
+
type_id_from_cardname type_name
|
60
93
|
end
|
61
94
|
end
|
95
|
+
|
96
|
+
def type_id_from_codename type_code
|
97
|
+
type_id_or_error(type_code) { Card::Codename.id type_code }
|
98
|
+
end
|
99
|
+
|
100
|
+
def type_id_from_cardname type_name
|
101
|
+
type_id_or_error(type_name) { type_name.card_id }
|
102
|
+
end
|
103
|
+
|
104
|
+
def type_id_or_error val
|
105
|
+
type_id = yield
|
106
|
+
return type_id if type_id
|
107
|
+
|
108
|
+
errors.add :type, "#{val} is not a known type."
|
109
|
+
nil
|
110
|
+
end
|
@@ -20,7 +20,7 @@ RSpec.describe Card::Set::All::NameEvents do
|
|
20
20
|
actions_count_before = card.actions.count
|
21
21
|
old_name = card.name
|
22
22
|
|
23
|
-
update! card.name, name: new_name
|
23
|
+
update! card.name, name: new_name
|
24
24
|
expect_action_added card, actions_count_before
|
25
25
|
expect_old_name_cleared old_name
|
26
26
|
expect_successful_rename card, attrs_before
|
@@ -66,7 +66,7 @@ RSpec.describe Card::Set::All::NameEvents do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
it "wipes old references by default" do
|
69
|
-
update "Menu", name: "manure"
|
69
|
+
update "Menu", name: "manure", skip: :update_referer_content
|
70
70
|
expect(Card["manure"].references_in.size).to eq(0)
|
71
71
|
end
|
72
72
|
|
@@ -133,7 +133,7 @@ RSpec.describe Card::Set::All::NameEvents do
|
|
133
133
|
end
|
134
134
|
|
135
135
|
c = Card["Joe Card"]
|
136
|
-
c.update! name: "Card of Joe"
|
136
|
+
c.update! name: "Card of Joe"
|
137
137
|
assert_equal "[[Card of Joe]]", Card["Admin Card"].content
|
138
138
|
end
|
139
139
|
|
@@ -144,7 +144,7 @@ RSpec.describe Card::Set::All::NameEvents do
|
|
144
144
|
Card.create! name: "Fruit+*type+*structure", content: "this [[Pit]]"
|
145
145
|
|
146
146
|
assert_equal "this [[Pit]]", Card["Orange"].content
|
147
|
-
c.update! name: "Seed"
|
147
|
+
c.update! name: "Seed"
|
148
148
|
assert_equal "this [[Seed]]", Card["Orange"].content
|
149
149
|
end
|
150
150
|
end
|
@@ -156,38 +156,38 @@ RSpec.describe Card::Set::All::NameEvents do
|
|
156
156
|
context "with self references" do
|
157
157
|
example "renaming card with self link should nothang" do
|
158
158
|
pre_content = Card["self_aware"].content
|
159
|
-
update "self aware", name: "buttah"
|
159
|
+
update "self aware", name: "buttah"
|
160
160
|
expect_card("Buttah").to have_content(pre_content)
|
161
161
|
end
|
162
162
|
|
163
163
|
it "renames card without updating references" do
|
164
164
|
pre_content = Card["self_aware"].content
|
165
|
-
update "self aware", name: "Newt"
|
165
|
+
update "self aware", name: "Newt"
|
166
166
|
expect_card("Newt").to have_content(pre_content)
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
170
170
|
context "with references" do
|
171
171
|
it "updates nests" do
|
172
|
-
update "Blue", name: "Red"
|
172
|
+
update "Blue", name: "Red"
|
173
173
|
expect_card("blue includer 1").to have_content("{{Red}}")
|
174
174
|
expect_card("blue includer 2").to have_content("{{Red|closed;other:stuff}}")
|
175
175
|
end
|
176
176
|
|
177
177
|
it "updates nests when renaming to plus" do
|
178
|
-
update "Blue", name: "blue includer 1+color"
|
178
|
+
update "Blue", name: "blue includer 1+color"
|
179
179
|
expect_card("blue includer 1").to have_content("{{blue includer 1+color}}")
|
180
180
|
end
|
181
181
|
|
182
182
|
it "reference updates on case variants" do
|
183
|
-
update "Blue", name: "Red"
|
183
|
+
update "Blue", name: "Red"
|
184
184
|
expect_card("blue linker 1").to have_content("[[Red]]")
|
185
185
|
expect_card("blue linker 2").to have_content("[[Red]]")
|
186
186
|
end
|
187
187
|
|
188
188
|
it "handles link to and nest of same card" do
|
189
189
|
update "blue linker 1", content: "[[Blue]] is {{Blue|name}}"
|
190
|
-
update "Blue", name: "Red"
|
190
|
+
update "Blue", name: "Red"
|
191
191
|
expect_card("blue linker 1").to have_content("[[Red]] is {{Red|name}}")
|
192
192
|
end
|
193
193
|
|
@@ -79,7 +79,7 @@ RSpec.describe Card::Set::All::Trash do
|
|
79
79
|
end
|
80
80
|
|
81
81
|
describe "event: validate_delete" do
|
82
|
-
it "certain 'all rules' should be
|
82
|
+
it "certain 'all rules' should be indestructible" do
|
83
83
|
rule = "*all+*default"
|
84
84
|
expect { Card[rule].delete! }
|
85
85
|
.to raise_error(/is an indestructible rule/)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|