html5-rails 0.0.7 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/README.md +23 -22
  2. data/app/assets/javascripts/application.js +1 -1
  3. data/app/assets/javascripts/polyfills.js +1 -1
  4. data/app/views/application/_flashes.html.erb +2 -4
  5. data/app/views/application/_footer.html.erb +1 -1
  6. data/app/views/application/_head.html.erb +3 -11
  7. data/app/views/application/_header.html.erb +1 -1
  8. data/app/views/application/_javascripts.html.erb +2 -2
  9. data/app/views/application/_stylesheets.html.erb +1 -1
  10. data/app/views/layouts/application.html.erb +4 -7
  11. data/html5-rails.gemspec +1 -1
  12. data/lib/generators/html5/assets/USAGE +7 -4
  13. data/lib/generators/html5/assets/assets_generator.rb +26 -25
  14. data/lib/generators/html5/assets/templates/javascripts/application.js +1 -1
  15. data/lib/generators/html5/assets/templates/javascripts/polyfills.js +1 -1
  16. data/lib/generators/html5/assets/templates/stylesheets/{application.css.scss → application/index.css.scss} +12 -16
  17. data/lib/generators/html5/assets/templates/stylesheets/application/{document.css.scss → layout.css.scss} +2 -2
  18. data/lib/generators/html5/assets/templates/stylesheets/application/media_queries.css.scss +15 -1
  19. data/lib/generators/html5/assets/templates/stylesheets/{_variables.css.scss → application/variables.css.scss} +1 -1
  20. data/lib/generators/html5/install/USAGE +14 -0
  21. data/lib/generators/html5/install/install_generator.rb +1 -1
  22. data/lib/generators/html5/install/templates/README +2 -2
  23. data/lib/generators/html5/install/templates/config/compass.rb +1 -1
  24. data/lib/generators/html5/install/templates/config/html5_rails.yml +2 -2
  25. data/lib/generators/html5/layout/USAGE +3 -3
  26. data/lib/generators/html5/layout/layout_generator.rb +5 -5
  27. data/lib/generators/html5/layout/templates/application.html.erb +3 -6
  28. data/lib/generators/html5/layout/templates/application.html.haml +8 -10
  29. data/lib/generators/html5/layout/templates/application.html.slim +18 -11
  30. data/lib/generators/html5/partial/USAGE +13 -3
  31. data/lib/generators/html5/partial/partial_generator.rb +9 -9
  32. data/lib/generators/html5/partial/templates/_chromeframe.html.haml +1 -1
  33. data/lib/generators/html5/partial/templates/_chromeframe.html.slim +1 -1
  34. data/lib/generators/html5/partial/templates/_flashes.html.erb +2 -4
  35. data/lib/generators/html5/partial/templates/_flashes.html.haml +2 -3
  36. data/lib/generators/html5/partial/templates/_flashes.html.slim +2 -3
  37. data/lib/generators/html5/partial/templates/_footer.html.erb +1 -1
  38. data/lib/generators/html5/partial/templates/_footer.html.haml +1 -1
  39. data/lib/generators/html5/partial/templates/_footer.html.slim +1 -1
  40. data/lib/generators/html5/partial/templates/_head.html.erb +3 -11
  41. data/lib/generators/html5/partial/templates/_head.html.haml +6 -17
  42. data/lib/generators/html5/partial/templates/_head.html.slim +6 -17
  43. data/lib/generators/html5/partial/templates/_header.html.erb +1 -1
  44. data/lib/generators/html5/partial/templates/_header.html.haml +1 -1
  45. data/lib/generators/html5/partial/templates/_javascripts.html.erb +2 -2
  46. data/lib/generators/html5/partial/templates/_javascripts.html.haml +3 -3
  47. data/lib/generators/html5/partial/templates/_javascripts.html.slim +4 -4
  48. data/lib/generators/html5/partial/templates/_stylesheets.html.erb +1 -1
  49. data/lib/generators/html5/partial/templates/_stylesheets.html.haml +1 -1
  50. data/lib/html5-rails.rb +1 -1
  51. data/lib/html5/rails/helpers.rb +1 -7
  52. data/lib/html5/rails/version.rb +2 -2
  53. data/test/generators/assets_generator_test.rb +18 -22
  54. data/test/generators/install_generator_test.rb +6 -7
  55. data/test/generators/layout_generator_test.rb +1 -2
  56. data/test/generators/partial_generator_test.rb +2 -3
  57. data/test/html5_rails_test.rb +1 -1
  58. data/test/test_helper.rb +1 -1
  59. data/vendor/assets/javascripts/h5bp.js +22 -0
  60. data/vendor/assets/javascripts/modernizr.min.js +3 -3
  61. metadata +16 -12
  62. data/lib/generators/html5/assets/templates/stylesheets/application/chromeframe.css.scss +0 -14
  63. data/vendor/assets/javascripts/h5bp/index.js +0 -1
  64. data/vendor/assets/javascripts/h5bp/plugins.js +0 -7
data/README.md CHANGED
@@ -4,8 +4,6 @@ Html5 for Rails
4
4
  Html5 for Rails projects based on [Html5 Boilerplate](http://html5boilerplate.com)
5
5
  by Paul Irish, Divya Manian and many other [fine folks](https://github.com/h5bp/html5-boilerplate/contributors).
6
6
 
7
- (Also, a rewrite of compass-html5-boilerplate that adds Rails asset pipeline integration).
8
-
9
7
  Installation
10
8
  =========================
11
9
 
@@ -16,17 +14,18 @@ group :assets do
16
14
  gem 'sass-rails'
17
15
  gem 'coffee-rails'
18
16
  gem 'uglifier'
19
- gem 'compass-rails'
17
+
20
18
  gem 'compass-h5bp'
21
19
  end
22
20
 
23
- # Optional - to generate haml
24
- #gem 'haml-rails'
25
- # Optional - to generate slim
26
- #gem 'slim-rails'
27
-
28
21
  gem 'jquery-rails'
29
22
  gem 'html5-rails'
23
+
24
+ # Optional: to generate haml
25
+ # gem 'haml-rails'
26
+
27
+ # Optional: to generate slim
28
+ # gem 'slim-rails'
30
29
  ```
31
30
 
32
31
  ##### 2. Install your bundle
@@ -45,21 +44,21 @@ $ rails generate html5:install
45
44
 
46
45
  create config/compass.rb
47
46
  create config/html5_rails.yml
48
- create app/views/layouts/application.html.erb
47
+ create app/views/layouts/application.html.(erb|haml|slim)
49
48
  create app/views/application
50
- create app/views/application/_footer.html.erb
51
- create app/views/application/_head.html.erb
52
- create app/views/application/_header.html.erb
53
- create app/views/application/_chromeframe.html.erb
49
+ create app/views/application/_footer.html.(erb|haml|slim)
50
+ create app/views/application/_head.html.(erb|haml|slim)
51
+ create app/views/application/_header.html.(erb|haml|slim)
52
+ create app/views/application/_chromeframe.html.(erb|haml|slim)
53
+ exist app/assets/javascripts
54
54
  insert app/assets/javascripts/application.js
55
55
  gsub app/assets/javascripts/application.js
56
56
  create app/assets/javascripts/polyfills.js
57
57
  remove app/assets/stylesheets/application.css
58
- create app/assets/stylesheets/_variables.css.scss
59
- create app/assets/stylesheets/application.css.scss
60
58
  create app/assets/stylesheets/application
61
- create app/assets/stylesheets/application/chromeframe.css.scss
62
- create app/assets/stylesheets/application/document.css.scss
59
+ create app/assets/stylesheets/application/index.css.scss
60
+ create app/assets/stylesheets/application/variables.css.scss
61
+ create app/assets/stylesheets/application/layout.css.scss
63
62
  create app/assets/stylesheets/application/media_queries.css.scss
64
63
 
65
64
  ##### 4. And you're done!
@@ -78,6 +77,11 @@ $ rails generate html5:partial --help
78
77
  $ rails generate html5:assets --help
79
78
  ```
80
79
 
80
+ Google Analytics
81
+ =========================
82
+
83
+ By default your Google Analytics code snippet will be hidden until you set your Google Account ID.
84
+ You can do this by either setting `ENV['GOOGLE_ACCOUNT_ID']` or `google_account_id` in config/html5_rails.yml.
81
85
 
82
86
  Notes
83
87
  ==========
@@ -86,13 +90,10 @@ Notes
86
90
  included in your assets group for development and asset precompiling to work.
87
91
 
88
92
  [2] If you use `--template-engine=haml` (or `haml-rails` gem), the install
89
- generator will remove your application.html.erb layout so that
93
+ generator will prompt to remove your application.html.erb layout so that
90
94
  application.html.haml will be used instead.
91
95
 
92
- [3] If you're upgrading from compass-html5-boilerplate you need to
93
- remove config/compass.rb before you run the generators.
94
-
95
- [4] For the time being, you will want to add the following line to
96
+ [3] For the time being, you will want to add the following line to
96
97
  config/production.rb so that polyfills are precompiled on deploy:
97
98
 
98
99
  `config.assets.precompile += %w( polyfills.js )`
@@ -6,4 +6,4 @@
6
6
  //
7
7
  //= require jquery
8
8
  //= require jquery_ujs
9
- //= require h5bp
9
+ //= require h5bp
@@ -3,4 +3,4 @@
3
3
  //
4
4
  // polyfill (n): a JavaScript shim that replicates the standard API for older browsers.
5
5
  //
6
- //= require modernizr.min
6
+ //= require modernizr.min
@@ -1,9 +1,7 @@
1
1
  <div id="flash">
2
2
  <% flash.each do |key, value| %>
3
- <div class="wrapper">
4
- <div title="<%= key.to_s.humanize %>" class="<%= key %>">
5
- <p><%= value %></p>
6
- </div>
3
+ <div title="<%= key.to_s.humanize %>" class="<%= key %>">
4
+ <p><%= value %></p>
7
5
  </div>
8
6
  <% end %>
9
7
  </div>
@@ -2,4 +2,4 @@
2
2
  <small class="copyright">
3
3
  Dummy, Copyright &copy; <%= Date.today.year %>
4
4
  </small>
5
- </footer>
5
+ </footer>
@@ -1,22 +1,14 @@
1
1
  <head>
2
2
  <meta charset="utf-8">
3
-
4
- <%# Use the .htaccess and remove these lines to avoid edge case issues. %>
5
- <%# More info: h5bp.com/b/378 %>
6
3
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
7
4
 
8
- <title></title>
9
- <meta name="description" content="">
5
+ <title><%= "#{ controller.controller_name.titleize } - #{ controller.action_name.titleize }" %></title>
10
6
 
11
- <%# Mobile viewport optimized: h5bp.com/viewport %>
7
+ <meta name="description" content="">
12
8
  <meta name="viewport" content="width=device-width">
13
9
 
14
10
  <%= render "stylesheets" %>
15
-
16
- <%# More ideas for your <head> here: h5bp.com/d/head-Tips %>
17
-
18
- <%# All JavaScript at the bottom, except polyfills %>
19
11
  <%= javascript_include_tag "polyfills" %>
20
12
 
21
13
  <%= csrf_meta_tag %>
22
- </head>
14
+ </head>
@@ -1,3 +1,3 @@
1
1
  <header id="header">
2
2
  <h1>Dummy</h1>
3
- </header>
3
+ </header>
@@ -3,7 +3,7 @@
3
3
  <%# Append your own using content_for :javascripts %>
4
4
  <%= yield :javascripts %>
5
5
 
6
- <%# asynchronous google analytics: mathiasbynens.be/notes/async-analytics-snippet %>
6
+ <%# Google Analytics %>
7
7
  <%# Looks for google_account_id first in ENV['GOOGLE_ACCOUNT_ID'] then in config/html5_rails.yml %>
8
8
  <% if !google_account_id.blank? %>
9
9
  <script>
@@ -14,4 +14,4 @@
14
14
  s.parentNode.insertBefore(g,s)}(document,'script'));
15
15
  //]]>
16
16
  </script>
17
- <% end %>
17
+ <% end %>
@@ -1,4 +1,4 @@
1
1
  <%= stylesheet_link_tag 'application', :media => nil %>
2
2
 
3
3
  <%# Append your own using content_for :stylesheets %>
4
- <%= yield :stylesheets %>
4
+ <%= yield :stylesheets %>
@@ -1,20 +1,17 @@
1
1
  <!DOCTYPE html>
2
- <%# http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither %>
3
2
  <%= html_tag :class => "no-js" %>
4
3
  <%= render "head" %>
5
4
 
6
- <body class="pages">
5
+ <body class="<%= controller.controller_name %>">
7
6
  <%= render "chromeframe" %>
8
7
  <%= render "header" %>
8
+ <%= render "flashes" %>
9
9
 
10
- <div id="main" role="main">
11
- <%= render "flashes" %>
12
- <%= yield %>
13
- </div>
10
+ <%= yield %>
14
11
 
15
12
  <%= render "footer" %>
16
13
 
17
14
  <%# Javascript at the bottom for fast page loading %>
18
15
  <%= render "javascripts" %>
19
16
  </body>
20
- </html>
17
+ </html>
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.rubyforge_project = "html5-rails"
16
16
 
17
17
  s.add_dependency "jquery-rails", ">= 2.0"
18
- s.add_dependency "railties", "~> 3.1"
18
+ s.add_dependency "railties", ">= 3.2"
19
19
  s.add_dependency "thor", "~> 0.14"
20
20
 
21
21
  s.add_development_dependency "compass-h5bp", "~> 0.1.0"
@@ -1,11 +1,14 @@
1
1
  Description:
2
- Generates CSS assets with compass imports and partials.
2
+ Generates javascript and stylesheet assets for a named resource.
3
3
 
4
4
  Example:
5
5
  rails generate html5:assets admin
6
6
 
7
7
  This will create:
8
- app/assets/stylesheets/admin.css.scss
9
- app/assets/stylesheets/_defaults.css.scss
10
- app/assets/stylesheets/admin/document.css.scss
8
+ app/assets/javascripts/admin.js
9
+ app/assets/javascripts/polyfills.js
10
+ app/assets/stylesheets/admin
11
+ app/assets/stylesheets/admin/index.css.scss
12
+ app/assets/stylesheets/admin/variables.css.scss
13
+ app/assets/stylesheets/admin/layout.css.scss
11
14
  app/assets/stylesheets/admin/media_queries.css.scss
@@ -9,39 +9,40 @@ module Html5
9
9
 
10
10
  argument :name, :type => :string,
11
11
  :required => false,
12
- :default => "application"
12
+ :default => 'application'
13
13
 
14
14
  def generate_javascripts
15
- asset_path = "app/assets/javascripts/#{ asset_name }.js"
16
- if File.exist?(asset_path) && File.read(asset_path) =~ /require jquery_ujs$/
17
- inject_into_file asset_path, :after => "require jquery_ujs" do
15
+ prefix = File.join('app', 'assets', 'javascripts')
16
+ manifest = File.join(prefix, File.basename(asset_path) + '.js')
17
+
18
+ empty_directory File.join(prefix, File.dirname(asset_path))
19
+
20
+ if File.exist?(manifest) && File.read(manifest) =~ /require jquery_ujs$/
21
+ inject_into_file manifest, :after => "require jquery_ujs" do
18
22
  "\n//= require h5bp"
19
23
  end
20
- gsub_file asset_path, /^\/\/= require_tree \.(\\n)?/, ""
24
+ gsub_file manifest, /^\/\/= require_tree \.(\\n)?/, ''
21
25
  else
22
- template "javascripts/application.js", asset_path
26
+ template "javascripts/application.js", manifest
23
27
  end
24
- template "javascripts/polyfills.js", "app/assets/javascripts/polyfills.js"
28
+
29
+ template "javascripts/polyfills.js", File.join(prefix, 'polyfills.js')
25
30
  end
26
31
 
27
32
  def generate_stylesheets
28
- if file_path == "application"
29
- remove_file "app/assets/stylesheets/application.css"
30
- end
33
+ prefix = File.join('app', 'assets', 'stylesheets')
31
34
 
32
- file_ext = ".css.scss"
33
- copy_file "stylesheets/_variables#{ file_ext }", "app/assets/stylesheets/_variables#{ file_ext }"
34
- template "stylesheets/application#{ file_ext }", File.join("app/assets/stylesheets", asset_name + file_ext)
35
- end
35
+ if file_path == 'application'
36
+ remove_file File.join(prefix, 'application.css')
37
+ end
36
38
 
37
- def generate_stylesheet_partials
38
- if stylesheet_partials.any?
39
- empty_directory File.join("app/assets/stylesheets", asset_name)
39
+ if stylesheets.any?
40
+ empty_directory File.join(prefix, asset_path)
40
41
  end
41
42
 
42
- file_ext = ".css.scss"
43
- stylesheet_partials.each do |partial|
44
- template File.join("stylesheets/application", partial + file_ext), File.join("app/assets/stylesheets", asset_name, partial + file_ext)
43
+ stylesheets.each do |stylesheet|
44
+ file_name = stylesheet + ".css.scss"
45
+ template "stylesheets/application/#{ file_name }", File.join(prefix, asset_path, file_name)
45
46
  end
46
47
  end
47
48
 
@@ -51,13 +52,13 @@ module Html5
51
52
 
52
53
  protected
53
54
 
54
- def asset_name
55
- (class_path + [file_name]).join('_')
55
+ def asset_path
56
+ File.join(class_path + [file_name])
56
57
  end
57
58
 
58
- def stylesheet_partials
59
- %w(chromeframe document media_queries)
59
+ def stylesheets
60
+ %w(index variables layout media_queries)
60
61
  end
61
62
  end
62
63
  end
63
- end
64
+ end
@@ -6,4 +6,4 @@
6
6
  //
7
7
  //= require jquery
8
8
  //= require jquery_ujs
9
- //= require h5bp
9
+ //= require h5bp
@@ -7,4 +7,4 @@
7
7
  //
8
8
  // polyfill (n): a JavaScript shim that replicates the standard API for older browsers.
9
9
  //
10
- //= require modernizr.min
10
+ //= require modernizr.min
@@ -1,33 +1,29 @@
1
1
  // This file was generated by html5-rails
2
2
  // https://github.com/sporkd/html5-rails
3
3
  // Upgrade with: $ rails generate html5:install
4
+ //
5
+ // <%= file_path %> styles
4
6
 
5
7
  //-----------------------------------------
6
- // Variables come first
8
+ // Variables
7
9
  //-----------------------------------------
8
- @import "variables";
10
+ @import 'variables';
9
11
 
10
12
  //-----------------------------------------
11
- // Imports
13
+ // Vendor imports
12
14
  //-----------------------------------------
13
- // @import "compass/css3";
14
- @import "h5bp";
15
+ // @import 'compass/css3';
16
+ @import 'h5bp';
15
17
 
16
18
  //-----------------------------------------
17
- // Prepend includes
19
+ // Vendor includes
18
20
  //-----------------------------------------
19
21
  @include h5bp-normalize;
20
22
  @include h5bp-main;
23
+ @include h5bp-helpers;
21
24
 
22
25
  //-----------------------------------------
23
- // Custom <%= file_path %> partials
24
- //-----------------------------------------
25
- @import "<%= file_path %>/chromeframe";
26
- @import "<%= file_path %>/document";
27
- @import "<%= file_path %>/media_queries"; // Media queries last
28
-
29
- //-----------------------------------------
30
- // Append includes
26
+ // Custom imports
31
27
  //-----------------------------------------
32
- @include h5bp-helpers;
33
- @include h5bp-media;
28
+ @import 'layout';
29
+ @import 'media_queries';
@@ -3,8 +3,8 @@
3
3
  // Upgrade with: $ rails generate html5:install
4
4
 
5
5
  //-----------------------------------------
6
- // Document styles
6
+ // Layout styles
7
7
  //-----------------------------------------
8
8
 
9
9
  html {}
10
- body {}
10
+ body {}
@@ -8,4 +8,18 @@
8
8
 
9
9
  @media only screen and (min-width: 35em) {
10
10
  // Style adjustments for viewports that meet the condition
11
- }
11
+ }
12
+
13
+ @media print,
14
+ (-o-min-device-pixel-ratio: 5/4),
15
+ (-webkit-min-device-pixel-ratio: 1.25),
16
+ (min-resolution: 120dpi) {
17
+ // Style adjustments for high resolution devices
18
+ }
19
+
20
+ // Print styles.
21
+ // Inlined to avoid required HTTP connection: h5bp.com/r
22
+
23
+ @media print {
24
+ @include h5bp-media-print;
25
+ }
@@ -17,4 +17,4 @@ $link-hover-color: #06e;
17
17
  $link-visited-color: #551a8b;
18
18
  $selected-font-color: #fff;
19
19
  $selected-background-color: #ff5e99;
20
- $invalid-background-color: #f0dddd;
20
+ $invalid-background-color: #f0dddd;
@@ -7,3 +7,17 @@ Example:
7
7
  This will create:
8
8
  config/compass.rb
9
9
  config/html5_rails.yml
10
+ app/views/layouts/application.html.(erb|haml|slim)
11
+ app/views/layouts/application.html.(erb|haml|slim)
12
+ app/views/application
13
+ app/views/application/_footer.html.(erb|haml|slim)
14
+ app/views/application/_head.html.(erb|haml|slim)
15
+ app/views/application/_header.html.(erb|haml|slim)
16
+ app/views/application/_chromeframe.html.(erb|haml|slim)
17
+ app/assets/javascripts/application.js
18
+ app/assets/javascripts/polyfills.js
19
+ app/assets/stylesheets/application
20
+ app/assets/stylesheets/application/index.css.scss
21
+ app/assets/stylesheets/application/variables.css.scss
22
+ app/assets/stylesheets/application/layout.css.scss
23
+ app/assets/stylesheets/application/media_queries.css.scss
@@ -34,4 +34,4 @@ module Html5
34
34
  end
35
35
  end
36
36
  end
37
- end
37
+ end
@@ -1,6 +1,6 @@
1
1
  ===============================================================================
2
2
 
3
- You are now on html5-rails. Really, that's it for now.
3
+ You've successfully installed html5-rails!
4
4
 
5
5
  If want to genrate additional layouts, just run:
6
6
  $ rails g html5:layout my_new_layout
@@ -8,4 +8,4 @@ $ rails g html5:layout my_new_layout
8
8
  Or if want to customize your other shared partials:
9
9
  $ rails g html5:partial --all
10
10
 
11
- ===============================================================================
11
+ ===============================================================================