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
@@ -5,7 +5,7 @@ module ClassMethods
|
|
5
5
|
if card
|
6
6
|
card.update_columns trash: true
|
7
7
|
card.expire
|
8
|
-
Card::Virtual.where(right_id: MachineCacheID).delete_all
|
8
|
+
Card::Virtual.where(right_id: Card::MachineCacheID).delete_all
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -16,7 +16,7 @@ module ClassMethods
|
|
16
16
|
card.update_columns trash: true
|
17
17
|
card.expire
|
18
18
|
end
|
19
|
-
Card::Virtual.where(right_id: MachineCacheID).delete_all
|
19
|
+
Card::Virtual.where(right_id: Card::MachineCacheID).delete_all
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -4,6 +4,7 @@ def source_files
|
|
4
4
|
%w[mod editor name_editor autosave doubleclick layout navbox upload
|
5
5
|
slot modal overlay recaptcha slotter bridge
|
6
6
|
nest_editor nest_editor_rules nest_editor_options nest_editor_name
|
7
|
+
link_editor
|
7
8
|
components decko follow card_menu slot_ready
|
8
9
|
filter filter_links filter_items].map do |n|
|
9
10
|
"decko/#{n}.js.coffee"
|
data/mod/media/set/type/image.rb
CHANGED
@@ -8,11 +8,15 @@ format :html do
|
|
8
8
|
split_button link_to_mycard, nil do
|
9
9
|
[
|
10
10
|
link_to_card([Auth.current, :account_settings], "Account"),
|
11
|
-
(["Roles", role_items(&render_role_item)]
|
11
|
+
(["Roles", role_items(&render_role_item)] if special_roles?)
|
12
12
|
]
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
def special_roles?
|
17
|
+
Auth.current_roles.size > 1
|
18
|
+
end
|
19
|
+
|
16
20
|
def role_items
|
17
21
|
Auth.current_roles.map do |role_name|
|
18
22
|
yield role_name
|
@@ -22,29 +22,49 @@ end
|
|
22
22
|
# it' still pointer content. The "when" clause helps with that (but is a hack)
|
23
23
|
event :standardize_items, :prepare_to_validate,
|
24
24
|
on: :save, changed: :content, when: :still_pointer? do
|
25
|
-
|
26
|
-
"[[#{name}]]"
|
27
|
-
end.join "\n"
|
25
|
+
items_to_content item_strings
|
28
26
|
end
|
29
27
|
|
30
28
|
def still_pointer?
|
31
29
|
type_id == Card::PointerID
|
32
30
|
end
|
33
31
|
|
34
|
-
|
32
|
+
def changed_item_names
|
35
33
|
dropped_item_names + added_item_names
|
36
34
|
end
|
37
35
|
|
38
|
-
|
39
|
-
|
36
|
+
def dropped_item_names
|
37
|
+
return item_names if trash
|
38
|
+
return [] unless (old_content = db_content_before_act)
|
39
|
+
|
40
|
+
old_items = item_names content: old_content
|
40
41
|
old_items - item_names
|
41
42
|
end
|
42
43
|
|
43
|
-
|
44
|
-
|
44
|
+
def added_item_names
|
45
|
+
return [] if trash
|
46
|
+
return item_names unless (old_content = db_content_before_act)
|
47
|
+
|
48
|
+
old_items = item_names content: old_content
|
45
49
|
item_names - old_items
|
46
50
|
end
|
47
51
|
|
48
|
-
|
49
|
-
|
52
|
+
# TODO: refactor. many of the above could be written more elegantly with improved
|
53
|
+
# handling of :content in item_names. If content is nil here, we would expect an
|
54
|
+
# empty set of cards, but in fact we get items based on self.content.
|
55
|
+
|
56
|
+
def changed_item_cards
|
57
|
+
dropped_item_cards + added_item_cards
|
58
|
+
end
|
59
|
+
|
60
|
+
def dropped_item_cards
|
61
|
+
return [] unless db_content_before_act
|
62
|
+
|
63
|
+
all_item_cards item_names: dropped_item_names
|
64
|
+
end
|
65
|
+
|
66
|
+
def added_item_cards
|
67
|
+
return item_cards unless db_content_before_act
|
68
|
+
|
69
|
+
all_item_cards item_names: added_item_names
|
50
70
|
end
|
@@ -98,14 +98,18 @@ format :html do
|
|
98
98
|
slot_selector: filtered_list_slot_class,
|
99
99
|
item_selector: "_filtered-list-item",
|
100
100
|
slot: { hide: [:modal_footer] },
|
101
|
-
filter: { not_ids:
|
101
|
+
filter: { not_ids: not_ids_value } }
|
102
|
+
end
|
103
|
+
|
104
|
+
def not_ids_value
|
105
|
+
card.item_ids.map(&:to_s).join(",")
|
102
106
|
end
|
103
107
|
|
104
108
|
def add_item_overlay_link; end
|
105
109
|
|
106
110
|
def one_line_content
|
107
111
|
if count == 1
|
108
|
-
card.
|
112
|
+
card.first_name
|
109
113
|
else
|
110
114
|
short_content
|
111
115
|
end
|
@@ -13,11 +13,24 @@
|
|
13
13
|
# @option args [String, Integer] :limit max number of cards to return
|
14
14
|
# @option args [String, Integer] :offset begin after the offset-th item
|
15
15
|
def item_names args={}
|
16
|
-
|
17
|
-
|
16
|
+
context = args[:context]
|
17
|
+
item_strings(args).map do |item|
|
18
|
+
clean_item_name item, context
|
18
19
|
end.compact
|
19
20
|
end
|
20
21
|
|
22
|
+
def first_name args={}
|
23
|
+
item_names(args).first
|
24
|
+
end
|
25
|
+
|
26
|
+
def first_card args={}
|
27
|
+
fetch_item_card first_name, args
|
28
|
+
end
|
29
|
+
|
30
|
+
def first_code
|
31
|
+
first_card&.codename
|
32
|
+
end
|
33
|
+
|
21
34
|
# @return [Array] list of integers (card ids of items)
|
22
35
|
# @param args [Hash] see #item_names
|
23
36
|
def item_ids args={}
|
@@ -47,23 +60,24 @@ end
|
|
47
60
|
# set card content based on array and save card
|
48
61
|
# @param array [Array] list of strings/names (Cardish)
|
49
62
|
def items= array
|
50
|
-
|
51
|
-
array.each { |i| self << i }
|
63
|
+
items_to_content array
|
52
64
|
save!
|
53
65
|
end
|
54
66
|
|
55
67
|
# append item to list (does not save)
|
56
68
|
# @param item [Cardish]
|
57
|
-
def <<
|
58
|
-
add_item
|
69
|
+
def << cardish
|
70
|
+
add_item cardish
|
59
71
|
end
|
60
72
|
|
61
73
|
# append item to list (does not save)
|
62
|
-
# @param
|
74
|
+
# @param cardish [String, Card::Name] item name
|
63
75
|
# @param allow_duplicates [True/False] permit duplicate items (default is False)
|
64
|
-
def add_item
|
65
|
-
return if !allow_duplicates && include_item?(
|
66
|
-
|
76
|
+
def add_item cardish, allow_duplicates=false
|
77
|
+
return if !allow_duplicates && include_item?(cardish)
|
78
|
+
|
79
|
+
items = item_strings << cardish
|
80
|
+
items_to_content items
|
67
81
|
end
|
68
82
|
|
69
83
|
# append item to list and save card
|
@@ -74,11 +88,9 @@ end
|
|
74
88
|
|
75
89
|
# remove item from list
|
76
90
|
# @param name [String, Card::Name] item name
|
77
|
-
def drop_item
|
78
|
-
|
79
|
-
|
80
|
-
new_names = item_names.reject { |n| n.to_name.key == key }
|
81
|
-
self.content = new_names.empty? ? "" : "[[#{new_names * "]]\n[["}]]"
|
91
|
+
def drop_item cardish
|
92
|
+
drop_item_name = Card::Name[cardish]
|
93
|
+
items_to_content(item_names.reject { |item_name| item_name == drop_item_name })
|
82
94
|
end
|
83
95
|
|
84
96
|
# remove item from list and save card
|
@@ -95,7 +107,7 @@ def insert_item index, name
|
|
95
107
|
new_names = item_names
|
96
108
|
new_names.delete name
|
97
109
|
new_names.insert index, name
|
98
|
-
|
110
|
+
items_to_content new_names
|
99
111
|
end
|
100
112
|
|
101
113
|
# insert item into list at specified location and save
|
@@ -121,14 +133,8 @@ def known_item_cards args={}
|
|
121
133
|
end
|
122
134
|
|
123
135
|
def all_item_cards args={}
|
124
|
-
item_names(args)
|
125
|
-
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
def new_unknown_item_args args
|
130
|
-
itype = args[:type] || item_type
|
131
|
-
itype ? { type: itype } : {}
|
136
|
+
names = args[:item_names] || item_names(args)
|
137
|
+
names.map { |name| fetch_item_card name, args }
|
132
138
|
end
|
133
139
|
|
134
140
|
# TODO: support type_code and type_id. (currently type)
|
@@ -140,24 +146,38 @@ def item_type
|
|
140
146
|
opt.item_type
|
141
147
|
end
|
142
148
|
|
143
|
-
|
149
|
+
def item_strings args={}
|
150
|
+
items = raw_item_strings(args[:content] || content)
|
151
|
+
return items unless args.present?
|
152
|
+
|
153
|
+
filtered_items items, args.slice(:limit, :offset)
|
154
|
+
end
|
155
|
+
|
156
|
+
def raw_item_strings content
|
157
|
+
content.to_s.split(/\n+/).map { |i| strip_item i }
|
158
|
+
end
|
159
|
+
|
160
|
+
private
|
144
161
|
|
145
|
-
def
|
146
|
-
items = all_raw_item_strings content
|
162
|
+
def filtered_items items, limit: 0, offset: 0
|
147
163
|
limit = limit.to_i
|
148
164
|
offset = offset.to_i
|
149
165
|
return items unless limit.positive? || offset.positive?
|
166
|
+
|
150
167
|
items[offset, (limit.zero? ? items.size : limit)] || []
|
151
168
|
end
|
152
169
|
|
153
|
-
def
|
154
|
-
|
170
|
+
def fetch_item_card name, args={}
|
171
|
+
Card.fetch name, new: new_unknown_item_args(args)
|
155
172
|
end
|
156
173
|
|
157
|
-
|
174
|
+
def new_unknown_item_args args
|
175
|
+
itype = args[:type] || item_type
|
176
|
+
itype ? { type: itype } : {}
|
177
|
+
end
|
158
178
|
|
159
179
|
def clean_item_name item, context
|
160
|
-
item =
|
180
|
+
item = item.to_name
|
161
181
|
return item if context == :raw
|
162
182
|
context ||= context_card.name
|
163
183
|
item.absolute_name context
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# store items as ids, not names
|
2
|
+
|
3
|
+
def standardize_item cardish
|
4
|
+
if (id = Card.fetch_id cardish)
|
5
|
+
"~#{id}"
|
6
|
+
else
|
7
|
+
Rails.logger.info "no id for '#{cardish}' added to id pointer"
|
8
|
+
nil
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def item_ids args={}
|
13
|
+
item_strings(args).map do |item|
|
14
|
+
item = standardize_item item unless item.match?(/^~/)
|
15
|
+
item.to_s.tr("~", "").to_i
|
16
|
+
end.compact
|
17
|
+
end
|
18
|
+
|
19
|
+
def item_names args={}
|
20
|
+
item_ids(args).map(&:cardname).compact
|
21
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
include_set Abstract::Pointer
|
2
2
|
|
3
3
|
event :validate_listed_by_name, :validate, on: :save, changing: :name do
|
4
|
-
if !junction? || !right || right.type_id != CardtypeID
|
4
|
+
if !junction? || !right || right.type_id != Card::CardtypeID
|
5
5
|
errors.add :name, tr(:cardtype_right)
|
6
6
|
end
|
7
7
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
include_set Abstract::Pointer
|
2
2
|
|
3
3
|
event :validate_list_name, :validate, on: :save, changed: :name do
|
4
|
-
errors.add :name, tr(:cardtype_right) unless right&.type_id == CardtypeID
|
4
|
+
errors.add :name, tr(:cardtype_right) unless right&.type_id == Card::CardtypeID
|
5
5
|
end
|
6
6
|
|
7
7
|
event :validate_list_item_type_change, :validate,
|
@@ -30,7 +30,7 @@ event :create_listed_by_cards, :prepare_to_validate,
|
|
30
30
|
listed_by_name = "#{item_name}+#{left.type_name}"
|
31
31
|
next if director.main_director.card.key == listed_by_name.to_name.key
|
32
32
|
if !Card[listed_by_name]
|
33
|
-
add_subcard listed_by_name, type_id: MirrorListID
|
33
|
+
add_subcard listed_by_name, type_id: Card::MirrorListID
|
34
34
|
else
|
35
35
|
Card[listed_by_name].update_references_out
|
36
36
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
RSpec.describe Card::Set::Abstract::PagingParams do
|
2
2
|
describe "offset_param" do
|
3
3
|
it "doesn't allow anonymous users to use extremely high values" do
|
4
|
-
Card::Auth.
|
4
|
+
Card::Auth.signin Card::AnonymousID
|
5
5
|
with_params offset: 10_000 do
|
6
6
|
expect { Card[:all].format(:json).offset_param }
|
7
7
|
.to raise_error(Card::Error::PermissionDenied,
|
@@ -13,17 +13,12 @@ def human?
|
|
13
13
|
add_recaptcha_errors result["error-codes"]
|
14
14
|
end
|
15
15
|
|
16
|
-
def consider_recaptcha?
|
17
|
-
true
|
18
|
-
end
|
19
|
-
|
20
16
|
def recaptcha_on?
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
!Auth.
|
17
|
+
recaptcha_keys? &&
|
18
|
+
Env[:controller] &&
|
19
|
+
!Auth.signed_in? &&
|
20
|
+
!Auth.always_ok? &&
|
25
21
|
!Auth.needs_setup? &&
|
26
|
-
!Auth.always_ok? &&
|
27
22
|
Card.toggle(rule(:captcha))
|
28
23
|
end
|
29
24
|
|