card 1.16.1 → 1.16.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardoc/checksums +60 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/.yardopts +6 -0
- data/README_Developers.rdoc +100 -0
- data/VERSION +1 -1
- data/card.gemspec +18 -18
- data/db/migrate/20150724210803_add_comment_to_actions.rb +5 -0
- data/db/migrate_core_cards/20150724123438_update_file_and_image_cards.rb +70 -0
- data/db/migrate_core_cards/20150807205221_create_references_for_search_cards.rb +10 -0
- data/db/migrate_core_cards/data/1.12_stylesheets/common.scss +4 -2
- data/db/schema.rb +2 -1
- data/db/seed/new/card_actions.yml +2334 -12538
- data/db/seed/new/card_acts.yml +1 -1
- data/db/seed/new/card_changes.yml +7384 -38929
- data/db/seed/new/card_references.yml +207 -207
- data/db/seed/new/cards.yml +1364 -1440
- data/db/seed/test/fixtures/card_actions.yml +3285 -13219
- data/db/seed/test/fixtures/card_acts.yml +107 -107
- data/db/seed/test/fixtures/card_changes.yml +10830 -42375
- data/db/seed/test/fixtures/card_references.yml +393 -393
- data/db/seed/test/fixtures/cards.yml +1701 -1777
- data/db/version.txt +1 -1
- data/db/version_core_cards.txt +1 -1
- data/lib/card.rb +13 -3
- data/lib/card/chunk.rb +22 -15
- data/lib/card/content.rb +9 -8
- data/lib/card/diff.rb +79 -79
- data/lib/card/loader.rb +33 -33
- data/lib/card/name.rb +8 -0
- data/lib/card/set.rb +44 -17
- data/lib/card/set_pattern.rb +8 -0
- data/lib/cardio.rb +19 -3
- data/mod/01_core/chunk/link.rb +7 -6
- data/mod/01_core/chunk/query_reference.rb +65 -0
- data/mod/01_core/set/all/content.rb +1 -1
- data/mod/01_core/set/all/fetch.rb +15 -7
- data/mod/01_core/set/all/initialize.rb +4 -3
- data/mod/01_core/set/all/phases.rb +12 -8
- data/mod/01_core/set/all/references.rb +12 -6
- data/mod/01_core/set/all/rules.rb +14 -11
- data/mod/01_core/set/all/states.rb +2 -1
- data/mod/01_core/set/all/tracked_attributes.rb +14 -0
- data/mod/01_core/spec/set/all/collection_spec.rb +5 -5
- data/mod/01_core/spec/set/all/name_spec.rb +6 -6
- data/mod/01_history/lib/card/act.rb +2 -2
- data/mod/01_history/lib/card/action.rb +11 -2
- data/mod/01_history/set/all/actions.rb +4 -3
- data/mod/01_history/set/all/content_history.rb +1 -1
- data/mod/01_history/set/all/history.rb +55 -66
- data/mod/02_basic_types/set/all/file.rb +26 -3
- data/mod/02_basic_types/set/type/pointer.rb +13 -14
- data/mod/02_basic_types/spec/set/all/file_spec.rb +0 -1
- data/mod/03_machines/lib/card/machine.rb +4 -4
- data/mod/03_machines/lib/javascript/wagn_mod.js.coffee +4 -17
- data/mod/03_machines/lib/stylesheets/style_cards.scss +5 -0
- data/mod/03_machines/set/right/machine_input.rb +3 -0
- data/mod/03_machines/set/right/machine_output.rb +4 -0
- data/mod/04_settings/lib/card/setting.rb +2 -1
- data/mod/04_settings/set/abstract/permission.rb +95 -0
- data/mod/04_settings/set/right/comment.rb +2 -90
- data/mod/04_settings/set/right/create.rb +2 -2
- data/mod/04_settings/set/right/delete.rb +2 -3
- data/mod/04_settings/set/right/read.rb +3 -2
- data/mod/04_settings/set/right/update.rb +3 -2
- data/mod/04_settings/set/self/recent_settings.rb +3 -0
- data/mod/04_settings/set/type/setting.rb +9 -1
- data/mod/05_email/set/all/notify.rb +2 -1
- data/mod/05_email/set/type/email_template.rb +17 -17
- data/mod/05_standard/file/credit_image/image-icon.png +0 -0
- data/mod/05_standard/file/credit_image/image-large.png +0 -0
- data/mod/05_standard/file/credit_image/image-medium.png +0 -0
- data/mod/05_standard/file/credit_image/image-original.png +0 -0
- data/mod/05_standard/file/credit_image/image-small.png +0 -0
- data/mod/05_standard/file/favicon/{icon-image.png → image-icon.png} +0 -0
- data/mod/05_standard/file/favicon/{large-image.png → image-large.png} +0 -0
- data/mod/05_standard/file/favicon/{medium-image.png → image-medium.png} +0 -0
- data/mod/05_standard/file/favicon/{original-image.png → image-original.png} +0 -0
- data/mod/05_standard/file/favicon/{small-image.png → image-small.png} +0 -0
- data/mod/05_standard/file/logo/{icon-image.png → image-icon.png} +0 -0
- data/mod/05_standard/file/logo/{large-image.png → image-large.png} +0 -0
- data/mod/05_standard/file/logo/{medium-image.png → image-medium.png} +0 -0
- data/mod/05_standard/file/logo/{original-image.png → image-original.png} +0 -0
- data/mod/05_standard/file/logo/{small-image.png → image-small.png} +0 -0
- data/mod/05_standard/lib/carrier_wave/cardmount.rb +79 -0
- data/mod/05_standard/lib/file_uploader.rb +127 -0
- data/mod/05_standard/lib/image_uploader.rb +35 -0
- data/mod/05_standard/set/abstract/attachment.rb +85 -0
- data/mod/05_standard/set/all/error.rb +1 -18
- data/mod/05_standard/set/all/event_viz.rb +17 -14
- data/mod/05_standard/set/all/rich_html/editing.rb +10 -10
- data/mod/05_standard/set/all/rich_html/toolbar.rb +44 -37
- data/mod/05_standard/set/right/account.rb +1 -1
- data/mod/05_standard/set/right/password.rb +9 -10
- data/mod/05_standard/set/self/recent.rb +1 -1
- data/mod/05_standard/set/type/file.rb +43 -31
- data/mod/05_standard/set/type/image.rb +22 -6
- data/mod/05_standard/set/type/search_type.rb +4 -2
- data/mod/05_standard/set/type/session.rb +7 -5
- data/mod/05_standard/set/type/set.rb +3 -1
- data/mod/05_standard/spec/set/all/history_spec.rb +1 -1
- data/mod/05_standard/spec/set/type/cardtype_spec.rb +3 -3
- data/mod/05_standard/spec/set/type/file_spec.rb +85 -1
- data/mod/05_standard/spec/set/type/image_spec.rb +89 -5
- data/mod/05_standard/spec/set/type/search_type_spec.rb +16 -1
- data/mod/06_bootstrap/file/{cerulean_skin/icon-image.png → cerulean_skin_image/image-icon.png} +0 -0
- data/mod/06_bootstrap/file/{cerulean_skin/large-image.png → cerulean_skin_image/image-large.png} +0 -0
- data/mod/06_bootstrap/file/{cerulean_skin/medium-image.png → cerulean_skin_image/image-medium.png} +0 -0
- data/mod/06_bootstrap/file/{cerulean_skin/original-image.png → cerulean_skin_image/image-original.png} +0 -0
- data/mod/06_bootstrap/file/{cerulean_skin/small-image.png → cerulean_skin_image/image-small.png} +0 -0
- data/mod/06_bootstrap/file/{cosmo_skin/icon-image.png → cosmo_skin_image/image-icon.png} +0 -0
- data/mod/06_bootstrap/file/{cosmo_skin/large-image.png → cosmo_skin_image/image-large.png} +0 -0
- data/mod/06_bootstrap/file/{cosmo_skin/medium-image.png → cosmo_skin_image/image-medium.png} +0 -0
- data/mod/06_bootstrap/file/{cosmo_skin/original-image.png → cosmo_skin_image/image-original.png} +0 -0
- data/mod/06_bootstrap/file/{cosmo_skin/small-image.png → cosmo_skin_image/image-small.png} +0 -0
- data/mod/06_bootstrap/file/{cyborg_skin/icon-image.png → cyborg_skin_image/image-icon.png} +0 -0
- data/mod/06_bootstrap/file/{cyborg_skin/large-image.png → cyborg_skin_image/image-large.png} +0 -0
- data/mod/06_bootstrap/file/{cyborg_skin/medium-image.png → cyborg_skin_image/image-medium.png} +0 -0
- data/mod/06_bootstrap/file/{cyborg_skin/original-image.png → cyborg_skin_image/image-original.png} +0 -0
- data/mod/06_bootstrap/file/{cyborg_skin/small-image.png → cyborg_skin_image/image-small.png} +0 -0
- data/mod/06_bootstrap/file/{darkly_skin/icon-image.png → darkly_skin_image/image-icon.png} +0 -0
- data/mod/06_bootstrap/file/{darkly_skin/large-image.png → darkly_skin_image/image-large.png} +0 -0
- data/mod/06_bootstrap/file/{darkly_skin/medium-image.png → darkly_skin_image/image-medium.png} +0 -0
- data/mod/06_bootstrap/file/{darkly_skin/original-image.png → darkly_skin_image/image-original.png} +0 -0
- data/mod/06_bootstrap/file/{darkly_skin/small-image.png → darkly_skin_image/image-small.png} +0 -0
- data/mod/06_bootstrap/file/{flatly_skin/icon-image.png → flatly_skin_image/image-icon.png} +0 -0
- data/mod/06_bootstrap/file/{flatly_skin/large-image.png → flatly_skin_image/image-large.png} +0 -0
- data/mod/06_bootstrap/file/{flatly_skin/medium-image.png → flatly_skin_image/image-medium.png} +0 -0
- data/mod/06_bootstrap/file/{flatly_skin/original-image.png → flatly_skin_image/image-original.png} +0 -0
- data/mod/06_bootstrap/file/{flatly_skin/small-image.png → flatly_skin_image/image-small.png} +0 -0
- data/mod/06_bootstrap/file/{journal_skin/icon-image.png → journal_skin_image/image-icon.png} +0 -0
- data/mod/06_bootstrap/file/{journal_skin/large-image.png → journal_skin_image/image-large.png} +0 -0
- data/mod/06_bootstrap/file/{journal_skin/medium-image.png → journal_skin_image/image-medium.png} +0 -0
- data/mod/06_bootstrap/file/{journal_skin/original-image.png → journal_skin_image/image-original.png} +0 -0
- data/mod/06_bootstrap/file/{journal_skin/small-image.png → journal_skin_image/image-small.png} +0 -0
- data/mod/06_bootstrap/file/{lumen_skin/icon-image.png → lumen_skin_image/image-icon.png} +0 -0
- data/mod/06_bootstrap/file/{lumen_skin/large-image.png → lumen_skin_image/image-large.png} +0 -0
- data/mod/06_bootstrap/file/{lumen_skin/medium-image.png → lumen_skin_image/image-medium.png} +0 -0
- data/mod/06_bootstrap/file/{lumen_skin/original-image.png → lumen_skin_image/image-original.png} +0 -0
- data/mod/06_bootstrap/file/{lumen_skin/small-image.png → lumen_skin_image/image-small.png} +0 -0
- data/mod/06_bootstrap/file/{paper_skin/icon-image.png → paper_skin_image/image-icon.png} +0 -0
- data/mod/06_bootstrap/file/{paper_skin/large-image.png → paper_skin_image/image-large.png} +0 -0
- data/mod/06_bootstrap/file/{paper_skin/medium-image.png → paper_skin_image/image-medium.png} +0 -0
- data/mod/06_bootstrap/file/{paper_skin/original-image.png → paper_skin_image/image-original.png} +0 -0
- data/mod/06_bootstrap/file/{paper_skin/small-image.png → paper_skin_image/image-small.png} +0 -0
- data/mod/06_bootstrap/file/{readable_skin/icon-image.png → readable_skin_image/image-icon.png} +0 -0
- data/mod/06_bootstrap/file/{readable_skin/large-image.png → readable_skin_image/image-large.png} +0 -0
- data/mod/06_bootstrap/file/{readable_skin/medium-image.png → readable_skin_image/image-medium.png} +0 -0
- data/mod/06_bootstrap/file/{readable_skin/original-image.png → readable_skin_image/image-original.png} +0 -0
- data/mod/06_bootstrap/file/{readable_skin/small-image.png → readable_skin_image/image-small.png} +0 -0
- data/mod/06_bootstrap/file/{sandstone_skin/icon-image.png → sandstone_skin_image/image-icon.png} +0 -0
- data/mod/06_bootstrap/file/{sandstone_skin/large-image.png → sandstone_skin_image/image-large.png} +0 -0
- data/mod/06_bootstrap/file/{sandstone_skin/medium-image.png → sandstone_skin_image/image-medium.png} +0 -0
- data/mod/06_bootstrap/file/{sandstone_skin/original-image.png → sandstone_skin_image/image-original.png} +0 -0
- data/mod/06_bootstrap/file/{sandstone_skin/small-image.png → sandstone_skin_image/image-small.png} +0 -0
- data/mod/06_bootstrap/file/{simplex_skin/icon-image.png → simplex_skin_image/image-icon.png} +0 -0
- data/mod/06_bootstrap/file/{simplex_skin/large-image.png → simplex_skin_image/image-large.png} +0 -0
- data/mod/06_bootstrap/file/{simplex_skin/medium-image.png → simplex_skin_image/image-medium.png} +0 -0
- data/mod/06_bootstrap/file/{simplex_skin/original-image.png → simplex_skin_image/image-original.png} +0 -0
- data/mod/06_bootstrap/file/{simplex_skin/small-image.png → simplex_skin_image/image-small.png} +0 -0
- data/mod/06_bootstrap/file/{slate_skin/icon-image.png → slate_skin_image/image-icon.png} +0 -0
- data/mod/06_bootstrap/file/{slate_skin/large-image.png → slate_skin_image/image-large.png} +0 -0
- data/mod/06_bootstrap/file/{slate_skin/medium-image.png → slate_skin_image/image-medium.png} +0 -0
- data/mod/06_bootstrap/file/{slate_skin/original-image.png → slate_skin_image/image-original.png} +0 -0
- data/mod/06_bootstrap/file/{slate_skin/small-image.png → slate_skin_image/image-small.png} +0 -0
- data/mod/06_bootstrap/file/{spacelab_skin/icon-image.png → spacelab_skin_image/image-icon.png} +0 -0
- data/mod/06_bootstrap/file/{spacelab_skin/large-image.png → spacelab_skin_image/image-large.png} +0 -0
- data/mod/06_bootstrap/file/{spacelab_skin/medium-image.png → spacelab_skin_image/image-medium.png} +0 -0
- data/mod/06_bootstrap/file/{spacelab_skin/original-image.png → spacelab_skin_image/image-original.png} +0 -0
- data/mod/06_bootstrap/file/{spacelab_skin/small-image.png → spacelab_skin_image/image-small.png} +0 -0
- data/mod/06_bootstrap/file/{superhero_skin/icon-image.png → superhero_skin_image/image-icon.png} +0 -0
- data/mod/06_bootstrap/file/{superhero_skin/large-image.png → superhero_skin_image/image-large.png} +0 -0
- data/mod/06_bootstrap/file/{superhero_skin/medium-image.png → superhero_skin_image/image-medium.png} +0 -0
- data/mod/06_bootstrap/file/{superhero_skin/original-image.png → superhero_skin_image/image-original.png} +0 -0
- data/mod/06_bootstrap/file/{superhero_skin/small-image.png → superhero_skin_image/image-small.png} +0 -0
- data/mod/06_bootstrap/file/{united_skin/icon-image.png → united_skin_image/image-icon.png} +0 -0
- data/mod/06_bootstrap/file/{united_skin/large-image.png → united_skin_image/image-large.png} +0 -0
- data/mod/06_bootstrap/file/{united_skin/medium-image.png → united_skin_image/image-medium.png} +0 -0
- data/mod/06_bootstrap/file/{united_skin/original-image.png → united_skin_image/image-original.png} +0 -0
- data/mod/06_bootstrap/file/{united_skin/small-image.png → united_skin_image/image-small.png} +0 -0
- data/mod/06_bootstrap/file/{yeti_skin/icon-image.png → yeti_skin_image/image-icon.png} +0 -0
- data/mod/06_bootstrap/file/{yeti_skin/large-image.png → yeti_skin_image/image-large.png} +0 -0
- data/mod/06_bootstrap/file/{yeti_skin/medium-image.png → yeti_skin_image/image-medium.png} +0 -0
- data/mod/06_bootstrap/file/{yeti_skin/original-image.png → yeti_skin_image/image-original.png} +0 -0
- data/mod/06_bootstrap/file/{yeti_skin/small-image.png → yeti_skin_image/image-small.png} +0 -0
- data/mod/06_bootstrap/lib/stylesheets/bootstrap_cards.scss +5 -3
- data/spec/lib/card/reference_spec.rb +8 -1
- data/tmpsets/README.md +2 -0
- data/tmpsets/set/mod001-01_core/all/active_card.rb +40 -0
- data/tmpsets/set/mod001-01_core/all/collection.rb +348 -0
- data/tmpsets/set/mod001-01_core/all/content.rb +68 -0
- data/tmpsets/set/mod001-01_core/all/erb.rb +17 -0
- data/tmpsets/set/mod001-01_core/all/fetch.rb +242 -0
- data/tmpsets/set/mod001-01_core/all/haml.rb +13 -0
- data/tmpsets/set/mod001-01_core/all/initialize.rb +56 -0
- data/tmpsets/set/mod001-01_core/all/name.rb +279 -0
- data/tmpsets/set/mod001-01_core/all/pattern.rb +62 -0
- data/tmpsets/set/mod001-01_core/all/permissions.rb +289 -0
- data/tmpsets/set/mod001-01_core/all/phases.rb +187 -0
- data/tmpsets/set/mod001-01_core/all/references.rb +130 -0
- data/tmpsets/set/mod001-01_core/all/rules.rb +324 -0
- data/tmpsets/set/mod001-01_core/all/states.rb +28 -0
- data/tmpsets/set/mod001-01_core/all/templating.rb +132 -0
- data/tmpsets/set/mod001-01_core/all/tracked_attributes.rb +136 -0
- data/tmpsets/set/mod001-01_core/all/trash.rb +56 -0
- data/tmpsets/set/mod001-01_core/all/type.rb +91 -0
- data/tmpsets/set/mod001-01_core/all/utils.rb +162 -0
- data/tmpsets/set/mod001-01_core/all/view_cache.rb +14 -0
- data/tmpsets/set/mod002-01_history/all/actions.rb +54 -0
- data/tmpsets/set/mod002-01_history/all/content_history.rb +140 -0
- data/tmpsets/set/mod002-01_history/all/history.rb +341 -0
- data/tmpsets/set/mod003-02_basic_types/all/all_css.rb +48 -0
- data/tmpsets/set/mod003-02_basic_types/all/all_csv.rb +58 -0
- data/tmpsets/set/mod003-02_basic_types/all/all_js.rb +13 -0
- data/tmpsets/set/mod003-02_basic_types/all/base.rb +128 -0
- data/tmpsets/set/mod003-02_basic_types/all/file.rb +42 -0
- data/tmpsets/set/mod003-02_basic_types/all/json.rb +72 -0
- data/tmpsets/set/mod003-02_basic_types/all/rss.rb +78 -0
- data/tmpsets/set/mod003-02_basic_types/all/text.rb +14 -0
- data/tmpsets/set/mod003-02_basic_types/type/html.rb +33 -0
- data/tmpsets/set/mod003-02_basic_types/type/plain_text.rb +16 -0
- data/tmpsets/set/mod003-02_basic_types/type/pointer.rb +358 -0
- data/tmpsets/set/mod004-03_machines/right/machine_input.rb +8 -0
- data/tmpsets/set/mod004-03_machines/right/machine_output.rb +30 -0
- data/tmpsets/set/mod004-03_machines/self/script_ace.rb +18 -0
- data/tmpsets/set/mod004-03_machines/self/script_card_menu.rb +17 -0
- data/tmpsets/set/mod004-03_machines/self/script_html5shiv_printshiv.rb +8 -0
- data/tmpsets/set/mod004-03_machines/self/script_jquery.rb +8 -0
- data/tmpsets/set/mod004-03_machines/self/script_jquery_helper.rb +18 -0
- data/tmpsets/set/mod004-03_machines/self/script_slot.rb +13 -0
- data/tmpsets/set/mod004-03_machines/self/script_tinymce.rb +8 -0
- data/tmpsets/set/mod004-03_machines/self/style_bootstrap_compatible.rb +11 -0
- data/tmpsets/set/mod004-03_machines/self/style_cards.rb +12 -0
- data/tmpsets/set/mod004-03_machines/self/style_jquery_ui_smoothness.rb +9 -0
- data/tmpsets/set/mod004-03_machines/type/coffee_script.rb +67 -0
- data/tmpsets/set/mod004-03_machines/type/css.rb +55 -0
- data/tmpsets/set/mod004-03_machines/type/java_script.rb +43 -0
- data/tmpsets/set/mod004-03_machines/type/scss.rb +28 -0
- data/tmpsets/set/mod004-03_machines/type/skin.rb +18 -0
- data/tmpsets/set/mod005-04_settings/abstract/permission.rb +101 -0
- data/tmpsets/set/mod005-04_settings/right/add_help.rb +17 -0
- data/tmpsets/set/mod005-04_settings/right/comment.rb +9 -0
- data/tmpsets/set/mod005-04_settings/right/create.rb +9 -0
- data/tmpsets/set/mod005-04_settings/right/default.rb +9 -0
- data/tmpsets/set/mod005-04_settings/right/delete.rb +9 -0
- data/tmpsets/set/mod005-04_settings/right/help.rb +9 -0
- data/tmpsets/set/mod005-04_settings/right/read.rb +9 -0
- data/tmpsets/set/mod005-04_settings/right/script.rb +16 -0
- data/tmpsets/set/mod005-04_settings/right/structure.rb +16 -0
- data/tmpsets/set/mod005-04_settings/right/style.rb +16 -0
- data/tmpsets/set/mod005-04_settings/right/update.rb +9 -0
- data/tmpsets/set/mod005-04_settings/self/accountable.rb +9 -0
- data/tmpsets/set/mod005-04_settings/self/add_help.rb +8 -0
- data/tmpsets/set/mod005-04_settings/self/autoname.rb +8 -0
- data/tmpsets/set/mod005-04_settings/self/captcha.rb +8 -0
- data/tmpsets/set/mod005-04_settings/self/create.rb +8 -0
- data/tmpsets/set/mod005-04_settings/self/default.rb +8 -0
- data/tmpsets/set/mod005-04_settings/self/delete.rb +8 -0
- data/tmpsets/set/mod005-04_settings/self/help.rb +8 -0
- data/tmpsets/set/mod005-04_settings/self/input.rb +7 -0
- data/tmpsets/set/mod005-04_settings/self/layout.rb +8 -0
- data/tmpsets/set/mod005-04_settings/self/on_create.rb +8 -0
- data/tmpsets/set/mod005-04_settings/self/on_delete.rb +8 -0
- data/tmpsets/set/mod005-04_settings/self/on_update.rb +8 -0
- data/tmpsets/set/mod005-04_settings/self/options.rb +8 -0
- data/tmpsets/set/mod005-04_settings/self/options_label.rb +8 -0
- data/tmpsets/set/mod005-04_settings/self/read.rb +8 -0
- data/tmpsets/set/mod005-04_settings/self/recent_settings.rb +8 -0
- data/tmpsets/set/mod005-04_settings/self/script.rb +8 -0
- data/tmpsets/set/mod005-04_settings/self/structure.rb +8 -0
- data/tmpsets/set/mod005-04_settings/self/style.rb +8 -0
- data/tmpsets/set/mod005-04_settings/self/table_of_contents.rb +8 -0
- data/tmpsets/set/mod005-04_settings/self/thanks.rb +8 -0
- data/tmpsets/set/mod005-04_settings/self/update.rb +8 -0
- data/tmpsets/set/mod005-04_settings/type/setting.rb +96 -0
- data/tmpsets/set/mod006-05_email/all/email_html.rb +11 -0
- data/tmpsets/set/mod006-05_email/all/email_text.rb +11 -0
- data/tmpsets/set/mod006-05_email/all/follow.rb +260 -0
- data/tmpsets/set/mod006-05_email/all/notify.rb +244 -0
- data/tmpsets/set/mod006-05_email/all/observer.rb +33 -0
- data/tmpsets/set/mod006-05_email/right/bcc.rb +51 -0
- data/tmpsets/set/mod006-05_email/right/cc.rb +9 -0
- data/tmpsets/set/mod006-05_email/right/follow.rb +90 -0
- data/tmpsets/set/mod006-05_email/right/follow_fields.rb +8 -0
- data/tmpsets/set/mod006-05_email/right/followers.rb +35 -0
- data/tmpsets/set/mod006-05_email/right/following.rb +58 -0
- data/tmpsets/set/mod006-05_email/right/from.rb +9 -0
- data/tmpsets/set/mod006-05_email/right/html_message.rb +9 -0
- data/tmpsets/set/mod006-05_email/right/to.rb +9 -0
- data/tmpsets/set/mod006-05_email/self/always.rb +20 -0
- data/tmpsets/set/mod006-05_email/self/created.rb +27 -0
- data/tmpsets/set/mod006-05_email/self/edited.rb +30 -0
- data/tmpsets/set/mod006-05_email/self/follow.rb +8 -0
- data/tmpsets/set/mod006-05_email/self/follow_defaults.rb +71 -0
- data/tmpsets/set/mod006-05_email/self/never.rb +21 -0
- data/tmpsets/set/mod006-05_email/type/email_template.rb +119 -0
- data/tmpsets/set/mod006-05_email/type_plus_right/user/follow.rb +182 -0
- data/tmpsets/set/mod007-05_standard/abstract/attachment.rb +91 -0
- data/tmpsets/set/mod007-05_standard/all/account.rb +73 -0
- data/tmpsets/set/mod007-05_standard/all/comment.rb +45 -0
- data/tmpsets/set/mod007-05_standard/all/error.rb +198 -0
- data/tmpsets/set/mod007-05_standard/all/event_viz.rb +75 -0
- data/tmpsets/set/mod007-05_standard/all/links.rb +153 -0
- data/tmpsets/set/mod007-05_standard/all/rich_html/content.rb +248 -0
- data/tmpsets/set/mod007-05_standard/all/rich_html/editing.rb +216 -0
- data/tmpsets/set/mod007-05_standard/all/rich_html/form.rb +238 -0
- data/tmpsets/set/mod007-05_standard/all/rich_html/header.rb +80 -0
- data/tmpsets/set/mod007-05_standard/all/rich_html/menu.rb +135 -0
- data/tmpsets/set/mod007-05_standard/all/rich_html/modal.rb +98 -0
- data/tmpsets/set/mod007-05_standard/all/rich_html/toolbar.rb +271 -0
- data/tmpsets/set/mod007-05_standard/all/rich_html/wrapper.rb +158 -0
- data/tmpsets/set/mod007-05_standard/right/account.rb +187 -0
- data/tmpsets/set/mod007-05_standard/right/discussion.rb +9 -0
- data/tmpsets/set/mod007-05_standard/right/email.rb +57 -0
- data/tmpsets/set/mod007-05_standard/right/password.rb +44 -0
- data/tmpsets/set/mod007-05_standard/right/salt.rb +11 -0
- data/tmpsets/set/mod007-05_standard/right/stats.rb +41 -0
- data/tmpsets/set/mod007-05_standard/right/status.rb +15 -0
- data/tmpsets/set/mod007-05_standard/right/token.rb +11 -0
- data/tmpsets/set/mod007-05_standard/right/when_created.rb +11 -0
- data/tmpsets/set/mod007-05_standard/right/when_last_edited.rb +11 -0
- data/tmpsets/set/mod007-05_standard/rstar/rules.rb +411 -0
- data/tmpsets/set/mod007-05_standard/self/account_links.rb +55 -0
- data/tmpsets/set/mod007-05_standard/self/alerts.rb +11 -0
- data/tmpsets/set/mod007-05_standard/self/all.rb +28 -0
- data/tmpsets/set/mod007-05_standard/self/foot.rb +14 -0
- data/tmpsets/set/mod007-05_standard/self/head.rb +126 -0
- data/tmpsets/set/mod007-05_standard/self/navbox.rb +39 -0
- data/tmpsets/set/mod007-05_standard/self/now.rb +12 -0
- data/tmpsets/set/mod007-05_standard/self/performance_log.rb +98 -0
- data/tmpsets/set/mod007-05_standard/self/recent.rb +54 -0
- data/tmpsets/set/mod007-05_standard/self/search.rb +49 -0
- data/tmpsets/set/mod007-05_standard/self/signin.rb +130 -0
- data/tmpsets/set/mod007-05_standard/self/stats.rb +109 -0
- data/tmpsets/set/mod007-05_standard/self/version.rb +15 -0
- data/tmpsets/set/mod007-05_standard/type/basic.rb +52 -0
- data/tmpsets/set/mod007-05_standard/type/cardtype.rb +78 -0
- data/tmpsets/set/mod007-05_standard/type/date.rb +14 -0
- data/tmpsets/set/mod007-05_standard/type/file.rb +103 -0
- data/tmpsets/set/mod007-05_standard/type/image.rb +89 -0
- data/tmpsets/set/mod007-05_standard/type/layout_type.rb +21 -0
- data/tmpsets/set/mod007-05_standard/type/number.rb +25 -0
- data/tmpsets/set/mod007-05_standard/type/phrase.rb +9 -0
- data/tmpsets/set/mod007-05_standard/type/search_type.rb +291 -0
- data/tmpsets/set/mod007-05_standard/type/session.rb +42 -0
- data/tmpsets/set/mod007-05_standard/type/set.rb +354 -0
- data/tmpsets/set/mod007-05_standard/type/signup.rb +150 -0
- data/tmpsets/set/mod007-05_standard/type/toggle.rb +18 -0
- data/tmpsets/set/mod007-05_standard/type/uri.rb +17 -0
- data/tmpsets/set/mod007-05_standard/type/user.rb +78 -0
- data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/form.rb +41 -0
- data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/helper.rb +150 -0
- data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/wrapper.rb +18 -0
- data/tmpsets/set/mod008-06_bootstrap/all/rich_bootstrap.rb +14 -0
- data/tmpsets/set/mod008-06_bootstrap/self/bootstrap_cards.rb +15 -0
- data/tmpsets/set/mod008-06_bootstrap/self/bootstrap_js.rb +13 -0
- data/tmpsets/set/mod008-06_bootstrap/self/bootswatch_shared.rb +38 -0
- data/tmpsets/set/mod008-06_bootstrap/self/smartmenu_css.rb +13 -0
- data/tmpsets/set/mod008-06_bootstrap/self/smartmenu_js.rb +12 -0
- data/tmpsets/set_pattern/100-all.rb +24 -0
- data/tmpsets/set_pattern/101-all_plus.rb +26 -0
- data/tmpsets/set_pattern/102-type.rb +36 -0
- data/tmpsets/set_pattern/103-star.rb +28 -0
- data/tmpsets/set_pattern/104-rstar.rb +30 -0
- data/tmpsets/set_pattern/105-right.rb +33 -0
- data/tmpsets/set_pattern/106-type_plus_right.rb +36 -0
- data/tmpsets/set_pattern/107-self.rb +32 -0
- metadata +306 -107
- data/mod/05_standard/set/all/attach.rb +0 -164
- data/mod/05_standard/spec/set/all/attach_spec.rb +0 -9
@@ -0,0 +1,62 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
class Card; module Set; module All; module Pattern; extend Card::Set # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/pattern.rb ~~~~~~~~~~~
|
3
|
+
|
4
|
+
def patterns
|
5
|
+
@patterns ||= set_patterns.map { |sub| sub.new(self) }.compact
|
6
|
+
end
|
7
|
+
|
8
|
+
def patterns_with_new
|
9
|
+
new_card? ? patterns_without_new[1..-1] : patterns_without_new
|
10
|
+
end
|
11
|
+
alias_method_chain :patterns, :new
|
12
|
+
|
13
|
+
def reset_patterns
|
14
|
+
@set_mods_loaded = @patterns = @set_modules = @junction_only = @set_names = @template = @rule_set_keys = @virtual = nil
|
15
|
+
true
|
16
|
+
end
|
17
|
+
|
18
|
+
def reset_patterns_if_rule saving=false
|
19
|
+
if !new_card? && is_rule?
|
20
|
+
set = left
|
21
|
+
set.reset_patterns
|
22
|
+
set.include_set_modules
|
23
|
+
|
24
|
+
#this is really messy.
|
25
|
+
if saving
|
26
|
+
self.add_to_read_rule_update_queue( set.item_cards :limit=>0 ) if right.id == Card::ReadID
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def safe_set_keys
|
32
|
+
patterns.map( &:safe_key ).reverse * " "
|
33
|
+
end
|
34
|
+
|
35
|
+
def set_modules
|
36
|
+
@set_modules ||= patterns_without_new[0..-2].reverse.map(&:module_list).flatten.compact
|
37
|
+
end
|
38
|
+
|
39
|
+
def set_format_modules klass
|
40
|
+
@set_format_modules ||= {}
|
41
|
+
@set_format_modules[klass] = patterns_without_new[0..-2].reverse.map do |pattern|
|
42
|
+
pattern.format_module_list klass
|
43
|
+
end.flatten.compact
|
44
|
+
end
|
45
|
+
|
46
|
+
def set_names
|
47
|
+
if @set_names.nil?
|
48
|
+
@set_names = patterns.map &:to_s
|
49
|
+
Card.set_members @set_names, key
|
50
|
+
end
|
51
|
+
@set_names
|
52
|
+
end
|
53
|
+
|
54
|
+
def rule_set_keys
|
55
|
+
set_names #this triggers set_members cache. need better solution!
|
56
|
+
@rule_set_keys ||= patterns.map( &:rule_set_key ).compact
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
# ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/pattern.rb ~~~~~~~~~~~
|
62
|
+
end;end;end;end;
|
@@ -0,0 +1,289 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
class Card; module Set; module All; module Permissions; extend Card::Set # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/permissions.rb ~~~~~~~~~~~
|
3
|
+
|
4
|
+
Card.error_codes.merge! :permission_denied=>[:denial, 403], :captcha=>[:errors,449]
|
5
|
+
|
6
|
+
|
7
|
+
# ok? and ok! are public facing methods to approve one action at a time
|
8
|
+
#
|
9
|
+
# fetching: if the optional :trait parameter is supplied, it is passed
|
10
|
+
# to fetch and the test is perfomed on the fetched card, therefore:
|
11
|
+
#
|
12
|
+
# :trait=>:account would fetch this card plus a tag codenamed :account
|
13
|
+
# :trait=>:roles, :new=>{} would initialize a new card with default ({}) options.
|
14
|
+
|
15
|
+
|
16
|
+
def ok? action
|
17
|
+
@action_ok = true
|
18
|
+
send "ok_to_#{action}"
|
19
|
+
@action_ok
|
20
|
+
end
|
21
|
+
|
22
|
+
def ok_with_fetch? action, opts={}
|
23
|
+
card = opts[:trait].nil? ? self : fetch(opts)
|
24
|
+
card && card.ok_without_fetch?(action)
|
25
|
+
end
|
26
|
+
alias_method_chain :ok?, :fetch # note: method is chained so that we can return the instance variable @action_ok
|
27
|
+
|
28
|
+
|
29
|
+
def ok! action, opts={}
|
30
|
+
raise Card::PermissionDenied.new self unless ok? action, opts
|
31
|
+
end
|
32
|
+
|
33
|
+
def who_can action
|
34
|
+
#warn "who_can[#{name}] #{(prc=permission_rule_card(action)).inspect}, #{prc.first.item_cards.map(&:id)}" if action == :update
|
35
|
+
permission_rule_card(action).first.item_cards.map &:id
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
def permission_rule_card action
|
40
|
+
opcard = rule_card action
|
41
|
+
|
42
|
+
unless opcard # RULE missing. should not be possible. generalize this to handling of all required rules
|
43
|
+
errors.add :permission_denied, "No #{action} rule for #{name}"
|
44
|
+
raise Card::PermissionDenied.new(self)
|
45
|
+
end
|
46
|
+
|
47
|
+
rcard = Auth.as_bot do
|
48
|
+
if ['_left','[[_left]]'].member?(opcard.db_content) && self.junction? # compound cards can inherit permissions from left parent
|
49
|
+
lcard = left_or_new( :skip_virtual=>true, :skip_modules=>true )
|
50
|
+
if action==:create && lcard.real? && !lcard.action==:create
|
51
|
+
action = :update
|
52
|
+
end
|
53
|
+
lcard.permission_rule_card(action).first
|
54
|
+
else
|
55
|
+
opcard
|
56
|
+
end
|
57
|
+
end
|
58
|
+
return rcard, opcard.rule_class_name
|
59
|
+
end
|
60
|
+
|
61
|
+
def rule_class_name
|
62
|
+
trunk.type_id == Card::SetID ? cardname.trunk_name.tag : nil
|
63
|
+
end
|
64
|
+
|
65
|
+
def you_cant what
|
66
|
+
"You don't have permission to #{what}"
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
def deny_because why
|
71
|
+
@permission_errors << why if @permission_errors
|
72
|
+
@action_ok = false
|
73
|
+
end
|
74
|
+
|
75
|
+
def permitted? action
|
76
|
+
|
77
|
+
if !Card.config.read_only
|
78
|
+
return true if action != :comment and Auth.always_ok?
|
79
|
+
|
80
|
+
permitted_ids = who_can action
|
81
|
+
if action == :comment && Auth.always_ok?
|
82
|
+
# admin can comment if anyone can
|
83
|
+
!permitted_ids.empty?
|
84
|
+
else
|
85
|
+
Auth.among? permitted_ids
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def permit action, verb=nil
|
91
|
+
|
92
|
+
if Card.config.read_only # not called by ok_to_read
|
93
|
+
deny_because "Currently in read-only mode"
|
94
|
+
end
|
95
|
+
|
96
|
+
verb ||= action.to_s
|
97
|
+
unless permitted? action
|
98
|
+
deny_because you_cant("#{verb} #{name.present? ? name : 'this'}")
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def ok_to_create
|
103
|
+
permit :create
|
104
|
+
if @action_ok and junction?
|
105
|
+
[:left, :right].each do |side|
|
106
|
+
next if side==:left && @superleft # left is supercard; create permissions will get checked there.
|
107
|
+
part_card = send side, :new=>{}
|
108
|
+
if part_card && part_card.new_card? # if no card, there must be other errors
|
109
|
+
unless part_card.ok? :create
|
110
|
+
deny_because you_cant("create #{part_card.name}")
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def ok_to_read
|
118
|
+
if !Auth.always_ok?
|
119
|
+
@read_rule_id ||= permission_rule_card(:read).first.id.to_i
|
120
|
+
if !Auth.as_card.read_rules.member? @read_rule_id
|
121
|
+
deny_because you_cant "read this"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def ok_to_update
|
127
|
+
permit :update
|
128
|
+
if @action_ok and type_id_changed? and !permitted? :create
|
129
|
+
deny_because you_cant( "change to this type (need create permission)" )
|
130
|
+
end
|
131
|
+
ok_to_read if @action_ok
|
132
|
+
end
|
133
|
+
|
134
|
+
def ok_to_delete
|
135
|
+
permit :delete
|
136
|
+
end
|
137
|
+
|
138
|
+
def ok_to_comment
|
139
|
+
permit :comment, 'comment on'
|
140
|
+
if @action_ok
|
141
|
+
deny_because "No comments allowed on templates" if is_template?
|
142
|
+
deny_because "No comments allowed on structured content" if structure
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
event :set_read_rule, :before=>:store do
|
148
|
+
if trash == true
|
149
|
+
self.read_rule_id = self.read_rule_class = nil
|
150
|
+
else
|
151
|
+
# avoid doing this on simple content saves?
|
152
|
+
rcard, rclass = permission_rule_card(:read)
|
153
|
+
self.read_rule_id = rcard.id
|
154
|
+
self.read_rule_class = rclass
|
155
|
+
#find all cards with me as trunk and update their read_rule (because of *type plus right)
|
156
|
+
# skip if name is updated because will already be resaved
|
157
|
+
|
158
|
+
if !new_card? && type_id_changed?
|
159
|
+
Auth.as_bot do
|
160
|
+
Card.search(:left=>self.name).each do |plus_card|
|
161
|
+
plus_card = plus_card.refresh.update_read_rule
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def update_read_rule
|
169
|
+
Card.record_timestamps = false
|
170
|
+
|
171
|
+
reset_patterns # why is this needed?
|
172
|
+
rcard, rclass = permission_rule_card :read
|
173
|
+
self.read_rule_id = rcard.id #these two are just to make sure vals are correct on current object
|
174
|
+
#warn "updating read rule for #{inspect} to #{rcard.inspect}, #{rclass}"
|
175
|
+
|
176
|
+
self.read_rule_class = rclass
|
177
|
+
Card.where(:id=>self.id).update_all(:read_rule_id=>rcard.id, :read_rule_class=>rclass)
|
178
|
+
expire
|
179
|
+
|
180
|
+
# currently doing a brute force search for every card that may be impacted. may want to optimize(?)
|
181
|
+
Auth.as_bot do
|
182
|
+
Card.search(:left=>self.name).each do |plus_card|
|
183
|
+
if plus_card.rule(:read) == '_left'
|
184
|
+
plus_card.update_read_rule
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
ensure
|
190
|
+
Card.record_timestamps = true
|
191
|
+
end
|
192
|
+
|
193
|
+
def add_to_read_rule_update_queue updates
|
194
|
+
@read_rule_update_queue = Array.wrap(@read_rule_update_queue).concat updates
|
195
|
+
end
|
196
|
+
|
197
|
+
|
198
|
+
event :check_permissions, :after=>:approve do
|
199
|
+
task = if @action != :delete && comment #will be obviated by new comment handling
|
200
|
+
:comment
|
201
|
+
else
|
202
|
+
@action
|
203
|
+
end
|
204
|
+
track_permission_errors do
|
205
|
+
ok? task
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
def track_permission_errors
|
210
|
+
@permission_errors = []
|
211
|
+
result = yield
|
212
|
+
|
213
|
+
@permission_errors.each do |message|
|
214
|
+
errors.add :permission_denied, message
|
215
|
+
end
|
216
|
+
@permission_errors = nil
|
217
|
+
|
218
|
+
result
|
219
|
+
end
|
220
|
+
|
221
|
+
|
222
|
+
def recaptcha_on?
|
223
|
+
have_recaptcha_keys? &&
|
224
|
+
Env[:controller] &&
|
225
|
+
!Auth.signed_in? &&
|
226
|
+
!Auth.needs_setup? &&
|
227
|
+
!Auth.always_ok? &&
|
228
|
+
Card.toggle( rule :captcha )
|
229
|
+
end
|
230
|
+
|
231
|
+
def have_recaptcha_keys?
|
232
|
+
@@have_recaptcha_keys = defined?(@@have_recaptcha_keys) ? @@have_recaptcha_keys :
|
233
|
+
!!( Card.config.recaptcha_public_key && Card.config.recaptcha_private_key )
|
234
|
+
end
|
235
|
+
|
236
|
+
event :recaptcha, :before=>:approve do
|
237
|
+
if !@supercard && !Env[:recaptcha_used] && recaptcha_on?
|
238
|
+
Env[:recaptcha_used] = true
|
239
|
+
Env[:controller].verify_recaptcha :model=>self, :attribute=>:captcha
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
module Accounts
|
244
|
+
# This is a short-term hack that is used in account-related cards to allow a permissions pattern where
|
245
|
+
# permissions are restricted to the owner of the account (and, by default, Admin)
|
246
|
+
# That pattern should be permitted by our card representation (without creating
|
247
|
+
# separate rules for each account holder) but is not yet.
|
248
|
+
|
249
|
+
def permit action, verb=nil
|
250
|
+
case
|
251
|
+
when action==:comment ; @action_ok = false
|
252
|
+
when action==:create ; @superleft ? true : super( action, verb )
|
253
|
+
#restricts account creation to subcard handling on permitted card (unless explicitly permitted)
|
254
|
+
when is_own_account? ; true
|
255
|
+
else ; super action, verb
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
end
|
260
|
+
|
261
|
+
module Follow
|
262
|
+
def ok_to_update
|
263
|
+
permit :update
|
264
|
+
end
|
265
|
+
|
266
|
+
def ok_to_create
|
267
|
+
permit :create
|
268
|
+
end
|
269
|
+
|
270
|
+
def ok_to_delete
|
271
|
+
permit :delete
|
272
|
+
end
|
273
|
+
|
274
|
+
def permit action, verb=nil
|
275
|
+
if [:create, :delete, :update].include?(action) && Auth.signed_in? &&
|
276
|
+
(user = rule_user) && Auth.current_id == user.id
|
277
|
+
return true
|
278
|
+
else
|
279
|
+
super action, verb
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
end
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
# ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/permissions.rb ~~~~~~~~~~~
|
289
|
+
end;end;end;end;
|
@@ -0,0 +1,187 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
class Card; module Set; module All; module Phases; extend Card::Set # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/phases.rb ~~~~~~~~~~~
|
3
|
+
|
4
|
+
# The Card#abort method is for cleanly exiting an action without continuing to process any further events.
|
5
|
+
#
|
6
|
+
# Three statuses are supported:
|
7
|
+
#
|
8
|
+
# failure: adds an error, returns false on save
|
9
|
+
# success: no error, returns true on save
|
10
|
+
# triumph: similar to success, but if called on a subcard it causes the entire action to abort (not just the subcard)
|
11
|
+
|
12
|
+
def abort status, msg='action canceled'
|
13
|
+
if status == :failure && errors.empty?
|
14
|
+
errors.add :abort, msg
|
15
|
+
elsif Hash === status and status[:success]
|
16
|
+
Env.params[:success] = status[:success]
|
17
|
+
status = :success
|
18
|
+
end
|
19
|
+
raise Card::Abort.new( status, msg)
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def abortable
|
24
|
+
yield
|
25
|
+
rescue Card::Abort => e
|
26
|
+
if e.status == :triumph
|
27
|
+
@supercard ? raise( e ) : true
|
28
|
+
elsif e.status == :success
|
29
|
+
if @supercard
|
30
|
+
@supercard.subcards.delete_if { |k,v| v==self }
|
31
|
+
end
|
32
|
+
true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def valid_subcard?
|
37
|
+
abortable { valid? }
|
38
|
+
end
|
39
|
+
|
40
|
+
# this is an override of standard rails behavior that rescues abortmakes it so that :success abortions do not rollback
|
41
|
+
def with_transaction_returning_status
|
42
|
+
status = nil
|
43
|
+
self.class.transaction do
|
44
|
+
add_to_transaction
|
45
|
+
status = abortable { yield }
|
46
|
+
raise ActiveRecord::Rollback unless status
|
47
|
+
end
|
48
|
+
status
|
49
|
+
end
|
50
|
+
|
51
|
+
# perhaps above should be in separate module?
|
52
|
+
#~~~~~~
|
53
|
+
|
54
|
+
def approve
|
55
|
+
@action = identify_action
|
56
|
+
# the following should really happen when type, name etc are changed
|
57
|
+
reset_patterns
|
58
|
+
include_set_modules
|
59
|
+
run_callbacks :approve
|
60
|
+
expire_pieces if errors.any?
|
61
|
+
errors.empty?
|
62
|
+
rescue =>e
|
63
|
+
rescue_event e
|
64
|
+
end
|
65
|
+
|
66
|
+
def identify_action
|
67
|
+
case
|
68
|
+
when trash ; :delete
|
69
|
+
when new_card? ; :create
|
70
|
+
else :update
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
def store
|
76
|
+
run_callbacks :store do
|
77
|
+
yield #unless @draft
|
78
|
+
@virtual = false
|
79
|
+
end
|
80
|
+
run_callbacks :stored
|
81
|
+
rescue =>e
|
82
|
+
rescue_event e
|
83
|
+
ensure
|
84
|
+
@from_trash = @last_action_id = @last_content_action_id = nil
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
def extend
|
89
|
+
run_callbacks :extend
|
90
|
+
run_callbacks :subsequent
|
91
|
+
rescue =>e
|
92
|
+
rescue_event e
|
93
|
+
ensure
|
94
|
+
@action = nil
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
def rescue_event e
|
101
|
+
@action = nil
|
102
|
+
expire_pieces
|
103
|
+
subcards.each do |key, card|
|
104
|
+
next unless Card===card
|
105
|
+
card.expire_pieces
|
106
|
+
end
|
107
|
+
raise e
|
108
|
+
#rescue Card::Cancel
|
109
|
+
# false
|
110
|
+
end
|
111
|
+
|
112
|
+
event :notable_exception_raised do
|
113
|
+
Rails.logger.debug "BT: #{Card::Error.current.backtrace*"\n "}"
|
114
|
+
end
|
115
|
+
|
116
|
+
|
117
|
+
def event_applies? opts
|
118
|
+
if opts[:on]
|
119
|
+
return false unless Array.wrap( opts[:on] ).member? @action
|
120
|
+
end
|
121
|
+
if changed_field = opts[:changed]
|
122
|
+
|
123
|
+
changed_field = 'db_content' if changed_field.to_sym == :content
|
124
|
+
return false if @action == :delete or !changes[ changed_field.to_s ]
|
125
|
+
end
|
126
|
+
if opts[:when]
|
127
|
+
return false unless opts[:when].call self
|
128
|
+
end
|
129
|
+
true
|
130
|
+
end
|
131
|
+
|
132
|
+
def subcards
|
133
|
+
@subcards ||= {}
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
event :process_subcards, :after=>:approve, :on=>:save do
|
138
|
+
subcards.keys.each do |sub_name|
|
139
|
+
opts = @subcards[sub_name] || {}
|
140
|
+
opts = { 'content' => opts } if String===opts
|
141
|
+
ab_name = sub_name.to_name.to_absolute_name name
|
142
|
+
next if ab_name.key == key # don't resave self!
|
143
|
+
|
144
|
+
opts = opts.stringify_keys
|
145
|
+
opts['subcards'] = extract_subcard_args! opts
|
146
|
+
|
147
|
+
opts[:supercard] = self
|
148
|
+
|
149
|
+
subcard =
|
150
|
+
if known_card = Card[ab_name]
|
151
|
+
known_card.refresh.assign_attributes opts
|
152
|
+
known_card
|
153
|
+
elsif (opts['content'].present? && opts['content'].strip.present?) ||
|
154
|
+
opts['subcards'].present? || opts['file'].present? || opts['image'].present?
|
155
|
+
Card.new opts.reverse_merge 'name' => sub_name
|
156
|
+
end
|
157
|
+
|
158
|
+
if subcard
|
159
|
+
@subcards[sub_name] = subcard
|
160
|
+
else
|
161
|
+
@subcards.delete sub_name
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
event :approve_subcards, :after=>:process_subcards do
|
167
|
+
subcards.each do |key, subcard|
|
168
|
+
if !subcard.valid_subcard?
|
169
|
+
subcard.errors.each do |field, err|
|
170
|
+
err = "#{field} #{err}" unless [:content, :abort].member? field
|
171
|
+
errors.add subcard.relative_name, err
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
event :store_subcards, :after=>:store do
|
178
|
+
subcards.each do |key, sub|
|
179
|
+
sub.save! :validate=>false #unless @draft
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
# ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/phases.rb ~~~~~~~~~~~
|
187
|
+
end;end;end;end;
|