diff --git a/lib/middleman.rb b/lib/middleman.rb index a121c725..3b7379b9 100755 --- a/lib/middleman.rb +++ b/lib/middleman.rb @@ -101,34 +101,28 @@ module Middleman # relative to the root of the project or use an absolute URL. autoload :RelativeAssets, "middleman/features/relative_assets" - # AssetHost allows you to setup multiple domains to host your static assets. - # Calls to asset paths in dynamic templates will then rotate through each of - # the asset servers to better spread the load. + # AssetHost allows you to setup multiple domains to host your static + # assets. Calls to asset paths in dynamic templates will then rotate + # through each of the asset servers to better spread the load. autoload :AssetHost, "middleman/features/asset_host" # CacheBuster adds a query string to assets in dynamic templates to avoid # browser caches failing to update to your new content. autoload :CacheBuster, "middleman/features/cache_buster" - # AutomaticImageSizes inspects the images used in your dynamic templates and - # automatically adds width and height attributes to their HTML elements. + # AutomaticImageSizes inspects the images used in your dynamic templates + # and automatically adds width and height attributes to their HTML + # elements. autoload :AutomaticImageSizes, "middleman/features/automatic_image_sizes" - # UglyHaml enables the non-indented output format from Haml templates. Useful - # for somewhat obfuscating the output and hiding the fact that you're using Haml. - autoload :UglyHaml, "middleman/features/ugly_haml" - # MinifyCss uses the YUI compressor to shrink CSS files autoload :MinifyCss, "middleman/features/minify_css" # MinifyJavascript uses the YUI compressor to shrink JS files autoload :MinifyJavascript, "middleman/features/minify_javascript" - # CodeRay is a syntax highlighter. - autoload :CodeRay, "middleman/features/code_ray" - - # Lorem provides a handful of helpful prototyping methods to generate words, - # paragraphs, fake images, names and email addresses. + # Lorem provides a handful of helpful prototyping methods to generate + # words, paragraphs, fake images, names and email addresses. autoload :Lorem, "middleman/features/lorem" # Treat project as a blog @@ -143,8 +137,8 @@ module Middleman # Automatically resize images for mobile devises # autoload :TinySrc, "middleman/features/tiny_src" - # LiveReload will auto-reload browsers with the live reload extension installed after changes - # Currently disabled and untested. + # LiveReload will auto-reload browsers with the live reload extension + # installed after changes. Currently disabled and untested. # autoload :LiveReload, "middleman/features/live_reload" end end diff --git a/lib/middleman/features/code_ray.rb b/lib/middleman/features/code_ray.rb deleted file mode 100644 index 0733ff4f..00000000 --- a/lib/middleman/features/code_ray.rb +++ /dev/null @@ -1,12 +0,0 @@ -module Middleman::Features::CodeRay - class << self - def registered(app) - begin - require 'haml-coderay' - rescue LoadError - puts "CodeRay not available. Install it with: gem install haml-coderay" - end - end - alias :included :registered - end -end \ No newline at end of file diff --git a/lib/middleman/features/ugly_haml.rb b/lib/middleman/features/ugly_haml.rb deleted file mode 100644 index 2771b22d..00000000 --- a/lib/middleman/features/ugly_haml.rb +++ /dev/null @@ -1,8 +0,0 @@ -module Middleman::Features::UglyHaml - class << self - def registered(app) - app.set :haml, app.settings.haml.merge({ :ugly_haml => true }) - end - alias :included :registered - end -end \ No newline at end of file diff --git a/lib/middleman/renderers/haml.rb b/lib/middleman/renderers/haml.rb index a6c10e32..73a45fb3 100755 --- a/lib/middleman/renderers/haml.rb +++ b/lib/middleman/renderers/haml.rb @@ -5,9 +5,20 @@ module Middleman::Renderers::Haml require "haml" # Coffee-script filter for Haml - require "coffee-filter" + begin + require "coffee-filter" + rescue LoadError + end + + # Code-ray Syntax highlighting + begin + require 'haml-coderay' + rescue LoadError + end app.helpers Helpers + + #app.set :haml, app.settings.haml.merge({ :ugly_haml => true }) end alias :included :registered end diff --git a/lib/middleman/renderers/sass.rb b/lib/middleman/renderers/sass.rb index 3dc8a1fd..3142338d 100644 --- a/lib/middleman/renderers/sass.rb +++ b/lib/middleman/renderers/sass.rb @@ -1,76 +1,77 @@ require "sass" require "sass/plugin" require "compass" -require "susy" -module Middleman - module Renderers - module Sass - class << self - def registered(app) - app.after_feature_init do - views_root = File.basename(app.views) - ::Compass.configuration do |config| - config.cache = false # For sassc files - config.project_path = app.root - config.sass_dir = File.join(views_root, app.css_dir) - config.output_style = :nested - config.fonts_dir = File.join(views_root, app.fonts_dir) - config.css_dir = File.join(views_root, app.css_dir) - config.images_dir = File.join(views_root, app.images_dir) - config.http_images_path = app.http_images_path rescue File.join(app.http_prefix || "/", app.images_dir) - config.http_stylesheets_path = app.http_css_path rescue File.join(app.http_prefix || "/", app.css_dir) - config.asset_cache_buster :none - - config.add_import_path(config.sass_dir) - end - - # configure :build do - # build_root = File.basename(self.build_dir) - # ::Compass.configuration do |config| - # config.css_dir = File.join(build_root, self.css_dir) - # config.images_dir = File.join(build_root, self.images_dir) - # end - # end - end - end - alias :included :registered +module Middleman::Renderers::Sass + class << self + def registered(app) + # Susy grids + begin + require "susy" + rescue LoadError end - class SassPlusCSSFilenameTemplate < ::Tilt::SassTemplate - def sass_options - return super if basename.nil? + app.after_feature_init do + views_root = File.basename(app.views) + ::Compass.configuration do |config| + config.cache = false # For sassc files + config.project_path = app.root + config.sass_dir = File.join(views_root, app.css_dir) + config.output_style = :nested + config.fonts_dir = File.join(views_root, app.fonts_dir) + config.css_dir = File.join(views_root, app.css_dir) + config.images_dir = File.join(views_root, app.images_dir) + config.http_images_path = app.http_images_path rescue File.join(app.http_prefix || "/", app.images_dir) + config.http_stylesheets_path = app.http_css_path rescue File.join(app.http_prefix || "/", app.css_dir) + config.asset_cache_buster :none - location_of_sass_file = Middleman::Server.environment == :build ? - File.join(Middleman::Server.root, Middleman::Server.build_dir) : - Middleman::Server.views - - parts = basename.split('.') - parts.pop - css_filename = File.join(location_of_sass_file, Middleman::Server.css_dir, parts.join(".")) - super.merge(::Compass.configuration.to_sass_engine_options).merge(:css_filename => css_filename) + config.add_import_path(config.sass_dir) end - def evaluate(scope, locals, &block) - begin - super - rescue Sass::SyntaxError => e - Sass::SyntaxError.exception_to_css(e, :full_exception => true) - end - end + # configure :build do + # build_root = File.basename(self.build_dir) + # ::Compass.configuration do |config| + # config.css_dir = File.join(build_root, self.css_dir) + # config.images_dir = File.join(build_root, self.images_dir) + # end + # end end - ::Tilt.register 'sass', SassPlusCSSFilenameTemplate - ::Tilt.prefer(SassPlusCSSFilenameTemplate) + end + alias :included :registered + end + + class SassPlusCSSFilenameTemplate < ::Tilt::SassTemplate + def sass_options + return super if basename.nil? - class ScssPlusCSSFilenameTemplate < SassPlusCSSFilenameTemplate - def sass_options - super.merge(:syntax => :scss) - end + location_of_sass_file = Middleman::Server.environment == :build ? + File.join(Middleman::Server.root, Middleman::Server.build_dir) : + Middleman::Server.views + + parts = basename.split('.') + parts.pop + css_filename = File.join(location_of_sass_file, Middleman::Server.css_dir, parts.join(".")) + super.merge(::Compass.configuration.to_sass_engine_options).merge(:css_filename => css_filename) + end + + def evaluate(scope, locals, &block) + begin + super + rescue Sass::SyntaxError => e + Sass::SyntaxError.exception_to_css(e, :full_exception => true) end - ::Tilt.register 'scss', ScssPlusCSSFilenameTemplate - ::Tilt.prefer(ScssPlusCSSFilenameTemplate) end end + ::Tilt.register 'sass', SassPlusCSSFilenameTemplate + ::Tilt.prefer(SassPlusCSSFilenameTemplate) + + class ScssPlusCSSFilenameTemplate < SassPlusCSSFilenameTemplate + def sass_options + super.merge(:syntax => :scss) + end + end + ::Tilt.register 'scss', ScssPlusCSSFilenameTemplate + ::Tilt.prefer(ScssPlusCSSFilenameTemplate) end # Use compass settings in Haml filters diff --git a/lib/middleman/templates/default/config.tt b/lib/middleman/templates/default/config.tt index 48506304..b1b6671f 100755 --- a/lib/middleman/templates/default/config.tt +++ b/lib/middleman/templates/default/config.tt @@ -1,7 +1,17 @@ -# CodeRay syntax highlighting in Haml -# activate :code_ray +# Susy grids in Compass +# First: gem install compass-susy-plugin +# require 'susy' -# Automatic sitemaps (gem install middleman-slickmap) +# CodeRay syntax highlighting in Haml +# First: gem install haml-coderay +# require 'haml-coderay' + +# CoffeeScript filters in Haml +# First: gem install coffee-filter +# require 'coffee-filter' + +# Automatic sitemaps +# First: gem install middleman-slickmap # require "middleman-slickmap" # activate :slickmap diff --git a/middleman.gemspec b/middleman.gemspec index a13d2b48..fa5c027c 100644 --- a/middleman.gemspec +++ b/middleman.gemspec @@ -8,8 +8,8 @@ Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.authors = ["Thomas Reynolds"] s.email = ["tdreyno@gmail.com"] - s.homepage = "http://wiki.github.com/tdreyno/middleman" - s.summary = "A static site generator based on Sinatra. Providing Haml, Sass, Compass, Less, Coffee Script and including minification, compression and cache busting." + s.homepage = "http://middlemanapp.com" + s.summary = "A static site generator based on Sinatra. Providing Haml, Sass, Compass, CoffeeScript and including minification, compression and cache busting." s.rubyforge_project = "middleman" @@ -29,11 +29,8 @@ Gem::Specification.new do |s| s.add_runtime_dependency("uglifier", ["~> 0.5.0"]) s.add_runtime_dependency("slim", ["~> 0.9.4"]) s.add_runtime_dependency("haml", ["~> 3.1.0"]) - s.add_runtime_dependency("coffee-filter", ["~> 0.1.0"]) s.add_runtime_dependency("sass", ["~> 3.1.0"]) s.add_runtime_dependency("compass", ["~> 0.11.3"]) - s.add_runtime_dependency("compass-susy-plugin", ["~> 0.9.0"]) - s.add_runtime_dependency("coffee-script", ["~> 2.2.0"]) s.add_runtime_dependency("httparty", ["~> 0.7.0"]) s.add_development_dependency("spork", ["~> 0.9.0.rc8"]) s.add_development_dependency("cucumber", ["~> 0.10.0"])