Commit Graph

30 Commits

Author SHA1 Message Date
Cody Cutrer eb3e0e7d4c use a consistent shard for css_and_js_overrides cache
Change-Id: Idb640305ce2cab2524ce6329ffeb014f150d76ac
Reviewed-on: https://gerrit.instructure.com/142664
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Jenkins
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2018-03-06 05:47:39 +00:00
Ryan Shaw cc49521daa Fix link & brand-primary color HC & ie11
Closes: CNVS-38498 CORE-25 CORE-338

test plan:
* turn on high contrast
* using ie11, make sure that all the links and things that should
  be the brand-primary color look right. (Dark, not light, blue)
* make sure they also look good in edge 15 and chrome with HC on.

Change-Id: I83cb35aa40c774bcd8e4c0a1a18b8cb0875e9a0c
Reviewed-on: https://gerrit.instructure.com/129911
Tested-by: Jenkins
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
2017-11-02 17:36:22 +00:00
Ryan Shaw 094d65a1cb Remove remaining dynamic brand css code
closes: CNVS-39103 CNVS-39104 CNVS-38650

test plan:
* do a general css styling regression pass
* make sure that the urls to css files look like
  /dist/brandable_css/new_styles_normal_contrast/<bundle>-<fingerprint>.css
  and not:
  /dist/brandable_css/<big long md5>/new_styles_normal_contrast/<bundle>-<fingerprint>.css
* make sure that stylesheets loaded by handlebars templates work
  eg: go to the calendar page and make sure it is styled correctly
* verify that the theme editor works. especially the process when you hit
  "preivew" and "apply"
* set up config/canvas_cdn.yml to use the dev cdn
* run `bundle exec canvas:compile_assets && bundle exec rake canvas:cdn:upload_to_s3`
* load a page, all the css should load from the cdn
* verify the theme editor works when using the cdn too.

* also review the changes in the brandable_css npm package:
  https://github.com/ryankshaw/brandable_css/compare/c6bef...b159d5

Change-Id: I55db41e90f6bc54183a661128f1050445a086d6b
Reviewed-on: https://gerrit.instructure.com/120912
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
2017-10-03 22:49:11 +00:00
Ryan Shaw 0f2832dcb0 Write css file with brand variables
closes:  CNVS-38408

NOTE: this does not actually change any behavior, it just
gets things set up so we can actually start using css variables
in follow-on commits.

test plan:
* with this checked out,
* run bundle exec rake brand_configs:generate_and_upload_all & compile assets
* open a page in canvas
* there should be a stylesheet near the top of the <head> with css variables
  of all the theme editor variables.

Change-Id: I2caa210917d9245ae103d1444d6353ecfdeb59fe
Reviewed-on: https://gerrit.instructure.com/120574
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Jenkins
QA-Review: Tucker McKnight <tmcknight@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
2017-07-28 22:23:25 +00:00
Landon Wilkins 9056b660b4 da licença part 9
add consistent license headers to all source files
(ruby, coffeescript, javascript)

except for vendor files

Change-Id: Ia785c0afdc3ad2352aeffab98645a7dcb8169cb5
Reviewed-on: https://gerrit.instructure.com/110029
Tested-by: Jenkins
Reviewed-by: Jon Jensen <jon@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
2017-04-27 21:33:39 +00:00
Ryan Shaw 98e45ee75e Generate JavaScript file file for brand configs
closes: CNVS-34333

things like inst-ui can now just look for a global
variable named `CANVAS_ACTIVE_BRAND_VARIABLES` that
will be present on every page to get all the colors/variables
they need to do theming.

you may need to run:
`bundle exec rake brand_configs:generate_and_upload_all`

to generate these files for all the brands you already
have in your local db for testing this locally.  that rake
task is ran in every deploy so they will get created for all the existing
brand_cofigs in prod/beta

test plan:
* with no brand applied:
* load a page
* view source and make sure there is a script tag something like this:
  <script src="/dist/brandable_css/default/variables-xxxxx.js"></script>
* open your dev console and type:
  console.log(CANVAS_ACTIVE_BRAND_VARIABLES['ic-brand-primary’])
* it should log “#008EE2” (the default canvas brand primary color)

* go to the theme editor and set your “brand primary” to e.g: #629f56
* load a page, and open your dev console and type:
  console.log(CANVAS_ACTIVE_BRAND_VARIABLES['ic-brand-primary’])
* it should log “#629f56”

Change-Id: Ie48d0dbcb8a79429d3d55779efdbf4ef07c636c6
Reviewed-on: https://gerrit.instructure.com/99509
Tested-by: Jenkins
Reviewed-by: Ed Schiebel <eschiebel@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
2017-02-17 21:05:18 +00:00
Cody Cutrer 1f03606627 aws sdk v2 support for attachments
closes CNVS-33615

test plan:
 * upload and download files using S3
 * submit an assignment
 * do an SIS import with parallel
 * do a course copy
 * export and import a course
 * upload some custom css file in theme editor
 * test a canvadoc and crocodoc preview

Change-Id: I9145b39728938e7e5903d23c4a4598fc8df4ef45
Reviewed-on: https://gerrit.instructure.com/93002
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
2017-01-24 21:09:14 +00:00
James Williams 89370c5f11 remove protected_attributes
refs #CNVS-32574

Change-Id: I3ba018a7110a7530c9af4a59c97422f626a749b6
Reviewed-on: https://gerrit.instructure.com/99260
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2017-01-12 17:46:18 +00:00
James Williams f58544fc35 strong params part C
refs #CNVS-32574

Change-Id: I272579bba8c1993fc5af872abe685f21318833a2
Reviewed-on: https://gerrit.instructure.com/94567
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2017-01-10 23:36:46 +00:00
Cody Cutrer 16c15781eb memoize css_and_js_overrides for a brand config
refs CNVS-31321

this may be queried multiple times from the same object in an API
response with lots of different api_user_content

Change-Id: I85fb56cc95fd65fa48b2b5c2d37500115a72ed36
Reviewed-on: https://gerrit.instructure.com/88806
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2016-08-26 16:27:33 +00:00
James Williams bea0c0071e use cache_key in brand config cache
Change-Id: Ifd4c87a1f3daa630c5247f9431ad21025b6bf621
Reviewed-on: https://gerrit.instructure.com/82639
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2016-06-16 12:19:43 +00:00
Ryan Shaw bcd0569251 handle regenerating all sub account themes & shared themes
fixes: CNVS-28400

test plan:

test 1.
for root account with unbranded child but branded
grandchild. aka:
When you have Acct (with Theme A) -> 
Sub Acct (with no theme) -> 
Sub Sub Account (with theme B), 
and update Theme A, Theme B is not updated to inherit 
from the new A.

* start with root no brand config, child no brand
* create a theme for grandchild with red buttons
  and js file with "console.log('from grandchild')"
* go to root. set a theme with blue nav bg &
  js file with "console.log('from root')"
* you should see progress for generating grandchild
  when you hit "save"
* go to page in grandchild. buttons should be red,
  nav bg should be blue. js console should have
  "from root" logged first, then "from grandchild"

test 2:
* create a bunch of saved themes in child and grandchild
* save a new theme to "root"
* when any of the saved themes are applied they
  should be based on the new root's theme (use
  colors and console.log's to verify)


Change-Id: Ic9dbeea1524034ef60b758398eca30bc019aa32e
Reviewed-on: https://gerrit.instructure.com/79739
Tested-by: Jenkins
QA-Review: Benjamin Christian Nelson <bcnelson@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
2016-05-18 22:22:39 +00:00
Ryan Shaw 1bee29bc66 All of the stuff from the save_a_theme dev branch
this commit is the result of squashing a bunch of
others together.  this is everything that was
already on the dev/save_a_theme branch as well as
the "Add specs" commit.

I left the test plans from some of the squashed
commits in case they are helpful for QA

Test plan:
- Recompile assets, restart Canvas and clear browser
  cache
- Go to Admin > [Your school name]
- Click on Themes in the context menu
- You should now see a collections page with
  a theme card for all the themes you have in
  Theme Editor: http://screencast.com/t/lb5vozF7
- Note: it might be my database, but on my end,
  I don't see a theme card for my Canvas default
  theme. There are also some brand colors missing
  for my theme cards. I'll be interested to see
  if you hit the same thing. These are issues that
  we can resolve with Ryan when he is back.
- You should be able to click on the Apply and Delete
  buttons and see the confirm-overlays. We still need
  final copy for these.

Test plan:
- Go to your institution's Settings page and click
  Themes on the context menu.
- You should now see a page listing all the default
  and user-created themes in your Canvas installation.
- Clicking on each theme will open it inside theme
  editor.
- The current/active theme will be correctly styled
  with a green outline

change redirect targets and messages in theme editor

test plan:
exiting theme editor
should redirect you back to the /accounts/x/themes page
instead of /acounts/x

make room for footer in theme editor

test plan:
in theme editor, scroll the preview to the bottom
you should be able to scroll all the way, without
having the bottom cut off by the footer

remove "theme editor" button from account user/course search

this is not needed since "Themes" now shows up
in the left nav.

test plan:
turn on the 'Course and User Search' feature flag
go to accounts/x
you should not see a "theme editor" button on the right
aka, not like this: http://cl.ly/2G2C3p3s3n0C

fix "Exit" button in theme editor

we were warning "you will lose unsaved changes"
even when you hand not made any changes

add specs to "Save A theme" stuff

closes: CNVS-27961

test plan:
do a whole regression test on the theme editor

don't show both "k12 theme" and "canvas default" as options

fixes: CNVS-25495

description (and test plan):

if you are a k12 school, rather than seeing both
"Canvas Default" and "K12 Theme"
as options on the tiles of system themes to start from,
you should now just see "Canvas Default".
if you pick that, it should show the k12 theme.

Change-Id: I5c2512e576dcb2aedaa899e17080d9c106e159ca
Reviewed-on: https://gerrit.instructure.com/78163
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
2016-05-18 22:01:25 +00:00
Rob Orton 7d7fb15fa6 s/remove_brand_dir!/remove_scss_dir!/
fixes: CNVS-29208

as part of https://gerrit.instructure.com/77427
we created a remove_brand_dir! method but in code
review decided it would be better to call it
remove_scss_dir! but did not catch renaming
this one spot where didn't change it


test plan:

go to theme editor
make change and preview 3 different times
it should not have a page error

Change-Id: Ifca9eaa03477414925a0e5427568d1754af352f9
Reviewed-on: https://gerrit.instructure.com/79016
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Ryan Shaw <ryan@instructure.com>
QA-Review: Benjamin Christian Nelson <bcnelson@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
2016-05-09 18:43:50 +00:00
Brent Burgoyne 2134a9b430 Generate JSON file for brand configs
Refs CNVS-28275, closes CNVS-28885

Generate a json file to go along with the scss file for each brand config.
The intention is that the json file for each brand config will be pushed
to the cdn. One difference from the scss file is that it includes all
variables, even if they are not specified in the brand config. Variable
that have not been customized will use the default value.

In addition to generating a json file for each brand, a json file for that
inclues all default values is generated so other services don't need to
know the defaults if no brand config is available.

To allow for long term caching the filename of the json file includes a
hash of the current defaults (including fingerprinted urls for default
images). This way when the defaults change (or a default image) it will
point to a new file even if the brand config didn't change.

Test plan:

- Save a new brand config.
- Look in public/dist/brandable_css/[brand config hash]/
- There should be a [hash of defaults].json file
  - Should include custom values from brand config
  - Should include default values not specified in the brand config
- Run rake brand_configs:clean && rake brand_configs:write
- Should generate json file for all brand configs
- Open console in browser
  - ENV.active_brand_config_json_url should be path the current brand json file
- Go back to the default brand
  - ENV.active_brand_config_json_url should be path to default json file
- Test with a real s3 bucket for the CDN
  - JSON files should be uploaded to the CDN
  - ENV.active_brand_config_json should work when used with ENV.ASSET_HOST

Change-Id: Ibcaf54a2bff324f419a7614a8d3906c0c49aed9e
Reviewed-on: https://gerrit.instructure.com/77427
Reviewed-by: Ryan Shaw <ryan@instructure.com>
Tested-by: Jenkins
QA-Review: August Thornton <august@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
2016-05-04 19:18:28 +00:00
Ryan Shaw 298e6808d5 get sub account branding and custom css/includes working
fixes: CNVS-24787
fixes: CNVS-23964
fixes: CNVS-23957 - Handle parent account custom css/js for new_styles
test plan:
* set up a root account, child account, and grandchild account
* use theme editor to set a custom css/js file for each
  (eg: for css `* {color:red}` and for js 'console.log("from grandchild")`
* make a course & a group in the grandchild account
* load a page in that course and group and make sure
  you see grandchild account's branding, and root's,
  child's, and then grandchild's css loaded on the page
  (grandchild should be loaded last so you see it's css
  effects override root or child's and you should see
  the console.log from root then child then grandchild)
* view a page in "child". it should have root and child's
  css/js but not grandchild
* as a user that only has enrollments (account associations)
  in "child", go to the dashboard. you should see
  css/js for both root and child but not grandchild

fixes: CNVS-25051 Opening Theme Editor for
sub-accounts shows incorrect theme preview
test plan:
* Go to a sub-account in theme editor and change
  settings so the Branding is different and save.
* the preview on the right should reflect your
  changes both after you "apply" and "save"
  (and not just show the preview of the root
  account's branding)

fixes: CNVS-23406 - global JS and CSS files are being
included when Global CSS/JavaScript includes is false
test plan:
* go to /accounts/self/, and go to theme editor and
  upload a css_override
* see that that css is loaded on pages
* back in root account settings disable Global
  CSS/JavaScript includes
* check that the css is no longer loaded.
* do the same thing checking a subaccount's custom css

fixes: CNVS-25558 - load whole chain of custom css/js 
in native app api requests

test plan:
* make api request for a wiki page in course in a 
  subaccount that has custom css/js within a root 
  account that also has custom css/js
* you should see both the root account's css/js and 
  the child account's returned in the response

to test grandchild js issue jeremyp found:
* go to theme editor for a grandchild account
* choose a js override file (like: `console.log('first')`)
* preview & apply
* you should see "first" in console
* go back to theme editor, pick a new file (like: `console.log('second')`)
* preview & apply
* you should only see "second" in console. not "first"

Change-Id: I8d9047948f5da94be41e0205844629a170f980af
Reviewed-on: https://gerrit.instructure.com/68249
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Tested-by: Jenkins
Product-Review: Ryan Shaw <ryan@instructure.com>
2015-12-19 02:47:39 +00:00
Rob Orton d252a7f2b4 mobile css and js overrides
closes CNVS-19900

test plan:
 - create a brand_config for an account
 - apply brand_config
 - add ?mobile=1 to an api request that returns a
   body (like a wiki page);
   observe no additional stylesheets in the body
 - go to /accounts/self/, and go to brand
   config and upload a mobile_css_override
 - add ?mobile=1 and check the api result again
   your stylesheet should be there appended to the
   body of the wiki page
 - back in brand_config, remove the uploaded file
 - check your source again - there should not be
   an empty stylesheet tag

Change-Id: Ief728a397d185282a57f8cede0916c7ffe4a2584
Reviewed-on: https://gerrit.instructure.com/61885
Tested-by: Jenkins
Reviewed-by: Ryan Shaw <ryan@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
2015-09-28 19:24:55 +00:00
Michael Nomitch 1936564adc dont save duplicate brand_config
fixes CNVS-23390

test plan:
  - make two sub accounts that are brandable
  - give each subaccount the same theme by
    changing a variable to the same thing
    - i.e. button color to "red"
    - apply the themes
  - on the parent account, change a color
    that is not the one you just changed on
    the children
    - preview the theme
    - apply the theme
  - you dont get an error when applying the theme
  - the change trickles down to the children properly

Change-Id: I8a9f0d33cc215fc6864178788faaab8644ada367
Reviewed-on: https://gerrit.instructure.com/63720
Tested-by: Jenkins
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
2015-09-23 22:39:00 +00:00
Michael Nomitch 8a6819e85d subaccount branding (creation and trickle down)
fixes CNVS-21426

changes theme_editor routes to nest under accounts
show correct brand_config for subaccount
be able to theme subaccounts
parent account changes trickle down to subs
theme editor default values are that of parent account
add not in preview text that subaccounts dont show

test plan:
  simple creation
  - create a sub-account
  - brand it differently from parent
  - if you go to courses belonging to
    this subaccount, it gets their css
  - if you go to courses belonging to
    the parent you get the parent css
  - if you go to a user dashboard
    you get the parent branding
    (maybe we can add smarts to this
     later in case you only are in
     the subaccount?)

  trickle down
  - rebrand two values on the parent
    - one that the subaccount explicitly sets
    - and one that doesnt
  - apply this config on the parent
  - wait a little and go to the child account
    - its theme inherits values for the parent,
      but... if it explicitly sets those values
      itself then it doesnt inherit it
  - go to the editor for the subaccount
    - the placeholder values are those
      of the parent account (or the canvas
      default if the parent hasnt set it)

  - test trickle down with a sub-account and
  a sub-sub-account

still to do on different patch sets:
  - account settings to allow subaccount branding
  - show the progress of all the child compilation

Change-Id: Iaddba7036f564965427807c2fd8b0a6a5d524366
Reviewed-on: https://gerrit.instructure.com/61285
Reviewed-by: Rob Orton <rob@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Tested-by: Jenkins
Product-Review: Ryan Shaw <ryan@instructure.com>
Product-Review: Colleen Palmer <colleen@instructure.com>
2015-09-08 20:30:22 +00:00
Ryan Shaw 9f34f62be9 upload css direct to s3 and optimize unbranded css
fixes: CNVS-22276

what this change does:
* changes it so if you have a 'host' set in canvs_cdn.yml,
  when you run brandable_css it will push the css
  files directly to s3 instead of writing them all to
  disk.
* fixes the bug where brandable_css thought it had
  to re-compile css files that have not changed
* changes the way we load css bundles that don't include
  any branding or use any of the variant variables
  (like: $use-high-contrast or $use-new-styles).
  before, we generated a unique css file for each
  variant and each brand for any of those bundles.
  this will instead point everyone to same url if 
  the file uses none of those variables.

test plan:
* with no canvas_cdn.yml file:
* run compile_assets
* run it again, it should say "no changes" quickly
* the css in canvas should work
* now, rm -rf public/dist/brandable_css
* save a canvas_cdn.yml with proper s3/cloudfront settings
* compile_assets
* canvas should work and use the css that was uploaded
  to s3 in previous step
* compile_assets again, it should say "no changes"
  within a few seconds.
* if you can, delete a css file from s3 & run 
  brandable_css again. it should see that it needs
  to regenerate that file and do so correctly.

when testing the css in the UI, especially make sure
to look for:
* try loading the equation editor in different variants,
  (e.g.: high contrast, new styles, legacy) the css
  for it should always be loaded from <cdn>/dist/brandable_css/no_variables/...
* keep your js console open, there should not be any 404s
* check the screenreader_gradebook


most of the changes actually happened in brandable_css:
https://github.com/ryankshaw/brandable_css/compare/6e0ddc59...master
when code-reviewing, please do a thorough scan of 
those changes too.


Change-Id: Ie6efcedd92c3783e0b2dd194ec222b9dc28d0838	
Change-Id: Ie6efcedd92c3783e0b2dd194ec222b9dc28d0838
Reviewed-on: https://gerrit.instructure.com/61495
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins
QA-Review: August Thornton <august@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
2015-09-04 21:23:43 +00:00
Michael Nomitch 039a996bc8 hide k12 styles unless flag is on
fixes CNVS-22216

test plan:
  - with k12 feature flag off
    - go to theme editor
    - it doesnt show k12 brand config
  - turn flag on
    - go back to theme editor
    - it does show k12 brand conifg
  - turn flag off and check that it goes away
  (note: it may take a little bit for the
   change to kick in)

Change-Id: Ic4ab4557d5330426128d26890d739ee6feb98a7b
Reviewed-on: https://gerrit.instructure.com/60783
Tested-by: Jenkins
Reviewed-by: Ryan Shaw <ryan@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Colleen Palmer <colleen@instructure.com>
2015-08-17 15:53:46 +00:00
Jennifer Stern 84933275d7 Add Upload CSS/JS tab to Theme Editor
refs CNVS-21431, CNVS-21425

Test scenarios: https://gist.github.com/junyper/7481e6a2b65a1b799bad

Change-Id: I28b24bce592952acfd33cb1303496b8178f0d4b4
Reviewed-on: https://gerrit.instructure.com/58780
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Tested-by: Jenkins
Reviewed-by: Colleen Palmer <colleen@instructure.com>
Product-Review: Jennifer Stern <jstern@instructure.com>
Reviewed-by: Ryan Shaw <ryan@instructure.com>
2015-07-28 22:35:52 +00:00
Ryan Shaw 52254ecc7b Theme Editor: Fix threading issues in preview progress updates
fixes: CNVS-22185

Because the the update_progress callback from the 
upload_to_s3 callback was happening inside a 
Parallel.each thread, we'd get random errors where 
it ran out of active record postgres connections. 
eg:
ActiveRecord::ConnectionTimeoutError
could not obtain a database connection within 5 
seconds (waited 5.000153379 seconds). The max pool 
size is currently 5; consider increasing it.

the fix is to call the callback on the main thread so 
any db queries are happening from the normal rails thread.

also, this adds a progress bar so if you run this from 
the command line, you'll get a nice progress bar like 
https://files.slack.com/files-pri/T028ZAGUD-F0896CFR9/screen_shot_2015-07-28_at_10.19.36_am.png 
so that when deployers run the:
`rake brand_configs:generate_and_upload_all` 
task, which takes a long time, they have an idea 
of how long it is going to take

test plan:

note:this is something that only broke on beta and 
not on local machines so to test that this fixes it,
you kinda need to just run it there:

* open theme editor
* make a change
* hit preview
* it should not say there was an error

Change-Id: Ife052ab9573aa677d49d8e5e6c637b0faa2b116e
Reviewed-on: https://gerrit.instructure.com/59407
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Tested-by: Jenkins
Product-Review: Ryan Shaw <ryan@instructure.com>
2015-07-28 20:25:21 +00:00
Michael Nomitch 65d278d56e theme editor - fix undo image error
fixes CNVS-22073

test plan:
  - go to theme editor
  - add an image and then undo
    having added that image
  - if that is the only thing youve
    changed so far, you do not get
    a preview button
  - once you change something else
    you can hit preview and it saves
    properly

  - apply theme with a non-default image
  - go to the editor and change back
    to default
  - you get an option to preview with
    the default
  - preview is successful

  - color & image changes act normally

Change-Id: Ia5de701177137625e65434ac316c22aec0e1dd39
Reviewed-on: https://gerrit.instructure.com/59056
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Reviewed-by: Jennifer Stern <jstern@instructure.com>
Product-Review: Jennifer Stern <jstern@instructure.com>
Tested-by: Jenkins
2015-07-28 18:16:50 +00:00
Ryan Shaw 5d165fe8c8 rename "CDN" ruby module to "Cdn"
...because apparently "it's preloading. for
autoloading, CDN will look for cdn or c_d_n.

then in prod mode, it's somewhat different. like
autoloading is disabled? and it just pre-requires
everything in the autoload dirs"


test plan:

run `RAILS_ENV=production bundle exec rake canvas:cdn:upload_to_s3`

it should work

Change-Id: I5deed1cc2b9daa678465b174af320cf1724fea8c
Reviewed-on: https://gerrit.instructure.com/59341
Reviewed-by: James Williams  <jamesw@instructure.com>
Tested-by: Jenkins
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
2015-07-27 21:55:37 +00:00
Ryan Shaw 1ef15493e5 Create predeploy rake task to handle Theme Editor
closes: CNVS-21990

This is the rake task we call from a job server
once that has new code before restarting all the
app servers.  It will make sure that our s3 bucket
has all static assets including the css for custom
themes people have created in the Theme Editor

test plan:

* make sure you have an config/canvas_cdn.yml file
* `rm -rf public/dist`
* run `bundle exec rake brand_configs:generate_and_upload_all`
* in log/development.log you should see it write
  a _variables.scss file for each brand_config
  in any shard to disk, compile the css for each
  of those brands and push all the js/css/images/etc to s3
* browse pages in canvas, the css/images/js
  should be served from your "host:" configured
  in canvas_cdn.yml and none should 404

this change also includes:

better error message when brandable_css manifest doesn't exist

if the manifest file can't be found, this will
tell you the full path to the file it was looking
for so that if it can't find the manifest file,it
will tell you the path to the file it was looking for.

test plan:

with RAILS_ENV=production:

* rm -rf public/dist
* try to access a page

the error that it give you should tell you the
full path to the json file it tried to read.

if we haven't loaded rails yet, we still want
to look at RAILS_ENV to get which style of css
to generate

Change-Id: I2dbb12541d6a28e90a326a51f0cddb90f313842f
Reviewed-on: https://gerrit.instructure.com/58809
Reviewed-by: Rob Orton <rob@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Tested-by: Jenkins
Product-Review: Ryan Shaw <ryan@instructure.com>
2015-07-20 21:19:53 +00:00
Cody Cutrer c472370223 use qualified table names in EXISTS subqueries
refs CNVS-21900

Change-Id: Ic49c570888ad8712d7ba93de632d952ddf2b53e1
Reviewed-on: https://gerrit.instructure.com/58629
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Jenkins
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2015-07-19 00:09:24 +00:00
Ryan Shaw 1e2d787cf9 show progress of them editor preview
closes: CNVS-21013

when the user hits 'preview' in the theme editor,
it fires off a delayed job to create the css files
and push them to s3. we need to show the user the
the progress of that job as it is working and
then reload the page when it is done.

I made a screencast to show how it should work and
what to look for:
http://screencast.com/t/x6EeOBiQT6d

test plan:

* go to the theme editor,
* make some changes (be sure to test both colors
  and images)
* press 'preview'
* notice the ProgressBar that comes up in a modal
* try exiting the theme editor, it should warn
  you if you have unsaved changes

Change-Id: I3f14beefba227b5ba23b33acf84e04542f48954e
Reviewed-on: https://gerrit.instructure.com/57626
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Jenkins
QA-Review: Adrian Foong <afoong@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
2015-07-18 20:08:53 +00:00
Ryan Shaw 87eba38b3e don't blow away the brandConfig someone else is working on
closes: CNVS-21804

this will also do a better job of cleaning up
the app/stylesheets/brandable_css_brands dir
(so when you compile sass, it won't do stuff
for brandConfigs that aren't being used anymore)

test plan:
open theme editor, make some changes, hit preview.
as a different user in a different browser,
open theme editor, make changes, press save.
now in the first window, try to hit save.
before it would break, now it will work

Change-Id: I094f737d35c854764a7c361bec4798b8a2203410
Reviewed-on: https://gerrit.instructure.com/58102
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Product-Review: Jennifer Stern <jstern@instructure.com>
Tested-by: Jenkins
QA-Review: Nathan Rogowski <nathan@instructure.com>
2015-07-16 21:59:10 +00:00
Ryan Shaw 84a7192a36 A new way of doing css/sass & New Canvas Theme Editor
what this does:
* Changes the way we generate css so we are able to generate custom
  css for people that use the theme editor.
* Sets everything up so we can push all of our static assets
  (js, fonts, css, images, etc) to s3 pre-deploy and serve them
  from cloudfront. Yay! faster canvas for everyone!
* as part of that, this enables the rails asset pipeline just so we
  can use it to put md5s in our urls.  we don't use it for any of the
  coffeescript/sass/sprockets transformer stuff.
* adds a new "Theme editor" functionality (only for people that have
  have the use-new-styles feature flag turned on) where an admin for
  an account can pick their own colors/images for all the users
  at their account/school.
* when the user is done saving things in theme editor, it will,
  in a delayed job, generate all the css with against the variables
  that user specified and push it to s3 so it will be available to
  anyone else that requests it.  (the delayed job will shell
  out to a node.js executable called `brandable_css`).
* ability to pick an existing shared theme and to reset to
  blank theme. closes: CNVS-19685
* gets rid of jammit.

test plan:
(this is exaustive, so not every person has to do every step
but we should make sure at least someone does each of these things.
maybe as part of the review add a comment if you have done one of these
bulletpoints)

* before you check this out, compile all css and copy the
  public/stylsheets_compiled directory somewhere. after you check out
  this code and regenerate all the css. make sure there are no
  significant changes to the css output. (we updated the versions of
  node-sass and autoprefixer that we use so we want to make sure they
  don't change things in a way we weren't expecting)

* make sure the way we load css for handlebars templates still works.
  eg: if there is a handlebars template at
  app/views/jst/some/template.handlebars
  if there is also a scss file at
  app/stylesheets/jst/some/template.scss
  then that stylesheet should get loaded when that template is rendered

* check out the code and run migrations. browse around canvas,
  make sure css and js files load correctly as before.

* cody, jacob, or someone on queso: look at the db migrations and
  make sure everything looks good and that I am handling sharding
  correctly.
* verify that both rake canvas:compile_assets and guard, works as well
  as `node_modules/.bin/brandable_css` (note: if you have
  "node_modules/.bin" in your PATH (which you should), it will also
  work with just `brandable_css`)

* verify that passing the --watch option to
  `.bin/node_modules/brandable_css` works and picks up changes to
  sass files, images, fonts, or any other resource that goes into
  a css file. and that it only recompiles the css files that actually
  depend on that file.

* go to https://github.com/ryankshaw/brandable_css and check out the
  code there. that is what is actually doing the sass compiling

* create a config/canvas_cdn.yml file and add aws access creds and
  an s3 bucket and cdn hostname (for testing, you can use the credentials
  for instructure_uploads_engineering from
  https://gollum.instructure.com/OtherServiceTestAccounts ). for a test
  cdn hostname you can use https://diu0rq5m1weh1.cloudfront.net. that
  is a cloudfront bucket I set up on my personal account that points to
  instructure_uploads_engineering

* run rake canvas:compile_assets again, this time, at the end, you
  should see it run the assets:precompile task that puts md5s in filenames
  and, gzipps them, and copys them to public/assets.
  then you should see it run canvas:cdn:upload_to_s3
  (look at log/development.log for progress),
  which pushes everything to s3.
  closes: CNVS-17333 CNVS-17430 CNVS-17337

* try out the theme editor: turn on new styles, go to accounts/x
  (where x is the @domain root acount you are testing from) and click
  the "theme editor" button on the right side of the page.
  that should take you to a page that has the ability to pick colors/images
  on the left side and preview your changes in an iframe on the right
  closes: CNVS-19360 CNVS-20551

* test the "preview", "save", "reset", and "choose existing" functionality
  closes: CNVS-17339 CNVS-17338 CNVS-19685

* make sure that the themeeditor works both if you have
  config/canvas_cdn.yml set up and enabled as well as if you don't.
  if it is enabled, you should see it push the css for just that new
  brand config to s3 when you hit preview, and the css
  should be accessible from the cdn you configured.

Change-Id: Ie0a812d04f5eeb40e7df7e71941ff63ea51a4d22
Reviewed-on: https://gerrit.instructure.com/53873
Tested-by: Jenkins
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
2015-07-02 22:42:18 +00:00