lti_template_builder 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 114b7c3effaf50ca1f87c8f47a40c320a07e03dd
4
- data.tar.gz: 4ff676cee26f2c9dda9c2e764a03469b91f92bb1
3
+ metadata.gz: 4479af7fb1c4d496a33ed19910eb923ec5a66cad
4
+ data.tar.gz: 7ab6367ca0752ef7d522f0235fe38f0c9b88756f
5
5
  SHA512:
6
- metadata.gz: 74257ed2c94edea6770a58533e97ba28aaba92959fe35f93a80777adbcb9854a2843891185897b39b36800d875c4f473b8fd6aab985b244f4a9efe05abbca2df
7
- data.tar.gz: 79d95cd1355e711557efb0ad4a650a5a2ca4c5f27933074db6f7e1aa1290fa61b900cc45017bd4dbf7efb39b16ea0098736269a7c3e12c32a30a56bd59fa1fe8
6
+ metadata.gz: f796021d1ee180fdee017f7e470e127210c5516a10b7ae63fb8abdd35dfdc3ff2ba2d73ff1beedf5e0fa343f7cd1ab060faae0ef1fe0a75f11a1bb4f026acc97
7
+ data.tar.gz: 86ac49d8daea9d085ec26fe571d3c83898463631f00c27bdf318f5eee27a90d17f39ef8844ee0348765c8a9f4e1780f12648201550e3c0a69f3933ee6f6ef2ac
@@ -2,6 +2,15 @@ inject_into_file "app/controllers/#{name}/lti_controller.rb", after: "def index\
2
2
  @launch_params = params.reject!{ |k,v| ['controller','action'].include? k }
3
3
  end
4
4
 
5
+ def launch
6
+ url = params[:url]
7
+ if url && url =~ /\\Ahttps?:\\/\\/.+\\..+\\Z/
8
+ redirect_to url
9
+ else
10
+ head 500
11
+ end
12
+ end
13
+
5
14
  def embed
6
15
  launch_params = JSON.parse(params[:launch_params] || "{}")
7
16
 
@@ -12,23 +21,24 @@ inject_into_file "app/controllers/#{name}/lti_controller.rb", after: "def index\
12
21
  # This should be replaced by actual logic.
13
22
  embed_type = params[:embed_type]
14
23
  if embed_type =~ /Video/
24
+ @content_type = "iframe"
15
25
  @title = "Getting Started in Canvas Network"
16
- @url = "//player.vimeo.com/video/79702646"
26
+ @url = "https://player.vimeo.com/video/79702646"
17
27
  @width = "500"
18
28
  @height = "284"
19
29
  elsif embed_type =~ /Picture/
30
+ @content_type = "image_url"
20
31
  @title = "Laughing Dog"
21
32
  @url = "https://dl.dropboxusercontent.com/u/2176587/laughing_dog.jpeg"
22
33
  @width = "284"
23
34
  @height = "177"
24
- else
25
- @title = "My Lti App"
26
- @url = "\#{root_url}" # <-- build return URL
27
- @width = 500 # <-- modal width (if applicable)
28
- @height = 530 # <-- modal height (if applicable)
35
+ elsif embed_type =~ /Link/
36
+ @content_type = "url"
37
+ @title = "Edu App Center"
38
+ @url = "https://www.eduappcenter.com"
29
39
  end
30
40
 
31
- redirect_url = build_url(tp, @title, @url, @width, @height)
41
+ redirect_url = build_url(tp, @title, @url, @width, @height, @content_type)
32
42
 
33
43
  if redirect_url.present?
34
44
  redirect_to redirect_url
@@ -58,14 +68,18 @@ inject_into_file "app/controllers/#{name}/lti_controller.rb", after: "def index\
58
68
 
59
69
  private
60
70
 
61
- def build_url(tp, title, url, width, height)
71
+ def build_url(tp, title, url, width, height, content_type)
62
72
  if tp.accepts_content?
63
- if tp.accepts_iframe?
73
+ redirect_url = nil
74
+ if content_type == "image_url" && tp.accepts_url?
75
+ redirect_url = tp.image_content_return_url(url, width, height, title)
76
+ elsif content_type == "iframe" && tp.accepts_iframe?
64
77
  redirect_url = tp.iframe_content_return_url(url, width, height, title)
65
78
  elsif tp.accepts_url?
66
- redirect_url = tp.url_content_return_url(url, title)
79
+ redirect_url = tp.url_content_return_url(url, title, title)
67
80
  elsif tp.accepts_lti_launch_url?
68
- redirect_url = tp.lti_launch_content_return_url(url, title, title)
81
+ launch_url = launch_url(url: url)
82
+ redirect_url = tp.lti_launch_content_return_url(launch_url, title, title)
69
83
  end
70
84
  return redirect_url
71
85
  end
@@ -76,6 +90,7 @@ route 'root "lti#index"'
76
90
  route 'match "/" => "lti#index", via: [:get, :post]'
77
91
  route 'get "health_check" => "lti#health_check"'
78
92
  route 'get "config(.xml)" => "lti#xml_config", as: :lti_xml_config'
93
+ route 'match "launch" => "lti#launch", as: :launch, via: [:get, :post]'
79
94
 
80
95
  remove_file "app/views/#{name}/lti/index.html.erb"
81
96
  create_file "app/views/#{name}/lti/index.html.erb" do <<-'RUBY'
@@ -92,14 +107,18 @@ create_file "app/views/#{name}/lti/index.html.erb" do <<-'RUBY'
92
107
  <%%= form_tag lti_embed_path do %>
93
108
  <input type="hidden" name="launch_params" value="<%%= @launch_params.to_json %>" />
94
109
  <div class="row">
95
- <div class="col-xs-6">
96
- <input type="submit" name="embed_type" class="btn btn-large btn-info btn-block"
110
+ <div class="col-xs-4">
111
+ <input type="submit" name="embed_type" class="btn btn-large btn-info btn-block"
97
112
  value="Embed a Video" />
98
113
  </div>
99
- <div class="col-xs-6">
100
- <input type="submit" name="embed_type" class="btn btn-large btn-success btn-block"
114
+ <div class="col-xs-4">
115
+ <input type="submit" name="embed_type" class="btn btn-large btn-success btn-block"
101
116
  value="Embed a Picture" />
102
117
  </div>
118
+ <div class="col-xs-4">
119
+ <input type="submit" name="embed_type" class="btn btn-large btn-warning btn-block"
120
+ value="Embed a Link" />
121
+ </div>
103
122
  </div>
104
123
  <%% end %>
105
124
  </div>
@@ -1,3 +1,3 @@
1
1
  module LtiTemplateBuilder
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lti_template_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Berry