Skip to content

Commit

Permalink
Cleanup (#38)
Browse files Browse the repository at this point in the history
* Removes unused css files

* Nest Application Instances in Applications for seeds

* Removed button from default messages

* Styling for alert messages

* Only declare font style once.

* Adds space
  • Loading branch information
jbasdf committed Feb 22, 2017
1 parent 6a4f851 commit 15543ba
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 74 deletions.
8 changes: 1 addition & 7 deletions app/assets/stylesheets/client.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@

// Modules and Variables
@import "client/partials/base";

// Partials
@import "client/partials/index";
// ...
html {}
1 change: 0 additions & 1 deletion app/assets/stylesheets/client/fonts/.keep

This file was deleted.

1 change: 0 additions & 1 deletion app/assets/stylesheets/client/modules/_index.css.scss

This file was deleted.

2 changes: 0 additions & 2 deletions app/assets/stylesheets/client/partials/_base.scss

This file was deleted.

2 changes: 0 additions & 2 deletions app/assets/stylesheets/client/partials/_index.scss

This file was deleted.

3 changes: 1 addition & 2 deletions app/views/layouts/_messages.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<%# Rails flash messages styled for Bootstrap 3.0 %>
<% flash.each do |name, msg| %>
<% if msg.is_a?(String) %>
<div class="alert alert-<%= name.to_s == 'notice' ? 'success' : 'danger' %>">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
<div class="c-alert c-alert--<%= name.to_s == 'notice' ? 'success' : 'danger' %>">
<%= content_tag :div, msg, :id => "flash_#{name}" %>
</div>
<% end %>
Expand Down
2 changes: 0 additions & 2 deletions client/styles/admin/modules/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,13 @@
}

@mixin semi-bold{
font-family: 'Roboto', sans-serif;
font-weight: 500;
}
@mixin regular{
font-family: 'Roboto', sans-serif;
font-weight: 400;
}
@mixin bold{
font-family: 'Roboto', sans-serif;
font-weight: 700;
}

Expand Down
13 changes: 13 additions & 0 deletions client/styles/admin/partials/_alerts.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.c-alert{
font-size: 16px;
text-align: center;
margin: 10px;
}

.c-alert--success{
color: #00FF00;
}

.c-alert--danger{
color: #FF0000;
}
1 change: 1 addition & 0 deletions client/styles/admin/partials/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ html, html a {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-shadow: 1px 1px 1px rgba(0,0,0,0.004);
@include regular;
}

html{
Expand Down
1 change: 0 additions & 1 deletion client/styles/admin/partials/_info.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
border-radius: 1.8rem;
padding: 0 2rem 0 3.5rem;
font-size: 1.6rem;
@include regular;
color: $dark-gray;

&:focus{
Expand Down
6 changes: 0 additions & 6 deletions client/styles/admin/partials/_inputs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
height: 3.5rem;
border: 0.1rem solid $gray;
padding: 0 1.5rem;
@include regular;
font-size: 1.4rem;
width: 100%;
}
Expand All @@ -27,7 +26,6 @@
border: 0.1rem solid $light-gray;
outline: none;
padding: 0.7rem 1rem;
@include regular;
font-size: 1.4rem;
color: $text-color;
}
Expand All @@ -41,14 +39,12 @@
border: none;
background: $lightest-gray;
padding: 0 1.5rem;
@include regular;
font-size: 1.4rem;
width: 100%;
}
}

.c-checkbox{
@include regular;
font-size: 1.4rem;
color: $text-color;
margin-bottom: 2rem;
Expand Down Expand Up @@ -94,7 +90,6 @@
background: none;
outline: none;
font-size: 1.4rem;
@include regular;
padding: 0 1.5rem;
color: $text-color;
position: relative;
Expand Down Expand Up @@ -122,7 +117,6 @@

.Select-option{
font-size: 1.4rem;
@include regular;
color: $text-color;
padding: 0 1.5rem;
line-height: 3.5rem;
Expand Down
2 changes: 0 additions & 2 deletions client/styles/admin/partials/_modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@
}

.c-modal__text{
@include regular;
font-size: 1.8rem;
color: $gray2;
text-align: center;
Expand All @@ -129,7 +128,6 @@
}

a.c-modal__link{
@include regular;
font-size: 1.8rem;
color: $blue;
margin: 2rem 0 3rem;
Expand Down
2 changes: 0 additions & 2 deletions client/styles/admin/partials/_sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
font-size: 1.2rem;
color: $yellow;
text-transform: uppercase;
@include regular;
letter-spacing: 0.1rem;
margin: 0 0 0.5rem;
}
Expand Down Expand Up @@ -54,7 +53,6 @@
font-size: 1.2rem;
color: $light-gray;
text-transform: uppercase;
@include regular;
letter-spacing: 0.1rem;
margin: 0 0 0.5rem;
}
Expand Down
4 changes: 0 additions & 4 deletions client/styles/admin/partials/_tables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,20 @@
&:nth-of-type(1){

div{
@include regular;
font-size: 1.2rem;
color: $gray;
}
}
&:nth-of-type(2){

span{
@include regular;
font-size: 1.2rem;
color: $gray;
}
}
&:nth-of-type(3){

span{
@include regular;
font-size: 1.2rem;
color: $gray;
}
Expand Down Expand Up @@ -87,7 +84,6 @@
&:nth-of-type(2){

span{
@include regular;
font-size: 1.2rem;
color: $gray;
}
Expand Down
1 change: 1 addition & 0 deletions client/styles/admin/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@import "partials/modal";
@import "partials/inputs";
@import "partials/login";
@import "partials/alerts";
// ...

// Third-party
82 changes: 40 additions & 42 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,42 +30,53 @@
client_application_name: "admin_app",
canvas_api_permissions: admin_api_permissions,
kind: Application.kinds[:admin],
application_instances: [{
tenant: "lti-admin",
lti_key: "lti-admin",
site_url: Rails.application.secrets.canvas_url,
domain: "admin.#{Rails.application.secrets.domain_name}",
lti_type: "account_navigation",
}],
},
{
name: "LTI Starter App",
description: "LTI Starter App by Atomic Jolt",
client_application_name: "app",
# List Canvas API methods the app is allowed to use. A full list of constants can be found in canvas_urls
canvas_api_permissions: "LIST_ACCOUNTS",
application_instances: [{
tenant: Rails.application.secrets.default_lti_key,
lti_key: Rails.application.secrets.default_lti_key,
lti_secret: Rails.application.secrets.default_lti_secret,
site_url: Rails.application.secrets.canvas_url,
# This is only required if the app needs API access and doesn't want each user to do the oauth dance
canvas_token: Rails.application.secrets.canvas_token,
# Each application instance can have it's own custom domain. Typically, this is not needed
# as the application will use the oauth_consumer_key from the LTI launch to partition different
# application instances. However, if Canvas is launching the LTI tool based on url then you will
# need a different domain for that tool since Canvas uses the domain to find the LTI tool among
# all installed LTI tools. If two tools share the same domain then the tool discovered by Canvas
# to do the LTI launch will be indeterminate
domain: "#{Rails.application.secrets.default_lti_key}.#{Rails.application.secrets.domain_name}",
}],
},
]

application_instances = [
{
application: "LTI Admin",
tenant: "lti-admin",
lti_key: "lti-admin",
url: Rails.application.secrets.canvas_url,
domain: "admin.#{Rails.application.secrets.domain_name}",
lti_type: "account_navigation",
},
{
application: "LTI Starter App",
tenant: Rails.application.secrets.default_lti_key,
lti_key: Rails.application.secrets.default_lti_key,
lti_secret: Rails.application.secrets.default_lti_secret,
url: Rails.application.secrets.canvas_url,
# This is only required if the app needs API access and doesn't want each user to do the oauth dance
canvas_token: Rails.application.secrets.canvas_token,
# Each application instance can have it's own custom domain. Typically, this is not needed
# as the application will use the oauth_consumer_key from the LTI launch to partition different
# application instances. However, if Canvas is launching the LTI tool based on url then you will
# need a different domain for that tool since Canvas uses the domain to find the LTI tool among
# all installed LTI tools. If two tools share the same domain then the tool discovered by Canvas
# to do the LTI launch will be indeterminate
domain: "#{Rails.application.secrets.default_lti_key}.#{Rails.application.secrets.domain_name}",
},
]
def setup_application_instances(application, application_instances)
application_instances.each do |attrs|
site = Site.find_by(url: attrs.delete(:site_url))
attrs = attrs.merge(application_id: application.id, site_id: site.id)

if application_instance = ApplicationInstance.find_by(lti_key: attrs[:lti_key])
# Don't change production lti keys or set keys to nil
attrs.delete(:lti_secret) if attrs[:lti_secret].blank? || Rails.env.production?

application_instance.update_attributes!(attrs)
else
ApplicationInstance.create!(attrs)
end
end
end

sites.each do |attrs|
if site = Site.find_by(url: attrs[:url])
Expand All @@ -76,26 +87,13 @@
end

applications.each do |attrs|
application_instances = attrs.delete(:application_instances)
if application = Application.find_by(name: attrs[:name])
application.update_attributes!(attrs)
else
Application.create!(attrs)
end
end

application_instances.each do |attrs|
application = Application.find_by(name: attrs.delete(:application))
site = Site.find_by(url: attrs.delete(:url))
attrs = attrs.merge(application_id: application.id, site_id: site.id)

if application_instance = ApplicationInstance.find_by(lti_key: attrs[:lti_key])
# Don't change production lti keys or set keys to nil
attrs.delete(:lti_secret) if attrs[:lti_secret].blank? || Rails.env.production?

application_instance.update_attributes!(attrs)
else
ApplicationInstance.create!(attrs)
application = Application.create!(attrs)
end
setup_application_instances(application, application_instances)
end

Lti::Utils.lti_configs

0 comments on commit 15543ba

Please sign in to comment.