From 7a35c1f48ed14a65838e094bdf112f96d2ac96b3 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Wed, 6 Jul 2011 09:50:34 -0700 Subject: [PATCH] split out core extensions from features --- lib/middleman.rb | 9 +++++++++ .../{features => core_extensions}/data.rb | 10 +++++----- .../default_helpers.rb | 10 ++++++++-- lib/middleman/features.rb | 7 ------- lib/middleman/server.rb | 14 +++++--------- 5 files changed, 27 insertions(+), 23 deletions(-) rename lib/middleman/{features => core_extensions}/data.rb (86%) rename lib/middleman/{features => core_extensions}/default_helpers.rb (92%) diff --git a/lib/middleman.rb b/lib/middleman.rb index 8fd2bb0f..6360cbbd 100755 --- a/lib/middleman.rb +++ b/lib/middleman.rb @@ -71,6 +71,15 @@ module Middleman autoload :Markdown, "middleman/renderers/markdown" autoload :CoffeeScript, "middleman/renderers/coffee_script" end + + module CoreExtensions + # DefaultHelpers are the built-in dynamic template helpers. + autoload :DefaultHelpers, "middleman/core_extensions/default_helpers" + + # Data looks at the data/ folder for YAML files and makes them available + # to dynamic requests. + autoload :Data, "middleman/core_extensions/data" + end # Features API autoload :Features, "middleman/features" diff --git a/lib/middleman/features/data.rb b/lib/middleman/core_extensions/data.rb similarity index 86% rename from lib/middleman/features/data.rb rename to lib/middleman/core_extensions/data.rb index f6160ae0..747f0d2b 100755 --- a/lib/middleman/features/data.rb +++ b/lib/middleman/core_extensions/data.rb @@ -2,18 +2,18 @@ require "yaml" require "httparty" require "thor" -module Middleman::Features::Data +module Middleman::CoreExtensions::Data class << self def registered(app) app.extend ClassMethods - app.helpers Middleman::Features::Data::Helpers + app.helpers Helpers end alias :included :registered end module Helpers def data - @@data ||= Middleman::Features::Data::DataObject.new(self) + @@data ||= Middleman::CoreExtensions::Data::DataObject.new(self) end end @@ -82,11 +82,11 @@ module Middleman::Features::Data # # data.my_json def data_source(name, url) - Middleman::Features::Data::DataObject.add_source(name, url) + Middleman::CoreExtensions::Data::DataObject.add_source(name, url) end def data_content(name, content) - Middleman::Features::Data::DataObject.data_content(name, content) + Middleman::CoreExtensions::Data::DataObject.data_content(name, content) end end end \ No newline at end of file diff --git a/lib/middleman/features/default_helpers.rb b/lib/middleman/core_extensions/default_helpers.rb similarity index 92% rename from lib/middleman/features/default_helpers.rb rename to lib/middleman/core_extensions/default_helpers.rb index 283929c3..daae3c63 100644 --- a/lib/middleman/features/default_helpers.rb +++ b/lib/middleman/core_extensions/default_helpers.rb @@ -1,7 +1,13 @@ -module Middleman::Features::DefaultHelpers +require "padrino-helpers" + +module Middleman::CoreExtensions::DefaultHelpers class << self def registered(app) - app.helpers Middleman::Features::DefaultHelpers::Helpers + # Use Padrino Helpers + app.register Padrino::Helpers + + # Middleman Helpers + app.helpers Helpers end alias :included :registered end diff --git a/lib/middleman/features.rb b/lib/middleman/features.rb index 5fa62622..e1d6ebe6 100644 --- a/lib/middleman/features.rb +++ b/lib/middleman/features.rb @@ -43,9 +43,6 @@ module Middleman::Features # browser caches failing to update to your new content. autoload :CacheBuster, "middleman/features/cache_buster" - # DefaultHelpers are the built-in dynamic template helpers. - autoload :DefaultHelpers, "middleman/features/default_helpers" - # 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" @@ -67,10 +64,6 @@ module Middleman::Features # paragraphs, fake images, names and email addresses. autoload :Lorem, "middleman/features/lorem" - # Data looks at the data/ folder for YAML files and makes them available - # to dynamic requests. - autoload :Data, "middleman/features/data" - # Parse YAML metadata from templates autoload :FrontMatter, "middleman/features/front_matter" diff --git a/lib/middleman/server.rb b/lib/middleman/server.rb index 90016abf..72db5db1 100644 --- a/lib/middleman/server.rb +++ b/lib/middleman/server.rb @@ -3,7 +3,6 @@ require "sinatra/base" # Use the padrino project's helpers require "padrino-core/application/rendering" -require "padrino-helpers" module Middleman class Server < Sinatra::Base @@ -34,18 +33,15 @@ module Middleman # Disable Padrino cache buster until explicitly enabled set :asset_stamp, false - # Use Padrino Helpers - register Padrino::Helpers + # Activate built-in helpers + register Middleman::CoreExtensions::DefaultHelpers + + # Activate Yaml Data package + register Middleman::CoreExtensions::Data # Activate custom features register Middleman::Features - # Activate built-in helpers - register Middleman::Features::DefaultHelpers - - # Activate Yaml Data package - register Middleman::Features::Data - # Activate Webservices Proxy package # register Middleman::Features::Proxy