Load Middleman using Pow.cx

This blog is (at time of writing) made using the awesome Middleman App. To easily write articles and view the result we’ve setup Pow to auto start the Middleman server.

Add the following config.ru to your Middleman App’s root path. This is a Rack middleware config that Pow uses to start your app.

require 'rubygems'
require 'bundler/setup'
require 'middleman-core/load_paths'

Middleman.setup_load_paths

require 'middleman-core'
require 'middleman-core/preview_server'

module Middleman::PreviewServer
  def self.preview_in_rack
    @options = {  }
    @app = new_app
    start_file_watcher
  end
end

Middleman::PreviewServer.preview_in_rack
run Middleman::PreviewServer.app.class.to_rack_app

Next just create your regular .pow/symlink.

Tail the logs using tail -f ~/Library/Logs/Pow/apps/yourappname.log.

This works for Middleman version 3.3.12.

UPDATE - Middleman 3.4.0

For Middleman 3.4.0 use:

require 'rubygems'
require 'bundler/setup'
require 'middleman-core/load_paths'

Middleman.setup_load_paths

require 'middleman-core'
require 'middleman-core/preview_server'

class Middleman::PreviewServer
  def self.preview_in_rack
    @server_information = ServerInformation.new
    @options = {  }
    @app = new_app
    start_file_watcher
  end
end

Middleman::PreviewServer.preview_in_rack
run Middleman::PreviewServer.app.class.to_rack_app