card 1.19.6 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/card.gemspec +8 -7
- data/config/initializers/01_core_extensions/array.rb +4 -0
- data/config/initializers/01_core_extensions/persistent_identifiers.rb +12 -0
- data/config/initializers/02_patches/better_errors.rb +56 -0
- data/config/initializers/core_extensions.rb +13 -18
- data/config/initializers/patches.rb +8 -0
- data/config/locales/de.yml +0 -2
- data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +22 -12
- data/db/migrate_core_cards/20161102202156_tweak_recaptcha_setting_cards.rb +17 -0
- data/db/migrate_core_cards/20161103154836_update_keys.rb +46 -0
- data/lib/card.rb +1 -8
- data/lib/card/act_manager.rb +4 -0
- data/lib/card/auth/permissions.rb +5 -3
- data/lib/card/cache.rb +1 -20
- data/lib/card/cache/persistent.rb +6 -0
- data/lib/card/content/chunk.rb +4 -3
- data/lib/card/content/diff.rb +2 -2
- data/lib/card/content/diff/result.rb +11 -0
- data/lib/card/env/success.rb +4 -0
- data/lib/card/error.rb +2 -0
- data/lib/card/format.rb +14 -17
- data/lib/card/format/content.rb +16 -8
- data/lib/card/format/error.rb +3 -5
- data/lib/card/format/names.rb +22 -16
- data/lib/card/format/nest.rb +67 -61
- data/lib/card/format/nest/fetch.rb +40 -33
- data/lib/card/format/nest/main.rb +39 -19
- data/lib/card/format/nest/subformat.rb +3 -16
- data/lib/card/format/nest/view.rb +23 -32
- data/lib/card/format/permission.rb +49 -34
- data/lib/card/format/registration.rb +12 -6
- data/lib/card/format/render.rb +62 -73
- data/lib/card/migration.rb +14 -10
- data/lib/card/migration/import.rb +20 -19
- data/lib/card/migration/import/import_data.rb +50 -59
- data/lib/card/migration/import/import_data/card_attributes.rb +56 -0
- data/lib/card/migration/import/import_data/card_content.rb +33 -0
- data/lib/card/migration/import/merger.rb +47 -0
- data/lib/card/mod/loader.rb +4 -4
- data/lib/card/model/save_helper.rb +49 -10
- data/lib/card/name.rb +16 -52
- data/lib/card/name/fields_and_traits.rb +67 -0
- data/lib/card/name/variants.rb +17 -0
- data/lib/card/query.rb +6 -2
- data/lib/card/query/attributes.rb +1 -1
- data/lib/card/query/interpretation.rb +3 -3
- data/lib/card/set/event.rb +2 -1
- data/lib/card/set/format.rb +18 -7
- data/lib/card/set_pattern.rb +17 -13
- data/lib/card/tasks/card.rake +1 -1
- data/lib/card/view.rb +55 -0
- data/lib/card/view/cache.rb +90 -0
- data/lib/card/view/fetch.rb +109 -0
- data/lib/card/view/options.rb +164 -0
- data/lib/card/view/stub.rb +30 -0
- data/lib/card/view/visibility.rb +95 -0
- data/lib/cardio.rb +3 -2
- data/lib/cardio/schema.rb +21 -8
- data/lib/generators/card.rb +16 -2
- data/lib/generators/card/format/format_generator.rb +10 -9
- data/lib/generators/card/migration/migration_generator.rb +10 -5
- data/lib/generators/card/set/USAGE +1 -1
- data/lib/generators/card/set/set_generator.rb +11 -9
- data/mod/account/set/right/account.rb +38 -40
- data/mod/account/set/right/token.rb +2 -1
- data/mod/account/set/self/account_links.rb +34 -54
- data/mod/account/set/self/signin.rb +107 -93
- data/mod/account/set/type/signup.rb +33 -32
- data/mod/account/set/type/user.rb +28 -21
- data/mod/account/spec/set/all/account_spec.rb +9 -9
- data/mod/account/spec/set/right/account_spec.rb +23 -14
- data/mod/account/spec/set/right/email_spec.rb +6 -6
- data/mod/account/spec/set/right/password_spec.rb +4 -4
- data/mod/account/spec/set/right/token_spec.rb +3 -3
- data/mod/account/spec/set/self/account_links_spec.rb +3 -3
- data/mod/account/spec/set/self/signin_spec.rb +2 -2
- data/mod/account/spec/set/type/signup_spec.rb +7 -8
- data/mod/ace_editor/set/abstract/ace_editor.rb +1 -4
- data/mod/admin/set/self/admin.rb +2 -2
- data/mod/admin/set/self/admin_info.rb +1 -1
- data/mod/admin/set/self/recaptcha_private_key.rb +3 -0
- data/mod/admin/set/self/recaptcha_proxy.rb +3 -0
- data/mod/admin/set/self/recaptcha_public_key.rb +3 -0
- data/mod/admin/set/self/trash.rb +4 -4
- data/mod/admin/spec/set/self/admin_spec.rb +4 -4
- data/mod/admin/spec/set/self/version_spec.rb +1 -1
- data/mod/basic_formats/set/all/all_css.rb +3 -3
- data/mod/basic_formats/set/all/all_csv.rb +6 -6
- data/mod/basic_formats/set/all/all_js.rb +4 -0
- data/mod/basic_formats/set/all/base.rb +40 -62
- data/mod/basic_formats/set/all/json.rb +34 -39
- data/mod/basic_formats/set/all/rss.rb +6 -6
- data/mod/basic_formats/set/all/text.rb +3 -2
- data/mod/basic_formats/set/self/01_head/javascript.rb +2 -2
- data/mod/basic_formats/set/self/head.rb +6 -10
- data/mod/basic_formats/spec/set/all/all_css_spec.rb +1 -1
- data/mod/basic_formats/spec/set/all/all_csv_spec.rb +1 -1
- data/mod/basic_formats/spec/set/all/base_spec.rb +8 -5
- data/mod/basic_formats/spec/set/all/json_spec.rb +2 -2
- data/mod/basic_formats/spec/set/all/rss_spec.rb +4 -4
- data/mod/basic_types/set/type/plain_text.rb +3 -5
- data/mod/basic_types/spec/set/type/plain_text_spec.rb +2 -2
- data/mod/bootstrap/lib/bootstrap.rb +16 -0
- data/mod/bootstrap/lib/bootstrap/basic_tags.rb +26 -0
- data/mod/bootstrap/lib/bootstrap/component.rb +133 -0
- data/mod/bootstrap/lib/bootstrap/component/form.rb +31 -0
- data/mod/bootstrap/lib/bootstrap/component/horizontal_form.rb +38 -0
- data/mod/bootstrap/lib/bootstrap/component/layout.rb +83 -0
- data/mod/bootstrap/lib/bootstrap/component/panel.rb +9 -0
- data/mod/bootstrap/lib/bootstrap/component_loader.rb +30 -0
- data/mod/bootstrap/lib/bootstrap/delegate.rb +16 -0
- data/mod/bootstrap/lib/bootstrapper.rb +16 -0
- data/mod/bootstrap/lib/stylesheets/bootstrap/_tables.scss +55 -52
- data/mod/bootstrap/lib/stylesheets/bootstrap/mixins/_table-row.scss +12 -12
- data/mod/bootstrap/lib/stylesheets/bootstrap_cards.scss +12 -0
- data/mod/bootstrap/set/all/bootstrap/accordion.rb +63 -0
- data/mod/bootstrap/set/all/bootstrap/helper.rb +7 -140
- data/mod/bootstrap/set/all/bootstrap/navbar.rb +74 -0
- data/mod/bootstrap/set/all/bootstrap/table.rb +76 -46
- data/mod/bootstrap/set/all/bootstrap/tabs.rb +58 -23
- data/mod/bootstrap/set/all/bootstrap/wrapper.rb +14 -8
- data/mod/bootstrap/set/all/rich_bootstrap.rb +5 -3
- data/mod/bootstrap/spec/set/all/bootstrap/bootstrap_builder_spec.rb +31 -0
- data/mod/bootstrap/spec/set/all/bootstrap/bootstrap_spec.rb +20 -0
- data/mod/bootstrap/spec/set/all/bootstrap/form_spec.rb +59 -1
- data/mod/bootstrap/spec/set/all/bootstrap/layout_spec.rb +104 -15
- data/mod/carrierwave/set/abstract/attachment.rb +4 -3
- data/mod/carrierwave/set/abstract/attachment/paths.rb +1 -1
- data/mod/carrierwave/set/abstract/attachment/storage_type.rb +5 -11
- data/mod/carrierwave/set/type/file.rb +39 -32
- data/mod/carrierwave/set/type/image.rb +59 -34
- data/mod/carrierwave/spec/set/type/image_spec.rb +3 -3
- data/mod/core/chunk/link.rb +5 -0
- data/mod/core/chunk/{include.rb → nest.rb} +8 -29
- data/mod/core/chunk/reference.rb +5 -6
- data/mod/core/chunk/view_stub.rb +42 -0
- data/mod/core/format/html_format.rb +23 -26
- data/mod/core/set/abstract/code_file.rb +1 -1
- data/mod/core/set/all/actify.rb +1 -1
- data/mod/core/set/all/active_card.rb +0 -1
- data/mod/core/set/all/{tracked_attributes.rb → assign_attributes.rb} +55 -24
- data/mod/core/set/all/collection.rb +136 -122
- data/mod/core/set/all/content.rb +8 -0
- data/mod/core/set/all/event.rb +5 -2
- data/mod/core/set/all/export.rb +7 -7
- data/mod/core/set/all/fetch.rb +90 -26
- data/mod/core/set/all/initialize.rb +17 -6
- data/mod/core/set/all/name.rb +2 -3
- data/mod/core/set/all/permissions.rb +19 -11
- data/mod/core/set/all/states.rb +12 -2
- data/mod/core/set/all/trash.rb +1 -1
- data/mod/core/set/all/type.rb +2 -0
- data/mod/core/set/all/utils.rb +4 -3
- data/mod/core/spec/chunk/literal_spec.rb +2 -2
- data/mod/core/spec/chunk/uri_spec.rb +17 -17
- data/mod/core/spec/format/html_format_spec.rb +11 -13
- data/mod/core/spec/set/all/attribute_tracking_spec.rb +2 -2
- data/mod/core/spec/set/all/collection_spec.rb +21 -24
- data/mod/core/spec/set/all/content_spec.rb +1 -1
- data/mod/core/spec/set/all/export_spec.rb +3 -3
- data/mod/core/spec/set/all/fetch_spec.rb +5 -5
- data/mod/core/spec/set/all/initialize_spec.rb +4 -4
- data/mod/core/spec/set/all/name_spec.rb +6 -6
- data/mod/core/spec/set/all/permissions_spec.rb +10 -10
- data/mod/core/spec/set/all/references_spec.rb +1 -1
- data/mod/core/spec/set/all/rules2_spec.rb +24 -24
- data/mod/core/spec/set/all/rules_spec.rb +1 -1
- data/mod/core/spec/set/all/templating_spec.rb +8 -8
- data/mod/core/spec/set/all/tracked_attributes_spec.rb +6 -6
- data/mod/core/spec/set/all/type_spec.rb +5 -5
- data/mod/developer/spec/set/all/event_viz_spec.rb +1 -1
- data/mod/developer/spec/set/right/debug_spec.rb +1 -1
- data/mod/email/set/all/email_html.rb +2 -2
- data/mod/email/set/all/notify.rb +8 -3
- data/mod/email/set/right/bcc.rb +3 -3
- data/mod/email/set/right/follow.rb +5 -5
- data/mod/email/set/right/following.rb +1 -1
- data/mod/email/set/self/follow_defaults.rb +27 -16
- data/mod/email/set/type/email_template.rb +1 -1
- data/mod/email/set/type_plus_right/user/follow.rb +10 -9
- data/mod/history/lib/card/act.rb +4 -0
- data/mod/history/lib/card/act/act_renderer.rb +194 -0
- data/mod/history/lib/card/act/act_renderer/absolute_act_renderer.rb +25 -0
- data/mod/history/lib/card/act/act_renderer/relative_act_renderer.rb +41 -0
- data/mod/history/lib/card/action.rb +1 -0
- data/mod/history/lib/card/action/action_renderer.rb +92 -0
- data/mod/history/lib/card/action/differ.rb +6 -1
- data/mod/history/set/all/act_view.rb +64 -0
- data/mod/history/set/all/action_view.rb +65 -0
- data/mod/history/set/all/content_history.rb +44 -37
- data/mod/history/set/all/history.rb +49 -263
- data/mod/machines/lib/stylesheets/style_cards.scss +30 -115
- data/mod/machines/set/abstract/script.rb +42 -7
- data/mod/machines/set/right/machine_input.rb +4 -0
- data/mod/machines/set/type/coffee_script.rb +8 -22
- data/mod/machines/set/type/css.rb +2 -2
- data/mod/machines/set/type/java_script.rb +4 -24
- data/mod/machines/set/type/scss.rb +1 -1
- data/mod/machines/spec/set/type/css_spec.rb +1 -1
- data/mod/machines/spec/set/type/scss_spec.rb +3 -3
- data/mod/machines/spec/set/type/skin_spec.rb +7 -7
- data/mod/pointer/set/abstract/01_pointer.rb +44 -46
- data/mod/pointer/set/abstract/01_pointer/edit.rb +13 -13
- data/mod/pointer/set/right/options.rb +4 -0
- data/mod/pointer/spec/set/type/pointer_spec.rb +7 -7
- data/mod/prosemirror_editor/set/abstract/prosemirror_editor.rb +3 -3
- data/mod/settings/set/abstract/permission.rb +25 -18
- data/mod/settings/set/right/add_help.rb +3 -3
- data/mod/settings/set/right/structure.rb +10 -16
- data/mod/settings/spec/set/right/comment_spec.rb +3 -3
- data/mod/settings/spec/set/right/create_spec.rb +1 -1
- data/mod/settings/spec/set/right/style_spec.rb +1 -1
- data/mod/settings/spec/set/type/setting_spec.rb +1 -1
- data/mod/solid_cache/set/abstract/solid_cache.rb +4 -4
- data/mod/solid_cache/set/right/solid_cache.rb +9 -10
- data/mod/standard/set/abstract/01_search_params.rb +41 -0
- data/mod/standard/set/abstract/search.rb +132 -0
- data/mod/standard/set/abstract/search/paging.rb +81 -0
- data/mod/standard/set/abstract/search/paging/paging_links.rb +90 -0
- data/mod/standard/set/abstract/wql_search.rb +67 -0
- data/mod/standard/set/all/error.rb +89 -82
- data/mod/standard/set/all/links.rb +1 -1
- data/mod/standard/set/all/rich_html/content.rb +125 -141
- data/mod/standard/set/all/rich_html/editing.rb +115 -178
- data/mod/standard/set/all/rich_html/form.rb +111 -131
- data/mod/standard/set/all/rich_html/header.rb +57 -39
- data/mod/standard/set/all/rich_html/menu.rb +94 -94
- data/mod/standard/set/all/rich_html/modal.rb +5 -10
- data/mod/standard/set/all/rich_html/new.rb +103 -0
- data/mod/standard/set/all/rich_html/toolbar.rb +54 -74
- data/mod/standard/set/all/rich_html/wrapper.rb +111 -138
- data/mod/standard/set/rstar/rules.rb +27 -38
- data/mod/standard/set/rstar/rules_editor.rb +298 -277
- data/mod/standard/set/self/navbox.rb +20 -15
- data/mod/standard/set/self/recent.rb +25 -17
- data/mod/standard/set/self/search.rb +25 -4
- data/mod/standard/set/type/cardtype.rb +11 -9
- data/mod/standard/set/type/date.rb +1 -1
- data/mod/standard/set/type/number.rb +1 -1
- data/mod/standard/set/type/phrase.rb +1 -1
- data/mod/standard/set/type/search_type.rb +17 -282
- data/mod/standard/set/type/session.rb +1 -1
- data/mod/standard/set/type/set.rb +155 -131
- data/mod/standard/set/type/toggle.rb +1 -1
- data/mod/standard/set/type/uri.rb +4 -4
- data/mod/standard/spec/chunk/include_spec.rb +13 -31
- data/mod/standard/spec/chunk/link_spec.rb +1 -1
- data/mod/standard/spec/set/all/error_spec.rb +1 -1
- data/mod/standard/spec/set/all/history_spec.rb +2 -2
- data/mod/standard/spec/set/all/rich_html/form_spec.rb +4 -4
- data/mod/standard/spec/set/all/rich_html/toolbar_spec.rb +22 -0
- data/mod/standard/spec/set/all/rich_html/wrapper_spec.rb +3 -2
- data/mod/standard/spec/set/right/when_created_spec.rb +1 -1
- data/mod/standard/spec/set/right/when_last_edited_spec.rb +1 -1
- data/mod/standard/spec/set/rstar/rules_spec.rb +2 -3
- data/mod/standard/spec/set/self/head_spec.rb +2 -2
- data/mod/standard/spec/set/self/navbox_spec.rb +1 -1
- data/mod/standard/spec/set/self/now_spec.rb +1 -1
- data/mod/standard/spec/set/type/date_spec.rb +1 -1
- data/mod/standard/spec/set/type/email_template_spec.rb +1 -1
- data/mod/standard/spec/set/type/layout_type_spec.rb +1 -1
- data/mod/standard/spec/set/type/number_spec.rb +1 -1
- data/mod/standard/spec/set/type/phrase_spec.rb +1 -1
- data/mod/standard/spec/set/type/search_type_spec.rb +2 -2
- data/mod/standard/spec/set/type/set_spec.rb +2 -2
- data/mod/standard/spec/set/type/toggle_spec.rb +2 -2
- data/mod/standard/spec/set/type/uri_spec.rb +3 -1
- data/mod/tinymce_editor/set/abstract/tinymce_editor.rb +1 -1
- data/spec/config/initializers/core_extensions_spec.rb +40 -10
- data/spec/lib/card/auth_spec.rb +8 -8
- data/spec/lib/card/cache_spec.rb +3 -3
- data/spec/lib/card/chunk_spec.rb +4 -4
- data/spec/lib/card/codename_spec.rb +2 -2
- data/spec/lib/card/content_spec.rb +23 -23
- data/spec/lib/card/diff_spec.rb +1 -1
- data/spec/lib/card/format_spec.rb +19 -24
- data/spec/lib/card/loader_spec.rb +4 -4
- data/spec/lib/card/name_spec.rb +16 -16
- data/spec/lib/card/query_spec.rb +80 -80
- data/spec/lib/card/reference_spec.rb +5 -5
- data/spec/lib/card/set_spec.rb +6 -6
- data/spec/lib/card/subcards_spec.rb +14 -0
- data/spec/lib/card/view_cache_spec.rb +5 -5
- data/spec/models/card/cardtype_spec.rb +15 -15
- data/spec/models/card/create_spec.rb +2 -2
- data/spec/models/card/trash_spec.rb +24 -24
- data/spec/models/card/type_transition_spec.rb +8 -8
- data/spec/models/card/validation_spec.rb +5 -5
- data/spec/models/card_spec.rb +14 -14
- data/spec/spec_helper.rb +6 -2
- data/spec/support/card_spec_helper.rb +21 -11
- data/spec/support/helper/card_helper.rb +11 -4
- metadata +73 -15
- data/lib/card/cache/view_cache.rb +0 -103
- data/mod/bootstrap/set/all/bootstrap/layout.rb +0 -58
- data/mod/core/set/all/view_cache.rb +0 -9
@@ -15,6 +15,10 @@ class Card
|
|
15
15
|
@summary.rendered
|
16
16
|
end
|
17
17
|
|
18
|
+
def summary_omits_content?
|
19
|
+
@summary.omits_content?
|
20
|
+
end
|
21
|
+
|
18
22
|
def write_added_chunk text
|
19
23
|
@adds_cnt += 1
|
20
24
|
@complete << Card::Content::Diff.render_added_chunk(text)
|
@@ -45,6 +49,7 @@ class Card
|
|
45
49
|
|
46
50
|
@summary = nil
|
47
51
|
@chunks = []
|
52
|
+
@content_omitted = false
|
48
53
|
end
|
49
54
|
|
50
55
|
def rendered
|
@@ -52,6 +57,7 @@ class Card
|
|
52
57
|
begin
|
53
58
|
truncate_overlap
|
54
59
|
@chunks.map do |chunk|
|
60
|
+
@content_omitted ||= chunk[:action] == :ellipsis
|
55
61
|
render_chunk chunk[:action], chunk[:text]
|
56
62
|
end.join
|
57
63
|
end
|
@@ -71,6 +77,10 @@ class Card
|
|
71
77
|
end
|
72
78
|
end
|
73
79
|
|
80
|
+
def omits_content?
|
81
|
+
@content_omitted || @remaining_chars < 0
|
82
|
+
end
|
83
|
+
|
74
84
|
private
|
75
85
|
|
76
86
|
def add_chunk text, action
|
@@ -105,6 +115,7 @@ class Card
|
|
105
115
|
def process_ellipsis
|
106
116
|
return unless @chunks.last[:action] == :ellipsis
|
107
117
|
@chunks.pop
|
118
|
+
@content_omitted = true
|
108
119
|
@remaining_chars += @joint.size
|
109
120
|
end
|
110
121
|
|
data/lib/card/env/success.rb
CHANGED
data/lib/card/error.rb
CHANGED
data/lib/card/format.rb
CHANGED
@@ -32,7 +32,6 @@ class Card
|
|
32
32
|
include Content
|
33
33
|
include Error
|
34
34
|
|
35
|
-
extend Nest::ClassMethods
|
36
35
|
extend Registration
|
37
36
|
|
38
37
|
# FIXME: should be set in views
|
@@ -45,28 +44,30 @@ class Card
|
|
45
44
|
send "#{accessor_name}=", {}
|
46
45
|
end
|
47
46
|
|
48
|
-
attr_reader :card, :root, :parent, :main_opts
|
49
|
-
attr_accessor :form, :error_status
|
47
|
+
attr_reader :card, :root, :parent, :main_opts, :mode
|
48
|
+
attr_accessor :form, :error_status
|
50
49
|
|
51
50
|
def initialize card, opts={}
|
52
|
-
|
53
|
-
|
54
|
-
raise Card::Error, msg
|
55
|
-
end
|
51
|
+
@card = card
|
52
|
+
require_card_to_initialize!
|
56
53
|
|
57
|
-
opts.each
|
58
|
-
instance_variable_set "@#{key}", value
|
59
|
-
end
|
54
|
+
opts.each { |key, value| instance_variable_set "@#{key}", value }
|
60
55
|
|
61
56
|
@mode ||= :normal
|
62
57
|
@root ||= self
|
63
58
|
@depth ||= 0
|
64
59
|
|
65
|
-
@context_names =
|
60
|
+
@context_names = initial_context_names
|
66
61
|
include_set_format_modules
|
67
62
|
self
|
68
63
|
end
|
69
64
|
|
65
|
+
def require_card_to_initialize!
|
66
|
+
return if @card
|
67
|
+
msg = I18n.t :exception_init_without_card, scope: "lib.card.format"
|
68
|
+
raise Card::Error, msg
|
69
|
+
end
|
70
|
+
|
70
71
|
def include_set_format_modules
|
71
72
|
self.class.format_ancestry.reverse_each do |klass|
|
72
73
|
card.set_format_modules(klass).each do |m|
|
@@ -98,11 +99,7 @@ class Card
|
|
98
99
|
end
|
99
100
|
|
100
101
|
def focal? # meaning the current card is the requested card
|
101
|
-
|
102
|
-
@depth.zero?
|
103
|
-
else
|
104
|
-
main?
|
105
|
-
end
|
102
|
+
@depth.zero?
|
106
103
|
end
|
107
104
|
|
108
105
|
def template
|
@@ -116,7 +113,7 @@ class Card
|
|
116
113
|
|
117
114
|
def method_missing method, *opts, &proc
|
118
115
|
if method =~ /(_)?(optional_)?render(_(\w+))?/
|
119
|
-
|
116
|
+
api_render Regexp.last_match, opts
|
120
117
|
else
|
121
118
|
pass_method_to_template_object(method, opts, proc) { yield }
|
122
119
|
end
|
data/lib/card/format/content.rb
CHANGED
@@ -5,7 +5,7 @@ class Card
|
|
5
5
|
content = override_content || render_raw || ""
|
6
6
|
content_object = get_content_object content, opts
|
7
7
|
content_object.process_each_chunk do |chunk_opts|
|
8
|
-
|
8
|
+
content_nest chunk_opts.merge(opts)
|
9
9
|
end
|
10
10
|
content_object.to_s
|
11
11
|
end
|
@@ -33,7 +33,17 @@ class Card
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def add_class options, klass
|
36
|
-
options[:class] =
|
36
|
+
options[:class] = css_classes options[:class], klass
|
37
|
+
end
|
38
|
+
|
39
|
+
alias_method :append_class, :add_class
|
40
|
+
|
41
|
+
def prepend_class options, klass
|
42
|
+
options[:class] = css_classes klass, options[:class]
|
43
|
+
end
|
44
|
+
|
45
|
+
def css_classes *array
|
46
|
+
array.flatten.uniq.compact * " "
|
37
47
|
end
|
38
48
|
|
39
49
|
def id_counter
|
@@ -43,14 +53,12 @@ class Card
|
|
43
53
|
end
|
44
54
|
|
45
55
|
def unique_id
|
46
|
-
"#{card.
|
56
|
+
"#{card.cardname.safe_key}-#{id_counter}"
|
47
57
|
end
|
48
58
|
|
49
|
-
def output content
|
50
|
-
|
51
|
-
|
52
|
-
when Array then content.compact.join "\n"
|
53
|
-
end
|
59
|
+
def output *content
|
60
|
+
content ||= yield
|
61
|
+
Array.wrap(content).flatten.compact.join "\n"
|
54
62
|
end
|
55
63
|
end
|
56
64
|
end
|
data/lib/card/format/error.rb
CHANGED
@@ -3,14 +3,12 @@ class Card
|
|
3
3
|
module Error
|
4
4
|
def rescue_view e, view
|
5
5
|
raise e if Rails.env =~ /^cucumber|test$/
|
6
|
-
Card::Error.
|
7
|
-
|
6
|
+
error_view = Card::Error.exception_view @card, e
|
7
|
+
# TODO: consider rendering dynamic error view here.
|
8
8
|
rendering_error e, view
|
9
9
|
end
|
10
10
|
|
11
|
-
def debug_error e
|
12
|
-
Rails.logger.info "#{rendering_error e, view}:\n" \
|
13
|
-
"#{e.class} : #{e.message}"
|
11
|
+
def debug_error e
|
14
12
|
debug = Card[:debugger]
|
15
13
|
raise e if debug && debug.content == "on"
|
16
14
|
end
|
data/lib/card/format/names.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
class Card
|
2
2
|
class Format
|
3
3
|
module Names
|
4
|
-
def
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
def initial_context_names
|
5
|
+
@initial_context_names ||=
|
6
|
+
if @context_names
|
7
|
+
context_names_minus_irrelevants
|
8
|
+
elsif params[:slot]
|
9
|
+
context_names_from_params
|
10
|
+
else
|
11
|
+
[]
|
12
|
+
end
|
12
13
|
end
|
13
14
|
|
14
15
|
def context_names_minus_irrelevants
|
@@ -21,23 +22,28 @@ class Card
|
|
21
22
|
context_name_list.split(",").map(&:to_name)
|
22
23
|
end
|
23
24
|
|
25
|
+
def context_names_to_params
|
26
|
+
return unless @context_names
|
27
|
+
@context_names.join(",")
|
28
|
+
end
|
29
|
+
|
24
30
|
def add_name_context name=nil
|
25
31
|
name ||= card.name
|
26
32
|
@context_names += name.to_name.part_names
|
27
33
|
@context_names.uniq!
|
28
34
|
end
|
29
35
|
|
30
|
-
def with_name_context name
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
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
|
37
43
|
|
38
44
|
def showname title=nil
|
39
45
|
if title
|
40
|
-
|
46
|
+
card.cardname.title title, @context_names
|
41
47
|
else
|
42
48
|
@showname ||= card.cardname.to_show(*@context_names)
|
43
49
|
end
|
data/lib/card/format/nest.rb
CHANGED
@@ -6,80 +6,84 @@ class Card
|
|
6
6
|
include Subformat
|
7
7
|
include View
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
opts[:
|
13
|
-
|
9
|
+
# nested by another card's content
|
10
|
+
# (as opposed to a direct API nest)
|
11
|
+
def content_nest opts={}
|
12
|
+
return opts[:comment] if opts.key? :comment # commented nest
|
13
|
+
nest_name = opts[:nest_name]
|
14
|
+
return main_nest(opts) if main_nest?(nest_name)
|
15
|
+
nest nest_name, opts
|
14
16
|
end
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
# home.field_nest :self # => nest for 'Home+*self'
|
22
|
-
def field_nest field, opts={}
|
23
|
-
if field.is_a?(Card)
|
24
|
-
nest_card field, opts
|
25
|
-
else
|
26
|
-
prepare_nest opts.merge(inc_name: card.cardname.field(field))
|
27
|
-
end
|
18
|
+
def nest cardish, options={}, &block
|
19
|
+
return "" if nest_invisible?
|
20
|
+
nested_card = fetch_nested_card cardish, options
|
21
|
+
view, options = interpret_nest_options nested_card, options
|
22
|
+
nest_render nested_card, view, options, &block
|
28
23
|
end
|
29
24
|
|
30
|
-
def
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
main_nest opts
|
40
|
-
else
|
41
|
-
# standard nest
|
42
|
-
count_chars { nest opts }
|
43
|
-
end
|
25
|
+
def interpret_nest_options nested_card, options
|
26
|
+
options[:nest_name] ||= nested_card.name
|
27
|
+
view = options[:view] || implicit_nest_view
|
28
|
+
view = Card::View.canonicalize view
|
29
|
+
|
30
|
+
# FIXME: should handle in closed / edit view definitions
|
31
|
+
options[:home_view] ||= [:closed, :edit].member?(view) ? :open : view
|
32
|
+
|
33
|
+
[view, options]
|
44
34
|
end
|
45
35
|
|
46
|
-
|
47
|
-
|
36
|
+
def implicit_nest_view
|
37
|
+
view = voo_items_view || default_nest_view
|
38
|
+
Card::View.canonicalize view
|
39
|
+
end
|
48
40
|
|
49
|
-
def
|
50
|
-
|
51
|
-
|
52
|
-
opts.delete_if { |_k, v| v.nil? }
|
53
|
-
opts.reverse_merge! nest_defaults(nested_card)
|
41
|
+
def default_nest_view
|
42
|
+
:name
|
43
|
+
end
|
54
44
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
45
|
+
def nest_render nested_card, view, options
|
46
|
+
subformat = nest_subformat nested_card, options, view
|
47
|
+
view = subformat.modal_nest_view view
|
48
|
+
rendered = count_chars { subformat.optional_render view, options }
|
49
|
+
block_given? ? yield(rendered, view) : rendered
|
60
50
|
end
|
61
51
|
|
62
|
-
def
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
52
|
+
def nest_subformat nested_card, opts, view
|
53
|
+
return self if reuse_format? opts, view
|
54
|
+
sub = subformat nested_card
|
55
|
+
sub.main! if opts[:main]
|
56
|
+
sub
|
68
57
|
end
|
69
58
|
|
70
|
-
def
|
71
|
-
|
59
|
+
def reuse_format? opts, view
|
60
|
+
return false unless opts[:nest_name] =~ /^_(self)?$/
|
61
|
+
!content_view? view
|
72
62
|
end
|
73
63
|
|
74
|
-
|
64
|
+
def content_view? view
|
65
|
+
# TODO: this should be specified in view definition
|
66
|
+
[:core, :content, :titled, :open, :closed].member? view.to_sym
|
67
|
+
end
|
75
68
|
|
76
|
-
|
77
|
-
|
78
|
-
|
69
|
+
# Main difference compared to #nest is that you can use
|
70
|
+
# codename symbols to get nested fields
|
71
|
+
# @example
|
72
|
+
# home = Card['home'].format
|
73
|
+
# home.nest :self # => nest for '*self'
|
74
|
+
# home.field_nest :self # => nest for 'Home+*self'
|
75
|
+
def field_nest field, opts={}
|
76
|
+
field = card.cardname.field(field) unless field.is_a? Card
|
77
|
+
nest field, opts
|
79
78
|
end
|
80
79
|
|
81
|
-
|
82
|
-
|
80
|
+
# opts[:home_view] = [:closed, :edit].member?(view) ? :open : view
|
81
|
+
# FIXME: special views should be represented in view definitions
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def nest_invisible?
|
86
|
+
@mode == :closed && @char_count && @char_count > max_char_count
|
83
87
|
end
|
84
88
|
|
85
89
|
def count_chars
|
@@ -90,10 +94,12 @@ class Card
|
|
90
94
|
result
|
91
95
|
end
|
92
96
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
+
def max_depth
|
98
|
+
Card.config.max_depth
|
99
|
+
end
|
100
|
+
|
101
|
+
def max_char_count
|
102
|
+
Card.config.max_char_count
|
97
103
|
end
|
98
104
|
end
|
99
105
|
end
|
@@ -3,49 +3,56 @@ class Card
|
|
3
3
|
module Nest
|
4
4
|
# Fetch card for a nest
|
5
5
|
module Fetch
|
6
|
-
def fetch_nested_card
|
7
|
-
case
|
8
|
-
when Card
|
9
|
-
|
10
|
-
when Hash
|
11
|
-
opts = name_or_card_or_opts
|
12
|
-
Card.fetch(opts[:inc_name], new: nest_new_args(opts))
|
13
|
-
when Symbol
|
14
|
-
Card.fetch(name_or_card_or_opts)
|
6
|
+
def fetch_nested_card cardish, opts={}
|
7
|
+
case cardish
|
8
|
+
when Card then cardish
|
9
|
+
when Symbol, Integer then Card.fetch cardish
|
15
10
|
else
|
16
|
-
opts[:
|
17
|
-
Card.fetch
|
11
|
+
opts[:nest_name] = cardish.to_s
|
12
|
+
Card.fetch cardish, new: nest_new_args(opts)
|
18
13
|
end
|
19
14
|
end
|
20
15
|
|
21
16
|
private
|
22
17
|
|
23
|
-
def
|
24
|
-
|
18
|
+
def nest_new_args nest_opts
|
19
|
+
nest_name = nest_opts[:nest_name].to_s
|
20
|
+
new_args = { name: nest_name, type: nest_opts[:type] }
|
25
21
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
22
|
+
new_args[:supercard] = card unless nest_name.strip.blank?
|
23
|
+
# special case. gets absolutized incorrectly. fix in smartname?
|
24
|
+
|
25
|
+
nest_new_main_args new_args if nest_name =~ /^_main\+/
|
26
|
+
nest_new_content_args new_args, nest_name
|
27
|
+
new_args
|
32
28
|
end
|
33
29
|
|
34
|
-
def
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
# FIXME: this is a rather hacky (and untested) way to get @superleft
|
40
|
-
# to work on new cards named _main+whatever
|
41
|
-
args[:name] = args[:name].gsub(/^_main\+/, "+")
|
42
|
-
args[:supercard] = root.card
|
43
|
-
end
|
44
|
-
if (content = nest_content opts[:inc_name])
|
45
|
-
args[:content] = content
|
46
|
-
end
|
47
|
-
args
|
30
|
+
def nest_new_main_args new_args
|
31
|
+
# FIXME: this is a rather hacky way to get @superleft
|
32
|
+
# to work on new cards named _main+whatever
|
33
|
+
new_args[:name] = new_args[:name].gsub(/^_main\+/, "+")
|
34
|
+
new_args[:supercard] = root.card
|
48
35
|
end
|
36
|
+
|
37
|
+
def nest_new_content_args new_args, nest_name
|
38
|
+
content = nest_content_from_shorthand_param(nest_name) ||
|
39
|
+
nest_content_from_subcard_params(nest_name)
|
40
|
+
new_args[:content] = content if content.present?
|
41
|
+
end
|
42
|
+
|
43
|
+
def nest_content_from_shorthand_param nest_name
|
44
|
+
shorthand_param = nest_name.tr "+", "_"
|
45
|
+
# FIXME: this is a lame shorthand; could be another card's key
|
46
|
+
# should be more robust and managed by Card::Name
|
47
|
+
params[shorthand_param]
|
48
|
+
end
|
49
|
+
|
50
|
+
def nest_content_from_subcard_params nest_name
|
51
|
+
return unless (subcard_params = params["subcards"])
|
52
|
+
return unless (nestcard_params = subcard_params[nest_name])
|
53
|
+
nestcard_params["content"]
|
54
|
+
end
|
55
|
+
|
49
56
|
end
|
50
57
|
end
|
51
58
|
end
|