html5-rails 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/Gemfile +13 -12
  2. data/LICENSE +20 -0
  3. data/README.md +58 -3
  4. data/app/assets/javascripts/application.js +9 -1
  5. data/app/assets/javascripts/polyfills.js +9 -1
  6. data/app/views/application/_flashes.html.erb +9 -0
  7. data/app/views/application/_footer.html.erb +5 -0
  8. data/app/views/application/_head.html.erb +25 -0
  9. data/app/views/application/_header.html.erb +3 -0
  10. data/app/views/application/_javascripts.html.erb +24 -0
  11. data/app/views/application/_stylesheets.html.erb +4 -0
  12. data/app/views/layouts/application.html.erb +25 -0
  13. data/html5-rails.gemspec +4 -2
  14. data/lib/generators/html5/assets/USAGE +11 -0
  15. data/lib/generators/html5/assets/assets_generator.rb +63 -0
  16. data/lib/generators/html5/assets/templates/javascripts/application.js +9 -0
  17. data/lib/generators/html5/assets/templates/javascripts/polyfills.js +10 -0
  18. data/lib/generators/html5/assets/templates/stylesheets/_defaults.css.scss +18 -0
  19. data/lib/generators/html5/assets/templates/stylesheets/application.css.scss +42 -0
  20. data/lib/generators/html5/assets/templates/stylesheets/application/_defaults.css.scss +7 -0
  21. data/lib/generators/html5/assets/templates/stylesheets/application/document.css.scss +9 -0
  22. data/lib/generators/html5/assets/templates/stylesheets/application/media_queries.css.scss +17 -0
  23. data/lib/generators/html5/generator_helpers.rb +37 -0
  24. data/lib/generators/html5/install/USAGE +1 -0
  25. data/lib/generators/html5/install/install_generator.rb +18 -3
  26. data/lib/generators/html5/install/templates/README +10 -2
  27. data/lib/generators/html5/install/templates/{compass.rb → config/compass.rb} +1 -1
  28. data/lib/generators/html5/install/templates/config/html5_rails.yml +26 -0
  29. data/lib/generators/html5/layout/USAGE +8 -0
  30. data/lib/generators/html5/layout/layout_generator.rb +44 -0
  31. data/lib/generators/html5/layout/templates/application.html.erb +25 -0
  32. data/lib/generators/html5/layout/templates/application.html.haml +16 -0
  33. data/lib/generators/html5/partial/USAGE +8 -0
  34. data/lib/generators/html5/partial/partial_generator.rb +77 -0
  35. data/lib/generators/html5/partial/templates/_flashes.html.erb +9 -0
  36. data/lib/generators/html5/partial/templates/_flashes.html.haml +5 -0
  37. data/lib/generators/html5/partial/templates/_footer.html.erb +5 -0
  38. data/lib/generators/html5/partial/templates/_footer.html.haml +3 -0
  39. data/lib/generators/html5/partial/templates/_head.html.erb +25 -0
  40. data/lib/generators/html5/partial/templates/_head.html.haml +28 -0
  41. data/lib/generators/html5/partial/templates/_header.html.erb +3 -0
  42. data/lib/generators/html5/partial/templates/_header.html.haml +2 -0
  43. data/lib/generators/html5/partial/templates/_javascripts.html.erb +24 -0
  44. data/lib/generators/html5/partial/templates/_javascripts.html.haml +19 -0
  45. data/lib/generators/html5/partial/templates/_stylesheets.html.erb +4 -0
  46. data/lib/generators/html5/partial/templates/_stylesheets.html.haml +4 -0
  47. data/lib/html5/rails.rb +1 -1
  48. data/lib/html5/rails/engine.rb +1 -1
  49. data/lib/html5/rails/{boilerplate_helper.rb → helpers.rb} +12 -10
  50. data/lib/html5/rails/version.rb +3 -5
  51. data/test/dummy/.gitignore +15 -5
  52. data/test/dummy/app/assets/javascripts/application.js +9 -2
  53. data/test/dummy/app/assets/stylesheets/application.css +7 -0
  54. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  55. data/test/dummy/app/views/pages/home.html.erb +1 -0
  56. data/test/dummy/config/application.rb +9 -4
  57. data/test/dummy/config/environments/development.rb +3 -0
  58. data/test/dummy/config/environments/production.rb +11 -2
  59. data/test/dummy/config/initializers/wrap_parameters.rb +5 -3
  60. data/test/dummy/config/routes.rb +1 -1
  61. data/test/dummy/db/seeds.rb +7 -0
  62. data/test/dummy/doc/README_FOR_APP +2 -0
  63. data/test/dummy/lib/assets/.gitkeep +0 -0
  64. data/test/generators/assets_generator_test.rb +60 -0
  65. data/test/generators/install_generator_test.rb +44 -3
  66. data/test/generators/layout_generator_test.rb +71 -0
  67. data/test/generators/partial_generator_test.rb +75 -0
  68. data/test/support/generator_test_helper.rb +18 -0
  69. data/test/test_helper.rb +4 -8
  70. data/{app/assets/javascripts/html5/boilerplate → vendor/assets/javascripts/h5bp}/index.js +0 -0
  71. data/vendor/assets/javascripts/h5bp/plugins.js +15 -0
  72. data/vendor/assets/javascripts/modernizr.min.js +3 -3
  73. metadata +115 -72
  74. data/LICENSE.rb +0 -3
  75. data/app/assets/javascripts/html5/boilerplate/plugins.js +0 -16
  76. data/app/assets/javascripts/html5/boilerplate/polyfills.js +0 -2
  77. data/app/views/application/_flashes.html.haml +0 -4
  78. data/app/views/application/_footer.html.haml +0 -2
  79. data/app/views/application/_head.html.haml +0 -24
  80. data/app/views/application/_header.html.haml +0 -1
  81. data/app/views/application/_javascripts.html.haml +0 -27
  82. data/app/views/application/_stylesheets.html.haml +0 -5
  83. data/app/views/layouts/application.html.haml +0 -20
  84. data/test/dummy/app/assets/stylesheets/application.css.scss +0 -19
  85. data/test/dummy/app/assets/stylesheets/partials/_media.css.scss +0 -22
  86. data/test/dummy/app/views/pages/home.html.haml +0 -2
  87. data/test/dummy/config/initializers/sass.rb +0 -3
  88. data/vendor/assets/javascripts/respond.min.js +0 -2
@@ -0,0 +1,7 @@
1
+ // This file was generated by html5-rails
2
+ // https://github.com/sporkd/html5-rails
3
+ // Upgrade with: $ rails generate html5:install
4
+ //
5
+ // These SCSS(SASS) variables will only be available
6
+ // to <%= file_path %> stylesheets.
7
+
@@ -0,0 +1,9 @@
1
+ // This file was generated by html5-rails
2
+ // https://github.com/sporkd/html5-rails
3
+ // Upgrade with: $ rails generate html5:install
4
+
5
+ //-----------------------------------------
6
+ // Document styles
7
+ //-----------------------------------------
8
+ html {}
9
+ body {}
@@ -0,0 +1,17 @@
1
+ // This file was generated by html5-rails
2
+ // https://github.com/sporkd/html5-rails
3
+ // Upgrade with: $ rails generate html5:install
4
+ //
5
+ // PLACEHOLDER Media Queries for Responsive Design.
6
+ // These override the primary ('mobile first') styles
7
+ // Modify as content requires.
8
+
9
+ @media only screen and (min-width: 480px) {
10
+ // Style adjustments for viewports 480px and over go here
11
+
12
+ }
13
+
14
+ @media only screen and (min-width: 768px) {
15
+ // Style adjustments for viewports 768px and over go here
16
+
17
+ }
@@ -0,0 +1,37 @@
1
+ module Html5
2
+ module Generators
3
+ module GeneratorHelpers
4
+
5
+ def application_name
6
+ if defined?(::Rails) && ::Rails.application
7
+ ::Rails.application.class.name.split('::').first
8
+ else
9
+ "application"
10
+ end
11
+ end
12
+
13
+ def application_title
14
+ if defined?(::Rails) && ::Rails.application
15
+ ::Rails.application.class.name.split('::').first.titleize
16
+ else
17
+ "My App"
18
+ end
19
+ end
20
+
21
+ protected
22
+
23
+ def format
24
+ :html
25
+ end
26
+
27
+ def handler
28
+ # Rails.configuration.generators.rails[:template_engine] ||
29
+ options[:template_engine] || :erb
30
+ end
31
+
32
+ def filename_with_extensions(name)
33
+ [name, format, handler].compact.join(".")
34
+ end
35
+ end
36
+ end
37
+ end
@@ -6,3 +6,4 @@ Example:
6
6
 
7
7
  This will create:
8
8
  config/compass.rb
9
+ config/html5_rails.yml
@@ -1,17 +1,32 @@
1
+ require "generators/html5/generator_helpers"
2
+
1
3
  module Html5
2
4
  module Generators
3
5
  class InstallGenerator < ::Rails::Generators::Base
6
+ include Html5::Generators::GeneratorHelpers
7
+
4
8
  source_root File.expand_path('../templates', __FILE__)
5
9
 
10
+ class_option :template_engine
11
+
6
12
  # def run_config
7
13
  # inside do
8
14
  # # Needs more work
9
- # run("bundle exec compass config --app rails -r compass-html5 -q")
15
+ # run("bundle exec compass config --app rails -r compass-h5bp -q")
10
16
  # end
11
17
  # end
12
18
 
13
- def copy_config
14
- copy_file "compass.rb", "config/compass.rb"
19
+ def copy_configs
20
+ template "config/compass.rb"
21
+ template "config/html5_rails.yml"
22
+ end
23
+
24
+ def generate_layout
25
+ invoke "html5:layout", ["application"], { :minimal_partials => true, :template_engine => options[:template_engine] }
26
+ end
27
+
28
+ def generate_assets
29
+ invoke "html5:assets", ["application"]
15
30
  end
16
31
 
17
32
  def show_readme
@@ -1,3 +1,11 @@
1
- README
2
- ==================
1
+ ===============================================================================
3
2
 
3
+ You are now on html5-rails. Really, that's it for now.
4
+
5
+ If want to genrate additional layouts, just run:
6
+ $ rails g html5:layout my_new_layout
7
+
8
+ Or if want to customize your other shared partials:
9
+ $ rails g html5:partial --all
10
+
11
+ ===============================================================================
@@ -1,5 +1,5 @@
1
1
  # This configuration file works with both the Compass command line tool and within Rails.
2
- require 'compass/html5'
2
+ require 'compass/h5bp'
3
3
 
4
4
  # Require any additional compass plugins here.
5
5
 
@@ -0,0 +1,26 @@
1
+ # This file stores config values that html5-rails uses
2
+ # to render various code blocks and features.
3
+ # (i.e. Google Analytics)
4
+ #
5
+ # Leaving a value blank will result in that code block
6
+ # or feature not rendering.
7
+ #
8
+ # You can also define any key/value pair in you ENV and
9
+ # it will take precidence over the yml value.
10
+ # e.g. ENV['google_account_id'] || yml[:google_account_id]
11
+
12
+ defaults: &defaults
13
+ :google_account_id: "" # Google Analytics
14
+ :google_api_key: "" # Google APIs
15
+
16
+ :development:
17
+ <<: *defaults
18
+
19
+ :test:
20
+ <<: *defaults
21
+
22
+ :staging:
23
+ <<: *defaults
24
+
25
+ :production:
26
+ <<: *defaults
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Removes Erb layout and installs a html5-rails Haml layout.
3
+
4
+ Example:
5
+ rails generate html5:layout layout_name
6
+
7
+ This will create:
8
+ app/views/layouts/layout_name.html.haml
@@ -0,0 +1,44 @@
1
+ require "generators/html5/generator_helpers"
2
+
3
+ module Html5
4
+ module Generators
5
+ class LayoutGenerator < ::Rails::Generators::NamedBase
6
+ include Html5::Generators::GeneratorHelpers
7
+
8
+ source_root File.expand_path('../templates', __FILE__)
9
+
10
+ argument :name, :type => :string,
11
+ :required => false,
12
+ :default => "application"
13
+
14
+ class_option :all_partials, :type => :boolean,
15
+ :default => false,
16
+ :desc => "Generate all partials for this layout"
17
+
18
+ class_option :minimal_partials, :type => :boolean,
19
+ :default => false,
20
+ :desc => "Generate minimal partials for this layout"
21
+
22
+ class_option :template_engine
23
+
24
+ def generate_layout
25
+ if file_path == "application" && options[:template_engine].to_s != "erb"
26
+ remove_file File.join("app/views/layouts/application.html.erb")
27
+ end
28
+ template filename_with_extensions("application"), File.join("app/views/layouts", class_path, filename_with_extensions(file_name))
29
+ end
30
+
31
+ def generate_partials
32
+ if options.all_partials?
33
+ invoke "html5:partial", [], { :all => true, :path => file_path,
34
+ :template_engine => options[:template_engine] }
35
+ end
36
+
37
+ if options.minimal_partials?
38
+ invoke "html5:partial", [], { :minimal => true, :path => file_path,
39
+ :template_engine => options[:template_engine] }
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <%%# http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither %>
3
+ <!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7 no-js" lang="en"> <![endif]-->
4
+ <!--[if IE 7]> <html class="lt-ie9 lt-ie8 no-js" lang="en"> <![endif]-->
5
+ <!--[if IE 8]> <html class="lt-ie9 no-js" lang="en"> <![endif]-->
6
+ <!--[if gt IE 8]><!-->
7
+ <html class='no-js' lang='en'>
8
+ <!--<![endif]-->
9
+
10
+ <%%= render "head" %>
11
+
12
+ <body class='pages'>
13
+ <%%= render "header" %>
14
+
15
+ <div id='main' role='main'>
16
+ <%%= render "flashes" %>
17
+ <%%= yield %>
18
+ </div>
19
+
20
+ <%%= render "footer" %>
21
+
22
+ <%%# Javascript at the bottom for fast page loading %>
23
+ <%%= render "javascripts" %>
24
+ </body>
25
+ </html>
@@ -0,0 +1,16 @@
1
+ !!! 5
2
+ -# http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither
3
+ - ie_html :class => "no-js", :lang => "en" do
4
+ = render "head"
5
+
6
+ %body{ :class => "#{ controller.controller_name }" }
7
+ = render "header"
8
+
9
+ #main{ :role => "main" }
10
+ = render "flashes"
11
+ = yield
12
+
13
+ = render "footer"
14
+
15
+ -# Javascript at the bottom for fast page loading
16
+ = render "javascripts"
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Generates a partial
3
+
4
+ Example:
5
+ rails generate html5:partial _partial_name
6
+
7
+ This will create:
8
+ app/views/application/_partial_name.html.haml
@@ -0,0 +1,77 @@
1
+ require "generators/html5/generator_helpers"
2
+
3
+ module Html5
4
+ module Generators
5
+ class PartialGenerator < ::Rails::Generators::NamedBase
6
+ include Html5::Generators::GeneratorHelpers
7
+
8
+ source_root File.expand_path('../templates', __FILE__)
9
+
10
+ argument :name, :type => :string,
11
+ :required => false,
12
+ :default => ""
13
+
14
+ class_option :all, :type => :boolean,
15
+ :default => false,
16
+ :desc => "Generate all partials"
17
+
18
+ class_option :minimal, :type => :boolean,
19
+ :default => false,
20
+ :desc => "Generate minimal partials (_head, _header, _footer)"
21
+
22
+ class_option :path, :type => :string,
23
+ :default => nil,
24
+ :required => false,
25
+ :desc => "resource path to generate partials in"
26
+
27
+ class_option :template_engine
28
+
29
+ # def validate_name
30
+ # if options[:all] || options[:minimal]
31
+ # if partials.include?(file_name)
32
+ # path = class_path.join("/")
33
+ # message = "Argument '#{ file_path }' not allowed with --all or --minimal options."
34
+ # message << " Try using '#{ path }' instead." if !path.blank?
35
+ # raise Error, message
36
+ # end
37
+ # end
38
+ # end
39
+
40
+ def generate_partials
41
+ if partials.any?
42
+ empty_directory File.join("app/views", partial_path)
43
+ end
44
+ partials.each do |partial|
45
+ generate_partial(partial)
46
+ end
47
+ end
48
+
49
+ protected
50
+
51
+ def partials
52
+ if options[:all]
53
+ %w(_flashes _footer _head _header _javascripts _stylesheets)
54
+ elsif options.minimal?
55
+ %w(_footer _head _header)
56
+ elsif file_name
57
+ [file_name]
58
+ else
59
+ []
60
+ end
61
+ end
62
+
63
+ def partial_path
64
+ if !options.path.blank?
65
+ path = options.path
66
+ else
67
+ path = class_path.join("/")
68
+ end
69
+ path.blank? ? "application" : path
70
+ end
71
+
72
+ def generate_partial(partial_name)
73
+ template filename_with_extensions(partial_name), File.join("app/views", partial_path, filename_with_extensions(partial_name))
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,9 @@
1
+ <div id="flash">
2
+ <%% flash.each do |key, value| %>
3
+ <div class="wrapper">
4
+ <div title="<%%= key.to_s.humanize %>" class="<%%= key %>"></div>
5
+ <p><%%= value %></p>
6
+ </div>
7
+ </div>
8
+ <%% end %>
9
+ </div>
@@ -0,0 +1,5 @@
1
+ #flash
2
+ - flash.each do |key, value|
3
+ .wrapper
4
+ %div{ :title => key.to_s.humanize, :class => key }
5
+ %p= value
@@ -0,0 +1,5 @@
1
+ <footer id="footer">
2
+ <small class="copyright">
3
+ <%= application_title %>, Copyright &copy; <%%= Date.today.year %>
4
+ </small>
5
+ </footer>
@@ -0,0 +1,3 @@
1
+ %footer#footer
2
+ %small.copyright
3
+ <%= application_title %>, Copyright &copy; #{ Date.today.year }
@@ -0,0 +1,25 @@
1
+ <head>
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
+ <meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible'>
7
+
8
+ <title></title>
9
+ <meta content='' name='description'>
10
+ <meta content='' name='author'>
11
+
12
+ <%%# Mobile viewport optimized: h5bp.com/viewport %>
13
+ <meta content='width=device-width,initial-scale=1' name='viewport'>
14
+
15
+ <%%= render "stylesheets" %>
16
+
17
+ <%%# More ideas for your <head> here: h5bp.com/d/head-Tips %>
18
+
19
+ <%%# All JavaScript at the bottom, except this Modernizr build incl. Respond.js %>
20
+ <%%# Respond is a polyfill for min/max-width media queries. Modernizr enables HTML5 elements & feature detects; %>
21
+ <%%# for optimal performance, create your own custom Modernizr build: www.modernizr.com/download/ %>
22
+ <%%= javascript_include_tag "polyfills" %>
23
+
24
+ <%%= csrf_meta_tag %>
25
+ </head>
@@ -0,0 +1,28 @@
1
+ %head
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
+ %meta{ 'http-equiv' => 'X-UA-Compatible', :content => 'IE=edge,chrome=1' }/
7
+
8
+ %title
9
+ == #{ controller.controller_name.titleize } - #{ controller.action_name.titleize }
10
+
11
+ %meta{ :name => "description", :content => "" }/
12
+ %meta{ :name => "author", :content => "" }/
13
+
14
+ -# Mobile viewport optimized: h5bp.com/viewport
15
+ %meta{ :name => "viewport", :content => "width=device-width,initial-scale=1" }/
16
+
17
+ -# Place favicon.ico and apple-touch-icon.png in the root directory: mathiasbynens.be/notes/touch-icons
18
+
19
+ = render "stylesheets"
20
+
21
+ -# More ideas for your <head> here: h5bp.com/d/head-Tips
22
+
23
+ -# All JavaScript at the bottom, except this Modernizr build incl. Respond.js
24
+ -# Respond is a polyfill for min/max-width media queries. Modernizr enables HTML5 elements & feature detects;
25
+ -# for optimal performance, create your own custom Modernizr build: www.modernizr.com/download/
26
+ = javascript_include_tag "polyfills"
27
+
28
+ = csrf_meta_tag