card 1.19.6 → 1.20.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 +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
data/lib/generators/card.rb
CHANGED
@@ -10,19 +10,33 @@ class Card
|
|
10
10
|
if path
|
11
11
|
@_card_source_root = path
|
12
12
|
else
|
13
|
-
@_card_source_root ||= File.expand_path(
|
13
|
+
@_card_source_root ||= File.expand_path(
|
14
|
+
File.join(File.dirname(__FILE__),
|
15
|
+
"card", generator_name, "templates")
|
16
|
+
)
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
17
20
|
# Override Rails default banner (wagn is the command name).
|
18
21
|
def banner
|
19
|
-
|
22
|
+
usage_arguments = arguments.map(&:usage) * " "
|
23
|
+
text = "wagn generate #{namespace} #{usage_arguments} [options]"
|
24
|
+
text.gsub(/\s+/, " ")
|
20
25
|
end
|
21
26
|
end
|
22
27
|
|
23
28
|
class NamedBase < ::Rails::Generators::NamedBase
|
24
29
|
extend ClassMethods
|
30
|
+
|
31
|
+
def mod_path
|
32
|
+
@mod_path ||= begin
|
33
|
+
path_parts = ["mod", file_name]
|
34
|
+
path_parts.unshift Cardio.gem_root if options.core?
|
35
|
+
File.join(*path_parts)
|
36
|
+
end
|
37
|
+
end
|
25
38
|
end
|
39
|
+
|
26
40
|
class MigrationBase < ::ActiveRecord::Generators::Base
|
27
41
|
extend ClassMethods
|
28
42
|
end
|
@@ -8,19 +8,20 @@ class Card
|
|
8
8
|
source_root File.expand_path("../templates", __FILE__)
|
9
9
|
|
10
10
|
argument :module_name, required: true
|
11
|
-
class_option "core", type: :boolean, aliases: "-c",
|
11
|
+
class_option "core", type: :boolean, aliases: "-c",
|
12
|
+
default: false, group: :runtime,
|
12
13
|
desc: "create format files in Card gem"
|
13
14
|
|
14
15
|
def create_files
|
15
|
-
mod_path = if options.core?
|
16
|
-
File.join Cardio.gem_root, "mod", file_name
|
17
|
-
else
|
18
|
-
File.join "mod", file_name
|
19
|
-
end
|
20
|
-
format_path = File.join(mod_path, "format", "#{module_name}_format.rb")
|
21
|
-
spec_path = File.join(mod_path, "spec", "format", "#{module_name}_format_spec.rb")
|
22
16
|
template "format_template.erb", format_path
|
23
|
-
template "format_spec_template.erb",
|
17
|
+
template "format_spec_template.erb", format_path("spec")
|
18
|
+
end
|
19
|
+
|
20
|
+
def format_path modifier=nil
|
21
|
+
suffix = modifier ? "_#{modifier}" : nil
|
22
|
+
filename = "#{module_name}_format#{suffix}.rb"
|
23
|
+
path_parts = [mod_path, modifier, "format", filename].compact
|
24
|
+
File.join(*path_parts)
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
@@ -7,7 +7,8 @@ class Card
|
|
7
7
|
class MigrationGenerator < MigrationBase
|
8
8
|
source_root File.expand_path("../templates", __FILE__)
|
9
9
|
|
10
|
-
class_option "core", type: :boolean, aliases: "-c",
|
10
|
+
class_option "core", type: :boolean, aliases: "-c",
|
11
|
+
default: false, group: :runtime,
|
11
12
|
desc: "Create card migration for card core"
|
12
13
|
|
13
14
|
def create_migration_file
|
@@ -15,18 +16,22 @@ class Card
|
|
15
16
|
mig_paths = Cardio.migration_paths(migration_type)
|
16
17
|
raise "No migration directory for #{migration_type}" if mig_paths.blank?
|
17
18
|
set_local_assigns!
|
18
|
-
migration_template @migration_template,
|
19
|
+
migration_template @migration_template,
|
20
|
+
File.join(mig_paths.first, "#{file_name}.rb")
|
19
21
|
end
|
20
22
|
|
21
23
|
protected
|
22
24
|
|
23
|
-
# sets the default migration template that is being used for the
|
24
|
-
#
|
25
|
+
# sets the default migration template that is being used for the
|
26
|
+
# generation of the migration
|
27
|
+
# depending on the arguments which would be sent out in the command line,
|
28
|
+
# the migration template
|
25
29
|
# and the table name instance variables are setup.
|
26
30
|
|
27
31
|
def set_local_assigns!
|
28
32
|
@migration_template = "card_migration.erb"
|
29
|
-
@migration_parent_class =
|
33
|
+
@migration_parent_class =
|
34
|
+
options["core"] ? "Card::Migration::Core" : "Card::Migration"
|
30
35
|
case file_name
|
31
36
|
when /^(import)_(.*)(?:\.json)?/
|
32
37
|
@migration_action = Regexp.last_match(1)
|
@@ -9,19 +9,21 @@ class Card
|
|
9
9
|
|
10
10
|
argument :set_pattern, required: true
|
11
11
|
argument :anchors, required: true, type: :array
|
12
|
-
class_option "core", type: :boolean, aliases: "-c",
|
12
|
+
class_option "core", type: :boolean, aliases: "-c",
|
13
|
+
default: false, group: :runtime,
|
13
14
|
desc: "create set files in Card gem"
|
14
15
|
|
15
16
|
def create_files
|
16
|
-
mod_path = if options.core?
|
17
|
-
File.join Cardio.gem_root, "mod", file_name
|
18
|
-
else
|
19
|
-
File.join "mod", file_name
|
20
|
-
end
|
21
|
-
set_path = File.join(mod_path, "set", set_pattern, anchors[0..-2], "#{anchors.last}.rb")
|
22
|
-
spec_path = File.join(mod_path, "spec", "set", set_pattern, anchors[0..-2], "#{anchors.last}_spec.rb")
|
23
17
|
template "set_template.erb", set_path
|
24
|
-
template "set_spec_template.erb",
|
18
|
+
template "set_spec_template.erb", set_path("spec")
|
19
|
+
end
|
20
|
+
|
21
|
+
def set_path modifier=nil
|
22
|
+
suffix = modifier ? "_#{modifier}" : nil
|
23
|
+
filename = "#{anchors.last}#{suffix}.rb"
|
24
|
+
dirs = anchors[0..-2]
|
25
|
+
path_parts = [mod_path, modifier, "set", set_pattern, dirs, filename]
|
26
|
+
File.join(*path_parts.compact)
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
include All::Permissions::Accounts
|
3
2
|
|
4
3
|
card_accessor :email
|
@@ -30,12 +29,13 @@ def validate_token! test_token
|
|
30
29
|
errors.empty?
|
31
30
|
end
|
32
31
|
|
32
|
+
def refreshed_token # TODO: explain why needed
|
33
|
+
token_card.refresh(true).content
|
34
|
+
end
|
35
|
+
|
33
36
|
format do
|
34
37
|
view :verify_url do
|
35
|
-
|
36
|
-
card_url "update/#{signup_name.url_key}" \
|
37
|
-
"?token=#{card.token}" \
|
38
|
-
"&live_token=true"
|
38
|
+
card_url path({ mark: card.cardname.left }.merge(token_path_opts))
|
39
39
|
end
|
40
40
|
|
41
41
|
view :verify_days do
|
@@ -43,9 +43,11 @@ format do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
view :reset_password_url do
|
46
|
-
card_url
|
47
|
-
|
48
|
-
|
46
|
+
card_url path({ mark: card, event: :reset_password }.merge(token_path_opts))
|
47
|
+
end
|
48
|
+
|
49
|
+
def token_path_opts
|
50
|
+
{ action: :update, live_token: true, token: card.refreshed_token }
|
49
51
|
end
|
50
52
|
|
51
53
|
view :reset_password_days do
|
@@ -54,20 +56,14 @@ format do
|
|
54
56
|
end
|
55
57
|
|
56
58
|
format :html do
|
57
|
-
view :raw do
|
58
|
-
|
59
|
-
|
60
|
-
content << "{{+#{Card[:email].name}|titled;title:email}}"
|
61
|
-
end
|
62
|
-
unless args[:no_password]
|
63
|
-
content << "{{+#{Card[:password].name}|titled;title:password}}"
|
64
|
-
end
|
65
|
-
content * " "
|
59
|
+
view :raw do
|
60
|
+
%({{+#{Card[:email].name}|titled;title:email}}
|
61
|
+
{{+#{Card[:password].name}|titled;title:password}})
|
66
62
|
end
|
67
63
|
|
68
|
-
view :edit do
|
69
|
-
|
70
|
-
super
|
64
|
+
view :edit do
|
65
|
+
voo.structure = true
|
66
|
+
super()
|
71
67
|
end
|
72
68
|
end
|
73
69
|
|
@@ -97,34 +93,36 @@ def confirm_ok?
|
|
97
93
|
Card.new(type_id: Card.default_accounted_type_id).ok? :create
|
98
94
|
end
|
99
95
|
|
100
|
-
event :generate_confirmation_token,
|
101
|
-
on: :create,
|
102
|
-
when: proc { |c| c.confirm_ok? } do
|
96
|
+
event :generate_confirmation_token,
|
97
|
+
:prepare_to_store, on: :create, when: :confirm_ok? do
|
103
98
|
add_subfield :token, content: generate_token
|
104
99
|
end
|
105
100
|
|
106
101
|
event :reset_password,
|
107
|
-
:prepare_to_validate, on: :update, when:
|
108
|
-
|
109
|
-
|
110
|
-
Auth.signin left_id
|
111
|
-
success << edit_password_success_args
|
112
|
-
else
|
113
|
-
error_msg = errors.first.last
|
114
|
-
send_reset_password_token
|
115
|
-
msg = "Sorry, #{error_msg}. " \
|
116
|
-
"Please check your email for a new password reset link."
|
117
|
-
success << { id: "_self", view: "message", message: msg }
|
118
|
-
end
|
102
|
+
:prepare_to_validate, on: :update, when: :reset_password? do
|
103
|
+
valid = validate_token! @env_token
|
104
|
+
success << (valid ? reset_password_success : reset_password_try_again)
|
119
105
|
abort :success
|
120
106
|
end
|
121
107
|
|
108
|
+
def reset_password_success
|
109
|
+
token_card.used!
|
110
|
+
Auth.signin left_id
|
111
|
+
{ id: left.name, view: :related, related: { name: "+#{Card[:account].name}",
|
112
|
+
view: "edit" } }
|
113
|
+
end
|
114
|
+
|
115
|
+
def reset_password_try_again
|
116
|
+
send_reset_password_token
|
117
|
+
{ id: "_self",
|
118
|
+
view: "message",
|
119
|
+
message: "Sorry, #{errors.first.last}. " \
|
120
|
+
"Please check your email for a new password reset link." }
|
121
|
+
end
|
122
|
+
|
123
|
+
|
122
124
|
def edit_password_success_args
|
123
|
-
|
124
|
-
id: left.name,
|
125
|
-
view: :related,
|
126
|
-
related: { name: "+#{Card[:account].name}", view: "edit" }
|
127
|
-
}
|
125
|
+
|
128
126
|
end
|
129
127
|
|
130
128
|
def reset_password?
|
@@ -1,80 +1,60 @@
|
|
1
1
|
|
2
2
|
format :html do
|
3
|
-
def item_links
|
4
|
-
[
|
5
|
-
optional_render
|
6
|
-
|
7
|
-
optional_render(:sign_out, args),
|
8
|
-
optional_render(:sign_up, args),
|
9
|
-
optional_render(:sign_in, args)
|
10
|
-
]
|
11
|
-
end
|
12
|
-
|
13
|
-
view :sign_up, perms: ->(r) { r.show_signup_link? },
|
14
|
-
denial: :blank do |args|
|
15
|
-
link_to_card :signup, args[:link_text], args[:link_opts]
|
16
|
-
end
|
17
|
-
|
18
|
-
view :sign_in, perms: ->(_r) { !Auth.signed_in? },
|
19
|
-
denial: :blank do |args|
|
20
|
-
link_to_card :signin, args[:link_text], args[:link_opts]
|
21
|
-
end
|
22
|
-
|
23
|
-
view :sign_out, perms: ->(_r) { Auth.signed_in? },
|
24
|
-
denial: :blank do |args|
|
25
|
-
link_to_card :signin, args[:link_text], args[:link_opts]
|
3
|
+
def item_links _args=nil
|
4
|
+
[:my_card, :invite, :sign_out, :sign_up, :sign_in].map do |link_view|
|
5
|
+
optional_render link_view
|
6
|
+
end
|
26
7
|
end
|
27
8
|
|
28
|
-
|
29
|
-
|
30
|
-
|
9
|
+
def self.link_options opts={}
|
10
|
+
options = { denial: :blank, cache: :never }.merge opts
|
11
|
+
options[:perms] = ->(r) { yield r } if block_given?
|
12
|
+
options.clone
|
31
13
|
end
|
32
14
|
|
33
|
-
view :
|
34
|
-
|
35
|
-
|
15
|
+
view :sign_up, link_options(&:show_signup_link?) do
|
16
|
+
link_to_card :signup, account_link_text(:sign_up),
|
17
|
+
class: classy("signup-link"),
|
18
|
+
path: { action: :new, mark: :signup }
|
36
19
|
end
|
37
20
|
|
38
|
-
|
39
|
-
|
40
|
-
|
21
|
+
view :sign_in, link_options { !Auth.signed_in? } do
|
22
|
+
link_to_card :signin, account_link_text(:sign_in),
|
23
|
+
class: classy("signin-link")
|
41
24
|
end
|
42
25
|
|
43
|
-
|
44
|
-
|
45
|
-
|
26
|
+
view :sign_out, link_options { Auth.signed_in? } do
|
27
|
+
link_to_card :signin, account_link_text(:sign_out),
|
28
|
+
class: classy("signout-link"),
|
29
|
+
path: { action: :delete }
|
46
30
|
end
|
47
31
|
|
48
|
-
|
49
|
-
|
50
|
-
|
32
|
+
view :invite, link_options(&:show_invite_link?) do
|
33
|
+
link_to_card :signup, account_link_text(:invite),
|
34
|
+
class: classy("invite-link"),
|
35
|
+
path: { action: :new, mark: :signup }
|
51
36
|
end
|
52
37
|
|
53
|
-
|
54
|
-
|
55
|
-
account_link_opts "signout-link", args, action: :delete
|
38
|
+
view :my_card, link_options { Auth.signed_in? } do
|
39
|
+
link_to_card Auth.current.cardname, nil, id: "my-card-link"
|
56
40
|
end
|
57
41
|
|
58
|
-
def account_link_text purpose
|
59
|
-
|
60
|
-
args.delete(:title) ||
|
42
|
+
def account_link_text purpose
|
43
|
+
voo.title ||
|
61
44
|
I18n.t(purpose, scope: "mod.standard.set.self.account_links")
|
62
45
|
end
|
63
46
|
|
64
|
-
|
65
|
-
|
66
|
-
args[:link_opts][:id] ||= id
|
67
|
-
args[:link_opts][:path] ||= path if path
|
47
|
+
view :raw do
|
48
|
+
item_links.join " "
|
68
49
|
end
|
69
50
|
|
70
|
-
view :
|
71
|
-
|
72
|
-
end
|
51
|
+
view(:navbar_right, cache: :never) { super() }
|
52
|
+
|
73
53
|
|
74
|
-
view :core do
|
54
|
+
view :core, cache: :never do
|
75
55
|
status_class = Auth.signed_in? ? "logged-in" : "logged-out"
|
76
|
-
|
77
|
-
render_raw
|
56
|
+
wrap_with :span, id: "logging", class: status_class do
|
57
|
+
render_raw
|
78
58
|
end
|
79
59
|
end
|
80
60
|
|
@@ -1,89 +1,105 @@
|
|
1
|
+
def consider_recaptcha?
|
2
|
+
false
|
3
|
+
end
|
1
4
|
|
2
5
|
format :html do
|
3
|
-
view :open do
|
4
|
-
|
5
|
-
super
|
6
|
+
view :open do
|
7
|
+
voo.show :help
|
8
|
+
super()
|
6
9
|
end
|
7
10
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
+
# FIXME: need a generic solution for this
|
12
|
+
view :title do
|
13
|
+
voo.title ||= I18n.t(:sign_in_title, scope: "mod.standard.set.self.signin")
|
14
|
+
super()
|
11
15
|
end
|
12
16
|
|
13
|
-
view :open_content do
|
17
|
+
view :open_content do
|
14
18
|
# annoying step designed to avoid table of contents. sigh
|
15
|
-
_render_core
|
19
|
+
_render_core
|
16
20
|
end
|
17
21
|
|
18
|
-
view :closed_content do
|
22
|
+
view :closed_content do
|
19
23
|
""
|
20
24
|
end
|
21
25
|
|
22
|
-
|
23
|
-
|
24
|
-
sign_in, or_sign_up, reset_password =
|
25
|
-
I18n.t([:sign_in, :or_sign_up, :reset_password],
|
26
|
-
scope: "mod.standard.set.self.signin")
|
27
|
-
# since i18n-tasks doesn't understand bulk lookups, tell it keys are used
|
28
|
-
# i18n-tasks-use t(:sign_in, scope: 'mod.standard.set.self.signin')
|
29
|
-
# i18n-tasks-use t(:or_sign_up, scope: 'mod.standard.set.self.signin')
|
30
|
-
# i18n-tasks-use t(:reset_password,
|
31
|
-
# scope: 'mod.standard.set.self.signin')
|
32
|
-
args[:buttons] = button_tag sign_in, situation: "primary"
|
33
|
-
subformat(Card[:account_links]).render :sign_up, title: or_sign_up
|
34
|
-
reset_link = link_to_view :edit, reset_password,
|
35
|
-
path: { slot: { hide: :toolbar } }
|
36
|
-
args[:buttons] += raw("<div style='float:right'>#{reset_link}</div>")
|
37
|
-
# FIXME: hardcoded styling
|
38
|
-
args
|
39
|
-
end
|
40
|
-
|
41
|
-
view :core do |args|
|
42
|
-
form_args = {
|
43
|
-
hidden: { success: "REDIRECT: #{Env.interrupted_action || '*previous'}" },
|
44
|
-
recaptcha: :off
|
45
|
-
}
|
26
|
+
view :core, cache: :never do
|
27
|
+
voo.structure = true
|
46
28
|
with_nest_mode :edit do
|
47
|
-
card_form :update,
|
29
|
+
card_form :update, recaptcha: :off do
|
48
30
|
[
|
49
|
-
|
50
|
-
|
51
|
-
|
31
|
+
hidden_signin_fields,
|
32
|
+
_optional_render_content_formgroup,
|
33
|
+
_optional_render_signin_buttons
|
34
|
+
]
|
52
35
|
end
|
53
36
|
end
|
54
37
|
end
|
55
38
|
|
39
|
+
def hidden_signin_fields
|
40
|
+
hidden_field_tag :success,
|
41
|
+
"REDIRECT: #{Env.interrupted_action || '*previous'}"
|
42
|
+
end
|
43
|
+
|
44
|
+
view :signin_buttons do
|
45
|
+
button_formgroup do
|
46
|
+
[signin_button, signup_link, reset_password_link]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def signin_button
|
51
|
+
text = I18n.t :sign_in, scope: "mod.standard.set.self.signin"
|
52
|
+
button_tag text, situation: "primary"
|
53
|
+
end
|
54
|
+
|
55
|
+
def signup_link
|
56
|
+
text = I18n.t :or_sign_up, scope: "mod.standard.set.self.signin"
|
57
|
+
subformat(Card[:account_links]).render :sign_up, title: text
|
58
|
+
end
|
59
|
+
|
60
|
+
def reset_password_link
|
61
|
+
text = I18n.t :reset_password, scope: "mod.standard.set.self.signin"
|
62
|
+
reset_link = link_to_view :edit, text, path: { slot: { hide: :toolbar } }
|
63
|
+
# FIXME: inline styling
|
64
|
+
raw("<div style='float:right'>#{reset_link}</div>")
|
65
|
+
end
|
66
|
+
|
56
67
|
# FORGOT PASSWORD
|
57
|
-
view :edit do
|
68
|
+
view :edit do
|
58
69
|
@forgot_password = true
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
success: { view: :reset_password_success }
|
70
|
-
}
|
70
|
+
voo.title ||= card.i18n_signin(:forgot_password)
|
71
|
+
voo.structure ||= true
|
72
|
+
voo.hide :help
|
73
|
+
Auth.as_bot { super() }
|
74
|
+
end
|
75
|
+
|
76
|
+
def edit_view_hidden
|
77
|
+
hidden_tags(
|
78
|
+
reset_password: true,
|
79
|
+
success: { view: :reset_password_success }
|
71
80
|
)
|
72
|
-
Auth.as_bot { super args }
|
73
81
|
end
|
74
82
|
|
75
|
-
view :
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
83
|
+
view :edit_buttons do
|
84
|
+
text = I18n.t :reset_my_password, scope: "mod.standard.set.self.signin"
|
85
|
+
button_tag text, situation: "primary"
|
86
|
+
end
|
87
|
+
|
88
|
+
view :content_formgroup do
|
89
|
+
fields = [signin_field(:email)]
|
90
|
+
fields << signin_field(:password) unless @forgot_password
|
91
|
+
voo.edit_structure = fields
|
92
|
+
|
93
|
+
super()
|
94
|
+
end
|
95
|
+
|
96
|
+
def signin_field name
|
97
|
+
nest_name = "".to_name.trait(name)
|
98
|
+
[nest_name, { title: name.to_s, view: "titled",
|
99
|
+
nest_name: nest_name, skip_perms: true }]
|
84
100
|
end
|
85
101
|
|
86
|
-
view :reset_password_success do
|
102
|
+
view :reset_password_success do
|
87
103
|
# 'Check your email for a link to reset your password'
|
88
104
|
frame { I18n.t(:check_email, scope: "mod.standard.set.self.signin") }
|
89
105
|
end
|
@@ -95,57 +111,55 @@ event :signin, :validate, on: :update do
|
|
95
111
|
pword = subfield :password
|
96
112
|
pword &&= pword.content
|
97
113
|
|
98
|
-
|
99
|
-
|
100
|
-
scope: "mod.standard.set.self.signin")
|
101
|
-
end
|
114
|
+
authenticate_or_abort email, pword
|
115
|
+
end
|
102
116
|
|
117
|
+
def authenticate_or_abort email, pword
|
118
|
+
abort :failure, i18n_signin(:abort_bad_signin_args) unless email && pword
|
103
119
|
if (account = Auth.authenticate(email, pword))
|
104
120
|
Auth.signin account.left_id
|
105
121
|
else
|
106
122
|
account = Auth.find_account_by_email email
|
107
|
-
|
108
|
-
case
|
109
|
-
when account.nil? then
|
110
|
-
# 'Unrecognized email.'
|
111
|
-
I18n.t(:error_unknown_email, scope: "mod.standard.set.self.signin")
|
112
|
-
when !account.active? then
|
113
|
-
# 'Sorry, that account is not active.'
|
114
|
-
I18n.t(:error_not_active, scope: "mod.standard.set.self.signin")
|
115
|
-
else
|
116
|
-
# 'Wrong password'
|
117
|
-
I18n.t(:error_wrong_password, scope: "mod.standard.set.self.signin")
|
118
|
-
end
|
119
|
-
errors.add :signin, error_msg
|
123
|
+
errors.add :signin, signin_error_message(account)
|
120
124
|
abort :failure
|
121
125
|
end
|
122
126
|
end
|
123
127
|
|
128
|
+
def signin_error_message account
|
129
|
+
case
|
130
|
+
when account.nil? then i18n_signin(:error_unknown_email)
|
131
|
+
when !account.active? then i18n_signin(:error_not_active)
|
132
|
+
else i18n_signin(:error_wrong_password)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def i18n_signin key
|
137
|
+
I18n.t key, scope: "mod.standard.set.self.signin"
|
138
|
+
end
|
139
|
+
|
124
140
|
event :signin_success, after: :signin do
|
125
141
|
abort :success
|
126
142
|
end
|
127
143
|
|
128
|
-
event :send_reset_password_token,
|
129
|
-
|
130
|
-
when: proc { Env.params[:reset_password] } do
|
144
|
+
event :send_reset_password_token, before: :signin, on: :update,
|
145
|
+
when: proc { Env.params[:reset_password] } do
|
131
146
|
email = subfield :email
|
132
147
|
email &&= email.content
|
133
148
|
|
134
149
|
account = Auth.find_account_by_email email
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
150
|
+
send_reset_password_email_or_fail account
|
151
|
+
end
|
152
|
+
|
153
|
+
def send_reset_password_email_or_fail account
|
154
|
+
if account && account.active?
|
155
|
+
account.send_reset_password_token
|
156
|
+
abort :success
|
157
|
+
elsif account
|
158
|
+
errors.add :account, i18n_signin(:error_not_active)
|
144
159
|
else
|
145
|
-
errors.add :email,
|
146
|
-
scope: "mod.standard.set.self.signin")
|
147
|
-
abort :failure
|
160
|
+
errors.add :email, i18n_signin(:error_not_recognized)
|
148
161
|
end
|
162
|
+
abort :failure
|
149
163
|
end
|
150
164
|
|
151
165
|
event :signout, :validate, on: :delete do
|