coalescing_panda 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,4 +10,5 @@
10
10
  // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
11
  // about supported directives.
12
12
  //
13
+ //= require jquery
13
14
  //= require_tree .
@@ -1,3 +1,22 @@
1
+ html, body {
2
+ font-family: Arial, Helvetica, sans-serif;
3
+ color: black !important;
4
+ font-size: 10pt;
5
+ background: transparent none !important;
6
+ }
7
+
8
+ h1 {
9
+ font-size: 23px !important;
10
+ }
11
+
12
+ h2 {
13
+ font-size: 14px !important;
14
+ }
15
+
16
+ h3 {
17
+ font-size: 19px !important;
18
+ }
19
+
1
20
  .btn-canvas {
2
21
  display: inline-block;
3
22
  padding: 4px 12px;
@@ -9,5 +9,8 @@
9
9
  * compiled file, but it's generally better to create a new file per style scope.
10
10
  *
11
11
  *= require_self
12
+ *= require bootstrap/bootstrap
13
+ *= require bootstrap/bootstrap-responsive
14
+ *= require bootstrap/bootstrap-overrides
12
15
  *= require_tree .
13
16
  */
@@ -0,0 +1,3 @@
1
+ #launch-content {
2
+ width: 50%;
3
+ }
@@ -1,4 +0,0 @@
1
- /*
2
- Place all the styles related to the matching controller here.
3
- They will automatically be included in application.css.
4
- */
@@ -27,6 +27,14 @@ module CoalescingPanda
27
27
  render :xml => xml
28
28
  end
29
29
 
30
+ def styleguide
31
+ render file: 'coalescing_panda/styleguide/styleguide.html'
32
+ end
33
+
34
+ def launch
35
+ render 'coalescing_panda/launch'
36
+ end
37
+
30
38
  private
31
39
 
32
40
  def setting_name(name)
@@ -0,0 +1,6 @@
1
+ .hero-unit
2
+ %h1.title
3
+ You should do an LTI Tool Launch.
4
+ %p
5
+ - link = raw("<a href='/lti/config'>HERE</a>")
6
+ Click the #{link} to get the configuration XML.
@@ -0,0 +1,227 @@
1
+ <!doctype html>
2
+
3
+ <html lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
6
+ <title>Styleguide</title>
7
+ <style>#nav {
8
+ position: absolute;
9
+ top: 0;
10
+ left: 0;
11
+ width: 200px;
12
+ bottom: 0;
13
+ overflow: auto;
14
+ -webkit-overflow-scrolling: touch;
15
+ }
16
+
17
+ #nav > *:fist-child {
18
+ height: 100.5%
19
+ }
20
+
21
+ #nav ul {
22
+ padding: 0;
23
+ margin: 0;
24
+ list-style: none;
25
+ }
26
+
27
+ #nav a {
28
+ display: block;
29
+ border-bottom: solid 1px #ccc;
30
+ padding: 8px 4px;
31
+ text-decoration: none;
32
+ background: #fff;
33
+ color: #454545;
34
+ }
35
+
36
+ #nav a:hover {
37
+ background: #f5f5f5;
38
+ }
39
+
40
+ #nav a.active {
41
+ background: #0088cc;
42
+ color: #fff;
43
+ }
44
+
45
+
46
+ #docs {
47
+ border-left: solid 1px;
48
+ position: absolute;
49
+ top: 0;
50
+ left: 200px;
51
+ right: 0;
52
+ bottom: 0;
53
+ overflow: auto;
54
+ -webkit-overflow-scrolling: touch;
55
+ background: #ccc;
56
+ }
57
+
58
+ #docs > article {
59
+ margin: 40px 20px;
60
+ padding: 20px;
61
+ min-height: 60%;
62
+ box-shadow: 2px 6px 16px rgba(0, 0, 0, 0.5);
63
+ background: #fff;
64
+ max-width: 700px;
65
+ }
66
+
67
+ #docs > article:first-child {
68
+ border:none;
69
+ }
70
+
71
+ .code-demo:hover {
72
+ margin-left: -12px;
73
+ border-left: solid 4px #0088cc;
74
+ padding-left: 8px;
75
+ }
76
+
77
+ .hll { background-color: #ffffcc }
78
+ .c { color: #999988; font-style: italic } /* Comment */
79
+ .err { color: #a61717; background-color: #e3d2d2 } /* Error */
80
+ .k { color: #000000; font-weight: bold } /* Keyword */
81
+ .o { color: #000000; font-weight: bold } /* Operator */
82
+ .cm { color: #999988; font-style: italic } /* Comment.Multiline */
83
+ .cp { color: #999999; font-weight: bold; font-style: italic } /* Comment.Preproc */
84
+ .c1 { color: #999988; font-style: italic } /* Comment.Single */
85
+ .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */
86
+ .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
87
+ .ge { color: #000000; font-style: italic } /* Generic.Emph */
88
+ .gr { color: #aa0000 } /* Generic.Error */
89
+ .gh { color: #999999 } /* Generic.Heading */
90
+ .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
91
+ .go { color: #888888 } /* Generic.Output */
92
+ .gp { color: #555555 } /* Generic.Prompt */
93
+ .gs { font-weight: bold } /* Generic.Strong */
94
+ .gu { color: #aaaaaa } /* Generic.Subheading */
95
+ .gt { color: #aa0000 } /* Generic.Traceback */
96
+ .kc { color: #000000; font-weight: bold } /* Keyword.Constant */
97
+ .kd { color: #000000; font-weight: bold } /* Keyword.Declaration */
98
+ .kn { color: #000000; font-weight: bold } /* Keyword.Namespace */
99
+ .kp { color: #000000; font-weight: bold } /* Keyword.Pseudo */
100
+ .kr { color: #000000; font-weight: bold } /* Keyword.Reserved */
101
+ .kt { color: #445588; font-weight: bold } /* Keyword.Type */
102
+ .m { color: #009999 } /* Literal.Number */
103
+ .s { color: #d01040 } /* Literal.String */
104
+ .na { color: #008080 } /* Name.Attribute */
105
+ .nb { color: #0086B3 } /* Name.Builtin */
106
+ .nc { color: #445588; font-weight: bold } /* Name.Class */
107
+ .no { color: #008080 } /* Name.Constant */
108
+ .nd { color: #3c5d5d; font-weight: bold } /* Name.Decorator */
109
+ .ni { color: #800080 } /* Name.Entity */
110
+ .ne { color: #990000; font-weight: bold } /* Name.Exception */
111
+ .nf { color: #990000; font-weight: bold } /* Name.Function */
112
+ .nl { color: #990000; font-weight: bold } /* Name.Label */
113
+ .nn { color: #555555 } /* Name.Namespace */
114
+ .nt { color: #000080 } /* Name.Tag */
115
+ .nv { color: #008080 } /* Name.Variable */
116
+ .ow { color: #000000; font-weight: bold } /* Operator.Word */
117
+ .w { color: #bbbbbb } /* Text.Whitespace */
118
+ .mf { color: #009999 } /* Literal.Number.Float */
119
+ .mh { color: #009999 } /* Literal.Number.Hex */
120
+ .mi { color: #009999 } /* Literal.Number.Integer */
121
+ .mo { color: #009999 } /* Literal.Number.Oct */
122
+ .sb { color: #d01040 } /* Literal.String.Backtick */
123
+ .sc { color: #d01040 } /* Literal.String.Char */
124
+ .sd { color: #d01040 } /* Literal.String.Doc */
125
+ .s2 { color: #d01040 } /* Literal.String.Double */
126
+ .se { color: #d01040 } /* Literal.String.Escape */
127
+ .sh { color: #d01040 } /* Literal.String.Heredoc */
128
+ .si { color: #d01040 } /* Literal.String.Interpol */
129
+ .sx { color: #d01040 } /* Literal.String.Other */
130
+ .sr { color: #009926 } /* Literal.String.Regex */
131
+ .s1 { color: #d01040 } /* Literal.String.Single */
132
+ .ss { color: #990073 } /* Literal.String.Symbol */
133
+ .bp { color: #999999 } /* Name.Builtin.Pseudo */
134
+ .vc { color: #008080 } /* Name.Variable.Class */
135
+ .vg { color: #008080 } /* Name.Variable.Global */
136
+ .vi { color: #008080 } /* Name.Variable.Instance */
137
+ .il { color: #009999 } /* Literal.Number.Integer.Long */
138
+ </style>
139
+ </head>
140
+ <body>
141
+
142
+ <nav id="nav">
143
+ <ul>
144
+ </ul>
145
+ </nav>
146
+
147
+ <section id="docs">
148
+ </section>
149
+
150
+ <script>;(function() {
151
+ var items = document.querySelectorAll('#nav a');
152
+ var docs = document.getElementById('docs');
153
+ var articles = [].slice.call(docs.querySelectorAll('article'), 0);
154
+ var tops;
155
+
156
+ var setTops = function() {
157
+ tops = articles.map(function(header) {
158
+ return header.offsetTop;
159
+ });
160
+ setTimeout(setTops, 1000);
161
+ };
162
+
163
+ var setAnchor = function() {
164
+ var top = docs.scrollTop + (docs.offsetHeight / 2);
165
+ var inView;
166
+ for (var i = 0; i < tops.length; i += 1) {
167
+ if (tops[i] >= top) break;
168
+ }
169
+ setCurrent(i - 1);
170
+ };
171
+
172
+ var setCurrent = (function() {
173
+ var current;
174
+ return function(index) {
175
+ var item = items[index];
176
+ if (current) current.setAttribute('class', '');
177
+ item.setAttribute('class', 'active');
178
+ current = item;
179
+ var article = articles[index];
180
+ var id = article.getAttribute('id');
181
+ article.setAttribute('id', '');
182
+ location.hash = item.hash
183
+ article.setAttribute('id', id);
184
+ }
185
+ })();
186
+
187
+ var throttle = function(func, wait) {
188
+ var context, args, timeout, throttling, more;
189
+ var whenDone = debounce(function(){ more = throttling = false; }, wait);
190
+ return function() {
191
+ context = this; args = arguments;
192
+ var later = function() {
193
+ timeout = null;
194
+ if (more) func.apply(context, args);
195
+ whenDone();
196
+ };
197
+ if (!timeout) timeout = setTimeout(later, wait);
198
+ if (throttling) {
199
+ more = true;
200
+ } else {
201
+ func.apply(context, args);
202
+ }
203
+ whenDone();
204
+ throttling = true;
205
+ };
206
+ };
207
+
208
+ var debounce = function(func, wait) {
209
+ var timeout;
210
+ return function() {
211
+ var context = this, args = arguments;
212
+ var later = function() {
213
+ timeout = null;
214
+ func.apply(context, args);
215
+ };
216
+ clearTimeout(timeout);
217
+ timeout = setTimeout(later, wait);
218
+ };
219
+ };
220
+
221
+ setTops();
222
+ docs.addEventListener('scroll', throttle(setAnchor, 100));
223
+
224
+ })();
225
+
226
+ </script>
227
+
data/config/routes.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  CoalescingPanda::Engine.routes.draw do
2
2
  get '/oauth2/redirect' => 'oauth2#redirect'
3
3
  get '/config' => 'lti#lti_config'
4
+ get '/launch' => 'lti#launch'
5
+ get '/styleguide' => 'lti#styleguide'
4
6
  end
@@ -0,0 +1,16 @@
1
+ # required - the file to generate
2
+ out_file: public/styleguide.html
3
+
4
+ # required - the files to extract docs from
5
+ glob: app/assets/stylesheets/**/*.css.scss
6
+
7
+ # optional - components can display where they are defined, this will be
8
+ # stripped from that definition
9
+ base_dir: app/stylesheets
10
+
11
+ # optional - Inline DressCode CSS styles, defaults to true
12
+ dress_code_css: true
13
+
14
+ # optional - Inline DressCode JS, defaults to true
15
+ dress_code_js: true
16
+
@@ -2,12 +2,15 @@ module CoalescingPanda
2
2
  module ControllerHelpers
3
3
 
4
4
  def canvas_oauth2(*roles)
5
+ return if have_session?
5
6
  if lti_authorize!(*roles)
6
7
  user_id = params['user_id']
7
8
  uri = URI.parse(params['launch_presentation_return_url'])
8
9
  api_domain = uri.host
9
10
  api_domain = "#{api_domain}:#{uri.port.to_s}" if uri.port
10
11
  scheme = uri.scheme + '://'
12
+ session['user_id'] = user_id
13
+ session['uri'] = params['launch_presentation_return_url']
11
14
 
12
15
  if token = CanvasApiAuth.where('user_id = ? and api_domain = ?', user_id, api_domain).pluck(:api_token).first
13
16
  @client = Bearcat::Client.new(token: token, prefix: scheme+api_domain)
@@ -26,6 +29,18 @@ module CoalescingPanda
26
29
  end
27
30
  end
28
31
 
32
+ def have_session?
33
+ if(session['user_id'] && session['uri'])
34
+ uri = URI.parse(session['uri'])
35
+ api_domain = uri.host
36
+ api_domain = "#{api_domain}:#{uri.port.to_s}" if uri.port
37
+ scheme = uri.scheme + '://'
38
+ token = CanvasApiAuth.where('user_id = ? and api_domain = ?', session['user_id'], api_domain).pluck(:api_token).first
39
+ @client = Bearcat::Client.new(token: token, prefix: scheme+api_domain) if token
40
+ end
41
+ !!@client
42
+ end
43
+
29
44
  def lti_authorize!(*roles)
30
45
  authorized = false
31
46
  if @lti_account = params['oauth_consumer_key'] && LtiAccount.find_by_key(params['oauth_consumer_key'])
@@ -6,7 +6,7 @@ module CoalescingPanda
6
6
  valid_options = [:course, :user, :account, :editor_button, :external_tool]
7
7
  if rest.empty? && nav.is_a?(Hash)
8
8
  options = nav
9
- nav, to = options.find {|name, _value| valid_options.include? name}
9
+ nav, to = options.find {|name, _| valid_options.include? name}
10
10
  options[:to] = to
11
11
  options.delete(nav)
12
12
  else
@@ -1,3 +1,3 @@
1
1
  module CoalescingPanda
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coalescing_panda
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-22 00:00:00.000000000 Z
12
+ date: 2014-01-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -233,10 +233,11 @@ files:
233
233
  - app/assets/javascripts/coalescing_panda/application.js
234
234
  - app/assets/javascripts/coalescing_panda/oauth2.js.coffee
235
235
  - app/assets/stylesheets/bootstrap/bootstrap-datepicker.css
236
- - app/assets/stylesheets/bootstrap/bootstrap-overrides.css
236
+ - app/assets/stylesheets/bootstrap/bootstrap-overrides.css.scss
237
237
  - app/assets/stylesheets/bootstrap/bootstrap-responsive.css
238
238
  - app/assets/stylesheets/bootstrap/bootstrap.css.scss
239
239
  - app/assets/stylesheets/coalescing_panda/application.css
240
+ - app/assets/stylesheets/coalescing_panda/launch.css.scss
240
241
  - app/assets/stylesheets/coalescing_panda/oauth2.css
241
242
  - app/controllers/coalescing_panda/application_controller.rb
242
243
  - app/controllers/coalescing_panda/lti_controller.rb
@@ -244,10 +245,13 @@ files:
244
245
  - app/models/coalescing_panda/canvas_api_auth.rb
245
246
  - app/models/coalescing_panda/lti_account.rb
246
247
  - app/models/coalescing_panda/lti_nonce.rb
248
+ - app/views/coalescing_panda/launch.html.haml
247
249
  - app/views/coalescing_panda/oauth2/oauth2.html.haml
248
250
  - app/views/coalescing_panda/oauth2/redirect.html.haml
251
+ - app/views/coalescing_panda/styleguide/styleguide.html
249
252
  - app/views/layouts/coalescing_panda/application.html.erb
250
253
  - config/routes.rb
254
+ - config/styleguide.yml
251
255
  - db/migrate/20131114150001_create_coalescing_panda_canvas_api_auths.rb
252
256
  - db/migrate/20131118211442_create_coalescing_panda_lti_accounts.rb
253
257
  - db/migrate/20131119165343_create_coalescing_panda_lti_nonces.rb