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
@@ -0,0 +1,45 @@
|
|
1
|
+
module Platform
|
2
|
+
module Api
|
3
|
+
module Proxy
|
4
|
+
|
5
|
+
def self.add(klass, proxy_class)
|
6
|
+
proxy_class.ensure_valid_class_name
|
7
|
+
(Platform::Config.proxies[klass.name] ||= SortedSet.new) << proxy_class
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.proxy_class_for(klass, version=nil)
|
11
|
+
unless proxy_array = proxies_for(klass)
|
12
|
+
raise ArgumentError, "No proxy for class: #{klass.name}"
|
13
|
+
end
|
14
|
+
|
15
|
+
proxy_array = proxy_array.to_a
|
16
|
+
if version.nil?
|
17
|
+
proxy_class = proxy_array.last
|
18
|
+
else
|
19
|
+
version = version.to_i
|
20
|
+
proxy_class = proxy_array.reverse.find {|ii| ii.api_version <= version}
|
21
|
+
end
|
22
|
+
raise ArgumentError "No proxy for version: #{version}" if proxy_class.nil?
|
23
|
+
|
24
|
+
proxy_class
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.for(instance, version=nil)
|
28
|
+
return proxy_class_for(instance.class, version).new(instance)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.reset
|
32
|
+
Platform::Config.proxies.clear
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def self.proxies_for(klass)
|
38
|
+
Platform::Config.load_proxies if Platform::Config.proxies.empty?
|
39
|
+
klass.ancestors.detect {|ii| return Platform::Config.proxies[ii.name] if Platform::Config.proxies.has_key?(ii.name)}
|
40
|
+
return nil
|
41
|
+
end
|
42
|
+
|
43
|
+
end # module Proxy
|
44
|
+
end # module Api
|
45
|
+
end # module Platform
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'platform/api/proxy'
|
2
|
+
|
3
|
+
module Platform
|
4
|
+
module Api
|
5
|
+
module Proxy
|
6
|
+
class Base
|
7
|
+
|
8
|
+
attr_accessor :instance
|
9
|
+
|
10
|
+
def self.proxy_for(klass)
|
11
|
+
Proxy.add(klass, self)
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(instance)
|
15
|
+
@instance = instance
|
16
|
+
end
|
17
|
+
|
18
|
+
def update_attributes!(attrs)
|
19
|
+
instance.update_attributes!(attrs)
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_json(opts={})
|
23
|
+
Api::AlreadyJsonedString.new(to_api_hash(opts).to_json(opts))
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_xml(opts={})
|
27
|
+
opts = opts.dup
|
28
|
+
opts[:root] ||= instance.class.name.underscore.downcase
|
29
|
+
to_api_hash(opts).to_xml(opts)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.<=>(other)
|
33
|
+
api_version <=> other.api_version
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.api_version
|
37
|
+
@api_version ||= begin
|
38
|
+
$1.to_i if name =~ /_(\d+)$/
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.instance_class
|
43
|
+
@klass
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.ensure_valid_class_name
|
47
|
+
raise NameError.new("Proxy class name (#{name}) must end in _<version>") if api_version.nil?
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_api_hash(opts = {})
|
51
|
+
raise NotImplementedError, 'Must be implemented in descendant class'
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_api_path(opts = {})
|
55
|
+
"#{Platform::Config.api_scheme}://#{Platform::Config.api_base_url}/#{instance.class.name.underscore}/#{instance.id}"
|
56
|
+
end
|
57
|
+
|
58
|
+
end # class Base
|
59
|
+
|
60
|
+
end # module Proxy
|
61
|
+
end # module Api
|
62
|
+
end # module Platform
|
@@ -0,0 +1,78 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2011 Michael Berkovich, Geni Inc
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
module Platform
|
25
|
+
class Cache
|
26
|
+
def self.cache
|
27
|
+
@cache ||= begin
|
28
|
+
if Platform::Config.cache_adapter == 'ActiveSupport::Cache'
|
29
|
+
store_params = [Platform::Config.cache_store].flatten
|
30
|
+
store_params[0] = store_params[0].to_sym
|
31
|
+
ActiveSupport::Cache.lookup_store(*store_params)
|
32
|
+
else
|
33
|
+
eval(Platform::Config.cache_adapter)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.enabled?
|
39
|
+
Platform::Config.enable_caching?
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.versioned_key(key)
|
43
|
+
"#{Platform::Config.cache_version}_#{key}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.fetch(key, options = {})
|
47
|
+
return yield unless enabled?
|
48
|
+
cache.fetch(versioned_key(key), options) do
|
49
|
+
yield
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.delete(key, options = nil)
|
54
|
+
return unless enabled?
|
55
|
+
cache.delete(versioned_key(key), options)
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.increment(key, amount = 1)
|
59
|
+
return unless enabled?
|
60
|
+
cache.increment(versioned_key(key), amount)
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.decrement(key, amount = 1)
|
64
|
+
return unless enabled?
|
65
|
+
cache.decrement(versioned_key(key), amount)
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.set(key, value, options = {})
|
69
|
+
return unless enabled?
|
70
|
+
cache.set(key, value, options)
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.get(key, options = {})
|
74
|
+
return unless enabled?
|
75
|
+
cache.get(key, options)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,666 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2011 Michael Berkovich, Geni Inc
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
module Platform
|
25
|
+
class Config
|
26
|
+
|
27
|
+
def self.init(site_current_user, current_application = nil)
|
28
|
+
Thread.current[:platform_current_user] = site_current_user
|
29
|
+
Thread.current[:platform_current_developer] = Platform::Developer.for(site_current_user)
|
30
|
+
Thread.current[:platform_current_application] = current_application
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.current_user
|
34
|
+
Thread.current[:platform_current_user]
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.current_developer
|
38
|
+
Thread.current[:platform_current_developer]
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.current_application
|
42
|
+
Thread.current[:platform_current_application]
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.current_application=(app)
|
46
|
+
Thread.current[:platform_current_application] = app
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.current_user_is_developer?
|
50
|
+
Thread.current[:platform_current_developer] != nil
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.reset!
|
54
|
+
Thread.current[:platform_current_user] = nil
|
55
|
+
Thread.current[:platform_current_developer] = nil
|
56
|
+
Thread.current[:platform_current_application] = nil
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.models
|
60
|
+
@models ||= begin
|
61
|
+
mdls = [
|
62
|
+
Platform::ApplicationDeveloper, Platform::ApplicationPermission, Platform::ApplicationUser,
|
63
|
+
Platform::ApplicationCategory, Platform::Category,
|
64
|
+
Platform::ForumMessage, Platform::ForumTopic,
|
65
|
+
Platform::Permission, Platform::Rating,
|
66
|
+
Platform::Developer, Platform::Application,
|
67
|
+
Platform::Oauth::OauthToken, Platform::Oauth::AccessToken,
|
68
|
+
Platform::Oauth::RequestToken, Platform::Oauth::RefreshToken,
|
69
|
+
Platform::Media::Media, Platform::Media::Image,
|
70
|
+
Platform::ApplicationLog, Platform::RollupLog,
|
71
|
+
Platform::ApplicationMetric, Platform::DailyApplicationMetric,
|
72
|
+
Platform::WeeklyApplicationMetric, Platform::MonthlyApplicationMetric,
|
73
|
+
Platform::TotalApplicationMetric, Platform::ApplicationUsageMetric,
|
74
|
+
Platform::LoggedException
|
75
|
+
]
|
76
|
+
|
77
|
+
if user_class_name == "Platform::PlatformUser" # used for stand-alone deployment only
|
78
|
+
mdls << [Platform::PlatformUser, Platform::PlatformAdmin]
|
79
|
+
end
|
80
|
+
|
81
|
+
mdls.flatten
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.reset_all!
|
86
|
+
models.each do |cls|
|
87
|
+
puts ">> Resetting #{cls.name}..."
|
88
|
+
cls.delete_all
|
89
|
+
end
|
90
|
+
|
91
|
+
init_default_categories
|
92
|
+
init_default_applications
|
93
|
+
|
94
|
+
puts "Done."
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.system_user
|
98
|
+
if user_class_name == "Platform::PlatformUser"
|
99
|
+
@system_user ||= Platform::PlatformUser.first || Platform::PlatformUser.create(:name => "System User")
|
100
|
+
return @system_user
|
101
|
+
end
|
102
|
+
|
103
|
+
return nil unless site_info[:system_user_id]
|
104
|
+
@system_user ||= user_class_name.constantize.find_by_id(site_info[:system_user_id])
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.system_developer
|
108
|
+
@system_developer ||= Platform::Developer.find_or_create(Platform::Config.system_user)
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.init_default_applications
|
112
|
+
puts "Initializing default applications..."
|
113
|
+
unless system_developer
|
114
|
+
puts "Cannot initialize default application because system user id is not specified in the config."
|
115
|
+
return
|
116
|
+
end
|
117
|
+
|
118
|
+
default_applications.each do |keyword, description|
|
119
|
+
category_keywords = description.delete("category_keywords")
|
120
|
+
icon_path = description.delete("icon_path")
|
121
|
+
logo_path = description.delete("logo_path")
|
122
|
+
|
123
|
+
app = Platform::Application.create(description.merge(:developer => system_developer))
|
124
|
+
app.store_icon(File.new("#{root}/#{icon_path}", "r")) if icon_path
|
125
|
+
app.store_logo(File.new("#{root}/#{logo_path}", "r")) if logo_path
|
126
|
+
|
127
|
+
puts "Initialized #{app.name}."
|
128
|
+
app.approve!
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def self.init_default_categories
|
133
|
+
puts "Initializing default categories..."
|
134
|
+
init_categories(Platform::Category.root, default_categories)
|
135
|
+
end
|
136
|
+
|
137
|
+
def self.init_categories(parent, categories)
|
138
|
+
categories.each do |keyword, info|
|
139
|
+
cat = Platform::Category.create(:parent => parent, :keyword => keyword, :name => info[:name], :position => info[:position])
|
140
|
+
init_categories(cat, info[:categories]) if info[:categories]
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def self.default_applications
|
145
|
+
@default_applications ||= load_yml("/config/platform/data/default_applications.yml")
|
146
|
+
end
|
147
|
+
|
148
|
+
def self.default_categories
|
149
|
+
@default_categories ||= load_yml("/config/platform/data/default_categories.yml")
|
150
|
+
end
|
151
|
+
|
152
|
+
def self.root
|
153
|
+
Rails.root
|
154
|
+
end
|
155
|
+
|
156
|
+
def self.env
|
157
|
+
Rails.env
|
158
|
+
end
|
159
|
+
|
160
|
+
def self.load_yml(file_path, for_env = env)
|
161
|
+
yml = YAML.load_file("#{root}#{file_path}")
|
162
|
+
yml = yml[for_env] unless for_env.nil?
|
163
|
+
HashWithIndifferentAccess.new(yml)
|
164
|
+
end
|
165
|
+
|
166
|
+
def self.config
|
167
|
+
@config ||= load_yml("/config/platform/config.yml")
|
168
|
+
end
|
169
|
+
|
170
|
+
def self.enabled?
|
171
|
+
config[:enable_platform]
|
172
|
+
end
|
173
|
+
|
174
|
+
def self.disabled?
|
175
|
+
not enabled?
|
176
|
+
end
|
177
|
+
|
178
|
+
def self.enable_app_directory?
|
179
|
+
config[:enable_app_directory]
|
180
|
+
end
|
181
|
+
|
182
|
+
def self.enable_embedded_applications?
|
183
|
+
config[:enable_embedded_applications]
|
184
|
+
end
|
185
|
+
|
186
|
+
def self.enable_mobile_applications?
|
187
|
+
config[:enable_mobile_applications]
|
188
|
+
end
|
189
|
+
|
190
|
+
def self.enable_developer_agreement?
|
191
|
+
config[:enable_developer_agreement]
|
192
|
+
end
|
193
|
+
|
194
|
+
def self.enable_app_statistics?
|
195
|
+
config[:enable_app_statistics]
|
196
|
+
end
|
197
|
+
|
198
|
+
def self.enable_api_verification?
|
199
|
+
config[:enable_api_verification]
|
200
|
+
end
|
201
|
+
|
202
|
+
def self.default_app_icon
|
203
|
+
"/assets/platform/default_app_icon.gif"
|
204
|
+
end
|
205
|
+
|
206
|
+
def self.default_app_logo
|
207
|
+
"/assets/platform/default_app_logo.gif"
|
208
|
+
end
|
209
|
+
|
210
|
+
#########################################################
|
211
|
+
# Config Sections
|
212
|
+
#########################################################
|
213
|
+
def self.caching
|
214
|
+
config[:caching]
|
215
|
+
end
|
216
|
+
|
217
|
+
def self.logger
|
218
|
+
config[:logger]
|
219
|
+
end
|
220
|
+
|
221
|
+
def self.site_info
|
222
|
+
config[:site_info]
|
223
|
+
end
|
224
|
+
|
225
|
+
def self.api
|
226
|
+
config[:API]
|
227
|
+
end
|
228
|
+
#########################################################
|
229
|
+
|
230
|
+
#########################################################
|
231
|
+
# Caching
|
232
|
+
#########################################################
|
233
|
+
def self.enable_caching?
|
234
|
+
caching[:enabled]
|
235
|
+
end
|
236
|
+
|
237
|
+
def self.cache_adapter
|
238
|
+
caching[:adapter]
|
239
|
+
end
|
240
|
+
|
241
|
+
def self.cache_store
|
242
|
+
caching[:store]
|
243
|
+
end
|
244
|
+
|
245
|
+
def self.cache_version
|
246
|
+
caching[:version]
|
247
|
+
end
|
248
|
+
#########################################################
|
249
|
+
|
250
|
+
#########################################################
|
251
|
+
# Logger
|
252
|
+
#########################################################
|
253
|
+
def self.enable_logger?
|
254
|
+
logger[:enabled]
|
255
|
+
end
|
256
|
+
|
257
|
+
def self.log_path
|
258
|
+
logger[:log_path]
|
259
|
+
end
|
260
|
+
#########################################################
|
261
|
+
|
262
|
+
#########################################################
|
263
|
+
# Site Info
|
264
|
+
def self.site_title
|
265
|
+
site_info[:title]
|
266
|
+
end
|
267
|
+
|
268
|
+
def self.site_logo_url
|
269
|
+
site_info[:logo_url]
|
270
|
+
end
|
271
|
+
|
272
|
+
def self.site_base_url
|
273
|
+
site_info[:base_url]
|
274
|
+
end
|
275
|
+
|
276
|
+
def self.default_url
|
277
|
+
site_info[:default_url]
|
278
|
+
end
|
279
|
+
|
280
|
+
def self.site_layout
|
281
|
+
site_info[:platform_layout]
|
282
|
+
end
|
283
|
+
|
284
|
+
def self.admin_layout
|
285
|
+
site_info[:admin_layout]
|
286
|
+
end
|
287
|
+
|
288
|
+
def self.oauth_web_layout
|
289
|
+
site_info[:oauth_web_layout]
|
290
|
+
end
|
291
|
+
|
292
|
+
def self.oauth_popup_layout
|
293
|
+
site_info[:oauth_popup_layout]
|
294
|
+
end
|
295
|
+
|
296
|
+
def self.oauth_mobile_layout
|
297
|
+
site_info[:oauth_mobile_layout]
|
298
|
+
end
|
299
|
+
|
300
|
+
def self.oauth_desktop_layout
|
301
|
+
site_info[:oauth_desktop_layout]
|
302
|
+
end
|
303
|
+
|
304
|
+
def self.media_directory
|
305
|
+
site_info[:media_directory]
|
306
|
+
end
|
307
|
+
|
308
|
+
def self.media_path
|
309
|
+
"#{root}/public#{media_directory}"
|
310
|
+
end
|
311
|
+
|
312
|
+
def self.helpers
|
313
|
+
return [] unless site_info[:helpers]
|
314
|
+
@tr8n_helpers ||= site_info[:helpers].collect{|helper| helper.to_sym}
|
315
|
+
end
|
316
|
+
|
317
|
+
def self.admin_helpers
|
318
|
+
return [] unless site_info[:admin_helpers]
|
319
|
+
@admin_helpers ||= site_info[:admin_helpers].collect{|helper| helper.to_sym}
|
320
|
+
end
|
321
|
+
|
322
|
+
def self.skip_before_filters
|
323
|
+
return [] unless site_info[:skip_before_filters]
|
324
|
+
@skip_before_filters ||= site_info[:skip_before_filters].collect{|filter| filter.to_sym}
|
325
|
+
end
|
326
|
+
|
327
|
+
def self.before_filters
|
328
|
+
return [] unless site_info[:before_filters]
|
329
|
+
@before_filters ||= site_info[:before_filters].collect{|filter| filter.to_sym}
|
330
|
+
end
|
331
|
+
|
332
|
+
def self.after_filters
|
333
|
+
return [] unless site_info[:after_filters]
|
334
|
+
@after_filters ||= site_info[:after_filters].collect{|filter| filter.to_sym}
|
335
|
+
end
|
336
|
+
|
337
|
+
#########################################################
|
338
|
+
# site user info
|
339
|
+
# The following methods could be overloaded in the initializer
|
340
|
+
#########################################################
|
341
|
+
def self.site_user_info
|
342
|
+
site_info[:user_info]
|
343
|
+
end
|
344
|
+
|
345
|
+
def self.current_user_method
|
346
|
+
site_user_info[:current_user_method]
|
347
|
+
end
|
348
|
+
|
349
|
+
def self.logout_method
|
350
|
+
site_user_info[:logout_method]
|
351
|
+
end
|
352
|
+
|
353
|
+
def self.login_url(params = {})
|
354
|
+
site_info[:login_url] + (site_info[:logout_url].index('?') ? ':' : '?') + params.collect{|n,v| "#{n}=#{CGI.escape(v.to_s)}"}.join('&')
|
355
|
+
end
|
356
|
+
|
357
|
+
def self.logout_url(params = {})
|
358
|
+
site_info[:logout_url] + (site_info[:logout_url].index('?') ? ':' : '?') + params.collect{|n,v| "#{n}=#{CGI.escape(v.to_s)}"}.join('&')
|
359
|
+
end
|
360
|
+
|
361
|
+
def self.site_user_info_enabled?
|
362
|
+
site_user_info[:enabled].nil? ? true : site_user_info[:enabled]
|
363
|
+
end
|
364
|
+
|
365
|
+
def self.site_user_info_disabled?
|
366
|
+
!site_user_info_enabled?
|
367
|
+
end
|
368
|
+
|
369
|
+
def self.user_class_name
|
370
|
+
return site_user_info[:class_name] if site_user_info_enabled?
|
371
|
+
"Platform::PlatformUser"
|
372
|
+
end
|
373
|
+
|
374
|
+
def self.user_class
|
375
|
+
user_class_name.constantize
|
376
|
+
end
|
377
|
+
|
378
|
+
def self.user_id(user = current_user)
|
379
|
+
user.send(site_user_info[:methods][:id])
|
380
|
+
rescue Exception => ex
|
381
|
+
Platform::Logger.error("Failed to fetch user id: #{ex.to_s}")
|
382
|
+
0
|
383
|
+
end
|
384
|
+
|
385
|
+
def self.user_name(user = current_user)
|
386
|
+
user.send(site_user_info[:methods][:name])
|
387
|
+
rescue Exception => ex
|
388
|
+
Platform::Logger.error("Failed to fetch #{user_class_name} name: #{ex.to_s}")
|
389
|
+
"Unknown user"
|
390
|
+
end
|
391
|
+
|
392
|
+
def self.user_email(user = current_user)
|
393
|
+
user.send(site_user_info[:methods][:email])
|
394
|
+
rescue Exception => ex
|
395
|
+
Platform::Logger.error("Failed to fetch #{user_class_name} name: #{ex.to_s}")
|
396
|
+
nil
|
397
|
+
end
|
398
|
+
|
399
|
+
def self.user_gender(user = current_user)
|
400
|
+
user.send(site_user_info[:methods][:gender])
|
401
|
+
rescue Exception => ex
|
402
|
+
Platform::Logger.error("Failed to fetch #{user_class_name} name: #{ex.to_s}")
|
403
|
+
"unknown"
|
404
|
+
end
|
405
|
+
|
406
|
+
def self.user_mugshot(user = current_user)
|
407
|
+
mugshot_image = user.send(site_user_info[:methods][:mugshot])
|
408
|
+
return silhouette_image(user) if mugshot_image.blank?
|
409
|
+
mugshot_image
|
410
|
+
rescue Exception => ex
|
411
|
+
Platform::Logger.error("Failed to fetch #{user_class_name} image: #{ex.to_s}")
|
412
|
+
silhouette_image
|
413
|
+
end
|
414
|
+
|
415
|
+
def self.user_link(user = current_user)
|
416
|
+
user.send(site_user_info[:methods][:link])
|
417
|
+
rescue Exception => ex
|
418
|
+
Platform::Logger.error("Failed to fetch #{user_class_name} link: #{ex.to_s}")
|
419
|
+
"/tr8n"
|
420
|
+
end
|
421
|
+
|
422
|
+
def self.user_locale(user = current_user)
|
423
|
+
user.send(site_user_info[:methods][:locale])
|
424
|
+
rescue Exception => ex
|
425
|
+
Platform::Logger.error("Failed to fetch #{user_class_name} locale: #{ex.to_s}")
|
426
|
+
default_locale
|
427
|
+
end
|
428
|
+
|
429
|
+
def self.admin_user?(user = current_user)
|
430
|
+
user.send(site_user_info[:methods][:admin])
|
431
|
+
rescue Exception => ex
|
432
|
+
Platform::Logger.error("Failed to fetch #{user_class_name} admin flag: #{ex.to_s}")
|
433
|
+
false
|
434
|
+
end
|
435
|
+
|
436
|
+
def self.current_user_is_admin?
|
437
|
+
admin_user?
|
438
|
+
end
|
439
|
+
|
440
|
+
def self.guest_user?(user = current_user)
|
441
|
+
return true unless user
|
442
|
+
user.send(site_user_info[:methods][:guest])
|
443
|
+
rescue Exception => ex
|
444
|
+
Platform::Logger.error("Failed to fetch #{user_class_name} guest flag: #{ex.to_s}")
|
445
|
+
true
|
446
|
+
end
|
447
|
+
|
448
|
+
def self.current_user_is_guest?
|
449
|
+
guest_user?
|
450
|
+
end
|
451
|
+
#########################################################
|
452
|
+
|
453
|
+
#########################################################
|
454
|
+
# site media info
|
455
|
+
# The following methods could be overloaded in the initializer
|
456
|
+
#########################################################
|
457
|
+
def self.site_media_info
|
458
|
+
site_info[:media_info]
|
459
|
+
end
|
460
|
+
|
461
|
+
def self.site_media_enabled?
|
462
|
+
site_media_info[:enabled]
|
463
|
+
end
|
464
|
+
|
465
|
+
def self.site_media_class
|
466
|
+
return "Platform::Media::Image" unless site_media_enabled?
|
467
|
+
site_media_info[:class_name]
|
468
|
+
end
|
469
|
+
|
470
|
+
def self.site_media_write_method
|
471
|
+
site_media_info[:write_method]
|
472
|
+
end
|
473
|
+
|
474
|
+
def self.create_media(file)
|
475
|
+
media = site_media_class.constantize.create
|
476
|
+
media.send(site_media_write_method, file)
|
477
|
+
media
|
478
|
+
rescue Exception => ex
|
479
|
+
pp ex
|
480
|
+
Platform::Logger.error("Failed to create media: #{ex.to_s}")
|
481
|
+
nil
|
482
|
+
end
|
483
|
+
|
484
|
+
def self.logo_url(media)
|
485
|
+
eval("media.#{site_media_info[:logo_url_method]}")
|
486
|
+
rescue Exception => ex
|
487
|
+
Platform::Logger.error("Failed to fetch logo url: #{ex.to_s}")
|
488
|
+
default_app_logo
|
489
|
+
end
|
490
|
+
|
491
|
+
def self.icon_url(media)
|
492
|
+
eval("media.#{site_media_info[:icon_url_method]}")
|
493
|
+
rescue Exception => ex
|
494
|
+
Platform::Logger.error("Failed to fetch icon url: #{ex.to_s}")
|
495
|
+
default_app_icon
|
496
|
+
end
|
497
|
+
#########################################################
|
498
|
+
|
499
|
+
#########################################################
|
500
|
+
# Application Directory
|
501
|
+
#########################################################
|
502
|
+
def self.featured_apps_enabled?
|
503
|
+
true
|
504
|
+
end
|
505
|
+
|
506
|
+
def self.featured_apps_title
|
507
|
+
"Featured Applications"
|
508
|
+
end
|
509
|
+
|
510
|
+
def self.featured_apps_per_row
|
511
|
+
2
|
512
|
+
end
|
513
|
+
|
514
|
+
def self.featured_apps_per_page
|
515
|
+
2
|
516
|
+
end
|
517
|
+
|
518
|
+
def self.suggested_apps_title
|
519
|
+
"Applications You May Like"
|
520
|
+
end
|
521
|
+
|
522
|
+
def self.suggested_apps_per_row
|
523
|
+
5
|
524
|
+
end
|
525
|
+
|
526
|
+
def self.suggested_apps_per_page
|
527
|
+
20
|
528
|
+
end
|
529
|
+
|
530
|
+
def self.searched_apps_title
|
531
|
+
"Search Results"
|
532
|
+
end
|
533
|
+
|
534
|
+
def self.searched_apps_per_page
|
535
|
+
15
|
536
|
+
end
|
537
|
+
|
538
|
+
#########################################################
|
539
|
+
# API
|
540
|
+
#########################################################
|
541
|
+
def self.enable_api?
|
542
|
+
api[:enabled]
|
543
|
+
end
|
544
|
+
|
545
|
+
def self.api_config_path
|
546
|
+
api[:config_path]
|
547
|
+
end
|
548
|
+
|
549
|
+
def self.api_logging_enabled?
|
550
|
+
api[:logging_enabled]
|
551
|
+
end
|
552
|
+
|
553
|
+
def self.api_request_limit
|
554
|
+
api[:request_limit]
|
555
|
+
end
|
556
|
+
|
557
|
+
def self.api_cookies_enabled?
|
558
|
+
api[:cookies_enabled]
|
559
|
+
end
|
560
|
+
|
561
|
+
def self.api_allow_public?
|
562
|
+
api[:allow_public]
|
563
|
+
end
|
564
|
+
|
565
|
+
def self.api_max_models
|
566
|
+
api[:max_models]
|
567
|
+
end
|
568
|
+
|
569
|
+
def self.api_request_window
|
570
|
+
api[:request_window]
|
571
|
+
end
|
572
|
+
|
573
|
+
def self.api_token_lifetime
|
574
|
+
api[:token_lifetime]
|
575
|
+
end
|
576
|
+
|
577
|
+
def self.api_request_limit
|
578
|
+
api[:request_limit]
|
579
|
+
end
|
580
|
+
|
581
|
+
def self.api_base_url
|
582
|
+
api[:base_url]
|
583
|
+
end
|
584
|
+
|
585
|
+
def self.api_scheme
|
586
|
+
api[:scheme]
|
587
|
+
end
|
588
|
+
|
589
|
+
def self.api_supported_versions
|
590
|
+
api[:supported_versions]
|
591
|
+
end
|
592
|
+
|
593
|
+
def self.api_supported_version_options
|
594
|
+
@api_supported_version_options ||= api[:supported_versions].collect{|v| ["v #{v}", v]}
|
595
|
+
end
|
596
|
+
|
597
|
+
def self.api_default_version
|
598
|
+
api[:default_version]
|
599
|
+
end
|
600
|
+
|
601
|
+
def self.api_explorer_app_id
|
602
|
+
config[:api_explorer_app_id]
|
603
|
+
end
|
604
|
+
|
605
|
+
def self.api_explorer_app?
|
606
|
+
!api_explorer_app_id.blank?
|
607
|
+
end
|
608
|
+
|
609
|
+
def self.proxies_path
|
610
|
+
api[:proxies_path]
|
611
|
+
end
|
612
|
+
|
613
|
+
def self.load_proxies
|
614
|
+
Dir["#{root}/#{proxies_path}/*_proxy_*.rb"].each do |file|
|
615
|
+
require_or_load file
|
616
|
+
end
|
617
|
+
end
|
618
|
+
|
619
|
+
def self.proxies
|
620
|
+
@proxies ||= {}
|
621
|
+
end
|
622
|
+
|
623
|
+
#########################################################
|
624
|
+
# API References
|
625
|
+
#########################################################
|
626
|
+
|
627
|
+
def self.api_reference(api_version = api_default_version)
|
628
|
+
@api_reference ||= begin
|
629
|
+
ref = HashWithIndifferentAccess.new
|
630
|
+
api_supported_versions.each do |version|
|
631
|
+
ref[version] = {}
|
632
|
+
path = "#{root}/#{api[:config_path]}/#{version}"
|
633
|
+
files = Dir.glob("#{path}/*.yml")
|
634
|
+
files.each do |file|
|
635
|
+
ref[version].merge!(YAML.load_file(file))
|
636
|
+
end
|
637
|
+
end
|
638
|
+
ref.freeze
|
639
|
+
end
|
640
|
+
@api_reference[api_version]
|
641
|
+
end
|
642
|
+
|
643
|
+
def self.api_explorer_groups(api_version = api_default_version)
|
644
|
+
api[:explorer_groups][api_version]
|
645
|
+
end
|
646
|
+
|
647
|
+
#########################################################
|
648
|
+
|
649
|
+
def self.silhouette_image(user = current_user)
|
650
|
+
"/assets/platform/photo_silhouette.gif"
|
651
|
+
end
|
652
|
+
|
653
|
+
def self.features
|
654
|
+
@features ||= begin
|
655
|
+
defs = load_yml("/config/platform/site/features.yml")
|
656
|
+
feats = []
|
657
|
+
defs[:enabled_features].each do |key|
|
658
|
+
defs[key][:key] = key
|
659
|
+
feats << defs[key]
|
660
|
+
end
|
661
|
+
feats
|
662
|
+
end
|
663
|
+
end
|
664
|
+
|
665
|
+
end
|
666
|
+
end
|