From 6e2bbfef9908424c3e5fd37350527419b602fb79 Mon Sep 17 00:00:00 2001 From: Stephen Bannasch Date: Tue, 9 Jul 2013 17:17:16 -0400 Subject: [PATCH] update to: ruby-2.0.0-p247 Also: - Gemfile updates: rake, librarian, shutterbug, guard-sass. guard-livereload, thor, capistrano, rvm-capistrano - Gemfile new gems: rack-livereload - Gemfile removed gems: rack-rewrite - new :environment variable in config.yml :environment can be 'development' or 'production' production: - delivers minimized javascript resources - sets JavaScript variable: Lab.config.environment = 'production' development: - delivers un-minimized javascript resources - sets JavaScript variable: Lab.config.environment = 'development' - enables rack-livereload (no-longer need to install extension in browser) Fixed Guardfile for watching top-level markdown files. --- .ruby-version | 2 +- Gemfile | 22 ++-- Gemfile.lock | 108 ++++++------------ Guardfile | 2 +- config.ru | 17 ++- config/config.sample.yml | 9 ++ script/check-development-dependencies.rb | 4 +- script/generate-js-config.rb | 1 + script/setup.rb | 59 ++++++++++ src/application.js | 4 +- src/embeddable.html.haml | 9 +- src/interactives.html.haml | 18 +-- .../common/controllers/model-controller.js | 4 +- 13 files changed, 133 insertions(+), 126 deletions(-) diff --git a/.ruby-version b/.ruby-version index 2aaf2528c3..abf2ccea04 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-1.9.3-p392 +ruby-2.0.0-p247 diff --git a/Gemfile b/Gemfile index e0e2e2b8cb..7ba279db0d 100755 --- a/Gemfile +++ b/Gemfile @@ -1,12 +1,11 @@ source "http://rubygems.org" gem "rack", "~> 1.5.2" -gem 'rack-rewrite', "~> 1.3.3" -gem "rake", "~> 10.0.4" +gem "rake", "~> 10.1.0" gem "fog", "~> 1.12.1" -gem "librarian", "~> 0.0.26" +gem "librarian", "~> 0.1.0" gem "haml", "~> 4.0.0" gem "sass", "~> 3.2.5" @@ -16,12 +15,15 @@ gem 'kramdown', "~> 0.13.8" # Adds Hash.from_xml method used in Energy2D importer gem 'active_support', "~> 3" +gem 'i18n', "~> 0.6.4" -gem "grit", "~> 2.5.0" +gem "gitlab-grit", "~> 2.6.0" gem "mustache", "~> 0.99.4" -gem "shutterbug", :github => 'concord-consortium/shutterbug', :tag => 'v0.0.4' +gem "shutterbug", "~> 0.0.7" + +gem "rack-livereload", "~> 0.3.15" def darwin_only(require_as) RbConfig::CONFIG['host_os'] =~ /darwin/ && require_as @@ -40,9 +42,9 @@ group :development do # guard related ... gem "guard", "~> 1.8.1" gem "guard-haml", "~> 0.4" - gem "guard-sass", "~> 1.3.1" + gem "guard-sass", "~> 1.3.2" gem "guard-shell", "~> 0.5.1" - gem "guard-livereload", "~> 1.1.3" + gem "guard-livereload", "~> 1.4.0" gem 'guard-coffeescript', "~> 1.3.2" gem 'guard-markdown', "~> 0.2.0" # FS Notification libraries for guard (non-polling) @@ -53,9 +55,9 @@ group :development do gem 'ruby_gntp', "~> 0.3.4" # deployment related ... - gem "thor", "~> 0.17.0" - gem "capistrano", "~> 2.14.2" - gem "rvm-capistrano", "~> 1.2.6" + gem "thor", "~> 0.18.1" + gem "capistrano", "~> 2.15.5" + gem "rvm-capistrano", "~> 1.4.0" # debuggers gem "pry" diff --git a/Gemfile.lock b/Gemfile.lock index 87d78e8593..ba44c460ed 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,55 +1,32 @@ -GIT - remote: git://github.com/concord-consortium/shutterbug.git - revision: 7c645f2a707c7891778c461aee0096e890e55d00 - tag: v0.0.4 - specs: - shutterbug (0.0.4) - rack - GEM remote: http://rubygems.org/ specs: active_support (3.0.0) activesupport (= 3.0.0) activesupport (3.0.0) - archive-tar-minitar (0.5.2) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) bourbon (3.1.8) sass (>= 3.2.0) thor builder (3.2.2) - capistrano (2.14.2) + capistrano (2.15.5) highline net-scp (>= 1.0.0) net-sftp (>= 2.0.0) net-ssh (>= 2.0.14) net-ssh-gateway (>= 1.1.0) - chef (11.4.4) - erubis - highline (>= 1.6.9) - json (>= 1.4.4, <= 1.7.7) - mixlib-authentication (>= 1.3.0) - mixlib-cli (~> 1.3.0) - mixlib-config (>= 1.1.2) - mixlib-log (>= 1.3.0) - mixlib-shellout - net-ssh (~> 2.6) - net-ssh-multi (~> 1.1.0) - ohai (>= 0.6.0) - rest-client (>= 1.0.4, < 1.7.0) - yajl-ruby (~> 1.1) + charlock_holmes (0.6.9.4) coderay (1.0.9) coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.6.2) + coffee-script-source (1.6.3) debug_inspector (0.0.2) diff-lcs (1.2.4) em-websocket (0.5.0) eventmachine (>= 0.12.9) http_parser.rb (~> 0.5.3) - erubis (2.7.0) eventmachine (1.0.3) excon (0.23.0) execjs (1.4.0) @@ -66,7 +43,8 @@ GEM nokogiri (~> 1.5.0) ruby-hmac formatador (0.2.4) - grit (2.5.0) + gitlab-grit (2.6.0) + charlock_holmes (~> 0.6.9) diff-lcs (~> 1.1) mime-types (~> 1.15) posix-spawn (~> 0.3.6) @@ -82,14 +60,14 @@ GEM guard-haml (0.5) guard (>= 1.1) haml (>= 3.0) - guard-livereload (1.1.3) - em-websocket (>= 0.2.0) - guard (>= 1.5.0) - multi_json (~> 1.0) + guard-livereload (1.4.0) + em-websocket (>= 0.5.0) + guard (>= 1.8.0) + multi_json (~> 1.7) guard-markdown (0.2.0) guard (>= 0.2.2) kramdown (~> 0.13.3) - guard-sass (1.3.1) + guard-sass (1.3.2) guard (>= 1.1.0) sass (>= 3.1) guard-shell (0.5.1) @@ -98,51 +76,31 @@ GEM tilt highline (1.6.19) http_parser.rb (0.5.3) - ipaddress (0.8.0) - json (1.7.7) + i18n (0.6.4) kramdown (0.13.8) - librarian (0.0.26) - archive-tar-minitar (>= 0.5.2) - chef (>= 0.10) + librarian (0.1.0) highline thor (~> 0.15) listen (1.2.2) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) rb-kqueue (>= 0.2) - lumberjack (1.0.3) + lumberjack (1.0.4) method_source (0.8.1) mime-types (1.23) - mixlib-authentication (1.3.0) - mixlib-log - mixlib-cli (1.3.0) - mixlib-config (1.1.2) - mixlib-log (1.6.0) - mixlib-shellout (1.1.0) multi_json (1.7.7) mustache (0.99.4) neat (1.2.1) bourbon (>= 2.1) sass (>= 3.2) - net-scp (1.1.1) + net-scp (1.1.2) net-ssh (>= 2.6.5) net-sftp (2.1.2) net-ssh (>= 2.6.5) - net-ssh (2.6.7) + net-ssh (2.6.8) net-ssh-gateway (1.2.0) net-ssh (>= 2.6.5) - net-ssh-multi (1.1) - net-ssh (>= 2.1.4) - net-ssh-gateway (>= 0.99.0) nokogiri (1.5.10) - ohai (6.16.0) - ipaddress - mixlib-cli - mixlib-config - mixlib-log - mixlib-shellout - systemu - yajl-ruby posix-spawn (0.3.6) pry (0.9.12.2) coderay (~> 1.0.5) @@ -154,26 +112,25 @@ GEM binding_of_caller (>= 0.7) pry (~> 0.9.11) rack (1.5.2) - rack-rewrite (1.3.3) - rake (10.0.4) + rack-livereload (0.3.15) + rack + rake (10.1.0) rb-fsevent (0.9.3) rb-inotify (0.9.0) ffi (>= 0.5.0) rb-kqueue (0.2.0) ffi (>= 0.5.0) - rest-client (1.6.7) - mime-types (>= 1.16) ruby-hmac (0.4.0) ruby_gntp (0.3.4) - rvm-capistrano (1.2.7) + rvm-capistrano (1.4.0) capistrano (>= 2.0.0) sass (3.2.9) + shutterbug (0.0.7) + rack slop (3.4.5) - systemu (2.5.2) - thor (0.17.0) + thor (0.18.1) tilt (1.4.1) wdm (0.1.0) - yajl-ruby (1.1.0) PLATFORMS ruby @@ -181,32 +138,33 @@ PLATFORMS DEPENDENCIES active_support (~> 3) bourbon (~> 3.1.1) - capistrano (~> 2.14.2) + capistrano (~> 2.15.5) fog (~> 1.12.1) - grit (~> 2.5.0) + gitlab-grit (~> 2.6.0) guard (~> 1.8.1) guard-coffeescript (~> 1.3.2) guard-haml (~> 0.4) - guard-livereload (~> 1.1.3) + guard-livereload (~> 1.4.0) guard-markdown (~> 0.2.0) - guard-sass (~> 1.3.1) + guard-sass (~> 1.3.2) guard-shell (~> 0.5.1) haml (~> 4.0.0) + i18n (~> 0.6.4) kramdown (~> 0.13.8) - librarian (~> 0.0.26) + librarian (~> 0.1.0) mustache (~> 0.99.4) neat (~> 1.2.0) pry pry-nav pry-stack_explorer rack (~> 1.5.2) - rack-rewrite (~> 1.3.3) - rake (~> 10.0.4) + rack-livereload (~> 0.3.15) + rake (~> 10.1.0) rb-fsevent (~> 0.9.3) rb-inotify (~> 0.9.0) ruby_gntp (~> 0.3.4) - rvm-capistrano (~> 1.2.6) + rvm-capistrano (~> 1.4.0) sass (~> 3.2.5) - shutterbug! - thor (~> 0.17.0) + shutterbug (~> 0.0.7) + thor (~> 0.18.1) wdm (~> 0.1.0) diff --git a/Guardfile b/Guardfile index 1b61371ef1..80de5c62fa 100755 --- a/Guardfile +++ b/Guardfile @@ -144,7 +144,7 @@ group :build do # , :api_version => '1.6', :port => '35728' guard 'livereload' do - watch(/^(server\/public\/).+\.(css|js|html)/) + watch(/^(public\/).+\.(css|js|html)/) end guard 'markdown', :kram_ops => { :toc_levels => [2,3,4,5] } do diff --git a/config.ru b/config.ru index 9778f0c3ea..0c7b48dd83 100644 --- a/config.ru +++ b/config.ru @@ -1,10 +1,8 @@ -gem 'rack-rewrite', '~> 1.3.3' -require 'rack/rewrite' +require 'rack-livereload' require 'shutterbug' -PUBLIC_PATH = File.join(Dir.pwd, 'public') +require "./script/setup" JNLP_APP_PATH = PUBLIC_PATH - require './lib/rack/jnlp.rb' use Rack::Jnlp @@ -15,6 +13,11 @@ use Rack::ContentLength # shutterbug/shutterbug.js shutterbug/get_png/SHA1 use Shutterbug::Rackapp +# see: https://github.com/johnbintz/rack-livereload +if CONFIG[:environment] == 'development' + use Rack::LiveReload, :min_delay => 200 +end + Rack::Mime::MIME_TYPES.merge!({ ".ttf" => "font/ttf", ".mml" => "application/xml", @@ -22,12 +25,6 @@ Rack::Mime::MIME_TYPES.merge!({ ".e2d" => "application/xml" }) -# use Rack::Rewrite do -# r301 '/examples/interactives/interactives.html', '/interactives.html' -# r301 '/examples/interactives/embeddable.html', '/embeddable.html' -# r301 '/examples/interactives/interactives.json', '/interactives.json' -# end - app = Rack::Directory.new PUBLIC_PATH run app diff --git a/config/config.sample.yml b/config/config.sample.yml index 8c5a7746ec..3af8f8a2a8 100644 --- a/config/config.sample.yml +++ b/config/config.sample.yml @@ -1,4 +1,13 @@ --- +# environment can be 'development' or 'production' +# production: +# - delivers minimized javascript resources +# - sets JavaScript variable: Lab.config.environment = 'production' +# development: +# - delivers un-minimized javascript resources +# - sets JavaScript variable: Lab.config.environment = 'development' +# - enables rack-livereload +:environment: development :server: development: :hostname: localhost:9292 diff --git a/script/check-development-dependencies.rb b/script/check-development-dependencies.rb index 9be3ffe4a9..26ed995b49 100755 --- a/script/check-development-dependencies.rb +++ b/script/check-development-dependencies.rb @@ -2,8 +2,8 @@ require 'json' -@required_ruby_version = "1.9.3" -@required_ruby_patchlevel = 392 +@required_ruby_version = "2.0.0" +@required_ruby_patchlevel = 247 @minimum_node_version = "v0.10.0" def macosx diff --git a/script/generate-js-config.rb b/script/generate-js-config.rb index 37201f520c..c743c857ad 100755 --- a/script/generate-js-config.rb +++ b/script/generate-js-config.rb @@ -29,6 +29,7 @@ CONFIG[:jsconfig][:actualRoot] = "" if CONFIG[:jsconfig][:actualRoot] == nil CONFIG[:jsconfig][:fontface] = "Open Sans" if CONFIG[:jsconfig][:fontface] == nil CONFIG[:jsconfig][:dataGamesProxyPrefix] = "DataGames/Games/concord/lab/" if CONFIG[:jsconfig][:dataGamesProxyPrefix] == nil +CONFIG[:jsconfig][:environment] = CONFIG[:environment] jsconfig = < HEREDOC end + +# setup partials for 'production' (minimized resources) or 'development' + +LAB_JS_DEPENDENCIES = case CONFIG[:environment] +when 'production' + <<-HEREDOC + + + + + + + HEREDOC +else + <<-HEREDOC + + + + + + + HEREDOC +end + +LAB_JS_ADDITIONAL_DEPENDENCIES = case CONFIG[:environment] +when 'production' + <<-HEREDOC + + + + + + + + + HEREDOC +else + <<-HEREDOC + + + + + + + + + HEREDOC +end + +LAB_JS = case CONFIG[:environment] +when 'production' + <<-HEREDOC + + HEREDOC +else + <<-HEREDOC + + HEREDOC +end \ No newline at end of file diff --git a/src/application.js b/src/application.js index d3b888c7b4..bba8499cb3 100644 --- a/src/application.js +++ b/src/application.js @@ -1,8 +1,6 @@ -/*global Lab, _, $, jQuery, d3, CodeMirror, controllers, alert, model, modelList, benchmark, getDomSnapshot, _gaq, DEVELOPMENT: true, AUTHORING: true */ +/*global Lab, _, $, jQuery, d3, CodeMirror, controllers, alert, model, modelList, benchmark, getDomSnapshot, _gaq, AUTHORING: true */ /*jshint boss:true */ -DEVELOPMENT = true; - // Strawman setting for telling the interactive to be in "author mode", // allowing things like positioning textBoxes by hand. AUTHORING = false; diff --git a/src/embeddable.html.haml b/src/embeddable.html.haml index 860ab8e8e0..63b9896c51 100644 --- a/src/embeddable.html.haml +++ b/src/embeddable.html.haml @@ -12,12 +12,7 @@ %script{:src => "vendor/modernizr/modernizr.js", :type => "text/javascript"} %script{:type => "text/javascript"} if (!Modernizr.svg) { window.location = 'browser-upgrade.html'; } - %script{:src => "vendor/d3/d3.js", :type => "text/javascript"} - %script{:src => "vendor/jquery/jquery.min.js", :type => "text/javascript"} - %script{:src => "vendor/jquery-ui/jquery-ui.min.js", :type => "text/javascript"} - %script{:src => "vendor/jquery-ui-touch-punch/jquery.ui.touch-punch.min.js", :type => "text/javascript"} - %script{:src => "vendor/jquery-context-menu/jquery.contextMenu.js", :type => "text/javascript"} - %script{:src => "vendor/jquery-selectBoxIt/jquery.selectBoxIt.min.js", :type => "text/javascript"} + = LAB_JS_DEPENDENCIES = ANALYTICS = MOCHA_PHANTOMJS_HEAD %body @@ -28,7 +23,7 @@ %p %a(href='http://blog.concord.org/serious-performance-regression-in-firefox-18-and-newer' class='opens-in-new-window' target='_blank') Firefox v18-22 performance issue ... - %script{:src => "lab/lab.js", :type => "text/javascript"} + = LAB_JS %script{:src => "application.js", :type => "text/javascript"} %script{:src => "shutterbug/shutterbug.js", :type => "text/javascript"} = MOCHA_PHANTOMJS_BODY diff --git a/src/interactives.html.haml b/src/interactives.html.haml index 3d32d8bba8..feee33b14d 100644 --- a/src/interactives.html.haml +++ b/src/interactives.html.haml @@ -13,20 +13,8 @@ %script{:src => "vendor/modernizr/modernizr.js", :type => "text/javascript"} %script{:type => "text/javascript"} if (!Modernizr.svg) { window.location = 'browser-upgrade.html'; } - %script{:src => "vendor/d3/d3.js", :type => "text/javascript"} - %script{:src => "vendor/jquery/jquery.min.js", :type => "text/javascript"} - %script{:src => "vendor/jquery-ui/jquery-ui.min.js", :type => "text/javascript"} - %script{:src => "vendor/jquery-ui-touch-punch/jquery.ui.touch-punch.min.js", :type => "text/javascript"} - %script{:src => "vendor/jquery-context-menu/jquery.contextMenu.js", :type => "text/javascript"} - %script{:src => "vendor/jquery-selectBoxIt/jquery.selectBoxIt.min.js", :type => "text/javascript"} - %script{:src => "vendor/tinysort/jquery.tinysort.js", :type => "text/javascript"} - %script{:src => "vendor/codemirror/lib/codemirror.js", :type => "text/javascript"} - %script{:src => "vendor/codemirror/mode/javascript/javascript.js", :type => "text/javascript"} - %script{:src => "vendor/codemirror/addon/fold/foldcode.js", :type => "text/javascript"} - %script{:src => "vendor/codemirror/addon/fold/collapserange.js", :type => "text/javascript"} - %script{:src => "vendor/codemirror/addon/format/formatting.js", :type => "text/javascript"} - %script{:src => "vendor/codemirror/addon/edit/matchbrackets.js", :type => "text/javascript"} - %script{:src => "vendor/codemirror/addon/edit/closebrackets.js", :type => "text/javascript"} + = LAB_JS_DEPENDENCIES + = LAB_JS_ADDITIONAL_DEPENDENCIES = ANALYTICS %body #header @@ -186,7 +174,7 @@ #image_output (no snapshot taken yet) - %script{:src => "lab/lab.js", :type => "text/javascript"} + = LAB_JS %script{:src => "imports/legacy-mw-content/model-list.js", :type => "text/javascript"} %script{:src => "application.js", :type => "text/javascript"} %script{:src => "shutterbug/shutterbug.js", :type => "text/javascript"} diff --git a/src/lab/common/controllers/model-controller.js b/src/lab/common/controllers/model-controller.js index 90ec791edd..7a9fe1819f 100644 --- a/src/lab/common/controllers/model-controller.js +++ b/src/lab/common/controllers/model-controller.js @@ -1,4 +1,4 @@ -/*global define, DEVELOPMENT, d3, alert, model: true */ +/*global define, d3, alert, model: true */ define(function () { @@ -125,7 +125,7 @@ define(function () { // // ------------------------------------------------------------ - if (typeof DEVELOPMENT === 'undefined') { + if (Lab.config.environment === 'production') { try { setupModel(); } catch(e) {