middleman 2.0.0.rc8 → 2.0.0.rc91

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. data/CHANGELOG +3 -1
  2. data/bin/mm-server +1 -1
  3. data/features/asset_host.feature +2 -0
  4. data/features/automatic_image_sizes.feature +2 -0
  5. data/features/builder.feature +4 -1
  6. data/features/cache_buster.feature +4 -0
  7. data/features/coffee-script.feature +6 -1
  8. data/features/dynamic_pages.feature +24 -0
  9. data/features/minify_css.feature +2 -0
  10. data/features/minify_javascript.feature +3 -0
  11. data/features/page_alias_and_layouts.feature +5 -0
  12. data/features/relative_assets.feature +33 -1
  13. data/features/step_definitions/asset_host_steps.rb +4 -6
  14. data/features/step_definitions/builder_steps.rb +5 -0
  15. data/features/step_definitions/middleman_steps.rb +11 -8
  16. data/features/step_definitions/page_layout_steps.rb +7 -11
  17. data/features/tiny_src.feature +2 -0
  18. data/fixtures/test-app/config.rb +10 -0
  19. data/fixtures/test-app/source/images/Child folder/regular_file(example).txt +1 -0
  20. data/fixtures/test-app/source/images/Read me (example).txt +1 -0
  21. data/fixtures/test-app/source/img/blank.gif +0 -0
  22. data/fixtures/test-app/source/javascripts/broken-coffee.js.coffee +3 -0
  23. data/fixtures/test-app/source/real.html +1 -0
  24. data/fixtures/test-app/source/real/index.html.erb +5 -0
  25. data/fixtures/test-app/source/relative_image.html.erb +1 -0
  26. data/fixtures/test-app/source/spaces in file.html.erb +1 -0
  27. data/lib/middleman/base.rb +9 -6
  28. data/lib/middleman/builder.rb +7 -4
  29. data/lib/middleman/core_extensions/compass.rb +45 -16
  30. data/lib/middleman/core_extensions/front_matter.rb +2 -1
  31. data/lib/middleman/core_extensions/routing.rb +21 -9
  32. data/lib/middleman/features/asset_host.rb +2 -2
  33. data/lib/middleman/features/blog.rb +8 -5
  34. data/lib/middleman/features/cache_buster.rb +8 -10
  35. data/lib/middleman/features/minify_css.rb +2 -2
  36. data/lib/middleman/guard.rb +8 -2
  37. data/lib/middleman/templates.rb +3 -6
  38. data/lib/middleman/templates/blog.rb +17 -0
  39. data/lib/middleman/templates/blog/config.ru +9 -0
  40. data/lib/middleman/templates/blog/config.tt +18 -0
  41. data/lib/middleman/templates/blog/source/2011/01/01/new-article.html.markdown +6 -0
  42. data/lib/middleman/templates/blog/source/archives/index.html.erb +10 -0
  43. data/lib/middleman/templates/blog/source/feed.xml.builder +23 -0
  44. data/lib/middleman/templates/blog/source/index.html.erb +9 -0
  45. data/lib/middleman/templates/blog/source/layout.erb +30 -0
  46. data/lib/middleman/templates/default.rb +6 -4
  47. data/lib/middleman/templates/default/source/index.html.erb +5 -0
  48. data/lib/middleman/templates/default/source/layout.erb +19 -0
  49. data/lib/middleman/templates/default/source/stylesheets/site.css.scss +36 -0
  50. data/lib/middleman/templates/html5.rb +6 -3
  51. data/lib/middleman/templates/html5/source/404.html +28 -18
  52. data/lib/middleman/templates/html5/source/apple-touch-icon-114x114-precomposed.png +0 -0
  53. data/lib/middleman/templates/html5/source/apple-touch-icon-57x57-precomposed.png +0 -0
  54. data/lib/middleman/templates/html5/source/apple-touch-icon-72x72-precomposed.png +0 -0
  55. data/lib/middleman/templates/html5/source/apple-touch-icon-precomposed.png +0 -0
  56. data/lib/middleman/templates/html5/source/apple-touch-icon.png +0 -0
  57. data/lib/middleman/templates/html5/source/crossdomain.xml +0 -0
  58. data/lib/middleman/templates/html5/source/css/handheld.css +0 -0
  59. data/lib/middleman/templates/html5/source/css/style.css +40 -36
  60. data/lib/middleman/templates/html5/source/favicon.ico +0 -0
  61. data/lib/middleman/templates/html5/source/humans.txt +0 -0
  62. data/lib/middleman/templates/html5/source/{images → img}/.gitignore +0 -0
  63. data/lib/middleman/templates/html5/source/index.html +26 -27
  64. data/lib/middleman/templates/html5/source/js/libs/dd_belatedpng.js +0 -0
  65. data/lib/middleman/templates/html5/source/js/libs/{jquery-1.5.0.js → jquery-1.5.1.js} +549 -409
  66. data/lib/middleman/templates/html5/source/js/libs/jquery-1.5.1.min.js +16 -0
  67. data/lib/middleman/templates/html5/source/js/libs/modernizr-1.7.min.js +2 -0
  68. data/lib/middleman/templates/html5/source/js/mylibs/.gitignore +0 -0
  69. data/lib/middleman/templates/html5/source/js/plugins.js +3 -1
  70. data/lib/middleman/templates/html5/source/js/script.js +0 -0
  71. data/lib/middleman/templates/html5/source/robots.txt +0 -0
  72. data/lib/middleman/templates/html5/source/test/index.html +31 -0
  73. data/lib/middleman/templates/html5/source/test/qunit/qunit.css +148 -0
  74. data/lib/middleman/templates/html5/source/test/qunit/qunit.js +1265 -0
  75. data/lib/middleman/templates/html5/source/test/tests.js +27 -0
  76. data/lib/middleman/templates/{default → shared}/config.ru +0 -0
  77. data/lib/middleman/templates/{default → shared}/config.tt +36 -8
  78. data/lib/middleman/version.rb +1 -1
  79. data/middleman.gemspec +6 -6
  80. metadata +188 -35
  81. data/.document +0 -5
  82. data/.gitmodules +0 -0
  83. data/lib/middleman/templates/compass.rb +0 -18
  84. data/lib/middleman/templates/default/source/index.html.haml +0 -4
  85. data/lib/middleman/templates/default/source/layout.haml +0 -21
  86. data/lib/middleman/templates/default/source/stylesheets/site.css.sass +0 -34
  87. data/lib/middleman/templates/html5/config.ru +0 -4
  88. data/lib/middleman/templates/html5/config.tt +0 -53
  89. data/lib/middleman/templates/html5/source/js/libs/jquery-1.5.0.min.js +0 -16
  90. data/lib/middleman/templates/html5/source/js/libs/modernizr-1.6.min.js +0 -30
  91. data/lib/middleman/templates/xhtml.rb +0 -16
  92. data/lib/middleman/templates/xhtml/config.ru +0 -4
  93. data/lib/middleman/templates/xhtml/config.tt +0 -68
  94. data/lib/middleman/templates/xhtml/source/index.html.haml +0 -4
  95. data/lib/middleman/templates/xhtml/source/layout.haml +0 -13
  96. data/lib/middleman/templates/xhtml/source/stylesheets/site.css.sass +0 -34
@@ -12,31 +12,60 @@ module Middleman::CoreExtensions::Compass
12
12
  end
13
13
 
14
14
  app.after_feature_init do
15
- views_root = File.basename(app.views)
15
+ # Support a stand-alone compass config file
16
+ # Many options are overwritten by Middleman, but the config is a good
17
+ # place to add:
18
+ # * output_style
19
+ # * disable_warnings
20
+ # * sass_options
21
+ # * line_comments
22
+ # * sprite_engine
23
+ # * chunky_png_options
24
+ compass_config_file = File.join(app.root, "compass.config")
25
+ if File.exists?(compass_config_file)
26
+ ::Compass.add_project_configuration(compass_config_file)
27
+ end
28
+
16
29
  ::Compass.configuration do |config|
17
- # config.cache = false # For sassc files
18
- config.cache_path = File.join(app.root, ".sass-cache")
19
30
  config.project_path = app.root
31
+ config.environment = :development
32
+ config.cache_path = File.join(app.root, ".sass-cache")
33
+
34
+ views_root = File.basename(app.views)
20
35
  config.sass_dir = File.join(views_root, app.css_dir)
21
- config.output_style = :nested
22
- config.fonts_dir = File.join(views_root, app.fonts_dir)
23
36
  config.css_dir = File.join(views_root, app.css_dir)
24
- config.images_dir = File.join(views_root, app.images_dir)
25
- config.http_images_path = app.http_images_path rescue File.join(app.http_prefix || "/", app.images_dir)
26
- config.http_stylesheets_path = app.http_css_path rescue File.join(app.http_prefix || "/", app.css_dir)
37
+ config.javascripts_dir = File.join(views_root, app.js_dir)
38
+ config.fonts_dir = File.join(views_root, app.fonts_dir)
39
+ config.images_dir = File.join(views_root, app.images_dir)
40
+
41
+ if app.respond_to? :http_images_path
42
+ config.http_images_path = app.http_images_path
43
+ end
44
+
45
+ if app.respond_to? :http_css_path
46
+ config.http_stylesheets_path = app.http_css_path
47
+ end
48
+
49
+ if app.respond_to? :http_js_path
50
+ config.http_javascripts_path = app.http_js_path
51
+ end
52
+
27
53
  config.asset_cache_buster :none
54
+ config.output_style = :nested
28
55
 
29
56
  config.add_import_path(config.sass_dir)
30
57
  end
31
58
 
32
59
  # Required for relative paths
33
60
  configure :build do
34
- build_root = File.basename(self.build_dir)
35
- ::Compass.configuration do |config|
36
- config.css_dir = File.join(build_root, self.css_dir)
37
- config.images_dir = File.join(build_root, self.images_dir)
38
- end
39
- end
61
+ ::Compass.configuration do |config|
62
+ config.environment = :production
63
+
64
+ build_root = File.basename(self.build_dir)
65
+ config.css_dir = File.join(build_root, self.css_dir)
66
+ config.images_dir = File.join(build_root, self.images_dir)
67
+ end
68
+ end
40
69
 
41
70
  app.execute_after_compass_init!
42
71
 
@@ -48,14 +77,14 @@ module Middleman::CoreExtensions::Compass
48
77
 
49
78
  module ClassMethods
50
79
  # Add a block/proc to be run after features have been setup
51
- def after_compass_init(&block)
80
+ def compass_config(&block)
52
81
  @run_after_compass ||= []
53
82
  @run_after_compass << block
54
83
  end
55
84
 
56
85
  def execute_after_compass_init!
57
86
  @run_after_compass ||= []
58
- @run_after_compass.each { |block| class_eval(&block) }
87
+ @run_after_compass.each { |block| block.call(::Compass.configuration) }
59
88
  end
60
89
  end
61
90
  end
@@ -24,7 +24,8 @@ module Middleman::CoreExtensions::FrontMatter
24
24
 
25
25
  app.after_feature_init do
26
26
  app.before_processing do
27
- result = resolve_template(request.path_info, :raise_exceptions => false)
27
+ request_path = request.path_info.gsub("%20", " ")
28
+ result = resolve_template(request_path, :raise_exceptions => false)
28
29
 
29
30
  if result && Tilt.mappings.has_key?(result[1].to_s)
30
31
  extensionless_path, template_engine = result
@@ -3,6 +3,8 @@ module Middleman::CoreExtensions::Routing
3
3
  def registered(app)
4
4
  app.extend ClassMethods
5
5
 
6
+ app.set :proxied_paths, {}
7
+
6
8
  # Normalize the path and add index if we're looking at a directory
7
9
  app.before_processing do
8
10
  request.path_info = self.class.path_to_index(request.path)
@@ -35,23 +37,33 @@ module Middleman::CoreExtensions::Routing
35
37
  set :layout, old_layout
36
38
  end
37
39
 
38
- # The page method allows the layout to be set on a specific path
39
- # page "/about.html", :layout => false
40
- # page "/", :layout => :homepage_layout
41
- def page(url, options={}, &block)
40
+ def paths_for_url(url)
42
41
  url = url.gsub(%r{#{settings.index_file}$}, "")
43
42
  url = url.gsub(%r{(\/)$}, "") if url.length > 1
44
43
 
45
44
  paths = [url]
46
45
  paths << "#{url}/" if url.length > 1 && url.split("/").last.split('.').length <= 1
47
46
  paths << "/#{path_to_index(url)}"
48
-
49
- options[:layout] = settings.layout if options[:layout].nil?
50
-
47
+ paths
48
+ end
49
+
50
+ # The page method allows the layout to be set on a specific path
51
+ # page "/about.html", :layout => false
52
+ # page "/", :layout => :homepage_layout
53
+ def page(url, options={}, &block)
51
54
  has_block = block_given?
52
-
53
- paths.each do |p|
55
+ options[:layout] = settings.layout if options[:layout].nil?
56
+
57
+ if options.has_key?(:proxy)
58
+ settings.proxied_paths[url] = options[:proxy]
59
+ end
60
+
61
+ paths_for_url(url).each do |p|
54
62
  get(p) do
63
+ if settings.proxied_paths.has_key?(url)
64
+ request.path_info = settings.proxied_paths[url]
65
+ end
66
+
55
67
  instance_eval(&block) if has_block
56
68
  process_request(options)
57
69
  end
@@ -1,9 +1,9 @@
1
1
  module Middleman::Features::AssetHost
2
2
  class << self
3
3
  def registered(app)
4
- app.after_compass_init do
4
+ app.compass_config do |config|
5
5
  if app.asset_host.is_a?(Proc)
6
- ::Compass.configuration.asset_host(&app.asset_host)
6
+ config.asset_host(&app.asset_host)
7
7
  end
8
8
  end
9
9
 
@@ -41,16 +41,19 @@ module Middleman
41
41
  app.set :blog_article_template, "article_template"
42
42
  end
43
43
 
44
- $stderr.puts "== Blog: #{app.settings.blog_permalink}"
44
+ if !app.build?
45
+ $stderr.puts "== Blog: #{app.settings.blog_permalink}"
46
+ end
45
47
 
46
- app.get(app.settings.blog_permalink) do
48
+ app.get("/#{app.blog_permalink}") do
49
+ $stderr.puts "*" * 500
47
50
  process_request({
48
- :layout => settings.blog_layout,
49
- :layout_engine => settings.blog_layout_engine
51
+ :layout => app.blog_layout,
52
+ :layout_engine => app.blog_layout_engine
50
53
  })
51
54
 
52
55
  # No need for separator on permalink page
53
- body body.gsub!(settings.blog_summary_separator, "")
56
+ body body.gsub!(app.blog_summary_separator, "")
54
57
  end
55
58
  end
56
59
 
@@ -25,16 +25,14 @@ module Middleman::Features::CacheBuster
25
25
  end
26
26
  end
27
27
 
28
- app.after_compass_init do
29
- ::Compass.configuration do |config|
30
- config.asset_cache_buster do |path, real_path|
31
- real_path = real_path.path if real_path.is_a? File
32
- real_path = real_path.gsub(File.join(app.root, app.build_dir), app.views)
33
- if File.readable?(real_path)
34
- File.mtime(real_path).strftime("%s")
35
- else
36
- $stderr.puts "WARNING: '#{File.basename(path)}' was not found (or cannot be read) in #{File.dirname(real_path)}"
37
- end
28
+ app.compass_config do |config|
29
+ config.asset_cache_buster do |path, real_path|
30
+ real_path = real_path.path if real_path.is_a? File
31
+ real_path = real_path.gsub(File.join(app.root, app.build_dir), app.views)
32
+ if File.readable?(real_path)
33
+ File.mtime(real_path).strftime("%s")
34
+ else
35
+ $stderr.puts "WARNING: '#{File.basename(path)}' was not found (or cannot be read) in #{File.dirname(real_path)}"
38
36
  end
39
37
  end
40
38
  end
@@ -1,8 +1,8 @@
1
1
  module Middleman::Features::MinifyCss
2
2
  class << self
3
3
  def registered(app)
4
- app.after_compass_init do
5
- ::Compass.configuration.output_style = :compressed
4
+ app.compass_config do |config|
5
+ config.output_style = :compressed
6
6
  end
7
7
  end
8
8
  alias :included :registered
@@ -1,6 +1,7 @@
1
1
  require "guard"
2
2
  require "guard/guard"
3
3
  require "guard/livereload"
4
+ require "webrick"
4
5
 
5
6
  module Middleman::Guard
6
7
  def self.start(options={}, livereload={})
@@ -53,12 +54,17 @@ module Guard
53
54
 
54
55
  private
55
56
  def server_start
56
- puts "== The Middleman is standing watch on port #{@options[:port]}"
57
- @server_options = { :Port => @options[:port], :AccessLog => [] }
57
+ @server_options = {
58
+ :Port => @options[:port],
59
+ :Logger => ::WEBrick::Log.new('/dev/null'),
60
+ :AccessLog => ::WEBrick::Log.new('/dev/null')
61
+ }
58
62
  @server_job = fork do
59
63
  @server_options[:app] = ::Middleman.server.new
60
64
  ::Rack::Server.new(@server_options).start
61
65
  end
66
+
67
+ puts "== The Middleman is standing watch on port #{@options[:port]}"
62
68
  end
63
69
 
64
70
  def server_stop
@@ -29,14 +29,11 @@ end
29
29
  # Default template
30
30
  require "middleman/templates/default"
31
31
 
32
- # XHMTL template
33
- require "middleman/templates/xhtml"
32
+ # Blog template
33
+ require "middleman/templates/blog"
34
34
 
35
35
  # HTML5 template
36
36
  require "middleman/templates/html5"
37
37
 
38
38
  # Local templates
39
- require "middleman/templates/local"
40
-
41
- # Compass templates
42
- # require "middleman/templates/compass"
39
+ require "middleman/templates/local"
@@ -0,0 +1,17 @@
1
+ class Middleman::Templates::Blog < Middleman::Templates::Base
2
+ def self.source_root
3
+ File.dirname(__FILE__)
4
+ end
5
+
6
+ def build_scaffold
7
+ template "blog/config.tt", File.join(location, "config.rb")
8
+ template "blog/config.ru", File.join(location, "config.ru")
9
+ directory "blog/source", File.join(location, "source")
10
+
11
+ empty_directory File.join(location, "source", options[:css_dir])
12
+ empty_directory File.join(location, "source", options[:js_dir])
13
+ empty_directory File.join(location, "source", options[:images_dir])
14
+ end
15
+ end
16
+
17
+ Middleman::Templates.register(:blog, Middleman::Templates::Blog)
@@ -0,0 +1,9 @@
1
+ # Rack config
2
+
3
+ # Look for index files in folders like Apache
4
+ require "rack/contrib/try_static"
5
+ use Rack::TryStatic, :root => "build", :urls => %w[/], :try => ['.html', 'index.html', '/index.html']
6
+
7
+ # Cache static assets
8
+ require "rack/contrib/static_cache"
9
+ use Rack::StaticCache, :urls => ['/'], :root => 'build'
@@ -0,0 +1,18 @@
1
+ activate :blog
2
+ # set :blog_permalink, ":year/:month/:day/:title.html"
3
+ # set :blog_summary_separator, /READMORE/
4
+ # set :blog_summary_length, 500
5
+
6
+ page "/feed.xml", :layout => false
7
+
8
+ # Build-specific configuration
9
+ configure :build do
10
+ # For example, change the Compass output style for deployment
11
+ # activate :minify_css
12
+
13
+ # Minify Javascript on build
14
+ # activate :minify_javascript
15
+
16
+ # Enable cache buster
17
+ # activate :cache_buster
18
+ end
@@ -0,0 +1,6 @@
1
+ ---
2
+ title: "New Article title"
3
+ date: 01/01/2011
4
+ ---
5
+
6
+ Content of my article
@@ -0,0 +1,10 @@
1
+ <h1>Archive: <%# @path %></h1>
2
+ <ul class="archives">
3
+ <% for entry in data.blog.articles %>
4
+ <li>
5
+ <a href="<%= entry.url %>"><%= entry.title %></a>
6
+ <span><%= entry.date.strftime('%b %e') %></span>
7
+ </li>
8
+ <% end %>
9
+ </ul>
10
+
@@ -0,0 +1,23 @@
1
+ xml.instruct!
2
+ xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
3
+ xml.title "Blog Name"
4
+ xml.subtitle "Blog subtitle"
5
+ xml.id "http://blog.url.com/"
6
+ xml.link "href" => "http://blog.url.com/"
7
+ xml.link "href" => "http://blog.url.com/feed.xml", "rel" => "self"
8
+ xml.updated data.blog.articles.first.date.to_time.iso8601
9
+ xml.author { xml.name "Blog Author" }
10
+
11
+ data.blog.articles.each do |article|
12
+ xml.entry do
13
+ xml.title article.title
14
+ xml.link "rel" => "alternate", "href" => article.url
15
+ xml.id article.url
16
+ xml.published article.date.to_time.iso8601
17
+ xml.updated article.date.to_time.iso8601
18
+ xml.author { xml.name "Article Author" }
19
+ xml.summary article.summary, "type" => "html"
20
+ xml.content article.body, "type" => "html"
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,9 @@
1
+ <% data.blog.articles[0...5].each_with_index do |article, i| %>
2
+ <article class="<%= (i == 0) ? 'first' : '' %>">
3
+ <h1><a href="<%= article.url %>"><%= article.title %></a> <span><%= article.date.strftime('%b %e %Y') %></span></h1>
4
+
5
+ <%= article.summary %>
6
+
7
+ <div class="more"><a href="<%= article.url %>">read on &raquo;</a></div>
8
+ </article>
9
+ <% end %>
@@ -0,0 +1,30 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta http-equiv='X-UA-Compatible' content='IE=edge;chrome=1' />
6
+ </head>
7
+ <body>
8
+
9
+ <div id="main" role="main">
10
+ <% if is_blog_article? %>
11
+ <% content_for :blog_article, yield %>
12
+ <%= partial settings.blog_article_template %>
13
+ <% else %>
14
+ <%= yield %>
15
+ <% end %>
16
+ </div>
17
+
18
+ <aside>
19
+ <h2>
20
+ Recent Articles
21
+ <a href="/archives">Archive</a>
22
+ </h2>
23
+ <ol>
24
+ <% data.blog.articles[0...10].each do |article| %>
25
+ <li><a href="<%= article.url %>"><%= article.title %></a> <span><%= article.date.strftime('%b %e') %></span></li>
26
+ <% end %>
27
+ </li>
28
+ </aside>
29
+ </body>
30
+ </html>
@@ -1,13 +1,15 @@
1
1
  class Middleman::Templates::Default < Middleman::Templates::Base
2
2
  def self.source_root
3
- File.join(File.dirname(__FILE__), 'default')
3
+ File.dirname(__FILE__)
4
4
  end
5
5
 
6
6
  def build_scaffold
7
- template "config.tt", File.join(location, "config.rb")
8
- template "config.ru", File.join(location, "config.ru")
9
- directory "source", File.join(location, "source")
7
+ template "shared/config.tt", File.join(location, "config.rb")
8
+ template "shared/config.ru", File.join(location, "config.ru")
9
+ copy_file "default/source/index.html.erb", File.join(location, "source/index.html.erb")
10
+ copy_file "default/source/layout.erb", File.join(location, "source/layout.erb")
10
11
  empty_directory File.join(location, "source", options[:css_dir])
12
+ copy_file "default/source/stylesheets/site.css.scss", File.join(location, "source", options[:css_dir], "site.css.scss")
11
13
  empty_directory File.join(location, "source", options[:js_dir])
12
14
  empty_directory File.join(location, "source", options[:images_dir])
13
15
  end
@@ -0,0 +1,5 @@
1
+ <% content_for :head do %>
2
+ <title>The Middleman!</title>
3
+ <% end%>
4
+
5
+ <h1>The Middleman is watching.</h1>