Skip to content
This repository
Browse code

Upgrade to Rails 3.2 and move some of the assets to the asset pipelin…

…e directories
  • Loading branch information...
commit bfd5b29a9a9cfae4db335cf34d5ee6ca7d6b4655 1 parent 61c7d21
Alan Bradburne authored
8  .gitignore
... ...
@@ -0,0 +1,8 @@
  1
+log/*.log
  2
+tmp/**/*
  3
+tmp/restart.txt
  4
+config/database.yml
  5
+.DS_Store
  6
+db/*.sqlite3
  7
+.bundle
  8
+.bundle/*
3  Gemfile
... ...
@@ -1,8 +1,9 @@
1 1
 source 'http://rubygems.org'
2 2
 
3  
-gem 'rails', '3.0.4' 
  3
+gem 'rails', '3.2.1'
4 4
 gem 'mysql2'
5 5
 gem 'authlogic'
  6
+gem 'jquery-rails'
6 7
 
7 8
 # Bundle gems for the local environment. Make sure to
8 9
 # put test-only gems in this group so their generators
165  Gemfile.lock
... ...
@@ -1,90 +1,108 @@
1 1
 GEM
2 2
   remote: http://rubygems.org/
3 3
   specs:
4  
-    ZenTest (4.5.0)
5  
-    abstract (1.0.0)
6  
-    actionmailer (3.0.4)
7  
-      actionpack (= 3.0.4)
8  
-      mail (~> 2.2.15)
9  
-    actionpack (3.0.4)
10  
-      activemodel (= 3.0.4)
11  
-      activesupport (= 3.0.4)
12  
-      builder (~> 2.1.2)
13  
-      erubis (~> 2.6.6)
14  
-      i18n (~> 0.4)
15  
-      rack (~> 1.2.1)
16  
-      rack-mount (~> 0.6.13)
17  
-      rack-test (~> 0.5.7)
18  
-      tzinfo (~> 0.3.23)
19  
-    activemodel (3.0.4)
20  
-      activesupport (= 3.0.4)
21  
-      builder (~> 2.1.2)
22  
-      i18n (~> 0.4)
23  
-    activerecord (3.0.4)
24  
-      activemodel (= 3.0.4)
25  
-      activesupport (= 3.0.4)
26  
-      arel (~> 2.0.2)
27  
-      tzinfo (~> 0.3.23)
28  
-    activeresource (3.0.4)
29  
-      activemodel (= 3.0.4)
30  
-      activesupport (= 3.0.4)
31  
-    activesupport (3.0.4)
  4
+    ZenTest (4.6.2)
  5
+    actionmailer (3.2.1)
  6
+      actionpack (= 3.2.1)
  7
+      mail (~> 2.4.0)
  8
+    actionpack (3.2.1)
  9
+      activemodel (= 3.2.1)
  10
+      activesupport (= 3.2.1)
  11
+      builder (~> 3.0.0)
  12
+      erubis (~> 2.7.0)
  13
+      journey (~> 1.0.1)
  14
+      rack (~> 1.4.0)
  15
+      rack-cache (~> 1.1)
  16
+      rack-test (~> 0.6.1)
  17
+      sprockets (~> 2.1.2)
  18
+    activemodel (3.2.1)
  19
+      activesupport (= 3.2.1)
  20
+      builder (~> 3.0.0)
  21
+    activerecord (3.2.1)
  22
+      activemodel (= 3.2.1)
  23
+      activesupport (= 3.2.1)
  24
+      arel (~> 3.0.0)
  25
+      tzinfo (~> 0.3.29)
  26
+    activeresource (3.2.1)
  27
+      activemodel (= 3.2.1)
  28
+      activesupport (= 3.2.1)
  29
+    activesupport (3.2.1)
  30
+      i18n (~> 0.6)
  31
+      multi_json (~> 1.0)
32 32
     annotate (2.4.0)
33  
-    arel (2.0.9)
34  
-    authlogic (2.1.6)
35  
-      activesupport
  33
+    arel (3.0.0)
  34
+    authlogic (3.1.0)
  35
+      activerecord (>= 3.0.7)
  36
+      activerecord (>= 3.0.7)
36 37
     autotest (4.4.6)
37 38
       ZenTest (>= 4.4.1)
38  
-    builder (2.1.2)
39  
-    diff-lcs (1.1.2)
40  
-    erubis (2.6.6)
41  
-      abstract (>= 1.0.0)
42  
-    i18n (0.5.0)
43  
-    mail (2.2.15)
44  
-      activesupport (>= 2.3.6)
  39
+    builder (3.0.0)
  40
+    diff-lcs (1.1.3)
  41
+    erubis (2.7.0)
  42
+    hike (1.2.1)
  43
+    i18n (0.6.0)
  44
+    journey (1.0.1)
  45
+    jquery-rails (2.0.0)
  46
+      railties (>= 3.2.0.beta, < 5.0)
  47
+      thor (~> 0.14)
  48
+    json (1.6.5)
  49
+    mail (2.4.1)
45 50
       i18n (>= 0.4.0)
46 51
       mime-types (~> 1.16)
47 52
       treetop (~> 1.4.8)
48  
-    mime-types (1.16)
49  
-    mysql2 (0.2.7)
50  
-    nokogiri (1.4.4)
51  
-    polyglot (0.3.1)
52  
-    rack (1.2.2)
53  
-    rack-mount (0.6.14)
54  
-      rack (>= 1.0.0)
55  
-    rack-test (0.5.7)
  53
+    mime-types (1.17.2)
  54
+    multi_json (1.0.4)
  55
+    mysql2 (0.3.11)
  56
+    nokogiri (1.5.0)
  57
+    polyglot (0.3.3)
  58
+    rack (1.4.1)
  59
+    rack-cache (1.1)
  60
+      rack (>= 0.4)
  61
+    rack-ssl (1.3.2)
  62
+      rack
  63
+    rack-test (0.6.1)
56 64
       rack (>= 1.0)
57  
-    rails (3.0.4)
58  
-      actionmailer (= 3.0.4)
59  
-      actionpack (= 3.0.4)
60  
-      activerecord (= 3.0.4)
61  
-      activeresource (= 3.0.4)
62  
-      activesupport (= 3.0.4)
  65
+    rails (3.2.1)
  66
+      actionmailer (= 3.2.1)
  67
+      actionpack (= 3.2.1)
  68
+      activerecord (= 3.2.1)
  69
+      activeresource (= 3.2.1)
  70
+      activesupport (= 3.2.1)
63 71
       bundler (~> 1.0)
64  
-      railties (= 3.0.4)
65  
-    railties (3.0.4)
66  
-      actionpack (= 3.0.4)
67  
-      activesupport (= 3.0.4)
  72
+      railties (= 3.2.1)
  73
+    railties (3.2.1)
  74
+      actionpack (= 3.2.1)
  75
+      activesupport (= 3.2.1)
  76
+      rack-ssl (~> 1.3.2)
68 77
       rake (>= 0.8.7)
69  
-      thor (~> 0.14.4)
70  
-    rake (0.8.7)
71  
-    rspec (2.5.0)
72  
-      rspec-core (~> 2.5.0)
73  
-      rspec-expectations (~> 2.5.0)
74  
-      rspec-mocks (~> 2.5.0)
75  
-    rspec-core (2.5.1)
76  
-    rspec-expectations (2.5.0)
  78
+      rdoc (~> 3.4)
  79
+      thor (~> 0.14.6)
  80
+    rake (0.9.2.2)
  81
+    rdoc (3.12)
  82
+      json (~> 1.4)
  83
+    rspec (2.8.0)
  84
+      rspec-core (~> 2.8.0)
  85
+      rspec-expectations (~> 2.8.0)
  86
+      rspec-mocks (~> 2.8.0)
  87
+    rspec-core (2.8.0)
  88
+    rspec-expectations (2.8.0)
77 89
       diff-lcs (~> 1.1.2)
78  
-    rspec-mocks (2.5.0)
79  
-    rspec-rails (2.5.0)
80  
-      actionpack (~> 3.0)
81  
-      activesupport (~> 3.0)
82  
-      railties (~> 3.0)
83  
-      rspec (~> 2.5.0)
  90
+    rspec-mocks (2.8.0)
  91
+    rspec-rails (2.8.1)
  92
+      actionpack (>= 3.0)
  93
+      activesupport (>= 3.0)
  94
+      railties (>= 3.0)
  95
+      rspec (~> 2.8.0)
  96
+    sprockets (2.1.2)
  97
+      hike (~> 1.2)
  98
+      rack (~> 1.0)
  99
+      tilt (~> 1.1, != 1.3.0)
84 100
     thor (0.14.6)
85  
-    treetop (1.4.9)
  101
+    tilt (1.3.3)
  102
+    treetop (1.4.10)
  103
+      polyglot
86 104
       polyglot (>= 0.3.1)
87  
-    tzinfo (0.3.25)
  105
+    tzinfo (0.3.31)
88 106
     webrat (0.7.3)
89 107
       nokogiri (>= 1.2.0)
90 108
       rack (>= 1.0)
@@ -97,8 +115,9 @@ DEPENDENCIES
97 115
   annotate
98 116
   authlogic
99 117
   autotest
  118
+  jquery-rails
100 119
   mysql2
101  
-  rails (= 3.0.4)
  120
+  rails (= 3.2.1)
102 121
   rspec (>= 2.0.0.beta.20)
103 122
   rspec-rails (>= 2.0.0.beta.20)
104 123
   webrat
9  app/assets/javascripts/application.js
... ...
@@ -0,0 +1,9 @@
  1
+// This is a manifest file that'll be compiled into including all the files listed below.
  2
+// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
  3
+// be included in the compiled file accessible from http://example.com/assets/application.js
  4
+// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
  5
+// the compiled file.
  6
+//
  7
+//= require jquery
  8
+//= require jquery_ujs
  9
+//= require_tree .
7  app/assets/stylesheets/application.css
... ...
@@ -0,0 +1,7 @@
  1
+/*
  2
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
  3
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
  4
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
  5
+ *= require_self
  6
+ *= require_tree . 
  7
+*/
0  public/stylesheets/custom.css → app/assets/stylesheets/custom.css
File renamed without changes
7  app/views/layouts/application.html.erb
@@ -2,10 +2,9 @@
2 2
 <html>
3 3
 <head>
4 4
   <title><%= @title.nil? ? (@menu.nil? ? t(:application_name) : @menu.capitalize + ' - ' + t(:application_name)) : @title + ' - ' + t(:application_name) %></title>
5  
-  <%= stylesheet_link_tag :all %>
6  
-	<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
7  
-  <%= csrf_meta_tag %>
8  
-  
  5
+  <%= stylesheet_link_tag "application" %>
  6
+  <%= javascript_include_tag "application" %>
  7
+  <%= csrf_meta_tag %>  
9 8
 </head>
10 9
 <body>
11 10
 		<div id="wrapper">
17  config/application.rb
@@ -2,9 +2,12 @@
2 2
 
3 3
 require 'rails/all'
4 4
 
5  
-# If you have a Gemfile, require the gems listed there, including any gems
6  
-# you've limited to :test, :development, or :production.
7  
-Bundler.require(:default, Rails.env) if defined?(Bundler)
  5
+if defined?(Bundler)
  6
+  # If you precompile assets before deploying to production, use this line
  7
+  # Bundler.require *Rails.groups(:assets => %w(development test))
  8
+  # If you want your assets lazily compiled in production, use this line
  9
+  Bundler.require(:default, :assets, Rails.env)
  10
+end
8 11
 
9 12
 module Thingspeak
10 13
   class Application < Rails::Application
@@ -13,7 +16,7 @@ class Application < Rails::Application
13 16
     # -- all .rb files in that directory are automatically loaded.
14 17
 
15 18
     # Custom directories with classes and modules you want to be autoloadable.
16  
-    # config.autoload_paths += %W(#{config.root}/extras)
  19
+    config.autoload_paths += %W(#{config.root}/lib)
17 20
 
18 21
     # Only load the plugins named here, in the order given (default is alphabetical).
19 22
     # :all can be used as a placeholder for all plugins not explicitly named.
@@ -38,5 +41,11 @@ class Application < Rails::Application
38 41
 
39 42
     # Configure sensitive parameters which will be filtered from the log file.
40 43
     config.filter_parameters += [:password]
  44
+
  45
+    # Enable the asset pipeline
  46
+    config.assets.enabled = true
  47
+
  48
+    # Version of your assets, change this if you want to expire all your assets
  49
+    config.assets.version = '1.0'
41 50
   end
42 51
 end
14  config/environments/development.rb
@@ -11,7 +11,6 @@
11 11
 
12 12
   # Show full error reports and disable caching
13 13
   config.consider_all_requests_local       = true
14  
-  config.action_view.debug_rjs             = true
15 14
   config.action_controller.perform_caching = false
16 15
 
17 16
   # Don't care if the mailer can't send
@@ -22,5 +21,18 @@
22 21
 
23 22
   # Only use best-standards-support built into browsers
24 23
   config.action_dispatch.best_standards_support = :builtin
  24
+
  25
+  # Raise exception on mass assignment protection for Active Record models
  26
+  config.active_record.mass_assignment_sanitizer = :strict
  27
+
  28
+  # Log the query plan for queries taking more than this (works
  29
+  # with SQLite, MySQL, and PostgreSQL)
  30
+  config.active_record.auto_explain_threshold_in_seconds = 0.5
  31
+
  32
+  # Do not compress assets
  33
+  config.assets.compress = false
  34
+
  35
+  # Expands the lines which load the assets
  36
+  config.assets.debug = true
25 37
 end
26 38
 
15  config/environments/production.rb
@@ -46,4 +46,19 @@
46 46
 
47 47
   # Send deprecation notices to registered listeners
48 48
   config.active_support.deprecation = :notify
  49
+
  50
+  # Compress JavaScripts and CSS
  51
+  config.assets.compress = true
  52
+
  53
+  # Don't fallback to assets pipeline if a precompiled asset is missed
  54
+  config.assets.compile = false
  55
+
  56
+  # Generate digests for assets URLs
  57
+  config.assets.digest = true
  58
+
  59
+  # Defaults to Rails.root.join("public/assets")
  60
+  # config.assets.manifest = YOUR_PATH
  61
+
  62
+  config.assets.js_compressor  = :uglifier
  63
+  config.assets.css_compressor = :scss
49 64
 end
7  config/environments/test.rb
@@ -32,4 +32,11 @@
32 32
 
33 33
   # Print deprecation notices to the stderr
34 34
   config.active_support.deprecation = :stderr
  35
+
  36
+  # Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets
  37
+  config.assets.allow_debugging = true
  38
+
  39
+  # Configure static asset server for tests with Cache-Control for performance
  40
+  config.serve_static_assets = true
  41
+  config.static_cache_control = "public, max-age=3600"
35 42
 end
BIN  public/images/rails.png
2  public/javascripts/application.js
... ...
@@ -1,2 +0,0 @@
1  
-// Place your application-specific JavaScript functions and classes here
2  
-// This file is automatically included by javascript_include_tag :defaults
175  public/javascripts/rails.js
... ...
@@ -1,175 +0,0 @@
1  
-(function() {
2  
-  // Technique from Juriy Zaytsev
3  
-  // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
4  
-  function isEventSupported(eventName) {
5  
-    var el = document.createElement('div');
6  
-    eventName = 'on' + eventName;
7  
-    var isSupported = (eventName in el);
8  
-    if (!isSupported) {
9  
-      el.setAttribute(eventName, 'return;');
10  
-      isSupported = typeof el[eventName] == 'function';
11  
-    }
12  
-    el = null;
13  
-    return isSupported;
14  
-  }
15  
-
16  
-  function isForm(element) {
17  
-    return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM'
18  
-  }
19  
-
20  
-  function isInput(element) {
21  
-    if (Object.isElement(element)) {
22  
-      var name = element.nodeName.toUpperCase()
23  
-      return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA'
24  
-    }
25  
-    else return false
26  
-  }
27  
-
28  
-  var submitBubbles = isEventSupported('submit'),
29  
-      changeBubbles = isEventSupported('change')
30  
-
31  
-  if (!submitBubbles || !changeBubbles) {
32  
-    // augment the Event.Handler class to observe custom events when needed
33  
-    Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap(
34  
-      function(init, element, eventName, selector, callback) {
35  
-        init(element, eventName, selector, callback)
36  
-        // is the handler being attached to an element that doesn't support this event?
37  
-        if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) ||
38  
-             (!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) {
39  
-          // "submit" => "emulated:submit"
40  
-          this.eventName = 'emulated:' + this.eventName
41  
-        }
42  
-      }
43  
-    )
44  
-  }
45  
-
46  
-  if (!submitBubbles) {
47  
-    // discover forms on the page by observing focus events which always bubble
48  
-    document.on('focusin', 'form', function(focusEvent, form) {
49  
-      // special handler for the real "submit" event (one-time operation)
50  
-      if (!form.retrieve('emulated:submit')) {
51  
-        form.on('submit', function(submitEvent) {
52  
-          var emulated = form.fire('emulated:submit', submitEvent, true)
53  
-          // if custom event received preventDefault, cancel the real one too
54  
-          if (emulated.returnValue === false) submitEvent.preventDefault()
55  
-        })
56  
-        form.store('emulated:submit', true)
57  
-      }
58  
-    })
59  
-  }
60  
-
61  
-  if (!changeBubbles) {
62  
-    // discover form inputs on the page
63  
-    document.on('focusin', 'input, select, texarea', function(focusEvent, input) {
64  
-      // special handler for real "change" events
65  
-      if (!input.retrieve('emulated:change')) {
66  
-        input.on('change', function(changeEvent) {
67  
-          input.fire('emulated:change', changeEvent, true)
68  
-        })
69  
-        input.store('emulated:change', true)
70  
-      }
71  
-    })
72  
-  }
73  
-
74  
-  function handleRemote(element) {
75  
-    var method, url, params;
76  
-
77  
-    var event = element.fire("ajax:before");
78  
-    if (event.stopped) return false;
79  
-
80  
-    if (element.tagName.toLowerCase() === 'form') {
81  
-      method = element.readAttribute('method') || 'post';
82  
-      url    = element.readAttribute('action');
83  
-      params = element.serialize();
84  
-    } else {
85  
-      method = element.readAttribute('data-method') || 'get';
86  
-      url    = element.readAttribute('href');
87  
-      params = {};
88  
-    }
89  
-
90  
-    new Ajax.Request(url, {
91  
-      method: method,
92  
-      parameters: params,
93  
-      evalScripts: true,
94  
-
95  
-      onComplete:    function(request) { element.fire("ajax:complete", request); },
96  
-      onSuccess:     function(request) { element.fire("ajax:success",  request); },
97  
-      onFailure:     function(request) { element.fire("ajax:failure",  request); }
98  
-    });
99  
-
100  
-    element.fire("ajax:after");
101  
-  }
102  
-
103  
-  function handleMethod(element) {
104  
-    var method = element.readAttribute('data-method'),
105  
-        url = element.readAttribute('href'),
106  
-        csrf_param = $$('meta[name=csrf-param]')[0],
107  
-        csrf_token = $$('meta[name=csrf-token]')[0];
108  
-
109  
-    var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
110  
-    element.parentNode.insert(form);
111  
-
112  
-    if (method !== 'post') {
113  
-      var field = new Element('input', { type: 'hidden', name: '_method', value: method });
114  
-      form.insert(field);
115  
-    }
116  
-
117  
-    if (csrf_param) {
118  
-      var param = csrf_param.readAttribute('content'),
119  
-          token = csrf_token.readAttribute('content'),
120  
-          field = new Element('input', { type: 'hidden', name: param, value: token });
121  
-      form.insert(field);
122  
-    }
123  
-
124  
-    form.submit();
125  
-  }
126  
-
127  
-
128  
-  document.on("click", "*[data-confirm]", function(event, element) {
129  
-    var message = element.readAttribute('data-confirm');
130  
-    if (!confirm(message)) event.stop();
131  
-  });
132  
-
133  
-  document.on("click", "a[data-remote]", function(event, element) {
134  
-    if (event.stopped) return;
135  
-    handleRemote(element);
136  
-    event.stop();
137  
-  });
138  
-
139  
-  document.on("click", "a[data-method]", function(event, element) {
140  
-    if (event.stopped) return;
141  
-    handleMethod(element);
142  
-    event.stop();
143  
-  });
144  
-
145  
-  document.on("submit", function(event) {
146  
-    var element = event.findElement(),
147  
-        message = element.readAttribute('data-confirm');
148  
-    if (message && !confirm(message)) {
149  
-      event.stop();
150  
-      return false;
151  
-    }
152  
-
153  
-    var inputs = element.select("input[type=submit][data-disable-with]");
154  
-    inputs.each(function(input) {
155  
-      input.disabled = true;
156  
-      input.writeAttribute('data-original-value', input.value);
157  
-      input.value = input.readAttribute('data-disable-with');
158  
-    });
159  
-
160  
-    var element = event.findElement("form[data-remote]");
161  
-    if (element) {
162  
-      handleRemote(element);
163  
-      event.stop();
164  
-    }
165  
-  });
166  
-
167  
-  document.on("ajax:after", "form", function(event, element) {
168  
-    var inputs = element.select("input[type=submit][disabled=true][data-disable-with]");
169  
-    inputs.each(function(input) {
170  
-      input.value = input.readAttribute('data-original-value');
171  
-      input.removeAttribute('data-original-value');
172  
-      input.disabled = false;
173  
-    });
174  
-  });
175  
-})();
0  public/stylesheets/.gitkeep
No changes.

0 notes on commit bfd5b29

Please sign in to comment.
Something went wrong with that request. Please try again.