diff --git a/VERSION b/VERSION index d1d899fa..ac39a106 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.5 +0.9.0 diff --git a/bin/mm-build b/bin/mm-build index 37d7978c..9494dfd4 100755 --- a/bin/mm-build +++ b/bin/mm-build @@ -30,7 +30,9 @@ module Generators if (args[0] === args[1]) args[1] = args[0].gsub("#{File.basename(Middleman::Base.views)}/", "") .gsub("#{File.basename(Middleman::Base.public)}/", "") - args[1] = args[1].gsub!(File.extname(args[1]), "") if File.basename(args[1]).split('.').length > 2 + if File.extname(args[1]) != ".js" + args[1] = args[1].gsub!(File.extname(args[1]), "") if File.basename(args[1]).split('.').length > 2 + end end super(name, *args, &block) diff --git a/lib/middleman/base.rb b/lib/middleman/base.rb index 1f839086..95cb99f6 100644 --- a/lib/middleman/base.rb +++ b/lib/middleman/base.rb @@ -32,7 +32,7 @@ module Middleman enable :minify_css enable :minify_javascript enable :cache_buster - disable :slickmap + # disable :slickmap end def template_exists?(path, renderer=nil) @@ -51,7 +51,7 @@ module Middleman # All other files disable :static - not_found do + not_found do path = request.path path << options.index_file if path.match(%r{/$}) path.gsub!(%r{^/}, '') diff --git a/lib/middleman/features/compass.rb b/lib/middleman/features/compass.rb index 42320f32..ea323296 100644 --- a/lib/middleman/features/compass.rb +++ b/lib/middleman/features/compass.rb @@ -3,11 +3,13 @@ require 'compass' class Middleman::Base configure do ::Compass.configuration do |config| + images_location = (self.environment == "build") ? self.build_dir : self.public + config.project_path = Dir.pwd config.sass_dir = File.join(File.basename(self.views), self.css_dir) - config.output_style = minify_css ? :compressed : :nested - config.css_dir = File.join(File.basename(self.public), self.css_dir) - config.images_dir = File.join(File.basename(self.public), self.images_dir) + config.output_style = self.minify_css? ? :compressed : :nested + config.css_dir = File.join(File.basename(images_location), self.css_dir) + config.images_dir = File.join(File.basename(images_location), self.images_dir) # File.expand_path(self.images_dir, self.public) if !cache_buster? diff --git a/lib/middleman/features/haml.rb b/lib/middleman/features/haml.rb index f5b303aa..0050e516 100644 --- a/lib/middleman/features/haml.rb +++ b/lib/middleman/features/haml.rb @@ -2,6 +2,7 @@ module Middleman module Haml def self.included(base) base.supported_formats << "haml" + # base.helpers Middleman::HamlHelpers end def render_path(path) @@ -20,43 +21,43 @@ module Middleman end end - # module Helpers - # def haml_partial(name, options = {}) - # item_name = name.to_sym - # counter_name = "#{name}_counter".to_sym - # if collection = options.delete(:collection) - # collection.enum_for(:each_with_index).collect do |item,index| - # haml_partial name, options.merge(:locals => {item_name => item, counter_name => index+1}) - # end.join - # elsif object = options.delete(:object) - # haml_partial name, options.merge(:locals => {item_name => object, counter_name => nil}) - # else - # haml "_#{name}".to_sym, options.merge(:layout => false) - # end - # end - # end + module HamlHelpers + def haml_partial(name, options = {}) + item_name = name.to_sym + counter_name = "#{name}_counter".to_sym + if collection = options.delete(:collection) + collection.enum_for(:each_with_index).collect do |item,index| + haml_partial name, options.merge(:locals => {item_name => item, counter_name => index+1}) + end.join + elsif object = options.delete(:object) + haml_partial name, options.merge(:locals => {item_name => object, counter_name => nil}) + else + haml "_#{name}".to_sym, options.merge(:layout => false) + end + end + end - # module Table - # include ::Haml::Filters::Base - # - # def render(text) - # output = '
' - # line_num = 0 - # text.each_line do |line| - # line_num += 1 - # next if line.strip.empty? - # output << %Q{} - # - # columns = line.split("|").map { |p| p.strip } - # columns.each_with_index do |col, i| - # output << %Q{} - # end - # - # output << "" - # end - # output + "
#{col}
" - # end - # end + module Table + include ::Haml::Filters::Base + + def render(text) + output = '
' + line_num = 0 + text.each_line do |line| + line_num += 1 + next if line.strip.empty? + output << %Q{} + + columns = line.split("|").map { |p| p.strip } + columns.each_with_index do |col, i| + output << %Q{} + end + + output << "" + end + output + "
#{col}
" + end + end module Sass def self.included(base) @@ -69,7 +70,7 @@ module Middleman static_version = options.public + request.path_info send_file(static_version) if File.exists? static_version - location_of_sass_file = defined?(MIDDLEMAN_BUILDER) ? "build" : "views" + location_of_sass_file = options.environment == "build" ? "build" : "views" css_filename = File.join(Dir.pwd, location_of_sass_file) + request.path_info sass(path.to_sym, Compass.sass_engine_options.merge({ :css_filename => css_filename })) rescue Exception => e diff --git a/lib/middleman/features/relative_assets.rb b/lib/middleman/features/relative_assets.rb index 3c471c57..63320fe6 100644 --- a/lib/middleman/features/relative_assets.rb +++ b/lib/middleman/features/relative_assets.rb @@ -1,19 +1,27 @@ - -# config.relative_assets = true - - def asset_url(path) - if path.include?("://") - path - else - request_path = request.path_info.dup - request_path << "index.html" if path.match(%r{/$}) - request_path.gsub!(%r{^/}, '') - parts = request_path.split('/') - - if parts.length > 1 - "../" * (parts.length - 1) + path - else +class Middleman::Base + if compass? + configure do + ::Compass.configuration do |config| + config.relative_assets = true + end + end + end + + helpers do + def asset_url(path) + if path.include?("://") path + else + request_path = request.path_info.dup + request_path << "index.html" if path.match(%r{/$}) + request_path.gsub!(%r{^/}, '') + parts = request_path.split('/') + + if parts.length > 1 + "../" * (parts.length - 1) + path + else + path + end end end end diff --git a/lib/middleman/helpers.rb b/lib/middleman/helpers.rb index d174193f..5bc07cbf 100644 --- a/lib/middleman/helpers.rb +++ b/lib/middleman/helpers.rb @@ -1,18 +1,5 @@ module Middleman module Helpers - def find_and_include_related_css_file - path = request.path_info.dup - path << "index.html" if path.match(%r{/$}) - path.gsub!(%r{^/}, '') - path.gsub!(File.extname(path), '') - path.gsub!('/', '-') - - sass_file = File.join(File.basename(self.class.views), "stylesheets", "#{path}.sass") - if File.exists? sass_file - stylesheet_link_tag "stylesheets/#{path}.css" - end - end - def page_classes(*additional) path = request.path_info path << "index.html" if path.match(%r{/$})