card 1.20.4 → 1.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/card.gemspec +9 -9
- data/db/migrate_core_cards/20170515101262_add_advanced_edit_cards.rb +20 -0
- data/db/migrate_core_cards/20170608083819_add_full_width_layout_card.rb +23 -0
- data/db/migrate_core_cards/20170608200649_add_input_options_codename.rb +8 -0
- data/db/seed/new/card_actions.yml +783 -791
- data/db/seed/new/card_acts.yml +65 -47
- data/db/seed/new/card_changes.yml +3198 -3177
- data/db/seed/new/card_references.yml +604 -534
- data/db/seed/new/cards.yml +2355 -2256
- data/db/seed/test/fixtures/card_actions.yml +1795 -1803
- data/db/seed/test/fixtures/card_acts.yml +264 -246
- data/db/seed/test/fixtures/card_changes.yml +6275 -6184
- data/db/seed/test/fixtures/card_references.yml +1305 -1263
- data/db/seed/test/fixtures/cards.yml +3393 -3298
- data/db/seed/test/seed.rb +2 -2
- data/db/version_core_cards.txt +1 -1
- data/lib/card.rb +4 -0
- data/lib/card/act_manager/subdirector_array.rb +1 -0
- data/lib/card/auth/current.rb +7 -3
- data/lib/card/env.rb +5 -0
- data/lib/card/env/success.rb +1 -1
- data/lib/card/format/names.rb +3 -13
- data/lib/card/model/save_helper.rb +4 -6
- data/lib/card/query.rb +2 -1
- data/lib/card/query/attributes.rb +34 -14
- data/lib/card/query/value.rb +3 -4
- data/lib/card/set/format.rb +29 -4
- data/lib/card/set/format/haml_views.rb +25 -13
- data/lib/card/set/trait.rb +1 -0
- data/lib/card/set_pattern.rb +17 -1
- data/lib/card/subcards.rb +3 -2
- data/lib/generators/card/format/format_generator.rb +2 -0
- data/lib/generators/card/set/set_generator.rb +2 -0
- data/lib/generators/card/template/USAGE +10 -0
- data/lib/generators/card/template/template_generator.rb +46 -0
- data/lib/generators/card/template/templates/haml_template.erb +1 -0
- data/mod/Modfile +1 -1
- data/mod/account/set/all/account.rb +9 -5
- data/mod/account/set/right/account.rb +17 -5
- data/mod/account/set/self/account_links.rb +1 -2
- data/mod/account/set/type/signup.rb +4 -5
- data/mod/account/set/type/user.rb +1 -1
- data/mod/account/spec/set/all/account_spec.rb +2 -2
- data/mod/account/spec/set/right/account_spec.rb +2 -2
- data/mod/account/spec/set/right/email_spec.rb +1 -1
- data/mod/account/spec/set/right/password_spec.rb +1 -1
- data/mod/account/spec/set/self/signin_spec.rb +2 -2
- data/mod/account/spec/set/type/signup_spec.rb +4 -0
- data/mod/ace_editor/set/abstract/ace_editor.rb +6 -3
- data/mod/ace_editor/set/self/script_ace.rb +1 -0
- data/mod/admin/set/self/admin.rb +1 -1
- data/mod/admin/set/self/version.rb +1 -0
- data/mod/basic_formats/format/css_format.rb +1 -0
- data/mod/basic_formats/format/csv_format.rb +1 -0
- data/mod/basic_formats/format/file_format.rb +1 -0
- data/mod/basic_formats/format/js_format.rb +1 -0
- data/mod/basic_formats/format/json_format.rb +1 -0
- data/mod/basic_formats/format/rss_format.rb +1 -0
- data/mod/basic_formats/format/xml_format.rb +1 -0
- data/mod/basic_formats/set/all/all_csv.rb +1 -1
- data/mod/basic_formats/set/all/base.rb +11 -3
- data/mod/basic_formats/set/all/json.rb +50 -8
- data/mod/basic_formats/set/all/rss.rb +21 -7
- data/mod/basic_formats/set/self/01_head/javascript.rb +1 -1
- data/mod/basic_formats/set/self/head.rb +1 -1
- data/mod/basic_formats/spec/set/all/base_spec.rb +13 -0
- data/mod/basic_types/set/type/html.rb +6 -2
- data/mod/basic_types/set/type/plain_text.rb +2 -3
- data/mod/bootstrap/lib/bootstrap.rb +2 -2
- data/mod/bootstrap/lib/bootstrap/basic_tags.rb +1 -1
- data/mod/bootstrap/lib/bootstrap/component.rb +2 -3
- data/mod/bootstrap/lib/bootstrap/component/form.rb +6 -5
- data/mod/bootstrap/lib/bootstrap/component/horizontal_form.rb +1 -1
- data/mod/bootstrap/lib/bootstrap/component/layout.rb +3 -3
- data/mod/bootstrap/lib/bootstrap/component_loader.rb +0 -2
- data/mod/bootstrap/lib/bootstrap/delegate.rb +2 -2
- data/mod/bootstrap/lib/bootstrapper.rb +1 -1
- data/mod/bootstrap/set/all/bootstrap/accordion.rb +1 -1
- data/mod/bootstrap/set/all/bootstrap/form.rb +2 -2
- data/mod/bootstrap/set/all/bootstrap/helper.rb +1 -0
- data/mod/bootstrap/set/all/bootstrap/wrapper.rb +1 -1
- data/mod/bootstrap/set/self/bootstrap_js.rb +1 -1
- data/mod/bootstrap/set/self/bootswatch_shared.rb +6 -6
- data/mod/bootstrap/set/self/script_mods.rb +1 -1
- data/mod/bootstrap/spec/set/all/bootstrap/bootstrap_builder_spec.rb +7 -6
- data/mod/bootstrap/spec/set/all/bootstrap/bootstrap_spec.rb +2 -1
- data/mod/bootstrap/spec/set/all/bootstrap/form_spec.rb +6 -3
- data/mod/bootstrap/spec/set/all/bootstrap/layout_spec.rb +3 -2
- data/mod/carrierwave/set/abstract/attachment.rb +1 -3
- data/mod/carrierwave/set/abstract/attachment/paths.rb +1 -1
- data/mod/carrierwave/set/abstract/attachment/storage_type.rb +11 -1
- data/mod/carrierwave/set/type/file.rb +3 -3
- data/mod/carrierwave/spec/lib/carrier_wave/file_card_uploader_spec.rb +3 -0
- data/mod/carrierwave/spec/set/type/file_spec.rb +24 -6
- data/mod/carrierwave/spec/set/type/image_spec.rb +3 -0
- data/mod/core/chunk/link.rb +1 -1
- data/mod/core/chunk/nest.rb +2 -1
- data/mod/core/chunk/query_reference.rb +1 -1
- data/mod/core/chunk/reference.rb +1 -0
- data/mod/core/chunk/uri.rb +4 -3
- data/mod/core/set/abstract/lock.rb +26 -0
- data/mod/core/set/all/assign_attributes.rb +8 -4
- data/mod/core/set/all/collection.rb +16 -7
- data/mod/core/set/all/content.rb +6 -0
- data/mod/core/set/all/event.rb +1 -1
- data/mod/core/set/all/fetch.rb +2 -2
- data/mod/core/set/all/haml.rb +5 -15
- data/mod/core/set/all/initialize.rb +2 -2
- data/mod/core/set/all/name.rb +1 -1
- data/mod/core/set/all/permissions.rb +28 -16
- data/mod/core/set/all/rules.rb +1 -2
- data/mod/core/set/all/subcards.rb +3 -3
- data/mod/core/set/all/templating.rb +5 -1
- data/mod/core/set/all/trash.rb +1 -1
- data/mod/core/set/all/utils.rb +1 -1
- data/mod/core/spec/set/all/actify_spec.rb +1 -1
- data/mod/core/spec/set/all/assign_attributes_spec.rb +2 -2
- data/mod/core/spec/set/all/collection_spec.rb +6 -3
- data/mod/core/spec/set/all/export_spec.rb +40 -112
- data/mod/core/spec/set/all/name_spec.rb +1 -1
- data/mod/core/spec/set/all/permissions_spec.rb +7 -7
- data/mod/core/spec/set/all/rules2_spec.rb +25 -25
- data/mod/core/spec/set/all/rules_spec.rb +2 -7
- data/mod/developer/set/all/event_viz.rb +1 -1
- data/mod/developer/set/right/debug.rb +1 -1
- data/mod/history/lib/card/act.rb +1 -0
- data/mod/history/lib/card/act/act_renderer.rb +23 -20
- data/mod/history/lib/card/act/act_renderer/absolute_act_renderer.rb +0 -1
- data/mod/history/lib/card/act/act_renderer/relative_act_renderer.rb +1 -0
- data/mod/history/lib/card/action.rb +1 -1
- data/mod/history/lib/card/action/action_renderer.rb +2 -2
- data/mod/history/lib/card/change.rb +2 -1
- data/mod/history/set/all/action_view.rb +1 -1
- data/mod/history/set/all/content_history.rb +7 -4
- data/mod/history/set/all/history.rb +6 -6
- data/mod/machines/file/all_script_machine_output/file.js +50 -34
- data/mod/machines/file/all_style_machine_output/file.css +1 -1
- data/mod/machines/lib/javascript/wagn.js.coffee +29 -18
- data/mod/machines/lib/javascript/wagn_layout.js.coffee +7 -3
- data/mod/machines/lib/stylesheets/style_cards.scss +10 -10
- data/mod/machines/set/abstract/machine.rb +5 -28
- data/mod/machines/set/abstract/script.rb +7 -4
- data/mod/machines/set/all/reset_machines.rb +1 -1
- data/mod/machines/set/self/script_jquery_helper.rb +2 -2
- data/mod/machines/set/self/script_slot.rb +1 -1
- data/mod/machines/set/type/coffee_script.rb +3 -2
- data/mod/machines/set/type/css.rb +7 -3
- data/mod/machines/set/type/scss.rb +7 -1
- data/mod/machines/spec/set/type/coffeescript_spec.rb +1 -1
- data/mod/machines/spec/set/type/javascript_spec.rb +1 -1
- data/mod/machines/spec/set/type/scss_spec.rb +3 -2
- data/mod/machines/spec/set/type/skin_spec.rb +1 -1
- data/mod/machines/spec/shared_examples/machine.rb +5 -3
- data/mod/machines/spec/shared_examples/machine_input.rb +1 -0
- data/mod/notifications/format/email_html_format.rb +1 -0
- data/mod/notifications/set/all/follow.rb +1 -1
- data/mod/notifications/set/all/observer.rb +1 -1
- data/mod/notifications/set/all/send_notifications.rb +2 -2
- data/mod/notifications/set/self/follow_defaults.rb +3 -8
- data/mod/notifications/set/type/email_template/email_config.rb +2 -2
- data/mod/notifications/set/type_plus_right/user/follow.rb +2 -2
- data/mod/notifications/spec/set/all/follow_spec.rb +7 -0
- data/mod/notifications/spec/set/all/notify_spec.rb +3 -0
- data/mod/notifications/spec/set/all/observer_spec.rb +1 -1
- data/mod/notifications/spec/set/right/followers_spec.rb +1 -0
- data/mod/pointer/set/abstract/00_paging_params.rb +11 -0
- data/mod/pointer/set/abstract/{00_paging.rb → 01_paging.rb} +10 -6
- data/mod/pointer/set/abstract/{00_paging → 01_paging}/paging_links.rb +0 -0
- data/mod/pointer/set/abstract/{01_pointer.rb → 02_pointer.rb} +26 -5
- data/mod/pointer/set/abstract/{01_pointer → 02_pointer}/edit.rb +3 -5
- data/mod/pointer/set/self/input_options.rb +12 -0
- data/mod/pointer/spec/set/self/input_options_spec.rb +8 -0
- data/mod/pointer/spec/set/type/pointer_spec.rb +3 -2
- data/mod/prosemirror_editor/set/abstract/prosemirror_editor.rb +1 -1
- data/mod/prosemirror_editor/set/self/script_prosemirror.rb +1 -0
- data/mod/settings/lib/card/setting.rb +1 -2
- data/mod/settings/set/abstract/permission.rb +1 -1
- data/mod/settings/set/self/add_help.rb +1 -1
- data/mod/settings/set/self/autoname.rb +1 -1
- data/mod/settings/set/self/csv_structure.rb +2 -0
- data/mod/settings/set/self/help.rb +1 -1
- data/mod/settings/set/self/input.rb +1 -2
- data/mod/settings/set/self/options.rb +2 -2
- data/mod/settings/set/self/options_label.rb +2 -2
- data/mod/settings/set/type/setting.rb +1 -1
- data/mod/settings/spec/set/right/script_spec.rb +1 -1
- data/mod/settings/spec/set/right/style_spec.rb +1 -1
- data/mod/solid_cache/set/abstract/solid_cache.rb +5 -3
- data/mod/solid_cache/spec/set/abstract/solid_cache_spec.rb +4 -3
- data/mod/standard/set/abstract/01_search_params.rb +4 -3
- data/mod/standard/set/abstract/search.rb +2 -1
- data/mod/standard/set/abstract/toolbar_split_button.rb +22 -0
- data/mod/standard/set/all/links.rb +3 -3
- data/mod/standard/set/all/rich_html/classy.rb +37 -0
- data/mod/standard/set/all/rich_html/editing.rb +6 -2
- data/mod/standard/set/all/rich_html/editor.rb +50 -0
- data/mod/standard/set/all/rich_html/form.rb +19 -12
- data/mod/standard/set/all/rich_html/form_elements.rb +2 -2
- data/mod/standard/set/all/rich_html/formgroup.rb +2 -1
- data/mod/standard/set/all/rich_html/header.rb +2 -27
- data/mod/standard/set/all/rich_html/menu.rb +1 -1
- data/mod/standard/set/all/rich_html/new.rb +5 -1
- data/mod/standard/set/all/rich_html/toolbar.rb +15 -60
- data/mod/standard/set/all/rich_html/wrapper.rb +6 -3
- data/mod/standard/set/right/when_created.rb +2 -2
- data/mod/standard/set/rstar/rules_editor.rb +10 -7
- data/mod/standard/set/self/activity_toolbar_button.rb +14 -0
- data/mod/standard/set/self/recent.rb +7 -2
- data/mod/standard/set/self/rules_toolbar_button.rb +42 -0
- data/mod/standard/set/self/search.rb +19 -6
- data/mod/standard/set/type/basic.rb +6 -6
- data/mod/standard/set/type/cardtype.rb +7 -3
- data/mod/standard/set/type/date.rb +2 -4
- data/mod/standard/set/type/layout_type.rb +1 -0
- data/mod/standard/set/type/list.rb +1 -1
- data/mod/standard/set/type/listed_by.rb +1 -2
- data/mod/standard/set/type/number.rb +4 -2
- data/mod/standard/set/type/phrase.rb +4 -2
- data/mod/standard/set/type/search_type.rb +11 -3
- data/mod/standard/set/type/set.rb +8 -8
- data/mod/standard/set/type/toggle.rb +1 -3
- data/mod/standard/set/type/uri.rb +6 -2
- data/mod/standard/spec/chunk/include_spec.rb +3 -2
- data/mod/standard/spec/chunk/query_reference_spec.rb +2 -2
- data/mod/standard/spec/set/all/history_spec.rb +1 -0
- data/mod/standard/spec/set/all/links_spec.rb +1 -0
- data/mod/standard/spec/set/all/rich_html/toolbar_spec.rb +2 -0
- data/mod/standard/spec/set/self/activity_toolbar_button_spec.rb +22 -0
- data/mod/standard/spec/set/type/email_template/email_config_spec.rb +10 -8
- data/mod/standard/spec/set/type/email_template_spec.rb +1 -0
- data/mod/standard/spec/set/type/list_spec.rb +2 -0
- data/mod/standard/spec/set/type/listed_by_spec.rb +5 -0
- data/mod/standard/spec/set/type/search_type_spec.rb +1 -1
- data/mod/standard/spec/set/type/toggle_spec.rb +1 -2
- data/mod/standard/spec/set/type/uri_spec.rb +0 -1
- data/mod/tinymce_editor/db/migrate_cards/20160804112560_add_tinymce_cards.rb +3 -1
- data/mod/tinymce_editor/set/abstract/tinymce_editor.rb +1 -1
- data/mod/tinymce_editor/set/self/script_tinymce.rb +1 -0
- data/mod/twitter/db/migrate_cards/20170305112346_add_twitter_cards.rb +1 -1
- data/mod/twitter/set/type/twitter_template.rb +1 -1
- data/spec/lib/card/format_spec.rb +26 -7
- data/spec/lib/card/loader_spec.rb +96 -35
- data/spec/lib/card/query_spec.rb +0 -1
- data/spec/support/card_spec_loader.rb +1 -0
- data/spec/support/helper/card_helper.rb +0 -36
- data/spec/support/helper/set_helper.rb +80 -0
- data/spec/support/matchers.rb +74 -0
- data/tmpsets/set/mod001-core/all/actify.rb +5 -6
- data/tmpsets/set/mod001-core/all/fetch.rb +14 -12
- data/tmpsets/set/mod001-core/all/name.rb +1 -1
- data/tmpsets/set/mod001-core/all/permissions.rb +12 -22
- data/tmpsets/set/mod001-core/all/tracked_attributes.rb +76 -0
- data/tmpsets/set/mod001-core/all/utils.rb +40 -3
- data/tmpsets/set/mod002-history/all/history.rb +1 -2
- data/tmpsets/set/mod008-solid_cache/abstract/solid_cache.rb +1 -1
- data/tmpsets/set/mod013-carrierwave/abstract/attachment.rb +282 -0
- data/tmpsets/set/mod013-carrierwave/type/file.rb +155 -0
- data/tmpsets/set/mod013-carrierwave/type/image.rb +96 -0
- data/tmpsets/set/mod014-admin/self/admin.rb +113 -0
- data/tmpsets/set/mod014-admin/self/admin_info.rb +110 -0
- data/tmpsets/set/mod014-admin/self/version.rb +15 -0
- data/tmpsets/set/mod015-developer/all/event_viz.rb +59 -0
- data/tmpsets/set/mod015-developer/all/view_viz.rb +30 -0
- data/tmpsets/set/mod015-developer/right/debug.rb +96 -0
- metadata +52 -22
data/db/seed/test/seed.rb
CHANGED
@@ -42,8 +42,8 @@ class SharedData
|
|
42
42
|
Card.create! name: "signup alert email+*to", content: "signups@wagn.org"
|
43
43
|
|
44
44
|
# generic, shared attribute card
|
45
|
-
|
46
|
-
|
45
|
+
Card.create! name: "color"
|
46
|
+
Card.create! name: "Basic Card"
|
47
47
|
|
48
48
|
# CREATE A CARD OF EACH TYPE
|
49
49
|
Card.create! type_id: Card::SignupID, name: "Sample Signup" # , email: "invitation@request.com"
|
data/db/version_core_cards.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
20170608200649
|
data/lib/card.rb
CHANGED
data/lib/card/auth/current.rb
CHANGED
@@ -53,12 +53,16 @@ class Card
|
|
53
53
|
{ as_id: as_id, current_id: current_id }
|
54
54
|
end
|
55
55
|
|
56
|
-
# @param auth_data [Integer|Hash] user id or a hash
|
56
|
+
# @param auth_data [Integer|Hash] user id, user name, or a hash
|
57
57
|
# @opts auth_data [Integer] current_id
|
58
58
|
# @opts auth_data [Integer] as_id
|
59
59
|
def with auth_data
|
60
|
-
|
61
|
-
|
60
|
+
case auth_data
|
61
|
+
when Integer
|
62
|
+
auth_data = { current_id: auth_data }
|
63
|
+
when String
|
64
|
+
auth_data = { current_id: Card.fetch_id(auth_data) }
|
65
|
+
end
|
62
66
|
|
63
67
|
tmp_current = current_id
|
64
68
|
tmp_as_id = as_id
|
data/lib/card/env.rb
CHANGED
data/lib/card/env/success.rb
CHANGED
data/lib/card/format/names.rb
CHANGED
@@ -5,10 +5,8 @@ class Card
|
|
5
5
|
@initial_context_names ||=
|
6
6
|
if @context_names
|
7
7
|
context_names_minus_irrelevants
|
8
|
-
elsif params[:slot]
|
9
|
-
context_names_from_params
|
10
8
|
else
|
11
|
-
|
9
|
+
context_names_from_params
|
12
10
|
end
|
13
11
|
end
|
14
12
|
|
@@ -18,8 +16,8 @@ class Card
|
|
18
16
|
end
|
19
17
|
|
20
18
|
def context_names_from_params
|
21
|
-
|
22
|
-
|
19
|
+
return [] unless (name_list = Card::Env.slot_opts[:name_context])
|
20
|
+
name_list.to_s.split(",").map(&:to_name)
|
23
21
|
end
|
24
22
|
|
25
23
|
def context_names_to_params
|
@@ -33,14 +31,6 @@ class Card
|
|
33
31
|
@context_names.uniq!
|
34
32
|
end
|
35
33
|
|
36
|
-
# def with_name_context name
|
37
|
-
# old_context = @context_names
|
38
|
-
# add_name_context name
|
39
|
-
# result = yield
|
40
|
-
# @context_names = old_context
|
41
|
-
# result
|
42
|
-
# end
|
43
|
-
|
44
34
|
def showname title=nil
|
45
35
|
if title
|
46
36
|
card.cardname.title title, @context_names
|
@@ -9,12 +9,10 @@ class Card
|
|
9
9
|
# All !-methods in this module rename existing cards
|
10
10
|
# to resolve name conflicts)
|
11
11
|
module SaveHelper
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
Card::Auth.current_id = current
|
17
|
-
result
|
12
|
+
def with_user user_name
|
13
|
+
Card::Auth.with current_id: Card.fetch_id(user_name) do
|
14
|
+
yield
|
15
|
+
end
|
18
16
|
end
|
19
17
|
|
20
18
|
def create_card name_or_args, content_or_args=nil
|
data/lib/card/query.rb
CHANGED
@@ -61,7 +61,8 @@ class Card
|
|
61
61
|
link_to linked_to_by
|
62
62
|
include included_by ),
|
63
63
|
conjunction: %w(and or all any),
|
64
|
-
special: %w(found_by not sort match complete
|
64
|
+
special: %w(found_by not sort match name_match complete junction_complete
|
65
|
+
extension_type),
|
65
66
|
ignore: %w(prepend append view params vars size)
|
66
67
|
}.each_with_object({}) do |pair, h|
|
67
68
|
pair[1].each { |v| h[v.to_sym] = pair[0] }
|
@@ -1,20 +1,14 @@
|
|
1
|
-
|
2
1
|
class Card
|
3
2
|
class Query
|
4
3
|
module Attributes
|
5
4
|
def found_by val
|
6
5
|
found_by_cards(val).compact.each do |c|
|
7
|
-
|
8
|
-
# FIXME: - move this check to set mods!
|
9
|
-
|
10
|
-
subquery(
|
11
|
-
c.wql_hash.merge(unjoined: true, context: c.name)
|
12
|
-
)
|
13
|
-
else
|
6
|
+
unless c && c.respond_to?(:wql_hash)
|
14
7
|
raise Card::Error::BadQuery,
|
15
8
|
'"found_by" value must be valid Search, ' \
|
16
9
|
"but #{c.name} is a #{c.type_name}"
|
17
10
|
end
|
11
|
+
subquery c.wql_hash.merge(unjoined: true, context: c.name)
|
18
12
|
end
|
19
13
|
end
|
20
14
|
|
@@ -28,6 +22,10 @@ class Card
|
|
28
22
|
end
|
29
23
|
end
|
30
24
|
|
25
|
+
# Implements the match attribute that matches always against content and name.
|
26
|
+
# That's different from the match operator that can be restricted to names or
|
27
|
+
# content.
|
28
|
+
# Example: { match: "name or content" } vs. { name: ["match", "a name"] }
|
31
29
|
def match val
|
32
30
|
cxn, val = match_prep val
|
33
31
|
val.gsub!(/[^#{Card::Name::OK4KEY_RE}]+/, " ")
|
@@ -40,20 +38,24 @@ class Card
|
|
40
38
|
].map do |field|
|
41
39
|
%(#{field} #{cxn.match quote("[[:<:]]#{v}[[:>:]]")})
|
42
40
|
end
|
43
|
-
|
41
|
+
or_join name_or_content
|
44
42
|
end
|
45
|
-
add_condition
|
43
|
+
add_condition and_join(val_list)
|
44
|
+
end
|
45
|
+
|
46
|
+
def name_match val
|
47
|
+
name_like "%#{val}%"
|
46
48
|
end
|
47
49
|
|
48
50
|
def complete val
|
49
51
|
no_plus_card = (val =~ /\+/ ? "" : "and right_id is null")
|
50
52
|
# FIXME: -- this should really be more nuanced --
|
51
53
|
# it breaks down after one plus
|
54
|
+
name_like "#{val}%", no_plus_card
|
55
|
+
end
|
52
56
|
|
53
|
-
|
54
|
-
|
55
|
-
" lower(#{quote(val.to_s + '%')}) #{no_plus_card}"
|
56
|
-
)
|
57
|
+
def junction_complete val
|
58
|
+
name_like ["#{val}%", "%+#{val}%"]
|
57
59
|
end
|
58
60
|
|
59
61
|
def extension_type _val
|
@@ -61,6 +63,24 @@ class Card
|
|
61
63
|
Rails.logger.info "using DEPRECATED extension_type in WQL"
|
62
64
|
interpret right_plus: AccountID
|
63
65
|
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def name_like patterns, extra_cond=""
|
70
|
+
likes =
|
71
|
+
Array(patterns).map do |pat|
|
72
|
+
"lower(#{table_alias}.name) LIKE lower(#{quote pat})"
|
73
|
+
end
|
74
|
+
add_condition "#{or_join(likes)} #{extra_cond}"
|
75
|
+
end
|
76
|
+
|
77
|
+
def or_join conditions
|
78
|
+
"(#{Array(conditions).join ' OR '})"
|
79
|
+
end
|
80
|
+
|
81
|
+
def and_join conditions
|
82
|
+
"(#{Array(conditions).join ' AND '})"
|
83
|
+
end
|
64
84
|
end
|
65
85
|
end
|
66
86
|
end
|
data/lib/card/query/value.rb
CHANGED
@@ -20,11 +20,10 @@ class Card
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def canonicalize_operator
|
23
|
-
|
24
|
-
@operator = target
|
25
|
-
else
|
23
|
+
unless (target = OPERATORS[@operator.to_s])
|
26
24
|
raise Card::Error::BadQuery, "Invalid Operator #{@operator}"
|
27
25
|
end
|
26
|
+
@operator = target
|
28
27
|
end
|
29
28
|
|
30
29
|
def sqlize v
|
@@ -47,7 +46,7 @@ class Card
|
|
47
46
|
["#{table}.db_content", v]
|
48
47
|
else
|
49
48
|
["#{table}.#{safe_sql field}", v]
|
50
|
-
|
49
|
+
end
|
51
50
|
|
52
51
|
v = v[0] if Array === v && v.length == 1 && op != "in"
|
53
52
|
if op == "~"
|
data/lib/card/set/format.rb
CHANGED
@@ -81,14 +81,35 @@ class Card
|
|
81
81
|
include Set::Format::HamlViews
|
82
82
|
|
83
83
|
mattr_accessor :views
|
84
|
-
self.views = {}
|
84
|
+
self.views = Hash.new { |h, k| h[k] = {} }
|
85
85
|
|
86
86
|
def view view, *args, &block
|
87
87
|
view = view.to_viewname.key.to_sym
|
88
|
-
views[self] ||= {}
|
89
88
|
interpret_view_opts view, args[0] if block_given?
|
90
|
-
|
91
|
-
|
89
|
+
view_method_block = view_block(view, args, &block)
|
90
|
+
if async_view? args
|
91
|
+
# This case makes only sense for HtmlFormat
|
92
|
+
# but I don't see an easy way to override class methods for a specific
|
93
|
+
# format. All formats are extended with this general module. So
|
94
|
+
# a HtmlFormat.view method would be overridden by AbstractFormat.view
|
95
|
+
# We need something like AbstractHtmlFormat for that.
|
96
|
+
define_async_view_method view, &view_method_block
|
97
|
+
else
|
98
|
+
define_standard_view_method view, &view_method_block
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def define_standard_view_method view, &block
|
103
|
+
views[self][view] = block
|
104
|
+
define_method "_view_#{view}", &block
|
105
|
+
end
|
106
|
+
|
107
|
+
def define_async_view_method view, &block
|
108
|
+
view_content = "#{view}_async_content"
|
109
|
+
define_standard_view_method view_content, &block
|
110
|
+
define_standard_view_method view do
|
111
|
+
"<card-view-placeholder data-url=#{path view: view_content}/>"
|
112
|
+
end
|
92
113
|
end
|
93
114
|
|
94
115
|
def interpret_view_opts view, opts
|
@@ -112,6 +133,10 @@ class Card
|
|
112
133
|
args.first.is_a?(Hash) && args.first[:template] == :haml
|
113
134
|
end
|
114
135
|
|
136
|
+
def async_view? args
|
137
|
+
args.first.is_a?(Hash) && args.first[:async]
|
138
|
+
end
|
139
|
+
|
115
140
|
def lookup_alias_block view, args
|
116
141
|
opts = args[0].is_a?(Hash) ? args.shift : { view: args.shift }
|
117
142
|
opts[:mod] ||= self
|
@@ -22,24 +22,26 @@ class Card
|
|
22
22
|
# > render :with_instance_variables # => "Hello haml"
|
23
23
|
module HamlViews
|
24
24
|
def haml_view_block view, &block
|
25
|
-
|
25
|
+
template_path = haml_template_path view
|
26
26
|
if block_given?
|
27
|
-
|
27
|
+
haml_template_render_block_with_locals view, template_path, &block
|
28
28
|
else
|
29
|
-
haml_template_render_block view,
|
29
|
+
haml_template_render_block view, template_path
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
def haml_template_render_block view,
|
33
|
+
def haml_template_render_block view, template_path
|
34
|
+
template = ::File.read template_path
|
34
35
|
proc do |view_args|
|
35
36
|
voo = View.new(self, view, view_args, @voo)
|
36
37
|
with_voo voo do
|
37
|
-
haml_to_html template, view_args
|
38
|
+
haml_to_html template, view_args, nil, path: template_path
|
38
39
|
end
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
42
|
-
def haml_template_render_block_with_locals view,
|
43
|
+
def haml_template_render_block_with_locals view, template_path, &block
|
44
|
+
template = ::File.read template_path
|
43
45
|
proc do |view_args|
|
44
46
|
instance_exec view_args, &block
|
45
47
|
locals = instance_variables.each_with_object({}) do |var, h|
|
@@ -47,30 +49,40 @@ class Card
|
|
47
49
|
end
|
48
50
|
voo = View.new(self, view, view_args, @voo)
|
49
51
|
with_voo voo do
|
50
|
-
haml_to_html template, locals
|
52
|
+
haml_to_html template, locals, nil, path: template_path
|
51
53
|
end
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
55
|
-
def haml_template_path view
|
56
|
-
source
|
57
|
+
def haml_template_path view, source=nil
|
58
|
+
source ||= source_location
|
57
59
|
basename = ::File.basename(source, ".rb")
|
60
|
+
source_dir = ::File.dirname(source)
|
58
61
|
["./#{basename}", "."].each do |template_dir|
|
59
|
-
path = try_haml_template_path(template_dir, view,
|
62
|
+
path = try_haml_template_path(template_dir, view, source_dir)
|
60
63
|
return path if path
|
61
64
|
end
|
62
65
|
raise(Card::Error, "can't find haml template for #{view}")
|
63
66
|
end
|
64
67
|
|
65
|
-
def try_haml_template_path template_path, view,
|
66
|
-
path = ::File.expand_path("#{template_path}/#{view}.#{ext}",
|
68
|
+
def try_haml_template_path template_path, view, source_dir, ext="haml"
|
69
|
+
path = ::File.expand_path("#{template_path}/#{view}.#{ext}", source_dir)
|
67
70
|
.sub(%r{(/mod/[^/]+)/set/}, "\\1/#{TEMPLATE_DIR}/")
|
68
71
|
::File.exist?(path) && path
|
69
72
|
end
|
70
73
|
|
71
|
-
def haml_to_html haml, locals, a_binding=nil
|
74
|
+
def haml_to_html haml, locals, a_binding=nil, debug_info={}
|
72
75
|
a_binding ||= binding
|
73
76
|
::Haml::Engine.new(haml).render a_binding, locals || {}
|
77
|
+
rescue Haml::SyntaxError => e
|
78
|
+
raise Card::Error,
|
79
|
+
"haml syntax error #{template_location(debug_info)}: #{e.message}"
|
80
|
+
end
|
81
|
+
|
82
|
+
def template_location debug_info
|
83
|
+
return "" unless debug_info[:path]
|
84
|
+
Pathname.new(debug_info[:path])
|
85
|
+
.relative_path_from(Pathname.new(Dir.pwd))
|
74
86
|
end
|
75
87
|
end
|
76
88
|
end
|
data/lib/card/set/trait.rb
CHANGED
data/lib/card/set_pattern.rb
CHANGED
@@ -99,6 +99,7 @@ EOF
|
|
99
99
|
@module_key
|
100
100
|
else
|
101
101
|
@module_key = begin
|
102
|
+
# binding.pry if to_s == "*input+*right+*options+*self"
|
102
103
|
if self.class.anchorless?
|
103
104
|
self.class.pattern_code.camelize
|
104
105
|
elsif anchor_codenames
|
@@ -124,12 +125,27 @@ EOF
|
|
124
125
|
end
|
125
126
|
|
126
127
|
def anchor_codenames
|
127
|
-
|
128
|
+
anchor_parts.map do |part|
|
128
129
|
part_id = Card.fetch_id part
|
129
130
|
part_id && Card::Codename[part_id.to_i] || (return nil)
|
130
131
|
end
|
131
132
|
end
|
132
133
|
|
134
|
+
def anchor_parts
|
135
|
+
return [@anchor_name] unless anchor_parts_count > 1
|
136
|
+
parts = @anchor_name.parts
|
137
|
+
if parts.size <= anchor_parts_count
|
138
|
+
parts
|
139
|
+
else
|
140
|
+
# handles cases where anchor is a compound card, eg A+B+*self
|
141
|
+
[@anchor_name[0..-anchor_parts_count]] + parts[(-anchor_parts_count + 1)..-1]
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def anchor_parts_count
|
146
|
+
self.class.anchor_parts_count
|
147
|
+
end
|
148
|
+
|
133
149
|
def pattern
|
134
150
|
@pattern ||= self.class.pattern
|
135
151
|
end
|
data/lib/card/subcards.rb
CHANGED
@@ -182,6 +182,7 @@ class Card
|
|
182
182
|
when Card
|
183
183
|
val.name = absolutize_subcard_name key
|
184
184
|
new_by_card val
|
185
|
+
when nil then next
|
185
186
|
else new_by_attributes key, val
|
186
187
|
end
|
187
188
|
end
|
@@ -246,6 +247,7 @@ class Card
|
|
246
247
|
end
|
247
248
|
|
248
249
|
def new_by_attributes name, attributes={}
|
250
|
+
attributes ||= {}
|
249
251
|
absolute_name = absolutize_subcard_name name
|
250
252
|
if absolute_name.field_of?(@context_card.name) &&
|
251
253
|
(absolute_name.parts.size - @context_card.cardname.parts.size) > 2
|
@@ -255,8 +257,7 @@ class Card
|
|
255
257
|
else
|
256
258
|
subcard_args = extract_subcard_args! attributes
|
257
259
|
t_i_s = attributes.delete(:transact_in_stage)
|
258
|
-
card = Card.assign_or_initialize_by absolute_name.s, attributes,
|
259
|
-
local_only: true
|
260
|
+
card = Card.assign_or_initialize_by absolute_name.s, attributes, local_only: true
|
260
261
|
subcard = new_by_card card, transact_in_stage: t_i_s
|
261
262
|
card.subcards.add subcard_args
|
262
263
|
subcard
|