platform 3.1.2 → 3.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/.rvmrc +2 -0
  2. data/Gemfile.lock +4 -4
  3. data/README.rdoc +0 -3
  4. data/app/assets/javascripts/platform/api_explorer.js +4 -1
  5. data/app/controllers/platform/api/base_controller.rb +39 -20
  6. data/app/models/platform/application.rb +2 -4
  7. data/app/models/platform/developer.rb +4 -2
  8. data/app/models/platform/logged_exception.rb +2 -2
  9. data/app/models/platform/media/media.rb +6 -3
  10. data/app/views/platform/admin/apps/index.html.erb +1 -1
  11. data/app/views/platform/apps/index.html.erb +2 -2
  12. data/app/views/platform/developer/api_explorer/index.html.erb +9 -5
  13. data/app/views/platform/developer/apps/_form.html.erb +4 -2
  14. data/app/views/platform/developer/apps/index.html.erb +6 -4
  15. data/app/views/platform/developer/common/_header.html.erb +0 -1
  16. data/app/views/platform/developer/dashboard/_statistics.html.erb +1 -1
  17. data/app/views/platform/developer/dashboard/index.html.erb +1 -1
  18. data/app/views/platform/developer/help/oauth_mobile.html.erb +5 -3
  19. data/app/views/platform/developer/registration/index.html.erb +8 -123
  20. data/lib/generators/platform/api_generator.rb +74 -0
  21. data/lib/generators/platform/platform_generator.rb +1 -1
  22. data/lib/generators/platform/proxy_generator.rb +1 -2
  23. data/lib/generators/platform/templates/config/platform/config.yml +9 -8
  24. data/lib/generators/platform/templates/config/platform/data/default_applications.yml +1 -23
  25. data/lib/generators/platform/templates/config/platform/data/default_categories.yml +1 -6
  26. data/lib/generators/platform/templates/config/platform/data/default_permissions.yml +16 -0
  27. data/lib/generators/platform/templates/config/platform/site/features.yml +1 -6
  28. data/lib/generators/platform/templates/db/create_platform_tables.rb +36 -47
  29. data/lib/platform/api/proxy/base.rb +4 -0
  30. data/lib/platform/config.rb +12 -16
  31. data/lib/platform/extensions/action_view_extension.rb +13 -1
  32. data/lib/platform/extensions/hash_extension.rb +69 -0
  33. data/lib/platform/railtie.rb +1 -0
  34. data/lib/platform/version.rb +1 -1
  35. data/lib/tasks/platform.rake +1 -0
  36. data/platform.gemspec +0 -1
  37. data/test/dummy/app/assets/images/logo.png +0 -0
  38. data/test/dummy/app/controllers/api/bookmarks_controller.rb +1 -1
  39. data/test/dummy/app/models/bookmark.rb +0 -2
  40. data/test/dummy/app/models/user.rb +1 -2
  41. data/test/dummy/app/views/home/index.html.erb +2 -2
  42. data/test/dummy/app/views/layouts/_footer.html.erb +1 -1
  43. data/test/dummy/app/views/layouts/_header.html.erb +1 -1
  44. data/test/dummy/config/application.rb +0 -1
  45. data/test/dummy/config/environments/development.rb +3 -1
  46. data/test/dummy/config/initializers/platform.rb +3 -0
  47. data/test/dummy/config/platform/api/1/bookmark.yml +2 -2
  48. data/test/dummy/config/platform/config.yml +10 -9
  49. data/test/dummy/config/platform/data/default_applications.yml +4 -23
  50. data/test/dummy/config/platform/data/default_categories.yml +1 -6
  51. data/test/dummy/config/platform/site/features.yml +1 -6
  52. data/test/dummy/config/routes.rb +1 -1
  53. data/test/dummy/config/tr8n/config.yml +2 -2
  54. data/test/dummy/db/migrate/20111004075531_create_platform_tables.rb +1 -1
  55. data/test/dummy/public/developer_agreement.html +123 -0
  56. metadata +52 -46
  57. data/db/migrate/20110602232141_create_platform_tables.rb +0 -262
@@ -0,0 +1,74 @@
1
+ #--
2
+ # Copyright (c) 2010-2011 Michael Berkovich
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
+ module Generators
26
+ class ApiGenerator < Rails::Generators::NamedBase
27
+ source_root File.expand_path("../templates", __FILE__)
28
+
29
+ desc "Creates an API proxy file for your model"
30
+ def create_proxy_file
31
+ create_file "#{Rails.root}/app/controllers/api/#{file_name}_controller.rb", %Q{class Api::#{class_name}Controller < Api::BaseController
32
+ def index
33
+ ensure_get
34
+ ensure_ids_provided
35
+ ensure_ownership
36
+ render_response page_models
37
+ end
38
+
39
+ def create
40
+ ensure_logged_in
41
+ # TODO: create object
42
+ render_response object
43
+ end
44
+
45
+ def update
46
+ ensure_logged_in
47
+ ensure_ownership
48
+ # TODO: update object
49
+ render_response object
50
+ end
51
+
52
+ def delete
53
+ ensure_logged_in
54
+ ensure_post
55
+ ensure_ownership
56
+ # TODO: delete object
57
+ render_response success_message
58
+ end
59
+
60
+ private
61
+
62
+ def model_class
63
+ #{class_name}
64
+ end
65
+
66
+ end
67
+ }
68
+ end
69
+
70
+ private
71
+
72
+ end
73
+ end
74
+ end
@@ -45,7 +45,7 @@ class PlatformGenerator < Rails::Generators::Base
45
45
  end
46
46
 
47
47
  def copy_configuration
48
- config_source = File.expand_path('../../../../config/platform', __FILE__)
48
+ config_source = File.expand_path("#{self.class.source_root}/config", __FILE__)
49
49
  system "rsync -ruv #{config_source} #{Rails.root}/config"
50
50
  end
51
51
 
@@ -31,8 +31,7 @@ module Platform
31
31
 
32
32
  desc "Creates an API proxy file for your model"
33
33
  def create_proxy_file
34
- create_file "#{Platform::Config.api_proxies_path}/#{file_name}_proxy_#{version}.rb", %Q{
35
- module Api
34
+ create_file "#{Platform::Config.api_proxies_path}/#{file_name}_proxy_#{version}.rb", %Q{module Api
36
35
  module Proxy
37
36
  class #{class_name}Proxy_#{version} < Platform::Api::Proxy::Base
38
37
  proxy_for(#{proxy_class})
@@ -9,16 +9,23 @@
9
9
  # Alternatively, you can overload any of the methods of Platform::Config
10
10
  #############################################################################
11
11
 
12
- defaults: &defaults
12
+ defaults:
13
13
  enable_platform: true
14
14
  enable_app_directory: true
15
15
  enable_embedded_applications: true
16
16
  enable_mobile_applications: true
17
- enable_developer_agreement: false
18
17
  enable_app_statistics: false
19
18
  enable_api_verification: false
20
19
  api_explorer_app_id: 1 # make sure to create an application for the test tool
21
20
 
21
+ #############################################################################
22
+ # You can enforce users to accept the developers agreement before they
23
+ # become developers. To do so, enable the line below and provide path
24
+ # to your dev agreement.
25
+ #############################################################################
26
+ enable_developer_agreement: false
27
+ developer_agreement_path: /developer_agreement.html
28
+
22
29
  #############################################################################
23
30
  # Platform best run with caching enabled
24
31
  # You can configure cache adapter and store parameters by providing the
@@ -118,19 +125,13 @@ defaults: &defaults
118
125
  # You can overload any feature defined in the defaults for any environment
119
126
  #############################################################################
120
127
  development:
121
- <<: *defaults
122
128
 
123
129
  test:
124
- <<: *defaults
125
130
 
126
131
  qa:
127
- <<: *defaults
128
132
 
129
133
  stage:
130
- <<: *defaults
131
134
 
132
135
  production:
133
- <<: *defaults
134
136
 
135
137
  sandbox:
136
- <<: *defaults
@@ -1,39 +1,17 @@
1
- defaults: &defaults
2
- google:
3
- name: "Google"
4
- description: "Google Search Engine"
5
- url: "http://www.google.com"
6
- contact_email: "apps@railsplatform.org"
7
- category_keywords: ["all"]
8
- icon_path: "/public/platform/images/apps/app_icon.gif"
9
- logo_path: "/public/platform/images/apps/app_logo.gif"
10
-
11
- yahoo:
12
- name: "Yahoo"
13
- description: "Yahoo Search Engine"
14
- url: "http://www.yahoo.com"
15
- contact_email: "apps@railsplatform.org"
16
- category_keywords: ["all"]
17
- icon_path: "/public/platform/images/apps/app_icon.gif"
18
- logo_path: "/public/platform/images/apps/app_logo.gif"
1
+ defaults:
19
2
 
20
3
  #############################################################################
21
4
  # Environment Settings
22
5
  # You can overload any feature defined in the defaults for any environment
23
6
  #############################################################################
24
7
  development:
25
- <<: *defaults
26
8
 
27
9
  test:
28
- <<: *defaults
29
10
 
30
11
  qa:
31
- <<: *defaults
32
12
 
33
13
  stage:
34
- <<: *defaults
35
14
 
36
15
  production:
37
- <<: *defaults
38
16
 
39
17
 
@@ -1,4 +1,4 @@
1
- defaults: &defaults
1
+ defaults:
2
2
  all:
3
3
  position: 1
4
4
  name: "All Apps"
@@ -39,18 +39,13 @@ defaults: &defaults
39
39
  # You can overload any feature defined in the defaults for any environment
40
40
  #############################################################################
41
41
  development:
42
- <<: *defaults
43
42
 
44
43
  test:
45
- <<: *defaults
46
44
 
47
45
  qa:
48
- <<: *defaults
49
46
 
50
47
  stage:
51
- <<: *defaults
52
48
 
53
49
  production:
54
- <<: *defaults
55
50
 
56
51
 
@@ -0,0 +1,16 @@
1
+ defaults:
2
+
3
+ #############################################################################
4
+ # Environment Settings
5
+ # You can overload any feature defined in the defaults for any environment
6
+ #############################################################################
7
+ development:
8
+
9
+ test:
10
+
11
+ qa:
12
+
13
+ stage:
14
+
15
+ production:
16
+
@@ -7,7 +7,7 @@
7
7
  # environment settings at the bottom of the file
8
8
  #############################################################################
9
9
 
10
- defaults: &defaults
10
+ defaults:
11
11
  enabled_features: [dashboard, apps, forum, api_explorer, help]
12
12
 
13
13
  dashboard:
@@ -51,16 +51,11 @@ defaults: &defaults
51
51
  # You can overload any feature defined in the defaults for any environment
52
52
  #############################################################################
53
53
  development:
54
- <<: *defaults
55
54
 
56
55
  test:
57
- <<: *defaults
58
56
 
59
57
  qa:
60
- <<: *defaults
61
58
 
62
59
  stage:
63
- <<: *defaults
64
60
 
65
61
  production:
66
- <<: *defaults
@@ -9,7 +9,8 @@ class CreatePlatformTables < ActiveRecord::Migration
9
9
  t.string :phone
10
10
  t.timestamps
11
11
  end
12
- add_index :platform_developers, :user_id
12
+ add_index :platform_developers, :user_id, :name => 'platform_pd_u'
13
+ add_index :platform_developers, :created_at, :name => 'platform_pd_c'
13
14
 
14
15
  create_table :platform_applications do |t|
15
16
  t.integer :developer_id
@@ -45,9 +46,10 @@ class CreatePlatformTables < ActiveRecord::Migration
45
46
  t.integer :parent_id
46
47
  t.timestamps
47
48
  end
48
- add_index :platform_applications, :developer_id
49
- add_index :platform_applications, :key, :unique
50
- add_index :platform_applications, :parent_id
49
+ add_index :platform_applications, :developer_id, :name => 'platform_pa_d'
50
+ add_index :platform_applications, :key, {:unique => true, :name => 'platform_pa_k'}
51
+ add_index :platform_applications, :parent_id, :name => 'platform_pa_p'
52
+ add_index :platform_applications, :created_at, :name => 'platform_pa_c'
51
53
 
52
54
  create_table :platform_application_logs do |t|
53
55
  t.integer :application_id
@@ -64,7 +66,8 @@ class CreatePlatformTables < ActiveRecord::Migration
64
66
  t.string :ip
65
67
  t.timestamps
66
68
  end
67
- add_index :platform_application_logs, [:application_id, :created_at]
69
+ add_index :platform_applications, :created_at, :name => 'platform_pal_c'
70
+ add_index :platform_application_logs, [:application_id, :created_at], :name => 'platform_pal_ac'
68
71
 
69
72
  create_table :platform_application_metrics do |t|
70
73
  t.string :type
@@ -74,7 +77,8 @@ class CreatePlatformTables < ActiveRecord::Migration
74
77
  t.integer :new_user_count
75
78
  t.timestamps
76
79
  end
77
- add_index :platform_application_metrics, [:application_id, :interval], :name => "pamai"
80
+ add_index :platform_application_metrics, [:application_id, :interval], :name => "platform_pam_ai"
81
+ add_index :platform_application_metrics, [:created_at], :name => "platform_pam_c"
78
82
 
79
83
  create_table :platform_application_usage_metrics do |t|
80
84
  t.string :type
@@ -86,7 +90,8 @@ class CreatePlatformTables < ActiveRecord::Migration
86
90
  t.integer :error_count
87
91
  t.timestamps
88
92
  end
89
- add_index :platform_application_usage_metrics, [:application_id, :interval], :name => "paumai"
93
+ add_index :platform_application_usage_metrics, [:application_id, :interval], :name => "platform_paum_ai"
94
+ add_index :platform_application_usage_metrics, [:created_at], :name => "platform_paum_c"
90
95
 
91
96
  create_table :platform_rollup_logs do |t|
92
97
  t.timestamp :interval
@@ -94,7 +99,8 @@ class CreatePlatformTables < ActiveRecord::Migration
94
99
  t.timestamp :finished_at
95
100
  t.timestamps
96
101
  end
97
- add_index :platform_rollup_logs, :interval
102
+ add_index :platform_rollup_logs, :interval, :name => "platform_prl_i"
103
+ add_index :platform_rollup_logs, [:created_at], :name => "platform_prl_c"
98
104
 
99
105
  create_table :platform_media do |t|
100
106
  t.string :type
@@ -103,17 +109,19 @@ class CreatePlatformTables < ActiveRecord::Migration
103
109
  t.string :file_name
104
110
  t.timestamps
105
111
  end
112
+ add_index :platform_media, [:type], :name => "platform_pm_t"
113
+ add_index :platform_media, [:created_at], :name => "platform_pm_c"
106
114
 
107
115
  create_table :platform_application_developers do |t|
108
116
  t.integer :application_id
109
117
  t.integer :developer_id
110
118
  t.timestamps
111
119
  end
112
- add_index :platform_application_developers, :application_id
113
- add_index :platform_application_developers, :developer_id
120
+ add_index :platform_application_developers, :application_id, :name => "platform_pad_a"
121
+ add_index :platform_application_developers, :developer_id, :name => "platform_pad_d"
114
122
 
115
123
  create_table :platform_oauth_tokens do |t|
116
- t.string :type, :limit => 20
124
+ t.string :type
117
125
  t.integer :user_id, :limit=>8
118
126
  t.integer :application_id
119
127
  t.string :token, :limit => 50
@@ -125,7 +133,9 @@ class CreatePlatformTables < ActiveRecord::Migration
125
133
  t.timestamp :authorized_at, :invalidated_at
126
134
  t.timestamps
127
135
  end
128
- add_index :platform_oauth_tokens, :token, :unique
136
+ add_index :platform_oauth_tokens, [:application_id, :type], :name => "platform_pot_at"
137
+ add_index :platform_oauth_tokens, :token, {:unique => true, :name => "platform_pot_tu"}
138
+ add_index :platform_oauth_tokens, :created_at, :name => "platform_pot_c"
129
139
 
130
140
  create_table :platform_ratings do |t|
131
141
  t.integer :user_id, :limit => 8, :null => false
@@ -135,8 +145,8 @@ class CreatePlatformTables < ActiveRecord::Migration
135
145
  t.text :comment
136
146
  t.timestamps
137
147
  end
138
- add_index :platform_ratings, :user_id
139
- add_index :platform_ratings, [:object_type, :object_id]
148
+ add_index :platform_ratings, :user_id, :name => "platform_pr_u"
149
+ add_index :platform_ratings, [:object_type, :object_id], :name => "platform_pr_oo"
140
150
 
141
151
  create_table :platform_categories do |t|
142
152
  t.string :type
@@ -148,7 +158,7 @@ class CreatePlatformTables < ActiveRecord::Migration
148
158
  t.integer :parent_id
149
159
  t.timestamps
150
160
  end
151
- add_index :platform_categories, :parent_id
161
+ add_index :platform_categories, :parent_id, :name => "platform_pc_p"
152
162
 
153
163
  create_table :platform_application_categories do |t|
154
164
  t.integer :category_id, :null => false
@@ -157,8 +167,8 @@ class CreatePlatformTables < ActiveRecord::Migration
157
167
  t.boolean :featured
158
168
  t.timestamps
159
169
  end
160
- add_index :platform_application_categories, :category_id, :name => "pacc"
161
- add_index :platform_application_categories, [:category_id, :application_id], :name => "pacca"
170
+ add_index :platform_application_categories, :category_id, :name => "platform_pac_c"
171
+ add_index :platform_application_categories, [:category_id, :application_id], :name => "platform_pac_ca"
162
172
 
163
173
  create_table :platform_forum_topics do |t|
164
174
  t.string :subject_type
@@ -167,8 +177,8 @@ class CreatePlatformTables < ActiveRecord::Migration
167
177
  t.text :topic, :null => false
168
178
  t.timestamps
169
179
  end
170
- add_index :platform_forum_topics, [:subject_type, :subject_id], :name => "pftss"
171
- add_index :platform_forum_topics, [:user_id], :name => "pftu"
180
+ add_index :platform_forum_topics, [:subject_type, :subject_id], :name => "platform_pft_ss"
181
+ add_index :platform_forum_topics, [:user_id], :name => "pftu", :name => "platform_pft_u"
172
182
 
173
183
  create_table :platform_forum_messages do |t|
174
184
  t.integer :forum_topic_id, :null => false
@@ -176,22 +186,22 @@ class CreatePlatformTables < ActiveRecord::Migration
176
186
  t.text :message, :null => false
177
187
  t.timestamps
178
188
  end
179
- add_index :platform_forum_messages, [:forum_topic_id]
180
- add_index :platform_forum_messages, [:user_id]
189
+ add_index :platform_forum_messages, [:forum_topic_id], :name => "platform_pfm_f"
190
+ add_index :platform_forum_messages, [:user_id], :name => "platform_pfm_u"
181
191
 
182
192
  create_table :platform_permissions do |t|
183
193
  t.string :keyword, :null => false
184
194
  t.text :description, :null => false
185
195
  t.timestamps
186
196
  end
187
- add_index :platform_permissions, [:keyword]
197
+ add_index :platform_permissions, [:keyword], :name => "platform_pp_k"
188
198
 
189
199
  create_table :platform_application_permissions do |t|
190
200
  t.integer :application_id
191
201
  t.integer :permission_id
192
202
  t.timestamps
193
203
  end
194
- add_index :platform_application_permissions, :application_id
204
+ add_index :platform_application_permissions, :application_id, :name => "platform_pap_a"
195
205
 
196
206
  create_table :platform_application_users do |t|
197
207
  t.integer :application_id, :null => false
@@ -199,28 +209,8 @@ class CreatePlatformTables < ActiveRecord::Migration
199
209
  t.text :data
200
210
  t.timestamps
201
211
  end
202
- add_index :platform_application_users, [:application_id]
203
- add_index :platform_application_users, [:user_id]
204
-
205
- create_table :platform_users do |t|
206
- t.string :name
207
- t.string :gender
208
- t.string :email
209
- t.string :password
210
- t.string :mugshot
211
- t.string :link
212
- t.string :locale
213
- t.timestamps
214
- end
215
- add_index :platform_users, [:email]
216
- add_index :platform_users, [:email, :password]
217
-
218
- create_table :platform_admins do |t|
219
- t.integer :user_id
220
- t.integer :level
221
- t.timestamps
222
- end
223
- add_index :platform_admins, [:user_id]
212
+ add_index :platform_application_users, [:application_id], :name => "platform_pau_a"
213
+ add_index :platform_application_users, [:user_id], :name => "platform_pau_u"
224
214
 
225
215
  create_table :platform_logged_exceptions do |t|
226
216
  t.column :exception_class, :string
@@ -237,6 +227,7 @@ class CreatePlatformTables < ActiveRecord::Migration
237
227
  t.column :application_id, :integer
238
228
  t.timestamps
239
229
  end
230
+ add_index :platform_logged_exceptions, [:created_at], :name => "platform_ple_c"
240
231
  end
241
232
 
242
233
  def self.down
@@ -255,8 +246,6 @@ class CreatePlatformTables < ActiveRecord::Migration
255
246
  drop_table :platform_permissions
256
247
  drop_table :platform_application_permissions
257
248
  drop_table :platform_application_users
258
- drop_table :platform_users
259
- drop_table :platform_admins
260
249
  drop_table :platform_logged_exceptions
261
250
  end
262
251
  end