middleman 0.99.1.pre → 0.99.2.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. data/Rakefile +9 -17
  2. data/VERSION +1 -1
  3. data/features/builder.feature +16 -0
  4. data/features/coffee-script.feature +7 -0
  5. data/features/helpers_auto_stylesheet_link_tag.feature +17 -0
  6. data/features/helpers_page_classes.feature +17 -0
  7. data/features/less-css.feature +7 -0
  8. data/features/padrino_helpers.feature +10 -0
  9. data/features/scss-support.feature +7 -0
  10. data/features/step_definitions/asset_host_steps.rb +1 -1
  11. data/features/step_definitions/builder_steps.rb +45 -0
  12. data/features/step_definitions/env.rb +1 -1
  13. data/features/step_definitions/generator_steps.rb +9 -3
  14. data/features/step_definitions/middleman_steps.rb +8 -6
  15. data/features/step_definitions/page_layout_steps.rb +2 -2
  16. data/features/{asset_host.feature → w_asset_host.feature} +0 -0
  17. data/features/{automatic_image_sizes.feature → x_automatic_image_sizes.feature} +0 -0
  18. data/features/{cache_buster.feature → y_cache_buster.feature} +0 -0
  19. data/features/{relative_assets.feature → z_relative_assets.feature} +0 -0
  20. data/{spec/fixtures/sample → fixtures/test-app}/config.rb +0 -0
  21. data/{spec/fixtures/sample → fixtures/test-app}/public/images/blank.gif +0 -0
  22. data/{spec/fixtures/sample → fixtures/test-app}/public/static.html +0 -0
  23. data/{spec/fixtures/sample → fixtures/test-app}/public/stylesheets/auto-css.css +0 -0
  24. data/{spec/fixtures/sample → fixtures/test-app}/public/stylesheets/static.css +0 -0
  25. data/{spec/fixtures/sample → fixtures/test-app}/public/stylesheets/sub1/auto-css.css +0 -0
  26. data/{spec/fixtures/sample → fixtures/test-app}/public/stylesheets/sub1/sub2/auto-css.css +0 -0
  27. data/{spec/fixtures/sample → fixtures/test-app}/views/_partial.haml +0 -0
  28. data/{spec/fixtures/sample → fixtures/test-app}/views/asset_host.html.haml +0 -0
  29. data/{spec/fixtures/sample → fixtures/test-app}/views/auto-css.html.haml +0 -0
  30. data/{spec/fixtures/sample → fixtures/test-app}/views/auto-image-sizes.html.haml +0 -0
  31. data/{spec/fixtures/sample → fixtures/test-app}/views/cache-buster.html.haml +0 -0
  32. data/{spec/fixtures/sample → fixtures/test-app}/views/custom-layout.html.haml +0 -0
  33. data/{spec/fixtures/sample → fixtures/test-app}/views/index.html.haml +0 -0
  34. data/{spec/fixtures/sample → fixtures/test-app}/views/inline-css.html.haml +0 -0
  35. data/{spec/fixtures/sample → fixtures/test-app}/views/inline-js.html.haml +0 -0
  36. data/fixtures/test-app/views/javascripts/coffee_test.js.coffee +3 -0
  37. data/{spec/fixtures/sample → fixtures/test-app}/views/layout.haml +0 -0
  38. data/{spec/fixtures/sample/views → fixtures/test-app/views/layouts}/custom.haml +0 -0
  39. data/fixtures/test-app/views/padrino_test.html.haml +5 -0
  40. data/{spec/fixtures/sample → fixtures/test-app}/views/page-classes.html.haml +0 -0
  41. data/{spec/fixtures/sample → fixtures/test-app}/views/services/index.html.haml +0 -0
  42. data/{spec/fixtures/sample → fixtures/test-app}/views/stylesheets/asset_host.css.sass +0 -0
  43. data/{spec/fixtures/sample → fixtures/test-app}/views/stylesheets/relative_assets.css.sass +0 -0
  44. data/{spec/fixtures/sample → fixtures/test-app}/views/stylesheets/site.css.sass +0 -0
  45. data/{spec/fixtures/sample → fixtures/test-app}/views/stylesheets/site_scss.css.scss +0 -0
  46. data/{spec/fixtures/sample → fixtures/test-app}/views/stylesheets/test_less.css.less +0 -0
  47. data/lib/middleman.rb +9 -1
  48. data/lib/middleman/features.rb +29 -36
  49. data/lib/middleman/features/asset_host.rb +16 -15
  50. data/lib/middleman/features/automatic_image_sizes.rb +26 -24
  51. data/lib/middleman/features/cache_buster.rb +34 -33
  52. data/lib/middleman/features/default_helpers.rb +26 -33
  53. data/lib/middleman/features/livereload.rb +1 -1
  54. data/lib/middleman/features/minify_css.rb +8 -7
  55. data/lib/middleman/features/minify_javascript.rb +11 -10
  56. data/lib/middleman/features/relative_assets.rb +30 -29
  57. data/lib/middleman/features/slickmap.rb +43 -42
  58. data/lib/middleman/features/smush_pngs.rb +29 -29
  59. data/lib/middleman/features/ugly_haml.rb +7 -6
  60. data/lib/middleman/renderers/{coffee.rb → coffee_script.rb} +11 -8
  61. data/lib/middleman/renderers/haml.rb +28 -33
  62. data/lib/middleman/renderers/sass.rb +30 -28
  63. data/lib/middleman/server.rb +44 -49
  64. data/lib/middleman/template/config.rbt +6 -6
  65. data/middleman.gemspec +49 -50
  66. metadata +79 -75
  67. data/lib/middleman/renderers.rb +0 -26
  68. data/spec/builder_spec.rb +0 -62
  69. data/spec/fixtures/sample/views/maruku.html.maruku +0 -1
  70. data/spec/helpers_spec.rb +0 -43
  71. data/spec/spec_helper.rb +0 -8
data/Rakefile CHANGED
@@ -1,24 +1,24 @@
1
1
  require 'lib/middleman'
2
2
  require 'rake'
3
- require 'spec/rake/spectask'
4
3
  require 'cucumber/rake/task'
5
4
 
6
5
  begin
7
6
  require 'jeweler'
8
7
  Jeweler::Tasks.new do |gem|
9
- gem.name = "middleman"
10
- gem.summary = %Q{A static site generator utilizing Haml, Sass and providing YUI compression and cache busting}
11
- gem.email = "tdreyno@gmail.com"
12
- gem.homepage = "http://wiki.github.com/tdreyno/middleman"
13
- gem.authors = ["Thomas Reynolds"]
8
+ gem.name = "middleman"
9
+ gem.summary = %Q{A static site generator utilizing Haml, Sass and providing YUI compression and cache busting}
10
+ gem.email = "tdreyno@gmail.com"
11
+ gem.homepage = "http://wiki.github.com/tdreyno/middleman"
12
+ gem.authors = ["Thomas Reynolds"]
14
13
  gem.rubyforge_project = "middleman"
15
- gem.executables = %w(mm-init mm-build mm-server)
14
+ gem.executables = %w(mm-init mm-build mm-server)
16
15
  gem.add_dependency("rack", "~>1.0")
17
16
  gem.add_dependency("thin", "~>1.2.0")
18
17
  gem.add_dependency("shotgun", "~>0.8.0")
19
18
  gem.add_dependency("templater", "~>1.0.0")
20
19
  gem.add_dependency("sinatra", "~>1.0")
21
- gem.add_dependency("sinatra-content-for", "~>0.2.0")
20
+ gem.add_dependency("padrino-core", "~>0.9.0")
21
+ gem.add_dependency("padrino-helpers", "~>0.9.0")
22
22
  gem.add_dependency("rack-test", "~>0.5.0")
23
23
  gem.add_dependency("yui-compressor", "~>0.9.0")
24
24
  gem.add_dependency("haml", "~>3.0")
@@ -28,7 +28,6 @@ begin
28
28
  gem.add_dependency("compass-slickmap", "~>0.4.0")
29
29
  # gem.add_dependency("livereload", "~>1.4.0")
30
30
 
31
- gem.add_development_dependency("rspec")
32
31
  gem.add_development_dependency("cucumber")
33
32
  gem.add_development_dependency("jeweler")
34
33
  end
@@ -38,15 +37,8 @@ rescue LoadError
38
37
  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
39
38
  end
40
39
 
41
- Spec::Rake::SpecTask.new(:spec) do |spec|
42
- spec.libs << 'lib' << 'spec'
43
- spec.spec_files = FileList['spec/**/*_spec.rb']
44
- end
45
-
46
40
  Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
47
41
  t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
48
42
  end
49
43
 
50
- task :spec => :check_dependencies
51
-
52
- task :default => [:cucumber, :spec]
44
+ task :default => :cucumber
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.99.1.pre
1
+ 0.99.2.pre
@@ -0,0 +1,16 @@
1
+ Feature: Builder
2
+ In order to output static html and css for delivery
3
+
4
+ Scenario: Checking built folder for content
5
+ Given a built test app
6
+ Then "index.html" should exist and include "Comment in layout"
7
+ Then "javascripts/coffee_test.js" should exist and include "Array.prototype.slice"
8
+ Then "index.html" should exist and include "<h1>Welcome</h1>"
9
+ Then "static.html" should exist and include "Static, no code!"
10
+ Then "services/index.html" should exist and include "Services"
11
+ Then "stylesheets/site.css" should exist and include "html, body, div, span"
12
+ Then "stylesheets/site_scss.css" should exist and include "html, body, div, span"
13
+ Then "stylesheets/test_less.css" should exist and include "666"
14
+ Then "stylesheets/static.css" should exist and include "body"
15
+ Then "_partial.html" should not exist
16
+ And cleanup built test app
@@ -0,0 +1,7 @@
1
+ Feature: Support coffee-script
2
+ In order to offer an alternative when writing Javascript
3
+
4
+ Scenario: Rendering coffee script
5
+ Given the Server is running
6
+ When I go to "/javascripts/coffee_test.js"
7
+ Then I should see "Array.prototype.slice"
@@ -0,0 +1,17 @@
1
+ Feature: Built-in auto_stylesheet_link_tag view helper
2
+ In order to simplify including css files
3
+
4
+ Scenario: Viewing the root path
5
+ Given the Server is running
6
+ When I go to "/auto-css.html"
7
+ Then I should see "stylesheets/auto-css.css"
8
+
9
+ Scenario: Viewing a tier-1 path
10
+ Given the Server is running
11
+ When I go to "/sub1/auto-css.html"
12
+ Then I should see "stylesheets/sub1/auto-css.css"
13
+
14
+ Scenario: Viewing a tier-2 path
15
+ Given the Server is running
16
+ When I go to "/sub1/sub2/auto-css.html"
17
+ Then I should see "stylesheets/sub1/sub2/auto-css.css"
@@ -0,0 +1,17 @@
1
+ Feature: Built-in page_classes view helper
2
+ In order to generate body classes for views
3
+
4
+ Scenario: Viewing the root path
5
+ Given the Server is running
6
+ When I go to "/page-class.html"
7
+ Then I should see "page-class"
8
+
9
+ Scenario: Viewing a tier-1 path
10
+ Given the Server is running
11
+ When I go to "/sub1/page-class.html"
12
+ Then I should see "sub1 sub1_page-class"
13
+
14
+ Scenario: Viewing a tier-2 path
15
+ Given the Server is running
16
+ When I go to "/sub1/sub2/page-class.html"
17
+ Then I should see "sub1 sub1_sub2 sub1_sub2_page-class"
@@ -0,0 +1,7 @@
1
+ Feature: Support Less CSS
2
+ In order to offer an alternative when writing CSS
3
+
4
+ Scenario: Rendering Less
5
+ Given the Server is running
6
+ When I go to "/stylesheets/test_less.css"
7
+ Then I should see "666"
@@ -0,0 +1,10 @@
1
+ Feature: Built-in macro view helpers
2
+ In order to simplify generating HTML
3
+
4
+ Scenario: Using the link_to helper
5
+ Given the Server is running
6
+ When I go to "/padrino_test.html"
7
+ And I should see 'href="test2.com"'
8
+ And I should see 'src="/images/test2.png"'
9
+ Then I should see 'src="/javascripts/test1.js"'
10
+ Then I should see 'href="/stylesheets/test1.css"'
@@ -0,0 +1,7 @@
1
+ Feature: Support SCSS Syntax
2
+ In order to offer an alternative when writing Sass
3
+
4
+ Scenario: Rendering scss
5
+ Given the Server is running
6
+ When I go to "/stylesheets/site_scss.css"
7
+ Then I should see "html"
@@ -1,5 +1,5 @@
1
1
  Given /^I am using an asset host$/ do
2
- Middleman::Server.enable :asset_host
2
+ Middleman::Server.activate :asset_host
3
3
  Middleman::Server.set :asset_host do |asset|
4
4
  "http://assets%d.example.com" % (asset.hash % 4)
5
5
  end
@@ -0,0 +1,45 @@
1
+ require 'fileutils'
2
+
3
+ Given /^a built test app$/ do
4
+ target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app")
5
+ build_cmd = File.expand_path(File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "bin", "mm-build"))
6
+ `cd #{target} && MM_DIR="#{target}" #{build_cmd}`
7
+ end
8
+
9
+ Given /^cleanup built test app$/ do
10
+ target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app", "build")
11
+ FileUtils.rm_rf(target)
12
+ end
13
+
14
+ Then /^"([^"]*)" should exist and include "([^"]*)"$/ do |target_file, expected|
15
+ target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app", "build", target_file)
16
+ File.exists?(target).should be_true
17
+ File.read(target).should include(expected)
18
+ end
19
+
20
+ Then /^"([^"]*)" should not exist$/ do |target_file|
21
+ target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app", "build", target_file)
22
+ File.exists?(target).should be_false
23
+ end
24
+
25
+
26
+
27
+ # require 'fileutils'
28
+ #
29
+ # describe "Builder" do
30
+ # def project_file(*parts)
31
+ # File.expand_path(File.join(File.dirname(__FILE__), "..", *parts))
32
+ # end
33
+ #
34
+ # before :all do
35
+ # @root_dir = project_file("spec", "fixtures", "sample")
36
+ # end
37
+ #
38
+ # before :each do
39
+ # build_cmd = project_file("bin", "mm-build")
40
+ # `cd #{@root_dir} && MM_DIR="#{@root_dir}" #{build_cmd}`
41
+ # end
42
+ #
43
+ # after :each do
44
+ # FileUtils.rm_rf(File.join(@root_dir, "build"))
45
+ # end
@@ -1,3 +1,3 @@
1
- ENV["MM_DIR"] = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "spec", "fixtures", "sample")
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
3
  require "rack/test"
@@ -1,7 +1,13 @@
1
1
  require 'fileutils'
2
2
 
3
+ Given /^generated directory at "([^\"]*)"$/ do |dirname|
4
+ target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", dirname)
5
+ init_cmd = File.expand_path(File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "bin", "mm-init"))
6
+ `cd #{File.dirname(target)} && #{init_cmd} #{File.basename(target)}`
7
+ end
8
+
3
9
  Then /^template files should exist at "([^\"]*)"$/ do |dirname|
4
- target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "spec", "fixtures", dirname)
10
+ target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", dirname)
5
11
  template_glob = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "lib", "middleman", "template", "*/**/*")
6
12
 
7
13
  Dir[template_glob].each do |f|
@@ -11,7 +17,7 @@ Then /^template files should exist at "([^\"]*)"$/ do |dirname|
11
17
  end
12
18
 
13
19
  Then /^empty directories should exist at "([^\"]*)"$/ do |dirname|
14
- target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "spec", "fixtures", dirname)
20
+ target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", dirname)
15
21
 
16
22
  %w(views/stylesheets public/stylesheets public/javascripts public/images).each do |d|
17
23
  File.exists?("#{target}/#{d}").should be_true
@@ -19,6 +25,6 @@ Then /^empty directories should exist at "([^\"]*)"$/ do |dirname|
19
25
  end
20
26
 
21
27
  Then /^cleanup at "([^\"]*)"$/ do |dirname|
22
- target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "spec", "fixtures", dirname)
28
+ target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", dirname)
23
29
  FileUtils.rm_rf(target)
24
30
  end
@@ -1,13 +1,12 @@
1
1
  Given /^"([^\"]*)" feature is "([^\"]*)"$/ do |feature, state|
2
- enable_or_disable = (state == "enabled") ? :enable : :disable
3
- Middleman::Server.send(enable_or_disable, feature.to_sym)
2
+ if state == "enabled"
3
+ Middleman::Server.activate(feature.to_sym)
4
+ end
4
5
  @browser = Rack::Test::Session.new(Rack::MockSession.new(Middleman::Server.new))
5
6
  end
6
7
 
7
- Given /^generated directory at "([^\"]*)"$/ do |dirname|
8
- target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "spec", "fixtures", dirname)
9
- init_cmd = File.expand_path(File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "bin", "mm-init"))
10
- `cd #{File.dirname(target)} && #{init_cmd} #{File.basename(target)}`
8
+ Given /^the Server is running$/ do
9
+ @browser = Rack::Test::Session.new(Rack::MockSession.new(Middleman::Server.new))
11
10
  end
12
11
 
13
12
  When /^I go to "([^\"]*)"$/ do |url|
@@ -17,6 +16,9 @@ end
17
16
  Then /^I should see "([^\"]*)"$/ do |expected|
18
17
  @browser.last_response.body.should include(expected)
19
18
  end
19
+ Then /^I should see '([^\']*)'$/ do |expected|
20
+ @browser.last_response.body.should include(expected)
21
+ end
20
22
 
21
23
  Then /^I should not see "([^\"]*)"$/ do |expected|
22
24
  @browser.last_response.body.should_not include(expected)
@@ -1,11 +1,11 @@
1
1
  Given /^page "([^\"]*)" has layout "([^\"]*)"$/ do |url, layout|
2
- Middleman::Server.set :root, File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "spec", "fixtures", "sample")
2
+ Middleman::Server.set :root, File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app")
3
3
  Middleman::Server.page(url, :layout => layout.to_sym)
4
4
  @browser = Rack::Test::Session.new(Rack::MockSession.new(Middleman::Server.new))
5
5
  end
6
6
 
7
7
  Given /^"([^\"]*)" with_layout block has layout "([^\"]*)"$/ do |url, layout|
8
- Middleman::Server.set :root, File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "spec", "fixtures", "sample")
8
+ Middleman::Server.set :root, File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app")
9
9
  Middleman::Server.with_layout(:layout => layout.to_sym) do
10
10
  page(url)
11
11
  end
@@ -0,0 +1,3 @@
1
+ # Splats:
2
+ race = (winner, runners...) ->
3
+ print winner, runners
@@ -0,0 +1,5 @@
1
+ = stylesheet_link_tag "test1"
2
+ = javascript_include_tag "test1"
3
+ = image_tag "test2.png", :alt => "alt"
4
+
5
+ = link_to "Has param", "test2.com", :class => "test"
data/lib/middleman.rb CHANGED
@@ -4,5 +4,13 @@ $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
4
4
  require 'rubygems'
5
5
 
6
6
  module Middleman
7
- autoload :Server, "middleman/server"
7
+ autoload :Server, "middleman/server"
8
+
9
+ module Renderers
10
+ autoload :CoffeeScript, "middleman/renderers/coffee_script"
11
+ autoload :Haml, "middleman/renderers/haml"
12
+ autoload :Sass, "middleman/renderers/sass"
13
+ end
14
+
15
+ autoload :Features, "middleman/features"
8
16
  end
@@ -1,41 +1,34 @@
1
- module Middleman
2
- module Features
3
- # Top-level method to register a new feature
4
- @@features = {}
5
- def self.register(feature_name, feature_class=nil, options={})
6
- @@features[feature_name] = feature_class
7
-
8
- # Default to disabled, unless the class asks to auto-enable
9
- activate_method = (options.has_key?(:auto_enable) && options[:auto_enable]) ? :enable : :disable
10
- Middleman::Server.send(activate_method, feature_name)
1
+ module Middleman::Features
2
+ autoload :RelativeAssets, "middleman/features/relative_assets"
3
+ autoload :AssetHost, "middleman/features/asset_host"
4
+ autoload :CacheBuster, "middleman/features/cache_buster"
5
+ autoload :DefaultHelpers, "middleman/features/default_helpers"
6
+ autoload :AutomaticImageSizes, "middleman/features/automatic_image_sizes"
7
+ autoload :UglyHaml, "middleman/features/ugly_haml"
8
+ autoload :MinifyCss, "middleman/features/minify_css"
9
+ autoload :MinifyJavascript, "middleman/features/minify_javascript"
10
+ autoload :Slickmap, "middleman/features/slickmap"
11
+ autoload :SmushPNGs, "middleman/features/smush_pngs"
12
+
13
+ class << self
14
+ def registered(app)
15
+ app.extend ClassMethods
11
16
  end
12
-
13
- # Initialize a feature
14
- def self.run(feature_name, feature_config, scope)
15
- feature_class = @@features[feature_name]
16
- feature_class.new(scope, feature_config) unless feature_class.nil?
17
+ alias :included :registered
18
+ end
19
+
20
+ module ClassMethods
21
+ def activate(feature_name)
22
+ mod_name = feature_name.to_s.camelize
23
+ if Middleman::Features.const_defined?(mod_name)
24
+ register Middleman::Features.const_get(mod_name)
25
+ end
17
26
  end
18
-
19
- # Get a list of all features
20
- def self.all
21
- @@features
27
+
28
+ def enable(feature_name)
29
+ $stderr.puts "Warning: Feature activation has been renamed from enable to activate"
30
+ activate(feature_name)
31
+ super(feature_name)
22
32
  end
23
-
24
33
  end
25
- end
26
-
27
- # livereload
28
- %w(default_helpers
29
- asset_host
30
- automatic_image_sizes
31
- cache_buster
32
- minify_css
33
- minify_javascript
34
- relative_assets
35
- slickmap
36
- smush_pngs
37
- ugly_haml).each do |feature|
38
-
39
- require File.join("middleman/features", feature)
40
-
41
34
  end