middleman 1.2.8 → 2.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/.gitignore +1 -0
  2. data/CHANGELOG +7 -0
  3. data/README.rdoc +1 -1
  4. data/bin/mm-server +15 -39
  5. data/features/coffee-script.feature +6 -1
  6. data/features/minify_javascript.feature +14 -6
  7. data/features/slim.feature +7 -0
  8. data/features/step_definitions/builder_steps.rb +1 -23
  9. data/features/step_definitions/env.rb +7 -1
  10. data/features/step_definitions/generator_steps.rb +1 -1
  11. data/features/step_definitions/middleman_steps.rb +5 -0
  12. data/fixtures/test-app/config.rb +2 -0
  13. data/fixtures/test-app/{views → source}/_partial.haml +0 -0
  14. data/fixtures/test-app/{views → source}/asset_host.html.haml +0 -0
  15. data/fixtures/test-app/{views → source}/auto-css.html.haml +0 -0
  16. data/fixtures/test-app/{views → source}/auto-image-sizes.html.haml +0 -0
  17. data/fixtures/test-app/{views → source}/cache-buster.html.haml +0 -0
  18. data/fixtures/test-app/{views → source}/custom-layout-dir/index.html.haml +0 -0
  19. data/fixtures/test-app/{views → source}/custom-layout.html.haml +0 -0
  20. data/fixtures/test-app/source/front-matter.html.erb +7 -0
  21. data/fixtures/test-app/{public → source}/images/blank.gif +0 -0
  22. data/fixtures/test-app/{views → source}/index.html.haml +0 -0
  23. data/fixtures/test-app/source/inline-coffeescript.html.haml +3 -0
  24. data/fixtures/test-app/{views → source}/inline-css.html.haml +0 -0
  25. data/fixtures/test-app/{views → source}/inline-js.html.haml +1 -1
  26. data/fixtures/test-app/{views → source}/javascripts/coffee_test.js.coffee +0 -0
  27. data/fixtures/test-app/source/javascripts/jquery.plugin.with.dots.js +1 -0
  28. data/fixtures/test-app/{views → source}/layout.haml +0 -0
  29. data/fixtures/test-app/{views → source}/layouts/custom.haml +0 -0
  30. data/fixtures/test-app/{views → source}/padrino_test.html.haml +0 -0
  31. data/fixtures/test-app/{views → source}/page-classes.html.haml +0 -0
  32. data/fixtures/test-app/{views → source}/services/index.html.haml +0 -0
  33. data/fixtures/test-app/source/slim.html.slim +7 -0
  34. data/fixtures/test-app/{public → source}/static.html +0 -0
  35. data/fixtures/test-app/{views → source}/stylesheets/asset_host.css.sass +0 -0
  36. data/fixtures/test-app/{public → source}/stylesheets/auto-css.css +0 -0
  37. data/fixtures/test-app/{views → source}/stylesheets/relative_assets.css.sass +0 -0
  38. data/fixtures/test-app/{views → source}/stylesheets/site.css.sass +0 -0
  39. data/fixtures/test-app/{views → source}/stylesheets/site_scss.css.scss +0 -0
  40. data/fixtures/test-app/{public → source}/stylesheets/static.css +0 -0
  41. data/fixtures/test-app/{public → source}/stylesheets/sub1/auto-css.css +0 -0
  42. data/fixtures/test-app/{public → source}/stylesheets/sub1/sub2/auto-css.css +0 -0
  43. data/fixtures/test-app/{views → source}/tiny_src.html.haml +0 -0
  44. data/lib/middleman.rb +1 -0
  45. data/lib/middleman/builder.rb +15 -22
  46. data/lib/middleman/features.rb +7 -1
  47. data/lib/middleman/features/automatic_image_sizes.rb +1 -1
  48. data/lib/middleman/features/blog.rb +118 -0
  49. data/lib/middleman/features/cache_buster.rb +2 -2
  50. data/lib/middleman/features/data.rb +19 -6
  51. data/lib/middleman/features/default_helpers.rb +1 -1
  52. data/lib/middleman/features/front_matter.rb +69 -0
  53. data/lib/middleman/features/live_reload.rb +8 -3
  54. data/lib/middleman/features/minify_javascript/rack.rb +27 -6
  55. data/lib/middleman/renderers/haml.rb +1 -0
  56. data/lib/middleman/renderers/sass.rb +5 -4
  57. data/lib/middleman/renderers/slim.rb +12 -0
  58. data/lib/middleman/server.rb +30 -11
  59. data/lib/middleman/templates/default.rb +4 -4
  60. data/lib/middleman/templates/default/{views → source}/index.html.haml +0 -0
  61. data/lib/middleman/templates/default/{views → source}/layout.haml +0 -0
  62. data/lib/middleman/templates/default/source/stylesheets/site.css.sass +34 -0
  63. data/lib/middleman/templates/html5.rb +2 -2
  64. data/lib/middleman/templates/html5/{public → source}/404.html +0 -0
  65. data/lib/middleman/templates/html5/{public → source}/apple-touch-icon.png +0 -0
  66. data/lib/middleman/templates/html5/{public → source}/crossdomain.xml +0 -0
  67. data/lib/middleman/templates/html5/{public → source}/css/handheld.css +0 -0
  68. data/lib/middleman/templates/html5/{public → source}/css/style.css +0 -0
  69. data/lib/middleman/templates/html5/{public → source}/favicon.ico +0 -0
  70. data/lib/middleman/templates/html5/{public → source}/humans.txt +0 -0
  71. data/lib/middleman/templates/html5/{public → source}/images/.gitignore +0 -0
  72. data/lib/middleman/templates/html5/{public → source}/index.html +0 -0
  73. data/lib/middleman/templates/html5/{public → source}/js/libs/dd_belatedpng.js +0 -0
  74. data/lib/middleman/templates/html5/{public → source}/js/libs/jquery-1.5.0.js +0 -0
  75. data/lib/middleman/templates/html5/{public → source}/js/libs/jquery-1.5.0.min.js +0 -0
  76. data/lib/middleman/templates/html5/{public → source}/js/libs/modernizr-1.6.min.js +0 -0
  77. data/lib/middleman/templates/html5/{public → source}/js/mylibs/.gitignore +0 -0
  78. data/lib/middleman/templates/html5/{public → source}/js/plugins.js +0 -0
  79. data/lib/middleman/templates/html5/{public → source}/js/script.js +0 -0
  80. data/lib/middleman/templates/html5/{public → source}/robots.txt +0 -0
  81. data/lib/middleman/templates/xhtml.rb +4 -4
  82. data/lib/middleman/templates/xhtml/{views → source}/index.html.haml +0 -0
  83. data/lib/middleman/templates/xhtml/{views → source}/layout.haml +0 -0
  84. data/lib/middleman/templates/xhtml/source/stylesheets/site.css.sass +34 -0
  85. data/lib/middleman/version.rb +1 -1
  86. data/middleman.gemspec +7 -7
  87. metadata +149 -113
  88. data/lib/middleman/templates/default/views/stylesheets/site.css.sass +0 -27
  89. data/lib/middleman/templates/xhtml/views/stylesheets/site.css.sass +0 -27
data/.gitignore CHANGED
@@ -7,3 +7,4 @@ pkg
7
7
  .tmp
8
8
  Gemfile.lock
9
9
  docs
10
+ .rvmrc
data/CHANGELOG ADDED
@@ -0,0 +1,7 @@
1
+ 2.0.0
2
+ =====
3
+
4
+ - Combine views/ and public/ into a single source/ folder.
5
+ - Support YAML front-matter
6
+ - Blog-aware
7
+ - Replaced Blueprint CSS templates with Susy
data/README.rdoc CHANGED
@@ -8,7 +8,7 @@ Everything you need to know is on the wiki: http://github.com/tdreyno/middleman/
8
8
 
9
9
  == Mailing List
10
10
 
11
- If you have questions, answers can be found on the mailing list: http://groups.google.com/group/middleman-users
11
+ If you have questions, answers can be found on community forum: https://convore.com/middleman/
12
12
 
13
13
  == Copyright
14
14
 
data/bin/mm-server CHANGED
@@ -1,22 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # Non-blocking site rebuilding
4
- trap("TSTP") do
5
- fork do
6
- require "open3"
7
- first_run = true
8
- Open3.popen3(%Q{cd "#{Dir.pwd}" && #{File.join(File.dirname(__FILE__), "mm-build")} | grep FORCED}) do |stdin, stdout, stderr|
9
- puts "\n== Building the site..."
10
- stdout.readlines.each do |l|
11
- puts "== Updated:" if first_run
12
- puts " " + l.split("[FORCED]").last.chomp
13
- first_run = false
14
- end
15
- puts "== Build complete"
16
- end
17
- end
18
- end if Signal.list.has_key? "TSTP"
19
-
20
3
  require 'optparse'
21
4
 
22
5
  # Require Middleman
@@ -25,6 +8,7 @@ require File.join(File.dirname(__FILE__), '..', 'lib', 'middleman')
25
8
  env = ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development'
26
9
  options = { :Port => 4567, :AccessLog => [] }
27
10
 
11
+ # TODO: Switch to Thor
28
12
  OptionParser.new { |opts|
29
13
  opts.banner = "Usage: mm-server [rack options]"
30
14
  opts.separator ""
@@ -51,10 +35,9 @@ ENV['RACK_ENV'] = env
51
35
  while (!@found_root && (@path_parts.length > 0))
52
36
  @current_path = File.join(*@path_parts)
53
37
 
54
- public_folder = File.join(@current_path, "public")
55
- views_folder = File.join(@current_path, "views")
38
+ source_folder = File.join(@current_path, "source")
56
39
 
57
- if File.exists?(public_folder) && File.exists?(views_folder)
40
+ if File.exists?(source_folder)
58
41
  @found_root = true
59
42
  next
60
43
  end
@@ -67,31 +50,24 @@ if !@found_root
67
50
  exit
68
51
  end
69
52
 
70
- # If the old init.rb exists, use it, but issue warning
53
+ # If the old init.rb exists, issue warning
71
54
  old_config = File.join(@current_path, "init.rb")
72
55
  if File.exists? old_config
73
56
  $stderr.puts "== Error: The init.rb file (deprecated) needs to be be renamed to config.rb"
74
57
  exit
75
58
  end
76
59
 
60
+ # If the old directories exists, use it, but issue warning
61
+ old_views = File.join(@current_path, "views")
62
+ old_public = File.join(@current_path, "public")
63
+ if File.exists?(old_views) || File.exists?(old_public)
64
+ $stderr.puts "== Error: The views and public folders are have been combined. Create a new 'source' folder, add the contents of views and public to it and then remove the empty views and public folders."
65
+ exit
66
+ end
77
67
 
78
- # require 'shotgun'
79
- # config = File.join(File.dirname(__FILE__), '..', 'lib', 'middleman', 'config.ru')
80
- # app = Shotgun.new(config, &lambda { |inner_app| Middleman::Server })
81
68
  Middleman::Server.root = @current_path
82
- app = Middleman::Server.new
69
+ options[:app] = Middleman::Server.new
70
+ # options[:server] = 'webrick'
83
71
 
84
- require 'rubygems'
85
-
86
- unless defined?(JRUBY_VERSION)
87
- require 'thin'
88
- handler = Rack::Handler::Thin
89
- else
90
- require 'kirk'
91
- require 'rack/handler/kirk'
92
- handler = Rack::Handler::Kirk
93
- end
94
-
95
- handler.run app, options do |inst|
96
- puts "== The Middleman is standing watch on port #{options[:Port]}"
97
- end
72
+ puts "== The Middleman is standing watch on port #{options[:Port]}"
73
+ Rack::Server.new(options).start
@@ -1,7 +1,12 @@
1
1
  Feature: Support coffee-script
2
2
  In order to offer an alternative when writing Javascript
3
-
3
+
4
4
  Scenario: Rendering coffee script
5
5
  Given the Server is running
6
6
  When I go to "/javascripts/coffee_test.js"
7
+ Then I should see "Array.prototype.slice"
8
+
9
+ Scenario: Rendering coffee-script with :coffeescript haml-filter
10
+ Given the Server is running
11
+ When I go to "/inline-coffeescript.html"
7
12
  Then I should see "Array.prototype.slice"
@@ -1,12 +1,20 @@
1
1
  Feature: Minify Javascript
2
2
  In order reduce bytes sent to client and appease YSlow
3
-
3
+
4
+ Background:
5
+ Given current environment is "build"
6
+
4
7
  Scenario: Rendering inline js with the feature disabled
5
8
  Given "minify_javascript" feature is "disabled"
6
9
  When I go to "/inline-js.html"
7
10
  Then I should see "10" lines
8
-
9
- # Scenario: Rendering inline js with the feature enabled
10
- # Given "minify_javascript" feature is "enabled"
11
- # When I go to "/inline-js.html"
12
- # Then I should see "1" lines
11
+
12
+ Scenario: Rendering inline js with the feature enabled
13
+ Given "minify_javascript" feature is "enabled"
14
+ When I go to "/inline-js.html"
15
+ Then I should see "5" lines
16
+
17
+ Scenario: Rendering inline js (coffeescript) with the feature enabled
18
+ Given "minify_javascript" feature is "enabled"
19
+ When I go to "/inline-coffeescript.html"
20
+ Then I should see "5" lines
@@ -0,0 +1,7 @@
1
+ Feature: Support slim templating language
2
+ In order to offer an alternative to Haml
3
+
4
+ Scenario: Rendering Slim
5
+ Given the Server is running
6
+ When I go to "/slim.html"
7
+ Then I should see "<h1>Welcome to Slim</h1>"
@@ -26,26 +26,4 @@ end
26
26
  Then /^"([^"]*)" should not exist$/ do |target_file|
27
27
  target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app", "build", target_file)
28
28
  File.exists?(target).should be_false
29
- end
30
-
31
-
32
-
33
- # require 'fileutils'
34
- #
35
- # describe "Builder" do
36
- # def project_file(*parts)
37
- # File.expand_path(File.join(File.dirname(__FILE__), "..", *parts))
38
- # end
39
- #
40
- # before :all do
41
- # @root_dir = project_file("spec", "fixtures", "sample")
42
- # end
43
- #
44
- # before :each do
45
- # build_cmd = project_file("bin", "mm-build")
46
- # `cd #{@root_dir} && MM_DIR="#{@root_dir}" #{build_cmd}`
47
- # end
48
- #
49
- # after :each do
50
- # FileUtils.rm_rf(File.join(@root_dir, "build"))
51
- # end
29
+ end
@@ -1,3 +1,9 @@
1
1
  ENV["MM_DIR"] = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app")
2
2
  require File.join(File.dirname(File.dirname(File.dirname(__FILE__))), 'lib', 'middleman')
3
- require "rack/test"
3
+ require "rack/test"
4
+
5
+ # absolute views path
6
+ # otherwise resolve_template (padrino-core) can't find templates
7
+ Before do
8
+ Middleman::Server.views = File.join(Middleman::Server.root, "source")
9
+ end
@@ -19,7 +19,7 @@ end
19
19
  Then /^empty directories should exist at "([^\"]*)"$/ do |dirname|
20
20
  target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", dirname)
21
21
 
22
- %w(views/stylesheets public/stylesheets public/javascripts public/images).each do |d|
22
+ %w(source/stylesheets source/javascripts source/images).each do |d|
23
23
  File.exists?("#{target}/#{d}").should be_true
24
24
  end
25
25
  end
@@ -2,9 +2,14 @@ Given /^"([^\"]*)" feature is "([^\"]*)"$/ do |feature, state|
2
2
  if state == "enabled"
3
3
  Middleman::Server.activate(feature.to_sym)
4
4
  end
5
+ Middleman::Server.environment = @current_env || :development
5
6
  @browser = Rack::Test::Session.new(Rack::MockSession.new(Middleman::Server.new))
6
7
  end
7
8
 
9
+ Given /^current environment is "([^\"]*)"$/ do |env|
10
+ @current_env = env.to_sym
11
+ end
12
+
8
13
  Given /^the Server is running$/ do
9
14
  @browser = Rack::Test::Session.new(Rack::MockSession.new(Middleman::Server.new))
10
15
  end
@@ -1,6 +1,8 @@
1
1
  with_layout false do
2
2
  page "/inline-css.html"
3
3
  page "/inline-js.html"
4
+ page "/inline-coffeescript.html"
5
+ page "/slim.html"
4
6
  end
5
7
 
6
8
  get "/page-class.html" do
File without changes
@@ -0,0 +1,7 @@
1
+ ---
2
+ layout: false
3
+ title: No title
4
+ ---
5
+
6
+ <%= data.page.title %>
7
+ <%= data.page.inspect %>
File without changes
@@ -0,0 +1,3 @@
1
+ :coffeescript
2
+ race = (winner, runners...) ->
3
+ print winner, runners
@@ -4,4 +4,4 @@
4
4
  should();
5
5
  all.be();
6
6
  on = { one: line };
7
- });
7
+ })();
File without changes
@@ -0,0 +1,7 @@
1
+ doctype 5
2
+ html lang='en'
3
+ head
4
+ meta charset="utf-8"
5
+
6
+ body
7
+ h1 Welcome to Slim
File without changes
data/lib/middleman.rb CHANGED
@@ -67,6 +67,7 @@ module Middleman
67
67
  module Renderers
68
68
  autoload :Haml, "middleman/renderers/haml"
69
69
  autoload :Sass, "middleman/renderers/sass"
70
+ autoload :Slim, "middleman/renderers/slim"
70
71
  end
71
72
 
72
73
  # Features API
@@ -8,7 +8,7 @@ module Middleman
8
8
  def tilt_template(source, *args, &block)
9
9
  config = args.last.is_a?(Hash) ? args.pop : {}
10
10
  destination = args.first || source
11
-
11
+
12
12
  source = File.expand_path(find_in_source_paths(source.to_s))
13
13
  context = instance_eval('binding')
14
14
 
@@ -33,6 +33,7 @@ module Middleman
33
33
  super
34
34
 
35
35
  Middleman::Server.new
36
+
36
37
  if options.has_key?("relative") && options["relative"]
37
38
  Middleman::Server.activate :relative_assets
38
39
  end
@@ -41,17 +42,12 @@ module Middleman
41
42
 
42
43
  def source_paths
43
44
  @source_paths ||= [
44
- Middleman::Server.public,
45
- Middleman::Server.views
45
+ Middleman::Server.root
46
46
  ]
47
47
  end
48
48
 
49
- def build_static_files
50
- action Directory.new(self, Middleman::Server.public, :public, Middleman::Server.build_dir, { :force => true })
51
- end
52
-
53
- def build_dynamic_files
54
- action Directory.new(self, Middleman::Server.views, :dynamic, Middleman::Server.build_dir, { :force => true })
49
+ def build_all_files
50
+ action Directory.new(self, Middleman::Server.views, Middleman::Server.build_dir, { :force => true })
55
51
  end
56
52
 
57
53
  @@hooks = {}
@@ -69,8 +65,7 @@ module Middleman
69
65
  class Directory < ::Thor::Actions::EmptyDirectory
70
66
  attr_reader :source
71
67
 
72
- def initialize(base, source, mode, destination=nil, config={}, &block)
73
- @mode = mode
68
+ def initialize(base, source, destination=nil, config={}, &block)
74
69
  @source = File.expand_path(base.find_in_source_paths(source.to_s))
75
70
  @block = block
76
71
  super(base, destination, { :recursive => true }.merge(config))
@@ -96,22 +91,20 @@ module Middleman
96
91
  end
97
92
 
98
93
  next if file_source.include?('layout')
99
- next unless file_source.split('/').select { |p| p[0,1] == '_' }.empty?
100
-
94
+
95
+ # Skip partials prefixed with an underscore
96
+ next unless file_source.gsub(Middleman::Server.root, '').split('/').select { |p| p[0,1] == '_' }.empty?
97
+
101
98
  file_extension = File.extname(file_source)
102
99
  file_destination = File.join(given_destination, file_source.gsub(source, '.'))
103
100
  file_destination.gsub!('/./', '/')
104
-
105
- handled_by_tilt = ::Tilt.mappings.keys.include?(file_extension.gsub(/^\./, ""))
106
- if handled_by_tilt || (file_extension == ".js")
107
- new_file_extension = (file_extension == ".js") ? ".js" : ""
108
- next if @mode == :dynamic && file_source.split('/').last.split('.').length < 3
109
101
 
110
- file_destination.gsub!(file_extension, new_file_extension)
111
- destination = base.tilt_template(file_source, file_destination, config, &@block)
112
- else
113
- destination = base.copy_file(file_source, file_destination, config, &@block)
102
+ handled_by_tilt = ::Tilt.mappings.has_key?(file_extension.gsub(/^\./, ""))
103
+ if handled_by_tilt
104
+ file_destination.gsub!(file_extension, "")
114
105
  end
106
+
107
+ destination = base.tilt_template(file_source, file_destination, config, &@block)
115
108
  end
116
109
  end
117
110
 
@@ -71,6 +71,12 @@ module Middleman::Features
71
71
  # to dynamic requests.
72
72
  autoload :Data, "middleman/features/data"
73
73
 
74
+ # Parse YAML metadata from templates
75
+ autoload :FrontMatter, "middleman/features/front_matter"
76
+
77
+ # Treat project as a blog
78
+ autoload :Blog, "middleman/features/blog"
79
+
74
80
  # Proxy web services requests in dev mode only
75
81
  # autoload :Proxy, "middleman/features/proxy"
76
82
 
@@ -79,7 +85,7 @@ module Middleman::Features
79
85
 
80
86
  # LiveReload will auto-reload browsers with the live reload extension installed after changes
81
87
  # Currently disabled and untested.
82
- #autoload :LiveReload, "middleman/features/live_reload"
88
+ # autoload :LiveReload, "middleman/features/live_reload"
83
89
 
84
90
  # The Feature API is itself a Feature. Mind blowing!
85
91
  class << self