rtml 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +396 -0
- data/PostInstall.txt +2 -0
- data/README.rdoc +42 -0
- data/Rakefile +33 -0
- data/app_generators/rtml/USAGE +5 -0
- data/app_generators/rtml/rtml_generator.rb +78 -0
- data/app_generators/rtml/templates/rails_template.rb +36 -0
- data/app_generators/rtml/templates/rtml/MIT-LICENSE +20 -0
- data/app_generators/rtml/templates/rtml/README +109 -0
- data/app_generators/rtml/templates/rtml/Rakefile +38 -0
- data/app_generators/rtml/templates/rtml/app/controllers/beryl_controller.rb +70 -0
- data/app_generators/rtml/templates/rtml/app/controllers/rtml/magcard_demo_controller.rb +9 -0
- data/app_generators/rtml/templates/rtml/app/controllers/rtml/oe/btmlpa_controller.rb +158 -0
- data/app_generators/rtml/templates/rtml/app/controllers/rtml/rtml_app_controller.rb +252 -0
- data/app_generators/rtml/templates/rtml/app/controllers/rtml/tml_app_controller.rb +418 -0
- data/app_generators/rtml/templates/rtml/app/helpers/beryl_helper.rb +72 -0
- data/app_generators/rtml/templates/rtml/app/helpers/beryl_tml_helpers/auth_result.rb +56 -0
- data/app_generators/rtml/templates/rtml/app/helpers/beryl_tml_helpers/common.rb +19 -0
- data/app_generators/rtml/templates/rtml/app/helpers/beryl_tml_helpers/index.rb +82 -0
- data/app_generators/rtml/templates/rtml/app/helpers/rtml/magcard_demo_helper.rb +2 -0
- data/app_generators/rtml/templates/rtml/app/helpers/rtml/magcard_demo_tml_helpers/authorized.rb +10 -0
- data/app_generators/rtml/templates/rtml/app/helpers/rtml/magcard_demo_tml_helpers/common.rb +20 -0
- data/app_generators/rtml/templates/rtml/app/helpers/rtml/magcard_demo_tml_helpers/index.rb +33 -0
- data/app_generators/rtml/templates/rtml/app/helpers/rtml/oe/btmlpa_helper.rb +2 -0
- data/app_generators/rtml/templates/rtml/app/helpers/rtml/oe/btmlpa_tml_helpers/auth_result.rb +23 -0
- data/app_generators/rtml/templates/rtml/app/helpers/rtml/oe/btmlpa_tml_helpers/common.rb +23 -0
- data/app_generators/rtml/templates/rtml/app/helpers/rtml/oe/btmlpa_tml_helpers/dynamic.rb +11 -0
- data/app_generators/rtml/templates/rtml/app/helpers/rtml/oe/btmlpa_tml_helpers/icc.rb +384 -0
- data/app_generators/rtml/templates/rtml/app/helpers/rtml/oe/btmlpa_tml_helpers/index.rb +191 -0
- data/app_generators/rtml/templates/rtml/app/helpers/rtml/oe/btmlpa_tml_helpers/receipt.rb +152 -0
- data/app_generators/rtml/templates/rtml/app/helpers/rtml/rtml_app_helper.rb +74 -0
- data/app_generators/rtml/templates/rtml/app/helpers/rtml/rtml_app_tml_helpers/common.rb +9 -0
- data/app_generators/rtml/templates/rtml/app/helpers/rtml/tml_app_helper.rb +43 -0
- data/app_generators/rtml/templates/rtml/app/models/rtml/card.rb +83 -0
- data/app_generators/rtml/templates/rtml/app/models/rtml/card_avs.rb +14 -0
- data/app_generators/rtml/templates/rtml/app/models/rtml/card_cvv.rb +14 -0
- data/app_generators/rtml/templates/rtml/app/models/rtml/card_parser.rb +21 -0
- data/app_generators/rtml/templates/rtml/app/models/rtml/card_pin.rb +18 -0
- data/app_generators/rtml/templates/rtml/app/models/rtml/emv_card_data.rb +25 -0
- data/app_generators/rtml/templates/rtml/app/models/rtml/mag_card_data.rb +21 -0
- data/app_generators/rtml/templates/rtml/app/models/rtml/reference_code.rb +26 -0
- data/app_generators/rtml/templates/rtml/app/models/rtml/state.rb +12 -0
- data/app_generators/rtml/templates/rtml/app/models/rtml/terminal.rb +8 -0
- data/app_generators/rtml/templates/rtml/app/models/rtml/transaction.rb +68 -0
- data/app_generators/rtml/templates/rtml/app/views/beryl/auth_result/another_rcpt.rtml.erb +15 -0
- data/app_generators/rtml/templates/rtml/app/views/beryl/auth_result/receipt.rtml.erb +108 -0
- data/app_generators/rtml/templates/rtml/app/views/beryl/auth_result/receipt_single_column.rtml.erb +106 -0
- data/app_generators/rtml/templates/rtml/app/views/beryl/index/about.rtml.erb +8 -0
- data/app_generators/rtml/templates/rtml/app/views/beryl/index/admin.rtml.erb +4 -0
- data/app_generators/rtml/templates/rtml/app/views/beryl/index/construction.rtml.erb +10 -0
- data/app_generators/rtml/templates/rtml/app/views/beryl/index/idle.rtml.erb +13 -0
- data/app_generators/rtml/templates/rtml/app/views/beryl/index/main_menu.rtml.erb +12 -0
- data/app_generators/rtml/templates/rtml/app/views/beryl/index/menu_credit.rtml.erb +8 -0
- data/app_generators/rtml/templates/rtml/app/views/beryl/index/menu_debit.rtml.erb +3 -0
- data/app_generators/rtml/templates/rtml/app/views/layouts/rtml/beryl_color.rtml.erb +24 -0
- data/app_generators/rtml/templates/rtml/app/views/layouts/rtml/beryl_mono.rtml.erb +8 -0
- data/app_generators/rtml/templates/rtml/app/views/layouts/rtml/magcard_demo_color.rtml.erb +24 -0
- data/app_generators/rtml/templates/rtml/app/views/layouts/rtml/magcard_demo_mono.rtml.erb +3 -0
- data/app_generators/rtml/templates/rtml/app/views/layouts/rtml/oe/btmlpa_i5100.rtml.erb +3 -0
- data/app_generators/rtml/templates/rtml/app/views/layouts/rtml/oe/btmlpa_i8550.rtml.erb +17 -0
- data/app_generators/rtml/templates/rtml/app/views/layouts/rtml/uml.html.erb +11 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/magcard_demo/authorized.html.erb +15 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/magcard_demo/authorized/main.rtml.erb +5 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/magcard_demo/index.html.erb +15 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/magcard_demo/index/_error.rtml.erb +2 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/magcard_demo/index/enter_amount.rtml.erb +5 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/magcard_demo/index/main.rtml.erb +4 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/dynamic/response.rtml.erb +2 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/icc.rtml.erb +760 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/_enter_amount.rtml.erb +4 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/_menu_about.rtml.erb +8 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/_menu_duplicate.rtml.erb +9 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/_menu_examples.rtml.erb +9 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/_menu_logo.rtml.erb +11 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/_menu_other.rtml.erb +20 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/_menu_refund.rtml.erb +8 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/_menu_reversal.rtml.erb +9 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/_menu_sale.rtml.erb +8 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/_menu_sale_cashback.rtml.erb +8 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/about.rtml.erb +1 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/assert.rtml.erb +2 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/card_nmb.rtml.erb +19 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/compl_txn.rtml.erb +1 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/confirm_rev.rtml.erb +3 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/duplicate_na.rtml.erb +1 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/error_scr.rtml.erb +4 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/main_menu.rtml.bak +31 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/main_menu.rtml.erb +40 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/print_pf.rtml.erb +1 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/rd_sale_disp.rtml.erb +1 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/read_refund.rtml.erb +1 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/read_scb.rtml.erb +10 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/reject_trans.rtml.erb +1 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/remove_card.rtml.erb +1 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/rev_bad.rtml.erb +1 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/scb_check_f.rtml.erb +2 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/sign_check.rtml.erb +3 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/subm_err.rtml.erb +2 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/to_man_entry.rtml.erb +2 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/trans_abrt.rtml.erb +1 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/void_trans.rtml.erb +1 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/receipt/_receipt.rtml.erb +29 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/receipt/error_paper.rtml.erb +3 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/rtml_app/_default_development.html.erb +167 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/rtml_app/_default_header.html.erb +12 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/rtml_app/_default_production.html.erb +8 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/rtml_app/charts.html.erb +14 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/tml_app/do_tml_redirect.rtml.erb +7 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/tml_app/get_terminal_info.rtml.erb +26 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/tml_app/rescue_action_in_public.rtml.erb +9 -0
- data/app_generators/rtml/templates/rtml/app/views/rtml/tml_app/rescue_action_locally.rtml.erb +42 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/common.rb +303 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/force.rb +46 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/return.rb +22 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/sale.rb +49 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/_confirmation.rtml.erb +10 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/_receipt_agreement.rtml.erb +3 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/_receipt_footer.rtml.erb +2 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/_receipt_header.rtml.erb +4 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/ask_cashback.rtml.erb +11 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/card_imprint.rtml.erb +7 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/check_cb.rtml.erb +11 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/conf_debit.rtml.erb +5 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/confirm_sale.rtml.erb +4 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/confrm_force.rtml.erb +4 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/cvv_skipped.rtml.erb +10 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/disp_avs.rtml.erb +8 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/do_avs_zip.rtml.erb +8 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/enter_amount.rtml.erb +12 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/enter_card.rtml.erb +8 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/enter_cashbk.rtml.erb +10 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/enter_cvv2.rtml.erb +8 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/enter_expiry.rtml.erb +9 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/fraud_check1.rtml.erb +6 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/fraud_check2.rtml.erb +8 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/frc_aprvl.rtml.erb +8 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/frc_avs_zip.rtml.erb +8 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/frc_bad_aprv.rtml.erb +5 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/frd_chk_fail.rtml.erb +5 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/invalid_exp.rtml.erb +1 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/no_entr_crd.rtml.erb +1 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/remove_card.rtml.erb +1 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/swipe_card.rtml.erb +7 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/trans_abort.rtml.erb +1 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/trans_reject.rtml.erb +1 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/views/void_ref.rtml.erb +10 -0
- data/app_generators/rtml/templates/rtml/components/rtml/features/void.rb +30 -0
- data/app_generators/rtml/templates/rtml/components/rtml/widgets/card_parser_widget.rb +90 -0
- data/app_generators/rtml/templates/rtml/components/rtml/widgets/display_widget.rb +66 -0
- data/app_generators/rtml/templates/rtml/components/rtml/widgets/element_builder_widget.rb +123 -0
- data/app_generators/rtml/templates/rtml/components/rtml/widgets/emv_support_widget.rb +365 -0
- data/app_generators/rtml/templates/rtml/components/rtml/widgets/form_submit_widget.rb +65 -0
- data/app_generators/rtml/templates/rtml/components/rtml/widgets/get_transaction_variables_widget.rb +33 -0
- data/app_generators/rtml/templates/rtml/components/rtml/widgets/get_variable_widget.rb +39 -0
- data/app_generators/rtml/templates/rtml/components/rtml/widgets/receipt_widget.rb +66 -0
- data/app_generators/rtml/templates/rtml/components/rtml/widgets/screen_builder_widget.rb +49 -0
- data/app_generators/rtml/templates/rtml/db/migrate/20090825132217_create_rtml_states.rb +15 -0
- data/app_generators/rtml/templates/rtml/db/migrate/20090825132401_create_rtml_terminals.rb +16 -0
- data/app_generators/rtml/templates/rtml/db/migrate/20090825132530_create_rtml_transactions.rb +24 -0
- data/app_generators/rtml/templates/rtml/db/migrate/20090825134118_create_rtml_cards.rb +23 -0
- data/app_generators/rtml/templates/rtml/db/migrate/20090825134622_create_rtml_emv_card_data.rb +20 -0
- data/app_generators/rtml/templates/rtml/db/migrate/20090825134629_create_rtml_mag_card_data.rb +17 -0
- data/app_generators/rtml/templates/rtml/db/migrate/20090825135838_create_rtml_card_parsers.rb +19 -0
- data/app_generators/rtml/templates/rtml/db/migrate/20090826103509_create_reference_codes.rb +14 -0
- data/app_generators/rtml/templates/rtml/db/migrate/20090915030044_add_batch_to_rtml_transactions.rb +10 -0
- data/app_generators/rtml/templates/rtml/db/migrate/20090915031155_add_additional_data_to_rtml_transactions.rb +10 -0
- data/app_generators/rtml/templates/rtml/db/migrate/20090915031156_add_hidden_data_to_rtml_transactions.rb +10 -0
- data/app_generators/rtml/templates/rtml/db/migrate/20091016133313_create_rtml_card_avs.rb +16 -0
- data/app_generators/rtml/templates/rtml/db/migrate/20091016135800_create_rtml_card_cvvs.rb +16 -0
- data/app_generators/rtml/templates/rtml/db/migrate/20091016135810_create_rtml_card_pins.rb +16 -0
- data/app_generators/rtml/templates/rtml/db/migrate/20091016135820_reverse_card_transaction_relationship.rb +11 -0
- data/app_generators/rtml/templates/rtml/db/migrate/20100127115105_convert_rtml_migrations_to_rails_migrations.rb +31 -0
- data/app_generators/rtml/templates/rtml/generators/rtml_controller/USAGE +25 -0
- data/app_generators/rtml/templates/rtml/generators/rtml_controller/rtml_controller_generator.rb +49 -0
- data/app_generators/rtml/templates/rtml/generators/rtml_controller/templates/common_tml_helper.rb +20 -0
- data/app_generators/rtml/templates/rtml/generators/rtml_controller/templates/controller.rb +3 -0
- data/app_generators/rtml/templates/rtml/generators/rtml_controller/templates/css_color.css +37 -0
- data/app_generators/rtml/templates/rtml/generators/rtml_controller/templates/css_mono.css +12 -0
- data/app_generators/rtml/templates/rtml/generators/rtml_controller/templates/functional_test.rb +11 -0
- data/app_generators/rtml/templates/rtml/generators/rtml_controller/templates/helper.rb +2 -0
- data/app_generators/rtml/templates/rtml/generators/rtml_controller/templates/layout_color.rtml.erb +24 -0
- data/app_generators/rtml/templates/rtml/generators/rtml_controller/templates/layout_mono.rtml.erb +3 -0
- data/app_generators/rtml/templates/rtml/generators/rtml_controller/templates/tml_helper.rb +16 -0
- data/app_generators/rtml/templates/rtml/generators/rtml_controller/templates/view.html.erb +15 -0
- data/app_generators/rtml/templates/rtml/generators/rtml_controller/templates/view.rtml.erb +2 -0
- data/app_generators/rtml/templates/rtml/generators/rtml_document/USAGE +8 -0
- data/app_generators/rtml/templates/rtml/generators/rtml_document/rtml_document_generator.rb +45 -0
- data/app_generators/rtml/templates/rtml/generators/rtml_document/templates/controller.rb +7 -0
- data/app_generators/rtml/templates/rtml/generators/rtml_document/templates/functional_test.rb +10 -0
- data/app_generators/rtml/templates/rtml/generators/rtml_document/templates/helper.rb +2 -0
- data/app_generators/rtml/templates/rtml/generators/rtml_document/templates/view.rtml.erb +11 -0
- data/app_generators/rtml/templates/rtml/generators/rtml_widget/USAGE +8 -0
- data/app_generators/rtml/templates/rtml/generators/rtml_widget/rtml_widget_generator.rb +66 -0
- data/app_generators/rtml/templates/rtml/generators/rtml_widget/templates/basic_widget.rb +57 -0
- data/app_generators/rtml/templates/rtml/generators/rtml_widget/templates/basic_widget_no_help.rb +27 -0
- data/app_generators/rtml/templates/rtml/init.rb +40 -0
- data/app_generators/rtml/templates/rtml/install.rb +18 -0
- data/app_generators/rtml/templates/rtml/lib/environment.rb +61 -0
- data/app_generators/rtml/templates/rtml/lib/extensions/action_controller/request.rb +9 -0
- data/app_generators/rtml/templates/rtml/lib/extensions/action_controller/routing/route_set.rb +34 -0
- data/app_generators/rtml/templates/rtml/lib/extensions/action_view/base.rb +74 -0
- data/app_generators/rtml/templates/rtml/lib/extensions/action_view/partial_template.rb +24 -0
- data/app_generators/rtml/templates/rtml/lib/extensions/active_record.rb +13 -0
- data/app_generators/rtml/templates/rtml/lib/extensions/active_support/dependencies.rb +25 -0
- data/app_generators/rtml/templates/rtml/lib/extensions/array.rb +15 -0
- data/app_generators/rtml/templates/rtml/lib/extensions/attr_boolean.rb +10 -0
- data/app_generators/rtml/templates/rtml/lib/extensions/hash.rb +28 -0
- data/app_generators/rtml/templates/rtml/lib/extensions/nil_class.rb +20 -0
- data/app_generators/rtml/templates/rtml/lib/extensions/rake.rb +19 -0
- data/app_generators/rtml/templates/rtml/lib/extensions/regexp.rb +16 -0
- data/app_generators/rtml/templates/rtml/lib/extensions/string.rb +37 -0
- data/app_generators/rtml/templates/rtml/lib/other_plugins.rb +23 -0
- data/app_generators/rtml/templates/rtml/lib/other_plugins/before_render/MIT-LICENSE +20 -0
- data/app_generators/rtml/templates/rtml/lib/other_plugins/before_render/README +36 -0
- data/app_generators/rtml/templates/rtml/lib/other_plugins/before_render/Rakefile +44 -0
- data/app_generators/rtml/templates/rtml/lib/other_plugins/before_render/init.rb +25 -0
- data/app_generators/rtml/templates/rtml/lib/other_plugins/before_render/lib/action_controller/filters/before_render_filter.rb +30 -0
- data/app_generators/rtml/templates/rtml/lib/other_plugins/before_render/lib/before_render.rb +43 -0
- data/app_generators/rtml/templates/rtml/lib/other_plugins/before_render/lib/before_render_instance.rb +45 -0
- data/app_generators/rtml/templates/rtml/lib/other_plugins/before_render/lib/filter_chain_has_many_types_of_filters.rb +87 -0
- data/app_generators/rtml/templates/rtml/lib/other_plugins/before_render/lib/filter_has_before_render.rb +26 -0
- data/app_generators/rtml/templates/rtml/lib/other_plugins/before_render/tasks/before_render_tasks.rake +25 -0
- data/app_generators/rtml/templates/rtml/lib/other_plugins/before_render/test/before_render_test.rb +29 -0
- data/app_generators/rtml/templates/rtml/lib/other_plugins/before_render/test/test_helper.rb +24 -0
- data/app_generators/rtml/templates/rtml/lib/rtml.rb +77 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/beryl/constants.rb +12 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/beryl/version.rb +11 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/common/renderable.rb +13 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/core/include.rb +30 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/core/layout.rb +59 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/core/next.rb +188 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/core/screen.rb +91 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/core/screen/iterators.rb +63 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/core/screen/next_screen_methods.rb +70 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/core/screen/variable_methods.rb +73 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/core/support/importer.rb +55 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/core/tml_document.rb +318 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/core/tml_document/screen_methods.rb +79 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/core/tml_document/variable_methods.rb +83 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/core/variable.rb +123 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/debug/browser_emulator.rb +59 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/debug/rtml_controller_test_case.rb +7 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/debug/rtml_core_unit_test.rb +11 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/debug/unit_test.rb +3 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/delegation.rb +8 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/doc.rb +12 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/element.rb +75 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/errors/widget_accessor_failure.rb +9 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/events/event_handler.rb +79 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/events/event_processor.rb +106 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/events/processors.rb +10 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/events/processors/defaults_processor.rb +18 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/events/processors/key_processor.rb +21 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/feature.rb +32 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/feature_config.rb +195 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/features.rb +18 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/features/array_of_feature_instances.rb +17 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/features/controller_class_methods.rb +30 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/features/controller_instance_methods.rb +35 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/helpers.rb +21 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/helpers/controller_helpers.rb +59 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/helpers/controller_helpers/menu_helpers.rb +193 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/helpers/core_helpers/action_view_wrapper.rb +23 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/helpers/core_helpers/event_helpers.rb +28 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/helpers/core_helpers/layout_helpers.rb +47 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/helpers/core_helpers/widget_support.rb +181 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/helpers/core_helpers/widget_support/class_methods.rb +28 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/helpers/core_helpers/yield_helpers.rb +33 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/helpers/proxy_helpers/feature_helpers.rb +17 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/helpers/render_helper.rb +71 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/helpers/terminal_helpers.rb +21 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/helpers/test_helpers.rb +6 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/helpers/test_helpers/tml_validation_assertions.rb +10 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/helpers/test_helpers/variable_assertions.rb +27 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/helpers/view_helpers/form_helpers.rb +70 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/helpers/view_helpers/rtml_form_builder.rb +174 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/oe/btmlpa_constants.rb +48 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/proxying/method_missing_methods.rb +14 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/proxying/rtml_interface.rb +33 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/proxying/sandbox.rb +18 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/text_utils.rb +51 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/tml_param_parser.rb +95 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/validation/dom_rule_parser.rb +61 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/validation/dom_tag.rb +52 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/validation/predefined_variable_rule_parser.rb +97 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/validation/tml_validator.rb +16 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/version.rb +11 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/widgets/property.rb +11 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/widgets/property_accessors.rb +59 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/widgets/widget.rb +251 -0
- data/app_generators/rtml/templates/rtml/lib/rtml/widgets/widget_class_methods.rb +213 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/dot.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_can.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_cand.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_en.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_end.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_i.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_icd.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_icl.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_icr.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_ics.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_icsw.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_icv.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_int.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_int2.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_men.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_mend.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_next.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_no.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_nod.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_ok.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_okd.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_pic1.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_pic2.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_pic3.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_pic4.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_top.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_txn.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_yes.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_yesd.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/btmlpa.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/can_dn.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/can_up.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/conf.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/iccemv.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/images.lib +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/magcard.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/no_dn.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/no_up.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/ok_dn.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/ok_up.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/top.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/yes_dn.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/yes_up.gif +0 -0
- data/app_generators/rtml/templates/rtml/public/stylesheets/rtml/beryl_color.css +37 -0
- data/app_generators/rtml/templates/rtml/public/stylesheets/rtml/beryl_mono.css +17 -0
- data/app_generators/rtml/templates/rtml/public/stylesheets/rtml/charts.css +0 -0
- data/app_generators/rtml/templates/rtml/public/stylesheets/rtml/oe/btmlpa/i5100.css +12 -0
- data/app_generators/rtml/templates/rtml/public/stylesheets/rtml/oe/btmlpa/i8550.css +37 -0
- data/app_generators/rtml/templates/rtml/public/stylesheets/rtml/oe/btmlpa/receipt.css +4 -0
- data/app_generators/rtml/templates/rtml/public/stylesheets/rtml/oe/examples/i5100.css +12 -0
- data/app_generators/rtml/templates/rtml/public/stylesheets/rtml/oe/examples/i8550.css +37 -0
- data/app_generators/rtml/templates/rtml/reporting/110409 +227 -0
- data/app_generators/rtml/templates/rtml/reporting/linecount.rb +42 -0
- data/app_generators/rtml/templates/rtml/rules/predefined_tml_variables.rb +63 -0
- data/app_generators/rtml/templates/rtml/rules/tml_document_structure.rb +84 -0
- data/app_generators/rtml/templates/rtml/rules/varns/audio.rb +30 -0
- data/app_generators/rtml/templates/rtml/rules/varns/card.rb +17 -0
- data/app_generators/rtml/templates/rtml/rules/varns/card/emv.rb +31 -0
- data/app_generators/rtml/templates/rtml/rules/varns/card/mag.rb +8 -0
- data/app_generators/rtml/templates/rtml/rules/varns/card/parser.rb +7 -0
- data/app_generators/rtml/templates/rtml/rules/varns/card/pin.rb +6 -0
- data/app_generators/rtml/templates/rtml/rules/varns/cfgm.rb +15 -0
- data/app_generators/rtml/templates/rtml/rules/varns/com.rb +9 -0
- data/app_generators/rtml/templates/rtml/rules/varns/err.rb +14 -0
- data/app_generators/rtml/templates/rtml/rules/varns/gma/event.rb +13 -0
- data/app_generators/rtml/templates/rtml/rules/varns/gprs.rb +8 -0
- data/app_generators/rtml/templates/rtml/rules/varns/imager.rb +8 -0
- data/app_generators/rtml/templates/rtml/rules/varns/ip.rb +15 -0
- data/app_generators/rtml/templates/rtml/rules/varns/oebr.rb +42 -0
- data/app_generators/rtml/templates/rtml/rules/varns/oebr/3rdparty.rb +7 -0
- data/app_generators/rtml/templates/rtml/rules/varns/oebr/backlight.rb +4 -0
- data/app_generators/rtml/templates/rtml/rules/varns/oebr/cache.rb +1 -0
- data/app_generators/rtml/templates/rtml/rules/varns/oebr/connect.rb +5 -0
- data/app_generators/rtml/templates/rtml/rules/varns/oebr/connection.rb +5 -0
- data/app_generators/rtml/templates/rtml/rules/varns/oebr/offline.rb +5 -0
- data/app_generators/rtml/templates/rtml/rules/varns/oegw.rb +12 -0
- data/app_generators/rtml/templates/rtml/rules/varns/payment.rb +21 -0
- data/app_generators/rtml/templates/rtml/rules/varns/ppp.rb +11 -0
- data/app_generators/rtml/templates/rtml/rules/varns/terminal.rb +29 -0
- data/app_generators/rtml/templates/rtml/tasks/rtml_tasks.rake +78 -0
- data/app_generators/rtml/templates/rtml/template.rb +64 -0
- data/app_generators/rtml/templates/rtml/test/core/element_test.rb +17 -0
- data/app_generators/rtml/templates/rtml/test/core/screen_test.rb +91 -0
- data/app_generators/rtml/templates/rtml/test/core/tml_document_test.rb +53 -0
- data/app_generators/rtml/templates/rtml/test/functional/beryl_controller_test.rb +13 -0
- data/app_generators/rtml/templates/rtml/test/functional/btmlpa_controller_test.rb +13 -0
- data/app_generators/rtml/templates/rtml/test/functional/magcard_demo_controller_test.rb +20 -0
- data/app_generators/rtml/templates/rtml/test/functional/rtml_app_controller_test.rb +9 -0
- data/app_generators/rtml/templates/rtml/test/functional/rtml_routing_test.rb +19 -0
- data/app_generators/rtml/templates/rtml/test/functional/tml_controller_params_test.rb +20 -0
- data/app_generators/rtml/templates/rtml/test/rtml_test_helper.rb +44 -0
- data/app_generators/rtml/templates/rtml/test/validation/predefined_variable_rule_parser_test.rb +11 -0
- data/app_generators/rtml/templates/rtml/uninstall.rb +1 -0
- data/app_generators/rtml/templates/rtml/update.rb +57 -0
- data/bin/rtml +36 -0
- data/lib/rtml.rb +4 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/tasks/reglob.rake +28 -0
- data/test/test_generator_helper.rb +29 -0
- data/test/test_helper.rb +3 -0
- data/test/test_rtml.rb +11 -0
- data/test/test_rtml_generator.rb +43 -0
- metadata +516 -0
@@ -0,0 +1,252 @@
|
|
1
|
+
class Rtml::RtmlAppController < Rtml::TmlAppController
|
2
|
+
include Rtml::Helpers::ControllerHelpers::MenuHelpers
|
3
|
+
|
4
|
+
prepend_before_filter :force_rtml, :only => :uml
|
5
|
+
before_render :render_tml
|
6
|
+
around_filter :process_action_with_view_paths
|
7
|
+
hide_action :rtml_interface, :tml_document, :rtml_document, :tml_document=, :rtml_document=
|
8
|
+
|
9
|
+
# For creating UML diagrams of TML screens for the given action. Must be in this same controller.
|
10
|
+
def uml
|
11
|
+
helper = response.template
|
12
|
+
|
13
|
+
include_view_paths_for params[:id]
|
14
|
+
self.rtml_interface.fire_action(params[:id], self)
|
15
|
+
@screens = tml_document.screens
|
16
|
+
url = []
|
17
|
+
@screens.each do |scr|
|
18
|
+
map = {}
|
19
|
+
left = nil
|
20
|
+
scr.every_possible_variant do |cond, dest|
|
21
|
+
left = helper.uml_for_screen(scr)
|
22
|
+
right = helper.uml_for_screen(@screens.find(dest) || helper.format_for_uml(dest))
|
23
|
+
if cond == :default and not map[right] then cond = ""
|
24
|
+
else
|
25
|
+
cond = unless cond =~ /key=/ then cond.to_s.gsub(/(^|\s)..=['"]([^'"]*)['"]/, '\1\2')
|
26
|
+
else cond.to_s.gsub(/['"]/, '').gsub(/key=/, 'on key ')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
if map[right] then map[right] << " | #{cond}"
|
30
|
+
else map[right] = cond
|
31
|
+
end
|
32
|
+
end
|
33
|
+
# we use the map to merge multiple conditions in order to point to a destination only once
|
34
|
+
map.each { |right, cond| url << "[#{left}]-#{cond}>[#{right}]" }
|
35
|
+
end
|
36
|
+
tml_document.reset!
|
37
|
+
|
38
|
+
data = helper.get_uml_image_data(url)
|
39
|
+
send_data data, :disposition => 'inline', :type => 'image/png', :file_name => "#{params[:id]}.png"
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.inherited(base) #:nodoc:
|
43
|
+
super
|
44
|
+
# TODO: It may be important to leave base.controller_path in the view paths in order to
|
45
|
+
# handle overriding the tml_app views. Need to figure out if this is necessary or not.
|
46
|
+
# base.append_view_path(File.join("vendor", "plugins", "rtml", "app/views", base.controller_path))
|
47
|
+
base.send :include, "#{base.controller_path}_tml_helpers".camelize.constantize rescue nil
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.rtml_interface #:nodoc:
|
51
|
+
if self.superclass.respond_to? :rtml_interface
|
52
|
+
@rtml_interface ||= Class.new(self.superclass.rtml_interface.class).new
|
53
|
+
else
|
54
|
+
@rtml_interface ||= Class.new(Rtml::Proxying::RtmlInterface).new
|
55
|
+
end
|
56
|
+
@rtml_interface
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.add_rtml_actions(*actions) #:nodoc:
|
60
|
+
actions.flatten.each do |action|
|
61
|
+
raise ArgumentError.new("Action must be Symbol or String") unless action.kind_of? Symbol or action.kind_of? String
|
62
|
+
line = __LINE__ + 1
|
63
|
+
eval %Q`
|
64
|
+
def #{action}
|
65
|
+
set_rtml unless template_exists?(default_template_name)
|
66
|
+
if request.format == :rtml
|
67
|
+
self.rtml_interface.fire_action(#{action.inspect}, self)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
`, binding, __FILE__, line
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def rtml_interface #:nodoc:
|
75
|
+
self.class.rtml_interface
|
76
|
+
end
|
77
|
+
|
78
|
+
# Returns the TML document that is being constructed for this request.
|
79
|
+
def tml_document
|
80
|
+
@tml_document ||= Rtml::Core::TMLDocument.new(response.template)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Overwrites the TML document, if any, with the specified target.
|
84
|
+
# The specified target document becomes the "active" target, and will
|
85
|
+
# be rendered in place of this one.
|
86
|
+
def tml_document=(target)
|
87
|
+
@tml_document = target
|
88
|
+
end
|
89
|
+
|
90
|
+
alias rtml_document= tml_document=
|
91
|
+
alias rtml_document tml_document
|
92
|
+
|
93
|
+
protected
|
94
|
+
include Rtml
|
95
|
+
include Rtml::Core
|
96
|
+
extend Rtml::TmlAppHelper
|
97
|
+
extend Rtml::Helpers::ControllerHelpers
|
98
|
+
|
99
|
+
# Adds the specified action's view paths to this action's view paths,
|
100
|
+
# which would allow you to render views and partials from the specified
|
101
|
+
# action. Note that if two actions specify the same view, the view path
|
102
|
+
# that is encountered first takes precedence. (This should be the current
|
103
|
+
# action, which is ideal, BUT it's Rails core functionality that I'm not
|
104
|
+
# going to vouch for. Basically, keep the names unique or use at your own
|
105
|
+
# risk.)
|
106
|
+
def include_view_paths_for(action)
|
107
|
+
add_instance_view_paths(action)
|
108
|
+
end
|
109
|
+
|
110
|
+
# Used for modifying the template files to be found in
|
111
|
+
# controller/action/screen_name.erb (instead of the Rails default
|
112
|
+
# controller/action.erb).
|
113
|
+
def default_template_name(action_name = self.action_name,
|
114
|
+
ext = response.template.template_format,
|
115
|
+
klass = self.class) #:nodoc:
|
116
|
+
s = super
|
117
|
+
return s if s
|
118
|
+
if action_name =~ /\//
|
119
|
+
return s
|
120
|
+
else
|
121
|
+
return super("#{params[:action]}/#{action_name}", ext, klass)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# We need the default rescue_action functionality, but we first
|
126
|
+
# need to reset the TML document that's being generated, or else
|
127
|
+
# we'll end up with a TML document that half represents what the
|
128
|
+
# user was constructing, half represents the error being reported,
|
129
|
+
# and is completely invalid TML!
|
130
|
+
def rescue_action(*a)
|
131
|
+
tml_document.reset!
|
132
|
+
super
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
private
|
137
|
+
# Adds default action-specific view paths to this controller, then
|
138
|
+
# calls the action, and finally removes the view paths.
|
139
|
+
def process_action_with_view_paths
|
140
|
+
include_view_paths_for params[:action]
|
141
|
+
yield
|
142
|
+
remove_instance_view_paths
|
143
|
+
end
|
144
|
+
|
145
|
+
# Adds all registered view paths for the specified action to the
|
146
|
+
# controller for this action. This is called by the around_filter
|
147
|
+
# before the action is called.
|
148
|
+
def add_instance_view_paths(action)
|
149
|
+
controller = self
|
150
|
+
@paths_to_delete = []
|
151
|
+
(controller.class.view_paths_for_actions.select do |a|
|
152
|
+
a[0].to_s.length == 0 || a[0].to_s == action.to_s
|
153
|
+
end).each do |a|
|
154
|
+
path = a[1]
|
155
|
+
add_instance_view_path path
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
# Adds the specified view path to the controller's view paths
|
160
|
+
# and also adds it to the list of paths to be deleted at the end
|
161
|
+
# of this action (so that they are not permanent in production).
|
162
|
+
def add_instance_view_path(path)
|
163
|
+
unless controller.class.view_paths.include? path
|
164
|
+
@paths_to_delete << path
|
165
|
+
controller.prepend_view_path path
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
# Removes all view paths that were not a part of the action-unspecific
|
170
|
+
# (global) array for this controller. This is called by the around_filter
|
171
|
+
# after content has been rendered.
|
172
|
+
def remove_instance_view_paths
|
173
|
+
controller = self
|
174
|
+
@paths_to_delete.each do |path|
|
175
|
+
controller.view_paths.delete path
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def render_tml
|
180
|
+
headers_filter
|
181
|
+
return unless tml_document.modified? and not performed? and response.redirected_to.nil?
|
182
|
+
|
183
|
+
# The reason I don't check against request.format here is because I want to handle things like respond_to,
|
184
|
+
# which might look something like
|
185
|
+
# respond_to do |format|
|
186
|
+
# format.rtml
|
187
|
+
# format.html
|
188
|
+
# format.json { render :json => obj.to_json }
|
189
|
+
# format.xml { render :xml => obj.to_xml }
|
190
|
+
# end
|
191
|
+
#
|
192
|
+
# respond_to does not set request.format; it sets response.template.template_format. So that's what I need
|
193
|
+
# to check. Note that pretty much everywhere else, request.format should be checked, because pretty much
|
194
|
+
# everywhere else we want to know what the client is ASKING for.
|
195
|
+
#
|
196
|
+
if response.template.template_format == :rtml
|
197
|
+
tml = tml_document.to_tml
|
198
|
+
### HACK!
|
199
|
+
# Having problems with the browser restarting the app when the visiting the full link with an anchor.
|
200
|
+
# Strange, it only happens once. But this should work around it.
|
201
|
+
tml.gsub!(/(["'])#{Regexp::escape url_for(:action => params[:action], :only_path => true)}\#/, '\1#')
|
202
|
+
logger.debug tml if self.class.rtml_debug_config[:dump_tml]
|
203
|
+
render_without_before_render_filter :text => tml
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
# Another method for forcing the user into an RTML format. See Rtml::TmlAppController#force_format
|
208
|
+
# and use with care. What this does, essentially, is check to see whether there are any RTML
|
209
|
+
# templates available, and if so, forces the user into RTML format. Only used in very rare
|
210
|
+
# circumstances, obviously, because this will ignore things like what browser is actually
|
211
|
+
# requesting the document. If you call this method, and the user is using Firefox or IE,
|
212
|
+
# tough luck: an RTML template exists, you've told RTML to use it unconditionally.
|
213
|
+
# No effect if no RTML ERB template exists. So for instance, if you are building a TML document
|
214
|
+
# via the tml_helpers, none of the above will happen.
|
215
|
+
def set_rtml
|
216
|
+
if self.class.action_methods.include? params[:action]
|
217
|
+
unless template_exists? default_template_name(params[:action]) and not tml_document.screen_defined? params[:action]
|
218
|
+
force_format :rtml
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
def force_rtml #:nodoc:
|
224
|
+
force_format :rtml
|
225
|
+
end
|
226
|
+
|
227
|
+
# Declare the specified action to require the specified path. This is used
|
228
|
+
# in the around_filter when constructing the default view paths for an action.
|
229
|
+
#
|
230
|
+
# If action is nil, this path will be added to all actions. (This may be useful
|
231
|
+
# if you want to add a view path to all instances of this controller without
|
232
|
+
# affecting the view paths of any other controllers.)
|
233
|
+
def self.append_view_path_for_action(action, path)
|
234
|
+
view_paths_for_actions << [ action.to_s, path ]
|
235
|
+
end
|
236
|
+
|
237
|
+
# Return the array of default paths. First argument is action name; second
|
238
|
+
# argument is the path itself.
|
239
|
+
def self.view_paths_for_actions
|
240
|
+
if @view_paths_for_actions.nil?
|
241
|
+
if self.superclass.respond_to? :view_paths_for_actions
|
242
|
+
@view_paths_for_actions = self.superclass.view_paths_for_actions.collect { |arr| arr.dup }
|
243
|
+
else
|
244
|
+
@view_paths_for_actions = []
|
245
|
+
end
|
246
|
+
end
|
247
|
+
@view_paths_for_actions
|
248
|
+
end
|
249
|
+
|
250
|
+
public
|
251
|
+
tml_helper :all
|
252
|
+
end
|
@@ -0,0 +1,418 @@
|
|
1
|
+
module Rtml
|
2
|
+
class TmlAppController < ApplicationController
|
3
|
+
include Rtml::Helpers::RenderHelper
|
4
|
+
include Rtml::Helpers::TerminalHelpers
|
5
|
+
|
6
|
+
#It's sad, but we have to skip the authenticity token, because OEGW doesn't support cookies
|
7
|
+
# and therefore has no clue what a Session object is. The Session is used to make sure
|
8
|
+
# authenticity tokens are valid and to generate new ones -- so what happens is, since
|
9
|
+
# the terminal doesn't maintain a session cookie, every request is considered a new "session"
|
10
|
+
# and the previous "session" token is invalidated. So POST data can't be processed because
|
11
|
+
# Rails thinks it's all fake! Until OpenEstate supports session cookies, it has to be disabled.
|
12
|
+
# FIXME: When session cookies are supported, re-enable authenticity verification. Or override
|
13
|
+
# Rails authenticity checking with something a little more TML-friendly...
|
14
|
+
skip_before_filter :verify_authenticity_token
|
15
|
+
|
16
|
+
before_filter :format_filter
|
17
|
+
#before_filter :headers_filter
|
18
|
+
before_filter :load_state
|
19
|
+
|
20
|
+
hide_action :embedded_app, :url_for
|
21
|
+
|
22
|
+
# 080609:
|
23
|
+
# save_state changed to a before_render filter because the user is more likely to change it
|
24
|
+
# in the TML helper than they are in the View, and after much research I had to take sides
|
25
|
+
# (RTML documents do a lot of render_or_redirect-ing, which halts the filter chain).
|
26
|
+
before_render :save_state
|
27
|
+
#after_filter :save_state
|
28
|
+
|
29
|
+
append_view_path File.join(PLUGIN_BASE, "app", "views", "rtml", "tml_app")
|
30
|
+
|
31
|
+
# Action reserved for retrieving TML state data. See
|
32
|
+
# app/views/rtml/tml_app/get_terminal_info.rtml.erb for customization.
|
33
|
+
# You can also override this view within your controller's views, if needed.
|
34
|
+
#
|
35
|
+
# Note that this file should be either a straight TML template (using ERB of course)
|
36
|
+
# or "document-level" RTML (essentially breaking the MVC rules and running the TML
|
37
|
+
# generation in the View). If you don't know what any of that means, then don't touch it.
|
38
|
+
def get_terminal_info
|
39
|
+
end
|
40
|
+
|
41
|
+
# Action reserved for redirect_to directives. This functionality will be removed
|
42
|
+
# when Incendo supports HTTP redirects, but until then, the only way to do it
|
43
|
+
# is in the terminal-side TML. See app/views/rtml/tml_app/do_tml_redirect.rtml.erb
|
44
|
+
# for customization.
|
45
|
+
# You can also override this view within your controller's views, if needed.
|
46
|
+
#
|
47
|
+
# Note that this file should be either a straight TML template (using ERB of course)
|
48
|
+
# or "document-level" RTML (essentially breaking the MVC rules and running the TML
|
49
|
+
# generation in the View). If you don't know what any of that means, then don't touch it.
|
50
|
+
def do_tml_redirect
|
51
|
+
end
|
52
|
+
|
53
|
+
def url_for(options = {})
|
54
|
+
super(options.reverse_merge(:format => params[:format]))
|
55
|
+
end
|
56
|
+
|
57
|
+
class << self
|
58
|
+
# Allows you to provide an expiration timeout. This must be done with a block so that it
|
59
|
+
# can be evaluated only when the expiration headers are being sent.
|
60
|
+
#
|
61
|
+
# Example:
|
62
|
+
# expires_at { 7.days.from_now }
|
63
|
+
# expires_at { |controller| controller.current_user.id == 1 ? Time.now : 3.days.from_now }
|
64
|
+
#
|
65
|
+
def expires_at(&block)
|
66
|
+
@expires_at_block = block if block_given?
|
67
|
+
return @expires_at_block
|
68
|
+
end
|
69
|
+
public :expires_at
|
70
|
+
end
|
71
|
+
|
72
|
+
# Allows you to provide an expiration timeout. This must be done with a block so that it
|
73
|
+
# can be evaluated only when the expiration headers are being sent.
|
74
|
+
#
|
75
|
+
# Example:
|
76
|
+
# expires_at { 7.days.from_now }
|
77
|
+
# expires_at { |controller| controller.current_user.id == 1 ? Time.now : 3.days.from_now }
|
78
|
+
#
|
79
|
+
def expires_at(&block)
|
80
|
+
@expires_at_block ||= self.class.expires_at
|
81
|
+
@expires_at_block = block if block_given?
|
82
|
+
return @expires_at_block
|
83
|
+
end
|
84
|
+
|
85
|
+
protected
|
86
|
+
# Overrides the set of defaults for when a Web browser (as opposed to a terminal browser)
|
87
|
+
# connects and requests this RTML resource.
|
88
|
+
#
|
89
|
+
# Example:
|
90
|
+
# class MyAppController < Rtml::RtmlAppController
|
91
|
+
# rtml_debug do |config|
|
92
|
+
# config[:model] = 5100
|
93
|
+
# end
|
94
|
+
# end
|
95
|
+
#
|
96
|
+
def self.rtml_debug(&blk)
|
97
|
+
yield self.rtml_debug_config
|
98
|
+
end
|
99
|
+
|
100
|
+
# Returns the hash of RTML debug options, for use when a Web browser (and not a terminal
|
101
|
+
# browser) requests this RTML resource.
|
102
|
+
def self.rtml_debug_config
|
103
|
+
@rtml_debug_config ||= HashWithIndifferentAccess.new({
|
104
|
+
:datetime_start => Date.parse('2006/01/01'),
|
105
|
+
:os => '03.27',
|
106
|
+
:itid => '111111111',
|
107
|
+
:model => 8550,
|
108
|
+
:datetime => Time.now,
|
109
|
+
:part_number => 'I8550_BROWSER',
|
110
|
+
:dump_tml => false
|
111
|
+
})
|
112
|
+
end
|
113
|
+
|
114
|
+
# Provides a tml_redirect method because Incendo won't understand the "Location"
|
115
|
+
# header that redirect_to produces. (Groupe has agreed to implement this missing
|
116
|
+
# functionality in an upcoming release.) This new redirect_to method will render the
|
117
|
+
# do_tml_redirect action instead, which results in a TML-based redirect.
|
118
|
+
# This is only done for the MicroBrowser. Any other browser gets the standard
|
119
|
+
# Rails functionality unless it passed in the .rtml extension to this request.
|
120
|
+
def redirect_to(a,&b)
|
121
|
+
if request.is_terminal? or params[:format] == 'rtml'
|
122
|
+
if a.kind_of? Hash
|
123
|
+
@redirect_to = url_for(a.merge(:only_path => true))
|
124
|
+
else
|
125
|
+
@redirect_to = url_for(:action => a)
|
126
|
+
end
|
127
|
+
render :action => 'do_tml_redirect'
|
128
|
+
else
|
129
|
+
super
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
# Forces the user to use the specified format, regardless of what was requested by the
|
134
|
+
# browser or detected by RTML. You should be very careful with this, because it can have
|
135
|
+
# unintended consequences such as feeding TML to a browser expecting HTML. In fact, it's
|
136
|
+
# generally better to leave the format handling for the RTML Core to worry about. You
|
137
|
+
# have been warned.
|
138
|
+
def force_format(fmt)
|
139
|
+
fmt = params[:format] || 'html' if fmt.nil?
|
140
|
+
request.format = fmt
|
141
|
+
format_filter
|
142
|
+
#headers_filter
|
143
|
+
end
|
144
|
+
|
145
|
+
# Allows you to toggle whether or not form data sent from a terminal via TMLPOST data should
|
146
|
+
# be available directly via the params object, or whether it should be isolated in params[:tml].
|
147
|
+
# For example, the "user_name" parameter would be stored in params[:user_name] if collect_params
|
148
|
+
# is false, or params[:tml][:user_name] if collect_params is true. By default, params are
|
149
|
+
# stored directly in the params hash (in other words, the default is "false") -- but if you
|
150
|
+
# call this method with no arguments, it will be set to TRUE.
|
151
|
+
#
|
152
|
+
# Example:
|
153
|
+
# class MyTmlController < Rtml::TmlAppController
|
154
|
+
# collect_params # => true
|
155
|
+
# collect_params false
|
156
|
+
# collect_params true
|
157
|
+
# . . .
|
158
|
+
# end
|
159
|
+
def self.collect_params(tf = true)
|
160
|
+
self.class_eval { def collect_params?; tf; end }
|
161
|
+
end
|
162
|
+
|
163
|
+
# Returns the terminal state hash. Raises an error if the state is not available (but this
|
164
|
+
# shouldn't happen unless you forgot to run rake rtml:setup). Note that you only need to run
|
165
|
+
# rake rtml:setup if you plan to actually make use of the state hash.
|
166
|
+
def state
|
167
|
+
@terminal_state.nil? ? (raise "State not available; run rake rtml:setup to enable it") :
|
168
|
+
@terminal_state#.state
|
169
|
+
end
|
170
|
+
|
171
|
+
# If true, TML params will be segregated into params[:tml]
|
172
|
+
# If false, default functionality is assumed, and params will be stored directly within the
|
173
|
+
# params hash. While you can override this if you wish, you're probably better off using
|
174
|
+
# the #collect_params method within your controller.
|
175
|
+
def collect_params?(); false; end
|
176
|
+
|
177
|
+
# This method is responsible for making view inheritance possible.
|
178
|
+
def default_template_name(action_name = self.action_name,
|
179
|
+
ext = response.template.template_format,
|
180
|
+
klass = self.class) #:nodoc:
|
181
|
+
if action_name && klass == self.class
|
182
|
+
action_name = action_name.to_s
|
183
|
+
if action_name.include?('/') && template_path_includes_controller?(action_name)
|
184
|
+
action_name = strip_out_controller(action_name)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
if !klass.superclass.method_defined?(:controller_path)
|
188
|
+
return "#{self.controller_path}/#{action_name}"
|
189
|
+
end
|
190
|
+
template_name = "#{klass.controller_path}/#{action_name}"
|
191
|
+
if template_exists? template_name, ext
|
192
|
+
return template_name
|
193
|
+
else
|
194
|
+
return default_template_name(action_name, ext, klass.superclass)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
# Checks to see if a template with the specified name and optional format exists.
|
199
|
+
unless ActionController::Base.private_instance_methods.include? 'template_exists?'
|
200
|
+
def template_exists?(template_name, fmt = response.template.template_format) #:nodoc:
|
201
|
+
self.view_paths.find_template(template_name, fmt)
|
202
|
+
rescue ActionView::MissingTemplate, Errno::ENOENT
|
203
|
+
false
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
# If a catastrophic error would otherwise result in a 500 Internal Server Error
|
208
|
+
# and the application server is running in PRODUCTION mode,
|
209
|
+
# this method will be called instead, and the terminal user will instead see a
|
210
|
+
# pretty error message. It's something generic like "Contact an administrator",
|
211
|
+
# and it can be overridden by creating a "rescue_action_in_public.rtml.erb" file
|
212
|
+
# somewhere in your view path. You can find the original at
|
213
|
+
# app/views/rtml/tml_app/rescue_action_in_public.rtml.erb.
|
214
|
+
#
|
215
|
+
# Note that this file should be either a straight TML template (using ERB of course)
|
216
|
+
# or "document-level" RTML (essentially breaking the MVC rules and running the TML
|
217
|
+
# generation in the View).
|
218
|
+
def rescue_action_in_public(exception) #:nodoc:
|
219
|
+
if request.is_terminal? or params[:error_mode] == 'rtml'
|
220
|
+
@exception = exception
|
221
|
+
render :action => 'rescue_action_in_public'
|
222
|
+
else
|
223
|
+
super
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
# If a catastrophic error would otherwise result in a 500 Internal Server Error
|
228
|
+
# and the application server is running in DEVELOPMENT mode,
|
229
|
+
# this method will be called instead, and the terminal user will instead see a
|
230
|
+
# detailed error report like the default ones that Rails generates for your
|
231
|
+
# Web browser.
|
232
|
+
# If you need to tweak the message, it can be overridden by creating a
|
233
|
+
# "rescue_action_locally.rtml.erb" file
|
234
|
+
# somewhere in your view path. You can find the original at
|
235
|
+
# app/views/rtml/tml_app/rescue_action_locally.rtml.erb.
|
236
|
+
#
|
237
|
+
# Note that this file should be either a straight TML template (using ERB of course)
|
238
|
+
# or "document-level" RTML (essentially breaking the MVC rules and running the TML
|
239
|
+
# generation in the View).
|
240
|
+
def rescue_action_locally(exception) #:nodoc:
|
241
|
+
if request.is_terminal? or params[:error_mode] == 'rtml'
|
242
|
+
@exception = exception
|
243
|
+
#if self.respond_to? :rtml_interface and rtml_interface
|
244
|
+
#rtml_interface.instance_variable_set("@exception", exception)
|
245
|
+
#end
|
246
|
+
render :action => 'rescue_action_locally'
|
247
|
+
else
|
248
|
+
super
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
|
253
|
+
private
|
254
|
+
# If params[:format] is specified as 'tml', it is changed to 'rtml' and the method returns.
|
255
|
+
# If it is set to any
|
256
|
+
# other non-nil value, nothing happens. If it is nil, then the following happens:
|
257
|
+
# If a template of the requested format exists, the method returns as no further action is
|
258
|
+
# necessary. (The matching template will be rendered unless you intervene.)
|
259
|
+
# If the requested format is 'tml', or the client is a terminal, the format is forced to 'rtml'.
|
260
|
+
# If the client is not a terminal and the requested format is not 'tml', nothing happens.
|
261
|
+
#
|
262
|
+
# This method also defines a singleton method for the request object called is_terminal? which
|
263
|
+
# returns true if the client for this request is a terminal (as opposed to a browser). Note that
|
264
|
+
# the is_terminal? method always tells the "truth" -- even if the browser is emulating a terminal
|
265
|
+
# for this request, it will still return false for a browser.
|
266
|
+
def format_filter
|
267
|
+
def request.is_terminal?
|
268
|
+
self.user_agent and (self.user_agent['OE MicroBrowser'] || self.user_agent['IO Browser'])
|
269
|
+
end
|
270
|
+
|
271
|
+
params[:format] = 'rtml' if params[:format] == 'tml'
|
272
|
+
return if params[:format] # Client-specified formats trump anything automatically assigned
|
273
|
+
return if template_exists? default_template_name(action_name, request.format)
|
274
|
+
|
275
|
+
fmt = request.format#response.template.template_format.to_s
|
276
|
+
fmt = 'rtml' if fmt == 'tml' or request.is_terminal?
|
277
|
+
request.format = fmt
|
278
|
+
# response.template.template_format = fmt # params[:format] = fmt
|
279
|
+
end
|
280
|
+
|
281
|
+
# Sets the content-type to XML instead of TML for anything but OEGW. This makes it viewable
|
282
|
+
# in a user's browser as an XML document. Also rebuilds the ETag header to be compatible with
|
283
|
+
# OpenEstate/Incendo Online. (Default Rails ETags are 1 character too long. Painful debugging,
|
284
|
+
# that.)
|
285
|
+
def headers_filter
|
286
|
+
if [:rtml, :tml].include? request.format.to_sym
|
287
|
+
headers['content-type'] = 'text/xml' unless request.is_terminal?
|
288
|
+
headers['content-type'] = 'text/tml' if request.is_terminal?
|
289
|
+
headers['Cache-Control'] = 'no-cache ' # trailing space is important!
|
290
|
+
headers['ETag'] = "W/\"329-#{Time.now.to_i}#{rand(9999)}\" "
|
291
|
+
headers['Expires'] =
|
292
|
+
if expires_at
|
293
|
+
expires_at.call(self)
|
294
|
+
else
|
295
|
+
Time.at(0) # always expired
|
296
|
+
end.strftime("%a, %d %b %Y %H:%M:%S GMT")
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
# Loads the terminal's (or browser's) state hash from the database.
|
301
|
+
# TODO: Use Rails.cache for the state whenever possible.
|
302
|
+
def load_state
|
303
|
+
if params[:tml]
|
304
|
+
term_params = params[:tml][:terminal]
|
305
|
+
else
|
306
|
+
term_params = params[:terminal]
|
307
|
+
end
|
308
|
+
fail = false # if true, the get_terminal_info TML page will be rendered.
|
309
|
+
repost = false # if true, the terminal data is out of date and needs to be refreshed.
|
310
|
+
|
311
|
+
headers = request.headers
|
312
|
+
unless request.is_terminal?
|
313
|
+
# Build some fake data if the user is viewing with a browser, for debugging
|
314
|
+
# Otherwise, user would just always see get_terminal_info. Epic debugfail.
|
315
|
+
p = params[:browser] || {}
|
316
|
+
headers = Rtml::Debug::BrowserEmulator.new(headers.merge(self.class.rtml_debug_config.merge(p)))
|
317
|
+
repost = true # always use current browser details. This enables debug configuration override.
|
318
|
+
end
|
319
|
+
|
320
|
+
itid = headers['ITID'] || headers['HTTP_ITID']
|
321
|
+
itsn = headers['ITSN'] || headers['HTTP_ITSN']
|
322
|
+
itpn = headers['ITPN'] || headers['HTTP_ITPN']
|
323
|
+
|
324
|
+
if itid && itsn && itpn or not request.is_terminal?
|
325
|
+
signature = "#{itsn}:#{itpn}:#{itid}"
|
326
|
+
@terminal_state = Rtml::State.find_by_signature(signature)
|
327
|
+
if @terminal_state.nil?
|
328
|
+
logger.debug "Terminal state for signature '#{signature}' not found; creating"
|
329
|
+
@terminal_state = Rtml::State.new(:signature => signature,
|
330
|
+
:terminal => Terminal.new(:itid => itid))
|
331
|
+
@terminal_state.state ||= HashWithIndifferentAccess.new
|
332
|
+
logger.debug "Saving empty state"
|
333
|
+
@terminal_state.save!
|
334
|
+
end
|
335
|
+
|
336
|
+
if @terminal_state.state.empty?
|
337
|
+
logger.debug "Terminal state needs populated."
|
338
|
+
repost = true
|
339
|
+
elsif @terminal_state.created_at < 1.day.ago
|
340
|
+
logger.debug "Terminal state is outdated (#{@terminal_state.created_at} < #{1.day.ago}) and will be repopulated."
|
341
|
+
repost = true
|
342
|
+
end
|
343
|
+
|
344
|
+
if repost
|
345
|
+
p = term_params
|
346
|
+
p = headers if headers.kind_of? Rtml::Debug::BrowserEmulator
|
347
|
+
|
348
|
+
if p
|
349
|
+
logger.debug "Found terminal information in headers."
|
350
|
+
@terminal_state.state.merge! p
|
351
|
+
@terminal_state.state[:signature] = @terminal_state.signature
|
352
|
+
@terminal_state.created_at = Time.now
|
353
|
+
# State is saved as a part of the before_render filter.
|
354
|
+
# @terminal_state.save!
|
355
|
+
|
356
|
+
if term_params
|
357
|
+
# FIXME: First I need to remember what this was designed to do (dumb me and no comments),
|
358
|
+
# and then I need to make it work. Whatever it was, it was causing an infinite loop when
|
359
|
+
# redirect_to resulted in reposting state data.
|
360
|
+
#
|
361
|
+
#params.delete :terminal
|
362
|
+
#params[:tml].delete :terminal if params[:tml]
|
363
|
+
#redirect_to params
|
364
|
+
end
|
365
|
+
return true
|
366
|
+
else
|
367
|
+
logger.debug "Could not find terminal information in headers; triggering a data post"
|
368
|
+
logger.debug "term_params: #{term_params.inspect}"
|
369
|
+
logger.debug "params: #{params.inspect}"
|
370
|
+
fail = true
|
371
|
+
end
|
372
|
+
end
|
373
|
+
else
|
374
|
+
raise "Could not find TID header!" unless itid
|
375
|
+
raise "Could not find SN header!" unless itsn
|
376
|
+
raise "Could not find PN header!" unless itpn
|
377
|
+
raise "Unknown error -- something to do with the TID/SN/PN headers!"
|
378
|
+
end
|
379
|
+
return true unless fail
|
380
|
+
|
381
|
+
unless request.post? # don't want to interfere with POSTing
|
382
|
+
force_format :rtml
|
383
|
+
# FIXME: It may be preferable to use redirect_to instead of render
|
384
|
+
# because if the terminal hits an error in get_terminal_info (or
|
385
|
+
# more likely, after it posts the data get_terminal_info is asking
|
386
|
+
# for), the user is going to be somewhat confused by an error message
|
387
|
+
# blaming HIS action, not the get_terminal_info action.
|
388
|
+
# However, also need to be sure that when the user hits get_terminal_info,
|
389
|
+
# he'll be sent back to the current action.
|
390
|
+
#redirect_to :action => 'get_terminal_info'
|
391
|
+
|
392
|
+
render :action => 'get_terminal_info'
|
393
|
+
headers_filter
|
394
|
+
return false
|
395
|
+
end
|
396
|
+
|
397
|
+
# If we get an ActiveRecord error, it's probably because RTML state has not been initialized.
|
398
|
+
# Fail silently. Then, if the user tries to access state, they'll get the "rake first"
|
399
|
+
# error via the #rtml_state method (above).
|
400
|
+
rescue ActiveRecord::StatementInvalid
|
401
|
+
true
|
402
|
+
end
|
403
|
+
|
404
|
+
# Saves the terminal's (or browser's) state hash to the database.
|
405
|
+
# TODO: Use Rails.cache for the state (as opposed to the database) whenever possible.
|
406
|
+
def save_state
|
407
|
+
if @terminal_state
|
408
|
+
begin
|
409
|
+
@terminal_state.save
|
410
|
+
rescue #save_state
|
411
|
+
logger.error $!
|
412
|
+
logger.error $!.backtrace.join("\n\t")
|
413
|
+
end
|
414
|
+
end
|
415
|
+
true
|
416
|
+
end
|
417
|
+
end
|
418
|
+
end
|