card 1.101.0 → 1.101.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/config/i18n-tasks.yml +0 -5
- data/config/initializers/01_core_extensions/array.rb +2 -1
- data/config/initializers/01_core_extensions/hash.rb +1 -0
- data/config/initializers/01_core_extensions/object.rb +15 -11
- data/config/initializers/02_patches/active_job.rb +1 -1
- data/config/initializers/02_patches/active_record.rb +2 -4
- data/config/initializers/02_patches/better_errors.rb +1 -3
- data/config/initializers/02_patches/kaminari.rb +2 -2
- data/config/initializers/deck_config.rb +1 -1
- data/config/initializers/inflections.rb +1 -0
- data/config/initializers/internationalization.rb +23 -21
- data/config/initializers/mime_types.rb +1 -0
- data/config/initializers/notification.rb +1 -0
- data/config/initializers/patches.rb +6 -5
- data/config/locales/en.yml +137 -525
- data/db/migrate/20110511221913_require_earlier_migrations.rb +1 -0
- data/db/migrate/20121111025347_require_1_10_migrations.rb +1 -0
- data/db/migrate/20121118114000_split_link_type.rb +1 -0
- data/db/migrate/20121118115000_update_link_type.rb +1 -0
- data/db/migrate/20130106052640_table_cleanup.rb +2 -2
- data/db/migrate/20130109015336_trunk_left.rb +1 -0
- data/db/migrate/20130411210957_update_codenames.rb +1 -0
- data/db/migrate/20140822073704_create_new_revision_tables.rb +1 -0
- data/db/migrate/20141001105348_move_revisions_to_actions.rb +9 -3
- data/db/migrate/20141216053032_better_index_names.rb +9 -6
- data/db/migrate/20170908114442_create_delayed_jobs.rb +1 -1
- data/db/migrate/20170908114452_increase_text_size_for_delayed_jobs.rb +1 -1
- data/db/migrate/20180514152037_add_card_virtuals_table.rb +1 -1
- data/db/migrate_core_cards/20120611203506_rails_inflection_updates.rb +3 -2
- data/db/migrate_core_cards/20130411191151_renaming_for_menu.rb +9 -9
- data/db/migrate_core_cards/20130419215612_import_help_text.rb +3 -2
- data/db/migrate_core_cards/20130823192433_add_style_cards.rb +5 -5
- data/db/migrate_core_cards/20130910183318_move_styles_to_content.rb +3 -2
- data/db/migrate_core_cards/20130920291703_update_stylesheets.rb +2 -4
- data/db/migrate_core_cards/20131016172445_common_css_patch.rb +1 -3
- data/db/migrate_core_cards/20140110193325_reset_account_request_type.rb +1 -3
- data/db/migrate_core_cards/20140307231621_user_data_to_cards.rb +12 -8
- data/db/migrate_core_cards/20140317035504_account_requests_to_signups.rb +2 -4
- data/db/migrate_core_cards/20140512155840_add_script_cards.rb +16 -9
- data/db/migrate_core_cards/20140629222005_add_email_cards.rb +19 -11
- data/db/migrate_core_cards/20140725180118_config_card_updates.rb +1 -1
- data/db/migrate_core_cards/20141115034214_config_descriptions_etc.rb +1 -1
- data/db/migrate_core_cards/20141119001955_make_symlinks_relative.rb +1 -1
- data/db/migrate_core_cards/20141204061304_watchers_to_following.rb +2 -0
- data/db/migrate_core_cards/20141216155251_add_more_following_cards.rb +4 -2
- data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +2 -2
- data/db/migrate_core_cards/20150220134731_following_to_follow_rule.rb +3 -4
- data/db/migrate_core_cards/20150317162412_bootstrap_themes.rb +8 -4
- data/db/migrate_core_cards/20150326205655_bootswatch_themes.rb +14 -7
- data/db/migrate_core_cards/20150429090551_search_card_context.rb +6 -4
- data/db/migrate_core_cards/20150508212032_menu_compatibility.rb +4 -2
- data/db/migrate_core_cards/20150510031118_fix_skin_codenames.rb +2 -1
- data/db/migrate_core_cards/20150601133433_add_recent_setting_session_card.rb +3 -3
- data/db/migrate_core_cards/20150610171702_add_debugger_session_card.rb +2 -1
- data/db/migrate_core_cards/20150610180019_add_recaptcha_key_and_admin_info_cards.rb +4 -3
- data/db/migrate_core_cards/20150724123438_update_file_and_image_cards.rb +6 -2
- data/db/migrate_core_cards/20150807205221_create_references_for_search_cards.rb +1 -1
- data/db/migrate_core_cards/20150824135418_update_file_history.rb +2 -0
- data/db/migrate_core_cards/20160804112510_reorganize_scripts.rb +1 -1
- data/db/migrate_core_cards/20160811115836_rename_stats_to_admin.rb +1 -0
- data/db/migrate_core_cards/20160914132636_fix_mod_files.rb +2 -0
- data/db/migrate_core_cards/20161102202156_tweak_recaptcha_setting_cards.rb +6 -6
- data/db/migrate_core_cards/20161103154836_update_keys.rb +2 -1
- data/db/migrate_core_cards/20170209132834_email_test_context.rb +2 -0
- data/db/migrate_core_cards/20170314175313_add_notification_event_card.rb +3 -3
- data/db/migrate_core_cards/20170515101262_add_advanced_edit_cards.rb +1 -1
- data/db/migrate_core_cards/20170608200649_add_input_options_codename.rb +1 -1
- data/db/migrate_core_cards/20180712042655_head_rule.rb +3 -4
- data/db/migrate_core_cards/20180905061537_migrate_layouts.rb +4 -4
- data/db/migrate_core_cards/20181120200937_update_layout.rb +1 -1
- data/db/migrate_core_cards/20190320091257_upgrade_recaptcha_to_v3.rb +7 -7
- data/db/migrate_core_cards/20190424100531_update_credit_image.rb +1 -0
- data/db/migrate_core_cards/20190502130029_add_shark_and_help_desk_role.rb +15 -14
- data/db/migrate_core_cards/20190503122739_update_pristine_data.rb +1 -1
- data/db/migrate_core_cards/20190625153616_pointer_overhaul.rb +9 -5
- data/db/migrate_core_cards/20190718140126_add_guides.rb +3 -3
- data/db/migrate_core_cards/20190822093633_move_help_text_to_code.rb +1 -2
- data/db/migrate_core_cards/20190823220018_cleanup_for_decko_1_0.rb +1 -1
- data/db/migrate_core_cards/20190829093961_cardtype_grouping.rb +7 -7
- data/db/migrate_core_cards/20190902193208_input_type.rb +1 -3
- data/db/migrate_core_cards/20190909104250_add_cardtype_input_types.rb +2 -2
- data/db/migrate_core_cards/20191028135243_add_link_editor_to_tiny_mce_config.rb +1 -0
- data/db/migrate_core_cards/20191115160748_history_cleanup.rb +0 -1
- data/db/migrate_core_cards/20191118145629_codename_fixes.rb +1 -2
- data/db/migrate_core_cards/20200821231558_add_nest_list_type.rb +1 -1
- data/db/migrate_core_cards/data/decko_logo.svg +1 -59
- data/db/seed/new/card_actions.yml +2153 -2145
- data/db/seed/new/card_acts.yml +3 -3
- data/db/seed/new/card_references.yml +900 -858
- data/db/seed/new/cards.yml +4869 -4848
- data/db/seed/new/schema_migrations_deck_cards.yml +2 -0
- data/db/seed/test/fixtures/card_actions.yml +3563 -3547
- data/db/seed/test/fixtures/card_acts.yml +675 -675
- data/db/seed/test/fixtures/card_changes.yml +103 -103
- data/db/seed/test/fixtures/card_references.yml +2165 -2123
- data/db/seed/test/fixtures/cards.yml +7862 -7751
- data/db/seed/test/fixtures/rails.gif +0 -0
- data/db/seed/test/fixtures/schema_migrations_deck_cards.yml +2 -0
- data/db/test_seed.rb +33 -34
- data/lib/card.rb +18 -1
- data/lib/card/auth.rb +5 -2
- data/lib/card/auth/current.rb +39 -100
- data/lib/card/auth/proxy.rb +36 -16
- data/lib/card/auth/token.rb +8 -2
- data/lib/card/cache.rb +2 -1
- data/lib/card/cache/all.rb +88 -0
- data/lib/card/cache/card_class.rb +44 -0
- data/lib/card/cache/persistent.rb +3 -34
- data/lib/card/cache/persistent_class.rb +28 -0
- data/lib/card/codename.rb +3 -4
- data/lib/card/content.rb +20 -10
- data/lib/card/content/all.rb +59 -0
- data/lib/card/content/chunk.rb +1 -1
- data/lib/card/content/clean.rb +4 -3
- data/lib/card/content/diff.rb +3 -2
- data/lib/card/content/diff/l_c_s/processor.rb +1 -1
- data/lib/card/content/diff/result.rb +41 -29
- data/lib/card/content/parser.rb +2 -2
- data/lib/card/content/truncate.rb +6 -6
- data/lib/card/director.rb +1 -1
- data/lib/card/director/act_direction.rb +4 -0
- data/lib/card/director/all.rb +61 -0
- data/lib/card/director/card_class.rb +18 -0
- data/lib/card/director/card_methods.rb +1 -0
- data/lib/card/director/event_delay.rb +4 -6
- data/lib/card/director/phases.rb +0 -1
- data/lib/card/director/run.rb +2 -0
- data/lib/card/director/stages.rb +3 -2
- data/lib/card/dirty.rb +13 -3
- data/lib/card/env.rb +2 -2
- data/lib/card/env/location.rb +4 -3
- data/lib/card/env/success.rb +46 -103
- data/lib/card/env/success/target.rb +73 -0
- data/lib/card/error.rb +1 -2
- data/lib/card/fetch.rb +7 -4
- data/lib/card/fetch/all.rb +33 -0
- data/lib/card/fetch/card_class.rb +155 -0
- data/lib/card/fetch/results.rb +9 -0
- data/lib/card/fetch/retrieve.rb +2 -0
- data/lib/card/fetch/store.rb +1 -0
- data/lib/card/format.rb +1 -2
- data/lib/card/format/content.rb +1 -3
- data/lib/card/format/error.rb +8 -4
- data/lib/card/format/method_delegation.rb +10 -2
- data/lib/card/format/nest.rb +3 -2
- data/lib/card/format/nest/fetch.rb +3 -2
- data/lib/card/format/nesting/mode.rb +1 -1
- data/lib/card/format/nesting/subformat.rb +2 -1
- data/lib/card/format/render.rb +2 -2
- data/lib/card/format/wrapper.rb +1 -1
- data/lib/card/lexicon.rb +5 -4
- data/lib/card/mark.rb +17 -15
- data/lib/card/model/save_helper.rb +18 -184
- data/lib/card/model/save_helper/save_arguments.rb +94 -0
- data/lib/card/model/save_helper/save_helper_helper.rb +93 -0
- data/lib/card/name.rb +10 -9
- data/lib/card/name/all.rb +136 -0
- data/lib/card/name/all/descendants.rb +48 -0
- data/lib/card/name/all/parts.rb +67 -0
- data/lib/card/name/card_class.rb +28 -0
- data/lib/card/name/fields_and_traits.rb +4 -2
- data/lib/card/name/name_variants.rb +0 -1
- data/lib/card/query.rb +24 -19
- data/lib/card/query/card_query/interpretation.rb +3 -2
- data/lib/card/query/card_query/match_attributes.rb +2 -1
- data/lib/card/query/card_query/normalization.rb +1 -0
- data/lib/card/query/card_query/reference_attributes.rb +1 -1
- data/lib/card/query/card_query/sorting.rb +12 -4
- data/lib/card/query/join.rb +1 -1
- data/lib/card/query/sql_statement.rb +1 -1
- data/lib/card/query/value/match_value.rb +1 -0
- data/lib/card/reference/all.rb +136 -0
- data/lib/card/rule/all.rb +76 -0
- data/lib/card/rule/cache.rb +2 -0
- data/lib/card/set/advanced_api.rb +8 -4
- data/lib/card/set/event.rb +2 -2
- data/lib/card/set/event/all.rb +101 -0
- data/lib/card/set/event/delayed_event.rb +6 -6
- data/lib/card/set/event/options.rb +14 -5
- data/lib/card/set/event/skip_and_trigger.rb +89 -0
- data/lib/card/set/format.rb +16 -9
- data/lib/card/set/format/abstract_format/view_definition.rb +1 -0
- data/lib/card/set/format/abstract_format/view_opts.rb +1 -0
- data/lib/card/set/i18n_scope.rb +18 -13
- data/lib/card/set/inheritance.rb +8 -6
- data/lib/card/set/loader.rb +24 -13
- data/lib/card/set/pattern/all.rb +63 -0
- data/lib/card/set/pattern/base.rb +4 -74
- data/lib/card/set/pattern/class_methods.rb +75 -0
- data/lib/card/set/required_field.rb +4 -1
- data/lib/card/set/trait.rb +11 -8
- data/lib/card/setting.rb +13 -12
- data/lib/card/subcards.rb +3 -4
- data/lib/card/subcards/add.rb +3 -24
- data/lib/card/subcards/all.rb +103 -0
- data/lib/card/subcards/args.rb +42 -0
- data/lib/card/tasks/card/file_card_creator/abstract_file_card/ruby_file.rb +1 -1
- data/lib/card/tasks/card/file_card_creator/output_helper.rb +17 -14
- data/lib/card/tasks/card/migrate.rake +2 -2
- data/lib/card/view/cache.rb +6 -8
- data/lib/card/view/cache/cache_action.rb +1 -2
- data/lib/card/view/cache/stub.rb +1 -1
- data/lib/card/view/options.rb +5 -4
- data/lib/card/view/permission.rb +15 -3
- data/lib/cardio.rb +10 -67
- data/lib/cardio/defaults.yml +70 -0
- data/lib/cardio/migration.rb +2 -2
- data/lib/cardio/migration/deck_structure.rb +2 -4
- data/lib/cardio/migration/import.rb +3 -3
- data/lib/cardio/migration/import/import_data.rb +1 -0
- data/lib/cardio/mod.rb +1 -0
- data/lib/cardio/mod/dirs.rb +2 -2
- data/lib/cardio/mod/load_strategy.rb +2 -4
- data/lib/cardio/mod/loader/set_loader.rb +2 -1
- data/lib/cardio/mod/loader/set_pattern_loader.rb +0 -1
- data/lib/cardio/mod/module_template.rb +1 -0
- data/lib/cardio/modfiles.rb +2 -4
- data/lib/cardio/schema.rb +2 -4
- data/lib/cardio/utils.rb +9 -0
- data/lib/generators/card/format/format_generator.rb +1 -1
- data/lib/generators/card/migration/migration_generator.rb +2 -1
- data/lib/generators/card/mod/mod_generator.rb +3 -2
- data/lib/generators/card/set/set_generator.rb +3 -3
- data/lib/generators/card/template/template_generator.rb +1 -1
- data/mod/admin/set/self/admin.rb +6 -3
- data/mod/admin/set/self/admin_info.rb +3 -8
- data/mod/admin/set/self/trash.rb +3 -2
- data/mod/admin/spec/set/self/admin_spec.rb +4 -4
- data/mod/core/set/all/abort.rb +5 -5
- data/mod/core/set/all/assign_attributes.rb +12 -28
- data/mod/core/set/all/autoname.rb +17 -0
- data/mod/core/set/all/codename.rb +3 -2
- data/mod/core/set/all/collection.rb +4 -6
- data/mod/core/set/all/content.rb +55 -99
- data/mod/core/set/all/contextual_content.rb +2 -4
- data/mod/core/set/all/initialize.rb +9 -9
- data/mod/core/set/all/name_events.rb +78 -58
- data/mod/core/set/all/reference_events.rb +69 -0
- data/mod/core/set/all/states.rb +5 -5
- data/mod/core/set/all/subcards.rb +1 -101
- data/mod/core/set/all/trash.rb +16 -14
- data/mod/core/set/all/type.rb +11 -11
- data/mod/core/set/all/utils.rb +4 -1
- data/mod/{settings → core}/set/right/autoname.rb +0 -0
- data/mod/{settings → core}/set/self/autoname.rb +0 -0
- data/mod/core/set/type/cardtype.rb +28 -0
- data/mod/core/set_pattern/06_rule.rb +1 -1
- data/mod/core/spec/set/all/assign_attributes_spec.rb +10 -9
- data/mod/core/spec/set/all/{rules2_spec.rb → clean_me_spec.rb} +19 -4
- data/mod/core/spec/set/all/collection_spec.rb +1 -1
- data/mod/core/spec/set/all/export_spec.rb +1 -0
- data/mod/core/spec/set/all/initialize_spec.rb +11 -11
- data/mod/core/spec/set/all/name_events_spec.rb +204 -0
- data/mod/{standard → core}/spec/set/type/cardtype_spec.rb +3 -24
- data/mod/standard/file/logo/image-original.svg +1 -59
- metadata +50 -61
- data/config/initializers/uuid_state_file.rb +0 -3
- data/lib/card/mod_inflector.rb +0 -16
- data/mod/Modfile +0 -4
- data/mod/core/set/all/actify.rb +0 -68
- data/mod/core/set/all/cache.rb +0 -109
- data/mod/core/set/all/event_conditions.rb +0 -172
- data/mod/core/set/all/fetch.rb +0 -122
- data/mod/core/set/all/fetch_helper.rb +0 -35
- data/mod/core/set/all/i18n.rb +0 -11
- data/mod/core/set/all/name.rb +0 -229
- data/mod/core/set/all/pattern.rb +0 -54
- data/mod/core/set/all/references.rb +0 -191
- data/mod/core/set/all/rename.rb +0 -33
- data/mod/core/set/all/rules.rb +0 -81
- data/mod/core/spec/set/all/actify_spec.rb +0 -58
- data/mod/core/spec/set/all/content_spec.rb +0 -15
- data/mod/core/spec/set/all/event_conditions_spec.rb +0 -217
- data/mod/core/spec/set/all/fetch_helper_spec.rb +0 -65
- data/mod/core/spec/set/all/fetch_spec.rb +0 -338
- data/mod/core/spec/set/all/i18n_spec.rb +0 -17
- data/mod/core/spec/set/all/name_spec.rb +0 -11
- data/mod/core/spec/set/all/pattern_spec.rb +0 -101
- data/mod/core/spec/set/all/permissions/reader_rules_spec.rb +0 -166
- data/mod/core/spec/set/all/references_spec.rb +0 -62
- data/mod/core/spec/set/all/rename_spec.rb +0 -189
- data/mod/core/spec/set/all/rules_spec.rb +0 -100
- data/mod/core/spec/set/all/subcards_spec.rb +0 -102
- data/mod/standard/set/all/rich_html/html_views/info.rb +0 -84
- data/mod/standard/set/type/cardtype.rb +0 -119
File without changes
|
data/db/test_seed.rb
CHANGED
@@ -12,10 +12,9 @@ class SharedData
|
|
12
12
|
"Big Brother", "Optic fan", "Sunglasses fan", "Narcissist"
|
13
13
|
].freeze
|
14
14
|
|
15
|
-
CARDTYPE_COUNT =
|
15
|
+
CARDTYPE_COUNT = 44
|
16
16
|
|
17
17
|
class << self
|
18
|
-
|
19
18
|
def create_user name, args
|
20
19
|
args[:subcards] = account_args args if args[:email]
|
21
20
|
|
@@ -46,9 +45,10 @@ class SharedData
|
|
46
45
|
# CREATE A CARD OF EACH TYPE
|
47
46
|
|
48
47
|
no_samples = %w[user sign_up set number mirror_list mirrored_list file image
|
49
|
-
customized_bootswatch_skin]
|
48
|
+
customized_bootswatch_skin alias]
|
50
49
|
Card::Auth.createable_types.each do |type|
|
51
50
|
next if no_samples.include? type.to_name.key
|
51
|
+
|
52
52
|
create type: type, name: "Sample #{type}"
|
53
53
|
end
|
54
54
|
|
@@ -57,7 +57,7 @@ class SharedData
|
|
57
57
|
end
|
58
58
|
|
59
59
|
create_layout_type "lay out", "Greatest {{_main|title: Callahan!; view: labeled}}"
|
60
|
-
create_pointer "stacks", [
|
60
|
+
create_pointer "stacks", %w[horizontal vertical]
|
61
61
|
create_pointer "stacks+*self+*layout", "lay out"
|
62
62
|
create "horizontal"
|
63
63
|
create_pointer "vertical"
|
@@ -75,7 +75,7 @@ class SharedData
|
|
75
75
|
["Z", "I'm here to be referenced to"],
|
76
76
|
["A", "Alpha [[Z]]"],
|
77
77
|
["B", "Beta {{Z}}"],
|
78
|
-
[
|
78
|
+
%w[T Theta],
|
79
79
|
["X", "[[A]] [[A+B]] [[T]]"],
|
80
80
|
["Y", "{{B}} {{A+B}} {{A}} {{T}}"],
|
81
81
|
["A+B", "AlphaBeta"],
|
@@ -114,7 +114,8 @@ class SharedData
|
|
114
114
|
## --------- Fruit: creatable by anyone but not readable ---
|
115
115
|
Card.create! type: "Cardtype", name: "Fruit"
|
116
116
|
Card.create! name: "Fruit+*type+*create", type: "Pointer", content: "[[Anyone]]"
|
117
|
-
Card.create! name: "Fruit+*type+*read", type: "Pointer",
|
117
|
+
Card.create! name: "Fruit+*type+*read", type: "Pointer",
|
118
|
+
content: "[[Administrator]]"
|
118
119
|
|
119
120
|
# codenames for card_accessor tests
|
120
121
|
Card.create! name: "*write", codename: :write
|
@@ -158,7 +159,7 @@ class SharedData
|
|
158
159
|
|
159
160
|
def user_and_role_cards
|
160
161
|
# Card::Auth.instant_account_activation do
|
161
|
-
|
162
|
+
create_user "Joe Admin", content: "I'm number one", email: "joe@admin.com"
|
162
163
|
create_user "Joe User", content: "I'm number two", email: "joe@user.com"
|
163
164
|
create_user "Joe Camel", content: "Mr. Buttz", email: "joe@camel.com"
|
164
165
|
|
@@ -169,10 +170,10 @@ class SharedData
|
|
169
170
|
|
170
171
|
# noinspection RubyResolve
|
171
172
|
Card["Joe Admin"].fetch(:roles, new: { type_code: "pointer" })
|
172
|
-
|
173
|
+
.items = [Card::AdministratorID, Card::SharkID, Card::HelpDeskID]
|
173
174
|
|
174
175
|
Card["Joe User"].fetch(:roles, new: { type_code: "pointer" })
|
175
|
-
|
176
|
+
.items = [Card::SharkID]
|
176
177
|
|
177
178
|
create_user "u1", email: "u1@user.com", password: "u1_pass"
|
178
179
|
create_user "u2", email: "u2@user.com", password: "u2_pass"
|
@@ -188,19 +189,18 @@ class SharedData
|
|
188
189
|
Card["u3"].fetch(:roles, new: {}).items = [r1, r4, Card::AdministratorID]
|
189
190
|
end
|
190
191
|
|
191
|
-
|
192
192
|
def cardtype_cards
|
193
193
|
# for cql & permissions
|
194
|
-
%w[A+C A+D A+E C+A D+A F+A A+B+C].each {|name| create name}
|
194
|
+
%w[A+C A+D A+E C+A D+A F+A A+B+C].each { |name| create name }
|
195
195
|
("A".."F").each do |ch|
|
196
196
|
create "Cardtype #{ch}", type_code: "cardtype",
|
197
|
-
|
197
|
+
codename: "cardtype_#{ch.downcase}"
|
198
198
|
end
|
199
199
|
Card::Codename.reset_cache
|
200
200
|
|
201
201
|
("a".."f").each do |ch|
|
202
202
|
create "type-#{ch}-card", type_code: "cardtype_#{ch}",
|
203
|
-
|
203
|
+
content: "type_#{ch}_content"
|
204
204
|
end
|
205
205
|
|
206
206
|
create_pointer "Cardtype B+*type+*create", "[[r3]]"
|
@@ -210,7 +210,6 @@ class SharedData
|
|
210
210
|
create "Cardtype E+*type+*default"
|
211
211
|
end
|
212
212
|
|
213
|
-
|
214
213
|
def notification_cards
|
215
214
|
Timecop.freeze(Cardio.future_stamp - 1.day) do
|
216
215
|
# fwiw Timecop is apparently limited by ruby Time object,
|
@@ -231,7 +230,7 @@ class SharedData
|
|
231
230
|
|
232
231
|
followers.each do |name, _follow|
|
233
232
|
create_user name, email: "#{name.parameterize}@user.com",
|
234
|
-
|
233
|
+
password: "#{name.parameterize}_pass"
|
235
234
|
end
|
236
235
|
|
237
236
|
create "All Eyes On Me"
|
@@ -252,7 +251,8 @@ class SharedData
|
|
252
251
|
|
253
252
|
Card::Auth.signin Card::WagnBotID
|
254
253
|
create "Google glass+*self+*follow_fields", ""
|
255
|
-
create "Sunglasses+*self+*follow_fields",
|
254
|
+
create "Sunglasses+*self+*follow_fields",
|
255
|
+
"[[#{:nests.cardname}]]\n[[_self+price]]\n[[_self+producer]]"
|
256
256
|
create "Sunglasses+tint"
|
257
257
|
create "Sunglasses+price"
|
258
258
|
|
@@ -277,7 +277,7 @@ class SharedData
|
|
277
277
|
["card with fields", "field 1", "field 2"],
|
278
278
|
["card with fields and admin fields", "field 1", "admin field 1"],
|
279
279
|
["admin card with fields and admin fields", "field 1", "admin field 1"],
|
280
|
-
["admin card with admin fields", "admin field 1", "admin field 2"]
|
280
|
+
["admin card with admin fields", "admin field 1", "admin field 2"]
|
281
281
|
].each do |name, f1, f2|
|
282
282
|
create name,
|
283
283
|
content: "main content {{+#{f1}}} {{+#{f2}}}",
|
@@ -297,25 +297,24 @@ class SharedData
|
|
297
297
|
end
|
298
298
|
create ["field 1", :right, :read], type: "Pointer", content: "[[Anyone]]"
|
299
299
|
end
|
300
|
-
|
301
300
|
end
|
302
301
|
end
|
303
302
|
|
304
|
-
TEXT =
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
303
|
+
TEXT = <<~TXT.strip_heredoc.freeze
|
304
|
+
Far out in the uncharted backwaters of the unfashionable end of
|
305
|
+
the western spiral arm of the Galaxy lies a small unregarded
|
306
|
+
yellow sun.
|
307
|
+
#{' '}
|
308
|
+
Orbiting this at a distance of roughly ninety-two million miles
|
309
|
+
is an utterly insignificant little blue green planet whose ape-
|
310
|
+
descended life forms are so amazingly primitive that they still
|
311
|
+
think digital watches are a pretty neat idea.
|
312
|
+
#{' '}
|
313
|
+
This planet has - or rather had - a problem, which was this: most
|
314
|
+
of the people living on it were unhappy for pretty much of the time.
|
315
|
+
Many solutions were suggested for this problem, but most of these
|
316
|
+
were largely concerned with the movements of small green pieces
|
317
|
+
of paper, which is odd because on the whole it wasn't the small
|
318
|
+
green pieces of paper that were unhappy.
|
320
319
|
TXT
|
321
320
|
end
|
data/lib/card.rb
CHANGED
@@ -113,9 +113,24 @@ ActiveSupport.run_load_hooks(:before_card, self)
|
|
113
113
|
class Card < ApplicationRecord
|
114
114
|
extend Mark
|
115
115
|
extend Dirty::MethodFactory
|
116
|
+
extend Name::CardClass
|
117
|
+
extend Cache::CardClass
|
118
|
+
extend Director::CardClass
|
119
|
+
extend Fetch::CardClass
|
120
|
+
|
116
121
|
include Dirty
|
117
122
|
include DirtyNames
|
118
123
|
include Director::CardMethods
|
124
|
+
include Name::All
|
125
|
+
include Content::All
|
126
|
+
include Set::Event::All
|
127
|
+
include Set::Pattern::All
|
128
|
+
include Cache::All
|
129
|
+
include Director::All
|
130
|
+
include Reference::All
|
131
|
+
include Rule::All
|
132
|
+
include Fetch::All
|
133
|
+
include Subcards::All
|
119
134
|
|
120
135
|
Card::Cache # trigger autoload
|
121
136
|
|
@@ -143,7 +158,6 @@ class Card < ApplicationRecord
|
|
143
158
|
:skip_in_action, # skip event for just this card
|
144
159
|
:trigger, # trigger event(s) for all cards in act
|
145
160
|
:trigger_in_action, # trigger event for just this card
|
146
|
-
|
147
161
|
:comment, # obviated soon
|
148
162
|
|
149
163
|
# TODO: refactor following to use skip/trigger
|
@@ -154,6 +168,9 @@ class Card < ApplicationRecord
|
|
154
168
|
|
155
169
|
attr_accessor(*action_specific_attributes)
|
156
170
|
|
171
|
+
self.action_specific_attributes +=
|
172
|
+
%i[skip_hash full_skip_hash trigger_hash full_trigger_hash]
|
173
|
+
|
157
174
|
define_callbacks :select_action, :show_page, :act
|
158
175
|
|
159
176
|
ActiveSupport.run_load_hooks :card, self
|
data/lib/card/auth.rb
CHANGED
@@ -10,8 +10,7 @@ class Card
|
|
10
10
|
extend Proxy
|
11
11
|
extend Setup
|
12
12
|
extend Current
|
13
|
-
|
14
|
-
@as_card = @as_id = @current_id = @current = nil
|
13
|
+
extend Token
|
15
14
|
|
16
15
|
class << self
|
17
16
|
# authenticate a user by their login name and unencrypted password.
|
@@ -40,6 +39,10 @@ class Card
|
|
40
39
|
def encrypt password, salt
|
41
40
|
Digest::SHA1.hexdigest "#{salt}--#{password}--"
|
42
41
|
end
|
42
|
+
|
43
|
+
def serialize
|
44
|
+
{ as_id: as_id, current_id: current_id }
|
45
|
+
end
|
43
46
|
end
|
44
47
|
end
|
45
48
|
end
|
data/lib/card/auth/current.rb
CHANGED
@@ -2,114 +2,66 @@ class Card
|
|
2
2
|
module Auth
|
3
3
|
# methods for setting current account
|
4
4
|
module Current
|
5
|
-
# set current user in process and session
|
6
|
-
def signin cardish
|
7
|
-
signin_id = Card.id(cardish) || Card::AnonymousID
|
8
|
-
self.current_id = signin_id
|
9
|
-
set_session_user signin_id
|
10
|
-
end
|
11
|
-
|
12
|
-
# current user is not anonymous
|
13
|
-
# @return [true/false]
|
14
|
-
def signed_in?
|
15
|
-
current_id != Card::AnonymousID
|
16
|
-
end
|
17
|
-
|
18
5
|
# id of current user card.
|
19
6
|
# @return [Integer]
|
20
7
|
def current_id
|
21
8
|
@current_id ||= Card::AnonymousID
|
22
9
|
end
|
23
10
|
|
11
|
+
# set the id of the current user.
|
12
|
+
# @return [Integer]
|
13
|
+
def current_id= card_id
|
14
|
+
reset
|
15
|
+
card_id = card_id.to_i if card_id.present?
|
16
|
+
@current_id = card_id
|
17
|
+
end
|
18
|
+
|
24
19
|
# current accounted card (must have +\*account)
|
25
20
|
# @return [Card]
|
26
|
-
def
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
@current = Card[current_id]
|
31
|
-
end
|
21
|
+
def current_card
|
22
|
+
return @current_card if @current_card&.id == current_id
|
23
|
+
|
24
|
+
@current_card = Card[current_id]
|
32
25
|
end
|
26
|
+
alias_method :current, :current_card
|
33
27
|
|
34
28
|
def current_roles
|
35
29
|
@current_roles ||= [Card.fetch_name(:anyone_signed_in),
|
36
30
|
current.fetch(:roles)&.item_names].flatten.compact
|
37
31
|
end
|
38
32
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
# @param auth_data [Integer|Hash] user id, user name, or a hash
|
44
|
-
# @option auth_data [Integer] current_id
|
45
|
-
# @option auth_data [Integer] as_id
|
46
|
-
def with auth_data
|
47
|
-
if auth_data.is_a?(Integer) || auth_data.is_a?(String)
|
48
|
-
auth_data = { current_id: Card.id(auth_data) }
|
49
|
-
end
|
50
|
-
|
51
|
-
tmp_current_id = current_id
|
52
|
-
tmp_as_id = as_id
|
53
|
-
tmp_current = @current
|
54
|
-
tmp_as_card = @as_card
|
55
|
-
tmp_current_roles = @current_roles
|
56
|
-
|
57
|
-
# resets @as and @as_card
|
58
|
-
self.current_id = auth_data[:current_id]
|
59
|
-
@as_id = auth_data[:as_id] if auth_data[:as_id]
|
60
|
-
yield
|
61
|
-
ensure
|
62
|
-
@current_id = tmp_current_id
|
63
|
-
@as_id = tmp_as_id
|
64
|
-
@current = tmp_current
|
65
|
-
@as_card = tmp_as_card
|
66
|
-
@current_roles = tmp_current_roles
|
33
|
+
# set current user in process and session
|
34
|
+
def signin cardish
|
35
|
+
session[session_user_key] =
|
36
|
+
self.current_id = Card.id(cardish) || Card::AnonymousID
|
67
37
|
end
|
68
38
|
|
69
|
-
#
|
70
|
-
# return [
|
71
|
-
def
|
72
|
-
Card::
|
39
|
+
# current user is not anonymous
|
40
|
+
# @return [true/false]
|
41
|
+
def signed_in?
|
42
|
+
current_id != Card::AnonymousID
|
73
43
|
end
|
74
44
|
|
75
45
|
# set current from token, api_key, or session
|
76
|
-
def signin_with
|
46
|
+
def signin_with _opts={}
|
77
47
|
if opts[:token]
|
78
48
|
signin_with_token opts[:token]
|
79
|
-
elsif opts[:api_key]
|
80
|
-
signin_with_api_key opts[:api_key]
|
81
49
|
else
|
82
50
|
signin_with_session
|
83
51
|
end
|
84
52
|
end
|
85
53
|
|
86
|
-
# set the current user based on token
|
87
|
-
def signin_with_token token
|
88
|
-
payload = Token.validate! token
|
89
|
-
signin payload[:anonymous] ? Card::AnonymousID : payload[:user_id]
|
90
|
-
end
|
91
|
-
|
92
|
-
# set the current user based on api_key
|
93
|
-
def signin_with_api_key api_key
|
94
|
-
account = find_account_by_api_key api_key
|
95
|
-
unless account&.validate_api_key! api_key
|
96
|
-
raise Card::Error::PermissionDenied, "API key authentication failed"
|
97
|
-
end
|
98
|
-
|
99
|
-
signin account.left_id
|
100
|
-
end
|
101
|
-
|
102
54
|
# get :user id from session and set Auth.current_id
|
103
55
|
def signin_with_session
|
104
|
-
card_id =
|
105
|
-
|
56
|
+
card_id = session[session_user_key]
|
57
|
+
card_id = nil unless Card.exists? card_id
|
58
|
+
signin card_id
|
106
59
|
end
|
107
60
|
|
108
|
-
#
|
109
|
-
#
|
110
|
-
|
111
|
-
|
112
|
-
find_account_by :api_key, api_key.strip
|
61
|
+
# get session object from Env
|
62
|
+
# return [Session]
|
63
|
+
def session
|
64
|
+
Card::Env.session
|
113
65
|
end
|
114
66
|
|
115
67
|
# find +\*account card by +\*email card
|
@@ -119,6 +71,16 @@ class Card
|
|
119
71
|
find_account_by :email, email.strip.downcase
|
120
72
|
end
|
121
73
|
|
74
|
+
def reset
|
75
|
+
@as_id = @as_card = @current_id = @current_card = @current_roles = nil
|
76
|
+
end
|
77
|
+
|
78
|
+
def session_user_key
|
79
|
+
"user_#{Cardio.database_name.underscore}".to_sym
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
|
122
84
|
# general pattern for finding +\*account card based on field cards
|
123
85
|
# @param fieldcode [Symbol] code of account field
|
124
86
|
# @param value [String] content of field
|
@@ -130,29 +92,6 @@ class Card
|
|
130
92
|
"find +:account with +#{fieldcode} (#{value})").first
|
131
93
|
end
|
132
94
|
end
|
133
|
-
|
134
|
-
def session_user
|
135
|
-
session[session_user_key]
|
136
|
-
end
|
137
|
-
|
138
|
-
def set_session_user card_id
|
139
|
-
session[session_user_key] = card_id
|
140
|
-
end
|
141
|
-
|
142
|
-
def session_user_key
|
143
|
-
"user_#{database.underscore}".to_sym
|
144
|
-
end
|
145
|
-
|
146
|
-
def database
|
147
|
-
Rails.configuration.database_configuration.dig Rails.env, "database"
|
148
|
-
end
|
149
|
-
|
150
|
-
# set the id of the current user.
|
151
|
-
def current_id= card_id
|
152
|
-
@current = @as_id = @as_card = @current_roles = nil
|
153
|
-
card_id = card_id.to_i if card_id.present?
|
154
|
-
@current_id = card_id
|
155
|
-
end
|
156
95
|
end
|
157
96
|
end
|
158
97
|
end
|
data/lib/card/auth/proxy.rb
CHANGED
@@ -4,10 +4,10 @@ class Card
|
|
4
4
|
module Proxy
|
5
5
|
# operate with the permissions of another "proxy" user
|
6
6
|
def as given_user
|
7
|
-
tmp_id
|
7
|
+
tmp_id = @as_id
|
8
8
|
tmp_card = @as_card
|
9
9
|
|
10
|
-
@as_id
|
10
|
+
@as_id = Card.id given_user
|
11
11
|
@as_card = nil
|
12
12
|
# we could go ahead and set as_card if given a card...
|
13
13
|
|
@@ -18,7 +18,7 @@ class Card
|
|
18
18
|
yield
|
19
19
|
ensure
|
20
20
|
if block_given?
|
21
|
-
@as_id
|
21
|
+
@as_id = tmp_id
|
22
22
|
@as_card = tmp_card
|
23
23
|
end
|
24
24
|
end
|
@@ -37,22 +37,42 @@ class Card
|
|
37
37
|
# proxy user card
|
38
38
|
# @return [Card]
|
39
39
|
def as_card
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
@as_card = Card[as_id]
|
44
|
-
end
|
40
|
+
return @as_card if @as_card&.id == as_id
|
41
|
+
|
42
|
+
@as_card = Card[as_id]
|
45
43
|
end
|
46
44
|
|
47
|
-
#
|
48
|
-
# @
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
when Integer then user
|
54
|
-
else Card.fetch_id(user)
|
45
|
+
# @param auth_data [Integer|Hash] user id, user name, or a hash
|
46
|
+
# @option auth_data [Integer] current_id
|
47
|
+
# @option auth_data [Integer] as_id
|
48
|
+
def with auth_data
|
49
|
+
if auth_data.is_a?(Integer) || auth_data.is_a?(String)
|
50
|
+
auth_data = { current_id: Card.id(auth_data) }
|
55
51
|
end
|
52
|
+
|
53
|
+
temporarily do
|
54
|
+
# resets @as and @as_card
|
55
|
+
self.current_id = auth_data[:current_id]
|
56
|
+
@as_id = auth_data[:as_id] if auth_data[:as_id]
|
57
|
+
yield
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def temporarily
|
64
|
+
tmp_current_id = current_id
|
65
|
+
tmp_as_id = as_id
|
66
|
+
tmp_current_card = @current_card
|
67
|
+
tmp_as_card = @as_card
|
68
|
+
tmp_current_roles = @current_roles
|
69
|
+
yield
|
70
|
+
ensure
|
71
|
+
@current_id = tmp_current_id
|
72
|
+
@as_id = tmp_as_id
|
73
|
+
@current = tmp_current_card
|
74
|
+
@as_card = tmp_as_card
|
75
|
+
@current_roles = tmp_current_roles
|
56
76
|
end
|
57
77
|
end
|
58
78
|
end
|