split out core extensions from features

This commit is contained in:
Thomas Reynolds 2011-07-06 09:50:34 -07:00
parent a6ad06f3e6
commit 7a35c1f48e
5 changed files with 27 additions and 23 deletions

View file

@ -72,6 +72,15 @@ module Middleman
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"
end

View file

@ -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

View file

@ -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

View file

@ -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"

View file

@ -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