lti_skydrive 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +20 -0
  4. data/app/assets/fonts/skydrive/font/FontAwesome.otf +0 -0
  5. data/app/assets/fonts/skydrive/font/fontawesome-webfont.eot +0 -0
  6. data/app/assets/fonts/skydrive/font/fontawesome-webfont.svg +399 -0
  7. data/app/assets/fonts/skydrive/font/fontawesome-webfont.ttf +0 -0
  8. data/app/assets/fonts/skydrive/font/fontawesome-webfont.woff +0 -0
  9. data/app/assets/images/skydrive/banner.png +0 -0
  10. data/app/assets/images/skydrive/icon-file.png +0 -0
  11. data/app/assets/images/skydrive/icon-folder-back.png +0 -0
  12. data/app/assets/images/skydrive/icon-folder.png +0 -0
  13. data/app/assets/images/skydrive/icon-jpg.png +0 -0
  14. data/app/assets/images/skydrive/icon-pdf.png +0 -0
  15. data/app/assets/images/skydrive/icon-png.png +0 -0
  16. data/app/assets/images/skydrive/icon-word.png +0 -0
  17. data/app/assets/images/skydrive/logo.png +0 -0
  18. data/app/assets/images/skydrive/office_365.jpg +0 -0
  19. data/app/assets/images/skydrive/skydrive_icon.png +0 -0
  20. data/app/assets/javascripts/skydrive/application.js +16 -0
  21. data/app/assets/javascripts/skydrive/vendor/ember.js +23 -0
  22. data/app/assets/javascripts/skydrive/vendor/handlebars.js +362 -0
  23. data/app/assets/javascripts/skydrive/vendor/jquery.js +9597 -0
  24. data/app/assets/stylesheets/skydrive/app.css +5617 -0
  25. data/app/assets/stylesheets/skydrive/font-awesome/font-awesome.min.css +403 -0
  26. data/app/assets/stylesheets/skydrive/normalize.css +405 -0
  27. data/app/assets/stylesheets/skydrive/style.css +27 -0
  28. data/app/controllers/skydrive/api_keys_controller.rb +13 -0
  29. data/app/controllers/skydrive/application_controller.rb +40 -0
  30. data/app/controllers/skydrive/ember_controller.rb +23 -0
  31. data/app/controllers/skydrive/files_controller.rb +62 -0
  32. data/app/controllers/skydrive/launch_controller.rb +152 -0
  33. data/app/controllers/skydrive/session_controller.rb +12 -0
  34. data/app/controllers/skydrive/users_controller.rb +34 -0
  35. data/app/helpers/skydrive/application_helper.rb +4 -0
  36. data/app/helpers/skydrive/ember_helper.rb +4 -0
  37. data/app/models/skydrive/api_key.rb +47 -0
  38. data/app/models/skydrive/lti_key.rb +10 -0
  39. data/app/models/skydrive/token.rb +14 -0
  40. data/app/models/skydrive/user.rb +28 -0
  41. data/app/serializers/api_key_serializer.rb +5 -0
  42. data/app/serializers/user_serializer.rb +5 -0
  43. data/app/views/layouts/skydrive/application.html.erb +21 -0
  44. data/app/views/skydrive/ember/index.html.erb +20 -0
  45. data/config/initializers/sharepoint.rb +1 -0
  46. data/config/routes.rb +24 -0
  47. data/config/sharepoint.yml.example +17 -0
  48. data/db/migrate/20130710195807_create_users.rb +11 -0
  49. data/db/migrate/20130710195819_create_api_keys.rb +15 -0
  50. data/db/migrate/20130722173006_add_skydrive_token_storage.rb +15 -0
  51. data/db/migrate/20130725183724_add_client_domain_to_skydrive_tokens.rb +5 -0
  52. data/db/migrate/20130726170108_add_personal_url_to_skydrive_token.rb +5 -0
  53. data/db/migrate/20130730164700_add_init_params_to_api_key.rb +5 -0
  54. data/db/migrate/20130801181008_create_lti_keys.rb +9 -0
  55. data/db/migrate/20130802231147_change_skydrive_token_length.rb +6 -0
  56. data/db/migrate/20140103221052_skydrive_namespace.rb +13 -0
  57. data/lib/skydrive/client.rb +161 -0
  58. data/lib/skydrive/engine.rb +16 -0
  59. data/lib/skydrive/file.rb +49 -0
  60. data/lib/skydrive/folder.rb +13 -0
  61. data/lib/skydrive/version.rb +3 -0
  62. data/lib/skydrive.rb +4 -0
  63. data/lib/skydrive_proxy.rb +33 -0
  64. data/lib/tasks/ember.rake +48 -0
  65. data/lib/tasks/lti_key.rake +8 -0
  66. data/test/controllers/skydrive/ember_controller_test.rb +11 -0
  67. data/test/dummy/README.rdoc +28 -0
  68. data/test/dummy/Rakefile +6 -0
  69. data/test/dummy/app/assets/javascripts/application.js +13 -0
  70. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  71. data/test/dummy/app/controllers/application_controller.rb +5 -0
  72. data/test/dummy/app/helpers/application_helper.rb +2 -0
  73. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  74. data/test/dummy/bin/bundle +3 -0
  75. data/test/dummy/bin/rails +4 -0
  76. data/test/dummy/bin/rake +4 -0
  77. data/test/dummy/config/application.rb +25 -0
  78. data/test/dummy/config/boot.rb +5 -0
  79. data/test/dummy/config/database.yml +25 -0
  80. data/test/dummy/config/environment.rb +5 -0
  81. data/test/dummy/config/environments/development.rb +29 -0
  82. data/test/dummy/config/environments/production.rb +80 -0
  83. data/test/dummy/config/environments/test.rb +36 -0
  84. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  85. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  86. data/test/dummy/config/initializers/inflections.rb +16 -0
  87. data/test/dummy/config/initializers/mime_types.rb +5 -0
  88. data/test/dummy/config/initializers/secret_token.rb +12 -0
  89. data/test/dummy/config/initializers/session_store.rb +3 -0
  90. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  91. data/test/dummy/config/locales/en.yml +23 -0
  92. data/test/dummy/config/routes.rb +3 -0
  93. data/test/dummy/config/sharepoint.yml +15 -0
  94. data/test/dummy/config.ru +4 -0
  95. data/test/dummy/db/development.sqlite3 +0 -0
  96. data/test/dummy/db/schema.rb +60 -0
  97. data/test/dummy/db/test.sqlite3 +0 -0
  98. data/test/dummy/log/development.log +6484 -0
  99. data/test/dummy/log/test.log +2958 -0
  100. data/test/dummy/public/404.html +58 -0
  101. data/test/dummy/public/422.html +58 -0
  102. data/test/dummy/public/500.html +57 -0
  103. data/test/dummy/public/favicon.ico +0 -0
  104. data/test/dummy/tmp/cache/assets/development/sprockets/00546f7f6da41f471084ed2589ca4442 +0 -0
  105. data/test/dummy/tmp/cache/assets/development/sprockets/049dac97744466d4435aa8de57cc6099 +0 -0
  106. data/test/dummy/tmp/cache/assets/development/sprockets/0c92f67702b0dbd50edf7e6be63359ca +0 -0
  107. data/test/dummy/tmp/cache/assets/development/sprockets/0d26053221de21901f734bd6ba75bb28 +0 -0
  108. data/test/dummy/tmp/cache/assets/development/sprockets/0e383306a92ebd12d003a9e49ef6d508 +0 -0
  109. data/test/dummy/tmp/cache/assets/development/sprockets/16fa9bed5ef4abda841d3ef00e727580 +0 -0
  110. data/test/dummy/tmp/cache/assets/development/sprockets/17588b92c903e02837946f638eca86db +0 -0
  111. data/test/dummy/tmp/cache/assets/development/sprockets/21900b90dba7acf710178f3cd9dad43b +0 -0
  112. data/test/dummy/tmp/cache/assets/development/sprockets/25efc08f115a66b9c241a48e80a207ca +0 -0
  113. data/test/dummy/tmp/cache/assets/development/sprockets/3064fc29e24c9e97f7aad24f7e899cf6 +0 -0
  114. data/test/dummy/tmp/cache/assets/development/sprockets/311d9a5a43eb3fee9bba76971680620f +0 -0
  115. data/test/dummy/tmp/cache/assets/development/sprockets/35a147c1af5b608250e82ccb2f569d4b +0 -0
  116. data/test/dummy/tmp/cache/assets/development/sprockets/3dd0eb5a85d766c8d9fe5b29014edee4 +0 -0
  117. data/test/dummy/tmp/cache/assets/development/sprockets/63616bfc6c3f0267d5951cbbc83308cd +0 -0
  118. data/test/dummy/tmp/cache/assets/development/sprockets/65aa42ce50eac6f72e31861670f94518 +0 -0
  119. data/test/dummy/tmp/cache/assets/development/sprockets/66a8e9d3d86505dece06e6dd0edd18e1 +0 -0
  120. data/test/dummy/tmp/cache/assets/development/sprockets/78c4cbc0498be843f50ebdd02e2ead2f +0 -0
  121. data/test/dummy/tmp/cache/assets/development/sprockets/7caeca69c3c375c50a3c8cad8584be79 +0 -0
  122. data/test/dummy/tmp/cache/assets/development/sprockets/7d2b5e5332f464f65bf745d12ed9cbaa +0 -0
  123. data/test/dummy/tmp/cache/assets/development/sprockets/7e229ef6d57ba0e9f562cc129a3e4dfc +0 -0
  124. data/test/dummy/tmp/cache/assets/development/sprockets/87149d8992d83d7a95023dbfa4b53907 +0 -0
  125. data/test/dummy/tmp/cache/assets/development/sprockets/8bf6a6b96f5c827206f1fd42babe6c5e +0 -0
  126. data/test/dummy/tmp/cache/assets/development/sprockets/8c2066f7cc911ab8803cab8fea4e8bd6 +0 -0
  127. data/test/dummy/tmp/cache/assets/development/sprockets/9157ff048f219d7abc8b0f0fda771c92 +0 -0
  128. data/test/dummy/tmp/cache/assets/development/sprockets/a17c28776c4a2887f0fff4893854ef1d +0 -0
  129. data/test/dummy/tmp/cache/assets/development/sprockets/a29fed21bbc3985a31325c84a77e5f26 +0 -0
  130. data/test/dummy/tmp/cache/assets/development/sprockets/a3119da5b51c1a0a3c5cb7414ec920f5 +0 -0
  131. data/test/dummy/tmp/cache/assets/development/sprockets/a674526f54bc8458ebe36912ef85f003 +0 -0
  132. data/test/dummy/tmp/cache/assets/development/sprockets/aa904c0cc06f37bb0df493db59f18d70 +0 -0
  133. data/test/dummy/tmp/cache/assets/development/sprockets/adfa454123f4741a4b3919023b570d82 +0 -0
  134. data/test/dummy/tmp/cache/assets/development/sprockets/af6eedeceb4b732776dca83f456b2b93 +0 -0
  135. data/test/dummy/tmp/cache/assets/development/sprockets/b40cb2ddb88705f771e77d872feacf6a +0 -0
  136. data/test/dummy/tmp/cache/assets/development/sprockets/bf64c92410e28e00afb6139c5d4c61b9 +0 -0
  137. data/test/dummy/tmp/cache/assets/development/sprockets/dc6268ee4fa18069ce7c21888ea1932e +0 -0
  138. data/test/dummy/tmp/cache/assets/development/sprockets/df9900b8557146382d16cc592306b17f +0 -0
  139. data/test/dummy/tmp/cache/assets/development/sprockets/e3caec07cb46343e49b4f060e2d3392a +0 -0
  140. data/test/dummy/tmp/cache/assets/development/sprockets/e6ebfb0e93a47d0164d0fc4637054c38 +0 -0
  141. data/test/dummy/tmp/cache/assets/development/sprockets/ecb48e7374f399434aedbf30716e489a +0 -0
  142. data/test/dummy/tmp/cache/assets/development/sprockets/eeb495bc326785d2a6a14cf6d97024e4 +0 -0
  143. data/test/dummy/tmp/cache/assets/development/sprockets/ef91e47e51f204a8373f160f13a05a30 +0 -0
  144. data/test/dummy/tmp/cache/assets/development/sprockets/f48290aae486ea863a9f456ba96443e9 +0 -0
  145. data/test/dummy/tmp/cache/assets/development/sprockets/fa078ac6abaaee94445294c5a7c6d793 +0 -0
  146. data/test/helpers/skydrive/ember_helper_test.rb +6 -0
  147. data/test/integration/navigation_test.rb +10 -0
  148. data/test/skydrive_test.rb +7 -0
  149. data/test/test_helper.rb +15 -0
  150. metadata +375 -0
@@ -0,0 +1,161 @@
1
+ require 'rest_client'
2
+ require 'curb'
3
+ require 'json'
4
+ require 'mimemagic'
5
+
6
+ module Skydrive
7
+ class Client
8
+ include ActionView::Helpers::NumberHelper
9
+
10
+ attr_accessor :client_id, :client_secret, :guid, :client_domain, :token
11
+
12
+ def initialize(options = {})
13
+ options.each { |key, val| self.send("#{key}=", val) if self.respond_to?("#{key}=") }
14
+ end
15
+
16
+ def oauth_authorize_redirect_uri(redirect_uri, options = {})
17
+ scope = options[:scope] || 'Web.Read AllSites.Write AllProfiles.Read'
18
+ state = options[:state]
19
+
20
+ redirect_params = {
21
+ client_id: client_id,
22
+ scope: scope,
23
+ redirect_uri: redirect_uri,
24
+ response_type: 'code'
25
+ }
26
+
27
+ "https://#{client_domain}/_layouts/15/OAuthAuthorize.aspx?" +
28
+ redirect_params.map{|k,v| "#{k}=#{CGI::escape(v)}"}.join('&') +
29
+ (state ? "&state=#{state}" : "")
30
+ end
31
+
32
+ def get_token(redirect_uri, code)
33
+ realm = self.get_realm
34
+ endpoint = "https://accounts.accesscontrol.windows.net/#{realm}/tokens/OAuth/2"
35
+
36
+ options = {
37
+ content_type: 'application/x-www-form-urlencoded',
38
+ client_id: "#{client_id}@#{realm}",
39
+ redirect_uri: redirect_uri,
40
+ client_secret: client_secret,
41
+ code: code,
42
+ grant_type: 'authorization_code',
43
+ resource: "#{guid}/#{client_domain}@#{realm}",
44
+ }
45
+
46
+ RestClient.post endpoint, options do |response, request, result|
47
+ results = format_results(JSON.parse(response))
48
+ self.token = results['access_token']
49
+ results
50
+ end
51
+ end
52
+
53
+ def refresh_token(refresh_token)
54
+ realm = self.get_realm
55
+ endpoint = "https://accounts.accesscontrol.windows.net/#{realm}/tokens/OAuth/2"
56
+
57
+ options = {
58
+ content_type: 'application/x-www-form-urlencoded',
59
+ client_id: "#{client_id}@#{realm}",
60
+ client_secret: client_secret,
61
+ refresh_token: refresh_token,
62
+ grant_type: 'refresh_token',
63
+ resource: "#{guid}/#{client_domain}@#{realm}",
64
+ }
65
+
66
+ RestClient.post endpoint, options do |response, request, result|
67
+ results = format_results(JSON.parse(response))
68
+ self.token = results['access_token']
69
+ results
70
+ end
71
+ end
72
+
73
+ def format_results(results)
74
+ results["expires_in"] = results["expires_in"].to_i
75
+ results["not_before"] = Time.at results["not_before"].to_i
76
+ results["expires_on"] = Time.at results["expires_on"].to_i
77
+ results
78
+ end
79
+
80
+ def get_realm
81
+ #401 sharepoint challenge to get the realm
82
+ resource = RestClient::Resource.new "https://#{client_domain}/_vti_bin/client.svc/",
83
+ {headers: {'Authorization' => 'Bearer'}}
84
+ www_authenticate = {}
85
+ resource.get do |response, request, result|
86
+ response.headers[:www_authenticate].scan(/[\w ]*="[^"]*"/).each do |attribute|
87
+ attribute = attribute.split('=')
88
+ www_authenticate[attribute.first] = attribute.last.delete('"')
89
+ end
90
+ end
91
+
92
+ www_authenticate["Bearer realm"]
93
+ end
94
+
95
+ def get_folder_and_files(uri, folder = Skydrive::Folder.new)
96
+ data = api_call(uri)
97
+
98
+ folder.icon = "/assets/skydrive/icon-folder.png"
99
+ folder.uri = uri
100
+ folder.name = data['Name']
101
+ folder.server_relative_url = data['ServerRelativeUrl']
102
+ folder.parse_parent_uri
103
+ folder.files = []
104
+ folder.folders = []
105
+
106
+ files = api_call(data['Files']['__deferred']['uri'])['results']
107
+ files.each do |f|
108
+ new_file = Skydrive::File.new
109
+ new_file.uri = f['__metadata']['uri']
110
+ new_file.file_size = number_to_human_size(f['Length'])
111
+ new_file.name = f['Name']
112
+ new_file.server_relative_url = f['ServerRelativeUrl']
113
+ new_file.time_created = Date.parse(f['TimeCreated'])
114
+ new_file.time_last_modified = Date.parse(f['TimeLastModified'])
115
+ new_file.title = f['Title']
116
+ new_file.content_tag = f['ContentTag']
117
+ folder.files << new_file
118
+ end
119
+
120
+ sub_folders = api_call(data['Folders']['__deferred']['uri'])['results']
121
+ sub_folders.each do |sf|
122
+
123
+ # Non-recursively
124
+ sub_folder = Skydrive::Folder.new
125
+ sub_folder.parent_uri = uri
126
+ sub_folder.icon = "/assets/skydrive/icon-folder.png"
127
+ sub_folder.uri = sf['__metadata']['uri']
128
+ sub_folder.name = sf['Name']
129
+ sub_folder.server_relative_url = sf['ServerRelativeUrl']
130
+ sub_folder.files = []
131
+ sub_folder.folders = []
132
+
133
+ #special exception for the special Forms folder in the root directory
134
+ if !folder.parent_uri && sub_folder.name == 'Forms'
135
+ next
136
+ end
137
+
138
+ # Recursively
139
+ # sub_folder = get_folder_and_files(sf['__metadata']['uri'])
140
+
141
+ folder.folders << sub_folder
142
+ end
143
+
144
+ return folder
145
+ end
146
+
147
+ def api_call(url)
148
+ url.gsub!("https:/i", "https://i")
149
+ uri = URI.escape(url)
150
+ http = Curl.get(uri) do |http|
151
+ http.headers['Authorization'] = "Bearer #{token}"
152
+ http.headers['Accept'] = "application/json; odata=verbose"
153
+ end
154
+ JSON.parse(http.body_str)["d"]
155
+ end
156
+
157
+ def get_user
158
+ api_call("https://#{client_domain}/_api/SP.UserProfiles.PeopleManager/GetMyProperties")
159
+ end
160
+ end
161
+ end
@@ -0,0 +1,16 @@
1
+ module Skydrive
2
+ class Engine < ::Rails::Engine
3
+ OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:ssl_version] = 'SSLv3'
4
+ config.autoload_paths << File.expand_path('../../', __FILE__)
5
+
6
+ isolate_namespace Skydrive
7
+
8
+ initializer :append_migrations do |app|
9
+ unless app.root.to_s == root.to_s
10
+ config.paths["db/migrate"].expanded.each do |expanded_path|
11
+ app.config.paths["db/migrate"] << expanded_path
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,49 @@
1
+ require 'mimemagic'
2
+
3
+ module Skydrive
4
+ class File
5
+ attr_accessor :uri, :file_size, :name, :server_relative_url, :time_created, :time_last_modified, :title, :content_tag,
6
+ :content_type, :is_image, :is_text, :is_video, :mime_comment, :icon, :kind, :suffix, :is_embeddable,
7
+ :homework_submission_url
8
+
9
+ def update_content_type_data(allowed_extensions=nil)
10
+ self.is_embeddable = true
11
+ mm = MimeMagic.by_path(self.name)
12
+ if mm
13
+ if mm.image?
14
+ case mm.to_s
15
+ when 'image/png'
16
+ self.icon = "/assets/skydrive/icon-png.png"
17
+ when 'image/jpeg'
18
+ self.icon = "/assets/skydrive/icon-jpg.png"
19
+ else
20
+ self.icon = "/assets/skydrive/icon-jpg.png"
21
+ end
22
+ elsif mm.text? || mm.subtype == "msword"
23
+ if mm.extensions & ['doc', 'docx']
24
+ self.icon = "/assets/skydrive/icon-word.png"
25
+ else
26
+ self.icon = "/assets/skydrive/icon-file.png"
27
+ end
28
+ elsif mm.to_s == 'application/pdf'
29
+ self.icon = "/assets/skydrive/icon-pdf.png"
30
+ else
31
+ self.icon = "/assets/skydrive/icon-file.png"
32
+ end
33
+ self.kind = mm.comment
34
+ self.suffix = mm.extensions.last
35
+
36
+ if !allowed_extensions || (allowed_extensions & mm.extensions).size > 0
37
+ self.is_embeddable = true
38
+ else
39
+ self.is_embeddable = false
40
+ end
41
+ else
42
+ self.icon = "/skydrive/images/icon-file.png"
43
+ self.kind = ''
44
+ self.suffix = self.name.split('.').try(:last) || ''
45
+ self.is_embeddable = false
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,13 @@
1
+ module Skydrive
2
+ class Folder
3
+ attr_accessor :uri, :parent_uri, :name, :server_relative_url, :files, :folders, :icon
4
+
5
+ def parse_parent_uri
6
+ if self.uri && self.server_relative_url.split('/').count > 4
7
+ self.parent_uri = { uri: self.uri.split(/\//)[0...-1].join('/') + "')" }
8
+ else
9
+ self.parent_uri = nil
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module Skydrive
2
+ VERSION = "0.0.1"
3
+ end
data/lib/skydrive.rb ADDED
@@ -0,0 +1,4 @@
1
+ require "skydrive/engine"
2
+
3
+ module Skydrive
4
+ end
@@ -0,0 +1,33 @@
1
+ # http://localhost:9393/download/file?access_token=516ad4d3-80b3-4da5-bb0f-b5651b9fce62&file=/personal/ericb_instructure_onmicrosoft_com/Documents/2013-05-17_1633.png
2
+
3
+ class SkydriveProxy
4
+ def initialize(app)
5
+ @app = app
6
+ end
7
+
8
+ def call(env)
9
+ path = env["REQUEST_PATH"]
10
+ if path =~ /^\/download\/.+/
11
+ dup._call(env)
12
+ else
13
+ @status, @headers, @response = @app.call(env)
14
+ [@status, @headers, self]
15
+ end
16
+ end
17
+
18
+ def _call(env)
19
+ params = Rack::Utils.parse_query(env["QUERY_STRING"])
20
+ api_key = ApiKey.where(access_token: params['access_token']).first
21
+ if api_key
22
+ user = api_key.user
23
+ uri = "#{user.token.personal_url}_api/Web/GetFileByServerRelativeUrl('#{params['file']}')"
24
+ [200, {"Content-Type" => "text/plain"}, [uri]]
25
+ else
26
+ [401, {"Content-Type" => "text/plain"}, []]
27
+ end
28
+ end
29
+
30
+ def each(&block)
31
+ @response.each(&block)
32
+ end
33
+ end
@@ -0,0 +1,48 @@
1
+ namespace :skydrive do
2
+ namespace :ember do
3
+ desc 'Build the ember application using the RAILS_ENV variable'
4
+ task :build do
5
+ require 'ember/source'
6
+
7
+ puts 'building ember for production'
8
+ FileUtils.cp Ember::Source.bundled_path_for('ember.min.js'), 'app/assets/javascripts/skydrive/vendor/ember.js'
9
+ puts 'building ember'
10
+ puts `ember build --out-file app/assets/javascripts/skydrive/application.js`
11
+ puts 'minifying application.js'
12
+ rewrite_file('app/assets/javascripts/skydrive/application.js') {|f| Uglifier.compile(f)}
13
+
14
+ #if(Rails.env.production?)
15
+ # puts 'building ember for production'
16
+ # FileUtils.cp Ember::Source.bundled_path_for('ember.min.js'), 'public/javascripts/vendor/ember.js'
17
+ # puts 'building ember'
18
+ # puts `ember build`
19
+ # puts 'minifying application.js'
20
+ # rewrite_file('public/javascripts/application.js') {|f| Uglifier.compile(f)}
21
+ #else
22
+ # puts 'building ember for development'
23
+ # FileUtils.cp Ember::Source.bundled_path_for('ember.js'), 'public/javascripts/vendor/ember.js'
24
+ # puts 'building ember'
25
+ # puts `ember build -d`
26
+ #end
27
+ end
28
+
29
+ #This doesn't work at present because ember requires an older version of handlebars
30
+ #The version required by the ember-source gem conflicts.
31
+ #task :handlebars do
32
+ # require 'handlebars/source'
33
+ #
34
+ # if(Rails.env.production?)
35
+ # puts 'building handlebars for production'
36
+ # FileUtils.cp Handlebars::Source.runtime_bundled_path, 'public/javascripts/vendor/handlebars.js'
37
+ # else
38
+ # puts 'building handlebars for development'
39
+ # FileUtils.cp Handlebars::Source.bundled_path, 'public/javascripts/vendor/handlebars.js'
40
+ # end
41
+ #end
42
+
43
+ def rewrite_file(file, &block)
44
+ source = File.read(file)
45
+ File.write(file, block.call(source))
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,8 @@
1
+ namespace :skydrive do
2
+ task :lti_key => :environment do
3
+ key = Skydrive::LtiKey.new_key
4
+ puts "key: #{key.key}"
5
+ puts "secret: #{key.secret}"
6
+ end
7
+ end
8
+
@@ -0,0 +1,11 @@
1
+ require 'test_helper'
2
+
3
+ module Skydrive
4
+ class EmberControllerTest < ActionController::TestCase
5
+ test "should get index" do
6
+ get :index
7
+ assert_response :success
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Dummy::Application.load_tasks
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
6
+ <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,25 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require(*Rails.groups)
6
+ require "skydrive"
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
15
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
16
+ # config.time_zone = 'Central Time (US & Canada)'
17
+
18
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
+ # config.i18n.default_locale = :de
21
+
22
+ config.action_dispatch.default_headers = { 'X-Frame-Options' => 'ALLOWALL' }
23
+ end
24
+ end
25
+
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ development:
7
+ adapter: sqlite3
8
+ database: db/development.sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ # Warning: The database defined as "test" will be erased and
13
+ # re-generated from your development database when you run "rake".
14
+ # Do not set this db to the same as development or production.
15
+ test:
16
+ adapter: sqlite3
17
+ database: db/test.sqlite3
18
+ pool: 5
19
+ timeout: 5000
20
+
21
+ production:
22
+ adapter: sqlite3
23
+ database: db/production.sqlite3
24
+ pool: 5
25
+ timeout: 5000
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ Dummy::Application.initialize!
@@ -0,0 +1,29 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
+
12
+ # Show full error reports and disable caching.
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send.
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger.
20
+ config.active_support.deprecation = :log
21
+
22
+ # Raise an error on page load if there are pending migrations
23
+ config.active_record.migration_error = :page_load
24
+
25
+ # Debug mode disables concatenation and preprocessing of assets.
26
+ # This option may cause significant delays in view rendering with a large
27
+ # number of complex assets.
28
+ config.assets.debug = true
29
+ end
@@ -0,0 +1,80 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # Code is not reloaded between requests.
5
+ config.cache_classes = true
6
+
7
+ # Eager load code on boot. This eager loads most of Rails and
8
+ # your application in memory, allowing both thread web servers
9
+ # and those relying on copy on write to perform better.
10
+ # Rake tasks automatically ignore this option for performance.
11
+ config.eager_load = true
12
+
13
+ # Full error reports are disabled and caching is turned on.
14
+ config.consider_all_requests_local = false
15
+ config.action_controller.perform_caching = true
16
+
17
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
+ # Add `rack-cache` to your Gemfile before enabling this.
19
+ # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
20
+ # config.action_dispatch.rack_cache = true
21
+
22
+ # Disable Rails's static asset server (Apache or nginx will already do this).
23
+ config.serve_static_assets = false
24
+
25
+ # Compress JavaScripts and CSS.
26
+ config.assets.js_compressor = :uglifier
27
+ # config.assets.css_compressor = :sass
28
+
29
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
30
+ config.assets.compile = false
31
+
32
+ # Generate digests for assets URLs.
33
+ config.assets.digest = true
34
+
35
+ # Version of your assets, change this if you want to expire all your assets.
36
+ config.assets.version = '1.0'
37
+
38
+ # Specifies the header that your server uses for sending files.
39
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
40
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
41
+
42
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
43
+ # config.force_ssl = true
44
+
45
+ # Set to :debug to see everything in the log.
46
+ config.log_level = :info
47
+
48
+ # Prepend all log lines with the following tags.
49
+ # config.log_tags = [ :subdomain, :uuid ]
50
+
51
+ # Use a different logger for distributed setups.
52
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
53
+
54
+ # Use a different cache store in production.
55
+ # config.cache_store = :mem_cache_store
56
+
57
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
58
+ # config.action_controller.asset_host = "http://assets.example.com"
59
+
60
+ # Precompile additional assets.
61
+ # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
62
+ # config.assets.precompile += %w( search.js )
63
+
64
+ # Ignore bad email addresses and do not raise email delivery errors.
65
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
66
+ # config.action_mailer.raise_delivery_errors = false
67
+
68
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
69
+ # the I18n.default_locale when a translation can not be found).
70
+ config.i18n.fallbacks = true
71
+
72
+ # Send deprecation notices to registered listeners.
73
+ config.active_support.deprecation = :notify
74
+
75
+ # Disable automatic flushing of the log to improve performance.
76
+ # config.autoflush_log = false
77
+
78
+ # Use default logging formatter so that PID and timestamp are not suppressed.
79
+ config.log_formatter = ::Logger::Formatter.new
80
+ end