platform 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +21 -0
- data/.rspec +2 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +191 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +5 -0
- data/Rakefile +37 -0
- data/app/assets/images/platform/.gitkeep +0 -0
- data/app/assets/images/platform/accept.png +0 -0
- data/app/assets/images/platform/action_tab_bkgd.gif +0 -0
- data/app/assets/images/platform/action_tab_white_bkgd.gif +0 -0
- data/app/assets/images/platform/add.png +0 -0
- data/app/assets/images/platform/apps/app_icon.gif +0 -0
- data/app/assets/images/platform/apps/app_logo.gif +0 -0
- data/app/assets/images/platform/arrow_down.gif +0 -0
- data/app/assets/images/platform/arrow_down.png +0 -0
- data/app/assets/images/platform/arrow_down_grey.png +0 -0
- data/app/assets/images/platform/arrow_right.gif +0 -0
- data/app/assets/images/platform/arrow_up.png +0 -0
- data/app/assets/images/platform/arrow_up_grey.png +0 -0
- data/app/assets/images/platform/bullet_go.png +0 -0
- data/app/assets/images/platform/buttons.png +0 -0
- data/app/assets/images/platform/cancel.png +0 -0
- data/app/assets/images/platform/clipboard_icon.gif +0 -0
- data/app/assets/images/platform/close.gif +0 -0
- data/app/assets/images/platform/cross.png +0 -0
- data/app/assets/images/platform/default_app_icon.gif +0 -0
- data/app/assets/images/platform/default_app_logo.gif +0 -0
- data/app/assets/images/platform/delete.png +0 -0
- data/app/assets/images/platform/disk.png +0 -0
- data/app/assets/images/platform/exclamation.png +0 -0
- data/app/assets/images/platform/eye.png +0 -0
- data/app/assets/images/platform/eye_not.png +0 -0
- data/app/assets/images/platform/field_sprite.gif +0 -0
- data/app/assets/images/platform/find.png +0 -0
- data/app/assets/images/platform/globe.gif +0 -0
- data/app/assets/images/platform/help.png +0 -0
- data/app/assets/images/platform/help/app_reg.png +0 -0
- data/app/assets/images/platform/help/app_reg_ext.png +0 -0
- data/app/assets/images/platform/help/app_reg_web.png +0 -0
- data/app/assets/images/platform/help/auth_desktop.png +0 -0
- data/app/assets/images/platform/help/auth_iframe.png +0 -0
- data/app/assets/images/platform/help/auth_iphone.png +0 -0
- data/app/assets/images/platform/help/auth_web.png +0 -0
- data/app/assets/images/platform/help/authorize.png +0 -0
- data/app/assets/images/platform/help/ext.png +0 -0
- data/app/assets/images/platform/help/login.png +0 -0
- data/app/assets/images/platform/help/login_desktop.png +0 -0
- data/app/assets/images/platform/help/login_iphone.png +0 -0
- data/app/assets/images/platform/help/login_web.png +0 -0
- data/app/assets/images/platform/help2.png +0 -0
- data/app/assets/images/platform/information.png +0 -0
- data/app/assets/images/platform/keyboard.png +0 -0
- data/app/assets/images/platform/language_selector_arrow.gif +0 -0
- data/app/assets/images/platform/left_quote.png +0 -0
- data/app/assets/images/platform/lightning.png +0 -0
- data/app/assets/images/platform/loading.gif +0 -0
- data/app/assets/images/platform/loading2.gif +0 -0
- data/app/assets/images/platform/loading3.gif +0 -0
- data/app/assets/images/platform/loading_animation.gif +0 -0
- data/app/assets/images/platform/loading_large.gif +0 -0
- data/app/assets/images/platform/lock.png +0 -0
- data/app/assets/images/platform/lock_add.png +0 -0
- data/app/assets/images/platform/lock_delete.png +0 -0
- data/app/assets/images/platform/lock_open.png +0 -0
- data/app/assets/images/platform/medals/bronze.png +0 -0
- data/app/assets/images/platform/medals/gold.png +0 -0
- data/app/assets/images/platform/medals/runner.png +0 -0
- data/app/assets/images/platform/medals/silver.png +0 -0
- data/app/assets/images/platform/minus_node.png +0 -0
- data/app/assets/images/platform/oauth/perm_tile.gif +0 -0
- data/app/assets/images/platform/oauth/right_grey.png +0 -0
- data/app/assets/images/platform/pencil.png +0 -0
- data/app/assets/images/platform/photo_silhouette.gif +0 -0
- data/app/assets/images/platform/pixel.gif +0 -0
- data/app/assets/images/platform/platform.png +0 -0
- data/app/assets/images/platform/platform2.png +0 -0
- data/app/assets/images/platform/platform3.png +0 -0
- data/app/assets/images/platform/platform4.png +0 -0
- data/app/assets/images/platform/platform5.png +0 -0
- data/app/assets/images/platform/plus.png +0 -0
- data/app/assets/images/platform/plus_node.png +0 -0
- data/app/assets/images/platform/random.png +0 -0
- data/app/assets/images/platform/random2.png +0 -0
- data/app/assets/images/platform/rating_star0.png +0 -0
- data/app/assets/images/platform/rating_star05.png +0 -0
- data/app/assets/images/platform/rating_star1.png +0 -0
- data/app/assets/images/platform/rating_stars.gif +0 -0
- data/app/assets/images/platform/rating_stars.psd +0 -0
- data/app/assets/images/platform/reply.png +0 -0
- data/app/assets/images/platform/right_quote.png +0 -0
- data/app/assets/images/platform/rotating_world.gif +0 -0
- data/app/assets/images/platform/script.png +0 -0
- data/app/assets/images/platform/script_edit.png +0 -0
- data/app/assets/images/platform/script_gear.png +0 -0
- data/app/assets/images/platform/site_sprite.gif +0 -0
- data/app/assets/images/platform/spinner.gif +0 -0
- data/app/assets/images/platform/star.png +0 -0
- data/app/assets/images/platform/table_edit.png +0 -0
- data/app/assets/images/platform/table_gear.png +0 -0
- data/app/assets/images/platform/table_multiple.png +0 -0
- data/app/assets/images/platform/thumb_down.png +0 -0
- data/app/assets/images/platform/thumb_up.png +0 -0
- data/app/assets/images/platform/top_left_stem.png +0 -0
- data/app/assets/images/platform/top_right_stem.png +0 -0
- data/app/assets/images/platform/translate_icn.gif +0 -0
- data/app/assets/images/platform/treeview/diffDoc.gif +0 -0
- data/app/assets/images/platform/treeview/diffFolder.gif +0 -0
- data/app/assets/images/platform/treeview/ftv2blank.gif +0 -0
- data/app/assets/images/platform/treeview/ftv2doc.gif +0 -0
- data/app/assets/images/platform/treeview/ftv2folderclosed.gif +0 -0
- data/app/assets/images/platform/treeview/ftv2folderopen.gif +0 -0
- data/app/assets/images/platform/treeview/ftv2lastnode.gif +0 -0
- data/app/assets/images/platform/treeview/ftv2link.gif +0 -0
- data/app/assets/images/platform/treeview/ftv2mlastnode.gif +0 -0
- data/app/assets/images/platform/treeview/ftv2mnode.gif +0 -0
- data/app/assets/images/platform/treeview/ftv2node.gif +0 -0
- data/app/assets/images/platform/treeview/ftv2plastnode.gif +0 -0
- data/app/assets/images/platform/treeview/ftv2pnode.gif +0 -0
- data/app/assets/images/platform/treeview/ftv2vertline.gif +0 -0
- data/app/assets/images/platform/wizard.png +0 -0
- data/app/assets/images/platform/world_link.png +0 -0
- data/app/assets/javascripts/platform/api_explorer.js +628 -0
- data/app/assets/javascripts/platform/application.js +9 -0
- data/app/assets/javascripts/platform/ftiens4.js +1197 -0
- data/app/assets/javascripts/platform/jsdk.js +539 -0
- data/app/assets/javascripts/platform/platform.js +447 -0
- data/app/assets/javascripts/platform/shortcut.js +223 -0
- data/app/assets/javascripts/platform/ua.js +147 -0
- data/app/assets/stylesheets/platform/api_explorer.css.scss +140 -0
- data/app/assets/stylesheets/platform/application.css.scss +6 -0
- data/app/assets/stylesheets/platform/components.css.scss +208 -0
- data/app/assets/stylesheets/platform/layout.css.scss +119 -0
- data/app/assets/stylesheets/platform/oauth.css +51 -0
- data/app/assets/stylesheets/platform/platform.css.scss +311 -0
- data/app/controllers/platform/admin/apps_controller.rb +99 -0
- data/app/controllers/platform/admin/base_controller.rb +60 -0
- data/app/controllers/platform/admin/categories_controller.rb +132 -0
- data/app/controllers/platform/admin/clientsdk_controller.rb +30 -0
- data/app/controllers/platform/admin/developers_controller.rb +30 -0
- data/app/controllers/platform/admin/exceptions_controller.rb +30 -0
- data/app/controllers/platform/admin/forum_controller.rb +34 -0
- data/app/controllers/platform/admin/metrics_controller.rb +42 -0
- data/app/controllers/platform/api/apps_controller.rb +40 -0
- data/app/controllers/platform/api/base_controller.rb +541 -0
- data/app/controllers/platform/apps_controller.rb +142 -0
- data/app/controllers/platform/base_controller.rb +127 -0
- data/app/controllers/platform/developer/api_explorer_controller.rb +56 -0
- data/app/controllers/platform/developer/apps_controller.rb +161 -0
- data/app/controllers/platform/developer/base_controller.rb +51 -0
- data/app/controllers/platform/developer/blog_controller.rb +29 -0
- data/app/controllers/platform/developer/dashboard_controller.rb +63 -0
- data/app/controllers/platform/developer/forum_controller.rb +85 -0
- data/app/controllers/platform/developer/help_controller.rb +113 -0
- data/app/controllers/platform/developer/info_controller.rb +41 -0
- data/app/controllers/platform/developer/registration_controller.rb +39 -0
- data/app/controllers/platform/developer/resources_controller.rb +30 -0
- data/app/controllers/platform/forum_controller.rb +74 -0
- data/app/controllers/platform/oauth_controller.rb +421 -0
- data/app/controllers/platform/ratings_controller.rb +61 -0
- data/app/helpers/platform/admin/categories_helper.rb +54 -0
- data/app/helpers/platform/apps_helper.rb +26 -0
- data/app/helpers/platform/developer/dashboard_helper.rb +42 -0
- data/app/helpers/platform/developer/help_helper.rb +45 -0
- data/app/helpers/platform_helper.rb +26 -0
- data/app/models/platform/application.rb +394 -0
- data/app/models/platform/application_category.rb +34 -0
- data/app/models/platform/application_developer.rb +30 -0
- data/app/models/platform/application_filter.rb +30 -0
- data/app/models/platform/application_log.rb +32 -0
- data/app/models/platform/application_log_filter.rb +34 -0
- data/app/models/platform/application_metric.rb +58 -0
- data/app/models/platform/application_metric_filter.rb +34 -0
- data/app/models/platform/application_permission.rb +30 -0
- data/app/models/platform/application_permission_filter.rb +30 -0
- data/app/models/platform/application_usage_metric.rb +58 -0
- data/app/models/platform/application_usage_metric_filter.rb +34 -0
- data/app/models/platform/application_user.rb +45 -0
- data/app/models/platform/application_user_filter.rb +34 -0
- data/app/models/platform/base_filter.rb +46 -0
- data/app/models/platform/category.rb +64 -0
- data/app/models/platform/daily_application_metric.rb +31 -0
- data/app/models/platform/developer.rb +45 -0
- data/app/models/platform/developer_filter.rb +26 -0
- data/app/models/platform/forum_message.rb +35 -0
- data/app/models/platform/forum_message_filter.rb +26 -0
- data/app/models/platform/forum_topic.rb +38 -0
- data/app/models/platform/forum_topic_filter.rb +26 -0
- data/app/models/platform/logged_exception.rb +290 -0
- data/app/models/platform/logged_exception_filter.rb +58 -0
- data/app/models/platform/media/image.rb +26 -0
- data/app/models/platform/media/media.rb +58 -0
- data/app/models/platform/monthly_application_metric.rb +31 -0
- data/app/models/platform/oauth/access_token.rb +57 -0
- data/app/models/platform/oauth/client_token.rb +38 -0
- data/app/models/platform/oauth/oauth_model_methods.rb +41 -0
- data/app/models/platform/oauth/oauth_token.rb +57 -0
- data/app/models/platform/oauth/oauth_token_filter.rb +34 -0
- data/app/models/platform/oauth/refresh_token.rb +47 -0
- data/app/models/platform/oauth/request_token.rb +50 -0
- data/app/models/platform/permission.rb +27 -0
- data/app/models/platform/rating.rb +43 -0
- data/app/models/platform/rating_filter.rb +30 -0
- data/app/models/platform/rollup_log.rb +27 -0
- data/app/models/platform/rollup_log_filter.rb +30 -0
- data/app/models/platform/total_application_metric.rb +40 -0
- data/app/models/platform/weekly_application_metric.rb +31 -0
- data/app/views/platform/admin/apps/_categories.html.erb +17 -0
- data/app/views/platform/admin/apps/_categories_scripts.html.erb +17 -0
- data/app/views/platform/admin/apps/_tabs.html.erb +25 -0
- data/app/views/platform/admin/apps/index.html.erb +32 -0
- data/app/views/platform/admin/apps/permissions.html.erb +7 -0
- data/app/views/platform/admin/apps/ratings.html.erb +7 -0
- data/app/views/platform/admin/apps/tokens.html.erb +18 -0
- data/app/views/platform/admin/apps/users.html.erb +7 -0
- data/app/views/platform/admin/apps/view.html.erb +170 -0
- data/app/views/platform/admin/categories/_tabs.html.erb +22 -0
- data/app/views/platform/admin/categories/category_assigner.html.erb +9 -0
- data/app/views/platform/admin/categories/category_assigner_tree.html.erb +81 -0
- data/app/views/platform/admin/categories/index.html.erb +106 -0
- data/app/views/platform/admin/categories/items.html.erb +153 -0
- data/app/views/platform/admin/categories/lb_update_application_category.html.erb +54 -0
- data/app/views/platform/admin/categories/lb_update_category.html.erb +64 -0
- data/app/views/platform/admin/categories/tree.html.erb +64 -0
- data/app/views/platform/admin/clientsdk/index.html.erb +89 -0
- data/app/views/platform/admin/common/_footer.html.erb +1 -0
- data/app/views/platform/admin/common/_header.html.erb +32 -0
- data/app/views/platform/admin/common/_lightbox_buttons.html.erb +5 -0
- data/app/views/platform/admin/common/_paginator.html.erb +20 -0
- data/app/views/platform/admin/developers/_tabs.html.erb +22 -0
- data/app/views/platform/admin/developers/index.html.erb +7 -0
- data/app/views/platform/admin/exceptions/_tabs.html.erb +22 -0
- data/app/views/platform/admin/exceptions/index.html.erb +7 -0
- data/app/views/platform/admin/forum/_tabs.html.erb +22 -0
- data/app/views/platform/admin/forum/index.html.erb +7 -0
- data/app/views/platform/admin/forum/messages.html.erb +7 -0
- data/app/views/platform/admin/metrics/_tabs.html.erb +25 -0
- data/app/views/platform/admin/metrics/application_log.html.erb +7 -0
- data/app/views/platform/admin/metrics/index.html.erb +9 -0
- data/app/views/platform/admin/metrics/rollup_log.html.erb +7 -0
- data/app/views/platform/admin/metrics/usage.html.erb +7 -0
- data/app/views/platform/apps/_actions_module.html.erb +3 -0
- data/app/views/platform/apps/_app_footer.html.erb +8 -0
- data/app/views/platform/apps/_app_header.html.erb +25 -0
- data/app/views/platform/apps/_apps_module.html.erb +42 -0
- data/app/views/platform/apps/_authorize_form.html.erb +11 -0
- data/app/views/platform/apps/_categories_module.html.erb +11 -0
- data/app/views/platform/apps/_featured_apps_module.html.erb +40 -0
- data/app/views/platform/apps/_left.html.erb +20 -0
- data/app/views/platform/apps/_monthly_users_module.html.erb +8 -0
- data/app/views/platform/apps/_paginator.html.erb +13 -0
- data/app/views/platform/apps/_rank_module.html.erb +18 -0
- data/app/views/platform/apps/_search_apps_module.html.erb +35 -0
- data/app/views/platform/apps/canvas_app.html.erb +15 -0
- data/app/views/platform/apps/index.html.erb +86 -0
- data/app/views/platform/apps/view.html.erb +71 -0
- data/app/views/platform/apps/xd.html.erb +11 -0
- data/app/views/platform/common/_footer.html.erb +1 -0
- data/app/views/platform/common/_header.html.erb +4 -0
- data/app/views/platform/common/_paginator.html.erb +32 -0
- data/app/views/platform/common/_scripts.html.erb +7 -0
- data/app/views/platform/common/_user_login.html.erb +11 -0
- data/app/views/platform/developer/api_explorer/history.html.erb +31 -0
- data/app/views/platform/developer/api_explorer/index.html.erb +134 -0
- data/app/views/platform/developer/api_explorer/oauth_lander.html.erb +4 -0
- data/app/views/platform/developer/api_explorer/options.html.erb +44 -0
- data/app/views/platform/developer/apps/_form.html.erb +340 -0
- data/app/views/platform/developer/apps/create_version.html.erb +19 -0
- data/app/views/platform/developer/apps/edit.html.erb +21 -0
- data/app/views/platform/developer/apps/index.html.erb +375 -0
- data/app/views/platform/developer/apps/new.html.erb +20 -0
- data/app/views/platform/developer/blog/index.html.erb +7 -0
- data/app/views/platform/developer/common/_footer.html.erb +1 -0
- data/app/views/platform/developer/common/_header.html.erb +34 -0
- data/app/views/platform/developer/dashboard/_apps_info.html.erb +84 -0
- data/app/views/platform/developer/dashboard/_discussions.html.erb +68 -0
- data/app/views/platform/developer/dashboard/_header.html.erb +12 -0
- data/app/views/platform/developer/dashboard/_reviews.html.erb +53 -0
- data/app/views/platform/developer/dashboard/_statistics.html.erb +105 -0
- data/app/views/platform/developer/dashboard/index.html.erb +85 -0
- data/app/views/platform/developer/dashboard/settings.html.erb +23 -0
- data/app/views/platform/developer/forum/_message.html.erb +17 -0
- data/app/views/platform/developer/forum/_messages.html.erb +14 -0
- data/app/views/platform/developer/forum/_new_message.html.erb +28 -0
- data/app/views/platform/developer/forum/_new_topic.html.erb +39 -0
- data/app/views/platform/developer/forum/index.html.erb +89 -0
- data/app/views/platform/developer/forum/topic.html.erb +28 -0
- data/app/views/platform/developer/help/_footer.html.erb +4 -0
- data/app/views/platform/developer/help/_header.html.erb +95 -0
- data/app/views/platform/developer/help/_navigation.html.erb +99 -0
- data/app/views/platform/developer/help/api.html.erb +120 -0
- data/app/views/platform/developer/help/credits.html.erb +77 -0
- data/app/views/platform/developer/help/index.html.erb +19 -0
- data/app/views/platform/developer/help/license.html.erb +586 -0
- data/app/views/platform/developer/help/oauth_app_login.html.erb +177 -0
- data/app/views/platform/developer/help/oauth_client_side.html.erb +264 -0
- data/app/views/platform/developer/help/oauth_desktop.html.erb +191 -0
- data/app/views/platform/developer/help/oauth_extensions.html.erb +342 -0
- data/app/views/platform/developer/help/oauth_intro.html.erb +371 -0
- data/app/views/platform/developer/help/oauth_mobile.html.erb +292 -0
- data/app/views/platform/developer/help/oauth_server_side.html.erb +603 -0
- data/app/views/platform/developer/help/oauth_trusted_client.html.erb +202 -0
- data/app/views/platform/developer/help/reference.html.erb +42 -0
- data/app/views/platform/developer/help/sdk_ios.html.erb +31 -0
- data/app/views/platform/developer/help/sdk_js.html.erb +202 -0
- data/app/views/platform/developer/info/_basic_info.html.erb +74 -0
- data/app/views/platform/developer/info/_header.html.erb +12 -0
- data/app/views/platform/developer/info/index.html.erb +23 -0
- data/app/views/platform/developer/registration/index.html.erb +134 -0
- data/app/views/platform/developer/resources/index.html.erb +23 -0
- data/app/views/platform/forum/_message.html.erb +17 -0
- data/app/views/platform/forum/_messages.html.erb +14 -0
- data/app/views/platform/forum/_new_message.html.erb +26 -0
- data/app/views/platform/forum/_new_topic.html.erb +38 -0
- data/app/views/platform/forum/_topic.html.erb +18 -0
- data/app/views/platform/forum/_topics.html.erb +74 -0
- data/app/views/platform/login/index.html.erb +31 -0
- data/app/views/platform/login/register.html.erb +55 -0
- data/app/views/platform/oauth/_authorization_box.html.erb +75 -0
- data/app/views/platform/oauth/_authorization_popup.html.erb +38 -0
- data/app/views/platform/oauth/_authorize_form.html.erb +11 -0
- data/app/views/platform/oauth/auth_failed.html.erb +0 -0
- data/app/views/platform/oauth/auth_success.html.erb +0 -0
- data/app/views/platform/oauth/authorize_desktop.html.erb +76 -0
- data/app/views/platform/oauth/authorize_failure_iframe.html.erb +1 -0
- data/app/views/platform/oauth/authorize_failure_mobile.html.erb +24 -0
- data/app/views/platform/oauth/authorize_failure_popup.html.erb +24 -0
- data/app/views/platform/oauth/authorize_failure_web.html.erb +1 -0
- data/app/views/platform/oauth/authorize_iframe.html.erb +16 -0
- data/app/views/platform/oauth/authorize_mobile.html.erb +1 -0
- data/app/views/platform/oauth/authorize_popup.html.erb +1 -0
- data/app/views/platform/oauth/authorize_success_iframe.html.erb +1 -0
- data/app/views/platform/oauth/authorize_success_mobile.html.erb +24 -0
- data/app/views/platform/oauth/authorize_success_popup.html.erb +24 -0
- data/app/views/platform/oauth/authorize_success_web.html.erb +1 -0
- data/app/views/platform/oauth/authorize_web.html.erb +3 -0
- data/app/views/platform/oauth/xd.html.erb +13 -0
- data/app/views/platform/ratings/_list.html.erb +30 -0
- data/app/views/platform/ratings/_new.html.erb +70 -0
- data/app/views/platform/ratings/_rating.html.erb +17 -0
- data/config/platform/config.yml +133 -0
- data/config/platform/data/default_applications.yml +39 -0
- data/config/platform/data/default_categories.yml +56 -0
- data/config/platform/data/default_permissions.yml +0 -0
- data/config/platform/site/features.yml +66 -0
- data/config/routes.rb +59 -0
- data/db/migrate/20110602232141_create_platform_tables.rb +262 -0
- data/docs/Classes.graffle +7315 -0
- data/docs/Classes.pdf +0 -0
- data/lib/generators/platform/platform_generator.rb +56 -0
- data/lib/generators/platform/templates/db/create_platform_tables.rb +262 -0
- data/lib/generators/platform/templates/layouts/platform.html.erb +49 -0
- data/lib/generators/platform/templates/layouts/platform_admin.html.erb +60 -0
- data/lib/platform.rb +6 -0
- data/lib/platform/api/already_jsoned_string.rb +9 -0
- data/lib/platform/api/proxy.rb +45 -0
- data/lib/platform/api/proxy/base.rb +62 -0
- data/lib/platform/cache.rb +78 -0
- data/lib/platform/config.rb +666 -0
- data/lib/platform/engine.rb +5 -0
- data/lib/platform/exception.rb +27 -0
- data/lib/platform/extensions/action_controller_extension.rb +65 -0
- data/lib/platform/extensions/action_view_extension.rb +168 -0
- data/lib/platform/extensions/object_extension.rb +51 -0
- data/lib/platform/helper.rb +33 -0
- data/lib/platform/logger.rb +62 -0
- data/lib/platform/railtie.rb +52 -0
- data/lib/platform/random_password_generator.rb +76 -0
- data/lib/platform/simple_string_permissions.rb +40 -0
- data/lib/platform/version.rb +3 -0
- data/lib/tasks/platform.rake +119 -0
- data/platform.gemspec +45 -0
- data/script/rails +6 -0
- data/spec/config/config_spec.rb +10 -0
- data/spec/dummy_app.rb +52 -0
- data/spec/models/application_spec.rb +53 -0
- data/spec/models/developer_spec.rb +23 -0
- data/spec/spec_helper.rb +29 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +7 -0
- data/test/dummy/app/assets/stylesheets/admin.css +200 -0
- data/test/dummy/app/assets/stylesheets/application.css +47 -0
- data/test/dummy/app/assets/stylesheets/components.css.scss +211 -0
- data/test/dummy/app/assets/stylesheets/layout.css.scss +143 -0
- data/test/dummy/app/controllers/admin/admins_controller.rb +7 -0
- data/test/dummy/app/controllers/admin/base_controller.rb +12 -0
- data/test/dummy/app/controllers/admin/bookmarks_controller.rb +7 -0
- data/test/dummy/app/controllers/admin/users_controller.rb +19 -0
- data/test/dummy/app/controllers/api/base_controller.rb +5 -0
- data/test/dummy/app/controllers/api/bookmarks_controller.rb +35 -0
- data/test/dummy/app/controllers/api/users_controller.rb +19 -0
- data/test/dummy/app/controllers/application_controller.rb +31 -0
- data/test/dummy/app/controllers/home_controller.rb +7 -0
- data/test/dummy/app/controllers/login_controller.rb +65 -0
- data/test/dummy/app/helpers/application_helper.rb +9 -0
- data/test/dummy/app/helpers/home_helper.rb +2 -0
- data/test/dummy/app/mailers/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/app/models/admin.rb +4 -0
- data/test/dummy/app/models/admin_filter.rb +7 -0
- data/test/dummy/app/models/bookmark.rb +7 -0
- data/test/dummy/app/models/user.rb +34 -0
- data/test/dummy/app/views/admin/admins/index.html.erb +7 -0
- data/test/dummy/app/views/admin/bookmarks/index.html.erb +5 -0
- data/test/dummy/app/views/admin/users/index.html.erb +10 -0
- data/test/dummy/app/views/demo/index.rhtml +108 -0
- data/test/dummy/app/views/demo/tokens.rhtml +35 -0
- data/test/dummy/app/views/home/index.html.erb +43 -0
- data/test/dummy/app/views/layouts/_footer.html.erb +16 -0
- data/test/dummy/app/views/layouts/_header.html.erb +22 -0
- data/test/dummy/app/views/layouts/admin.html.erb +97 -0
- data/test/dummy/app/views/layouts/application.html.erb +25 -0
- data/test/dummy/app/views/layouts/minimal.html.erb +37 -0
- data/test/dummy/app/views/layouts/popup.html.erb +43 -0
- data/test/dummy/app/views/login/index.html.erb +34 -0
- data/test/dummy/app/views/login/register.html.erb +51 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +51 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +30 -0
- data/test/dummy/config/environments/production.rb +60 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/platform/api/0/bookmark.yml +18 -0
- data/test/dummy/config/platform/api/0/user.yml +17 -0
- data/test/dummy/config/platform/api/1/bookmark.yml +58 -0
- data/test/dummy/config/platform/api/1/user.yml +36 -0
- data/test/dummy/config/platform/config.yml +135 -0
- data/test/dummy/config/platform/data/default_applications.yml +39 -0
- data/test/dummy/config/platform/data/default_categories.yml +56 -0
- data/test/dummy/config/platform/data/default_permissions.yml +0 -0
- data/test/dummy/config/platform/site/features.yml +66 -0
- data/test/dummy/config/platform/site/sample_apps.yml +100 -0
- data/test/dummy/config/routes.rb +30 -0
- data/test/dummy/config/tr8n/config.yml +247 -0
- data/test/dummy/config/tr8n/data/ip_locations.csv +93460 -0
- data/test/dummy/config/tr8n/rules/default_date_rules.yml +20 -0
- data/test/dummy/config/tr8n/rules/default_gender_list_rules.yml +82 -0
- data/test/dummy/config/tr8n/rules/default_gender_rules.yml +20 -0
- data/test/dummy/config/tr8n/rules/default_language_cases.yml +272 -0
- data/test/dummy/config/tr8n/rules/default_list_rules.yml +19 -0
- data/test/dummy/config/tr8n/rules/default_numeric_rules.yml +42 -0
- data/test/dummy/config/tr8n/rules/default_value_rules.yml +18 -0
- data/test/dummy/config/tr8n/site/default_glossary.yml +18 -0
- data/test/dummy/config/tr8n/site/default_languages.yml +1591 -0
- data/test/dummy/config/tr8n/site/features.yml +111 -0
- data/test/dummy/config/tr8n/site/shortcuts.yml +55 -0
- data/test/dummy/config/tr8n/site/sitemap.json +42 -0
- data/test/dummy/config/tr8n/tokens/data.yml +19 -0
- data/test/dummy/config/tr8n/tokens/decorations.yml +19 -0
- data/test/dummy/config/will_filter/config.yml +99 -0
- data/test/dummy/db/migrate/20101207014543_create_users.rb +23 -0
- data/test/dummy/db/migrate/20110113223509_create_admins.rb +15 -0
- data/test/dummy/db/migrate/20110930041143_create_will_filter_filters.rb +15 -0
- data/test/dummy/db/migrate/20110930041150_create_tr8n_tables.rb +350 -0
- data/test/dummy/db/migrate/20111004075531_create_platform_tables.rb +262 -0
- data/test/dummy/db/migrate/20111012055603_create_bookmarks.rb +10 -0
- data/test/dummy/db/schema.rb +683 -0
- data/test/dummy/lib/assets/.gitkeep +0 -0
- data/test/dummy/lib/platform/api/bookmark_proxy_0.rb +12 -0
- data/test/dummy/lib/platform/api/bookmark_proxy_1.rb +12 -0
- data/test/dummy/lib/platform/api/user_proxy_0.rb +12 -0
- data/test/dummy/lib/platform/api/user_proxy_1.rb +12 -0
- data/test/dummy/log/.gitkeep +0 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/test/fixtures/documents.yml +11 -0
- data/test/dummy/test/unit/document_test.rb +7 -0
- metadata +886 -0
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,628 @@
|
|
1
|
+
var field_count = 0;
|
2
|
+
var base_api_url = "";
|
3
|
+
var base_site_url = "";
|
4
|
+
var api_explorer_app_id = "";
|
5
|
+
var api_history = {};
|
6
|
+
var api_history_index = -1;
|
7
|
+
var api_result_json = "";
|
8
|
+
var api_result_object_keys = [];
|
9
|
+
|
10
|
+
function initApiExplorer(app_id, site_url, api_url, api_history_string) {
|
11
|
+
api_explorer_app_id = app_id;
|
12
|
+
base_site_url = site_url;
|
13
|
+
base_api_url = api_url;
|
14
|
+
api_history = JSON.parse(api_history_string);
|
15
|
+
updateHistoryButtons();
|
16
|
+
}
|
17
|
+
|
18
|
+
function hidePopups() {
|
19
|
+
Platform.Effects.hide("api_clipboard");
|
20
|
+
Platform.Effects.hide("api_history");
|
21
|
+
Platform.Effects.hide("api_options");
|
22
|
+
}
|
23
|
+
|
24
|
+
/************************************************************************************
|
25
|
+
** Access Token Functions
|
26
|
+
************************************************************************************/
|
27
|
+
function getAccessToken() {
|
28
|
+
var width = 600;
|
29
|
+
var height = 600;
|
30
|
+
var top = (parseInt(window.innerHeight)-height)/2;
|
31
|
+
var left = (parseInt(window.innerWidth)-width)/2;
|
32
|
+
var land_url = base_site_url + "/platform/developer/api_explorer/oauth_lander";
|
33
|
+
if (land_url.indexOf("http") == -1) {
|
34
|
+
land_url = "http://" + land_url;
|
35
|
+
}
|
36
|
+
var oauth_url = '/platform/oauth/authorize?client_id=' + api_explorer_app_id + '&response_type=token&display=mobile&redirect_url=' + escape(land_url)
|
37
|
+
var win = window.open(oauth_url, 'oauthx_auth', 'width=' + width +',height=' + height + ',top=' + top + ',left=' + left);
|
38
|
+
}
|
39
|
+
|
40
|
+
function updateAccessToken(token) {
|
41
|
+
Platform.element("access_token").value = token;
|
42
|
+
}
|
43
|
+
|
44
|
+
/************************************************************************************
|
45
|
+
** Clipboard Functions
|
46
|
+
************************************************************************************/
|
47
|
+
function copyToClipboard(trigger) {
|
48
|
+
Platform.Effects.hide("api_history");
|
49
|
+
Platform.Effects.hide("api_options");
|
50
|
+
|
51
|
+
var options = Platform.element("api_clipboard");
|
52
|
+
|
53
|
+
if (options.style.display == "none") {
|
54
|
+
var trigger_position = Platform.Utils.cumulativeOffset(trigger);
|
55
|
+
var container_position = {
|
56
|
+
left: trigger_position[0] + trigger.offsetWidth - 25 + 'px',
|
57
|
+
top: trigger_position[1] + trigger.offsetHeight + 10 + 'px'
|
58
|
+
}
|
59
|
+
options.style.left = container_position.left;
|
60
|
+
options.style.top = container_position.top;
|
61
|
+
Platform.Effects.show("api_clipboard");
|
62
|
+
} else {
|
63
|
+
Platform.Effects.hide("api_clipboard");
|
64
|
+
}
|
65
|
+
|
66
|
+
Platform.element("api_clipboard_text").value = api_result_json;
|
67
|
+
Platform.element("api_clipboard_text").focus();
|
68
|
+
Platform.element("api_clipboard_text").select();
|
69
|
+
}
|
70
|
+
|
71
|
+
function copyUrlToClipboard(trigger) {
|
72
|
+
Platform.Effects.hide("api_history");
|
73
|
+
Platform.Effects.hide("api_options");
|
74
|
+
|
75
|
+
var options = Platform.element("api_clipboard");
|
76
|
+
|
77
|
+
if (options.style.display == "none") {
|
78
|
+
var trigger_position = Platform.Utils.cumulativeOffset(trigger);
|
79
|
+
var container_position = {
|
80
|
+
left: trigger_position[0] + trigger.offsetWidth - 25 + 'px',
|
81
|
+
top: trigger_position[1] + trigger.offsetHeight + 10 + 'px'
|
82
|
+
}
|
83
|
+
options.style.left = container_position.left;
|
84
|
+
options.style.top = container_position.top;
|
85
|
+
Platform.Effects.show("api_clipboard");
|
86
|
+
} else {
|
87
|
+
Platform.Effects.hide("api_clipboard");
|
88
|
+
}
|
89
|
+
|
90
|
+
var params = generateRequestParams();
|
91
|
+
var link_location = "" + window.location;
|
92
|
+
link_location = link_location.split("?")[0];
|
93
|
+
link_location = link_location + "?path=" + Platform.value("api_path") + "&method=" + Platform.value("request_method") + "&api_version=" + Platform.value("api_version");
|
94
|
+
|
95
|
+
for (key in params) {
|
96
|
+
if (key == "") continue;
|
97
|
+
link_location = link_location + "&" + escape(encodeURI(key)) + "=" + escape(encodeURI(params[key]));
|
98
|
+
}
|
99
|
+
|
100
|
+
Platform.element("api_clipboard_text").value = link_location;
|
101
|
+
Platform.element("api_clipboard_text").focus();
|
102
|
+
Platform.element("api_clipboard_text").select();
|
103
|
+
}
|
104
|
+
|
105
|
+
|
106
|
+
function toggleApiOptions(trigger) {
|
107
|
+
Platform.Effects.hide("api_clipboard");
|
108
|
+
Platform.Effects.hide("api_history");
|
109
|
+
|
110
|
+
var options = Platform.element("api_options");
|
111
|
+
|
112
|
+
if (options.style.display == "none") {
|
113
|
+
Platform.element("api_options_container").innerHTML = "<img src='/assets/platform/loading.gif' style='width:16px;vertical-align:middle;'> Loading...";
|
114
|
+
|
115
|
+
var trigger_position = Platform.Utils.cumulativeOffset(trigger);
|
116
|
+
var container_position = {
|
117
|
+
left: trigger_position[0] + trigger.offsetWidth - 765 + 'px',
|
118
|
+
top: trigger_position[1] + trigger.offsetHeight + 10 + 'px'
|
119
|
+
}
|
120
|
+
options.style.left = container_position.left;
|
121
|
+
options.style.top = container_position.top;
|
122
|
+
Platform.Effects.show("api_options");
|
123
|
+
|
124
|
+
Platform.Utils.update("api_options_container", "/platform/developer/api_explorer/options", {
|
125
|
+
parameters: {api_version:Platform.value("api_version")}
|
126
|
+
});
|
127
|
+
|
128
|
+
} else {
|
129
|
+
Platform.Effects.hide("api_options");
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
function switchApiVersion() {
|
134
|
+
var options = Platform.element("api_options");
|
135
|
+
|
136
|
+
if (options.style.display != "none") {
|
137
|
+
Platform.element("api_options_container").innerHTML = "<img src='/assets/platform/loading.gif' style='width:16px;vertical-align:middle;'> Loading...";
|
138
|
+
|
139
|
+
Platform.Utils.update("api_options_container", "/platform/developer/api_explorer/options", {
|
140
|
+
parameters: {
|
141
|
+
api_version: Platform.value("api_version")
|
142
|
+
}
|
143
|
+
});
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
/************************************************************************************
|
148
|
+
** API History Functions
|
149
|
+
************************************************************************************/
|
150
|
+
function clearApiHistory() {
|
151
|
+
setCookie("api_history", "[]");
|
152
|
+
setCookie("api_history_index", "-1");
|
153
|
+
api_history = [];
|
154
|
+
api_history_index = -1;
|
155
|
+
hidePopups();
|
156
|
+
updateHistoryButtons();
|
157
|
+
}
|
158
|
+
|
159
|
+
function callHistoricApi(index) {
|
160
|
+
api_history_index = index;
|
161
|
+
var apic = api_history[api_history_index];
|
162
|
+
updateApi(apic.path, apic.method, apic.params);
|
163
|
+
submitRequest();
|
164
|
+
|
165
|
+
updateHistoryButtons();
|
166
|
+
}
|
167
|
+
|
168
|
+
function makePreviousCall() {
|
169
|
+
if (api_history.length == 0 || api_history_index == 0) return;
|
170
|
+
|
171
|
+
if (api_history_index == -1) {
|
172
|
+
callHistoricApi(api_history.length - 1);
|
173
|
+
return;
|
174
|
+
}
|
175
|
+
|
176
|
+
callHistoricApi(api_history_index - 1);
|
177
|
+
}
|
178
|
+
|
179
|
+
function makeNextCall() {
|
180
|
+
if (api_history.length == 0 || api_history_index == -1) return;
|
181
|
+
if (api_history_index == api_history.length-1) return;
|
182
|
+
|
183
|
+
callHistoricApi(api_history_index + 1);
|
184
|
+
}
|
185
|
+
|
186
|
+
function updateHistoryButtons() {
|
187
|
+
if (api_history_index == -1) {
|
188
|
+
Platform.element("history_next").className = "button super gray small";
|
189
|
+
if (api_history.length == 0) {
|
190
|
+
Platform.element("history_previous").className = "button super gray small";
|
191
|
+
} else {
|
192
|
+
Platform.element("history_previous").className = "button super blue small";
|
193
|
+
}
|
194
|
+
return;
|
195
|
+
}
|
196
|
+
|
197
|
+
if (api_history_index < api_history.length-1) {
|
198
|
+
Platform.element("history_next").className = "button super blue small";
|
199
|
+
} else {
|
200
|
+
Platform.element("history_next").className = "button super gray small";
|
201
|
+
}
|
202
|
+
|
203
|
+
if (api_history_index > 0 && api_history.length > 1) {
|
204
|
+
Platform.element("history_previous").className = "button super blue small";
|
205
|
+
} else {
|
206
|
+
Platform.element("history_previous").className = "button super gray small";
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
210
|
+
function toggleApiHistory(trigger) {
|
211
|
+
Platform.Effects.hide("api_clipboard");
|
212
|
+
Platform.Effects.hide("api_options");
|
213
|
+
|
214
|
+
var options = Platform.element("api_history");
|
215
|
+
Platform.element("api_history_container").innerHTML = "<img src='/assets/platform/loading.gif' style='width:16px;vertical-align:middle;'> Loading...";
|
216
|
+
|
217
|
+
if (options.style.display == "none") {
|
218
|
+
var trigger_position = Platform.Utils.cumulativeOffset(trigger);
|
219
|
+
var container_position = {
|
220
|
+
left: trigger_position[0] + trigger.offsetWidth - 765 + 'px',
|
221
|
+
top: trigger_position[1] + trigger.offsetHeight + 10 + 'px'
|
222
|
+
}
|
223
|
+
options.style.left = container_position.left;
|
224
|
+
options.style.top = container_position.top;
|
225
|
+
Platform.Effects.show("api_history");
|
226
|
+
|
227
|
+
Platform.Utils.update("api_history_container", "/platform/developer/api_explorer/history", {
|
228
|
+
parameters: {api_history_index:api_history_index}
|
229
|
+
});
|
230
|
+
|
231
|
+
} else {
|
232
|
+
Platform.Effects.hide("api_history");
|
233
|
+
}
|
234
|
+
}
|
235
|
+
|
236
|
+
function saveCallToHistory(path, method, params) {
|
237
|
+
if (api_history_index != -1) {
|
238
|
+
updateHistoryButtons();
|
239
|
+
return;
|
240
|
+
}
|
241
|
+
|
242
|
+
if (api_history.length > 0) {
|
243
|
+
var last_call = api_history[api_history.length-1];
|
244
|
+
if (last_call.path == path && last_call.method == method && Platform.Utils.equal(last_call.params, params))
|
245
|
+
return;
|
246
|
+
}
|
247
|
+
|
248
|
+
api_history.push({
|
249
|
+
path: path,
|
250
|
+
method: method,
|
251
|
+
params: params
|
252
|
+
});
|
253
|
+
|
254
|
+
setCookie("api_history", JSON.stringify(api_history));
|
255
|
+
|
256
|
+
if (api_history_index == -1 || api_history_index == (api_history.length-2))
|
257
|
+
api_history_index = api_history.length-1;
|
258
|
+
|
259
|
+
updateHistoryButtons();
|
260
|
+
}
|
261
|
+
|
262
|
+
function setCookie( name, value, expires, path, domain, secure ) {
|
263
|
+
var today = new Date();
|
264
|
+
today.setTime( today.getTime() );
|
265
|
+
|
266
|
+
if (expires) {
|
267
|
+
expires = expires * 1000 * 60 * 60 * 24;
|
268
|
+
}
|
269
|
+
var expires_date = new Date( today.getTime() + (expires) );
|
270
|
+
|
271
|
+
document.cookie = name + "=" +escape( value ) +
|
272
|
+
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
|
273
|
+
( ( path ) ? ";path=" + path : "" ) +
|
274
|
+
( ( domain ) ? ";domain=" + domain : "" ) +
|
275
|
+
( ( secure ) ? ";secure" : "" );
|
276
|
+
}
|
277
|
+
|
278
|
+
|
279
|
+
/************************************************************************************
|
280
|
+
** API Form Functions
|
281
|
+
************************************************************************************/
|
282
|
+
function updateStatus(msg) {
|
283
|
+
Platform.element("status").innerHTML = msg;
|
284
|
+
}
|
285
|
+
|
286
|
+
function logInfo(msg) {
|
287
|
+
updateStatus("<span class='info'>" + msg + "</span>");
|
288
|
+
}
|
289
|
+
|
290
|
+
function logError(msg) {
|
291
|
+
updateStatus("<span class='error'>" + msg + "</span>");
|
292
|
+
}
|
293
|
+
|
294
|
+
function switchRequestMethod() {
|
295
|
+
// if (Platform.value("request_method") == "GET") {
|
296
|
+
// Platform.Effects.hide("post_params");
|
297
|
+
// } else {
|
298
|
+
// Platform.Effects.show("post_params");
|
299
|
+
// }
|
300
|
+
}
|
301
|
+
|
302
|
+
function addPostField(name, value) {
|
303
|
+
var fields = Platform.element("post_fields");
|
304
|
+
var field = document.createElement("div");
|
305
|
+
field.id="field" + field_count;
|
306
|
+
field.className="field";
|
307
|
+
|
308
|
+
var field_name_container = document.createElement("span");
|
309
|
+
field_name_container.className="field_name_container";
|
310
|
+
|
311
|
+
var field_name = document.createElement("input");
|
312
|
+
field_name.type="text";
|
313
|
+
field_name.className="field_name";
|
314
|
+
field_name.id="field_name" + field_count;
|
315
|
+
field_name.label="name";
|
316
|
+
field_name.value = name;
|
317
|
+
field_name_container.appendChild(field_name);
|
318
|
+
field.appendChild(field_name_container);
|
319
|
+
|
320
|
+
var field_value = document.createElement("input");
|
321
|
+
field_value.type="text";
|
322
|
+
field_value.className="field_value";
|
323
|
+
field_value.id="field_value" + field_count;
|
324
|
+
field_value.value = value;
|
325
|
+
field_value.label="value";
|
326
|
+
field.appendChild(field_value);
|
327
|
+
|
328
|
+
var field_action = document.createElement("a");
|
329
|
+
field_action.setAttribute("onclick", "removePostField(" + field_count + "); return false;");
|
330
|
+
field_action.innerHTML="<span>X</span>";
|
331
|
+
field_action.className="field_action";
|
332
|
+
field_action.id="field_action" + field_count;
|
333
|
+
field_action.href="#";
|
334
|
+
field.appendChild(field_action);
|
335
|
+
|
336
|
+
fields.appendChild(field);
|
337
|
+
field_count++;
|
338
|
+
|
339
|
+
Platform.Effects.show("post_params");
|
340
|
+
Platform.Effects.show('remove_all_params_link');
|
341
|
+
}
|
342
|
+
|
343
|
+
function removeAllPostFields() {
|
344
|
+
var fields = Platform.element("post_fields");
|
345
|
+
fields.innerHTML = "";
|
346
|
+
field_count = 0;
|
347
|
+
|
348
|
+
Platform.Effects.hide('remove_all_params_link');
|
349
|
+
}
|
350
|
+
|
351
|
+
function removePostField(field_index) {
|
352
|
+
var fields = Platform.element("post_fields");
|
353
|
+
var field = Platform.element("field" + field_index);
|
354
|
+
fields.removeChild(field);
|
355
|
+
|
356
|
+
field_index ++;
|
357
|
+
var next_field = Platform.element("field" + field_index);
|
358
|
+
while (next_field) {
|
359
|
+
next_field.id="field" + (field_index-1);
|
360
|
+
var field_name = Platform.element("field_name" + field_index);
|
361
|
+
field_name.id="field_name" + (field_index-1);
|
362
|
+
var field_value = Platform.element("field_value" + field_index);
|
363
|
+
field_value.id="field_value" + (field_index-1);
|
364
|
+
var field_action = Platform.element("field_action" + field_index);
|
365
|
+
field_action.id="field_action" + (field_index-1);
|
366
|
+
field_action.setAttribute("onclick", "removePostField(" + (field_index-1) + "); return false;");
|
367
|
+
field_index ++;
|
368
|
+
next_field = Platform.element("field" + field_index);
|
369
|
+
}
|
370
|
+
|
371
|
+
field_count--;
|
372
|
+
|
373
|
+
if (field_count == 0) {
|
374
|
+
Platform.Effects.hide('remove_all_params_link');
|
375
|
+
}
|
376
|
+
}
|
377
|
+
|
378
|
+
/************************************************************************************
|
379
|
+
** API Call Functions
|
380
|
+
************************************************************************************/
|
381
|
+
function generateRequestParams() {
|
382
|
+
var params = {};
|
383
|
+
var field_index = 0;
|
384
|
+
|
385
|
+
var field = Platform.element("field" + field_index);
|
386
|
+
while (field) {
|
387
|
+
var field_name = Platform.value("field_name" + field_index);
|
388
|
+
var field_value = Platform.value("field_value" + field_index);
|
389
|
+
params[field_name] = field_value;
|
390
|
+
|
391
|
+
field_index ++;
|
392
|
+
field = Platform.element("field" + field_index);
|
393
|
+
}
|
394
|
+
|
395
|
+
return params;
|
396
|
+
}
|
397
|
+
|
398
|
+
function submitRequest() {
|
399
|
+
hidePopups();
|
400
|
+
|
401
|
+
logInfo("Executing request...");
|
402
|
+
Platform.element("response_data").innerHTML = "<img src='/assets/platform/loading.gif' style='width:16px;vertical-align:middle;'> Loading...";
|
403
|
+
|
404
|
+
var params = generateRequestParams();
|
405
|
+
// add access token
|
406
|
+
if (Platform.element("access_token") && Platform.value("access_token") != "") {
|
407
|
+
params['access_token'] = Platform.value("access_token");
|
408
|
+
}
|
409
|
+
|
410
|
+
// add version
|
411
|
+
params['api_version'] = Platform.value('api_version');
|
412
|
+
|
413
|
+
// saveCallToHistory(Platform.value("api_path"), Platform.value("request_method"), params);
|
414
|
+
|
415
|
+
var path = Platform.value("api_path");
|
416
|
+
var method = Platform.value("request_method");
|
417
|
+
if (method == 'GET') {
|
418
|
+
var path_params = [];
|
419
|
+
for (key in params) {
|
420
|
+
if (key == "") continue;
|
421
|
+
path_params.push(encodeURI(key) + "=" + encodeURI(params[key]));
|
422
|
+
}
|
423
|
+
path += (path.indexOf("?") == -1) ? "?" : "&";
|
424
|
+
path += path_params.join("&");
|
425
|
+
}
|
426
|
+
|
427
|
+
var t0 = new Date();
|
428
|
+
Platform.Utils.ajax("http://" + base_api_url + "/" + path, {
|
429
|
+
method: method,
|
430
|
+
parameters: params,
|
431
|
+
onSuccess: function(response) {
|
432
|
+
var t1 = new Date();
|
433
|
+
logInfo("Request took " + (t1.getTime() - t0.getTime()) + " milliseconds");
|
434
|
+
formatResponse(response.responseText);
|
435
|
+
},
|
436
|
+
onFailure: function(response) {
|
437
|
+
logError("API call failed with status: " + response.status);
|
438
|
+
formatResponse(response.responseText);
|
439
|
+
}
|
440
|
+
});
|
441
|
+
}
|
442
|
+
|
443
|
+
function updateApi(path, method, params) {
|
444
|
+
hidePopups();
|
445
|
+
|
446
|
+
if (path.indexOf(base_api_url) != -1) {
|
447
|
+
var parts = path.split(base_api_url);
|
448
|
+
path = parts[parts.length-1];
|
449
|
+
}
|
450
|
+
|
451
|
+
logInfo("");
|
452
|
+
Platform.element("response_data").innerHTML = "";
|
453
|
+
Platform.element("api_path").value = path;
|
454
|
+
Platform.element("request_method").value = method;
|
455
|
+
switchRequestMethod();
|
456
|
+
removeAllPostFields();
|
457
|
+
for (key in params) {
|
458
|
+
if (key == 'api_version') continue;
|
459
|
+
addPostField(key, params[key]);
|
460
|
+
}
|
461
|
+
|
462
|
+
if (params['api_version']) {
|
463
|
+
Platform.element('api_version').value = params['api_version'];
|
464
|
+
}
|
465
|
+
}
|
466
|
+
|
467
|
+
function callApi(path, method, params) {
|
468
|
+
api_history_index = -1;
|
469
|
+
updateApi(path, method, params);
|
470
|
+
submitRequest();
|
471
|
+
}
|
472
|
+
|
473
|
+
/************************************************************************************
|
474
|
+
** Format Response Functions
|
475
|
+
************************************************************************************/
|
476
|
+
function S4() {
|
477
|
+
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
|
478
|
+
}
|
479
|
+
|
480
|
+
function guid() {
|
481
|
+
return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
|
482
|
+
}
|
483
|
+
|
484
|
+
function showObject(obj_key, flag) {
|
485
|
+
if (flag) {
|
486
|
+
Platform.Effects.hide("no_object_" + obj_key);
|
487
|
+
Platform.Effects.show("object_" + obj_key);
|
488
|
+
Platform.element("expander_" + obj_key).innerHTML = "<img src='/assets/platform//minus_node.png'>";
|
489
|
+
} else {
|
490
|
+
Platform.Effects.hide("object_" + obj_key);
|
491
|
+
Platform.Effects.show("no_object_" + obj_key);
|
492
|
+
Platform.element("expander_" + obj_key).innerHTML = "<img src='/assets/platform/plus_node.png'>";
|
493
|
+
}
|
494
|
+
}
|
495
|
+
|
496
|
+
function toggleObject(obj_key) {
|
497
|
+
showObject(obj_key, (Platform.element("object_" + obj_key).style.display == 'none'));
|
498
|
+
}
|
499
|
+
|
500
|
+
function expandAllResultObjects(flag) {
|
501
|
+
for (var i=0; i<api_result_object_keys.length; i++) {
|
502
|
+
showObject(api_result_object_keys[i], flag);
|
503
|
+
}
|
504
|
+
}
|
505
|
+
|
506
|
+
function formatResponse(response_text) {
|
507
|
+
api_result_json = response_text;
|
508
|
+
api_result_object_keys = [];
|
509
|
+
|
510
|
+
var response = response_text;
|
511
|
+
|
512
|
+
if (typeof response_text == 'string') {
|
513
|
+
try {
|
514
|
+
response = eval("[" + response_text + "]")[0];
|
515
|
+
}
|
516
|
+
catch (err) {
|
517
|
+
Platform.element("response_data").innerText = response_text;
|
518
|
+
return;
|
519
|
+
}
|
520
|
+
}
|
521
|
+
|
522
|
+
if (typeof response == 'object') {
|
523
|
+
Platform.element("response_data").innerHTML = formatObject(response, 1);
|
524
|
+
} else {
|
525
|
+
Platform.element("response_data").innerHTML = "Invalid response: " + response_text;
|
526
|
+
}
|
527
|
+
}
|
528
|
+
|
529
|
+
function formatObject(obj, level) {
|
530
|
+
if (obj == null) return "{<br>}";
|
531
|
+
|
532
|
+
var html = [];
|
533
|
+
var obj_key = guid();
|
534
|
+
html.push("<span class='expander' id='expander_" + obj_key + "' onClick=\"toggleObject('" + obj_key + "')\"><img src='/assets/platform/minus_node.png'></span> <span style='display:none' id='no_object_" + obj_key + "'>{...}</span> <span id='object_" + obj_key + "'>{");
|
535
|
+
api_result_object_keys.push(obj_key);
|
536
|
+
|
537
|
+
var keys = Object.keys(obj).sort();
|
538
|
+
|
539
|
+
for (var i=0; i<keys.length; i++) {
|
540
|
+
key = keys[i];
|
541
|
+
if (isObject(obj[key])) {
|
542
|
+
if (isArray(obj[key])) {
|
543
|
+
html.push(createSpacer(level) + "<span class='obj_key'>" + key + ":</span>" + formatArray(obj[key], level + 1) + ",");
|
544
|
+
} else {
|
545
|
+
html.push(createSpacer(level) + "<span class='obj_key'>" + key + ":</span>" + formatObject(obj[key], level + 1) + ",");
|
546
|
+
}
|
547
|
+
} else {
|
548
|
+
html.push(createSpacer(level) + formatProperty(key, obj[key]) + ",");
|
549
|
+
}
|
550
|
+
}
|
551
|
+
html.push(createSpacer(level-1) + "}</span>");
|
552
|
+
return html.join("<br>");
|
553
|
+
}
|
554
|
+
|
555
|
+
function formatArray(arr, level) {
|
556
|
+
var html = [];
|
557
|
+
|
558
|
+
var obj_key = guid();
|
559
|
+
html.push("<span class='expander' id='expander_" + obj_key + "' onClick=\"toggleObject('" + obj_key + "')\"><img src='/assets/platform/minus_node.png'></span> <span style='display:none' id='no_object_" + obj_key + "'>[...]</span> <span id='object_" + obj_key + "'>[");
|
560
|
+
api_result_object_keys.push(obj_key);
|
561
|
+
|
562
|
+
for (var i=0; i<arr.length; i++) {
|
563
|
+
if (isObject(arr[i])) {
|
564
|
+
if (isArray(arr[i])) {
|
565
|
+
html.push(createSpacer(level) + formatArray(arr[i], level + 1) + ",");
|
566
|
+
} else {
|
567
|
+
html.push(createSpacer(level) + formatObject(arr[i], level + 1) + ",");
|
568
|
+
}
|
569
|
+
} else {
|
570
|
+
html.push(createSpacer(level) + formatProperty(null, arr[i]) + ",");
|
571
|
+
}
|
572
|
+
}
|
573
|
+
html.push(createSpacer(level-1) + "]</span>");
|
574
|
+
return html.join("<br>");
|
575
|
+
}
|
576
|
+
|
577
|
+
function createSpacer(level) {
|
578
|
+
return "<img src='/assets/platform/pixel.gif' style='height:1px;width:" + (level * 20) + "px;'>";
|
579
|
+
}
|
580
|
+
|
581
|
+
function isArray(obj) {
|
582
|
+
if (obj == null) return false;
|
583
|
+
return !(obj.constructor.toString().indexOf("Array") == -1);
|
584
|
+
}
|
585
|
+
|
586
|
+
function isObject(obj) {
|
587
|
+
if (obj == null) return false;
|
588
|
+
return (typeof obj == 'object');
|
589
|
+
}
|
590
|
+
|
591
|
+
function isString(obj) {
|
592
|
+
return (typeof obj == 'string');
|
593
|
+
}
|
594
|
+
|
595
|
+
function isURL(str) {
|
596
|
+
str = "" + str;
|
597
|
+
return (str.indexOf("http://") != -1) || (str.indexOf("https://") != -1);
|
598
|
+
}
|
599
|
+
|
600
|
+
function isApiCall(str) {
|
601
|
+
str = "" + str;
|
602
|
+
return (str.indexOf(base_api_url) != -1);
|
603
|
+
}
|
604
|
+
|
605
|
+
function formatProperty(key, value) {
|
606
|
+
if (value == null) return "<span class='obj_key'>" + key + ":</span><span class='obj_value_null'>null</span>";
|
607
|
+
|
608
|
+
var cls = "obj_value_" + (typeof value);
|
609
|
+
var value_span = "";
|
610
|
+
|
611
|
+
if (isURL(value)) {
|
612
|
+
if (isApiCall(value)) {
|
613
|
+
value = "<a target='_new' class='api_url' href='#' onclick=\"callApi('" + value + "', 'GET', {}); return false;\">" + value + "</a>";
|
614
|
+
} else {
|
615
|
+
value = "<a target='_new' href='" + value + "'>" + value + "</a>";
|
616
|
+
}
|
617
|
+
}
|
618
|
+
|
619
|
+
if (isString(value))
|
620
|
+
value_span = "<span class='" + cls + "'>\"" + value + "\"</span>";
|
621
|
+
else
|
622
|
+
value_span = "<span class='" + cls + "'>" + value + "</span>";
|
623
|
+
|
624
|
+
if (key == null)
|
625
|
+
return value_span;
|
626
|
+
|
627
|
+
return "<span class='obj_key'>" + key + ":</span>" + value_span;
|
628
|
+
}
|