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
@@ -1,6 +1,6 @@
|
|
1
1
|
module ClassMethods
|
2
2
|
def update_all_storage_locations
|
3
|
-
Card.search(type_id: ["in", FileID, ImageID])
|
3
|
+
Card.search(type_id: ["in", Card::FileID, Card::ImageID])
|
4
4
|
.each(&:update_storage_location!)
|
5
5
|
end
|
6
6
|
|
@@ -34,4 +34,8 @@ module ClassMethods
|
|
34
34
|
"AND card_actions.draft = true"
|
35
35
|
)
|
36
36
|
end
|
37
|
+
|
38
|
+
def count_cards_with_attachment
|
39
|
+
Card.search type_id: ["in", Card::FileID, Card::ImageID], return: :count
|
40
|
+
end
|
37
41
|
end
|
@@ -4,7 +4,7 @@ add_to_basket(
|
|
4
4
|
execute_policy: -> { Card.update_all_storage_locations },
|
5
5
|
stats: {
|
6
6
|
title: "cards with attachment",
|
7
|
-
count: -> { Card.
|
7
|
+
count: -> { Card.count_cards_with_attachment }
|
8
8
|
# link_text: "update storage locations",
|
9
9
|
# task: "update_file_storage_locations"
|
10
10
|
}
|
data/mod/core/chunk/link.rb
CHANGED
@@ -1,113 +1,121 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
module Card::Content::Chunk
|
6
|
-
class Link < Reference
|
7
|
-
CODE = "L".freeze # L for "Link"
|
8
|
-
attr_reader :link_text
|
9
|
-
# Groups: $1, [$2]: [[$1]] or [[$1|$2]] or $3, $4: [$3][$4]
|
10
|
-
Card::Content::Chunk.register_class self,
|
11
|
-
prefix_re: '\\[\\[',
|
12
|
-
full_re: /\A\[\[([^\]]+)\]\]/,
|
13
|
-
idx_char: "["
|
14
|
-
def reference_code
|
15
|
-
CODE
|
16
|
-
end
|
3
|
+
# require File.expand_path("../reference", __FILE__)
|
4
|
+
load File.expand_path("../reference.rb", __FILE__)
|
17
5
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
6
|
+
class Card
|
7
|
+
class Content
|
8
|
+
module Chunk
|
9
|
+
# extend ActiveSupport::Autoload
|
10
|
+
# autoload :Reference , "reference"
|
11
|
+
|
12
|
+
class Link < Card::Content::Chunk::Reference
|
13
|
+
CODE = "L".freeze # L for "Link"
|
14
|
+
attr_reader :link_text
|
15
|
+
# Groups: $1, [$2]: [[$1]] or [[$1|$2]] or $3, $4: [$3][$4]
|
16
|
+
Card::Content::Chunk.register_class self,
|
17
|
+
prefix_re: '\\[\\[',
|
18
|
+
full_re: /\A\[\[([^\]]+)\]\]/,
|
19
|
+
idx_char: "["
|
20
|
+
def reference_code
|
21
|
+
CODE
|
26
22
|
end
|
27
23
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
24
|
+
def interpret match, _content
|
25
|
+
target, @link_text =
|
26
|
+
if (raw_syntax = match[1])
|
27
|
+
if (i = divider_index(raw_syntax)) # [[A | B]]
|
28
|
+
[raw_syntax[0..(i - 1)], raw_syntax[(i + 1)..-1]]
|
29
|
+
else # [[ A ]]
|
30
|
+
[raw_syntax, nil]
|
31
|
+
end
|
32
|
+
end
|
35
33
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
44
|
-
string_copy.index "|"
|
45
|
-
end
|
34
|
+
@link_text = objectify @link_text
|
35
|
+
if target.match? %r{^(/|https?:|mailto:)}
|
36
|
+
@explicit_link = objectify target
|
37
|
+
else
|
38
|
+
@name = target
|
39
|
+
end
|
40
|
+
end
|
46
41
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
42
|
+
def divider_index string
|
43
|
+
# there's probably a better way to do the following.
|
44
|
+
# point is to find the first pipe that's not inside an nest
|
45
|
+
return unless string.index "|"
|
46
|
+
string_copy = string.dup
|
47
|
+
string.scan(/\{\{[^\}]*\}\}/) do |incl|
|
48
|
+
string_copy.gsub! incl, ("x" * incl.length)
|
49
|
+
end
|
50
|
+
string_copy.index "|"
|
51
|
+
end
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
53
|
+
# view options
|
54
|
+
def options
|
55
|
+
link_text ? { title: link_text } : {}
|
56
|
+
end
|
57
|
+
|
58
|
+
def objectify raw
|
59
|
+
return unless raw
|
60
|
+
raw.strip!
|
61
|
+
if raw =~ /(^|[^\\])\{\{/
|
62
|
+
Card::Content.new raw, format
|
63
|
+
else
|
64
|
+
raw
|
65
|
+
end
|
66
|
+
end
|
61
67
|
|
62
|
-
|
63
|
-
|
68
|
+
def render_link view: :link, explicit_link_opts: {}
|
69
|
+
@link_text = render_obj @link_text
|
64
70
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
+
if @explicit_link
|
72
|
+
@explicit_link = render_obj @explicit_link
|
73
|
+
format.link_to_resource @explicit_link, @link_text, explicit_link_opts
|
74
|
+
elsif @name
|
75
|
+
format.with_nest_mode :normal do
|
76
|
+
format.nest referee_name, options.merge(view: view)
|
77
|
+
end
|
78
|
+
end
|
71
79
|
end
|
72
|
-
end
|
73
|
-
end
|
74
80
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
81
|
+
def link_target
|
82
|
+
if @explicit_link
|
83
|
+
render_obj @explicit_link
|
84
|
+
elsif @name
|
85
|
+
referee_name
|
86
|
+
end
|
87
|
+
end
|
82
88
|
|
83
|
-
|
84
|
-
|
85
|
-
|
89
|
+
def process_chunk
|
90
|
+
@process_chunk ||= render_link
|
91
|
+
end
|
86
92
|
|
87
|
-
|
88
|
-
|
93
|
+
def inspect
|
94
|
+
"<##{self.class}:e[#{@explicit_link}]n[#{@name}]l[#{@link_text}]" \
|
89
95
|
"p[#{@process_chunk}] txt:#{@text}>"
|
90
|
-
|
96
|
+
end
|
91
97
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
+
def replace_reference old_name, new_name
|
99
|
+
replace_name_reference old_name, new_name
|
100
|
+
replace_link_text old_name, new_name
|
101
|
+
@text =
|
102
|
+
@link_text.nil? ? "[[#{referee_name}]]" : "[[#{referee_name}|#{@link_text}]]"
|
103
|
+
end
|
98
104
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
105
|
+
def replace_link_text old_name, new_name
|
106
|
+
if @link_text.is_a?(Card::Content)
|
107
|
+
@link_text.find_chunks(Card::Content::Chunk::Reference).each do |chunk|
|
108
|
+
chunk.replace_reference old_name, new_name
|
109
|
+
end
|
110
|
+
elsif @link_text.present?
|
111
|
+
@link_text = old_name.to_name.sub_in(@link_text, with: new_name)
|
112
|
+
end
|
103
113
|
end
|
104
|
-
elsif @link_text.present?
|
105
|
-
@link_text = old_name.to_name.sub_in(@link_text, with: new_name)
|
106
|
-
end
|
107
|
-
end
|
108
114
|
|
109
|
-
|
110
|
-
|
115
|
+
def explicit_link?
|
116
|
+
@explicit_link
|
117
|
+
end
|
118
|
+
end
|
111
119
|
end
|
112
120
|
end
|
113
121
|
end
|
data/mod/core/chunk/nest.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
|
-
|
3
|
+
# require File.expand_path("../reference", __FILE__)
|
4
4
|
|
5
5
|
class Card
|
6
6
|
class Content
|
@@ -11,7 +11,7 @@ class Card
|
|
11
11
|
DEFAULT_OPTION = :view # a value without a key is interpreted as view
|
12
12
|
|
13
13
|
Chunk.register_class(self, prefix_re: '\\{\\{',
|
14
|
-
full_re: /\A\{\{([^\}]*)\}\}/,
|
14
|
+
full_re: /\A\{\{([^\{\}]*)\}\}/,
|
15
15
|
idx_char: "{")
|
16
16
|
|
17
17
|
def interpret match, _content
|
@@ -1,90 +1,95 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
|
-
|
3
|
+
class Card
|
4
|
+
class Content
|
5
|
+
module Chunk
|
6
|
+
# This should find +Alfred+ in expressions like
|
7
|
+
# 1) {"name":"Alfred"}
|
8
|
+
# 2a) {"name":["in","Alfred"]}
|
9
|
+
# 3a) {"plus_right":["Alfred"]}
|
10
|
+
# but not in
|
11
|
+
# 2b) "content":"foo", "Alfred":"bar"
|
12
|
+
# 3b) {"name":["Alfred", "Toni"]} ("Alfred" is an operator here)
|
13
|
+
# It's not possible to distinguish between 2a) and 2b) or 3a) and 3b) with a
|
14
|
+
# simple regex, hence we use a too general regex and check for query keywords
|
15
|
+
# after the match, which of course means that we don't find references with
|
16
|
+
# query keywords as name
|
4
17
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
# query keywords as name
|
18
|
+
require File.expand_path("reference", __dir__)
|
19
|
+
class QueryReference < Reference
|
20
|
+
QUERY_KEYWORDS = ::Set.new(
|
21
|
+
(
|
22
|
+
::Card::Query::MODIFIERS.keys +
|
23
|
+
::Card::Query::OPERATORS.keys +
|
24
|
+
::Card::Query::ATTRIBUTES.keys +
|
25
|
+
::Card::Query::CONJUNCTIONS.keys +
|
26
|
+
%w[desc asc count]
|
27
|
+
).map(&:to_s)
|
28
|
+
)
|
17
29
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
)
|
30
|
+
Card::Content::Chunk.register_class(
|
31
|
+
self, prefix_re: '(?<=[:,\\[])\\s*"',
|
32
|
+
# we check for colon, comma or square bracket before a quote
|
33
|
+
# we have to use a lookbehind, otherwise
|
34
|
+
# if the colon matches it would be
|
35
|
+
# identified mistakenly as an URI chunk
|
36
|
+
full_re: /\A\s*"([^"]+)"/,
|
37
|
+
idx_char: '"'
|
38
|
+
)
|
28
39
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
)
|
40
|
+
# OPTIMIZE: instead of comma or square bracket check for operator followed
|
41
|
+
# by comma or "plus_right"|"plus_left"|"plus" followed by square bracket
|
42
|
+
# something like
|
43
|
+
# prefix_patterns = [
|
44
|
+
# "\"\\s*(?:#{Card::Query::OPERATORS.keys.join('|')})\"\\s*,",
|
45
|
+
# "\"\\s*(?:#{Card::Query::PLUS_ATTRIBUTES}.keys
|
46
|
+
# .join('|')})\\s*:\\s*\\[\\s*",
|
47
|
+
# "\"\\s*(?:#{(QUERY_KEYWORDS - Card::Query::PLUS_ATTRIBUTES)
|
48
|
+
# .join('|')})\"\\s*:",
|
49
|
+
# ]
|
50
|
+
# prefix_re: '(?<=#{prefix_patterns.join('|')})\\s*"'
|
51
|
+
# But: What do we do with the "in" operator? After the first value there is
|
52
|
+
# no prefix which we can use to detect the following values as
|
53
|
+
# QueryReference chunks
|
38
54
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
# .join('|')})\\s*:\\s*\\[\\s*",
|
46
|
-
# "\"\\s*(?:#{(QUERY_KEYWORDS - Card::Query::PLUS_ATTRIBUTES)
|
47
|
-
# .join('|')})\"\\s*:",
|
48
|
-
# ]
|
49
|
-
# prefix_re: '(?<=#{prefix_patterns.join('|')})\\s*"'
|
50
|
-
# But: What do we do with the "in" operator? After the first value there is
|
51
|
-
# no prefix which we can use to detect the following values as
|
52
|
-
# QueryReference chunks
|
55
|
+
class << self
|
56
|
+
def full_match content, prefix
|
57
|
+
# matches cardnames that are not keywords
|
58
|
+
# FIXME: would not match cardnames that are keywords
|
59
|
+
match, offset = super(content, prefix)
|
60
|
+
return if !match || keyword?(match[1])
|
53
61
|
|
54
|
-
|
55
|
-
|
56
|
-
# matches cardnames that are not keywords
|
57
|
-
# FIXME: would not match cardnames that are keywords
|
58
|
-
match, offset = super(content, prefix)
|
59
|
-
return if !match || keyword?(match[1])
|
60
|
-
[match, offset]
|
61
|
-
end
|
62
|
+
[match, offset]
|
63
|
+
end
|
62
64
|
|
63
|
-
|
64
|
-
|
65
|
-
QUERY_KEYWORDS.include?(str.tr(" ", "_").downcase)
|
66
|
-
end
|
67
|
-
end
|
65
|
+
def keyword? str
|
66
|
+
return unless str
|
68
67
|
|
69
|
-
|
70
|
-
|
71
|
-
|
68
|
+
QUERY_KEYWORDS.include?(str.tr(" ", "_").downcase)
|
69
|
+
end
|
70
|
+
end
|
72
71
|
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
def interpret match, _content
|
73
|
+
@name = match[1]
|
74
|
+
end
|
76
75
|
|
77
|
-
|
78
|
-
|
79
|
-
|
76
|
+
def process_chunk
|
77
|
+
@process_chunk ||= @text
|
78
|
+
end
|
80
79
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
80
|
+
def inspect
|
81
|
+
"<##{self.class}:n[#{@name}] p[#{@process_chunk}] txt:#{@text}>"
|
82
|
+
end
|
85
83
|
|
86
|
-
|
87
|
-
|
84
|
+
def replace_reference old_name, new_name
|
85
|
+
replace_name_reference old_name, new_name
|
86
|
+
@text = "\"#{@name}\""
|
87
|
+
end
|
88
|
+
|
89
|
+
def reference_code
|
90
|
+
"Q" # for "Query"
|
91
|
+
end
|
92
|
+
end
|
88
93
|
end
|
89
94
|
end
|
90
95
|
end
|
data/mod/core/chunk/view_stub.rb
CHANGED
@@ -16,10 +16,19 @@ class Card
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def interpret match, _content
|
19
|
-
@stub_hash =
|
19
|
+
@stub_hash = initial_stub_hash match[1]
|
20
20
|
interpret_hash_values
|
21
21
|
end
|
22
22
|
|
23
|
+
def initial_stub_hash string
|
24
|
+
JSON.parse(string).symbolize_keys
|
25
|
+
# MessagePack.unpack(hex_to_bin(string)).symbolize_keys
|
26
|
+
end
|
27
|
+
|
28
|
+
def hex_to_bin string
|
29
|
+
string.scan(/../).map { |x| x.hex.chr }.join
|
30
|
+
end
|
31
|
+
|
23
32
|
def interpret_hash_values
|
24
33
|
@stub_hash.keys.each do |key|
|
25
34
|
send "interpret_#{key}"
|