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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4479af7fb1c4d496a33ed19910eb923ec5a66cad
|
4
|
+
data.tar.gz: 7ab6367ca0752ef7d522f0235fe38f0c9b88756f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 = "
|
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
|
-
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
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
|
-
|
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
|
-
|
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-
|
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-
|
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>
|