convert default helpers to new ext
This commit is contained in:
parent
1d1f37d764
commit
01e85b8bf7
2 changed files with 214 additions and 225 deletions
|
@ -21,7 +21,7 @@ module Middleman
|
|||
|
||||
# Setup default helpers
|
||||
require "middleman-more/core_extensions/default_helpers"
|
||||
Middleman::Application.register Middleman::CoreExtensions::DefaultHelpers
|
||||
Middleman::CoreExtensions::DefaultHelpers.new(app)
|
||||
|
||||
# i18n
|
||||
require "i18n"
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
require 'active_support/core_ext/object/to_query'
|
||||
class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
|
||||
|
||||
module Middleman
|
||||
module CoreExtensions
|
||||
# Built-in helpers
|
||||
module DefaultHelpers
|
||||
def initialize(app, options_hash={}, &block)
|
||||
super
|
||||
|
||||
# Extension registered
|
||||
class << self
|
||||
# @private
|
||||
def registered(app)
|
||||
require 'active_support/core_ext/object/to_query'
|
||||
require 'padrino-helpers'
|
||||
|
||||
app.helpers ::Padrino::Helpers::OutputHelpers
|
||||
|
@ -19,15 +14,11 @@ module Middleman
|
|||
app.helpers ::Padrino::Helpers::RenderHelpers
|
||||
app.helpers ::Padrino::Helpers::NumberHelpers
|
||||
|
||||
app.helpers Helpers
|
||||
|
||||
app.config.define_setting :relative_links, false, 'Whether to generate relative links instead of absolute ones'
|
||||
end
|
||||
alias :included :registered
|
||||
end
|
||||
|
||||
# The helpers
|
||||
module Helpers
|
||||
helpers do
|
||||
# Disable Padrino cache buster
|
||||
def asset_stamp
|
||||
false
|
||||
|
@ -78,7 +69,7 @@ module Middleman
|
|||
def page_classes
|
||||
path = current_path.dup
|
||||
path << index_file if path.end_with?('/')
|
||||
path = Util.strip_leading_slash(path)
|
||||
path = ::Middleman::Util.strip_leading_slash(path)
|
||||
|
||||
classes = []
|
||||
parts = path.split('.').first.split('/')
|
||||
|
@ -153,7 +144,7 @@ module Middleman
|
|||
|
||||
# Try to find a sitemap resource corresponding to the desired path
|
||||
this_resource = current_resource # store in a local var to save work
|
||||
if path_or_resource.is_a?(Sitemap::Resource)
|
||||
if path_or_resource.is_a?(::Middleman::Sitemap::Resource)
|
||||
resource = path_or_resource
|
||||
resource_url = url
|
||||
elsif this_resource && uri.path
|
||||
|
@ -239,6 +230,4 @@ module Middleman
|
|||
super
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue