platform 3.1.1 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/Gemfile.lock +1 -3
  2. data/README.rdoc +140 -3
  3. data/app/assets/images/platform/help/app_reg.png +0 -0
  4. data/app/assets/images/platform/help/app_reg_ext.png +0 -0
  5. data/app/assets/images/platform/help/app_reg_web.png +0 -0
  6. data/app/assets/images/platform/help/auth_desktop.png +0 -0
  7. data/app/assets/images/platform/help/auth_iframe.png +0 -0
  8. data/app/assets/images/platform/help/auth_iphone.png +0 -0
  9. data/app/assets/images/platform/help/auth_web.png +0 -0
  10. data/app/assets/images/platform/help/authorize.png +0 -0
  11. data/app/assets/images/platform/help/ext.png +0 -0
  12. data/app/assets/images/platform/help/login_desktop.png +0 -0
  13. data/app/assets/images/platform/help/login_iphone.png +0 -0
  14. data/app/assets/images/platform/help/login_web.png +0 -0
  15. data/app/assets/images/platform/help/register_desktop.png +0 -0
  16. data/app/assets/images/platform/help/register_iphone.png +0 -0
  17. data/app/assets/javascripts/platform/platform.js +1 -1
  18. data/app/controllers/platform/api/base_controller.rb +24 -14
  19. data/app/controllers/platform/apps_controller.rb +16 -0
  20. data/app/controllers/platform/developer/help_controller.rb +2 -15
  21. data/app/controllers/platform/oauth_controller.rb +3 -3
  22. data/app/helpers/platform/admin/categories_helper.rb +1 -1
  23. data/app/helpers/platform/developer/help_helper.rb +2 -1
  24. data/app/models/platform/application.rb +2 -0
  25. data/app/models/platform/developer.rb +2 -0
  26. data/app/models/platform/logged_exception.rb +1 -1
  27. data/app/views/platform/admin/clientsdk/index.html.erb +12 -12
  28. data/app/views/platform/apps/_search_apps_module.html.erb +1 -1
  29. data/app/views/platform/apps/settings.html.erb +77 -0
  30. data/app/views/platform/developer/api_explorer/options.html.erb +0 -2
  31. data/app/views/platform/developer/dashboard/index.html.erb +1 -1
  32. data/app/views/platform/developer/help/_navigation.html.erb +1 -1
  33. data/app/views/platform/developer/help/oauth_client_side.html.erb +17 -15
  34. data/app/views/platform/developer/help/oauth_extensions.html.erb +1 -1
  35. data/app/views/platform/developer/help/oauth_mobile.html.erb +12 -12
  36. data/app/views/platform/developer/help/oauth_server_side.html.erb +6 -6
  37. data/app/views/platform/developer/help/sdk_ios.html.erb +3 -3
  38. data/app/views/platform/developer/help/sdk_js.html.erb +13 -185
  39. data/app/views/platform/developer/info/_basic_info.html.erb +1 -1
  40. data/app/views/platform/developer/info/_header.html.erb +3 -3
  41. data/app/views/platform/developer/registration/index.html.erb +30 -30
  42. data/app/views/platform/oauth/_authorization_box.html.erb +6 -7
  43. data/app/views/platform/oauth/_authorization_popup.html.erb +1 -1
  44. data/app/views/platform/oauth/authorize_desktop.html.erb +1 -76
  45. data/config/routes.rb +2 -4
  46. data/lib/generators/platform/proxy_generator.rb +78 -0
  47. data/lib/generators/platform/templates/config/platform/api/0/platform.yml +55 -0
  48. data/lib/generators/platform/templates/config/platform/api/0/platform_application.yml +37 -0
  49. data/lib/generators/platform/templates/config/platform/api/0/platform_developer.yml +22 -0
  50. data/{config → lib/generators/platform/templates/config}/platform/config.yml +22 -19
  51. data/{config → lib/generators/platform/templates/config}/platform/data/default_applications.yml +0 -0
  52. data/{config → lib/generators/platform/templates/config}/platform/data/default_categories.yml +0 -0
  53. data/{config → lib/generators/platform/templates/config}/platform/data/default_permissions.yml +0 -0
  54. data/{config → lib/generators/platform/templates/config}/platform/site/features.yml +0 -0
  55. data/lib/platform.rb +23 -0
  56. data/lib/platform/api/proxy/base.rb +5 -2
  57. data/lib/platform/cache.rb +1 -1
  58. data/lib/platform/config.rb +20 -3
  59. data/lib/platform/engine.rb +23 -0
  60. data/lib/platform/exception.rb +1 -1
  61. data/lib/platform/extensions/action_view_extension.rb +25 -0
  62. data/lib/platform/helper.rb +1 -1
  63. data/lib/platform/logger.rb +1 -1
  64. data/lib/platform/random_password_generator.rb +1 -1
  65. data/lib/platform/simple_string_permissions.rb +1 -1
  66. data/lib/platform/version.rb +24 -1
  67. data/lib/tasks/platform.rake +1 -1
  68. data/platform.gemspec +1 -1
  69. data/test/dummy/.pryrc +15 -0
  70. data/test/dummy/app/controllers/api/base_controller.rb +0 -1
  71. data/test/dummy/app/controllers/api/bookmarks_controller.rb +6 -1
  72. data/{app/controllers/platform/developer/resources_controller.rb → test/dummy/app/controllers/api/platform_controller.rb} +16 -2
  73. data/test/dummy/app/controllers/api/users_controller.rb +1 -0
  74. data/test/dummy/app/controllers/login_controller.rb +2 -1
  75. data/test/dummy/app/models/user.rb +8 -0
  76. data/test/dummy/app/views/layouts/_header.html.erb +1 -0
  77. data/test/dummy/app/views/layouts/blank.html.erb +24 -0
  78. data/test/dummy/app/views/layouts/mobile.html.erb +68 -0
  79. data/test/dummy/app/views/login/index.html.erb +1 -2
  80. data/test/dummy/app/views/login/register.html.erb +3 -3
  81. data/test/dummy/config/application.rb +1 -1
  82. data/test/dummy/config/platform/api/1/bookmark.yml +23 -3
  83. data/test/dummy/config/platform/api/1/platform.yml +55 -0
  84. data/test/dummy/config/platform/api/1/platform_application.yml +37 -0
  85. data/test/dummy/config/platform/api/1/platform_developer.yml +22 -0
  86. data/test/dummy/config/platform/api/1/user.yml +1 -1
  87. data/test/dummy/config/platform/config.yml +5 -4
  88. data/test/dummy/config/routes.rb +4 -0
  89. data/test/dummy/config/tr8n/config.yml +1 -1
  90. data/test/dummy/lib/platform/api/platform_application_proxy_0.rb +28 -0
  91. data/test/dummy/lib/platform/api/platform_developer_proxy_0.rb +19 -0
  92. metadata +72 -65
  93. data/app/assets/images/platform/help/login.png +0 -0
  94. data/app/assets/javascripts/platform/jsdk.js +0 -539
  95. data/app/controllers/platform/api/apps_controller.rb +0 -40
  96. data/app/views/platform/developer/resources/index.html.erb +0 -23
  97. data/test/dummy/config/platform/site/sample_apps.yml +0 -100
@@ -6,6 +6,7 @@ class Api::UsersController < Api::BaseController
6
6
  end
7
7
 
8
8
  def bookmarks
9
+ ensure_logged_in
9
10
  ensure_get
10
11
  render_response current_user.bookmarks
11
12
  end
@@ -41,7 +41,8 @@ class LoginController < ApplicationController
41
41
  private
42
42
 
43
43
  def login_layout
44
- return 'minimal' if ['mobile', 'popup'].include?(params[:display])
44
+ return 'mobile' if params[:display] == 'mobile'
45
+ return 'minimal' if params[:display] == 'popup'
45
46
  'application'
46
47
  end
47
48
 
@@ -31,4 +31,12 @@ class User < ActiveRecord::Base
31
31
  name
32
32
  end
33
33
 
34
+ def mugshot
35
+ default_url = "http://#{Platform::Config.site_base_url}#{Platform::Config.silhouette_image}"
36
+ pp default_url
37
+ return default_url
38
+ gravatar_id = Digest::MD5.hexdigest(email.downcase)
39
+ "http://gravatar.com/avatar/#{gravatar_id}.png?s=48&d=#{CGI.escape(default_url)}"
40
+ end
41
+
34
42
  end
@@ -6,6 +6,7 @@
6
6
  <li><%=link_to(tr("Login"), "/login")%></li>
7
7
  <% else %>
8
8
  <li><%=tr("Welcome {user}!", "", :user => [current_user, current_user.name]) %></li>
9
+ <li><%=link_to(tr("My Apps"), "/platform/apps/settings") %></li>
9
10
  <li><%=link_to(tr("Logout"), "/login/out")%></li>
10
11
  <% end %>
11
12
  <li><%= tr8n_language_selector_tag(:lightbox=>false) %></li>
@@ -0,0 +1,24 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
+ <head>
4
+ <title><%=trl("Platform Sample Application", "Application title")%></title>
5
+ <%= stylesheet_link_tag "application" %>
6
+ <%= javascript_include_tag "application" %>
7
+ <%= csrf_meta_tag %>
8
+ <%= tr8n_scripts_tag %>
9
+ <style>
10
+ .page_fixed {
11
+ width:100%;
12
+ }
13
+ </style>
14
+ </head>
15
+ <body style="background-color:white">
16
+ <div class="document">
17
+ <div class="page_fixed">
18
+ <div class="page_body">
19
+ <%= yield %>
20
+ </div>
21
+ </div>
22
+ </div>
23
+ </body>
24
+ </html>
@@ -0,0 +1,68 @@
1
+ <!DOCTYPE html>
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" <%= "dir='rtl'" if Tr8n::Config.current_language.right_to_left? %>>
3
+
4
+ <head>
5
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
6
+ <meta content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=0;" name="viewport">
7
+ <%= csrf_meta_tag %>
8
+
9
+ <style>
10
+ body {font-family: helvetica, sans-serif;-webkit-text-size-adjust: none;width:100%;min-width:320px;font-size:16px;margin:0px;padding:0px;}
11
+ h1,.h1 {font:bold normal 28px Helvetica, sans-serif;}
12
+ h2,.h2 {font:normal normal 20px Helvetica, sans-serif;}
13
+ h3,.h3 {font:normal normal 20px Helvetica, sans-serif;}
14
+ h4,.h4 {font:normal bold 17px Helvetica, sans-serif}
15
+ h5,.h5 {font:normal bold 15px Helvetica, sans-serif;}
16
+ h6,.h6 {font:normal bold 15px Helvetica, sans-serif;}
17
+
18
+ .super {font-size:64px;}
19
+ .xlarge {font-size:18px;}
20
+ .large {font-size:17px;}
21
+ .normal {font-size:16px;}
22
+ .small {font-size:15px;letter-spacing:normal;}
23
+ .xsmall {font-size:14px;}
24
+
25
+ /* Forms */
26
+
27
+ .field {margin:0 0 0.5em 0;}
28
+ .field_hd {}
29
+ .field_bd {}
30
+
31
+ input[type='text'],
32
+ input[type='password'],
33
+ input[type='email'],
34
+ textarea {width:95%;font-size:16px;font-family:Helvetica, sans-serif;padding:4px;margin:0px;border-color:#aaa #999 #999 #aaa;}
35
+
36
+ .module {
37
+ margin:10px;
38
+ }
39
+ .field_bd {
40
+ text-align:left;
41
+ }
42
+ .content_hd {
43
+ font-weight:bold;
44
+ }
45
+ .content_bd {
46
+ text-align:left;
47
+ }
48
+ .buttons {
49
+ text-align:center;
50
+ }
51
+ a {
52
+ text-decoration:none;
53
+ }
54
+ </style>
55
+ </head>
56
+ <body style="background-color: white;">
57
+ <div style="background-color:#eee;padding:10px;font-size:24px;font-weight:bold;border-bottom:1px solid #DDDDDD;border-top:4px solid #6699CC;">
58
+ <%=Platform::Config.site_title%>
59
+ </div>
60
+ <div class="module">
61
+ <div style="text-align:center">
62
+ <%= tr8n_flashes_tag %>
63
+ </div>
64
+
65
+ <%= yield %>
66
+ </div>
67
+ </body>
68
+ </html>
@@ -1,8 +1,7 @@
1
1
  <h2 class="underscore content_hd">
2
- <%=tr('Login to Platform Engine Sample Application') %>
2
+ <%=tr('Login to Sample Application') %>
3
3
  </h2>
4
4
  <div class="content_bd">
5
-
6
5
  <div class="page_form">
7
6
  <%= form_tag(:controller=>:login, :action=>:index) do %>
8
7
  <%=hidden_field_tag(:display, params[:display])%>
@@ -1,5 +1,5 @@
1
1
  <h2 class="underscore content_hd">
2
- <%=tr('Register for Platform Developer Account') %>
2
+ <%=tr('Register for new Account') %>
3
3
  </h2>
4
4
  <div class="content_bd">
5
5
  <div class="page_form">
@@ -9,13 +9,13 @@
9
9
  <div class="field">
10
10
  <div class="strong field_hd txt_r h4"><%=tr('Email:') %></div>
11
11
  <div class="field_bd">
12
- <%=text_field_tag :email, params[:email], :class => "xlong_input h4" %> &nbsp; *
12
+ <%=text_field_tag :email, params[:email], :class => "xlong_input h4" %>
13
13
  </div>
14
14
  </div>
15
15
  <div class="field">
16
16
  <div class="strong field_hd txt_r h4"><%=tr('Password:') %></div>
17
17
  <div class="field_bd">
18
- <%=password_field_tag :password, "", :class => "xlong_input h4"%> &nbsp; *
18
+ <%=password_field_tag :password, "", :class => "xlong_input h4"%>
19
19
  </div>
20
20
  </div>
21
21
  <div class="field">
@@ -9,7 +9,7 @@ require "kaminari"
9
9
  require "platform"
10
10
  require "acts_as_tree"
11
11
  require "acts_as_state_machine"
12
- require "rmagick"
12
+ # require "rmagick"
13
13
 
14
14
  module Dummy
15
15
  class Application < Rails::Application
@@ -23,7 +23,7 @@ bookmark:
23
23
  method: GET
24
24
  status: added
25
25
  description: "Adds a bookmark."
26
- sample: "http://localhost:3000/api/bookmark?title=Google&url=www.google.com"
26
+ sample: "http://localhost:3000/api/bookmark/create?title=Google&url=www.google.com"
27
27
  params:
28
28
  title:
29
29
  description: "The bookmark's title"
@@ -33,7 +33,17 @@ bookmark:
33
33
  description: "The bookmark's url"
34
34
  type: "String"
35
35
  required: true
36
- fields: "*"
36
+ fields:
37
+ title:
38
+ description: "The bookmark's title"
39
+ type: "String"
40
+ url:
41
+ description: "The bookmark's url"
42
+ type: "String"
43
+ created_at:
44
+ description: "The bookmark's creation date as a timestamp"
45
+ type: "Number"
46
+ status: updated
37
47
  update:
38
48
  path: "bookmark/update"
39
49
  method: GET
@@ -49,7 +59,17 @@ bookmark:
49
59
  description: "The bookmark's url"
50
60
  type: "String"
51
61
  required: true
52
- fields: "*"
62
+ fields:
63
+ title:
64
+ description: "The bookmark's title"
65
+ type: "String"
66
+ url:
67
+ description: "The bookmark's url"
68
+ type: "String"
69
+ created_at:
70
+ description: "The bookmark's creation date as a timestamp"
71
+ type: "Number"
72
+ status: updated
53
73
  delete:
54
74
  path: "bookmark/delete"
55
75
  method: POST
@@ -0,0 +1,55 @@
1
+ platform:
2
+ type: "api"
3
+ path: "platform"
4
+ sample: "http://localhost:3000/api/platform"
5
+ description: "Returns status of the platform."
6
+
7
+ fields:
8
+ status:
9
+ description: "The platform status"
10
+ type: "String"
11
+
12
+ actions:
13
+ apps:
14
+ path: "platform/apps"
15
+ method: GET
16
+ description: "Returns list of all registered applications."
17
+ sample: "http://localhost:3000/api/platform/apps"
18
+ params:
19
+ limit:
20
+ description: "How many applications to display per page"
21
+ type: "Number"
22
+ required: false
23
+ page:
24
+ description: "Which page to display"
25
+ type: "Number"
26
+ required: false
27
+ fields:
28
+ results:
29
+ description: "List of platform applications"
30
+ type: "Array"
31
+ array_type: "PlatformApplication"
32
+ page:
33
+ description: "Current page"
34
+ type: "Number"
35
+ next_page:
36
+ description: "Url for the next page"
37
+ type: "String"
38
+ previous_page:
39
+ description: "Url for the previous page"
40
+ type: "String"
41
+
42
+ services:
43
+ path: "platform/services"
44
+ method: GET
45
+ description: "Returns a list of all available APIs on this platform."
46
+ sample: "http://localhost:3000/api/platform/services"
47
+ params:
48
+ version:
49
+ description: "Version of the API services."
50
+ type: "String"
51
+ required: false
52
+ fields:
53
+ results:
54
+ description: "Hash representation of available platform API services."
55
+ type: "Hash"
@@ -0,0 +1,37 @@
1
+ platform_application:
2
+ type: "struct"
3
+ title: "Platform Application"
4
+ path: "platform/application"
5
+ description: "Returns information about an application."
6
+
7
+ fields:
8
+ name:
9
+ description: "The application's name"
10
+ type: "String"
11
+ description:
12
+ description: "The application's description"
13
+ type: "String"
14
+ url:
15
+ description: "The application's url"
16
+ type: "String"
17
+ icon_url:
18
+ description: "The application's icon url"
19
+ type: "String"
20
+ logo_url:
21
+ description: "The application's logo url"
22
+ type: "String"
23
+ locale:
24
+ description: "The application's locale"
25
+ type: "String"
26
+ privacy_policy_url:
27
+ description: "The application's privacy policy"
28
+ type: "String"
29
+ terms_of_service_url:
30
+ description: "The application's terms of service"
31
+ type: "String"
32
+ created_at:
33
+ description: "The application's creation timestamp"
34
+ type: "Number"
35
+ developer:
36
+ description: "The application's developer"
37
+ type: "PlatformDeveloper"
@@ -0,0 +1,22 @@
1
+ platform_developer:
2
+ type: "struct"
3
+ title: "Platform Developer"
4
+ path: "platform/developer"
5
+ description: "Returns information about a developer."
6
+
7
+ fields:
8
+ id:
9
+ description: "The developer's id"
10
+ type: "Number"
11
+ name:
12
+ description: "The developer's name"
13
+ type: "String"
14
+ about:
15
+ description: "The developer's description"
16
+ type: "String"
17
+ url:
18
+ description: "The developer's url"
19
+ type: "String"
20
+ created_at:
21
+ description: "The developer's creation timestamp"
22
+ type: "Number"
@@ -28,7 +28,7 @@ user:
28
28
  method: GET
29
29
  status: added
30
30
  description: "Gets a list of user's bookmark."
31
- sample: "http://localhost:3000/user/bookmarks"
31
+ sample: "http://localhost:3000/api/user/bookmarks"
32
32
  fields:
33
33
  results:
34
34
  description: "List of user's bookmarks"
@@ -55,7 +55,7 @@ defaults: &defaults
55
55
  title: "Sample Application"
56
56
  logo_url: "/assets/platform/platform5.png"
57
57
  base_url: "localhost:3000"
58
- contact_email: platform@geni.com
58
+ contact_email: feedback@oauthx.com
59
59
  default_url: "/home"
60
60
  login_url: "/login"
61
61
  logout_url: "/login/out"
@@ -63,7 +63,8 @@ defaults: &defaults
63
63
  admin_layout: admin
64
64
  oauth_web_layout: minimal
65
65
  oauth_popup_layout: popup
66
- oauth_mobile_layout: popup
66
+ oauth_iframe_layout: blank
67
+ oauth_mobile_layout: mobile
67
68
  oauth_desktop_layout: popup
68
69
  system_user_id: 10
69
70
  media_directory: "/media/p1"
@@ -97,7 +98,7 @@ defaults: &defaults
97
98
  config_path: "config/platform/api"
98
99
  proxies_path: "lib/platform/api"
99
100
  logging_enabled: true
100
- admin_email: scott.steadman@geni.com
101
+ admin_email: feedback@oauthx.com
101
102
  allow_public: true
102
103
  cookies_enabled: true
103
104
  max_models: 50
@@ -108,7 +109,7 @@ defaults: &defaults
108
109
  default_version: '1'
109
110
  explorer_groups:
110
111
  '0': [['user'], ['bookmark']]
111
- '1': [['user'], ['bookmark']]
112
+ '1': [['platform', 'user'], ['bookmark']]
112
113
  user:
113
114
  create_enabled: true
114
115
 
@@ -13,6 +13,10 @@ Rails.application.routes.draw do
13
13
  match "/api/bookmark/delete/:id", :to => "api/bookmarks#delete"
14
14
  match "/api/bookmark/update/:id", :to => "api/bookmarks#update"
15
15
  match "/api/bookmark(/:id)", :to => "api/bookmarks#index"
16
+
17
+ # Enable Platform API
18
+ match "api/platform(/:action)", :controller => "api/platform"
19
+
16
20
  ##################################################
17
21
 
18
22
  root :to => "home#index"
@@ -130,7 +130,7 @@ defaults: &defaults
130
130
  decoration_token_classes: ["Tr8n::Tokens::DecorationToken"]
131
131
  allow_nil_token_values: true
132
132
  numeric_rule:
133
- token_suffixes: [count, num, age, hours, minutes, years, seconds]
133
+ token_suffixes: [count, num, age, hours, minutes, years, seconds, days, months]
134
134
  object_method: to_i
135
135
  gender_rule:
136
136
  token_suffixes: [user, profile, actor, target]
@@ -0,0 +1,28 @@
1
+ module Api
2
+ module Proxy
3
+ class PlatformApplicationProxy_0 < Platform::Api::Proxy::Base
4
+ proxy_for(Platform::Application)
5
+
6
+ def to_api_hash(options={})
7
+ {
8
+ :id => instance.id,
9
+ :developer => instance.developer.to_api_hash(options),
10
+ :name => instance.name,
11
+ :description => instance.description,
12
+ :locale => instance.locale,
13
+ :support_url => instance.support_url,
14
+ :contact_email => instance.contact_email,
15
+ :privacy_policy_url => instance.privacy_policy_url,
16
+ :terms_of_service_url => instance.terms_of_service_url,
17
+ :url => instance.url,
18
+ :icon_url => full_url(instance.icon_url),
19
+ :logo_url => full_url(instance.logo_url),
20
+ :canvas_url => instance.app_url,
21
+ :created_at => instance.created_at
22
+ }
23
+ end
24
+
25
+ end
26
+ end
27
+ end
28
+
@@ -0,0 +1,19 @@
1
+ module Api
2
+ module Proxy
3
+ class PlatformDeveloperProxy_0 < Platform::Api::Proxy::Base
4
+ proxy_for(Platform::Developer)
5
+
6
+ def to_api_hash(options={})
7
+ {
8
+ :id => instance.id,
9
+ :name => instance.name,
10
+ :about => instance.about || "",
11
+ :url => instance.url || "",
12
+ :created_at => instance.created_at
13
+ }
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+