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
@@ -0,0 +1,81 @@
|
|
1
|
+
format do
|
2
|
+
def limit
|
3
|
+
default_limit
|
4
|
+
end
|
5
|
+
|
6
|
+
def offset
|
7
|
+
search_params[:offset] || 0
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
format :html do
|
12
|
+
def with_paging path_args={}
|
13
|
+
paging_path_args path_args
|
14
|
+
output [yield, _optional_render_paging]
|
15
|
+
end
|
16
|
+
|
17
|
+
view :paging, cache: :never do
|
18
|
+
return "" unless paging_needed?
|
19
|
+
<<-HTML
|
20
|
+
<nav>
|
21
|
+
<ul class="pagination paging">
|
22
|
+
#{paging_links.join}
|
23
|
+
</ul>
|
24
|
+
</nav>
|
25
|
+
HTML
|
26
|
+
end
|
27
|
+
|
28
|
+
def paging_links
|
29
|
+
total_pages = ((count_with_params - 1) / limit).to_i
|
30
|
+
current_page = (offset / limit).to_i
|
31
|
+
PagingLinks.new(total_pages, current_page)
|
32
|
+
.build do |text, page, status, options|
|
33
|
+
page_link_li text, page, status, options
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# First page is 0 (not 1)
|
38
|
+
def page_link_li text, page, status, options={}
|
39
|
+
wrap_with :li, class: status do
|
40
|
+
page_link text, page, options
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def page_link text, page, options
|
45
|
+
return text unless page
|
46
|
+
paging_path_args[:offset] = page * limit
|
47
|
+
options.merge! class: "card-paging-link slotter",
|
48
|
+
remote: true,
|
49
|
+
path: paging_path_args
|
50
|
+
link_to raw(text), options
|
51
|
+
end
|
52
|
+
|
53
|
+
def paging_path_args local_args={}
|
54
|
+
@paging_path_args ||= {
|
55
|
+
limit: limit,
|
56
|
+
view: voo.home_view,
|
57
|
+
slot: voo.slot_options
|
58
|
+
}.merge(extra_paging_path_args).merge local_args
|
59
|
+
end
|
60
|
+
|
61
|
+
def paging_view
|
62
|
+
(voo && voo.home_view) || :content
|
63
|
+
end
|
64
|
+
|
65
|
+
def extra_paging_path_args
|
66
|
+
{}
|
67
|
+
end
|
68
|
+
|
69
|
+
def paging_needed?
|
70
|
+
return false if limit < 1
|
71
|
+
return false if fewer_results_than_limit? # avoid extra count search
|
72
|
+
# count search result instead
|
73
|
+
limit < count_with_params
|
74
|
+
end
|
75
|
+
|
76
|
+
# clear we don't need paging even before running count query
|
77
|
+
def fewer_results_than_limit?
|
78
|
+
return false unless offset.zero?
|
79
|
+
limit > offset + search_with_params.length
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
#! no set module
|
2
|
+
|
3
|
+
# render paging links
|
4
|
+
class PagingLinks
|
5
|
+
def initialize total_pages, current_page
|
6
|
+
@total = total_pages
|
7
|
+
@current = current_page
|
8
|
+
end
|
9
|
+
|
10
|
+
# @param window [integer] number of page links shown left and right
|
11
|
+
# of the current page
|
12
|
+
# @example: current page = 5, window = 2
|
13
|
+
# |<<|1|...|3|4|[5]|6|7|...|10|>>|
|
14
|
+
# @yield [text, page, status, options] block to build single paging link
|
15
|
+
# @yieldparam status [Symbol] :active (for current page) or :disabled
|
16
|
+
# @yieldparam page [Integer] page number, first page is 0
|
17
|
+
# @return [Array<String>]
|
18
|
+
def build window=2, &block
|
19
|
+
@render_item = block
|
20
|
+
links window
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def links window
|
26
|
+
@window_start = [@current - window, 0].max
|
27
|
+
@window_end = [@current + window, @total].min
|
28
|
+
left_part + window_part + right_part
|
29
|
+
end
|
30
|
+
|
31
|
+
# the links around the current page
|
32
|
+
def window_part
|
33
|
+
(@window_start..@window_end).map do |page|
|
34
|
+
direct_page_link page
|
35
|
+
end.compact
|
36
|
+
end
|
37
|
+
|
38
|
+
def left_part
|
39
|
+
[
|
40
|
+
previous_page_link,
|
41
|
+
(direct_page_link 0 if @window_start > 0),
|
42
|
+
(ellipse if @window_start > 1)
|
43
|
+
].compact
|
44
|
+
end
|
45
|
+
|
46
|
+
def right_part
|
47
|
+
[
|
48
|
+
(ellipse if @total > @window_end + 1),
|
49
|
+
(direct_page_link @total if @total > @window_end),
|
50
|
+
next_page_link
|
51
|
+
].compact
|
52
|
+
end
|
53
|
+
|
54
|
+
def previous_page_link
|
55
|
+
paging_item '<span aria-hidden="true">«</span>', previous_page,
|
56
|
+
"aria-label" => "Previous"
|
57
|
+
end
|
58
|
+
|
59
|
+
def next_page_link
|
60
|
+
paging_item '<span aria-hidden="true">»</span>', next_page,
|
61
|
+
"aria-label" => "Next"
|
62
|
+
end
|
63
|
+
|
64
|
+
def direct_page_link page
|
65
|
+
return unless page >= 0 && page <= @total
|
66
|
+
paging_item page + 1, page
|
67
|
+
end
|
68
|
+
|
69
|
+
def ellipse
|
70
|
+
@render_item.call "<span>...</span>", false
|
71
|
+
end
|
72
|
+
|
73
|
+
def paging_item text, page, options={}
|
74
|
+
status =
|
75
|
+
if page == @current
|
76
|
+
:active
|
77
|
+
elsif !page
|
78
|
+
:disabled
|
79
|
+
end
|
80
|
+
@render_item.call text, page, status, options
|
81
|
+
end
|
82
|
+
|
83
|
+
def previous_page
|
84
|
+
@current > 0 ? @current - 1 : false
|
85
|
+
end
|
86
|
+
|
87
|
+
def next_page
|
88
|
+
@current < @total ? @current + 1 : false
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
include_set Abstract::Search
|
2
|
+
|
3
|
+
def search args={}
|
4
|
+
query = fetch_query(args)
|
5
|
+
# forces explicit limiting
|
6
|
+
# can be 0 or less to force no limit
|
7
|
+
raise "OH NO.. no limit" unless query.mods[:limit]
|
8
|
+
query.run
|
9
|
+
end
|
10
|
+
|
11
|
+
# override this to define search
|
12
|
+
def wql_hash
|
13
|
+
@wql_hash ||= begin
|
14
|
+
query = raw_content
|
15
|
+
query = query.is_a?(Hash) ? query : parse_json_query(query)
|
16
|
+
query.symbolize_keys
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def query args={}
|
21
|
+
query_args = wql_hash.merge! args
|
22
|
+
query_args = standardized_query_args query_args
|
23
|
+
Query.new query_args, name
|
24
|
+
end
|
25
|
+
|
26
|
+
def fetch_query args={}
|
27
|
+
@query ||= {}
|
28
|
+
@query[args.to_s] ||= query(args.clone) # cache query
|
29
|
+
end
|
30
|
+
|
31
|
+
def standardized_query_args args
|
32
|
+
args = args.symbolize_keys
|
33
|
+
args[:context] ||= cardname
|
34
|
+
args
|
35
|
+
end
|
36
|
+
|
37
|
+
def parse_json_query query
|
38
|
+
empty_query_error! if query.empty?
|
39
|
+
JSON.parse query
|
40
|
+
rescue
|
41
|
+
raise Error::BadQuery, "Invalid JSON search query: #{query}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def empty_query_error!
|
45
|
+
raise Error::BadQuery,
|
46
|
+
"Error in card '#{name}':can't run search with empty content"
|
47
|
+
end
|
48
|
+
|
49
|
+
format do
|
50
|
+
def default_search_params
|
51
|
+
@default_search_params ||= { limit: (card_content_limit || default_limit) }
|
52
|
+
end
|
53
|
+
|
54
|
+
def card_content_limit
|
55
|
+
card.wql_hash[:limit]
|
56
|
+
rescue
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
|
60
|
+
def query_with_params
|
61
|
+
@query_with_params ||= card.fetch_query search_params
|
62
|
+
end
|
63
|
+
|
64
|
+
def limit
|
65
|
+
query_with_params.limit
|
66
|
+
end
|
67
|
+
end
|
@@ -9,8 +9,8 @@ format do
|
|
9
9
|
""
|
10
10
|
end
|
11
11
|
|
12
|
-
view :unsupported_view, perms: :none, tags: :unknown_ok do
|
13
|
-
"view (#{
|
12
|
+
view :unsupported_view, perms: :none, tags: :unknown_ok do
|
13
|
+
"view (#{voo.unsupported_view}) not supported for #{error_cardname}"
|
14
14
|
end
|
15
15
|
|
16
16
|
view :missing, perms: :none do
|
@@ -48,31 +48,31 @@ format do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
format :html do
|
51
|
-
def view_for_unknown view
|
51
|
+
def view_for_unknown view
|
52
52
|
case
|
53
|
-
when focal? && ok?(:create)
|
54
|
-
when commentable?(view
|
53
|
+
when focal? && ok?(:create) then :new
|
54
|
+
when commentable?(view) then view
|
55
55
|
else super
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
def commentable? view
|
60
|
-
return false unless self.class.tagged
|
61
|
-
|
62
|
-
return false unless show_view? :comment_box, visibility_args
|
59
|
+
def commentable? view
|
60
|
+
return false unless self.class.tagged(view, :comment) &&
|
61
|
+
show_view?(:comment_box, :hide)
|
63
62
|
ok? :comment
|
64
63
|
end
|
65
64
|
|
66
65
|
def rendering_error exception, view
|
66
|
+
debug_error exception if Auth.always_ok?
|
67
67
|
details = Auth.always_ok? ? backtrace_link(exception) : error_cardname
|
68
|
-
|
68
|
+
wrap_with :span, class: "render-error alert alert-danger" do
|
69
69
|
["error rendering", details, "(#{view} view)"].join "\n"
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
73
|
def backtrace_link exception
|
74
|
-
|
75
|
-
warning = alert("warning",
|
74
|
+
class_up "alert", "render-error-message errors-view admin-error-message"
|
75
|
+
warning = alert("warning", true) do
|
76
76
|
%{
|
77
77
|
<h3>Error message (visible to admin only)</h3>
|
78
78
|
<p><strong>#{exception.message}</strong></p>
|
@@ -83,39 +83,38 @@ format :html do
|
|
83
83
|
link + warning
|
84
84
|
end
|
85
85
|
|
86
|
-
view :unsupported_view, perms: :none, tags: :unknown_ok do
|
86
|
+
view :unsupported_view, perms: :none, tags: :unknown_ok do
|
87
87
|
%(
|
88
88
|
<strong>
|
89
|
-
view <em>#{
|
89
|
+
view <em>#{voo.unsupported_view}</em>
|
90
90
|
not supported for <em>#{error_cardname}</em>
|
91
91
|
</strong>
|
92
92
|
)
|
93
93
|
end
|
94
94
|
|
95
|
-
view :message, perms: :none, tags: :unknown_ok do
|
96
|
-
frame
|
97
|
-
params[:message]
|
98
|
-
end
|
95
|
+
view :message, perms: :none, tags: :unknown_ok do
|
96
|
+
frame { params[:message] }
|
99
97
|
end
|
100
98
|
|
101
|
-
view :missing do
|
99
|
+
view :missing do
|
102
100
|
return "" unless card.ok? :create # should this be moved into ok_view?
|
103
|
-
path_opts =
|
104
|
-
link_text = "Add #{fancy_title
|
105
|
-
klass = "slotter missing-#{
|
106
|
-
wrap
|
101
|
+
path_opts = voo.type ? { card: { type: voo.type } } : {}
|
102
|
+
link_text = "Add #{fancy_title _render_title}"
|
103
|
+
klass = "slotter missing-#{@denied_view || voo.home_view}"
|
104
|
+
wrap { link_to_view :new, link_text, path: path_opts, class: klass }
|
107
105
|
end
|
108
106
|
|
109
107
|
view :closed_missing, perms: :none do
|
110
|
-
|
108
|
+
wrap_with :span, showname, class: "faint"
|
111
109
|
end
|
112
110
|
|
113
|
-
view :conflict, error_code: 409 do
|
111
|
+
view :conflict, error_code: 409 do
|
114
112
|
actor_link = link_to_card card.last_action.act.actor.cardname
|
115
|
-
expanded_act = wrap
|
113
|
+
expanded_act = wrap do
|
116
114
|
_render_act_expanded act: card.last_action.act, current_rev_nr: 0
|
117
115
|
end
|
118
|
-
|
116
|
+
class_up "card-slot", "error-view"
|
117
|
+
wrap do # ENGLISH below
|
119
118
|
alert "warning" do
|
120
119
|
%(
|
121
120
|
<strong>Conflict!</strong>
|
@@ -128,72 +127,80 @@ format :html do
|
|
128
127
|
end
|
129
128
|
end
|
130
129
|
|
131
|
-
view :errors, perms: :none do
|
132
|
-
if card.errors.
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
end
|
142
|
-
alert "warning", dismissible: true, alert_class: "card-error-msg" do
|
143
|
-
msg
|
144
|
-
end
|
130
|
+
view :errors, perms: :none do
|
131
|
+
return if card.errors.empty?
|
132
|
+
voo.title = card.name.blank? ? "Problems" : "Problems with #{card.name}"
|
133
|
+
voo.hide! :menu
|
134
|
+
class_up "card-frame", "panel panel-warning"
|
135
|
+
class_up "alert", "card-error-msg"
|
136
|
+
frame do
|
137
|
+
card.errors.map do |attrib, msg|
|
138
|
+
alert "warning", true do
|
139
|
+
attrib == :abort ? msg : standard_error_message(attrib, msg)
|
145
140
|
end
|
146
141
|
end
|
147
142
|
end
|
148
143
|
end
|
149
144
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
145
|
+
def standard_error_message attribute, message
|
146
|
+
"<strong>#{attribute.to_s.upcase}:</strong> #{message}"
|
147
|
+
end
|
148
|
+
|
149
|
+
view :not_found do # ug. bad name.
|
150
|
+
voo.hide! :menu
|
151
|
+
voo.title = "Not Found"
|
152
|
+
card_label = card.name.present? ? "<em>#{card.name}</em>" : "that"
|
153
|
+
frame do
|
154
|
+
[wrap_with(:h2) { "Could not find #{card_label}." },
|
155
|
+
sign_in_or_up_links]
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def sign_in_or_up_links
|
160
|
+
return if Auth.signed_in?
|
161
|
+
signin_link = link_to_card :signin, "Sign in"
|
162
|
+
signup_link = link_to "Sign up", path: { action: :new, mark: :signup }
|
163
|
+
wrap_with(:div) { "#{signin_link} or #{signup_link} to create it." }
|
164
|
+
end
|
165
|
+
|
166
|
+
view :denial do
|
167
|
+
focal? ? loud_denial : quiet_denial
|
168
|
+
end
|
169
|
+
|
170
|
+
def quiet_denial
|
171
|
+
wrap_with :span, class: "denied" do
|
172
|
+
"<!-- Sorry, you don't have permission (#{@denied_task}) -->"
|
160
173
|
end
|
161
174
|
end
|
162
175
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
176
|
+
def loud_denial
|
177
|
+
frame do
|
178
|
+
[
|
179
|
+
wrap_with(:h1, "Sorry!"),
|
180
|
+
wrap_with(:div, loud_denial_message)
|
181
|
+
]
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
def loud_denial_message
|
186
|
+
to_task = @denied_task ? "to #{@denied_task} this." : "to do that."
|
187
|
+
case
|
188
|
+
when @denied_task != :read && Card.config.read_only
|
189
|
+
"We are currently in read-only mode. Please try again later."
|
190
|
+
when Auth.signed_in?
|
191
|
+
"You need permission #{to_task}"
|
172
192
|
else
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
when task != :read && Card.config.read_only
|
177
|
-
"We are currently in read-only mode. Please try again later."
|
178
|
-
when Auth.signed_in?
|
179
|
-
"You need permission #{to_task}"
|
180
|
-
else
|
181
|
-
signin_link = link_to_card :signin, "sign in"
|
182
|
-
or_signup_link =
|
183
|
-
if Card.new(type_id: Card::SignupID).ok? :create
|
184
|
-
"or " +
|
185
|
-
link_to("sign up", path: { action: "new", mark: :signup })
|
186
|
-
end
|
187
|
-
Env.save_interrupted_action(request.env["REQUEST_URI"])
|
188
|
-
"Please #{signin_link} #{or_signup_link} #{to_task}"
|
189
|
-
end
|
193
|
+
denial_message_with_links to_task
|
194
|
+
end
|
195
|
+
end
|
190
196
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
end
|
197
|
+
def denial_message_with_links to_task
|
198
|
+
linx = [link_to_card(:signin, "sign in")]
|
199
|
+
if Card.new(type_id: Card::SignupID).ok?(:create)
|
200
|
+
linx += ["or", link_to("sign up", path: { action: "new", mark: :signup })]
|
196
201
|
end
|
202
|
+
Env.save_interrupted_action request.env["REQUEST_URI"]
|
203
|
+
"Please #{linx.join ' '} #{to_task}"
|
197
204
|
end
|
198
205
|
|
199
206
|
view :server_error do
|