card 1.99.1 → 1.99.2
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/01_core_extensions/array.rb +1 -0
- data/config/initializers/01_core_extensions/persistent_identifiers.rb +1 -1
- data/config/initializers/02_patches/zeitwerk.rb +13 -0
- data/config/initializers/patches.rb +7 -0
- data/config/initializers/recaptcha.rb +1 -2
- data/config/initializers/zeitwerk.rb +5 -0
- data/config/locales/de.yml +1 -1
- data/config/locales/en.yml +1 -1
- data/config/locales/es.yml +1 -1
- data/db/migrate/20110511221913_require_earlier_migrations.rb +0 -3
- data/db/migrate/20141001105348_move_revisions_to_actions.rb +1 -1
- data/db/migrate_core_cards/20140629222005_add_email_cards.rb +5 -5
- data/db/migrate_core_cards/20141120120605_fix_notification_html_message.rb +1 -1
- data/db/migrate_core_cards/20141204061304_watchers_to_following.rb +1 -1
- data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +2 -2
- data/db/migrate_core_cards/20150317162412_bootstrap_themes.rb +4 -4
- data/db/migrate_core_cards/20150724123438_update_file_and_image_cards.rb +1 -1
- data/db/migrate_core_cards/20190204195039_add_rule_card.rb +1 -1
- data/db/migrate_core_cards/20191008201046_fixture_fix.rb +3 -1
- data/db/migrate_core_cards/20191028135243_add_link_editor_to_tiny_mce_config.rb +8 -0
- data/db/migrate_core_cards/20191115160748_history_cleanup.rb +27 -0
- data/db/migrate_core_cards/20191118145629_codename_fixes.rb +6 -0
- data/db/seed/new/card_actions.yml +874 -874
- data/db/seed/new/card_acts.yml +2 -2
- data/db/seed/new/card_references.yml +2 -2
- data/db/seed/new/cards.yml +1576 -1576
- data/db/seed/new/schema_migrations_core_cards.yml +8 -0
- data/db/seed/test/fixtures/card_actions.yml +1815 -1815
- data/db/seed/test/fixtures/card_acts.yml +499 -499
- data/db/seed/test/fixtures/card_changes.yml +66 -66
- data/db/seed/test/fixtures/card_references.yml +634 -634
- data/db/seed/test/fixtures/cards.yml +2730 -2730
- data/db/seed/test/fixtures/schema_migrations_core_cards.yml +8 -0
- data/db/test_seed.rb +10 -11
- data/lib/card.rb +9 -30
- data/lib/card/act_manager.rb +0 -2
- data/lib/card/auth.rb +0 -5
- data/lib/card/auth/current.rb +32 -59
- data/lib/card/auth/setup.rb +1 -1
- data/lib/card/codename.rb +5 -6
- data/lib/card/content.rb +5 -8
- data/lib/card/content/chunk.rb +0 -78
- data/lib/card/content/chunk/abstract.rb +88 -0
- data/lib/card/content/clean.rb +3 -3
- data/lib/card/content/diff/{lcs.rb → l_c_s.rb} +5 -7
- data/lib/card/content/diff/{processor.rb → l_c_s/processor.rb} +0 -0
- data/lib/card/content/parser.rb +1 -1
- data/lib/card/dirty.rb +25 -31
- data/lib/card/dirty/method_factory.rb +15 -0
- data/lib/card/env.rb +0 -3
- data/lib/card/error.rb +6 -2
- data/lib/card/format.rb +5 -5
- data/lib/card/format/nest/fetch.rb +2 -1
- data/lib/card/mark.rb +1 -0
- data/lib/card/migration.rb +4 -0
- data/lib/card/mod.rb +2 -5
- data/lib/card/mod/dirs.rb +1 -0
- data/lib/card/mod/load_strategy.rb +23 -12
- data/lib/card/mod/loader.rb +13 -13
- data/lib/card/mod/loader/set_loader.rb +7 -1
- data/lib/card/mod/loader/set_pattern_loader.rb +2 -2
- data/lib/card/mod/module_template.rb +1 -5
- data/lib/card/mod_inflector.rb +16 -0
- data/lib/card/model/save_helper.rb +2 -2
- data/lib/card/name.rb +2 -2
- data/lib/card/name/name_variants.rb +19 -0
- data/lib/card/query.rb +4 -2
- data/lib/card/query/card_query/reference_attributes.rb +2 -2
- data/lib/card/query/sql_statement.rb +4 -0
- data/lib/card/set.rb +18 -3
- data/lib/card/set/abstract.rb +6 -0
- data/lib/card/set/event.rb +13 -11
- data/lib/card/set/event/delayed_event.rb +2 -0
- data/lib/card/set/format.rb +3 -3
- data/lib/card/set/helpers.rb +20 -8
- data/lib/card/set/loader.rb +1 -1
- data/lib/card/set/pattern.rb +47 -0
- data/lib/card/{set_pattern.rb → set/pattern/base.rb} +11 -92
- data/lib/card/set/required_field.rb +64 -30
- data/lib/card/set/trait.rb +3 -2
- data/lib/card/set/type.rb +46 -0
- data/lib/card/subcards.rb +0 -4
- data/lib/card/tasks/card.rake +1 -0
- data/lib/card/tasks/card/migrate.rake +1 -1
- data/lib/card/view.rb +2 -7
- data/lib/card/view/cache.rb +3 -0
- data/lib/card/view/cache/stub.rb +5 -0
- data/lib/cardio.rb +73 -46
- data/mod/account/set/abstract/accountable.rb +49 -0
- data/mod/account/set/all/account.rb +3 -3
- data/mod/account/set/right/account.rb +1 -1
- data/mod/account/set/self/signin.rb +2 -2
- data/mod/account/set/type/role.rb +1 -1
- data/mod/account/set/type/signup.rb +2 -2
- data/mod/account/set/type/signup/views.rb +1 -1
- data/mod/account/set/type/user.rb +1 -1
- data/mod/account/spec/set/abstract/accountable_spec.rb +7 -0
- data/mod/account/spec/set/all/account_spec.rb +3 -3
- data/mod/account/spec/set/right/account_spec.rb +1 -1
- data/mod/account/spec/set/type/signup_spec.rb +4 -4
- data/mod/admin/set/self/admin.rb +1 -1
- data/mod/admin/set/self/admin_info.rb +2 -2
- data/mod/admin/set/self/version.rb +1 -1
- data/mod/basic_types/set/type/json.rb +4 -0
- data/mod/basic_types/spec/set/type/html_spec.rb +1 -1
- data/mod/bootstrap/db/migrate_core_cards/data/20181108181219_migrate_classic_skins_to_bootstrap.rb +2 -2
- data/mod/bootstrap/lib/bootstrap/component_loader.rb +1 -1
- data/mod/bootstrap/lib/stylesheets/style_bootstrap_cards.scss +1 -0
- data/mod/bootstrap/set/abstract/bootswatch_theme.rb +1 -1
- data/mod/bootstrap/set/all/bootstrap/tabs.rb +4 -4
- data/mod/bootstrap/set/type/customized_bootswatch_skin.rb +5 -4
- data/mod/carrierwave/config/core_initializers/carrierwave.rb +1 -3
- data/mod/carrierwave/lib/carrier_wave/{cardmount.rb → card_mount.rb} +2 -2
- data/mod/carrierwave/lib/carrier_wave/file_card_uploader.rb +27 -12
- data/mod/carrierwave/set/abstract/attachment.rb +0 -2
- data/mod/carrierwave/set/all/file_utils.rb +5 -1
- data/mod/carrierwave/set/self/admin.rb +1 -1
- data/mod/core/chunk/link.rb +99 -91
- data/mod/core/chunk/nest.rb +2 -2
- data/mod/core/chunk/query_reference.rb +79 -74
- data/mod/core/chunk/view_stub.rb +10 -1
- data/mod/core/format/html_format.rb +1 -1
- data/mod/core/set/abstract/code_file.rb +6 -6
- data/mod/core/set/all/content.rb +1 -1
- data/mod/core/set/all/event_conditions.rb +1 -2
- data/mod/core/set/all/fetch.rb +22 -19
- data/mod/core/set/all/fetch_helper.rb +7 -5
- data/mod/core/set/all/initialize.rb +35 -9
- data/mod/core/set/all/item.rb +16 -6
- data/mod/core/set/all/name.rb +19 -15
- data/mod/core/set/all/pattern.rb +4 -0
- data/mod/core/set/all/permissions.rb +13 -11
- data/mod/core/set/all/rename.rb +1 -0
- data/mod/core/set/all/rules.rb +4 -4
- data/mod/core/set/all/subcards.rb +36 -1
- data/mod/core/set/all/type.rb +1 -1
- data/mod/core/set_pattern/03_type.rb +2 -0
- data/mod/core/spec/chunk/nest_spec.rb +7 -2
- data/mod/core/spec/set/all/fetch_spec.rb +1 -1
- data/mod/core/spec/set/all/permissions_spec.rb +11 -12
- data/mod/core/spec/set/all/rules_spec.rb +3 -3
- data/mod/edit/set/all/bridge.rb +1 -3
- data/mod/edit/set/all/bridge/tab_views.rb +0 -7
- data/mod/edit/set/all/bridge/tab_visibility.rb +5 -7
- data/mod/edit/set/all/form_buttons.rb +1 -1
- data/mod/edit/set/all/form_elements.rb +1 -0
- data/mod/edit/set/all/new.rb +2 -2
- data/mod/edit/spec/set/all/bridge/tab_views_spec.rb +1 -1
- data/mod/edit/spec/set/all/{nest_editor → reference_editor/nest_editor}/nest_parser_spec.rb +1 -1
- data/mod/edit/spec/set/all/{nest_editor_spec.rb → reference_editor/nest_editor_spec.rb} +6 -3
- data/mod/edit/spec/set/all/{nest_image_spec.rb → reference_editor/nest_image_spec.rb} +1 -1
- data/mod/email/set/abstract/test_context.rb +1 -1
- data/mod/email/set/type/email_template/email_config.rb +1 -1
- data/mod/follow/set/all/notify.rb +1 -1
- data/mod/follow/set/all/notify/base_views.rb +1 -1
- data/mod/follow/set/right/account.rb +8 -6
- data/mod/follow/set/right/followers.rb +2 -5
- data/mod/follow/set/right/following.rb +1 -1
- data/mod/follow/spec/set/all/follow_spec.rb +3 -3
- data/mod/follow/spec/set/all/notify_spec.rb +1 -1
- data/mod/follow/spec/set/right/followers_spec.rb +2 -2
- data/mod/history/lib/card/act.rb +3 -1
- data/mod/history/lib/card/action.rb +3 -3
- data/mod/history/lib/card/action/admin.rb +0 -11
- data/mod/history/set/all/history_bridge.rb +1 -1
- data/mod/machines/file/all_script_machine_output/file.js +38415 -69
- data/mod/machines/file/all_style_machine_output/file.css +2 -2
- data/mod/machines/file/script_html5shiv_printshiv_machine_output/file.js +1 -1
- data/mod/machines/lib/javascript/decko/filter.js.coffee +7 -1
- data/mod/machines/lib/javascript/decko/filter_links.js.coffee +13 -2
- data/mod/machines/lib/javascript/decko/link_editor.js.coffee +64 -0
- data/mod/machines/lib/javascript/decko/mod.js.coffee +3 -0
- data/mod/machines/lib/javascript/decko/nest_editor.js.coffee +49 -29
- data/mod/machines/lib/javascript/decko/nest_editor_name.js.coffee +30 -7
- data/mod/machines/lib/javascript/decko/slot.js.coffee +4 -1
- data/mod/machines/lib/stylesheets/style_cards.scss +31 -19
- data/mod/machines/set/abstract/machine/output_cache.rb +1 -1
- data/mod/machines/set/abstract/machine/output_update.rb +1 -1
- data/mod/machines/set/all/reset_machines.rb +2 -2
- data/mod/machines/set/self/script_decko.rb +1 -0
- data/mod/media/set/abstract/media.rb +1 -1
- data/mod/media/set/type/image.rb +1 -1
- data/mod/navbar/set/abstract/account_dropdown.rb +5 -1
- data/mod/navbar/set/right/enabled_roles.rb +1 -1
- data/mod/navbar/set/self/account_links.rb +1 -1
- data/mod/pointer/set/abstract/02_pointer.rb +1 -1
- data/mod/pointer/set/abstract/02_pointer/events.rb +30 -10
- data/mod/pointer/set/abstract/02_pointer/html_views.rb +6 -2
- data/mod/pointer/set/abstract/02_pointer/html_views/autocomplete_input.haml +1 -1
- data/mod/pointer/set/abstract/02_pointer/html_views/filter.rb +1 -1
- data/mod/pointer/set/abstract/02_pointer/item_api.rb +51 -31
- data/mod/pointer/set/abstract/id_pointer.rb +21 -0
- data/mod/pointer/set/type/link_list.rb +1 -1
- data/mod/pointer/set/type/mirror_list.rb +1 -1
- data/mod/pointer/set/type/mirrored_list.rb +2 -2
- data/mod/pointer/spec/set/abstract/paging_params_spec.rb +1 -1
- data/mod/pointer/spec/set/abstract/pointer/item_api_spec.rb +1 -1
- data/mod/recaptcha/set/all/recaptcha.rb +4 -9
- data/mod/rules/set/rule/editor.rb +2 -2
- data/mod/rules/set/type/set/html_views/rule_lists.rb +1 -1
- data/mod/rules/spec/set/type/set_spec.rb +1 -1
- data/mod/search/set/abstract/03_filter/filter_form.haml +1 -1
- data/mod/search/set/abstract/03_filter/filter_form.rb +23 -2
- data/mod/search/set/abstract/03_filter/quick_filters.haml +7 -10
- data/mod/search/template/abstract/search/checkbox_item.haml +5 -6
- data/mod/settings/set/abstract/permission.rb +2 -2
- data/mod/settings/set/right/input_type.rb +3 -3
- data/mod/settings/set/right/structure.rb +1 -1
- data/mod/settings/set/right/style.rb +1 -1
- data/mod/settings/set/type/setting.rb +2 -2
- data/mod/standard/set/all/rich_html/html_views/guide.rb +1 -1
- data/mod/standard/set/all/rich_html/menu.rb +6 -5
- data/mod/standard/set/self/cardtype.rb +1 -1
- data/mod/standard/set/type/cardtype.rb +33 -17
- data/mod/standard/set/type/session.rb +12 -0
- data/mod/standard/spec/set/type/email_template/email_config_spec.rb +1 -2
- data/mod/standard/spec/set/type/email_template_spec.rb +1 -3
- data/mod/tinymce_editor/lib/javascript/script_tinymce_config.js.coffee +3 -2
- data/mod/tinymce_editor/public/assets/tinymce/plugins/nest/plugin.min.js +1 -1
- data/mod/tinymce_editor/set/all/reference_editor.rb +23 -0
- data/mod/tinymce_editor/set/all/reference_editor/_link_editor.haml +18 -0
- data/mod/tinymce_editor/set/all/reference_editor/_nest_editor.haml +17 -0
- data/mod/tinymce_editor/set/all/reference_editor/link_editor.rb +33 -0
- data/mod/tinymce_editor/set/all/reference_editor/link_editor/link_parser.rb +35 -0
- data/mod/tinymce_editor/set/all/reference_editor/nest_editor.rb +174 -0
- data/mod/{edit/set/all → tinymce_editor/set/all/reference_editor}/nest_editor/_help.haml +0 -0
- data/mod/tinymce_editor/set/all/reference_editor/nest_editor/_options.haml +12 -0
- data/mod/{edit/set/all → tinymce_editor/set/all/reference_editor}/nest_editor/_options_select.haml +0 -0
- data/mod/{edit/set/all → tinymce_editor/set/all/reference_editor}/nest_editor/_options_select_row.haml +0 -0
- data/mod/{edit/set/all → tinymce_editor/set/all/reference_editor}/nest_editor/nest_parser.rb +7 -1
- data/mod/tinymce_editor/set/all/reference_editor/nest_image.rb +70 -0
- data/mod/tinymce_editor/set/all/reference_editor/reference_editor.haml +18 -0
- metadata +39 -21
- data/mod/account/set/abstract/accounted.rb +0 -15
- data/mod/edit/set/all/bridge/account_section.rb +0 -16
- data/mod/edit/set/all/nest_editor.rb +0 -122
- data/mod/edit/set/all/nest_editor/_options.haml +0 -12
- data/mod/edit/set/all/nest_editor/nest_editor.haml +0 -31
- data/mod/edit/set/all/nest_image.rb +0 -37
@@ -0,0 +1,88 @@
|
|
1
|
+
class Card
|
2
|
+
class Content < SimpleDelegator
|
3
|
+
# A chunk is a pattern of text that can be protected
|
4
|
+
# and interrogated by a format. Each Chunk class has a
|
5
|
+
# +pattern+ that states what sort of text it matches.
|
6
|
+
# Chunks are initalized by passing in the result of a
|
7
|
+
# match by its pattern.
|
8
|
+
#
|
9
|
+
module Chunk
|
10
|
+
class Abstract
|
11
|
+
class_attribute :config
|
12
|
+
attr_reader :text, :process_chunk
|
13
|
+
|
14
|
+
class << self
|
15
|
+
# if the prefix regex matched check that chunk against the full regex
|
16
|
+
def full_match content, prefix=nil
|
17
|
+
content.match full_re(prefix)
|
18
|
+
end
|
19
|
+
|
20
|
+
def full_re _prefix
|
21
|
+
config[:full_re]
|
22
|
+
end
|
23
|
+
|
24
|
+
def context_ok? _content, _chunk_start
|
25
|
+
true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def reference_code
|
30
|
+
"I"
|
31
|
+
end
|
32
|
+
|
33
|
+
def initialize match, content
|
34
|
+
match = self.class.full_match(match) if match.is_a? String
|
35
|
+
@text = match[0]
|
36
|
+
@processed = nil
|
37
|
+
@content = content
|
38
|
+
interpret match, content
|
39
|
+
end
|
40
|
+
|
41
|
+
def interpret _match_string, _content
|
42
|
+
Rails.logger.info "no #interpret method found for chunk class: " \
|
43
|
+
"#{self.class}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def format
|
47
|
+
@content.format
|
48
|
+
end
|
49
|
+
|
50
|
+
def card
|
51
|
+
@content.card
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_s
|
55
|
+
result
|
56
|
+
end
|
57
|
+
|
58
|
+
def result
|
59
|
+
burn_read || @process_chunk || @processed || @text
|
60
|
+
end
|
61
|
+
|
62
|
+
def burn_read
|
63
|
+
return unless @burn_read
|
64
|
+
|
65
|
+
tmp = @burn_read
|
66
|
+
@burn_read = nil
|
67
|
+
tmp
|
68
|
+
end
|
69
|
+
|
70
|
+
# Temporarily overrides the processed nest content for single-use
|
71
|
+
# After using the nest's result
|
72
|
+
# (for example via `to_s`) the original result is restored
|
73
|
+
def burn_after_reading text
|
74
|
+
@burn_read = text
|
75
|
+
end
|
76
|
+
|
77
|
+
def inspect
|
78
|
+
"<##{self.class}##{self}>"
|
79
|
+
end
|
80
|
+
|
81
|
+
def as_json _options={}
|
82
|
+
burn_read || @process_chunk || @processed ||
|
83
|
+
"not rendered #{self.class}, #{card&.name}"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
data/lib/card/content/clean.rb
CHANGED
@@ -16,7 +16,7 @@ class Card
|
|
16
16
|
"blockquote" => ["cite"]
|
17
17
|
)
|
18
18
|
|
19
|
-
if
|
19
|
+
if Cardio.config.allow_inline_styles
|
20
20
|
allowed_tags["table"] += %w[cellpadding align border cellspacing data-mce-style]
|
21
21
|
allowed_tags["td"] += %w[scope data-mce-style]
|
22
22
|
allowed_tags["th"] += %w[scope data-mce-style]
|
@@ -24,7 +24,7 @@ class Card
|
|
24
24
|
|
25
25
|
allowed_tags.each_key do |k|
|
26
26
|
allowed_tags[k] << "class"
|
27
|
-
allowed_tags[k] << "style" if
|
27
|
+
allowed_tags[k] << "style" if Cardio.config.allow_inline_styles
|
28
28
|
allowed_tags[k]
|
29
29
|
end
|
30
30
|
|
@@ -52,7 +52,7 @@ class Card
|
|
52
52
|
end.gsub(/<\!--.*?-->/, "")
|
53
53
|
end
|
54
54
|
|
55
|
-
if
|
55
|
+
if Cardio.config.space_last_in_multispace
|
56
56
|
def clean_with_space_last! string, tags=ALLOWED_TAGS
|
57
57
|
cwo = clean_without_space_last!(string, tags)
|
58
58
|
cwo.gsub(/(?:^|\b) ((?: )+)/, '\1 ')
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# require "card/content/diff/processor"
|
2
2
|
|
3
3
|
class Card
|
4
4
|
class Content
|
@@ -55,12 +55,10 @@ class Card
|
|
55
55
|
def check_exclude_and_disjunction_pattern list
|
56
56
|
list.each_with_index.each_with_object([[], []]) do |pair, res|
|
57
57
|
element, index = pair
|
58
|
-
if element.match @disjunction_pattern
|
59
|
-
res[1] << { chunk_index: index, element: element,
|
60
|
-
|
61
|
-
|
62
|
-
res[1] << { chunk_index: index, element: element, type:
|
63
|
-
:excludee }
|
58
|
+
if element.match? @disjunction_pattern
|
59
|
+
res[1] << { chunk_index: index, element: element, type: :disjunction }
|
60
|
+
elsif element.match? @exclude_pattern
|
61
|
+
res[1] << { chunk_index: index, element: element, type: :excludee }
|
64
62
|
else
|
65
63
|
res[0] << element
|
66
64
|
end
|
File without changes
|
data/lib/card/content/parser.rb
CHANGED
data/lib/card/dirty.rb
CHANGED
@@ -1,41 +1,35 @@
|
|
1
1
|
class Card
|
2
|
-
|
3
|
-
|
4
|
-
attribute_before_act field
|
5
|
-
end
|
2
|
+
module Dirty
|
3
|
+
extend ::Card::Dirty::MethodFactory
|
6
4
|
|
7
|
-
|
8
|
-
|
5
|
+
%i[name db_content trash type_id].each do |field|
|
6
|
+
define_dirty_methods field
|
9
7
|
end
|
10
|
-
end
|
11
|
-
|
12
|
-
%i[name db_content trash type_id].each do |field|
|
13
|
-
define_dirty_methods field
|
14
|
-
end
|
15
8
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
9
|
+
def attribute_before_act attr
|
10
|
+
if saved_change_to_attribute? attr
|
11
|
+
attribute_before_last_save attr
|
12
|
+
elsif will_save_change_to_attribute? attr
|
13
|
+
mutations_from_database.changed_values[attr]
|
14
|
+
elsif not_in_callback?
|
15
|
+
attribute_was attr
|
16
|
+
else
|
17
|
+
_read_attribute attr
|
18
|
+
end
|
25
19
|
end
|
26
|
-
end
|
27
20
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
21
|
+
def not_in_callback?
|
22
|
+
# or in integrate_with_delay stage
|
23
|
+
mutations_before_last_save.equal?(mutations_from_database)
|
24
|
+
end
|
32
25
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
26
|
+
def attribute_is_changing? attr
|
27
|
+
if not_in_callback?
|
28
|
+
attribute_changed? attr
|
29
|
+
else
|
30
|
+
saved_change_to_attribute?(attr) ||
|
31
|
+
will_save_change_to_attribute?(attr)
|
32
|
+
end
|
39
33
|
end
|
40
34
|
end
|
41
35
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Card
|
2
|
+
module Dirty
|
3
|
+
module MethodFactory
|
4
|
+
def define_dirty_methods field
|
5
|
+
define_method "#{field}_before_act" do
|
6
|
+
attribute_before_act field
|
7
|
+
end
|
8
|
+
|
9
|
+
define_method "#{field}_is_changing?" do
|
10
|
+
attribute_is_changing? field
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/card/env.rb
CHANGED
data/lib/card/error.rb
CHANGED
@@ -42,13 +42,17 @@ class Card
|
|
42
42
|
# error attributable to code (as opposed to card configuration)
|
43
43
|
class ServerError < Error
|
44
44
|
def self.view
|
45
|
-
|
45
|
+
debugger_on? ? :debug_server_error : :server_error
|
46
46
|
end
|
47
47
|
|
48
48
|
def self.status_code
|
49
49
|
# Errors with status code 900 are displayed as modal instead of inside
|
50
50
|
# the "card-notice" div``
|
51
|
-
|
51
|
+
debugger_on? ? 900 : 500
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.debugger_on?
|
55
|
+
Card::Codename[:debugger] && Card[:debugger]&.content =~ /on/
|
52
56
|
end
|
53
57
|
|
54
58
|
def report
|
data/lib/card/format.rb
CHANGED
@@ -10,10 +10,13 @@ class Card
|
|
10
10
|
#
|
11
11
|
# {Card::Mod} explains how to set up a mod.
|
12
12
|
# {Card::Set::Format} explains how to use this and other format classes within a mod.
|
13
|
-
# {Card::Set::
|
14
|
-
# format classes.
|
13
|
+
# {Card::Set::Format::AbstractFormat} introduces the view API, which is organized with
|
14
|
+
# these format classes.
|
15
15
|
#
|
16
16
|
class Format
|
17
|
+
extend ActiveSupport::Autoload
|
18
|
+
extend Registration
|
19
|
+
|
17
20
|
include Card::Env::Location
|
18
21
|
include Nesting
|
19
22
|
include Render
|
@@ -22,8 +25,6 @@ class Card
|
|
22
25
|
include Error
|
23
26
|
include MethodDelegation
|
24
27
|
|
25
|
-
extend Registration
|
26
|
-
|
27
28
|
cattr_accessor :registered, :aliases
|
28
29
|
self.registered = []
|
29
30
|
self.aliases = {}
|
@@ -40,7 +41,6 @@ class Card
|
|
40
41
|
require_card_to_initialize!
|
41
42
|
opts.each { |key, value| instance_variable_set "@#{key}", value }
|
42
43
|
include_set_format_modules
|
43
|
-
self
|
44
44
|
end
|
45
45
|
|
46
46
|
def require_card_to_initialize!
|
@@ -34,7 +34,8 @@ class Card
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def new_card_args
|
37
|
-
args = { name: view_opts[:nest_name]
|
37
|
+
args = { name: view_opts[:nest_name] }
|
38
|
+
args[:type] = view_opts[:type] if view_opts[:type]
|
38
39
|
args.merge(new_supercard_args)
|
39
40
|
.merge(new_main_args)
|
40
41
|
.merge(new_content_args)
|
data/lib/card/mark.rb
CHANGED
data/lib/card/migration.rb
CHANGED
data/lib/card/mod.rb
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
require_dependency "card/mod/loader"
|
2
|
-
require_dependency "card/mod/dirs"
|
3
|
-
|
4
1
|
class Card
|
5
2
|
# A Card Mod (short for "module" or "modification") is a discrete piece of Decko
|
6
3
|
# functionality. Mods are how the Decko community develops and shares code.
|
@@ -70,7 +67,7 @@ class Card
|
|
70
67
|
return if ENV["CARD_MODS"] == "none"
|
71
68
|
|
72
69
|
if Card.take
|
73
|
-
Loader.load_mods
|
70
|
+
Card::Mod::Loader.load_mods
|
74
71
|
else
|
75
72
|
Rails.logger.warn "empty database"
|
76
73
|
end
|
@@ -78,7 +75,7 @@ class Card
|
|
78
75
|
|
79
76
|
# @return an array of Rails::Path objects
|
80
77
|
def dirs
|
81
|
-
@dirs ||= Dirs.new(Card.paths["mod"].existent)
|
78
|
+
@dirs ||= Mod::Dirs.new(Card.paths["mod"].existent)
|
82
79
|
end
|
83
80
|
end
|
84
81
|
end
|
data/lib/card/mod/dirs.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
class Card
|
2
2
|
module Mod
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
# require "card/mod/load_strategy/eval"
|
4
|
+
# require "card/mod/load_strategy/pattern_tmp_files"
|
5
|
+
# require "card/mod/load_strategy/set_binding_magic"
|
6
|
+
# require "card/mod/load_strategy/set_tmp_files"
|
7
|
+
# require "card/mod/load_strategy/tmp_files"
|
8
8
|
|
9
9
|
# Shared code for the three different load strategies: Eval, TmpFiles and BindingMagic
|
10
10
|
class LoadStrategy
|
@@ -36,18 +36,29 @@ class Card
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def each_file &block
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
each_file_in_dir base_dir, pattern.to_s, &block
|
44
|
-
end
|
45
|
-
else
|
39
|
+
if module_type == :set
|
40
|
+
each_set_file(&block)
|
41
|
+
else
|
42
|
+
each_mod_dir module_type do |base_dir|
|
46
43
|
each_file_in_dir base_dir, &block
|
47
44
|
end
|
48
45
|
end
|
49
46
|
end
|
50
47
|
|
48
|
+
def each_set_file &block
|
49
|
+
each_mod_dir :set do |base_dir|
|
50
|
+
@loader.patterns.each do |pattern|
|
51
|
+
each_file_in_dir base_dir, pattern.to_s, &block
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def each_mod_dir module_type
|
57
|
+
@mod_dirs.each module_type do |base_dir|
|
58
|
+
yield base_dir
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
51
62
|
def each_file_in_dir base_dir, subdir=nil
|
52
63
|
pattern = File.join(*[base_dir, subdir, "**/*.rb"].compact)
|
53
64
|
Dir.glob(pattern).sort.each do |abs_path|
|
data/lib/card/mod/loader.rb
CHANGED
@@ -1,10 +1,5 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
|
-
require_dependency "card/set"
|
4
|
-
require_dependency "card/set_pattern"
|
5
|
-
require_dependency "card/mod/loader/set_loader"
|
6
|
-
require_dependency "card/mod/loader/set_pattern_loader"
|
7
|
-
|
8
3
|
class Card
|
9
4
|
module Mod
|
10
5
|
# Card::Mod::Loader is used to load all part of a mod,
|
@@ -17,7 +12,7 @@ class Card
|
|
17
12
|
# The mods are given by a Mod::Dirs object.
|
18
13
|
# SetLoader can use three different strategies to load the set modules.
|
19
14
|
class Loader
|
20
|
-
def initialize load_strategy
|
15
|
+
def initialize load_strategy: nil, mod_dirs: nil
|
21
16
|
load_strategy ||= Cardio.config.load_strategy
|
22
17
|
mod_dirs ||= Mod.dirs
|
23
18
|
klass = load_strategy_class load_strategy
|
@@ -40,17 +35,20 @@ class Card
|
|
40
35
|
attr_reader :module_type
|
41
36
|
|
42
37
|
def load_mods
|
43
|
-
SetPatternLoader.new.load
|
44
38
|
load_formats
|
45
|
-
|
39
|
+
Card::Mod::Loader::SetPatternLoader.new.load
|
40
|
+
Card::Mod::Loader::SetLoader.new.load
|
41
|
+
Card::Set.process_base_modules
|
46
42
|
load_initializers
|
47
|
-
# rescue
|
48
|
-
# raise Card::Error, "unrescued error loading mods"
|
49
43
|
end
|
50
44
|
|
51
|
-
def
|
45
|
+
def reload_sets
|
52
46
|
Card::Set::Pattern.reset
|
53
|
-
|
47
|
+
Card::Set.reset_modules
|
48
|
+
Card::Mod::Loader::SetPatternLoader.new.load
|
49
|
+
Card::Mod::Loader::SetLoader.new(
|
50
|
+
patterns: Card::Set::Pattern.nonbase_loadable_codes
|
51
|
+
).load
|
54
52
|
end
|
55
53
|
|
56
54
|
def load_chunks
|
@@ -84,7 +82,9 @@ class Card
|
|
84
82
|
def load_dir dir
|
85
83
|
Dir["#{dir}/*.rb"].sort.each do |file|
|
86
84
|
# puts Benchmark.measure("from #load_dir: rd: #{file}") {
|
87
|
-
|
85
|
+
# require file
|
86
|
+
# "require" breaks the reloading in development env
|
87
|
+
load file
|
88
88
|
# }.format('%n: %t %r')
|
89
89
|
end
|
90
90
|
end
|