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,68 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
class Card; module Set; module All; module Content; extend Card::Set # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/content.rb ~~~~~~~~~~~
|
3
|
+
::Card.error_codes[:conflict] = [:conflict, 409]
|
4
|
+
|
5
|
+
def content
|
6
|
+
db_content or (new_card? && template.db_content)
|
7
|
+
end
|
8
|
+
|
9
|
+
def content=(value)
|
10
|
+
self.db_content = value
|
11
|
+
end
|
12
|
+
|
13
|
+
def raw_content
|
14
|
+
structure ? template.db_content : content
|
15
|
+
end
|
16
|
+
|
17
|
+
format do
|
18
|
+
def chunk_list #override to customize by set
|
19
|
+
:default
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def label
|
24
|
+
name
|
25
|
+
end
|
26
|
+
|
27
|
+
def creator
|
28
|
+
Card[ creator_id ]
|
29
|
+
end
|
30
|
+
|
31
|
+
def updater
|
32
|
+
Card[ updater_id ]
|
33
|
+
end
|
34
|
+
|
35
|
+
def clean_html?
|
36
|
+
true
|
37
|
+
end
|
38
|
+
|
39
|
+
def history?
|
40
|
+
false
|
41
|
+
end
|
42
|
+
|
43
|
+
def save_content_draft content
|
44
|
+
clear_drafts
|
45
|
+
end
|
46
|
+
|
47
|
+
def clear_drafts
|
48
|
+
drafts.created_by(Card::Auth.current_id).each do |draft|
|
49
|
+
draft.delete
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
event :save_draft, :before=>:store, :on=>:update, :when=>proc{ |c| Env.params['draft'] == 'true' } do
|
54
|
+
save_content_draft content
|
55
|
+
abort :success
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
event :set_default_content, :on=>:create, :before=>:approve do
|
60
|
+
if !db_content_changed? && template && template.db_content.present?
|
61
|
+
self.db_content = template.db_content
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
# ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/content.rb ~~~~~~~~~~~
|
68
|
+
end;end;end;end;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
class Card; module Set; module All; module Erb; extend Card::Set # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/erb.rb ~~~~~~~~~~~
|
3
|
+
format do
|
4
|
+
def render_erb locals={}, template=nil, a_binding=nil, &block
|
5
|
+
template ||= block.call
|
6
|
+
a_binding ||= binding
|
7
|
+
locals.each do |k,v|
|
8
|
+
#a_binding.local_variable_set(k, v) # needs ruby 2.1
|
9
|
+
instance_variable_set("@#{k}",v)
|
10
|
+
end
|
11
|
+
ERB.new(template,nil,'-').result(binding)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
# ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/erb.rb ~~~~~~~~~~~
|
17
|
+
end;end;end;end;
|
@@ -0,0 +1,242 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
class Card; module Set; module All; module Fetch; extend Card::Set # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/fetch.rb ~~~~~~~~~~~
|
3
|
+
# = Card#fetch
|
4
|
+
#
|
5
|
+
# A multipurpose retrieval operator that incorporates caching, "virtual" card retrieval
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
|
9
|
+
# === fetch
|
10
|
+
#
|
11
|
+
# looks for cards in
|
12
|
+
# - cache
|
13
|
+
# - database
|
14
|
+
# - virtual cards
|
15
|
+
#
|
16
|
+
# "mark" here means one of three unique identifiers
|
17
|
+
# 1. a numeric id (Integer)
|
18
|
+
# 2. a name/key (String or Card::Name)
|
19
|
+
# 3. a codename (Symbol)
|
20
|
+
#
|
21
|
+
# Options:
|
22
|
+
# :skip_virtual Real cards only
|
23
|
+
# :skip_modules Don't load Set modules
|
24
|
+
# :look_in_trash Return trashed card objects
|
25
|
+
# :new => { card opts } Return a new card when not found
|
26
|
+
#
|
27
|
+
def fetch mark, opts={}
|
28
|
+
if String === mark
|
29
|
+
case mark
|
30
|
+
when /^\~(\d+)$/ # get by id
|
31
|
+
mark = $1.to_i
|
32
|
+
when /^\:(\w+)$/ # get by codename
|
33
|
+
mark = $1.to_sym
|
34
|
+
end
|
35
|
+
end
|
36
|
+
mark = Card::Codename[mark] if Symbol === mark # id from codename
|
37
|
+
|
38
|
+
if mark.present?
|
39
|
+
card, mark, needs_caching = fetch_from_cache_or_db mark, opts # have existing
|
40
|
+
else
|
41
|
+
return unless opts[:new]
|
42
|
+
end
|
43
|
+
|
44
|
+
if Integer===mark
|
45
|
+
return if card.nil? || mark.nil?
|
46
|
+
else
|
47
|
+
return card.renew(opts) if card and card.eager_renew?(opts)
|
48
|
+
if !card or card.type_id==-1 && clean_cache_opts?(opts) # new (or improved) card for cache
|
49
|
+
needs_caching = true
|
50
|
+
card = new_for_cache mark, opts
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
write_to_cache card if Card.cache && needs_caching
|
55
|
+
|
56
|
+
if card.new_card?
|
57
|
+
if opts[:new]
|
58
|
+
return card.renew(opts) if !clean_cache_opts? opts
|
59
|
+
elsif opts[:skip_virtual]
|
60
|
+
return
|
61
|
+
else
|
62
|
+
card.include_set_modules unless opts[:skip_modules] # need to load modules here to call the right virtual? method
|
63
|
+
return unless card.virtual?
|
64
|
+
end
|
65
|
+
card.name = mark.to_s if mark && mark.to_s != card.name
|
66
|
+
end
|
67
|
+
|
68
|
+
card.include_set_modules unless opts[:skip_modules]
|
69
|
+
card
|
70
|
+
end
|
71
|
+
|
72
|
+
def fetch_id mark #should optimize this. what if mark is int? or codename?
|
73
|
+
card = fetch mark, :skip_virtual=>true, :skip_modules=>true
|
74
|
+
card and card.id
|
75
|
+
end
|
76
|
+
|
77
|
+
def [](mark)
|
78
|
+
fetch mark, :skip_virtual=>true
|
79
|
+
end
|
80
|
+
|
81
|
+
def exists? mark
|
82
|
+
card = fetch mark, :skip_virtual=>true, :skip_modules=>true
|
83
|
+
card.present?
|
84
|
+
end
|
85
|
+
|
86
|
+
def known? mark
|
87
|
+
card = fetch mark, :skip_modules=>true
|
88
|
+
card.present?
|
89
|
+
end
|
90
|
+
|
91
|
+
def expire name
|
92
|
+
#note: calling instance method breaks on dirty names
|
93
|
+
key = name.to_name.key
|
94
|
+
if card = Card.cache.read( key )
|
95
|
+
Card.cache.delete key
|
96
|
+
Card.cache.delete "~#{card.id}" if card.id
|
97
|
+
end
|
98
|
+
#Rails.logger.warn "expiring #{name}, #{card.inspect}"
|
99
|
+
end
|
100
|
+
|
101
|
+
# set_names reverse map (cached)
|
102
|
+
def members key
|
103
|
+
(v=Card.cache.read "$#{key}").nil? ? [] : v.keys
|
104
|
+
end
|
105
|
+
|
106
|
+
def set_members set_names, key
|
107
|
+
set_names.compact.map(&:to_name).map(&:key).map do |set_key|
|
108
|
+
skey = "$#{set_key}" # dollar sign avoids conflict with card keys
|
109
|
+
h = Card.cache.read skey
|
110
|
+
if h.nil?
|
111
|
+
h = {}
|
112
|
+
elsif h[key]
|
113
|
+
next
|
114
|
+
end
|
115
|
+
h = h.dup if h.frozen?
|
116
|
+
h[key] = true
|
117
|
+
Card.cache.write skey, h
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def cache
|
122
|
+
Card::Cache[Card]
|
123
|
+
end
|
124
|
+
|
125
|
+
def fetch_from_cache cache_key
|
126
|
+
Card.cache.read cache_key if Card.cache
|
127
|
+
end
|
128
|
+
|
129
|
+
def fullname_from_name name, new_opts={}
|
130
|
+
if new_opts and supercard = new_opts[:supercard]
|
131
|
+
name.to_name.to_absolute_name supercard.name
|
132
|
+
else
|
133
|
+
name.to_name
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def fetch_from_cache_or_db mark, opts
|
138
|
+
needs_caching = false
|
139
|
+
mark_type = Integer===mark ? :id : :key
|
140
|
+
|
141
|
+
if mark_type == :key
|
142
|
+
mark = fullname_from_name mark, opts[:new]
|
143
|
+
val = mark.key
|
144
|
+
else
|
145
|
+
val = mark
|
146
|
+
end
|
147
|
+
|
148
|
+
card = send( "fetch_from_cache_by_#{mark_type}", val )
|
149
|
+
|
150
|
+
if opts[:look_in_trash]
|
151
|
+
if card.nil? || (card.new_card? && !card.trash)
|
152
|
+
card = Card.where( mark_type => val ).take
|
153
|
+
needs_caching = card && !card.trash
|
154
|
+
end
|
155
|
+
elsif card.nil?
|
156
|
+
needs_caching = true
|
157
|
+
card = Card.where( mark_type => val, trash: false).take
|
158
|
+
end
|
159
|
+
|
160
|
+
[ card, mark, needs_caching ]
|
161
|
+
end
|
162
|
+
|
163
|
+
|
164
|
+
def fetch_from_cache_by_id id
|
165
|
+
if name = fetch_from_cache("~#{id}")
|
166
|
+
fetch_from_cache name
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def fetch_from_cache_by_key key
|
171
|
+
fetch_from_cache key
|
172
|
+
end
|
173
|
+
|
174
|
+
def new_for_cache name, opts
|
175
|
+
new_args = { :name=>name, :skip_modules=>true }
|
176
|
+
new_args[:type_id] = -1 unless clean_cache_opts? opts
|
177
|
+
# The -1 type_id allows us to skip all the type lookup and flag the need for
|
178
|
+
# reinitialization later. *** It should NEVER be seen elsewhere ***
|
179
|
+
new new_args
|
180
|
+
end
|
181
|
+
|
182
|
+
def clean_cache_opts? opts
|
183
|
+
!opts[:skip_virtual] && !opts[:new].present?
|
184
|
+
end
|
185
|
+
|
186
|
+
def write_to_cache card
|
187
|
+
Card.cache.write card.key, card
|
188
|
+
Card.cache.write "~#{card.id}", card.key if card.id and card.id != 0
|
189
|
+
end
|
190
|
+
|
191
|
+
|
192
|
+
end
|
193
|
+
|
194
|
+
# ~~~~~~~~~~ Instance ~~~~~~~~~~~~~
|
195
|
+
|
196
|
+
def fetch opts={}
|
197
|
+
if traits = opts.delete(:trait)
|
198
|
+
traits = [traits] unless Array===traits
|
199
|
+
traits.inject(self) { |card, trait| Card.fetch( card.cardname.trait(trait), opts ) }
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
|
204
|
+
def renew args={}
|
205
|
+
opts = args[:new].clone
|
206
|
+
opts[:name] ||= cardname
|
207
|
+
opts[:skip_modules] = args[:skip_modules]
|
208
|
+
Card.new opts
|
209
|
+
end
|
210
|
+
|
211
|
+
def expire_pieces
|
212
|
+
cardname.piece_names.each do |piece|
|
213
|
+
Card.expire piece
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
|
218
|
+
def expire
|
219
|
+
#Rails.logger.warn "expiring i:#{id}, #{inspect}"
|
220
|
+
Card.cache.delete key
|
221
|
+
Card.cache.delete "~#{id}" if id
|
222
|
+
end
|
223
|
+
|
224
|
+
def refresh force=false
|
225
|
+
if force || self.frozen? || self.readonly?
|
226
|
+
fresh_card = self.class.find id
|
227
|
+
fresh_card.include_set_modules
|
228
|
+
fresh_card
|
229
|
+
else
|
230
|
+
self
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
def eager_renew? opts
|
235
|
+
opts[:skip_virtual] && new_card? && opts[:new].present?
|
236
|
+
end
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
# ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/fetch.rb ~~~~~~~~~~~
|
242
|
+
end;end;end;end;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
class Card; module Set; module All; module Haml; extend Card::Set # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/haml.rb ~~~~~~~~~~~
|
3
|
+
format do
|
4
|
+
def render_haml locals={}, template=nil, a_binding=nil, &block
|
5
|
+
template ||= block.call
|
6
|
+
a_binding ||= binding
|
7
|
+
::Haml::Engine.new(template).render(a_binding, locals)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
# ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/haml.rb ~~~~~~~~~~~
|
13
|
+
end;end;end;end;
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
class Card; module Set; module All; module Initialize; extend Card::Set # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/initialize.rb ~~~~~~~~~~~
|
3
|
+
JUNK_INIT_ARGS = %w{ missing skip_virtual id }
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
def new args={}, options={}
|
7
|
+
args = (args || {}).stringify_keys
|
8
|
+
JUNK_INIT_ARGS.each { |a| args.delete(a) }
|
9
|
+
%w{ type type_code }.each { |k| args.delete(k) if args[k].blank? }
|
10
|
+
args.delete('content') if args['attach'] # should not be handled here!
|
11
|
+
super args
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize args={}
|
16
|
+
args['name'] = args['name' ].to_s
|
17
|
+
args['type_id'] = args['type_id'].to_i
|
18
|
+
|
19
|
+
args.delete('type_id') if args['type_id'] == 0 # can come in as 0, '', or nil
|
20
|
+
@type_args = {
|
21
|
+
:type => args.delete('type' ),
|
22
|
+
:type_code => args.delete('type_code'),
|
23
|
+
:type_id => args[ 'type_id' ]
|
24
|
+
}
|
25
|
+
|
26
|
+
args['db_content'] = args.delete('content') if args['content']
|
27
|
+
|
28
|
+
#FIXME -- too much of the above is duplicated by assign_attributes (tracked_attributes.rb)
|
29
|
+
|
30
|
+
@supercard = args.delete 'supercard' # must come before name =
|
31
|
+
skip_modules = args.delete 'skip_modules'
|
32
|
+
|
33
|
+
super args # ActiveRecord #initialize
|
34
|
+
|
35
|
+
if tid = get_type_id( @type_args )
|
36
|
+
self.type_id = tid
|
37
|
+
end
|
38
|
+
|
39
|
+
include_set_modules unless skip_modules
|
40
|
+
self
|
41
|
+
end
|
42
|
+
|
43
|
+
def include_set_modules
|
44
|
+
unless @set_mods_loaded
|
45
|
+
set_modules.each do |m|
|
46
|
+
singleton_class.send :include, m
|
47
|
+
end
|
48
|
+
assign_set_specific_attributes
|
49
|
+
@set_mods_loaded=true
|
50
|
+
end
|
51
|
+
self
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
# ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/initialize.rb ~~~~~~~~~~~
|
56
|
+
end;end;end;end;
|
@@ -0,0 +1,279 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
class Card; module Set; module All; module Name; extend Card::Set # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/name.rb ~~~~~~~~~~~
|
3
|
+
require 'uuid'
|
4
|
+
|
5
|
+
def name= newname
|
6
|
+
cardname = newname.to_name
|
7
|
+
if @supercard
|
8
|
+
@relative_name = cardname.to_s
|
9
|
+
relparts = @relative_name.to_name.parts
|
10
|
+
@superleft = @supercard if relparts.size==2 && relparts.first.blank?
|
11
|
+
cardname = @relative_name.to_name.to_absolute_name @supercard.name
|
12
|
+
end
|
13
|
+
|
14
|
+
newkey = cardname.key
|
15
|
+
if key != newkey
|
16
|
+
self.key = newkey
|
17
|
+
reset_patterns_if_rule # reset the old name - should be handled in tracked_attributes!!
|
18
|
+
reset_patterns
|
19
|
+
end
|
20
|
+
|
21
|
+
subcards.each do |subkey, subcard|
|
22
|
+
next unless Card===subcard
|
23
|
+
subcard.name = subkey.to_name.to_absolute cardname
|
24
|
+
end
|
25
|
+
|
26
|
+
write_attribute :name, cardname.s
|
27
|
+
end
|
28
|
+
|
29
|
+
def cardname
|
30
|
+
name.to_name
|
31
|
+
end
|
32
|
+
|
33
|
+
def autoname name
|
34
|
+
if Card.exists? name
|
35
|
+
autoname name.next
|
36
|
+
else
|
37
|
+
name
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# FIXME: use delegations and include all cardname functions
|
42
|
+
def simple?
|
43
|
+
cardname.simple?
|
44
|
+
end
|
45
|
+
|
46
|
+
def junction?
|
47
|
+
cardname.junction?
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def relative_name
|
52
|
+
@relative_name || name
|
53
|
+
end
|
54
|
+
|
55
|
+
def left *args
|
56
|
+
if !simple?
|
57
|
+
@superleft or begin
|
58
|
+
unless name_changed? and name.to_name.trunk_name.key == name_was.to_name.key
|
59
|
+
# prevent recursion when, eg, renaming A+B to A+B+C
|
60
|
+
Card.fetch cardname.left, *args
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def right *args
|
67
|
+
Card.fetch( cardname.right, *args ) if !simple?
|
68
|
+
end
|
69
|
+
|
70
|
+
def [] *args
|
71
|
+
if args[0].kind_of?(Fixnum) || args[0].kind_of?(Range)
|
72
|
+
fetch_name = Array.wrap(cardname.parts[args[0]]).compact.join '+'
|
73
|
+
Card.fetch( fetch_name, args[1] || {} ) if !simple?
|
74
|
+
else
|
75
|
+
super
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def trunk *args
|
80
|
+
simple? ? self : left( *args )
|
81
|
+
end
|
82
|
+
|
83
|
+
def tag *args
|
84
|
+
simple? ? self : Card.fetch( cardname.right, *args )
|
85
|
+
end
|
86
|
+
|
87
|
+
def left_or_new args={}
|
88
|
+
left args or Card.new args.merge(:name=>cardname.left)
|
89
|
+
end
|
90
|
+
|
91
|
+
def children
|
92
|
+
Card.search( { (simple? ? :part : :left) => name } ).to_a
|
93
|
+
end
|
94
|
+
|
95
|
+
def dependents
|
96
|
+
return [] if new_card?
|
97
|
+
|
98
|
+
if @dependents.nil?
|
99
|
+
@dependents =
|
100
|
+
Auth.as_bot do
|
101
|
+
deps = children
|
102
|
+
deps.inject(deps) do |array, card|
|
103
|
+
array + card.dependents
|
104
|
+
end
|
105
|
+
end
|
106
|
+
#Rails.logger.warn "dependents[#{inspect}] #{@dependents.inspect}"
|
107
|
+
end
|
108
|
+
@dependents
|
109
|
+
end
|
110
|
+
|
111
|
+
def repair_key
|
112
|
+
Auth.as_bot do
|
113
|
+
correct_key = cardname.key
|
114
|
+
current_key = key
|
115
|
+
return self if current_key==correct_key
|
116
|
+
|
117
|
+
if key_blocker = Card.find_by_key_and_trash(correct_key, true)
|
118
|
+
key_blocker.cardname = key_blocker.cardname + "*trash#{rand(4)}"
|
119
|
+
key_blocker.save
|
120
|
+
end
|
121
|
+
|
122
|
+
saved = ( self.key = correct_key and self.save! )
|
123
|
+
saved ||= ( self.cardname = current_key and self.save! )
|
124
|
+
|
125
|
+
if saved
|
126
|
+
self.dependents.each { |c| c.repair_key }
|
127
|
+
else
|
128
|
+
Rails.logger.debug "FAILED TO REPAIR BROKEN KEY: #{key}"
|
129
|
+
self.name = "BROKEN KEY: #{name}"
|
130
|
+
end
|
131
|
+
self
|
132
|
+
end
|
133
|
+
rescue
|
134
|
+
Rails.logger.info "BROKE ATTEMPTING TO REPAIR BROKEN KEY: #{key}"
|
135
|
+
self
|
136
|
+
end
|
137
|
+
|
138
|
+
|
139
|
+
event :permit_codename, :before=>:approve, :on=>:update, :changed=>:codename do
|
140
|
+
errors.add :codename, 'only admins can set codename' unless Auth.always_ok?
|
141
|
+
end
|
142
|
+
|
143
|
+
event :validate_unique_codename, :after=>:permit_codename do
|
144
|
+
if codename.present? and errors.empty? and Card.find_by_codename(codename).present?
|
145
|
+
errors.add :codename, "codename #{codename} already in use"
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
event :validate_name, :before=>:approve, :on=>:save do
|
150
|
+
cdname = name.to_name
|
151
|
+
if name.length > 255
|
152
|
+
errors.add :name, "is too long (255 character maximum)"
|
153
|
+
elsif cdname.blank?
|
154
|
+
errors.add :name, "can't be blank"
|
155
|
+
elsif name_changed?
|
156
|
+
#Rails.logger.debug "valid name #{card.name.inspect} New #{name.inspect}"
|
157
|
+
|
158
|
+
unless cdname.valid?
|
159
|
+
errors.add :name, "may not contain any of the following characters: #{ Card::Name.banned_array * ' ' }"
|
160
|
+
end
|
161
|
+
# this is to protect against using a plus card as a tag
|
162
|
+
if cdname.junction? and simple? and id and Auth.as_bot { Card.count_by_wql :right_id=>id } > 0
|
163
|
+
errors.add :name, "#{name} in use as a tag"
|
164
|
+
end
|
165
|
+
|
166
|
+
# validate uniqueness of name
|
167
|
+
condition_sql = "cards.key = ? and trash=?"
|
168
|
+
condition_params = [ cdname.key, false ]
|
169
|
+
unless new_record?
|
170
|
+
condition_sql << " AND cards.id <> ?"
|
171
|
+
condition_params << id
|
172
|
+
end
|
173
|
+
if c = Card.find_by(condition_sql, *condition_params)
|
174
|
+
errors.add :name, "must be unique; '#{c.name}' already exists."
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
|
180
|
+
event :set_autoname, :before=>:validate_name, :on=>:create do
|
181
|
+
if name.blank? and autoname_card = rule_card(:autoname)
|
182
|
+
self.name = autoname autoname_card.content
|
183
|
+
Auth.as_bot { autoname_card.refresh.update_attributes! :content=>name } #fixme, should give placeholder on new, do next and save on create
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
event :validate_key, :after=>:validate_name, :on=>:save do
|
189
|
+
if key.empty?
|
190
|
+
errors.add :key, "cannot be blank" if errors.empty?
|
191
|
+
elsif key != cardname.key
|
192
|
+
errors.add :key, "wrong key '#{key}' for name #{name}"
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
event :set_name, :before=>:store, :changed=>:name do
|
197
|
+
Card.expire name
|
198
|
+
Card.expire name_was
|
199
|
+
if cardname.junction?
|
200
|
+
[:left, :right].each do |side|
|
201
|
+
sidename = cardname.send "#{side}_name"
|
202
|
+
#warn "sidename #{name} / #{name_was} / #{cardname}, #{side}: #{sidename}"
|
203
|
+
sidecard = Card[sidename]
|
204
|
+
old_name_in_way = (sidecard && sidecard.id==self.id) # eg, renaming A to A+B
|
205
|
+
suspend_name(sidename) if old_name_in_way
|
206
|
+
send "#{side}_id=", begin
|
207
|
+
if !sidecard || old_name_in_way
|
208
|
+
Card.create! :name=>sidename, :supercard => self
|
209
|
+
else
|
210
|
+
sidecard
|
211
|
+
end.id
|
212
|
+
end
|
213
|
+
end
|
214
|
+
else
|
215
|
+
self.left_id = self.right_id = nil
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
|
220
|
+
event :rename, :after=>:set_name, :on=>:update do
|
221
|
+
if existing_card = Card.find_by_key_and_trash(cardname.key, true) and existing_card != self
|
222
|
+
existing_card.name = existing_card.name+'*trash'
|
223
|
+
existing_card.rename_without_callbacks
|
224
|
+
existing_card.save!
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
def suspend_name(name)
|
229
|
+
# move the current card out of the way, in case the new name will require
|
230
|
+
# re-creating a card with the current name, ie. A -> A+B
|
231
|
+
Card.expire name
|
232
|
+
tmp_name = "tmp:" + UUID.new.generate
|
233
|
+
Card.where(:id=>self.id).update_all(:name=>tmp_name, :key=>tmp_name)
|
234
|
+
end
|
235
|
+
|
236
|
+
|
237
|
+
event :cascade_name_changes, :after=>:store, :on=>:update, :changed=>:name do
|
238
|
+
Rails.logger.debug "-------------------#{name_was}- CASCADE #{self.name} -------------------------------------"
|
239
|
+
|
240
|
+
self.update_referencers = false if self.update_referencers == 'false' #handle strings from cgi
|
241
|
+
Card::Reference.update_on_rename self, name, self.update_referencers
|
242
|
+
|
243
|
+
deps = self.dependents
|
244
|
+
#warn "-------------------#{name_was}---- CASCADE #{self.name} -> deps: #{deps.map(&:name)*", "} -----------------------"
|
245
|
+
|
246
|
+
@dependents = nil #reset
|
247
|
+
|
248
|
+
deps.each do |dep|
|
249
|
+
# here we specifically want NOT to invoke recursive cascades on these cards, have to go this low level to avoid callbacks.
|
250
|
+
Card.expire dep.name #old name
|
251
|
+
newname = dep.cardname.replace_part name_was, name
|
252
|
+
Card.where( :id=> dep.id ).update_all :name => newname.to_s, :key => newname.key
|
253
|
+
Card::Reference.update_on_rename dep, newname, update_referencers
|
254
|
+
Card.expire newname
|
255
|
+
end
|
256
|
+
if update_referencers
|
257
|
+
Auth.as_bot do
|
258
|
+
[self.name_referencers(name_was)+(deps.map &:referencers)].flatten.uniq.each do |card|
|
259
|
+
# FIXME using "name_referencers" instead of plain "referencers" for self because there are cases where trunk and tag
|
260
|
+
# have already been saved via association by this point and therefore referencers misses things
|
261
|
+
# eg. X includes Y, and Y is renamed to X+Z. When X+Z is saved, X is first updated as a trunk before X+Z gets to this point.
|
262
|
+
# so at this time X is still including Y, which does not exist. therefore #referencers doesn't find it, but name_referencers(old_name) does.
|
263
|
+
# some even more complicated scenario probably breaks on the dependents, so this probably needs a more thoughtful refactor
|
264
|
+
# aligning the dependent saving with the name cascading
|
265
|
+
|
266
|
+
Rails.logger.debug "------------------ UPDATE REFERER #{card.name} ------------------------"
|
267
|
+
unless card == self or card.structure
|
268
|
+
card = card.refresh
|
269
|
+
card.db_content = card.replace_references name_was, name
|
270
|
+
card.save!
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
|
278
|
+
# ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/name.rb ~~~~~~~~~~~
|
279
|
+
end;end;end;end;
|