card 1.99.1 → 1.99.2
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/initializers/01_core_extensions/array.rb +1 -0
- data/config/initializers/01_core_extensions/persistent_identifiers.rb +1 -1
- data/config/initializers/02_patches/zeitwerk.rb +13 -0
- data/config/initializers/patches.rb +7 -0
- data/config/initializers/recaptcha.rb +1 -2
- data/config/initializers/zeitwerk.rb +5 -0
- data/config/locales/de.yml +1 -1
- data/config/locales/en.yml +1 -1
- data/config/locales/es.yml +1 -1
- data/db/migrate/20110511221913_require_earlier_migrations.rb +0 -3
- data/db/migrate/20141001105348_move_revisions_to_actions.rb +1 -1
- data/db/migrate_core_cards/20140629222005_add_email_cards.rb +5 -5
- data/db/migrate_core_cards/20141120120605_fix_notification_html_message.rb +1 -1
- data/db/migrate_core_cards/20141204061304_watchers_to_following.rb +1 -1
- data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +2 -2
- data/db/migrate_core_cards/20150317162412_bootstrap_themes.rb +4 -4
- data/db/migrate_core_cards/20150724123438_update_file_and_image_cards.rb +1 -1
- data/db/migrate_core_cards/20190204195039_add_rule_card.rb +1 -1
- data/db/migrate_core_cards/20191008201046_fixture_fix.rb +3 -1
- data/db/migrate_core_cards/20191028135243_add_link_editor_to_tiny_mce_config.rb +8 -0
- data/db/migrate_core_cards/20191115160748_history_cleanup.rb +27 -0
- data/db/migrate_core_cards/20191118145629_codename_fixes.rb +6 -0
- data/db/seed/new/card_actions.yml +874 -874
- data/db/seed/new/card_acts.yml +2 -2
- data/db/seed/new/card_references.yml +2 -2
- data/db/seed/new/cards.yml +1576 -1576
- data/db/seed/new/schema_migrations_core_cards.yml +8 -0
- data/db/seed/test/fixtures/card_actions.yml +1815 -1815
- data/db/seed/test/fixtures/card_acts.yml +499 -499
- data/db/seed/test/fixtures/card_changes.yml +66 -66
- data/db/seed/test/fixtures/card_references.yml +634 -634
- data/db/seed/test/fixtures/cards.yml +2730 -2730
- data/db/seed/test/fixtures/schema_migrations_core_cards.yml +8 -0
- data/db/test_seed.rb +10 -11
- data/lib/card.rb +9 -30
- data/lib/card/act_manager.rb +0 -2
- data/lib/card/auth.rb +0 -5
- data/lib/card/auth/current.rb +32 -59
- data/lib/card/auth/setup.rb +1 -1
- data/lib/card/codename.rb +5 -6
- data/lib/card/content.rb +5 -8
- data/lib/card/content/chunk.rb +0 -78
- data/lib/card/content/chunk/abstract.rb +88 -0
- data/lib/card/content/clean.rb +3 -3
- data/lib/card/content/diff/{lcs.rb → l_c_s.rb} +5 -7
- data/lib/card/content/diff/{processor.rb → l_c_s/processor.rb} +0 -0
- data/lib/card/content/parser.rb +1 -1
- data/lib/card/dirty.rb +25 -31
- data/lib/card/dirty/method_factory.rb +15 -0
- data/lib/card/env.rb +0 -3
- data/lib/card/error.rb +6 -2
- data/lib/card/format.rb +5 -5
- data/lib/card/format/nest/fetch.rb +2 -1
- data/lib/card/mark.rb +1 -0
- data/lib/card/migration.rb +4 -0
- data/lib/card/mod.rb +2 -5
- data/lib/card/mod/dirs.rb +1 -0
- data/lib/card/mod/load_strategy.rb +23 -12
- data/lib/card/mod/loader.rb +13 -13
- data/lib/card/mod/loader/set_loader.rb +7 -1
- data/lib/card/mod/loader/set_pattern_loader.rb +2 -2
- data/lib/card/mod/module_template.rb +1 -5
- data/lib/card/mod_inflector.rb +16 -0
- data/lib/card/model/save_helper.rb +2 -2
- data/lib/card/name.rb +2 -2
- data/lib/card/name/name_variants.rb +19 -0
- data/lib/card/query.rb +4 -2
- data/lib/card/query/card_query/reference_attributes.rb +2 -2
- data/lib/card/query/sql_statement.rb +4 -0
- data/lib/card/set.rb +18 -3
- data/lib/card/set/abstract.rb +6 -0
- data/lib/card/set/event.rb +13 -11
- data/lib/card/set/event/delayed_event.rb +2 -0
- data/lib/card/set/format.rb +3 -3
- data/lib/card/set/helpers.rb +20 -8
- data/lib/card/set/loader.rb +1 -1
- data/lib/card/set/pattern.rb +47 -0
- data/lib/card/{set_pattern.rb → set/pattern/base.rb} +11 -92
- data/lib/card/set/required_field.rb +64 -30
- data/lib/card/set/trait.rb +3 -2
- data/lib/card/set/type.rb +46 -0
- data/lib/card/subcards.rb +0 -4
- data/lib/card/tasks/card.rake +1 -0
- data/lib/card/tasks/card/migrate.rake +1 -1
- data/lib/card/view.rb +2 -7
- data/lib/card/view/cache.rb +3 -0
- data/lib/card/view/cache/stub.rb +5 -0
- data/lib/cardio.rb +73 -46
- data/mod/account/set/abstract/accountable.rb +49 -0
- data/mod/account/set/all/account.rb +3 -3
- data/mod/account/set/right/account.rb +1 -1
- data/mod/account/set/self/signin.rb +2 -2
- data/mod/account/set/type/role.rb +1 -1
- data/mod/account/set/type/signup.rb +2 -2
- data/mod/account/set/type/signup/views.rb +1 -1
- data/mod/account/set/type/user.rb +1 -1
- data/mod/account/spec/set/abstract/accountable_spec.rb +7 -0
- data/mod/account/spec/set/all/account_spec.rb +3 -3
- data/mod/account/spec/set/right/account_spec.rb +1 -1
- data/mod/account/spec/set/type/signup_spec.rb +4 -4
- data/mod/admin/set/self/admin.rb +1 -1
- data/mod/admin/set/self/admin_info.rb +2 -2
- data/mod/admin/set/self/version.rb +1 -1
- data/mod/basic_types/set/type/json.rb +4 -0
- data/mod/basic_types/spec/set/type/html_spec.rb +1 -1
- data/mod/bootstrap/db/migrate_core_cards/data/20181108181219_migrate_classic_skins_to_bootstrap.rb +2 -2
- data/mod/bootstrap/lib/bootstrap/component_loader.rb +1 -1
- data/mod/bootstrap/lib/stylesheets/style_bootstrap_cards.scss +1 -0
- data/mod/bootstrap/set/abstract/bootswatch_theme.rb +1 -1
- data/mod/bootstrap/set/all/bootstrap/tabs.rb +4 -4
- data/mod/bootstrap/set/type/customized_bootswatch_skin.rb +5 -4
- data/mod/carrierwave/config/core_initializers/carrierwave.rb +1 -3
- data/mod/carrierwave/lib/carrier_wave/{cardmount.rb → card_mount.rb} +2 -2
- data/mod/carrierwave/lib/carrier_wave/file_card_uploader.rb +27 -12
- data/mod/carrierwave/set/abstract/attachment.rb +0 -2
- data/mod/carrierwave/set/all/file_utils.rb +5 -1
- data/mod/carrierwave/set/self/admin.rb +1 -1
- data/mod/core/chunk/link.rb +99 -91
- data/mod/core/chunk/nest.rb +2 -2
- data/mod/core/chunk/query_reference.rb +79 -74
- data/mod/core/chunk/view_stub.rb +10 -1
- data/mod/core/format/html_format.rb +1 -1
- data/mod/core/set/abstract/code_file.rb +6 -6
- data/mod/core/set/all/content.rb +1 -1
- data/mod/core/set/all/event_conditions.rb +1 -2
- data/mod/core/set/all/fetch.rb +22 -19
- data/mod/core/set/all/fetch_helper.rb +7 -5
- data/mod/core/set/all/initialize.rb +35 -9
- data/mod/core/set/all/item.rb +16 -6
- data/mod/core/set/all/name.rb +19 -15
- data/mod/core/set/all/pattern.rb +4 -0
- data/mod/core/set/all/permissions.rb +13 -11
- data/mod/core/set/all/rename.rb +1 -0
- data/mod/core/set/all/rules.rb +4 -4
- data/mod/core/set/all/subcards.rb +36 -1
- data/mod/core/set/all/type.rb +1 -1
- data/mod/core/set_pattern/03_type.rb +2 -0
- data/mod/core/spec/chunk/nest_spec.rb +7 -2
- data/mod/core/spec/set/all/fetch_spec.rb +1 -1
- data/mod/core/spec/set/all/permissions_spec.rb +11 -12
- data/mod/core/spec/set/all/rules_spec.rb +3 -3
- data/mod/edit/set/all/bridge.rb +1 -3
- data/mod/edit/set/all/bridge/tab_views.rb +0 -7
- data/mod/edit/set/all/bridge/tab_visibility.rb +5 -7
- data/mod/edit/set/all/form_buttons.rb +1 -1
- data/mod/edit/set/all/form_elements.rb +1 -0
- data/mod/edit/set/all/new.rb +2 -2
- data/mod/edit/spec/set/all/bridge/tab_views_spec.rb +1 -1
- data/mod/edit/spec/set/all/{nest_editor → reference_editor/nest_editor}/nest_parser_spec.rb +1 -1
- data/mod/edit/spec/set/all/{nest_editor_spec.rb → reference_editor/nest_editor_spec.rb} +6 -3
- data/mod/edit/spec/set/all/{nest_image_spec.rb → reference_editor/nest_image_spec.rb} +1 -1
- data/mod/email/set/abstract/test_context.rb +1 -1
- data/mod/email/set/type/email_template/email_config.rb +1 -1
- data/mod/follow/set/all/notify.rb +1 -1
- data/mod/follow/set/all/notify/base_views.rb +1 -1
- data/mod/follow/set/right/account.rb +8 -6
- data/mod/follow/set/right/followers.rb +2 -5
- data/mod/follow/set/right/following.rb +1 -1
- data/mod/follow/spec/set/all/follow_spec.rb +3 -3
- data/mod/follow/spec/set/all/notify_spec.rb +1 -1
- data/mod/follow/spec/set/right/followers_spec.rb +2 -2
- data/mod/history/lib/card/act.rb +3 -1
- data/mod/history/lib/card/action.rb +3 -3
- data/mod/history/lib/card/action/admin.rb +0 -11
- data/mod/history/set/all/history_bridge.rb +1 -1
- data/mod/machines/file/all_script_machine_output/file.js +38415 -69
- data/mod/machines/file/all_style_machine_output/file.css +2 -2
- data/mod/machines/file/script_html5shiv_printshiv_machine_output/file.js +1 -1
- data/mod/machines/lib/javascript/decko/filter.js.coffee +7 -1
- data/mod/machines/lib/javascript/decko/filter_links.js.coffee +13 -2
- data/mod/machines/lib/javascript/decko/link_editor.js.coffee +64 -0
- data/mod/machines/lib/javascript/decko/mod.js.coffee +3 -0
- data/mod/machines/lib/javascript/decko/nest_editor.js.coffee +49 -29
- data/mod/machines/lib/javascript/decko/nest_editor_name.js.coffee +30 -7
- data/mod/machines/lib/javascript/decko/slot.js.coffee +4 -1
- data/mod/machines/lib/stylesheets/style_cards.scss +31 -19
- data/mod/machines/set/abstract/machine/output_cache.rb +1 -1
- data/mod/machines/set/abstract/machine/output_update.rb +1 -1
- data/mod/machines/set/all/reset_machines.rb +2 -2
- data/mod/machines/set/self/script_decko.rb +1 -0
- data/mod/media/set/abstract/media.rb +1 -1
- data/mod/media/set/type/image.rb +1 -1
- data/mod/navbar/set/abstract/account_dropdown.rb +5 -1
- data/mod/navbar/set/right/enabled_roles.rb +1 -1
- data/mod/navbar/set/self/account_links.rb +1 -1
- data/mod/pointer/set/abstract/02_pointer.rb +1 -1
- data/mod/pointer/set/abstract/02_pointer/events.rb +30 -10
- data/mod/pointer/set/abstract/02_pointer/html_views.rb +6 -2
- data/mod/pointer/set/abstract/02_pointer/html_views/autocomplete_input.haml +1 -1
- data/mod/pointer/set/abstract/02_pointer/html_views/filter.rb +1 -1
- data/mod/pointer/set/abstract/02_pointer/item_api.rb +51 -31
- data/mod/pointer/set/abstract/id_pointer.rb +21 -0
- data/mod/pointer/set/type/link_list.rb +1 -1
- data/mod/pointer/set/type/mirror_list.rb +1 -1
- data/mod/pointer/set/type/mirrored_list.rb +2 -2
- data/mod/pointer/spec/set/abstract/paging_params_spec.rb +1 -1
- data/mod/pointer/spec/set/abstract/pointer/item_api_spec.rb +1 -1
- data/mod/recaptcha/set/all/recaptcha.rb +4 -9
- data/mod/rules/set/rule/editor.rb +2 -2
- data/mod/rules/set/type/set/html_views/rule_lists.rb +1 -1
- data/mod/rules/spec/set/type/set_spec.rb +1 -1
- data/mod/search/set/abstract/03_filter/filter_form.haml +1 -1
- data/mod/search/set/abstract/03_filter/filter_form.rb +23 -2
- data/mod/search/set/abstract/03_filter/quick_filters.haml +7 -10
- data/mod/search/template/abstract/search/checkbox_item.haml +5 -6
- data/mod/settings/set/abstract/permission.rb +2 -2
- data/mod/settings/set/right/input_type.rb +3 -3
- data/mod/settings/set/right/structure.rb +1 -1
- data/mod/settings/set/right/style.rb +1 -1
- data/mod/settings/set/type/setting.rb +2 -2
- data/mod/standard/set/all/rich_html/html_views/guide.rb +1 -1
- data/mod/standard/set/all/rich_html/menu.rb +6 -5
- data/mod/standard/set/self/cardtype.rb +1 -1
- data/mod/standard/set/type/cardtype.rb +33 -17
- data/mod/standard/set/type/session.rb +12 -0
- data/mod/standard/spec/set/type/email_template/email_config_spec.rb +1 -2
- data/mod/standard/spec/set/type/email_template_spec.rb +1 -3
- data/mod/tinymce_editor/lib/javascript/script_tinymce_config.js.coffee +3 -2
- data/mod/tinymce_editor/public/assets/tinymce/plugins/nest/plugin.min.js +1 -1
- data/mod/tinymce_editor/set/all/reference_editor.rb +23 -0
- data/mod/tinymce_editor/set/all/reference_editor/_link_editor.haml +18 -0
- data/mod/tinymce_editor/set/all/reference_editor/_nest_editor.haml +17 -0
- data/mod/tinymce_editor/set/all/reference_editor/link_editor.rb +33 -0
- data/mod/tinymce_editor/set/all/reference_editor/link_editor/link_parser.rb +35 -0
- data/mod/tinymce_editor/set/all/reference_editor/nest_editor.rb +174 -0
- data/mod/{edit/set/all → tinymce_editor/set/all/reference_editor}/nest_editor/_help.haml +0 -0
- data/mod/tinymce_editor/set/all/reference_editor/nest_editor/_options.haml +12 -0
- data/mod/{edit/set/all → tinymce_editor/set/all/reference_editor}/nest_editor/_options_select.haml +0 -0
- data/mod/{edit/set/all → tinymce_editor/set/all/reference_editor}/nest_editor/_options_select_row.haml +0 -0
- data/mod/{edit/set/all → tinymce_editor/set/all/reference_editor}/nest_editor/nest_parser.rb +7 -1
- data/mod/tinymce_editor/set/all/reference_editor/nest_image.rb +70 -0
- data/mod/tinymce_editor/set/all/reference_editor/reference_editor.haml +18 -0
- metadata +39 -21
- data/mod/account/set/abstract/accounted.rb +0 -15
- data/mod/edit/set/all/bridge/account_section.rb +0 -16
- data/mod/edit/set/all/nest_editor.rb +0 -122
- data/mod/edit/set/all/nest_editor/_options.haml +0 -12
- data/mod/edit/set/all/nest_editor/nest_editor.haml +0 -31
- data/mod/edit/set/all/nest_image.rb +0 -37
@@ -307,3 +307,11 @@ schema_migrations_core_cards_153:
|
|
307
307
|
version: '20190927112151'
|
308
308
|
schema_migrations_core_cards_154:
|
309
309
|
version: '20191008201046'
|
310
|
+
schema_migrations_core_cards_155:
|
311
|
+
version: '20191014204655'
|
312
|
+
schema_migrations_core_cards_156:
|
313
|
+
version: '20191028135243'
|
314
|
+
schema_migrations_core_cards_157:
|
315
|
+
version: '20191115160748'
|
316
|
+
schema_migrations_core_cards_158:
|
317
|
+
version: '20191118145629'
|
data/db/test_seed.rb
CHANGED
@@ -4,7 +4,6 @@ require "timecop"
|
|
4
4
|
|
5
5
|
# noinspection RubyResolve
|
6
6
|
class SharedData
|
7
|
-
require_relative "../lib/card/model/save_helper"
|
8
7
|
extend Card::Model::SaveHelper
|
9
8
|
|
10
9
|
USERS = [
|
@@ -96,11 +95,11 @@ class SharedData
|
|
96
95
|
Card.create! type_id: Card::CardtypeID, name: "UserForm"
|
97
96
|
create "UserForm+*type+*structure", "{{+name}} {{+age}} {{+description}}"
|
98
97
|
|
99
|
-
Card::Auth.
|
98
|
+
Card::Auth.signin "joe_user"
|
100
99
|
create "JoeLater", "test"
|
101
100
|
create "JoeNow", "test"
|
102
101
|
|
103
|
-
Card::Auth.
|
102
|
+
Card::Auth.signin Card::WagnBotID
|
104
103
|
|
105
104
|
create_cardtype "Book"
|
106
105
|
create "Book+*type+*structure", "by {{+author}}, design by {{+illustrator}}"
|
@@ -169,10 +168,10 @@ class SharedData
|
|
169
168
|
end
|
170
169
|
|
171
170
|
# noinspection RubyResolve
|
172
|
-
Card["Joe Admin"].fetch(
|
171
|
+
Card["Joe Admin"].fetch(:roles, new: { type_code: "pointer" })
|
173
172
|
.items = [Card::AdministratorID, Card::SharkID, Card::HelpDeskID]
|
174
173
|
|
175
|
-
Card["Joe User"].fetch(
|
174
|
+
Card["Joe User"].fetch(:roles, new: { type_code: "pointer" })
|
176
175
|
.items = [Card::SharkID]
|
177
176
|
|
178
177
|
create_user "u1", email: "u1@user.com", password: "u1_pass"
|
@@ -184,9 +183,9 @@ class SharedData
|
|
184
183
|
r3 = create_role "r3"
|
185
184
|
r4 = create_role "r4"
|
186
185
|
|
187
|
-
Card["u1"].fetch(
|
188
|
-
Card["u2"].fetch(
|
189
|
-
Card["u3"].fetch(
|
186
|
+
Card["u1"].fetch(:roles, new: { type_code: "pointer" }).items = [r1, r2, r3]
|
187
|
+
Card["u2"].fetch(:roles, new: {}).items = [r1, r2, r4]
|
188
|
+
Card["u3"].fetch(:roles, new: {}).items = [r1, r4, Card::AdministratorID]
|
190
189
|
end
|
191
190
|
|
192
191
|
|
@@ -244,14 +243,14 @@ class SharedData
|
|
244
243
|
create "John Following+her"
|
245
244
|
magnifier = create "Magnifier+lens"
|
246
245
|
|
247
|
-
Card::Auth.
|
246
|
+
Card::Auth.signin "Narcissist"
|
248
247
|
magnifier.update! content: "zoom in"
|
249
248
|
create_optic "Sunglasses", "{{+tint}}{{+lens}}"
|
250
249
|
|
251
|
-
Card::Auth.
|
250
|
+
Card::Auth.signin "Optic fan"
|
252
251
|
create_optic "Google glass", "{{+price}}"
|
253
252
|
|
254
|
-
Card::Auth.
|
253
|
+
Card::Auth.signin Card::WagnBotID
|
255
254
|
create "Google glass+*self+*follow_fields", ""
|
256
255
|
create "Sunglasses+*self+*follow_fields", "[[#{Card[:nests].name}]]\n[[_self+price]]\n[[_self+producer]]"
|
257
256
|
create "Sunglasses+tint"
|
data/lib/card.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
|
-
Object.const_remove_if_defined :Card
|
4
3
|
ActiveSupport.run_load_hooks(:before_card, self)
|
5
|
-
# ActiveSupport::Dependencies.loaded.clear
|
6
4
|
|
7
5
|
# Cards are wiki-inspired building blocks.
|
8
6
|
#
|
@@ -93,28 +91,12 @@ ActiveSupport.run_load_hooks(:before_card, self)
|
|
93
91
|
# You can see the current user with `Card::Auth.current`. The permissions of a proxy user can be temporarily assumed using `Card::Auth#as`.
|
94
92
|
#
|
95
93
|
# {Card::Auth More on accounts}
|
96
|
-
#
|
97
94
|
class Card < ApplicationRecord
|
98
|
-
|
99
|
-
extend
|
95
|
+
extend ::Card::Mark
|
96
|
+
extend ::Card::Dirty::MethodFactory
|
97
|
+
include ::Card::Dirty
|
100
98
|
|
101
|
-
|
102
|
-
require_dependency "card/codename"
|
103
|
-
require_dependency "card/query"
|
104
|
-
require_dependency "card/format"
|
105
|
-
require_dependency "card/error"
|
106
|
-
require_dependency "card/auth"
|
107
|
-
require_dependency "card/mod"
|
108
|
-
require_dependency "card/content"
|
109
|
-
require_dependency "card/action"
|
110
|
-
require_dependency "card/act"
|
111
|
-
require_dependency "card/change"
|
112
|
-
require_dependency "card/reference"
|
113
|
-
require_dependency "card/subcards"
|
114
|
-
require_dependency "card/view"
|
115
|
-
require_dependency "card/act_manager"
|
116
|
-
require_dependency "card/dirty"
|
117
|
-
require_dependency "card/layout"
|
99
|
+
Card::Cache
|
118
100
|
|
119
101
|
has_many :references_in, class_name: :Reference, foreign_key: :referee_id
|
120
102
|
has_many :references_out, class_name: :Reference, foreign_key: :referer_id
|
@@ -159,33 +141,30 @@ class Card < ApplicationRecord
|
|
159
141
|
|
160
142
|
attr_accessor :follower_stash
|
161
143
|
|
162
|
-
|
144
|
+
STAGE_CALLBACKS = [
|
163
145
|
:select_action, :show_page, :act,
|
164
|
-
|
165
146
|
# VALIDATION PHASE
|
166
147
|
:initialize_stage, :prepare_to_validate_stage, :validate_stage,
|
167
148
|
:initialize_final_stage, :prepare_to_validate_final_stage,
|
168
149
|
:validate_final_stage,
|
169
|
-
|
170
150
|
# STORAGE PHASE
|
171
151
|
:prepare_to_store_stage, :store_stage, :finalize_stage,
|
172
152
|
:prepare_to_store_final_stage, :store_final_stage, :finalize_final_stage,
|
173
|
-
|
174
153
|
# INTEGRATION PHASE
|
175
154
|
:integrate_stage, :integrate_with_delay_stage,
|
176
155
|
:integrate_final_stage,
|
177
156
|
:after_integrate_stage,
|
178
157
|
:after_integrate_final_stage, :integrate_with_delay_final_stage
|
179
|
-
|
158
|
+
].freeze
|
159
|
+
define_callbacks(*STAGE_CALLBACKS)
|
180
160
|
|
181
161
|
# Validation and integration phase are only called for the act card
|
182
162
|
# The act card starts those phases for all its subcards
|
183
163
|
before_validation :validation_phase, unless: -> { only_storage_phase? }
|
184
164
|
around_save :storage_phase
|
185
165
|
after_commit :integration_phase, unless: -> { only_storage_phase? }
|
186
|
-
# after_rollback :clean_up, unless: -> { only_storage_phase? }
|
166
|
+
# after_rollback :clean_up, unless: -> { only_storage_phase? }
|
187
167
|
|
188
168
|
ActiveSupport.run_load_hooks(:card, self)
|
189
169
|
end
|
190
|
-
|
191
|
-
ActiveSupport.run_load_hooks(:after_card, self)
|
170
|
+
ActiveSupport.run_load_hooks :after_card, self
|
data/lib/card/act_manager.rb
CHANGED
data/lib/card/auth.rb
CHANGED
@@ -1,10 +1,5 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
|
-
require_dependency "card/auth/permissions"
|
4
|
-
require_dependency "card/auth/proxy"
|
5
|
-
require_dependency "card/auth/setup"
|
6
|
-
require_dependency "card/auth/token"
|
7
|
-
|
8
3
|
class Card
|
9
4
|
# Singleton methods for account authentication and contextualization.
|
10
5
|
#
|
data/lib/card/auth/current.rb
CHANGED
@@ -3,7 +3,8 @@ class Card
|
|
3
3
|
# methods for setting current account
|
4
4
|
module Current
|
5
5
|
# set current user in process and session
|
6
|
-
def signin
|
6
|
+
def signin cardish
|
7
|
+
signin_id = Card.id(cardish) || Card::AnonymousID
|
7
8
|
self.current_id = signin_id
|
8
9
|
set_session_user signin_id
|
9
10
|
end
|
@@ -30,37 +31,9 @@ class Card
|
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
33
|
-
# set the id of the current user.
|
34
|
-
def current_id= card_id
|
35
|
-
@current = @as_id = @as_card = @current_roles = nil
|
36
|
-
card_id = card_id.to_i if card_id.present?
|
37
|
-
@current_id = card_id
|
38
|
-
end
|
39
|
-
|
40
|
-
# set current user from email or id
|
41
|
-
# @return [Integer]
|
42
|
-
def current= mark
|
43
|
-
self.current_id =
|
44
|
-
if mark.to_s =~ /@/
|
45
|
-
account = Auth.find_account_by_email mark
|
46
|
-
account && account.active? ? account.left_id : Card::AnonymousID
|
47
|
-
else
|
48
|
-
mark
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
34
|
def current_roles
|
53
35
|
@current_roles ||= [Card.fetch_name(:anyone_signed_in),
|
54
|
-
current.fetch(
|
55
|
-
end
|
56
|
-
|
57
|
-
def no_special_roles?
|
58
|
-
Auth.current_roles.size == 1 # &&
|
59
|
-
# Auth.current_roles.first == Card.fetch_name(:anyone_signed_in)
|
60
|
-
end
|
61
|
-
|
62
|
-
def clear_current_roles
|
63
|
-
@current_roles = nil
|
36
|
+
current.fetch(:roles)&.item_names].flatten.compact
|
64
37
|
end
|
65
38
|
|
66
39
|
def serialize
|
@@ -71,11 +44,8 @@ class Card
|
|
71
44
|
# @option auth_data [Integer] current_id
|
72
45
|
# @option auth_data [Integer] as_id
|
73
46
|
def with auth_data
|
74
|
-
|
75
|
-
|
76
|
-
auth_data = { current_id: auth_data }
|
77
|
-
when String
|
78
|
-
auth_data = { current_id: Card.fetch_id(auth_data) }
|
47
|
+
if auth_data.is_a?(Integer) || auth_data.is_a?(String)
|
48
|
+
auth_data = { current_id: Card.id(auth_data) }
|
79
49
|
end
|
80
50
|
|
81
51
|
tmp_current_id = current_id
|
@@ -102,68 +72,62 @@ class Card
|
|
102
72
|
Card::Env.session
|
103
73
|
end
|
104
74
|
|
105
|
-
# set current from token or session
|
106
|
-
def
|
75
|
+
# set current from token, api_key, or session
|
76
|
+
def signin_with opts={}
|
107
77
|
if opts[:token]
|
108
|
-
|
78
|
+
signin_with_token opts[:token]
|
109
79
|
elsif opts[:api_key]
|
110
|
-
|
80
|
+
signin_with_api_key opts[:api_key]
|
111
81
|
else
|
112
|
-
|
82
|
+
signin_with_session
|
113
83
|
end
|
114
84
|
end
|
115
85
|
|
116
86
|
# set the current user based on token
|
117
|
-
def
|
87
|
+
def signin_with_token token
|
118
88
|
payload = Token.validate! token
|
119
|
-
|
89
|
+
signin payload[:anonymous] ? Card::AnonymousID : payload[:user_id]
|
120
90
|
end
|
121
91
|
|
122
92
|
# set the current user based on api_key
|
123
|
-
def
|
93
|
+
def signin_with_api_key api_key
|
124
94
|
account = find_account_by_api_key api_key
|
125
95
|
unless account&.validate_api_key! api_key
|
126
96
|
raise Card::Error::PermissionDenied, "API key authentication failed"
|
127
97
|
end
|
128
98
|
|
129
|
-
|
99
|
+
signin account.left_id
|
130
100
|
end
|
131
101
|
|
132
102
|
# get :user id from session and set Auth.current_id
|
133
|
-
def
|
134
|
-
|
135
|
-
|
136
|
-
card_id
|
137
|
-
else
|
138
|
-
set_session_user Card::AnonymousID
|
139
|
-
end
|
103
|
+
def signin_with_session
|
104
|
+
card_id = session_user
|
105
|
+
signin(card_id && Card.exists?(card_id) ? card_id : nil)
|
140
106
|
end
|
141
107
|
|
142
108
|
# find +\*account card by +\*api card
|
143
109
|
# @param token [String]
|
144
110
|
# @return [+*account card, nil]
|
145
111
|
def find_account_by_api_key api_key
|
146
|
-
find_account_by
|
112
|
+
find_account_by :api_key, api_key.strip
|
147
113
|
end
|
148
114
|
|
149
115
|
# find +\*account card by +\*email card
|
150
116
|
# @param email [String]
|
151
117
|
# @return [+*account card, nil]
|
152
118
|
def find_account_by_email email
|
153
|
-
find_account_by
|
119
|
+
find_account_by :email, email.strip.downcase
|
154
120
|
end
|
155
121
|
|
156
122
|
# general pattern for finding +\*account card based on field cards
|
157
|
-
# @param
|
158
|
-
# @param field_id [Integer] card id of field's simple card
|
123
|
+
# @param fieldcode [Symbol] code of account field
|
159
124
|
# @param value [String] content of field
|
160
125
|
# @return [+*account card, nil]
|
161
|
-
def find_account_by
|
126
|
+
def find_account_by fieldcode, value
|
162
127
|
Auth.as_bot do
|
163
128
|
Card.search({ right_id: Card::AccountID,
|
164
|
-
right_plus: [{
|
165
|
-
|
166
|
-
"find +:account for #{fieldname} (#{value})").first
|
129
|
+
right_plus: [Card::Codename.id(fieldcode), { content: value }] },
|
130
|
+
"find +:account with +#{fieldcode} (#{value})").first
|
167
131
|
end
|
168
132
|
end
|
169
133
|
|
@@ -182,6 +146,15 @@ class Card
|
|
182
146
|
def database
|
183
147
|
Rails.configuration.database_configuration.dig Rails.env, "database"
|
184
148
|
end
|
149
|
+
|
150
|
+
private
|
151
|
+
|
152
|
+
# set the id of the current user.
|
153
|
+
def current_id= card_id
|
154
|
+
@current = @as_id = @as_card = @current_roles = nil
|
155
|
+
card_id = card_id.to_i if card_id.present?
|
156
|
+
@current_id = card_id
|
157
|
+
end
|
185
158
|
end
|
186
159
|
end
|
187
160
|
end
|
data/lib/card/auth/setup.rb
CHANGED
data/lib/card/codename.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
|
-
require_dependency "card/cache"
|
4
|
-
require_dependency "card/name"
|
5
|
-
|
6
3
|
class Card
|
7
4
|
# {Card}'s names can be changed, and therefore _names_ should not be directly mentioned
|
8
5
|
# in code, lest a name change break the application.
|
@@ -46,7 +43,9 @@ class Card
|
|
46
43
|
end
|
47
44
|
end
|
48
45
|
|
49
|
-
def name codename
|
46
|
+
def name codename=nil
|
47
|
+
return super() if codename.nil?
|
48
|
+
|
50
49
|
name! codename
|
51
50
|
rescue Error::CodenameNotFound => _e
|
52
51
|
yield if block_given?
|
@@ -75,7 +74,7 @@ class Card
|
|
75
74
|
# clear cache both locally and in cache
|
76
75
|
def reset_cache
|
77
76
|
@codehash = nil
|
78
|
-
Card.cache.delete "CODEHASH"
|
77
|
+
::Card.cache.delete "CODEHASH"
|
79
78
|
end
|
80
79
|
|
81
80
|
# @param codename [Symbol, String]
|
@@ -112,7 +111,7 @@ class Card
|
|
112
111
|
|
113
112
|
# generate Hash for @codehash and put it in the cache
|
114
113
|
def load_codehash
|
115
|
-
Card.cache.fetch("CODEHASH") do
|
114
|
+
::Card.cache.fetch("CODEHASH") do
|
116
115
|
generate_codehash
|
117
116
|
end
|
118
117
|
end
|
data/lib/card/content.rb
CHANGED
@@ -1,10 +1,5 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
|
-
require_dependency "card/content/chunk"
|
4
|
-
require_dependency "card/content/parser"
|
5
|
-
require_dependency "card/content/clean"
|
6
|
-
require_dependency "card/content/truncate"
|
7
|
-
|
8
3
|
class Card
|
9
4
|
# Content objects support the parsing of content strings into arrays that
|
10
5
|
# contain semantically meaningful "chunks" like nests, links, urls, etc.
|
@@ -12,8 +7,10 @@ class Card
|
|
12
7
|
# Each chunk has an object whose class inherits from {Card::Content::Chunk::Abstract}
|
13
8
|
#
|
14
9
|
class Content < SimpleDelegator
|
15
|
-
extend
|
16
|
-
extend
|
10
|
+
extend Clean
|
11
|
+
extend Truncate
|
12
|
+
|
13
|
+
Chunk
|
17
14
|
|
18
15
|
attr_reader :revision, :format, :chunks, :opts
|
19
16
|
|
@@ -46,7 +43,7 @@ class Card
|
|
46
43
|
end
|
47
44
|
|
48
45
|
def has_chunk? chunk_type
|
49
|
-
each_chunk.any { |chunk| chunk.is_a?(chunk_type)}
|
46
|
+
each_chunk.any { |chunk| chunk.is_a?(chunk_type) }
|
50
47
|
end
|
51
48
|
|
52
49
|
# sends &block to #process_chunk on each Chunk object
|
data/lib/card/content/chunk.rb
CHANGED
@@ -89,84 +89,6 @@ class Card
|
|
89
89
|
register_list :nest_only, [:Nest]
|
90
90
|
register_list :query, [:QueryReference]
|
91
91
|
register_list :stub, [:ViewStub]
|
92
|
-
|
93
|
-
class Abstract
|
94
|
-
class_attribute :config
|
95
|
-
attr_reader :text, :process_chunk
|
96
|
-
|
97
|
-
class << self
|
98
|
-
# if the prefix regex matched check that chunk against the full regex
|
99
|
-
def full_match content, prefix=nil
|
100
|
-
content.match full_re(prefix)
|
101
|
-
end
|
102
|
-
|
103
|
-
def full_re _prefix
|
104
|
-
config[:full_re]
|
105
|
-
end
|
106
|
-
|
107
|
-
def context_ok? _content, _chunk_start
|
108
|
-
true
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
def reference_code
|
113
|
-
"I"
|
114
|
-
end
|
115
|
-
|
116
|
-
def initialize match, content
|
117
|
-
match = self.class.full_match(match) if match.is_a? String
|
118
|
-
@text = match[0]
|
119
|
-
@processed = nil
|
120
|
-
@content = content
|
121
|
-
interpret match, content
|
122
|
-
self
|
123
|
-
end
|
124
|
-
|
125
|
-
def interpret _match_string, _content
|
126
|
-
Rails.logger.info "no #interpret method found for chunk class: " \
|
127
|
-
"#{self.class}"
|
128
|
-
end
|
129
|
-
|
130
|
-
def format
|
131
|
-
@content.format
|
132
|
-
end
|
133
|
-
|
134
|
-
def card
|
135
|
-
@content.card
|
136
|
-
end
|
137
|
-
|
138
|
-
def to_s
|
139
|
-
result
|
140
|
-
end
|
141
|
-
|
142
|
-
def result
|
143
|
-
burn_read || @process_chunk || @processed || @text
|
144
|
-
end
|
145
|
-
|
146
|
-
def burn_read
|
147
|
-
return unless @burn_read
|
148
|
-
|
149
|
-
tmp = @burn_read
|
150
|
-
@burn_read = nil
|
151
|
-
tmp
|
152
|
-
end
|
153
|
-
|
154
|
-
# Temporarily overrides the processed nest content for single-use
|
155
|
-
# After using the nest's result
|
156
|
-
# (for example via `to_s`) the original result is restored
|
157
|
-
def burn_after_reading text
|
158
|
-
@burn_read = text
|
159
|
-
end
|
160
|
-
|
161
|
-
def inspect
|
162
|
-
"<##{self.class}##{self}>"
|
163
|
-
end
|
164
|
-
|
165
|
-
def as_json _options={}
|
166
|
-
burn_read || @process_chunk || @processed ||
|
167
|
-
"not rendered #{self.class}, #{card&.name}"
|
168
|
-
end
|
169
|
-
end
|
170
92
|
end
|
171
93
|
end
|
172
94
|
Card::Mod::Loader.load_chunks
|