diff --git a/bin/mm-server b/bin/mm-server index ac520393..92737e65 100755 --- a/bin/mm-server +++ b/bin/mm-server @@ -4,4 +4,5 @@ require File.join(File.dirname(__FILE__), '..', 'lib', 'middleman') # Start Middleman +Middleman.set :server, %w[thin webrick] Middleman.run!(:root => Dir.pwd) \ No newline at end of file diff --git a/lib/middleman.rb b/lib/middleman.rb index 13088119..fe9001ce 100644 --- a/lib/middleman.rb +++ b/lib/middleman.rb @@ -45,7 +45,6 @@ class Middleman < Sinatra::Base config.output_style = :nested config.css_dir = File.join(File.basename(self.public), "stylesheets") config.images_dir = File.join(File.basename(self.public), "images") - config.http_path = "/" config.http_images_path = "/images" config.http_stylesheets_path = "/stylesheets" config.add_import_path(config.sass_dir) diff --git a/lib/middleman/helpers.rb b/lib/middleman/helpers.rb index b8caff30..17a7180a 100644 --- a/lib/middleman/helpers.rb +++ b/lib/middleman/helpers.rb @@ -1,3 +1,38 @@ +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 + +def find_and_include_related_sass_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 link_to(title, url="#", params={}) params.merge!(:href => url) params = params.map { |k,v| %Q{#{k}="#{v}"}}.join(' ')