From c95c924d53083dff68c90415bf085bb33a1125d3 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Tue, 31 Dec 2013 18:21:30 -0800 Subject: [PATCH 001/580] build a config file jail --- .../fixtures/feature-params-app/config.rb | 16 +- .../feature-params-app/source/index.html.erb | 5 +- .../fixtures/v4-extension-callbacks/config.rb | 20 +- .../lib/middleman-core/application.rb | 37 ++- .../lib/middleman-core/cli/build.rb | 5 +- .../lib/middleman-core/cli/console.rb | 2 +- .../lib/middleman-core/config_context.rb | 66 +++++ .../lib/middleman-core/configuration.rb | 70 +---- .../core_extensions/extensions.rb | 14 +- .../middleman-core/core_extensions/request.rb | 1 + .../middleman-core/core_extensions/routing.rb | 91 +++--- .../lib/middleman-core/renderers/stylus.rb | 5 +- middleman-core/lib/middleman-core/sitemap.rb | 25 -- .../sitemap/extensions/ignores.rb | 124 ++++----- .../sitemap/extensions/proxies.rb | 260 ++++++++---------- .../sitemap/extensions/redirects.rb | 189 ++++++------- .../sitemap/extensions/request_endpoints.rb | 151 +++++----- .../sitemap/extensions/traversal.rb | 12 +- .../lib/middleman-core/sitemap/resource.rb | 8 +- .../lib/middleman-core/sitemap/store.rb | 35 ++- .../step_definitions/server_steps.rb | 8 +- .../core_extensions/default_helpers.rb | 12 +- .../extensions/automatic_image_sizes.rb | 2 +- .../middleman-more/extensions/cache_buster.rb | 4 +- .../extensions/directory_indexes.rb | 2 +- .../lib/middleman-more/extensions/gzip.rb | 2 +- 26 files changed, 553 insertions(+), 613 deletions(-) create mode 100644 middleman-core/lib/middleman-core/config_context.rb diff --git a/middleman-core/fixtures/feature-params-app/config.rb b/middleman-core/fixtures/feature-params-app/config.rb index f30e6074..fda7e5a0 100644 --- a/middleman-core/fixtures/feature-params-app/config.rb +++ b/middleman-core/fixtures/feature-params-app/config.rb @@ -1,12 +1,16 @@ set :layout, false -module ExtensionA - class << self - def registered(app, options={}) - app.set :a_options, options +class ExtensionA < ::Middleman::Extension + helpers do + def get_option(key) + extensions[:extension_a].options[key] end - alias :included :registered end + + option :hello, '', '' + option :hola, '', '' end -activate ExtensionA, :hello => "world", :hola => "mundo" +ExtensionA.register + +activate :extension_a, :hello => "world", :hola => "mundo" diff --git a/middleman-core/fixtures/feature-params-app/source/index.html.erb b/middleman-core/fixtures/feature-params-app/source/index.html.erb index 0435545e..62193af1 100644 --- a/middleman-core/fixtures/feature-params-app/source/index.html.erb +++ b/middleman-core/fixtures/feature-params-app/source/index.html.erb @@ -1,3 +1,2 @@ -<% a_options.each do |k, v| %> - <%= k %>: <%= v%> -<% end %> \ No newline at end of file +hello: <%= get_option(:hello) %> +hola: <%= get_option(:hola) %> \ No newline at end of file diff --git a/middleman-core/fixtures/v4-extension-callbacks/config.rb b/middleman-core/fixtures/v4-extension-callbacks/config.rb index 174bbec3..c9c1c5d4 100644 --- a/middleman-core/fixtures/v4-extension-callbacks/config.rb +++ b/middleman-core/fixtures/v4-extension-callbacks/config.rb @@ -1,9 +1,17 @@ class ExtensionOne < ::Middleman::Extension + helpers do + def extension_two_was_activated + extensions[:extension_one].extension_two_was_activated + end + end + + attr_reader :extension_two_was_activated + def initialize(app, options_hash={}) super after_extension_activated :extension_two do - app.set :extension_two_was_activated, true + @extension_two_was_activated = true end end end @@ -11,11 +19,19 @@ end ExtensionOne.register class ExtensionTwo < ::Middleman::Extension + helpers do + def extension_one_was_activated + extensions[:extension_two].extension_one_was_activated + end + end + + attr_reader :extension_one_was_activated + def initialize(app, options_hash={}) super after_extension_activated :extension_one do - app.set :extension_one_was_activated, true + @extension_one_was_activated = true end end end diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb index 74c35285..a1dc0092 100644 --- a/middleman-core/lib/middleman-core/application.rb +++ b/middleman-core/lib/middleman-core/application.rb @@ -20,10 +20,13 @@ require 'vendored-middleman-deps/hooks-0.2.0/lib/hooks' require 'middleman-core/logger' require 'middleman-core/sitemap' +require 'middleman-core/sitemap/store' require 'middleman-core/configuration' require 'middleman-core/core_extensions' +require 'middleman-core/config_context' + # Core Middleman Class module Middleman class Application @@ -150,48 +153,52 @@ module Middleman # extensions see updated frontmatter! register Middleman::CoreExtensions::FrontMatter - # Sitemap + # Sitemap Config options and public api register Middleman::Sitemap # Setup external helpers register Middleman::CoreExtensions::ExternalHelpers - # with_layout and page routing - include Middleman::CoreExtensions::Routing - + # Reference to Logger singleton attr_reader :logger + # New container for config.rb commands + attr_reader :config_context + + # Reference to Sitemap + attr_reader :sitemap + + # Template cache + attr_reader :cache + # Initialize the Middleman project def initialize(&block) + @cache = ::Tilt::Cache.new @logger = ::Middleman::Logger.singleton - - # Clear the static class cache - cache.clear + @config_context = ConfigContext.new(self) # Setup the default values from calls to set before initialization self.class.config.load_settings(self.class.superclass.config.all_settings) + # Initialize the Sitemap + @sitemap = ::Middleman::Sitemap::Store.new(self) + if Object.const_defined?(:Encoding) Encoding.default_internal = config[:encoding] Encoding.default_external = config[:encoding] end # Evaluate a passed block if given - instance_exec(&block) if block_given? + @config_context.instance_exec(&block) if block_given? config[:source] = ENV['MM_SOURCE'] if ENV['MM_SOURCE'] super end - # Shared cache instance - # - # @private - # @return [Middleman::Util::Cache] The cache - def self.cache - @_cache ||= ::Tilt::Cache.new + def add_to_config_context(name, &func) + @config_context.define_singleton_method(name, &func) end - delegate :cache, :to => :"self.class" # Whether we're in development mode # @return [Boolean] If we're in dev mode diff --git a/middleman-core/lib/middleman-core/cli/build.rb b/middleman-core/lib/middleman-core/cli/build.rb index 33365949..c4d20923 100644 --- a/middleman-core/lib/middleman-core/cli/build.rb +++ b/middleman-core/lib/middleman-core/cli/build.rb @@ -68,6 +68,7 @@ module Middleman::Cli action BuildAction.new(self, opts) self.class.shared_instance.run_hook :after_build, self + self.class.shared_instance.config_context.execute_after_build_callbacks(self) if self.had_errors && !self.debugging msg = 'There were errors during this build' @@ -110,7 +111,7 @@ module Middleman::Cli def initialize(base, config={}) @app = base.class.shared_instance @source_dir = Pathname(@app.source_dir) - @build_dir = Pathname(@app.build_dir) + @build_dir = Pathname(@app.config[:build_dir]) @to_clean = Set.new @logger = @app.logger @@ -190,7 +191,7 @@ module Middleman::Cli logger.debug '== Checking for Compass sprites' # Double-check for compass sprites - @app.files.find_new_files((@source_dir + @app.images_dir).relative_path_from(@app.root_path)) + @app.files.find_new_files((@source_dir + @app.config[:images_dir]).relative_path_from(@app.root_path)) @app.sitemap.ensure_resource_list_updated! # Sort paths to be built by the above order. This is primarily so Compass can diff --git a/middleman-core/lib/middleman-core/cli/console.rb b/middleman-core/lib/middleman-core/cli/console.rb index d647db2f..21f4c42c 100644 --- a/middleman-core/lib/middleman-core/cli/console.rb +++ b/middleman-core/lib/middleman-core/cli/console.rb @@ -29,7 +29,7 @@ module Middleman::Cli @app =::Middleman::Application.server.inst do if opts[:environment] - set :environment, opts[:environment].to_sym + config[:environment] = opts[:environment].to_sym end logger(opts[:debug] ? 0 : 1, opts[:instrumenting] || false) diff --git a/middleman-core/lib/middleman-core/config_context.rb b/middleman-core/lib/middleman-core/config_context.rb new file mode 100644 index 00000000..358dc9f2 --- /dev/null +++ b/middleman-core/lib/middleman-core/config_context.rb @@ -0,0 +1,66 @@ +module Middleman + class ConfigContext + # with_layout and page routing + include Middleman::CoreExtensions::Routing + + attr_reader :app + + # Whitelist methods that can reach out. + delegate :config, :logger, :activate, :use, :map, :mime_type, :data, :helpers, :template_extensions, :root, :to => :app + + def initialize(app) + @app = app + @ready_callbacks = [] + @after_build_callbacks = [] + @after_configuration_callbacks = [] + @configure_callbacks = {} + end + + def ready(&block) + @ready_callbacks << block + end + + def execute_ready_callbacks + @ready_callbacks.each do |b| + instance_exec(&b) + end + end + + def after_build(&block) + @after_build_callbacks << block + end + + def execute_after_build_callbacks(*args) + @after_build_callbacks.each do |b| + instance_exec(*args, &b) + end + end + + def after_configuration(&block) + @after_configuration_callbacks << block + end + + def execute_after_configuration_callbacks + @after_configuration_callbacks.each do |b| + instance_exec(&b) + end + end + + def configure(key, &block) + @configure_callbacks[key] ||= [] + @configure_callbacks[key] << block + end + + def execute_configure_callbacks(key) + @configure_callbacks[key] ||= [] + @configure_callbacks[key].each do |b| + instance_exec(&b) + end + end + + def set(key, default=nil, &block) + config.define_setting(key, default) unless config.defines_setting?(key) + @app.config[key] = block_given? ? block : default + end + end +end \ No newline at end of file diff --git a/middleman-core/lib/middleman-core/configuration.rb b/middleman-core/lib/middleman-core/configuration.rb index 4340fa16..ea6d9037 100644 --- a/middleman-core/lib/middleman-core/configuration.rb +++ b/middleman-core/lib/middleman-core/configuration.rb @@ -5,6 +5,7 @@ module Middleman module Global def self.included(app) app.send :extend, ClassMethods + app.send :delegate, :config, :to => :"self.class" end module ClassMethods @@ -13,75 +14,6 @@ module Middleman def config @_config ||= ConfigurationManager.new end - - # Set attributes (global variables) - # - # @deprecated Prefer accessing settings through "config". - # - # @param [Symbol] key Name of the attribue - # @param default Attribute value - # @return [void] - def set(key, default=nil, &block) - config.define_setting(key, default) unless config.defines_setting?(key) - @inst.set(key, default, &block) if @inst - end - - # Access global settings as methods, to preserve compatibility with - # old Middleman. - # - # @deprecated Prefer accessing settings through "config". - def method_missing(method, *args) - if config.defines_setting? method - config[method] - else - super - end - end - - # Needed so that method_missing makes sense - def respond_to?(method, include_private = false) - super || config.defines_setting?(method) - end - end - - def config - self.class.config - end - - # Backwards compatibilty with old Sinatra template interface - # - # @deprecated Prefer accessing settings through "config". - # - # @return [ConfigurationManager] - alias :settings :config - - # Set attributes (global variables) - # - # @deprecated Prefer accessing settings through "config". - # - # @param [Symbol] key Name of the attribue - # @param value Attribute value - # @return [void] - def set(key, value=nil, &block) - value = block if block_given? - config[key] = value - end - - # Access global settings as methods, to preserve compatibility with - # old Middleman. - # - # @deprecated Prefer accessing settings through "config". - def method_missing(method, *args) - if config.defines_setting? method - config[method] - else - super - end - end - - # Needed so that method_missing makes sense - def respond_to?(method, include_private = false) - super || config.defines_setting?(method) end end diff --git a/middleman-core/lib/middleman-core/core_extensions/extensions.rb b/middleman-core/lib/middleman-core/core_extensions/extensions.rb index 9f7fe708..3f028c08 100644 --- a/middleman-core/lib/middleman-core/core_extensions/extensions.rb +++ b/middleman-core/lib/middleman-core/core_extensions/extensions.rb @@ -159,11 +159,18 @@ module Middleman local_config = File.join(root, 'config.rb') if File.exists? local_config logger.debug '== Reading: Local config' - instance_eval File.read(local_config), local_config, 1 + config_context.instance_eval File.read(local_config), local_config, 1 end - run_hook :build_config if build? - run_hook :development_config if development? + if build? + run_hook :build_config + config_context.execute_configure_callbacks(:build) + end + + if development? + run_hook :development_config + config_context.execute_configure_callbacks(:development) + end run_hook :instance_available @@ -177,6 +184,7 @@ module Middleman end run_hook :after_configuration + config_context.execute_after_configuration_callbacks logger.debug 'Loaded extensions:' self.extensions.each do |ext, klass| diff --git a/middleman-core/lib/middleman-core/core_extensions/request.rb b/middleman-core/lib/middleman-core/core_extensions/request.rb index 09380ab8..fde29797 100644 --- a/middleman-core/lib/middleman-core/core_extensions/request.rb +++ b/middleman-core/lib/middleman-core/core_extensions/request.rb @@ -51,6 +51,7 @@ module Middleman @inst ||= begin mm = new(&block) mm.run_hook :ready + mm.config_context.execute_ready_callbacks mm end end diff --git a/middleman-core/lib/middleman-core/core_extensions/routing.rb b/middleman-core/lib/middleman-core/core_extensions/routing.rb index ea53efeb..c4171b78 100644 --- a/middleman-core/lib/middleman-core/core_extensions/routing.rb +++ b/middleman-core/lib/middleman-core/core_extensions/routing.rb @@ -2,69 +2,72 @@ module Middleman module CoreExtensions module Routing - # Takes a block which allows many pages to have the same layout - # - # with_layout :admin do - # page "/admin/" - # page "/admin/login.html" - # end - # - # @param [String, Symbol] layout_name - # @return [void] - def with_layout(layout_name, &block) - old_layout = config[:layout] - config[:layout] = layout_name - instance_exec(&block) if block_given? - ensure - config[:layout] = old_layout + # Sandboxed layout to implement temporary overriding of layout. + class LayoutBlock + attr_reader :scope + + def initialize(scope, layout_name) + @scope = scope + @layout_name = layout_name end - # The page method allows the layout to be set on a specific path - # - # page "/about.html", :layout => false - # page "/", :layout => :homepage_layout - # - # @param [String] url - # @param [Hash] opts - # @return [void] def page(url, opts={}, &block) - blocks = Array(block) + opts[:layout] ||= @layout_name + @scope.page(url, opts, &block) + end - # Default layout - opts[:layout] = config[:layout] if opts[:layout].nil? + delegate :proxy, :to => :scope + end - # If the url is a regexp - if url.is_a?(Regexp) || url.include?('*') + # Takes a block which allows many pages to have the same layout + # + # with_layout :admin do + # page "/admin/" + # page "/admin/login.html" + # end + # + # @param [String, Symbol] layout_name + # @return [void] + def with_layout(layout_name, &block) + LayoutBlock.new(self, layout_name).instance_eval(&block) + end - # Use the metadata loop for matching against paths at runtime - sitemap.provides_metadata_for_path(url) do |_| - { :options => opts, :blocks => blocks } - end - - return - end + # The page method allows the layout to be set on a specific path + # + # page "/about.html", :layout => false + # page "/", :layout => :homepage_layout + # + # @param [String] url + # @param [Hash] opts + # @return [void] + def page(url, opts={}, &block) + # Default layout + opts[:layout] = @app.config[:layout] if opts[:layout].nil? + metadata = { :options => opts, :blocks => Array(block) } + # If the url is a regexp + unless url.is_a?(Regexp) || url.include?('*') # Normalized path url = '/' + Middleman::Util.normalize_path(url) - if url.end_with?('/') || File.directory?(File.join(source_dir, url)) - url = File.join(url, config[:index_file]) + if url.end_with?('/') || File.directory?(File.join(@app.source_dir, url)) + url = File.join(url, @app.config[:index_file]) end # Setup proxy if target = opts.delete(:proxy) # TODO: deprecate proxy through page? - proxy(url, target, opts, &block) and return + @app.proxy(url, target, opts, &block) + return elsif opts.delete(:ignore) # TODO: deprecate ignore through page? - ignore(url) - end - - # Setup a metadata matcher for rendering those options - sitemap.provides_metadata_for_path(url) do |_| - { :options => opts, :blocks => blocks } + @app.ignore(url) end end + + # Setup a metadata matcher for rendering those options + @app.sitemap.provides_metadata_for_path(url) { |_| metadata } + end end end end diff --git a/middleman-core/lib/middleman-core/renderers/stylus.rb b/middleman-core/lib/middleman-core/renderers/stylus.rb index 87109104..72a4cba8 100644 --- a/middleman-core/lib/middleman-core/renderers/stylus.rb +++ b/middleman-core/lib/middleman-core/renderers/stylus.rb @@ -12,8 +12,9 @@ module Middleman # Once registered def registered(app) - # Default less options - app.set :styl, {} + # Default stylus options + app.config.define_setting :styl, {}, 'Stylus config options' + app.before_configuration do template_extensions :styl => :css diff --git a/middleman-core/lib/middleman-core/sitemap.rb b/middleman-core/lib/middleman-core/sitemap.rb index 61f5de97..389ef5c4 100644 --- a/middleman-core/lib/middleman-core/sitemap.rb +++ b/middleman-core/lib/middleman-core/sitemap.rb @@ -1,12 +1,3 @@ -require 'middleman-core/sitemap/store' -require 'middleman-core/sitemap/resource' - -require 'middleman-core/sitemap/extensions/on_disk' -require 'middleman-core/sitemap/extensions/redirects' -require 'middleman-core/sitemap/extensions/request_endpoints' -require 'middleman-core/sitemap/extensions/proxies' -require 'middleman-core/sitemap/extensions/ignores' - # Core Sitemap Extensions module Middleman @@ -18,11 +9,6 @@ module Middleman # Once registered def registered(app) - app.register Middleman::Sitemap::Extensions::RequestEndpoints - app.register Middleman::Sitemap::Extensions::Proxies - app.register Middleman::Sitemap::Extensions::Ignores - app.register Middleman::Sitemap::Extensions::Redirects - # Set to automatically convert some characters into a directory app.config.define_setting :automatic_directory_matcher, nil, 'Set to automatically convert some characters into a directory' @@ -46,11 +32,6 @@ module Middleman # Include instance methods app.send :include, InstanceMethods - - # Initialize Sitemap - app.before_configuration do - sitemap - end end alias :included :registered @@ -59,12 +40,6 @@ module Middleman # Sitemap instance methods module InstanceMethods - # Get the sitemap class instance - # @return [Middleman::Sitemap::Store] - def sitemap - @_sitemap ||= Store.new(self) - end - # Get the resource object for the current path # @return [Middleman::Sitemap::Resource] def current_page diff --git a/middleman-core/lib/middleman-core/sitemap/extensions/ignores.rb b/middleman-core/lib/middleman-core/sitemap/extensions/ignores.rb index 59553626..3c5d3872 100644 --- a/middleman-core/lib/middleman-core/sitemap/extensions/ignores.rb +++ b/middleman-core/lib/middleman-core/sitemap/extensions/ignores.rb @@ -4,87 +4,61 @@ module Middleman module Extensions - module Ignores + # Class to handle managing ignores + class Ignores + def initialize(sitemap) + @app = sitemap.app + @app.add_to_config_context :ignore, &method(:create_ignore) + @app.define_singleton_method(:ignore, &method(:create_ignore)) - # Setup extension - class << self + # Array of callbacks which can ass ignored + @ignored_callbacks = [] - # Once registered - def registered(app) - # Include methods - app.send :include, InstanceMethods - - ::Middleman::Sitemap::Resource.send :include, ResourceInstanceMethods - end - - alias :included :registered + sitemap.define_singleton_method(:ignored?, &method(:ignored?)) + ::Middleman::Sitemap::Resource.send :include, IgnoreResourceInstanceMethods end - # Helpers methods for Resources - module ResourceInstanceMethods - - # Whether the Resource is ignored - # @return [Boolean] - def ignored? - @app.ignore_manager.ignored?(path) || - (!proxy? && - @app.ignore_manager.ignored?(source_file.sub("#{@app.source_dir}/", '')) - ) - end - end - - # Ignore-related instance methods - module InstanceMethods - def ignore_manager - @_ignore_manager ||= IgnoreManager.new(self) - end - - # Ignore a path or add an ignore callback - # @param [String, Regexp] path Path glob expression, or path regex - # @return [void] - def ignore(path=nil, &block) - ignore_manager.ignore(path, &block) - end - end - - # Class to handle managing ignores - class IgnoreManager - def initialize(app) - @app = app - - # Array of callbacks which can ass ignored - @ignored_callbacks = [] - end - - # Ignore a path or add an ignore callback - # @param [String, Regexp] path Path glob expression, or path regex - # @return [void] - def ignore(path=nil, &block) - if path.is_a? Regexp - @ignored_callbacks << Proc.new {|p| p =~ path } - elsif path.is_a? String - path_clean = ::Middleman::Util.normalize_path(path) - if path_clean.include?('*') # It's a glob - @ignored_callbacks << Proc.new {|p| File.fnmatch(path_clean, p) } - else - # Add a specific-path ignore unless that path is already covered - return if ignored?(path_clean) - @ignored_callbacks << Proc.new {|p| p == path_clean } - end - elsif block_given? - @ignored_callbacks << block - end - - @app.sitemap.invalidate_resources_not_ignored_cache! - end - - # Whether a path is ignored - # @param [String] path - # @return [Boolean] - def ignored?(path) + # Ignore a path or add an ignore callback + # @param [String, Regexp] path Path glob expression, or path regex + # @return [void] + def create_ignore(path=nil, &block) + if path.is_a? Regexp + @ignored_callbacks << Proc.new {|p| p =~ path } + elsif path.is_a? String path_clean = ::Middleman::Util.normalize_path(path) - @ignored_callbacks.any? { |b| b.call(path_clean) } + if path_clean.include?('*') # It's a glob + @ignored_callbacks << Proc.new {|p| File.fnmatch(path_clean, p) } + else + # Add a specific-path ignore unless that path is already covered + return if ignored?(path_clean) + @ignored_callbacks << Proc.new {|p| p == path_clean } + end + elsif block_given? + @ignored_callbacks << block end + + @app.sitemap.invalidate_resources_not_ignored_cache! + end + + # Whether a path is ignored + # @param [String] path + # @return [Boolean] + def ignored?(path) + path_clean = ::Middleman::Util.normalize_path(path) + @ignored_callbacks.any? { |b| b.call(path_clean) } + end + end + + # Helpers methods for Resources + module IgnoreResourceInstanceMethods + + # Whether the Resource is ignored + # @return [Boolean] + def ignored? + @app.sitemap.ignored?(path) || + (!proxy? && + @app.sitemap.ignored?(source_file.sub("#{@app.source_dir}/", '')) + ) end end end diff --git a/middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb b/middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb index 18076943..933e7312 100644 --- a/middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb +++ b/middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb @@ -4,165 +4,143 @@ module Middleman module Extensions - module Proxies + # Manages the list of proxy configurations and manipulates the sitemap + # to include new resources based on those configurations + class Proxies + def initialize(sitemap) + @app = sitemap.app + @app.add_to_config_context :proxy, &method(:create_proxy) + @app.define_singleton_method(:proxy, &method(:create_proxy)) - # Setup extension - class << self + @proxy_configs = Set.new - # Once registered - def registered(app) - ::Middleman::Sitemap::Resource.send :include, ResourceInstanceMethods - - # Include methods - app.send :include, InstanceMethods - end - - alias :included :registered + ::Middleman::Sitemap::Resource.send :include, ProxyResourceInstanceMethods end - module ResourceInstanceMethods - # Whether this page is a proxy - # @return [Boolean] - def proxy? - !!@proxied_to + # Setup a proxy from a path to a target + # @param [String] path + # @param [String] target + # @param [Hash] opts options to apply to the proxy, including things like + # :locals, :ignore to hide the proxy target, :layout, and :directory_indexes. + # @return [void] + def create_proxy(path, target, opts={}, &block) + metadata = { :options => {}, :locals => {}, :blocks => [] } + metadata[:blocks] << block if block_given? + metadata[:locals] = opts.delete(:locals) || {} + + @app.ignore(target) if opts.delete(:ignore) + metadata[:options] = opts + + @proxy_configs << ProxyConfiguration.new(:path => path, :target => target, :metadata => metadata) + + @app.sitemap.rebuild_resource_list!(:added_proxy) + end + + # Update the main sitemap resource list + # @return [void] + def manipulate_resource_list(resources) + resources + @proxy_configs.map do |config| + p = ::Middleman::Sitemap::Resource.new( + @app.sitemap, + config.path + ) + p.proxy_to(config.target) + p.add_metadata(config.metadata) + p end + end + end - # Set this page to proxy to a target path - # @param [String] target - # @return [void] - def proxy_to(target) - target = ::Middleman::Util.normalize_path(target) - raise "You can't proxy #{path} to itself!" if target == path - @proxied_to = target - end + # Configuration for a proxy instance + class ProxyConfiguration + # The path that this proxy will appear at in the sitemap + attr_reader :path + def path=(p) + @path = ::Middleman::Util.normalize_path(p) + end - # The path of the page this page is proxied to, or nil if it's not proxied. - # @return [String] - def proxied_to - @proxied_to - end + # The existing sitemap path that this will proxy to + attr_reader :target + def target=(t) + @target = ::Middleman::Util.normalize_path(t) + end - # The resource for the page this page is proxied to. Throws an exception - # if there is no resource. - # @return [Sitemap::Resource] - def proxied_to_resource - proxy_resource = store.find_resource_by_path(proxied_to) + # Additional metadata like blocks and locals to apply to the proxy + attr_accessor :metadata - unless proxy_resource - raise "Path #{path} proxies to unknown file #{proxied_to}:#{store.resources.map(&:path)}" - end - - if proxy_resource.proxy? - raise "You can't proxy #{path} to #{proxied_to} which is itself a proxy." - end - - proxy_resource - end - - def get_source_file - if proxy? - proxied_to_resource.source_file - else - super - end - end - - def content_type - mime_type = super - return mime_type if mime_type - - if proxy? - proxied_to_resource.content_type - else - nil - end + # Create a new proxy configuration from hash options + def initialize(options={}) + options.each do |key, value| + send "#{key}=", value end end - module InstanceMethods - def proxy_manager - @_proxy_manager ||= ProxyManager.new(self) + # Two configurations are equal if they reference the same path + def eql?(other) + other.path == path + end + + # Two configurations are equal if they reference the same path + def hash + path.hash + end + end + + module ProxyResourceInstanceMethods + # Whether this page is a proxy + # @return [Boolean] + def proxy? + !!@proxied_to + end + + # Set this page to proxy to a target path + # @param [String] target + # @return [void] + def proxy_to(target) + target = ::Middleman::Util.normalize_path(target) + raise "You can't proxy #{path} to itself!" if target == path + @proxied_to = target + end + + # The path of the page this page is proxied to, or nil if it's not proxied. + # @return [String] + def proxied_to + @proxied_to + end + + # The resource for the page this page is proxied to. Throws an exception + # if there is no resource. + # @return [Sitemap::Resource] + def proxied_to_resource + proxy_resource = store.find_resource_by_path(proxied_to) + + unless proxy_resource + raise "Path #{path} proxies to unknown file #{proxied_to}:#{store.resources.map(&:path)}" end - def proxy(*args, &block) - proxy_manager.proxy(*args, &block) + if proxy_resource.proxy? + raise "You can't proxy #{path} to #{proxied_to} which is itself a proxy." + end + + proxy_resource + end + + def get_source_file + if proxy? + proxied_to_resource.source_file + else + super end end - # Manages the list of proxy configurations and manipulates the sitemap - # to include new resources based on those configurations - class ProxyManager - def initialize(app) - @app = app - @proxy_configs = Set.new - end + def content_type + mime_type = super + return mime_type if mime_type - # Setup a proxy from a path to a target - # @param [String] path - # @param [String] target - # @param [Hash] opts options to apply to the proxy, including things like - # :locals, :ignore to hide the proxy target, :layout, and :directory_indexes. - # @return [void] - def proxy(path, target, opts={}, &block) - metadata = { :options => {}, :locals => {}, :blocks => [] } - metadata[:blocks] << block if block_given? - metadata[:locals] = opts.delete(:locals) || {} - - @app.ignore(target) if opts.delete(:ignore) - metadata[:options] = opts - - @proxy_configs << ProxyConfiguration.new(:path => path, :target => target, :metadata => metadata) - - @app.sitemap.rebuild_resource_list!(:added_proxy) - end - - # Update the main sitemap resource list - # @return [void] - def manipulate_resource_list(resources) - resources + @proxy_configs.map do |config| - p = ::Middleman::Sitemap::Resource.new( - @app.sitemap, - config.path - ) - p.proxy_to(config.target) - p.add_metadata(config.metadata) - p - end - end - end - - # Configuration for a proxy instance - class ProxyConfiguration - # The path that this proxy will appear at in the sitemap - attr_reader :path - def path=(p) - @path = ::Middleman::Util.normalize_path(p) - end - - # The existing sitemap path that this will proxy to - attr_reader :target - def target=(t) - @target = ::Middleman::Util.normalize_path(t) - end - - # Additional metadata like blocks and locals to apply to the proxy - attr_accessor :metadata - - # Create a new proxy configuration from hash options - def initialize(options={}) - options.each do |key, value| - send "#{key}=", value - end - end - - # Two configurations are equal if they reference the same path - def eql?(other) - other.path == path - end - - # Two configurations are equal if they reference the same path - def hash - path.hash + if proxy? + proxied_to_resource.content_type + else + nil end end end diff --git a/middleman-core/lib/middleman-core/sitemap/extensions/redirects.rb b/middleman-core/lib/middleman-core/sitemap/extensions/redirects.rb index 9e67cd4d..6dfdb2b0 100644 --- a/middleman-core/lib/middleman-core/sitemap/extensions/redirects.rb +++ b/middleman-core/lib/middleman-core/sitemap/extensions/redirects.rb @@ -1,126 +1,105 @@ +require 'middleman-core/sitemap/resource' + module Middleman module Sitemap module Extensions - module Redirects + # Manages the list of proxy configurations and manipulates the sitemap + # to include new resources based on those configurations + class Redirects + def initialize(sitemap) + @app = sitemap.app + @app.add_to_config_context :redirect, &method(:create_redirect) - # Setup extension - class << self - - # Once registered - def registered(app) - # Include methods - app.send :include, InstanceMethods - end - - alias :included :registered + @redirects = {} end - module InstanceMethods - def redirect_manager - @_redirect_manager ||= RedirectManager.new(self) + # Setup a redirect from a path to a target + # @param [String] path + # @param [Hash] opts The :to value gives a target path + def create_redirect(path, opts={}, &block) + if block_given? + opts[:template] = block end - def redirect(*args, &block) - redirect_manager.create_redirect(*args, &block) + @redirects[path] = opts + + @app.sitemap.rebuild_resource_list!(:added_redirect) + end + + # Update the main sitemap resource list + # @return [void] + def manipulate_resource_list(resources) + resources + @redirects.map do |path, opts| + r = RedirectResource.new( + @app.sitemap, + path, + opts[:to] + ) + r.output = opts[:template] if opts[:template] + r + end + end + end + + class RedirectResource < ::Middleman::Sitemap::Resource + attr_accessor :output + + def initialize(store, path, target) + @request_path = target + + super(store, path) + end + + def template? + true + end + + def render(*args, &block) + url = ::Middleman::Util.url_for(store.app, @request_path, { + :relative => false, + :find_resource => true + }) + + if output + output.call(path, url) + else + <<-END + + + + + + + + + + END end end - # Manages the list of proxy configurations and manipulates the sitemap - # to include new resources based on those configurations - class RedirectManager - def initialize(app) - @app = app - @redirects = {} - end + # def request_path + # @request_path + # end - # Setup a redirect from a path to a target - # @param [String] path - # @param [Hash] opts The :to value gives a target path - def create_redirect(path, opts={}, &block) - if block_given? - opts[:template] = block - end - - @redirects[path] = opts - - @app.sitemap.rebuild_resource_list!(:added_redirect) - end - - # Update the main sitemap resource list - # @return [void] - def manipulate_resource_list(resources) - resources + @redirects.map do |path, opts| - r = RedirectResource.new( - @app.sitemap, - path, - opts[:to] - ) - r.output = opts[:template] if opts[:template] - r - end - end + def binary? + false end - class RedirectResource < ::Middleman::Sitemap::Resource - attr_accessor :output - - def initialize(store, path, target) - @request_path = target - - super(store, path) - end - - def template? - true - end - - def render(*args, &block) - url = ::Middleman::Util.url_for(store.app, @request_path, { - :relative => false, - :find_resource => true - }) - - if output - output.call(path, url) - else - <<-END - - - - - - - - - - END - end - end - - # def request_path - # @request_path - # end - - def binary? - false - end - - def raw_data - {} - end - - def ignored? - false - end - - def metadata - @local_metadata.dup - end - + def raw_data + {} end + + def ignored? + false + end + + def metadata + @local_metadata.dup + end + end end end diff --git a/middleman-core/lib/middleman-core/sitemap/extensions/request_endpoints.rb b/middleman-core/lib/middleman-core/sitemap/extensions/request_endpoints.rb index 84eee061..ba3ad732 100644 --- a/middleman-core/lib/middleman-core/sitemap/extensions/request_endpoints.rb +++ b/middleman-core/lib/middleman-core/sitemap/extensions/request_endpoints.rb @@ -4,110 +4,87 @@ module Middleman module Extensions - module RequestEndpoints - - # Setup extension - class << self - - # Once registered - def registered(app) - # Include methods - app.send :include, InstanceMethods - end - - alias :included :registered - end - - module InstanceMethods - def endpoint_manager - @_endpoint_manager ||= EndpointManager.new(self) - end - - def endpoint(*args, &block) - endpoint_manager.create_endpoint(*args, &block) - end - end + class RequestEndpoints # Manages the list of proxy configurations and manipulates the sitemap # to include new resources based on those configurations - class EndpointManager - def initialize(app) - @app = app - @endpoints = {} - end + def initialize(sitemap) + @app = sitemap.app + @app.add_to_config_context :endpoint, &method(:create_endpoint) - # Setup a proxy from a path to a target - # @param [String] path - # @param [Hash] opts The :path value gives a request path if it - # differs from the output path - def create_endpoint(path, opts={}, &block) - endpoint = { - :request_path => path - } - - if block_given? - endpoint[:output] = block - else - endpoint[:request_path] = opts[:path] if opts.has_key?(:path) - end - - @endpoints[path] = endpoint - - @app.sitemap.rebuild_resource_list!(:added_endpoint) - end - - # Update the main sitemap resource list - # @return [void] - def manipulate_resource_list(resources) - resources + @endpoints.map do |path, config| - r = EndpointResource.new( - @app.sitemap, - path, - config[:request_path] - ) - r.output = config[:output] if config.has_key?(:output) - r - end - end + @endpoints = {} end - class EndpointResource < ::Middleman::Sitemap::Resource - attr_accessor :output + # Setup a proxy from a path to a target + # @param [String] path + # @param [Hash] opts The :path value gives a request path if it + # differs from the output path + def create_endpoint(path, opts={}, &block) + endpoint = { + :request_path => path + } - def initialize(store, path, source_file) - @request_path = ::Middleman::Util.normalize_path(source_file) - - super(store, path) + if block_given? + endpoint[:output] = block + else + endpoint[:request_path] = opts[:path] if opts.has_key?(:path) end - def template? - true - end + @endpoints[path] = endpoint - def render(*args, &block) - return self.output.call if self.output - end + @app.sitemap.rebuild_resource_list!(:added_endpoint) + end - def request_path - @request_path + # Update the main sitemap resource list + # @return [void] + def manipulate_resource_list(resources) + resources + @endpoints.map do |path, config| + r = EndpointResource.new( + @app.sitemap, + path, + config[:request_path] + ) + r.output = config[:output] if config.has_key?(:output) + r end + end + end - def binary? - false - end + class EndpointResource < ::Middleman::Sitemap::Resource + attr_accessor :output - def raw_data - {} - end + def initialize(store, path, source_file) + @request_path = ::Middleman::Util.normalize_path(source_file) - def ignored? - false - end + super(store, path) + end - def metadata - @local_metadata.dup - end + def template? + true + end + def render(*args, &block) + return self.output.call if self.output + end + + def request_path + @request_path + end + + def binary? + false + end + + def raw_data + {} + end + + def ignored? + false + end + + def metadata + @local_metadata.dup end end end diff --git a/middleman-core/lib/middleman-core/sitemap/extensions/traversal.rb b/middleman-core/lib/middleman-core/sitemap/extensions/traversal.rb index 78f8eb28..65c43030 100644 --- a/middleman-core/lib/middleman-core/sitemap/extensions/traversal.rb +++ b/middleman-core/lib/middleman-core/sitemap/extensions/traversal.rb @@ -9,12 +9,12 @@ module Middleman # @return [Middleman::Sitemap::Resource, nil] def parent parts = path.split('/') - parts.pop if path.include?(app.index_file) + parts.pop if path.include?(app.config[:index_file]) return nil if parts.length < 1 parts.pop - parts << app.index_file + parts << app.config[:index_file] parent_path = '/' + parts.join('/') @@ -30,7 +30,7 @@ module Middleman base_path = eponymous_directory_path prefix = %r|^#{base_path.sub("/", "\\/")}| else - base_path = path.sub("#{app.index_file}", '') + base_path = path.sub("#{app.config[:index_file]}", '') prefix = %r|^#{base_path.sub("/", "\\/")}| end @@ -43,7 +43,7 @@ module Middleman if parts.length == 1 true elsif parts.length == 2 - parts.last == app.index_file + parts.last == app.config[:index_file] else false end @@ -61,14 +61,14 @@ module Middleman # Whether this resource either a directory index, or has the same name as an existing directory in the source # @return [Boolean] def directory_index? - path.include?(app.index_file) || path =~ /\/$/ || eponymous_directory? + path.include?(app.config[:index_file]) || path =~ /\/$/ || eponymous_directory? end # Whether the resource has the same name as a directory in the source # (e.g., if the resource is named 'gallery.html' and a path exists named 'gallery/', this would return true) # @return [Boolean] def eponymous_directory? - if !path.end_with?("/#{app.index_file}") && destination_path.end_with?("/#{app.index_file}") + if !path.end_with?("/#{app.config[:index_file]}") && destination_path.end_with?("/#{app.config[:index_file]}") return true end full_path = File.join(app.source_dir, eponymous_directory_path) diff --git a/middleman-core/lib/middleman-core/sitemap/resource.rb b/middleman-core/lib/middleman-core/sitemap/resource.rb index ae3f7ae7..d0d39483 100644 --- a/middleman-core/lib/middleman-core/sitemap/resource.rb +++ b/middleman-core/lib/middleman-core/sitemap/resource.rb @@ -149,11 +149,11 @@ module Middleman # @return [String] def url url_path = destination_path - if app.strip_index_file - url_path = url_path.sub(/(^|\/)#{Regexp.escape(app.index_file)}$/, - app.trailing_slash ? '/' : '') + if app.config[:strip_index_file] + url_path = url_path.sub(/(^|\/)#{Regexp.escape(app.config[:index_file])}$/, + app.config[:trailing_slash] ? '/' : '') end - File.join(app.respond_to?(:http_prefix) ? app.http_prefix : '/', url_path) + File.join(app.config[:http_prefix], url_path) end # Whether the source file is binary. diff --git a/middleman-core/lib/middleman-core/sitemap/store.rb b/middleman-core/lib/middleman-core/sitemap/store.rb index 190da9b7..a8fcdd22 100644 --- a/middleman-core/lib/middleman-core/sitemap/store.rb +++ b/middleman-core/lib/middleman-core/sitemap/store.rb @@ -3,6 +3,13 @@ require 'active_support/core_ext/hash/deep_merge' require 'monitor' require 'middleman-core/sitemap/queryable' +# Extensions +require 'middleman-core/sitemap/extensions/on_disk' +require 'middleman-core/sitemap/extensions/redirects' +require 'middleman-core/sitemap/extensions/request_endpoints' +require 'middleman-core/sitemap/extensions/proxies' +require 'middleman-core/sitemap/extensions/ignores' + module Middleman # Sitemap namespace @@ -29,21 +36,31 @@ module Middleman @_cached_metadata = {} @resource_list_manipulators = [] @needs_sitemap_rebuild = true + @lock = Monitor.new - reset_lookup_cache! - # Register classes which can manipulate the main site map list - register_resource_list_manipulator(:on_disk, Middleman::Sitemap::Extensions::OnDisk.new(self)) + # Handle ignore commands + Middleman::Sitemap::Extensions::Ignores.new(self) - # Request Endpoints - register_resource_list_manipulator(:request_endpoints, @app.endpoint_manager) + # Extensions + { + # Register classes which can manipulate the main site map list + on_disk: Middleman::Sitemap::Extensions::OnDisk, - # Proxies - register_resource_list_manipulator(:proxies, @app.proxy_manager) + # Request Endpoints + request_endpoints: Middleman::Sitemap::Extensions::RequestEndpoints, - # Redirects - register_resource_list_manipulator(:redirects, @app.redirect_manager) + # Proxies + proxies: Middleman::Sitemap::Extensions::Proxies, + + # Redirects + redirects: Middleman::Sitemap::Extensions::Redirects + }.each do |k, m| + register_resource_list_manipulator(k, m.new(self)) + end + + app.config_context.class.send :delegate, :sitemap, :to => :app end # Register a klass which can manipulate the main site map list. Best to register diff --git a/middleman-core/lib/middleman-core/step_definitions/server_steps.rb b/middleman-core/lib/middleman-core/step_definitions/server_steps.rb index 0dda0772..7f51de6e 100644 --- a/middleman-core/lib/middleman-core/step_definitions/server_steps.rb +++ b/middleman-core/lib/middleman-core/step_definitions/server_steps.rb @@ -24,7 +24,9 @@ end Given /^"([^\"]*)" is set to "([^\"]*)"$/ do |variable, value| @initialize_commands ||= [] - @initialize_commands << lambda { set(variable.to_sym, value) } + @initialize_commands << lambda { + config[variable.to_sym] = value + } end Given /^current environment is "([^\"]*)"$/ do |env| @@ -44,8 +46,8 @@ Given /^the Server is running$/ do initialize_commands = @initialize_commands || [] initialize_commands.unshift lambda { - set :environment, @current_env || :development - set :show_exceptions, false + config[:environment] = @current_env || :development + config[:show_exceptions] = false } @server_inst = Middleman::Application.server.inst do diff --git a/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb b/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb index ce6d245d..b3120bb6 100644 --- a/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb +++ b/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb @@ -105,8 +105,8 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension def auto_tag(asset_ext, asset_dir=nil) if asset_dir.nil? asset_dir = case asset_ext - when :js then js_dir - when :css then css_dir + when :js then config[:js_dir] + when :css then config[:css_dir] end end @@ -153,10 +153,10 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension def asset_path(kind, source) return source if source.to_s.include?('//') || source.to_s.start_with?('data:') asset_folder = case kind - when :css then css_dir - when :js then js_dir - when :images then images_dir - when :fonts then fonts_dir + when :css then config[:css_dir] + when :js then config[:js_dir] + when :images then config[:images_dir] + when :fonts then config[:fonts_dir] else kind.to_s end source = source.to_s.tr(' ', '') diff --git a/middleman-core/lib/middleman-more/extensions/automatic_image_sizes.rb b/middleman-core/lib/middleman-more/extensions/automatic_image_sizes.rb index 1b600e4e..2fb37abb 100644 --- a/middleman-core/lib/middleman-more/extensions/automatic_image_sizes.rb +++ b/middleman-core/lib/middleman-more/extensions/automatic_image_sizes.rb @@ -20,7 +20,7 @@ class Middleman::Extensions::AutomaticImageSizes < ::Middleman::Extension params[:alt] ||= '' real_path = path - real_path = File.join(images_dir, real_path) unless real_path.start_with?('/') + real_path = File.join(config[:images_dir], real_path) unless real_path.start_with?('/') full_path = File.join(source_dir, real_path) if File.exists?(full_path) diff --git a/middleman-core/lib/middleman-more/extensions/cache_buster.rb b/middleman-core/lib/middleman-more/extensions/cache_buster.rb index 02ded8af..8d1788ce 100644 --- a/middleman-core/lib/middleman-more/extensions/cache_buster.rb +++ b/middleman-core/lib/middleman-more/extensions/cache_buster.rb @@ -8,7 +8,7 @@ class Middleman::Extensions::CacheBuster < ::Middleman::Extension app.compass_config do |config| config.asset_cache_buster do |path, real_path| real_path = real_path.path if real_path.is_a? File - real_path = real_path.gsub(File.join(root, build_dir), source) + real_path = real_path.gsub(File.join(app.root, app.config[:build_dir]), app.config[:source]) if File.readable?(real_path) File.mtime(real_path).strftime('%s') else @@ -35,7 +35,7 @@ class Middleman::Extensions::CacheBuster < ::Middleman::Extension real_path_static = File.join(prefix, path) if build? - real_path_dynamic = File.join(build_dir, prefix, path) + real_path_dynamic = File.join(config[:build_dir], prefix, path) real_path_dynamic = File.expand_path(real_path_dynamic, root) http_path << '?' + File.mtime(real_path_dynamic).strftime('%s') if File.readable?(real_path_dynamic) elsif resource = sitemap.find_resource_by_path(real_path_static) diff --git a/middleman-core/lib/middleman-more/extensions/directory_indexes.rb b/middleman-core/lib/middleman-more/extensions/directory_indexes.rb index 18818f5e..5c14f723 100644 --- a/middleman-core/lib/middleman-more/extensions/directory_indexes.rb +++ b/middleman-core/lib/middleman-more/extensions/directory_indexes.rb @@ -3,7 +3,7 @@ class Middleman::Extensions::DirectoryIndexes < ::Middleman::Extension # Update the main sitemap resource list # @return [void] def manipulate_resource_list(resources) - index_file = app.index_file + index_file = app.config[:index_file] new_index_path = "/#{index_file}" resources.each do |resource| diff --git a/middleman-core/lib/middleman-more/extensions/gzip.rb b/middleman-core/lib/middleman-more/extensions/gzip.rb index d52e8cfc..6ca5e6d1 100644 --- a/middleman-core/lib/middleman-more/extensions/gzip.rb +++ b/middleman-core/lib/middleman-more/extensions/gzip.rb @@ -23,7 +23,7 @@ class Middleman::Extensions::Gzip < ::Middleman::Extension def after_build(builder) num_threads = 4 - paths = ::Middleman::Util.all_files_under(app.build_dir) + paths = ::Middleman::Util.all_files_under(app.config[:build_dir]) total_savings = 0 # Fill a queue with inputs From b5fec39df8e007f7915e8dcf945ec304b6c413c5 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Wed, 1 Jan 2014 15:00:56 -0800 Subject: [PATCH 002/580] 2.1 is for reals now --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 520228b1..d10d9c65 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,6 @@ matrix: fast_finish: true allow_failures: - rvm: ruby-head - - rvm: 2.1.0 - rvm: jruby-19mode env: TEST=true before_install: git submodule update --init --recursive From a6106087855c9ae99983c3de0286ce9c843f02ed Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Wed, 1 Jan 2014 14:50:42 -0800 Subject: [PATCH 003/580] remove old style extension support --- Gemfile | 2 +- middleman-core/features/v3_extensions.feature | 20 -- .../lib/middleman-core/application.rb | 38 ++-- .../middleman-core/core_extensions/data.rb | 3 +- .../core_extensions/extensions.rb | 41 ++-- .../core_extensions/external_helpers.rb | 44 ++--- .../core_extensions/file_watcher.rb | 9 +- .../core_extensions/rendering.rb | 24 ++- .../middleman-core/core_extensions/request.rb | 4 +- .../core_extensions/show_exceptions.rb | 28 ++- .../lib/middleman-core/extension.rb | 149 +++++++++++++++ .../lib/middleman-core/extensions.rb | 180 +----------------- middleman-core/lib/middleman-core/sitemap.rb | 3 +- .../middleman-more/core_extensions/compass.rb | 7 +- .../core_extensions/default_helpers.rb | 2 + .../middleman-more/core_extensions/i18n.rb | 2 + .../lib/middleman-more/extensions/lorem.rb | 2 + 17 files changed, 245 insertions(+), 313 deletions(-) delete mode 100644 middleman-core/features/v3_extensions.feature create mode 100644 middleman-core/lib/middleman-core/extension.rb diff --git a/Gemfile b/Gemfile index 5e98142c..fec45479 100644 --- a/Gemfile +++ b/Gemfile @@ -38,5 +38,5 @@ gem 'rubocop', :require => false # Middleman itself gem 'middleman-core', :path => 'middleman-core' -gem 'middleman-sprockets', :github => 'middleman/middleman-sprockets' +gem 'middleman-sprockets', :github => 'middleman/middleman-sprockets', :require => false gem 'middleman', :path => 'middleman' diff --git a/middleman-core/features/v3_extensions.feature b/middleman-core/features/v3_extensions.feature deleted file mode 100644 index 134dd72f..00000000 --- a/middleman-core/features/v3_extensions.feature +++ /dev/null @@ -1,20 +0,0 @@ -Feature: v3 Modular Extension - Scenario: Registering and overwriting a system config option - Given a fixture app "large-build-app" - And a file named "config.rb" with: - """ - module MyFeature - class << self - def registered(app) - app.set :css_dir, "lib/my/css" - end - alias :included :registered - end - end - - ::Middleman::Extensions.register(:my_feature, MyFeature) - activate :my_feature - """ - Given a successfully built app at "large-build-app" - When I cd to "build" - Then the file "link_test.html" should contain "lib/my/css/test.css" \ No newline at end of file diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb index a1dc0092..2d31d870 100644 --- a/middleman-core/lib/middleman-core/application.rb +++ b/middleman-core/lib/middleman-core/application.rb @@ -135,29 +135,29 @@ module Middleman include Middleman::CoreExtensions::Extensions # Basic Rack Request Handling - register Middleman::CoreExtensions::Request + include Middleman::CoreExtensions::Request # Handle exceptions - register Middleman::CoreExtensions::ShowExceptions + include Middleman::CoreExtensions::ShowExceptions # Add Watcher Callbacks - register Middleman::CoreExtensions::FileWatcher + include Middleman::CoreExtensions::FileWatcher # Activate Data package - register Middleman::CoreExtensions::Data + include Middleman::CoreExtensions::Data # Setup custom rendering - register Middleman::CoreExtensions::Rendering + include Middleman::CoreExtensions::Rendering # Parse YAML from templates. Must be before sitemap so sitemap # extensions see updated frontmatter! register Middleman::CoreExtensions::FrontMatter # Sitemap Config options and public api - register Middleman::Sitemap + include Middleman::Sitemap # Setup external helpers - register Middleman::CoreExtensions::ExternalHelpers + include Middleman::CoreExtensions::ExternalHelpers # Reference to Logger singleton attr_reader :logger @@ -188,11 +188,19 @@ module Middleman Encoding.default_external = config[:encoding] end - # Evaluate a passed block if given - @config_context.instance_exec(&block) if block_given? - config[:source] = ENV['MM_SOURCE'] if ENV['MM_SOURCE'] + # Built-in extensions + activate :default_helpers + activate :lorem + + if defined?(Middleman::CoreExtensions::Compass) + activate :compass + end + + # Evaluate a passed block if given + @config_context.instance_exec(&block) if block_given? + super end @@ -232,13 +240,3 @@ module Middleman end end - -Middleman::CoreExtensions::DefaultHelpers.activate - -Middleman::CoreExtensions::Internationalization.register(:i18n) - -if defined?(Middleman::CoreExtensions::Compass) - Middleman::CoreExtensions::Compass.activate -end - -Middleman::Extensions::Lorem.activate diff --git a/middleman-core/lib/middleman-core/core_extensions/data.rb b/middleman-core/lib/middleman-core/core_extensions/data.rb index 4ae83b6e..21961f5c 100644 --- a/middleman-core/lib/middleman-core/core_extensions/data.rb +++ b/middleman-core/lib/middleman-core/core_extensions/data.rb @@ -8,7 +8,7 @@ module Middleman # Extension registered class << self # @private - def registered(app) + def included(app) # Data formats require 'yaml' require 'active_support/json' @@ -16,7 +16,6 @@ module Middleman app.config.define_setting :data_dir, 'data', 'The directory data files are stored in' app.send :include, InstanceMethods end - alias :included :registered end # Instance methods diff --git a/middleman-core/lib/middleman-core/core_extensions/extensions.rb b/middleman-core/lib/middleman-core/core_extensions/extensions.rb index 3f028c08..4b1354b8 100644 --- a/middleman-core/lib/middleman-core/core_extensions/extensions.rb +++ b/middleman-core/lib/middleman-core/core_extensions/extensions.rb @@ -36,7 +36,7 @@ module Middleman # Register extension class << self # @private - def registered(app) + def included(app) app.define_hook :initialized app.define_hook :instance_available app.define_hook :after_configuration @@ -51,7 +51,6 @@ module Middleman app.send :include, InstanceMethods app.delegate :configure, :to => :"self.class" end - alias :included :registered end # Class methods @@ -70,18 +69,10 @@ module Middleman # @param [Hash] options Per-extension options hash # @return [void] def register(extension, options={}, &block) - if extension.instance_of?(Class) && extension.ancestors.include?(::Middleman::Extension) + if extension.ancestors.include?(::Middleman::Extension) extension.new(self, options, &block) else - extend extension - if extension.respond_to?(:registered) - if extension.method(:registered).arity === 1 - extension.registered(self, &block) - else - extension.registered(self, options, &block) - end - end - extension + $stderr.puts "!! Tried to register old-style extension: #{extension}" end end end @@ -97,32 +88,26 @@ module Middleman # @param [Symbol, Module] ext Which extension to activate # @return [void] def activate(ext, options={}, &block) - ext_module = if ext.is_a?(Module) - ext - else - ::Middleman::Extensions.load(ext) - end + if extension = ::Middleman::Extensions::registered[ext] + if extension.ancestors.include?(::Middleman::Extension) + logger.debug "== Activating: #{ext}" - if ext_module.nil? - logger.error "== Unknown Extension: #{ext}" - else - logger.debug "== Activating: #{ext}" - - if ext_module.instance_of? Module - extensions[ext] = self.class.register(ext_module, options, &block) - elsif ext_module.instance_of?(Class) && ext_module.ancestors.include?(::Middleman::Extension) - if ext_module.supports_multiple_instances? + if extension.supports_multiple_instances? extensions[ext] ||= {} key = "instance_#{extensions[ext].keys.length}" - extensions[ext][key] = ext_module.new(self.class, options, &block) + extensions[ext][key] = extension.new(self.class, options, &block) else if extensions[ext] logger.error "== #{ext} already activated." else - extensions[ext] = ext_module.new(self.class, options, &block) + extensions[ext] = extension.new(self.class, options, &block) end end + else + logger.error "!! Tried to activate old-style extension: #{ext}" end + else + logger.error "!! Unknown Extension: #{ext}" end end diff --git a/middleman-core/lib/middleman-core/core_extensions/external_helpers.rb b/middleman-core/lib/middleman-core/core_extensions/external_helpers.rb index 1a97e1a5..f30c0d3a 100644 --- a/middleman-core/lib/middleman-core/core_extensions/external_helpers.rb +++ b/middleman-core/lib/middleman-core/core_extensions/external_helpers.rb @@ -2,37 +2,31 @@ module Middleman module CoreExtensions module ExternalHelpers + # once registered + def self.included(app) + # Setup a default helpers paths + app.config.define_setting :helpers_dir, 'helpers', 'Directory to autoload helper modules from' + app.config.define_setting :helpers_filename_glob, '**.rb', 'Glob pattern for matching helper ruby files' + app.config.define_setting :helpers_filename_to_module_name_proc, Proc.new { |filename| + basename = File.basename(filename, File.extname(filename)) + basename.camelcase + }, 'Proc implementing the conversion from helper filename to module name' - # Setup extension - class << self + # After config + app.after_configuration do + helpers_path = File.join(root, config[:helpers_dir]) + next unless File.exists?(helpers_path) - # once registered - def registered(app) - # Setup a default helpers paths - app.config.define_setting :helpers_dir, 'helpers', 'Directory to autoload helper modules from' - app.config.define_setting :helpers_filename_glob, '**.rb', 'Glob pattern for matching helper ruby files' - app.config.define_setting :helpers_filename_to_module_name_proc, Proc.new { |filename| - basename = File.basename(filename, File.extname(filename)) - basename.camelcase - }, 'Proc implementing the conversion from helper filename to module name' + Dir[File.join(helpers_path, config[:helpers_filename_glob])].each do |filename| + module_name = config[:helpers_filename_to_module_name_proc].call(filename) + next unless module_name - # After config - app.after_configuration do - helpers_path = File.join(root, config[:helpers_dir]) - next unless File.exists?(helpers_path) + require filename + next unless Object.const_defined?(module_name.to_sym) - Dir[File.join(helpers_path, config[:helpers_filename_glob])].each do |filename| - module_name = config[:helpers_filename_to_module_name_proc].call(filename) - next unless module_name - - require filename - next unless Object.const_defined?(module_name.to_sym) - - helpers Object.const_get(module_name.to_sym) - end + helpers Object.const_get(module_name.to_sym) end end - alias :included :registered end end end diff --git a/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb b/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb index fbe39c1f..d0ebec77 100644 --- a/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb +++ b/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb @@ -1,6 +1,3 @@ -require 'pathname' -require 'set' - # API for watching file change events module Middleman module CoreExtensions @@ -27,7 +24,10 @@ module Middleman class << self # Once registered - def registered(app) + def included(app) + require 'pathname' + require 'set' + app.send :include, InstanceMethods app.config.define_setting :file_watcher_ignore, IGNORE_LIST, 'Regexes for paths that should be ignored when they change.' @@ -46,7 +46,6 @@ module Middleman files.reload_path('.') end end - alias :included :registered end # Instance methods diff --git a/middleman-core/lib/middleman-core/core_extensions/rendering.rb b/middleman-core/lib/middleman-core/core_extensions/rendering.rb index e326d2e1..0bde0104 100644 --- a/middleman-core/lib/middleman-core/core_extensions/rendering.rb +++ b/middleman-core/lib/middleman-core/core_extensions/rendering.rb @@ -15,7 +15,7 @@ module Middleman class << self # Once registered - def registered(app) + def included(app) # Include methods app.send :include, InstanceMethods @@ -29,65 +29,65 @@ module Middleman # Activate custom renderers require 'middleman-core/renderers/erb' - app.register Middleman::Renderers::ERb + app.send :include, Middleman::Renderers::ERb # CoffeeScript Support begin require 'middleman-core/renderers/coffee_script' - app.register Middleman::Renderers::CoffeeScript + app.send :include, Middleman::Renderers::CoffeeScript rescue LoadError end # Haml Support begin require 'middleman-core/renderers/haml' - app.register Middleman::Renderers::Haml + app.send :include, Middleman::Renderers::Haml rescue LoadError end # Sass Support begin require 'middleman-core/renderers/sass' - app.register Middleman::Renderers::Sass + app.send :include, Middleman::Renderers::Sass rescue LoadError end # Markdown Support require 'middleman-core/renderers/markdown' - app.register Middleman::Renderers::Markdown + app.send :include, Middleman::Renderers::Markdown # AsciiDoc Support begin require 'middleman-core/renderers/asciidoc' - app.register Middleman::Renderers::AsciiDoc + app.send :include, Middleman::Renderers::AsciiDoc rescue LoadError end # Liquid Support begin require 'middleman-core/renderers/liquid' - app.register Middleman::Renderers::Liquid + app.send :include, Middleman::Renderers::Liquid rescue LoadError end # Slim Support begin require 'middleman-core/renderers/slim' - app.register Middleman::Renderers::Slim + app.send :include, Middleman::Renderers::Slim rescue LoadError end # Less Support begin require 'middleman-core/renderers/less' - app.register Middleman::Renderers::Less + app.send :include, Middleman::Renderers::Less rescue LoadError end # Stylus Support begin require 'middleman-core/renderers/stylus' - app.register Middleman::Renderers::Stylus + app.send :include, Middleman::Renderers::Stylus rescue LoadError end @@ -102,8 +102,6 @@ module Middleman end end end - - alias :included :registered end # Custom error class for handling diff --git a/middleman-core/lib/middleman-core/core_extensions/request.rb b/middleman-core/lib/middleman-core/core_extensions/request.rb index fde29797..0447ff18 100644 --- a/middleman-core/lib/middleman-core/core_extensions/request.rb +++ b/middleman-core/lib/middleman-core/core_extensions/request.rb @@ -15,8 +15,7 @@ module Middleman # Extension registered class << self # @private - def registered(app) - + def included(app) # CSSPIE HTC File ::Rack::Mime::MIME_TYPES['.htc'] = 'text/x-component' @@ -32,7 +31,6 @@ module Middleman # Include instance methods app.send :include, InstanceMethods end - alias :included :registered end module ClassMethods diff --git a/middleman-core/lib/middleman-core/core_extensions/show_exceptions.rb b/middleman-core/lib/middleman-core/core_extensions/show_exceptions.rb index 60cac3e8..ed74cf88 100644 --- a/middleman-core/lib/middleman-core/core_extensions/show_exceptions.rb +++ b/middleman-core/lib/middleman-core/core_extensions/show_exceptions.rb @@ -1,26 +1,20 @@ -# Require lib -require 'rack/showexceptions' - # Support rack/showexceptions during development module Middleman module CoreExtensions module ShowExceptions + def self.included(app) + # Require lib + require 'rack/showexceptions' - # Setup extension - class << self + # Whether to catch and display exceptions + # @return [Boolean] + app.config.define_setting :show_exceptions, true, 'Whether to catch and display exceptions' - # Once registered - def registered(app) - # Whether to catch and display exceptions - # @return [Boolean] - app.config.define_setting :show_exceptions, true, 'Whether to catch and display exceptions' - - # When in dev - app.configure :development do - # Include middlemare - if config[:show_exceptions] - use ::Rack::ShowExceptions - end + # When in dev + app.configure :development do + # Include middlemare + if config[:show_exceptions] + use ::Rack::ShowExceptions end end end diff --git a/middleman-core/lib/middleman-core/extension.rb b/middleman-core/lib/middleman-core/extension.rb new file mode 100644 index 00000000..ec02bb8f --- /dev/null +++ b/middleman-core/lib/middleman-core/extension.rb @@ -0,0 +1,149 @@ +module Middleman + class Extension + class_attribute :supports_multiple_instances, :instance_reader => false, :instance_writer => false + class_attribute :defined_helpers, :instance_reader => false, :instance_writer => false + class_attribute :ext_name, :instance_reader => false, :instance_writer => false + + class << self + def config + @_config ||= ::Middleman::Configuration::ConfigurationManager.new + end + + def option(key, default=nil, description=nil) + config.define_setting(key, default, description) + end + + # Add helpers to the global Middleman application. + # This accepts either a list of modules to add on behalf + # of this extension, or a block whose contents will all + # be used as helpers in a new module. + def helpers(*m, &block) + self.defined_helpers ||= [] + + if block + mod = Module.new + mod.module_eval(&block) + m = [mod] + end + + self.defined_helpers += m + end + + def extension_name + self.ext_name || self.name.underscore.split('/').last.to_sym + end + + def register(n=self.extension_name) + ::Middleman::Extensions.register(n, self) + end + + def activate + new(::Middleman::Application) + end + + def clear_after_extension_callbacks + @_extension_activation_callbacks = {} + end + + def after_extension_activated(name, &block) + @_extension_activation_callbacks ||= {} + @_extension_activation_callbacks[name] ||= [] + @_extension_activation_callbacks[name] << block if block_given? + end + + def activated_extension(instance) + name = instance.class.extension_name + return unless @_extension_activation_callbacks && @_extension_activation_callbacks[name] + @_extension_activation_callbacks[name].each do |block| + block.arity == 1 ? block.call(instance) : block.call() + end + end + end + + attr_accessor :options + attr_reader :app + + delegate :after_extension_activated, :to => :"::Middleman::Extension" + + def initialize(klass, options_hash={}, &block) + @_helpers = [] + @klass = klass + + setup_options(options_hash, &block) + setup_app_reference_when_available + + # Bind app hooks to local methods + bind_before_configuration + bind_after_configuration + bind_after_build + end + + def app=(app) + @app = app + + (self.class.defined_helpers || []).each do |m| + app.class.send(:include, m) + end + end + + protected + + def setup_options(options_hash, &block) + @options = self.class.config.dup + @options.finalize! + + options_hash.each do |k, v| + @options[k] = v + end + + yield @options if block_given? + end + + def setup_app_reference_when_available + ext = self + + @klass.initialized do + ext.app = self + end + + @klass.instance_available do + ext.app ||= self + end + end + + def bind_before_configuration + ext = self + if ext.respond_to?(:before_configuration) + @klass.before_configuration do + ext.before_configuration + end + end + end + + def bind_after_configuration + ext = self + @klass.after_configuration do + if ext.respond_to?(:after_configuration) + ext.after_configuration + end + + if ext.respond_to?(:manipulate_resource_list) + ext.app.sitemap.register_resource_list_manipulator(ext.class.extension_name, ext) + end + end + end + + def bind_after_build + ext = self + if ext.respond_to?(:after_build) + @klass.after_build do |builder| + if ext.method(:after_build).arity === 1 + ext.after_build(builder) + else + ext.after_build + end + end + end + end + end +end diff --git a/middleman-core/lib/middleman-core/extensions.rb b/middleman-core/lib/middleman-core/extensions.rb index 2c97fea0..150a5c53 100644 --- a/middleman-core/lib/middleman-core/extensions.rb +++ b/middleman-core/lib/middleman-core/extensions.rb @@ -20,35 +20,11 @@ module Middleman # # @param [Symbol] name The name of the extension # @param [Module] namespace The extension module - # @yield Instead of passing a module in namespace, you can provide - # a block which returns your extension module. This gives - # you the ability to require other files only when the - # extension is activated. - def register(name, namespace=nil, &block) - # If we've already got a matching extension that passed the - # version check, bail out. - return if registered.has_key?(name.to_sym) && - !registered[name.to_sym].is_a?(String) - - registered[name.to_sym] = if block_given? - block - elsif namespace - namespace + def register(name, namespace) + if !registered.has_key?(name.to_sym) + registered[name.to_sym] = namespace end end - - def load(name) - name = name.to_sym - return nil unless registered.has_key?(name) - - extension = registered[name] - if extension.is_a?(Proc) - extension = extension.call() || nil - registered[name] = extension - end - - extension - end end end @@ -98,152 +74,6 @@ module Middleman File.exists?(full_path) end end - - class Extension - class_attribute :supports_multiple_instances, :instance_reader => false, :instance_writer => false - class_attribute :defined_helpers, :instance_reader => false, :instance_writer => false - class_attribute :ext_name, :instance_reader => false, :instance_writer => false - - class << self - def config - @_config ||= ::Middleman::Configuration::ConfigurationManager.new - end - - def option(key, default=nil, description=nil) - config.define_setting(key, default, description) - end - - # Add helpers to the global Middleman application. - # This accepts either a list of modules to add on behalf - # of this extension, or a block whose contents will all - # be used as helpers in a new module. - def helpers(*m, &block) - self.defined_helpers ||= [] - - if block - mod = Module.new - mod.module_eval(&block) - m = [mod] - end - - self.defined_helpers += m - end - - def extension_name - self.ext_name || self.name.underscore.split('/').last.to_sym - end - - def register(n=self.extension_name) - ::Middleman::Extensions.register(n, self) - end - - def activate - new(::Middleman::Application) - end - - def clear_after_extension_callbacks - @_extension_activation_callbacks = {} - end - - def after_extension_activated(name, &block) - @_extension_activation_callbacks ||= {} - @_extension_activation_callbacks[name] ||= [] - @_extension_activation_callbacks[name] << block if block_given? - end - - def activated_extension(instance) - name = instance.class.extension_name - return unless @_extension_activation_callbacks && @_extension_activation_callbacks[name] - @_extension_activation_callbacks[name].each do |block| - block.arity == 1 ? block.call(instance) : block.call() - end - end - end - - attr_accessor :options - attr_reader :app - - delegate :after_extension_activated, :to => :"::Middleman::Extension" - - def initialize(klass, options_hash={}, &block) - @_helpers = [] - @klass = klass - - setup_options(options_hash, &block) - setup_app_reference_when_available - - # Bind app hooks to local methods - bind_before_configuration - bind_after_configuration - bind_after_build - end - - def app=(app) - @app = app - - (self.class.defined_helpers || []).each do |m| - app.class.send(:include, m) - end - end - - protected - - def setup_options(options_hash, &block) - @options = self.class.config.dup - @options.finalize! - - options_hash.each do |k, v| - @options[k] = v - end - - yield @options if block_given? - end - - def setup_app_reference_when_available - ext = self - - @klass.initialized do - ext.app = self - end - - @klass.instance_available do - ext.app ||= self - end - end - - def bind_before_configuration - ext = self - if ext.respond_to?(:before_configuration) - @klass.before_configuration do - ext.before_configuration - end - end - end - - def bind_after_configuration - ext = self - @klass.after_configuration do - if ext.respond_to?(:after_configuration) - ext.after_configuration - end - - if ext.respond_to?(:manipulate_resource_list) - ext.app.sitemap.register_resource_list_manipulator(ext.class.extension_name, ext) - end - end - end - - def bind_after_build - ext = self - if ext.respond_to?(:after_build) - @klass.after_build do |builder| - if ext.method(:after_build).arity === 1 - ext.after_build(builder) - else - ext.after_build - end - end - end - end - end end + +require 'middleman-core/extension' \ No newline at end of file diff --git a/middleman-core/lib/middleman-core/sitemap.rb b/middleman-core/lib/middleman-core/sitemap.rb index 389ef5c4..9bceb950 100644 --- a/middleman-core/lib/middleman-core/sitemap.rb +++ b/middleman-core/lib/middleman-core/sitemap.rb @@ -7,7 +7,7 @@ module Middleman class << self # Once registered - def registered(app) + def included(app) # Set to automatically convert some characters into a directory app.config.define_setting :automatic_directory_matcher, nil, 'Set to automatically convert some characters into a directory' @@ -33,7 +33,6 @@ module Middleman # Include instance methods app.send :include, InstanceMethods end - alias :included :registered end diff --git a/middleman-core/lib/middleman-more/core_extensions/compass.rb b/middleman-core/lib/middleman-more/core_extensions/compass.rb index 366d6196..b46b7639 100644 --- a/middleman-core/lib/middleman-more/core_extensions/compass.rb +++ b/middleman-core/lib/middleman-more/core_extensions/compass.rb @@ -1,11 +1,12 @@ require 'middleman-core/renderers/sass' -require 'compass' class Middleman::CoreExtensions::Compass < ::Middleman::Extension def initialize(app, options_hash={}, &block) super + require 'compass' + # Hooks to manually update the compass config after we're # done with it app.define_hook :compass_config @@ -72,4 +73,6 @@ class Middleman::CoreExtensions::Compass < ::Middleman::Extension super.merge(::Compass.configuration.to_sass_engine_options) end end -end \ No newline at end of file +end + +Middleman::CoreExtensions::Compass.register diff --git a/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb b/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb index b3120bb6..64b11911 100644 --- a/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb +++ b/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb @@ -248,3 +248,5 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension end end end + +Middleman::CoreExtensions::DefaultHelpers.register \ No newline at end of file diff --git a/middleman-core/lib/middleman-more/core_extensions/i18n.rb b/middleman-core/lib/middleman-more/core_extensions/i18n.rb index 6f0b0e1c..24787a04 100644 --- a/middleman-core/lib/middleman-more/core_extensions/i18n.rb +++ b/middleman-core/lib/middleman-more/core_extensions/i18n.rb @@ -209,3 +209,5 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension end end end + +Middleman::CoreExtensions::Internationalization.register(:i18n) diff --git a/middleman-core/lib/middleman-more/extensions/lorem.rb b/middleman-core/lib/middleman-more/extensions/lorem.rb index d13abeeb..a69454c6 100644 --- a/middleman-core/lib/middleman-more/extensions/lorem.rb +++ b/middleman-core/lib/middleman-more/extensions/lorem.rb @@ -174,3 +174,5 @@ class Middleman::Extensions::Lorem < ::Middleman::Extension end end end + +Middleman::Extensions::Lorem.register \ No newline at end of file From 42fb8c229af580f86fe1ae568fcacb31975ddc16 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Wed, 1 Jan 2014 18:08:30 -0800 Subject: [PATCH 004/580] bump version --- middleman-core/lib/middleman-core/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/middleman-core/lib/middleman-core/version.rb b/middleman-core/lib/middleman-core/version.rb index e0bac425..08c45048 100644 --- a/middleman-core/lib/middleman-core/version.rb +++ b/middleman-core/lib/middleman-core/version.rb @@ -1,5 +1,5 @@ module Middleman # Current Version # @return [String] - VERSION = '3.2.1' unless const_defined?(:VERSION) + VERSION = '4.0.0.pre.0' unless const_defined?(:VERSION) end From 0a288131c10ee3ea5dea69d0add1154c5a046ef1 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Wed, 1 Jan 2014 18:09:19 -0800 Subject: [PATCH 005/580] changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a660954..cb9e9dbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ master === +* Remove old module-style extension support +* Placed all `config.rb` evaluation inside the `ConfigContext` class + 3.2.1 === From 95eaeba960b52aae3f3352c020d75e1a5238291a Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Wed, 1 Jan 2014 19:09:47 -0800 Subject: [PATCH 006/580] Start cleaning up Rack internals --- CHANGELOG.md | 1 + ...urrent_page_request_path_backwards.feature | 6 ------ .../features/request_params.feature | 6 ------ .../fixtures/current-page-app/config.rb | 3 --- .../source/request-path.html.erb | 1 - middleman-core/fixtures/request-app/config.rb | 0 .../request-app/source/index.html.erb | 3 --- .../middleman-core/core_extensions/request.rb | 20 +------------------ 8 files changed, 2 insertions(+), 38 deletions(-) delete mode 100644 middleman-core/features/current_page_request_path_backwards.feature delete mode 100644 middleman-core/features/request_params.feature delete mode 100644 middleman-core/fixtures/current-page-app/config.rb delete mode 100644 middleman-core/fixtures/current-page-app/source/request-path.html.erb delete mode 100644 middleman-core/fixtures/request-app/config.rb delete mode 100644 middleman-core/fixtures/request-app/source/index.html.erb diff --git a/CHANGELOG.md b/CHANGELOG.md index cb9e9dbb..e75ecd71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ master === +* Remove deprecated `request` instance * Remove old module-style extension support * Placed all `config.rb` evaluation inside the `ConfigContext` class diff --git a/middleman-core/features/current_page_request_path_backwards.feature b/middleman-core/features/current_page_request_path_backwards.feature deleted file mode 100644 index 41853e75..00000000 --- a/middleman-core/features/current_page_request_path_backwards.feature +++ /dev/null @@ -1,6 +0,0 @@ -Feature: Support old request.path object used by many extensions - - Scenario: Viewing the root path - Given the Server is running at "current-page-app" - When I go to "/request-path.html" - Then I should see "true" \ No newline at end of file diff --git a/middleman-core/features/request_params.feature b/middleman-core/features/request_params.feature deleted file mode 100644 index 968d0bfc..00000000 --- a/middleman-core/features/request_params.feature +++ /dev/null @@ -1,6 +0,0 @@ -Feature: Support request parameters - Scenario: Use request params in a template - Given the Server is running at "request-app" - When I go to "/index.html?say=Hello+World" - Then I should see "Quote Hello World" - Then I should see "Symbol Hello World" diff --git a/middleman-core/fixtures/current-page-app/config.rb b/middleman-core/fixtures/current-page-app/config.rb deleted file mode 100644 index dc0297e1..00000000 --- a/middleman-core/fixtures/current-page-app/config.rb +++ /dev/null @@ -1,3 +0,0 @@ -with_layout false do - page "/request-path.html" -end diff --git a/middleman-core/fixtures/current-page-app/source/request-path.html.erb b/middleman-core/fixtures/current-page-app/source/request-path.html.erb deleted file mode 100644 index cb134235..00000000 --- a/middleman-core/fixtures/current-page-app/source/request-path.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= current_path == request.path %> \ No newline at end of file diff --git a/middleman-core/fixtures/request-app/config.rb b/middleman-core/fixtures/request-app/config.rb deleted file mode 100644 index e69de29b..00000000 diff --git a/middleman-core/fixtures/request-app/source/index.html.erb b/middleman-core/fixtures/request-app/source/index.html.erb deleted file mode 100644 index f87a2bd9..00000000 --- a/middleman-core/fixtures/request-app/source/index.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -Dot <%= request.params.say %> -Quote <%= request.params["say"] %> -Symbol <%= request.params[:say] %> diff --git a/middleman-core/lib/middleman-core/core_extensions/request.rb b/middleman-core/lib/middleman-core/core_extensions/request.rb index 0447ff18..352dc557 100644 --- a/middleman-core/lib/middleman-core/core_extensions/request.rb +++ b/middleman-core/lib/middleman-core/core_extensions/request.rb @@ -151,10 +151,6 @@ module Middleman # Methods to be mixed-in to Middleman::Application module InstanceMethods - # Backwards-compatibility with old request.path signature - def request - Thread.current[:legacy_request] - end # Accessor for current path # @return [String] @@ -168,24 +164,11 @@ module Middleman # @return [void] def current_path=(path) Thread.current[:current_path] = path - Thread.current[:legacy_request] = ::Thor::CoreExt::HashWithIndifferentAccess.new({ - :path => path, - :params => req ? ::Thor::CoreExt::HashWithIndifferentAccess.new(req.params) : {} - }) end delegate :use, :to => :"self.class" delegate :map, :to => :"self.class" - # Rack request - # @return [Rack::Request] - def req - Thread.current[:req] - end - def req=(value) - Thread.current[:req] = value - end - def call(env) dup.call!(env) end @@ -195,7 +178,7 @@ module Middleman # @param env Rack environment def call!(env) # Store environment, request and response for later - self.req = req = ::Rack::Request.new(env) + req = ::Rack::Request.new(env) res = ::Rack::Response.new logger.debug "== Request: #{env["PATH_INFO"]}" @@ -253,7 +236,6 @@ module Middleman begin # Write out the contents of the page output = resource.render do - self.req = req self.current_path = current_path end From d77ef04774e711c8e731f2608718c0a29c2742d4 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Thu, 2 Jan 2014 14:38:18 -0800 Subject: [PATCH 007/580] upgrade to newest activesupport --- middleman-core/lib/middleman-core/application.rb | 1 - middleman-core/lib/middleman-core/logger.rb | 4 ++-- middleman-core/middleman-core.gemspec | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb index 2d31d870..625e974e 100644 --- a/middleman-core/lib/middleman-core/application.rb +++ b/middleman-core/lib/middleman-core/application.rb @@ -11,7 +11,6 @@ require 'i18n' # Use ActiveSupport JSON require 'active_support/json' require 'active_support/core_ext/integer/inflections' -require 'active_support/core_ext/float/rounding' # Simple callback library require 'vendored-middleman-deps/hooks-0.2.0/lib/hooks' diff --git a/middleman-core/lib/middleman-core/logger.rb b/middleman-core/lib/middleman-core/logger.rb index d8b23c9f..3ab3581e 100644 --- a/middleman-core/lib/middleman-core/logger.rb +++ b/middleman-core/lib/middleman-core/logger.rb @@ -1,12 +1,12 @@ # Use the Ruby/Rails logger require 'active_support/notifications' -require 'active_support/buffered_logger' +require 'active_support/logger' require 'thread' module Middleman # The Middleman Logger - class Logger < ActiveSupport::BufferedLogger + class Logger < ActiveSupport::Logger def self.singleton(*args) if !@_logger || args.length > 0 diff --git a/middleman-core/middleman-core.gemspec b/middleman-core/middleman-core.gemspec index 954a2325..3e56b1d6 100644 --- a/middleman-core/middleman-core.gemspec +++ b/middleman-core/middleman-core.gemspec @@ -30,7 +30,7 @@ Gem::Specification.new do |s| s.add_dependency("thor", [">= 0.15.2", "< 2.0"]) # Helpers - s.add_dependency("activesupport", ["~> 3.2.6"]) + s.add_dependency("activesupport", ["~> 4.0.1"]) # Watcher s.add_dependency("listen", ["~> 1.1"]) From 5afa66f194af47b7e9765281bb5ab74b2bbf8838 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Thu, 2 Jan 2014 14:48:40 -0800 Subject: [PATCH 008/580] bump deps 1 --- middleman-core/middleman-core.gemspec | 6 +++--- middleman/middleman.gemspec | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/middleman-core/middleman-core.gemspec b/middleman-core/middleman-core.gemspec index 3e56b1d6..4dd98a8e 100644 --- a/middleman-core/middleman-core.gemspec +++ b/middleman-core/middleman-core.gemspec @@ -24,16 +24,16 @@ Gem::Specification.new do |s| s.add_dependency("tilt", ["~> 1.4.1"]) # Builder - s.add_dependency("rack-test", ["~> 0.6.1"]) + s.add_dependency("rack-test", ["~> 0.6.2"]) # CLI - s.add_dependency("thor", [">= 0.15.2", "< 2.0"]) + s.add_dependency("thor", [">= 0.17.0", "< 2.0"]) # Helpers s.add_dependency("activesupport", ["~> 4.0.1"]) # Watcher - s.add_dependency("listen", ["~> 1.1"]) + s.add_dependency("listen", ["~> 1.3"]) # i18n s.add_dependency("i18n", ["~> 0.6.9"]) diff --git a/middleman/middleman.gemspec b/middleman/middleman.gemspec index 0c44da8a..dcbbd21f 100644 --- a/middleman/middleman.gemspec +++ b/middleman/middleman.gemspec @@ -23,8 +23,8 @@ Gem::Specification.new do |s| s.add_dependency("haml", [">= 3.1.6"]) s.add_dependency("sass", [">= 3.1.20"]) s.add_dependency("compass", [">= 0.12.2"]) - s.add_dependency("uglifier", ["~> 2.1.0"]) + s.add_dependency("uglifier", ["~> 2.4.0"]) s.add_dependency("coffee-script", ["~> 2.2.0"]) - s.add_dependency("execjs", ["~> 1.4.0"]) + s.add_dependency("execjs", ["~> 2.0.2"]) s.add_dependency("kramdown", ["~> 1.2"]) end From 9798f152ca83445c75f8fafbfead16bcbef63a95 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Thu, 2 Jan 2014 14:59:14 -0800 Subject: [PATCH 009/580] silence slim warnings --- middleman-core/lib/middleman-core/renderers/slim.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/middleman-core/lib/middleman-core/renderers/slim.rb b/middleman-core/lib/middleman-core/renderers/slim.rb index 55457f3b..bd22d357 100644 --- a/middleman-core/lib/middleman-core/renderers/slim.rb +++ b/middleman-core/lib/middleman-core/renderers/slim.rb @@ -29,10 +29,9 @@ module Middleman :context => self } - slim_embedded = defined?(::Slim::Embedded) ? ::Slim::Embedded : ::Slim::EmbeddedEngine - + ::Slim::Embedded::SassEngine.disable_option_validator! %w(sass scss markdown).each do |engine| - slim_embedded.default_options[engine.to_sym] = context_hack + ::Slim::Embedded.default_options[engine.to_sym] = context_hack end end end From 305d2f99edc0d228e18fe67632f73efe66567ccf Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Wed, 1 Jan 2014 21:19:05 -0800 Subject: [PATCH 010/580] Put template rendering in a jail --- .travis.yml | 1 + .../lib/middleman-core/application.rb | 16 +-- .../lib/middleman-core/config_context.rb | 20 ++- .../core_extensions/extensions.rb | 5 + .../core_extensions/external_helpers.rb | 2 +- .../core_extensions/front_matter.rb | 12 +- .../core_extensions/rendering.rb | 131 +++--------------- .../lib/middleman-core/extension.rb | 9 +- .../lib/middleman-core/renderers/haml.rb | 30 +++- .../lib/middleman-core/renderers/kramdown.rb | 8 +- .../lib/middleman-core/renderers/markdown.rb | 2 - .../lib/middleman-core/renderers/redcarpet.rb | 14 +- .../lib/middleman-core/renderers/sass.rb | 2 +- middleman-core/lib/middleman-core/sitemap.rb | 2 +- .../lib/middleman-core/template_context.rb | 105 ++++++++++++++ .../core_extensions/default_helpers.rb | 35 +++-- .../lib/middleman-more/extensions/gzip.rb | 8 +- 17 files changed, 233 insertions(+), 169 deletions(-) create mode 100644 middleman-core/lib/middleman-core/template_context.rb diff --git a/.travis.yml b/.travis.yml index d10d9c65..520228b1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ matrix: fast_finish: true allow_failures: - rvm: ruby-head + - rvm: 2.1.0 - rvm: jruby-19mode env: TEST=true before_install: git submodule update --init --recursive diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb index 625e974e..4103c2b2 100644 --- a/middleman-core/lib/middleman-core/application.rb +++ b/middleman-core/lib/middleman-core/application.rb @@ -44,15 +44,6 @@ module Middleman # Runs after the build is finished define_hook :after_build - # Mix-in helper methods. Accepts either a list of Modules - # and/or a block to be evaluated - # @return [void] - def self.helpers(*extensions, &block) - class_eval(&block) if block_given? - include(*extensions) if extensions.any? - end - delegate :helpers, :to => :"self.class" - # Root project directory (overwritten in middleman build/server) # @return [String] def self.root @@ -170,11 +161,16 @@ module Middleman # Template cache attr_reader :cache + attr_reader :generic_template_context + delegate :link_to, :image_tag, :to => :generic_template_context + # Initialize the Middleman project def initialize(&block) @cache = ::Tilt::Cache.new @logger = ::Middleman::Logger.singleton - @config_context = ConfigContext.new(self) + @template_context_class = Class.new(Middleman::TemplateContext) + @generic_template_context = @template_context_class.new(self) + @config_context = ConfigContext.new(self, @template_context_class) # Setup the default values from calls to set before initialization self.class.config.load_settings(self.class.superclass.config.all_settings) diff --git a/middleman-core/lib/middleman-core/config_context.rb b/middleman-core/lib/middleman-core/config_context.rb index 358dc9f2..40e7ef88 100644 --- a/middleman-core/lib/middleman-core/config_context.rb +++ b/middleman-core/lib/middleman-core/config_context.rb @@ -6,16 +6,32 @@ module Middleman attr_reader :app # Whitelist methods that can reach out. - delegate :config, :logger, :activate, :use, :map, :mime_type, :data, :helpers, :template_extensions, :root, :to => :app + delegate :config, :logger, :activate, :use, :map, :mime_type, :data, :template_extensions, :root, :to => :app - def initialize(app) + def initialize(app, template_context_class) @app = app + @template_context_class = template_context_class + @ready_callbacks = [] @after_build_callbacks = [] @after_configuration_callbacks = [] @configure_callbacks = {} end + def helpers(*helper_modules, &block) + helper_modules ||= [] + + if block_given? + block_module = Module.new + block_module.module_eval(&block) + helper_modules << block_module + end + + helper_modules.each do |mod| + @template_context_class.send :include, mod + end + end + def ready(&block) @ready_callbacks << block end diff --git a/middleman-core/lib/middleman-core/core_extensions/extensions.rb b/middleman-core/lib/middleman-core/core_extensions/extensions.rb index 4b1354b8..9dfea24c 100644 --- a/middleman-core/lib/middleman-core/core_extensions/extensions.rb +++ b/middleman-core/lib/middleman-core/core_extensions/extensions.rb @@ -182,6 +182,11 @@ module Middleman end if klass.is_a?(::Middleman::Extension) + # Forward Extension helpers to TemplateContext + (klass.class.defined_helpers || []).each do |m| + @template_context_class.send(:include, m) + end + ::Middleman::Extension.activated_extension(klass) end end diff --git a/middleman-core/lib/middleman-core/core_extensions/external_helpers.rb b/middleman-core/lib/middleman-core/core_extensions/external_helpers.rb index f30c0d3a..8cc5022e 100644 --- a/middleman-core/lib/middleman-core/core_extensions/external_helpers.rb +++ b/middleman-core/lib/middleman-core/core_extensions/external_helpers.rb @@ -24,7 +24,7 @@ module Middleman require filename next unless Object.const_defined?(module_name.to_sym) - helpers Object.const_get(module_name.to_sym) + @template_context_class.send :include, Object.const_get(module_name.to_sym) end end end diff --git a/middleman-core/lib/middleman-core/core_extensions/front_matter.rb b/middleman-core/lib/middleman-core/core_extensions/front_matter.rb index 87f0f9cb..d967e204 100644 --- a/middleman-core/lib/middleman-core/core_extensions/front_matter.rb +++ b/middleman-core/lib/middleman-core/core_extensions/front_matter.rb @@ -81,13 +81,11 @@ module Middleman::CoreExtensions end end - helpers do - # Get the template data from a path - # @param [String] path - # @return [String] - def template_data_for_file(path) - extensions[:frontmatter].data(path).last - end + # Get the template data from a path + # @param [String] path + # @return [String] + def template_data_for_file(path) + data(path).last end def data(path) diff --git a/middleman-core/lib/middleman-core/core_extensions/rendering.rb b/middleman-core/lib/middleman-core/core_extensions/rendering.rb index 0bde0104..734b9195 100644 --- a/middleman-core/lib/middleman-core/core_extensions/rendering.rb +++ b/middleman-core/lib/middleman-core/core_extensions/rendering.rb @@ -1,13 +1,8 @@ -# Shutup Tilt Warnings -# @private -class Tilt::Template - def warn(*args) - # Kernel.warn(*args) - end -end +require 'middleman-core/template_context' # Rendering extension module Middleman + module CoreExtensions module Rendering @@ -136,16 +131,17 @@ module Middleman ::I18n.locale = opts[:lang] if opts[:lang] end - # Use a dup of self as a context so that instance variables set within - # the template don't persist for other templates. - context = self.dup + # Sandboxed class for template eval + context = @template_context_class.new(self, locs, opts) + + if context.respond_to?(:init_haml_helpers) + context.init_haml_helpers + end + blocks.each do |block| context.instance_eval(&block) end - # Store current locs/opts for later - @current_locs = locs, @current_opts = opts - # Keep rendering template until we've used up all extensions. This # handles cases like `style.css.sass.erb` content = nil @@ -170,60 +166,6 @@ module Middleman # Pop all the saved variables from earlier as we may be returning to a # previous render (layouts, partials, nested layouts). ::I18n.locale = old_locale if defined?(::I18n) - @content_blocks = nil - @current_locs = nil - @current_opts = nil - end - - # Sinatra/Padrino compatible render method signature referenced by some view - # helpers. Especially partials. - # - # @param [String, Symbol] engine - # @param [String, Symbol] data - # @param [Hash] options - # @return [String] - def render(engine, data, options={}, &block) - data = data.to_s - - locals = options[:locals] - - found_partial = false - engine = nil - - # If the path is known to the sitemap - if resource = sitemap.find_resource_by_path(current_path) - current_dir = File.dirname(resource.source_file) - engine = File.extname(resource.source_file)[1..-1].to_sym - - # Look for partials relative to the current path - relative_dir = File.join(current_dir.sub(%r{^#{Regexp.escape(self.source_dir)}/?}, ''), data) - - # Try to use the current engine first - found_partial, found_engine = resolve_template(relative_dir, :preferred_engine => engine, :try_without_underscore => true) - - # Fall back to any engine available - if !found_partial - found_partial, found_engine = resolve_template(relative_dir, :try_without_underscore => true) - end - end - - # Look in the partials_dir for the partial with the current engine - partials_path = File.join(config[:partials_dir], data) - if !found_partial && !engine.nil? - found_partial, found_engine = resolve_template(partials_path, :preferred_engine => engine, :try_without_underscore => true) - end - - # Look in the root with any engine - if !found_partial - found_partial, found_engine = resolve_template(partials_path, :try_without_underscore => true) - end - - # Render the partial if found, otherwide throw exception - if found_partial - render_individual_file(found_partial, locals, options, self, &block) - else - raise ::Middleman::CoreExtensions::Rendering::TemplateNotFound, "Could not locate partial: #{data}" - end end # Render an on-disk file. Used for everything, including layouts. @@ -233,7 +175,7 @@ module Middleman # @param [Hash] opts # @param [Class] context # @return [String] - def render_individual_file(path, locs = {}, opts = {}, context = self, &block) + def render_individual_file(path, locs = {}, opts = {}, context, &block) path = path.to_s # Detect the remdering engine from the extension @@ -244,7 +186,7 @@ module Middleman context.current_engine, engine_was = engine, context.current_engine # Save current buffer for later - @_out_buf, _buf_was = '', @_out_buf + _buf_was = context.save_buffer # Read from disk or cache the contents of the file body = if opts[:template_body] @@ -287,7 +229,7 @@ module Middleman output ensure # Reset stored buffer - @_out_buf = _buf_was + context.restore_buffer(_buf_was) context.current_engine = engine_was end @@ -295,7 +237,11 @@ module Middleman # @param [String] path # @return [String] def template_data_for_file(path) - File.read(File.expand_path(path, source_dir)) + if extensions[:frontmatter] + extensions[:frontmatter].template_data_for_file(path) + else + File.read(File.expand_path(path, source_dir)) + end end # Get a hash of configuration options for a given file extension, from @@ -393,49 +339,6 @@ module Middleman layout_path end - # Allow layouts to be wrapped in the contents of other layouts - # @param [String, Symbol] layout_name - # @return [void] - def wrap_layout(layout_name, &block) - # Save current buffer for later - @_out_buf, _buf_was = '', @_out_buf - - layout_path = locate_layout(layout_name, self.current_engine) - - extension = File.extname(layout_path) - engine = extension[1..-1].to_sym - - # Store last engine for later (could be inside nested renders) - self.current_engine, engine_was = engine, self.current_engine - - begin - content = if block_given? - capture_html(&block) - else - '' - end - ensure - # Reset stored buffer - @_out_buf = _buf_was - end - - concat_safe_content render_individual_file(layout_path, @current_locs || {}, @current_opts || {}, self) { content } - ensure - self.current_engine = engine_was - end - - # The currently rendering engine - # @return [Symbol, nil] - def current_engine - @_current_engine ||= nil - end - - # The currently rendering engine - # @return [Symbol, nil] - def current_engine=(v) - @_current_engine = v - end - # Find a template on disk given a output path # @param [String] request_path # @param [Hash] options diff --git a/middleman-core/lib/middleman-core/extension.rb b/middleman-core/lib/middleman-core/extension.rb index ec02bb8f..78179afe 100644 --- a/middleman-core/lib/middleman-core/extension.rb +++ b/middleman-core/lib/middleman-core/extension.rb @@ -20,7 +20,7 @@ module Middleman def helpers(*m, &block) self.defined_helpers ||= [] - if block + if block_given? mod = Module.new mod.module_eval(&block) m = [mod] @@ -81,8 +81,11 @@ module Middleman def app=(app) @app = app - (self.class.defined_helpers || []).each do |m| - app.class.send(:include, m) + ext = self + if ext.respond_to?(:instance_available) + @klass.instance_available do + ext.instance_available + end end end diff --git a/middleman-core/lib/middleman-core/renderers/haml.rb b/middleman-core/lib/middleman-core/renderers/haml.rb index 5d68d568..e26ba812 100644 --- a/middleman-core/lib/middleman-core/renderers/haml.rb +++ b/middleman-core/lib/middleman-core/renderers/haml.rb @@ -4,24 +4,42 @@ require 'haml' module Middleman module Renderers + # Haml precompiles filters before the scope is even available, + # thus making it impossible to pass our Middleman instance + # in. So we have to resort to heavy hackery :( + class HamlTemplate < ::Tilt::HamlTemplate + def prepare + end + + def evaluate(scope, locals, &block) + ::Middleman::Renderers::Haml.last_haml_scope = scope + + options = @options.merge(:filename => eval_file, :line => line) + @engine = ::Haml::Engine.new(data, options) + output = @engine.render(scope, locals, &block) + + ::Middleman::Renderers::Haml.last_haml_scope = nil + + output + end + end + # Haml Renderer module Haml + mattr_accessor :last_haml_scope # Setup extension class << self # Once registered def registered(app) + ::Tilt.prefer(::Middleman::Renderers::HamlTemplate, 'haml') + app.before_configuration do template_extensions :haml => :html end # Add haml helpers to context - app.send :include, ::Haml::Helpers - - # Setup haml helper paths - app.ready do - init_haml_helpers - end + ::Middleman::TemplateContext.send :include, ::Haml::Helpers end alias :included :registered end diff --git a/middleman-core/lib/middleman-core/renderers/kramdown.rb b/middleman-core/lib/middleman-core/renderers/kramdown.rb index bccfea76..d5e5757c 100644 --- a/middleman-core/lib/middleman-core/renderers/kramdown.rb +++ b/middleman-core/lib/middleman-core/renderers/kramdown.rb @@ -7,6 +7,8 @@ module Middleman class KramdownTemplate < ::Tilt::KramdownTemplate def evaluate(scope, locals, &block) @output ||= begin + MiddlemanKramdownHTML.scope = ::Middleman::Renderers::Haml.last_haml_scope || scope + output, warnings = MiddlemanKramdownHTML.convert(@engine.root, @engine.options) @engine.warnings.concat(warnings) output @@ -16,13 +18,13 @@ module Middleman # Custom Kramdown renderer that uses our helpers for images and links class MiddlemanKramdownHTML < ::Kramdown::Converter::Html - cattr_accessor :middleman_app + cattr_accessor :scope def convert_img(el, indent) attrs = el.attr.dup link = attrs.delete('src') - middleman_app.image_tag(link, attrs) + scope.image_tag(link, attrs) end def convert_a(el, indent) @@ -37,7 +39,7 @@ module Middleman attr = el.attr.dup link = attr.delete('href') - middleman_app.link_to(content, link, attr) + scope.link_to(content, link, attr) end end end diff --git a/middleman-core/lib/middleman-core/renderers/markdown.rb b/middleman-core/lib/middleman-core/renderers/markdown.rb index 61e22b17..00fdd8bb 100644 --- a/middleman-core/lib/middleman-core/renderers/markdown.rb +++ b/middleman-core/lib/middleman-core/renderers/markdown.rb @@ -30,11 +30,9 @@ module Middleman if config[:markdown_engine] == :redcarpet require 'middleman-core/renderers/redcarpet' ::Tilt.prefer(::Middleman::Renderers::RedcarpetTemplate, *markdown_exts) - MiddlemanRedcarpetHTML.middleman_app = self elsif config[:markdown_engine] == :kramdown require 'middleman-core/renderers/kramdown' ::Tilt.prefer(::Middleman::Renderers::KramdownTemplate, *markdown_exts) - MiddlemanKramdownHTML.middleman_app = self elsif !config[:markdown_engine].nil? # Map symbols to classes markdown_engine_klass = if config[:markdown_engine].is_a? Symbol diff --git a/middleman-core/lib/middleman-core/renderers/redcarpet.rb b/middleman-core/lib/middleman-core/renderers/redcarpet.rb index 79b4f37e..e5ead89e 100644 --- a/middleman-core/lib/middleman-core/renderers/redcarpet.rb +++ b/middleman-core/lib/middleman-core/renderers/redcarpet.rb @@ -40,6 +40,14 @@ module Middleman renderer.new(render_options) end + def evaluate(scope, locals, &block) + @output ||= begin + MiddlemanRedcarpetHTML.scope = ::Middleman::Renderers::Haml.last_haml_scope || scope + + @engine.render(data) + end + end + private def covert_options_to_aliases! @@ -51,7 +59,7 @@ module Middleman # Custom Redcarpet renderer that uses our helpers for images and links class MiddlemanRedcarpetHTML < ::Redcarpet::Render::HTML - cattr_accessor :middleman_app + cattr_accessor :scope def initialize(options={}) @local_options = options.dup @@ -61,7 +69,7 @@ module Middleman def image(link, title, alt_text) if !@local_options[:no_images] - middleman_app.image_tag(link, :title => title, :alt => alt_text) + scope.image_tag(link, :title => title, :alt => alt_text) else link_string = link.dup link_string << %Q{"#{title}"} if title && title.length > 0 && title != alt_text @@ -74,7 +82,7 @@ module Middleman attributes = { :title => title } attributes.merge!( @local_options[:link_attributes] ) if @local_options[:link_attributes] - middleman_app.link_to(content, link, attributes ) + scope.link_to(content, link, attributes ) else link_string = link.dup link_string << %Q{"#{title}"} if title && title.length > 0 && title != alt_text diff --git a/middleman-core/lib/middleman-core/renderers/sass.rb b/middleman-core/lib/middleman-core/renderers/sass.rb index d8c33fd8..f3022696 100644 --- a/middleman-core/lib/middleman-core/renderers/sass.rb +++ b/middleman-core/lib/middleman-core/renderers/sass.rb @@ -74,7 +74,7 @@ module Middleman def sass_options more_opts = { :filename => eval_file, :line => line, :syntax => syntax } - if @context.is_a?(::Middleman::Application) && file + if @context.is_a?(::Middleman::TemplateContext) && file location_of_sass_file = @context.source_dir parts = basename.split('.') diff --git a/middleman-core/lib/middleman-core/sitemap.rb b/middleman-core/lib/middleman-core/sitemap.rb index 9bceb950..6d7b6518 100644 --- a/middleman-core/lib/middleman-core/sitemap.rb +++ b/middleman-core/lib/middleman-core/sitemap.rb @@ -31,7 +31,7 @@ module Middleman }, 'Callbacks that can exclude paths from the sitemap' # Include instance methods - app.send :include, InstanceMethods + ::Middleman::TemplateContext.send :include, InstanceMethods end end diff --git a/middleman-core/lib/middleman-core/template_context.rb b/middleman-core/lib/middleman-core/template_context.rb new file mode 100644 index 00000000..c2d666d8 --- /dev/null +++ b/middleman-core/lib/middleman-core/template_context.rb @@ -0,0 +1,105 @@ +module Middleman + class TemplateContext + attr_reader :app + attr_accessor :current_engine, :current_path + + delegate :config, :logger, :sitemap, :build?, :development?, :data, :extensions, :source_dir, :root, :to => :app + + def initialize(app, locs={}, opts={}) + @app = app + @current_locs = locs + @current_opts = opts + end + + def save_buffer + @_out_buf, _buf_was = '', @_out_buf + _buf_was + end + + def restore_buffer(_buf_was) + @_out_buf = _buf_was + end + + # Allow layouts to be wrapped in the contents of other layouts + # @param [String, Symbol] layout_name + # @return [void] + def wrap_layout(layout_name, &block) + # Save current buffer for later + _buf_was = save_buffer + + layout_path = @app.locate_layout(layout_name, self.current_engine) + + extension = File.extname(layout_path) + engine = extension[1..-1].to_sym + + # Store last engine for later (could be inside nested renders) + self.current_engine, engine_was = engine, self.current_engine + + begin + content = if block_given? + capture_html(&block) + else + '' + end + ensure + # Reset stored buffer + restore_buffer(_buf_was) + end + + concat_safe_content @app.render_individual_file(layout_path, @current_locs || {}, @current_opts || {}, self) { content } + ensure + self.current_engine = engine_was + end + + # Sinatra/Padrino compatible render method signature referenced by some view + # helpers. Especially partials. + # + # @param [String, Symbol] engine + # @param [String, Symbol] data + # @param [Hash] options + # @return [String] + def render(engine, data, options={}, &block) + data = data.to_s + + locals = options[:locals] + + found_partial = false + engine = nil + + # If the path is known to the sitemap + if resource = sitemap.find_resource_by_path(current_path) + current_dir = File.dirname(resource.source_file) + engine = File.extname(resource.source_file)[1..-1].to_sym + + # Look for partials relative to the current path + relative_dir = File.join(current_dir.sub(%r{^#{Regexp.escape(self.source_dir)}/?}, ''), data) + + # Try to use the current engine first + found_partial, found_engine = @app.resolve_template(relative_dir, :preferred_engine => engine, :try_without_underscore => true) + + # Fall back to any engine available + if !found_partial + found_partial, found_engine = @app.resolve_template(relative_dir, :try_without_underscore => true) + end + end + + # Look in the partials_dir for the partial with the current engine + partials_path = File.join(config[:partials_dir], data) + if !found_partial && !engine.nil? + found_partial, found_engine = @app.resolve_template(partials_path, :preferred_engine => engine, :try_without_underscore => true) + end + + # Look in the root with any engine + if !found_partial + found_partial, found_engine = @app.resolve_template(partials_path, :try_without_underscore => true) + end + + # Render the partial if found, otherwide throw exception + if found_partial + @app.render_individual_file(found_partial, locals, options, self, &block) + else + raise ::Middleman::CoreExtensions::Rendering::TemplateNotFound, "Could not locate partial: #{data}" + end + end + end +end diff --git a/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb b/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb index 64b11911..d9c70aa5 100644 --- a/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb +++ b/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb @@ -21,15 +21,15 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension require 'active_support/core_ext/object/to_query' - app.helpers ::Padrino::Helpers::OutputHelpers - app.helpers ::Padrino::Helpers::TagHelpers - app.helpers ::Padrino::Helpers::AssetTagHelpers - app.helpers ::Padrino::Helpers::FormHelpers - app.helpers ::Padrino::Helpers::FormatHelpers - app.helpers ::Padrino::Helpers::RenderHelpers - app.helpers ::Padrino::Helpers::NumberHelpers - # app.helpers ::Padrino::Helpers::TranslationHelpers - app.helpers ::Padrino::Helpers::Breadcrumbs + ::Middleman::TemplateContext.send :include, ::Padrino::Helpers::OutputHelpers + ::Middleman::TemplateContext.send :include, ::Padrino::Helpers::TagHelpers + ::Middleman::TemplateContext.send :include, ::Padrino::Helpers::AssetTagHelpers + ::Middleman::TemplateContext.send :include, ::Padrino::Helpers::FormHelpers + ::Middleman::TemplateContext.send :include, ::Padrino::Helpers::FormatHelpers + ::Middleman::TemplateContext.send :include, ::Padrino::Helpers::RenderHelpers + ::Middleman::TemplateContext.send :include, ::Padrino::Helpers::NumberHelpers + # ::Middleman::TemplateContext.send :include, ::Padrino::Helpers::TranslationHelpers + ::Middleman::TemplateContext.send :include, ::Padrino::Helpers::Breadcrumbs app.config.define_setting :relative_links, false, 'Whether to generate relative links instead of absolute ones' end @@ -39,6 +39,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension # Make all block content html_safe def content_tag(name, content = nil, options = nil, &block) + # safe_content_tag(name, content, options, &block) if block_given? options = content if content.is_a?(Hash) content = capture_html(&block) @@ -61,17 +62,23 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension def capture_html(*args, &block) handler = auto_find_proper_handler(&block) captured_block, captured_html = nil, '' - if handler && handler.is_type? && handler.block_is_type?(block) + + if handler && handler.block_is_type?(block) captured_html, captured_block = handler.capture_from_template(*args, &block) end + # invoking the block directly if there was no template - captured_html = block_given? && ( captured_block || block.call(*args) ) if captured_html.blank? + captured_html = block_given? && ( captured_block || block.call(*args) ) if captured_html.blank? captured_html end def auto_find_proper_handler(&block) - engine = block_given? ? File.extname(block.source_location[0])[1..-1].to_sym : current_engine - ::Padrino::Helpers::OutputHelpers.handlers.map { |h| h.new(self) }.find { |h| h.engines.include?(engine) && h.is_type? } + if block_given? + engine = File.extname(block.source_location[0])[1..-1].to_sym + ::Padrino::Helpers::OutputHelpers.handlers.map { |h| h.new(self) }.find { |h| h.engines.include?(engine) && h.block_is_type?(block) } + else + find_proper_handler + end end # Disable Padrino cache buster @@ -197,7 +204,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension options_with_resource = options.dup options_with_resource[:current_resource] ||= current_resource - ::Middleman::Util.url_for(self, path_or_resource, options_with_resource) + ::Middleman::Util.url_for(app, path_or_resource, options_with_resource) end # Overload the regular link_to to be sitemap-aware - if you diff --git a/middleman-core/lib/middleman-more/extensions/gzip.rb b/middleman-core/lib/middleman-more/extensions/gzip.rb index 6ca5e6d1..89ea38ed 100644 --- a/middleman-core/lib/middleman-more/extensions/gzip.rb +++ b/middleman-core/lib/middleman-more/extensions/gzip.rb @@ -12,6 +12,10 @@ class Middleman::Extensions::Gzip < ::Middleman::Extension option :exts, %w(.js .css .html .htm), 'File extensions to Gzip when building.' + class NumberHelpers + include ::Padrino::Helpers::NumberHelpers + end + def initialize(app, options_hash={}) super @@ -57,11 +61,11 @@ class Middleman::Extensions::Gzip < ::Middleman::Extension if output_filename total_savings += (old_size - new_size) size_change_word = (old_size - new_size) > 0 ? 'smaller' : 'larger' - builder.say_status :gzip, "#{output_filename} (#{app.number_to_human_size((old_size - new_size).abs)} #{size_change_word})" + builder.say_status :gzip, "#{output_filename} (#{NumberHelpers.new.number_to_human_size((old_size - new_size).abs)} #{size_change_word})" end end - builder.say_status :gzip, "Total gzip savings: #{app.number_to_human_size(total_savings)}", :blue + builder.say_status :gzip, "Total gzip savings: #{NumberHelpers.new.number_to_human_size(total_savings)}", :blue I18n.locale = old_locale end From bea2515a417abb82bd717a749ea0bd3ac0146683 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Thu, 2 Jan 2014 16:34:08 -0800 Subject: [PATCH 011/580] Move CLI into middleman-cli --- .gitmodules | 3 - .yardopts | 10 +- Gemfile | 1 + Rakefile | 2 +- .../img/.gitignore => middleman-cli/.gemtest | 0 middleman-cli/.simplecov | 7 + middleman-cli/.yardopts | 8 + middleman-cli/Rakefile | 5 + .../bin/middleman | 2 +- .../features/.gitkeep | 0 middleman-cli/fixtures/.gitkeep | 0 .../lib/middleman-cli.rb | 16 +- .../lib/middleman-cli}/build.rb | 0 .../lib/middleman-cli}/bundler.rb | 0 .../lib/middleman-cli}/console.rb | 0 .../lib/middleman-cli}/extension.rb | 22 +- .../lib/middleman-cli}/init.rb | 2 +- .../lib/middleman-cli}/server.rb | 0 .../lib/middleman-cli}/templates.rb | 13 +- .../lib/middleman-cli}/templates/default.rb | 0 .../default/source/images/background.png | Bin .../default/source/images/middleman.png | Bin .../templates/default/source/index.html.erb | 0 .../default/source/javascripts/all.js | 0 .../default/source/layouts/layout.erb | 0 .../default/source/stylesheets/all.css | 0 .../default/source/stylesheets/normalize.css | 0 .../lib/middleman-cli}/templates/empty.rb | 0 .../middleman-cli}/templates/empty/Gemfile.tt | 0 .../templates/extension/Gemfile | 0 .../templates/extension/Rakefile | 0 .../extension/features/support/env.rb | 0 .../templates/extension/gemspec | 0 .../templates/extension/gitignore | 0 .../templates/extension/lib/lib.rb | 0 .../extension/lib/middleman_extension.rb | 0 .../lib/middleman-cli}/templates/html5.rb | 0 .../templates/html5/source/.htaccess | 0 .../templates/html5/source/404.html | 0 .../templates/html5/source/LICENSE.md | 0 .../templates/html5/source/README.md | 0 .../apple-touch-icon-114x114-precomposed.png | Bin .../apple-touch-icon-144x144-precomposed.png | Bin .../apple-touch-icon-57x57-precomposed.png | Bin .../apple-touch-icon-72x72-precomposed.png | Bin .../source/apple-touch-icon-precomposed.png | Bin .../html5/source/apple-touch-icon.png | Bin .../templates/html5/source/crossdomain.xml | 0 .../templates/html5/source/css/main.css | 0 .../templates/html5/source/css/normalize.css | 0 .../templates/html5/source/favicon.ico | Bin .../templates/html5/source/humans.txt | 0 .../templates/html5/source/img/.gitignore | 0 .../templates/html5/source/index.html.erb | 0 .../templates/html5/source/js/main.js | 0 .../templates/html5/source/js/plugins.js | 0 .../source/js/vendor/jquery-1.8.0.min.js | 0 .../source/js/vendor/modernizr-2.6.1.min.js | 0 .../templates/html5/source/layouts/layout.erb | 0 .../templates/html5/source/robots.txt | 0 .../lib/middleman-cli}/templates/local.rb | 0 .../lib/middleman-cli}/templates/mobile.rb | 0 .../templates/mobile/source/404.html | 0 .../templates/mobile/source/README.markdown | 0 .../templates/mobile/source/crossdomain.xml | 0 .../templates/mobile/source/css/style.css | 0 .../templates/mobile/source/humans.txt | 0 .../mobile/source/img/h/apple-touch-icon.png | Bin .../templates/mobile/source/img/h/splash.png | Bin .../img/l/apple-touch-icon-precomposed.png | Bin .../mobile/source/img/l/apple-touch-icon.png | Bin .../templates/mobile/source/img/l/splash.png | Bin .../mobile/source/img/m/apple-touch-icon.png | Bin .../templates/mobile/source/index.html | 0 .../mobile/source/js/libs/modernizr-custom.js | 0 .../mobile/source/js/libs/respond.min.js | 0 .../mobile/source/js/mylibs/helper.js | 0 .../templates/mobile/source/js/plugins.js | 0 .../templates/mobile/source/js/script.js | 0 .../templates/mobile/source/robots.txt | 0 .../templates/mobile/source/sitemap.xml | 0 .../templates/mobile/source/test/index.html | 0 .../mobile/source/test/qunit/qunit.css | 0 .../mobile/source/test/qunit/qunit.js | 0 .../templates/mobile/source/test/tests.js | 0 .../tools/googleanalyticsformobile/Readme.PDF | Bin .../aspx/aspx1.snippet | 0 .../aspx/aspx2.snippet | 0 .../googleanalyticsformobile/aspx/ga.aspx | 0 .../googleanalyticsformobile/aspx/sample.aspx | 0 .../tools/googleanalyticsformobile/jsp/ga.jsp | 0 .../googleanalyticsformobile/jsp/jsp1.snippet | 0 .../googleanalyticsformobile/jsp/jsp2.snippet | 0 .../googleanalyticsformobile/jsp/sample.jsp | 0 .../tools/googleanalyticsformobile/php/ga.php | 0 .../googleanalyticsformobile/php/php1.snippet | 0 .../googleanalyticsformobile/php/php2.snippet | 0 .../googleanalyticsformobile/php/sample.php | 0 .../tools/googleanalyticsformobile/pl/ga.pl | 0 .../googleanalyticsformobile/pl/perl1.snippet | 0 .../googleanalyticsformobile/pl/perl2.snippet | 0 .../googleanalyticsformobile/pl/sample.pl | 0 .../tools/mobile-bookmark-bubble/COPYING | 0 .../mobile-bookmark-bubble/bookmark_bubble.js | 0 .../example/example.html | 0 .../mobile-bookmark-bubble/example/example.js | 0 .../mobile-bookmark-bubble/images/arrow.png | Bin .../mobile-bookmark-bubble/images/close.png | Bin .../images/generate_base64_images | 0 .../images/icon_calendar.png | Bin .../templates/mobile/source/tools/wspl/README | 0 .../source/tools/wspl/databasefactory.js | 0 .../mobile/source/tools/wspl/dbworker.js | 0 .../source/tools/wspl/dbworker_test.html | 0 .../source/tools/wspl/dbworkerstarter.js | 0 .../source/tools/wspl/dbwrapper_gears.js | 0 .../tools/wspl/dbwrapper_gears_test.html | 0 .../source/tools/wspl/dbwrapper_html5.js | 0 .../tools/wspl/dbwrapper_html5_test.html | 0 .../mobile/source/tools/wspl/dbwrapperapi.js | 0 .../source/tools/wspl/dbwrapperapi_test.html | 0 .../source/tools/wspl/gears_resultset.js | 0 .../tools/wspl/gears_resultset_test.html | 0 .../source/tools/wspl/gears_transaction.js | 0 .../tools/wspl/gears_transaction_test.html | 0 .../mobile/source/tools/wspl/gearsutils.js | 0 .../source/tools/wspl/gearsutils_test.html | 0 .../source/tools/wspl/global_functions.js | 0 .../source/tools/wspl/simplenotes/index.html | 0 .../tools/wspl/simplenotes/simplenotes.js | 0 .../source/tools/wspl/simplenotes/styles.css | 0 .../source/tools/wspl/simplenotes/template.js | 0 .../templates/shared/Gemfile.tt | 0 .../middleman-cli}/templates/shared/config.ru | 0 .../middleman-cli}/templates/shared/config.tt | 0 .../middleman-cli}/templates/shared/gitignore | 0 middleman-cli/middleman-cli.gemspec | 24 ++ middleman-cli/spec/middleman/future_spec.rb | 0 middleman-cli/spec/spec_helper.rb | 0 middleman-core/.yardopts | 5 - .../core_extensions/front_matter.rb | 2 +- middleman-core/lib/middleman-core/util.rb | 84 +++- .../lib/middleman-more/templates/smacss.rb | 30 -- .../templates/smacss/source/_footer.haml | 1 - .../templates/smacss/source/index.html.haml | 1 - .../smacss/source/layouts/layout.haml | 13 - .../source/stylesheets/base/README.markdown | 11 - .../smacss/source/stylesheets/base/base.scss | 1 - .../source/stylesheets/base/normalize.scss | 375 ------------------ .../source/stylesheets/layout/README.markdown | 9 - .../stylesheets/modules/README.markdown | 9 - .../source/stylesheets/states/README.markdown | 12 - .../smacss/source/stylesheets/style.css.scss | 12 - .../lib/padrino-core/server.rb | 2 +- middleman-core/middleman-core.gemspec | 4 - middleman/middleman.gemspec | 1 + 156 files changed, 164 insertions(+), 523 deletions(-) rename middleman-core/lib/middleman-core/templates/html5/source/img/.gitignore => middleman-cli/.gemtest (100%) mode change 100755 => 100644 create mode 100644 middleman-cli/.simplecov create mode 100644 middleman-cli/.yardopts create mode 100644 middleman-cli/Rakefile rename {middleman-core => middleman-cli}/bin/middleman (92%) rename middleman-core/lib/middleman-core/templates/mobile/source/js/script.js => middleman-cli/features/.gitkeep (100%) mode change 100755 => 100644 create mode 100644 middleman-cli/fixtures/.gitkeep rename middleman-core/lib/middleman-core/cli.rb => middleman-cli/lib/middleman-cli.rb (88%) rename {middleman-core/lib/middleman-core/cli => middleman-cli/lib/middleman-cli}/build.rb (100%) rename {middleman-core/lib/middleman-core/cli => middleman-cli/lib/middleman-cli}/bundler.rb (100%) rename {middleman-core/lib/middleman-core/cli => middleman-cli/lib/middleman-cli}/console.rb (100%) rename {middleman-core/lib/middleman-core/cli => middleman-cli/lib/middleman-cli}/extension.rb (52%) rename {middleman-core/lib/middleman-core/cli => middleman-cli/lib/middleman-cli}/init.rb (98%) rename {middleman-core/lib/middleman-core/cli => middleman-cli/lib/middleman-cli}/server.rb (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates.rb (90%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/default.rb (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/default/source/images/background.png (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/default/source/images/middleman.png (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/default/source/index.html.erb (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/default/source/javascripts/all.js (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/default/source/layouts/layout.erb (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/default/source/stylesheets/all.css (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/default/source/stylesheets/normalize.css (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/empty.rb (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/empty/Gemfile.tt (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/extension/Gemfile (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/extension/Rakefile (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/extension/features/support/env.rb (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/extension/gemspec (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/extension/gitignore (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/extension/lib/lib.rb (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/extension/lib/middleman_extension.rb (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/html5.rb (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/html5/source/.htaccess (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/html5/source/404.html (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/html5/source/LICENSE.md (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/html5/source/README.md (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/html5/source/apple-touch-icon-114x114-precomposed.png (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/html5/source/apple-touch-icon-144x144-precomposed.png (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/html5/source/apple-touch-icon-57x57-precomposed.png (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/html5/source/apple-touch-icon-72x72-precomposed.png (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/html5/source/apple-touch-icon-precomposed.png (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/html5/source/apple-touch-icon.png (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/html5/source/crossdomain.xml (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/html5/source/css/main.css (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/html5/source/css/normalize.css (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/html5/source/favicon.ico (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/html5/source/humans.txt (100%) create mode 100755 middleman-cli/lib/middleman-cli/templates/html5/source/img/.gitignore rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/html5/source/index.html.erb (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/html5/source/js/main.js (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/html5/source/js/plugins.js (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/html5/source/js/vendor/jquery-1.8.0.min.js (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/html5/source/js/vendor/modernizr-2.6.1.min.js (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/html5/source/layouts/layout.erb (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/html5/source/robots.txt (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/local.rb (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile.rb (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/404.html (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/README.markdown (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/crossdomain.xml (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/css/style.css (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/humans.txt (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/img/h/apple-touch-icon.png (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/img/h/splash.png (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/img/l/apple-touch-icon-precomposed.png (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/img/l/apple-touch-icon.png (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/img/l/splash.png (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/img/m/apple-touch-icon.png (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/index.html (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/js/libs/modernizr-custom.js (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/js/libs/respond.min.js (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/js/mylibs/helper.js (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/js/plugins.js (100%) create mode 100755 middleman-cli/lib/middleman-cli/templates/mobile/source/js/script.js rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/robots.txt (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/sitemap.xml (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/test/index.html (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/test/qunit/qunit.css (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/test/qunit/qunit.js (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/test/tests.js (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/googleanalyticsformobile/Readme.PDF (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx1.snippet (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx2.snippet (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/googleanalyticsformobile/aspx/ga.aspx (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/googleanalyticsformobile/aspx/sample.aspx (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/googleanalyticsformobile/jsp/ga.jsp (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp1.snippet (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp2.snippet (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/googleanalyticsformobile/jsp/sample.jsp (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/googleanalyticsformobile/php/ga.php (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/googleanalyticsformobile/php/php1.snippet (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/googleanalyticsformobile/php/php2.snippet (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/googleanalyticsformobile/php/sample.php (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/googleanalyticsformobile/pl/ga.pl (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/googleanalyticsformobile/pl/perl1.snippet (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/googleanalyticsformobile/pl/perl2.snippet (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/googleanalyticsformobile/pl/sample.pl (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/mobile-bookmark-bubble/COPYING (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/mobile-bookmark-bubble/bookmark_bubble.js (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/mobile-bookmark-bubble/example/example.html (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/mobile-bookmark-bubble/example/example.js (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/mobile-bookmark-bubble/images/arrow.png (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/mobile-bookmark-bubble/images/close.png (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/mobile-bookmark-bubble/images/generate_base64_images (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/mobile-bookmark-bubble/images/icon_calendar.png (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/wspl/README (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/wspl/databasefactory.js (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/wspl/dbworker.js (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/wspl/dbworker_test.html (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/wspl/dbworkerstarter.js (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/wspl/dbwrapper_gears.js (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/wspl/dbwrapper_gears_test.html (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/wspl/dbwrapper_html5.js (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/wspl/dbwrapper_html5_test.html (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/wspl/dbwrapperapi.js (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/wspl/dbwrapperapi_test.html (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/wspl/gears_resultset.js (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/wspl/gears_resultset_test.html (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/wspl/gears_transaction.js (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/wspl/gears_transaction_test.html (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/wspl/gearsutils.js (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/wspl/gearsutils_test.html (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/wspl/global_functions.js (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/wspl/simplenotes/index.html (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/wspl/simplenotes/simplenotes.js (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/wspl/simplenotes/styles.css (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/mobile/source/tools/wspl/simplenotes/template.js (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/shared/Gemfile.tt (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/shared/config.ru (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/shared/config.tt (100%) rename {middleman-core/lib/middleman-core => middleman-cli/lib/middleman-cli}/templates/shared/gitignore (100%) create mode 100644 middleman-cli/middleman-cli.gemspec create mode 100644 middleman-cli/spec/middleman/future_spec.rb create mode 100644 middleman-cli/spec/spec_helper.rb delete mode 100644 middleman-core/lib/middleman-more/templates/smacss.rb delete mode 100644 middleman-core/lib/middleman-more/templates/smacss/source/_footer.haml delete mode 100644 middleman-core/lib/middleman-more/templates/smacss/source/index.html.haml delete mode 100644 middleman-core/lib/middleman-more/templates/smacss/source/layouts/layout.haml delete mode 100644 middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/base/README.markdown delete mode 100644 middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/base/base.scss delete mode 100644 middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/base/normalize.scss delete mode 100644 middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/layout/README.markdown delete mode 100644 middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/modules/README.markdown delete mode 100644 middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/states/README.markdown delete mode 100644 middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/style.css.scss diff --git a/.gitmodules b/.gitmodules index 4f5e8fa4..e69de29b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "middleman-core/lib/middleman-more/templates/smacss"] - path = middleman-core/lib/middleman-more/templates/smacss - url = git@github.com:nsteiner/middleman-smacss.git diff --git a/.yardopts b/.yardopts index 40867ad0..980f0e4c 100644 --- a/.yardopts +++ b/.yardopts @@ -1,10 +1,10 @@ middleman-*/lib/**/*.rb --exclude middleman-core/lib/vendored-middleman-deps/ --exclude middleman-core/lib/middleman-core/step_definitions ---exclude middleman-core/lib/middleman-core/templates/default/ ---exclude middleman-core/lib/middleman-core/templates/html5/ ---exclude middleman-core/lib/middleman-core/templates/mobile/ ---exclude middleman-core/lib/middleman-core/templates/shared/ ---exclude middleman-core/lib/middleman-core/templates/extension/ +--exclude middleman-cli/lib/middleman-cli/templates/default/ +--exclude middleman-cli/lib/middleman-cli/templates/html5/ +--exclude middleman-cli/lib/middleman-cli/templates/mobile/ +--exclude middleman-cli/lib/middleman-cli/templates/shared/ +--exclude middleman-cli/lib/middleman-cli/templates/extension/ --no-private --hide-void-return \ No newline at end of file diff --git a/Gemfile b/Gemfile index fec45479..a5046c8b 100644 --- a/Gemfile +++ b/Gemfile @@ -38,5 +38,6 @@ gem 'rubocop', :require => false # Middleman itself gem 'middleman-core', :path => 'middleman-core' +gem 'middleman-cli', :path => 'middleman-cli' gem 'middleman-sprockets', :github => 'middleman/middleman-sprockets', :require => false gem 'middleman', :path => 'middleman' diff --git a/Rakefile b/Rakefile index 642efee9..b8b528e4 100644 --- a/Rakefile +++ b/Rakefile @@ -7,7 +7,7 @@ require File.expand_path('../middleman-core/lib/middleman-core/version.rb', __FI ROOT = File.expand_path(File.dirname(__FILE__)) GEM_NAME = 'middleman' -middleman_gems = %w(middleman-core middleman) +middleman_gems = %w(middleman-core middleman-cli middleman) GEM_PATHS = middleman_gems.freeze def sh_rake(command) diff --git a/middleman-core/lib/middleman-core/templates/html5/source/img/.gitignore b/middleman-cli/.gemtest old mode 100755 new mode 100644 similarity index 100% rename from middleman-core/lib/middleman-core/templates/html5/source/img/.gitignore rename to middleman-cli/.gemtest diff --git a/middleman-cli/.simplecov b/middleman-cli/.simplecov new file mode 100644 index 00000000..1e7f68e2 --- /dev/null +++ b/middleman-cli/.simplecov @@ -0,0 +1,7 @@ +SimpleCov.start do + add_filter '/fixtures/' + add_filter '/features/' + add_filter '/spec/' + add_filter '/step_definitions/' + add_filter '/lib/vendored-middleman-deps/' +end \ No newline at end of file diff --git a/middleman-cli/.yardopts b/middleman-cli/.yardopts new file mode 100644 index 00000000..47ae041b --- /dev/null +++ b/middleman-cli/.yardopts @@ -0,0 +1,8 @@ +lib/**/*.rb +--exclude lib/middleman-cli/templates/default/ +--exclude lib/middleman-cli/templates/html5/ +--exclude lib/middleman-cli/templates/mobile/ +--exclude lib/middleman-cli/templates/shared/ +--exclude lib/middleman-cli/templates/extension/ +--no-private +--hide-void-return \ No newline at end of file diff --git a/middleman-cli/Rakefile b/middleman-cli/Rakefile new file mode 100644 index 00000000..f1f8c51e --- /dev/null +++ b/middleman-cli/Rakefile @@ -0,0 +1,5 @@ +# coding:utf-8 +RAKE_ROOT = __FILE__ + +GEM_NAME = 'middleman-cli' +require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper') diff --git a/middleman-core/bin/middleman b/middleman-cli/bin/middleman similarity index 92% rename from middleman-core/bin/middleman rename to middleman-cli/bin/middleman index d17dbd1b..924f905d 100755 --- a/middleman-core/bin/middleman +++ b/middleman-cli/bin/middleman @@ -9,7 +9,7 @@ Middleman::Profiling.start require "middleman-core/load_paths" Middleman.setup_load_paths -require "middleman-core/cli" +require "middleman-cli" # Change directory to the root Dir.chdir(ENV["MM_ROOT"]) if ENV["MM_ROOT"] diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/js/script.js b/middleman-cli/features/.gitkeep old mode 100755 new mode 100644 similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/js/script.js rename to middleman-cli/features/.gitkeep diff --git a/middleman-cli/fixtures/.gitkeep b/middleman-cli/fixtures/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/middleman-core/lib/middleman-core/cli.rb b/middleman-cli/lib/middleman-cli.rb similarity index 88% rename from middleman-core/lib/middleman-core/cli.rb rename to middleman-cli/lib/middleman-cli.rb index 7823de81..512ab3ce 100644 --- a/middleman-core/lib/middleman-core/cli.rb +++ b/middleman-cli/lib/middleman-cli.rb @@ -1,3 +1,7 @@ +# Setup our load paths +libdir = File.expand_path(File.dirname(__FILE__)) +$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir) + # Require thor since that's what the who CLI is built around require 'thor' require 'thor/group' @@ -82,9 +86,9 @@ module Middleman end # Include the core CLI items -require 'middleman-core/cli/init' -require 'middleman-core/cli/bundler' -require 'middleman-core/cli/extension' -require 'middleman-core/cli/server' -require 'middleman-core/cli/build' -require 'middleman-core/cli/console' +require 'middleman-cli/init' +require 'middleman-cli/bundler' +require 'middleman-cli/extension' +require 'middleman-cli/server' +require 'middleman-cli/build' +require 'middleman-cli/console' \ No newline at end of file diff --git a/middleman-core/lib/middleman-core/cli/build.rb b/middleman-cli/lib/middleman-cli/build.rb similarity index 100% rename from middleman-core/lib/middleman-core/cli/build.rb rename to middleman-cli/lib/middleman-cli/build.rb diff --git a/middleman-core/lib/middleman-core/cli/bundler.rb b/middleman-cli/lib/middleman-cli/bundler.rb similarity index 100% rename from middleman-core/lib/middleman-core/cli/bundler.rb rename to middleman-cli/lib/middleman-cli/bundler.rb diff --git a/middleman-core/lib/middleman-core/cli/console.rb b/middleman-cli/lib/middleman-cli/console.rb similarity index 100% rename from middleman-core/lib/middleman-core/cli/console.rb rename to middleman-cli/lib/middleman-cli/console.rb diff --git a/middleman-core/lib/middleman-core/cli/extension.rb b/middleman-cli/lib/middleman-cli/extension.rb similarity index 52% rename from middleman-core/lib/middleman-core/cli/extension.rb rename to middleman-cli/lib/middleman-cli/extension.rb index 1b077f50..71bfb38e 100644 --- a/middleman-core/lib/middleman-core/cli/extension.rb +++ b/middleman-cli/lib/middleman-cli/extension.rb @@ -15,21 +15,25 @@ module Middleman::Cli # Template files are relative to this file # @return [String] def self.source_root - File.join(File.dirname(__FILE__), '..', 'templates', 'extension') + File.join(File.dirname(__FILE__), 'templates') end desc 'extension [options]', 'Create Middleman extension scaffold NAME' + method_option 'skip-git', + :type => :boolean, + :default => false, + :desc => 'Skip Git ignores and keeps' # The extension task # @param [String] name def extension generate_gitignore! - template 'Rakefile', File.join(name, 'Rakefile') - template 'gemspec', File.join(name, "#{name}.gemspec") - template 'Gemfile', File.join(name, 'Gemfile') - template 'lib/middleman_extension.rb', File.join(name, 'lib', 'middleman_extension.rb') - template 'lib/lib.rb', File.join(name, 'lib', "#{name}.rb") - template 'features/support/env.rb', File.join(name, 'features', 'support', 'env.rb') + template 'extension/Rakefile', File.join(name, 'Rakefile') + template 'extension/gemspec', File.join(name, "#{name}.gemspec") + template 'extension/Gemfile', File.join(name, 'Gemfile') + template 'extension/lib/middleman_extension.rb', File.join(name, 'lib', 'middleman_extension.rb') + template 'extension/lib/lib.rb', File.join(name, 'lib', "#{name}.rb") + template 'extension/features/support/env.rb', File.join(name, 'features', 'support', 'env.rb') empty_directory File.join(name, 'fixtures') end @@ -40,8 +44,8 @@ module Middleman::Cli # Write a .gitignore file for project # @return [void] def generate_gitignore! - return unless options[:git] - copy_file 'gitignore', File.join(name, '.gitignore') + return if options[:'skip-git'] + copy_file 'shared/gitignore', File.join(name, '.gitignore') end } diff --git a/middleman-core/lib/middleman-core/cli/init.rb b/middleman-cli/lib/middleman-cli/init.rb similarity index 98% rename from middleman-core/lib/middleman-core/cli/init.rb rename to middleman-cli/lib/middleman-cli/init.rb index 6f61a080..2e588cc7 100644 --- a/middleman-core/lib/middleman-core/cli/init.rb +++ b/middleman-cli/lib/middleman-cli/init.rb @@ -1,4 +1,4 @@ -require 'middleman-core/templates' +require 'middleman-cli/templates' # CLI Module module Middleman::Cli diff --git a/middleman-core/lib/middleman-core/cli/server.rb b/middleman-cli/lib/middleman-cli/server.rb similarity index 100% rename from middleman-core/lib/middleman-core/cli/server.rb rename to middleman-cli/lib/middleman-cli/server.rb diff --git a/middleman-core/lib/middleman-core/templates.rb b/middleman-cli/lib/middleman-cli/templates.rb similarity index 90% rename from middleman-core/lib/middleman-core/templates.rb rename to middleman-cli/lib/middleman-cli/templates.rb index ba0e9d3e..c163a903 100644 --- a/middleman-core/lib/middleman-core/templates.rb +++ b/middleman-cli/lib/middleman-cli/templates.rb @@ -84,19 +84,16 @@ module Middleman::Templates end # Default template -require 'middleman-core/templates/default' +require 'middleman-cli/templates/default' # HTML5 template -require 'middleman-core/templates/html5' +require 'middleman-cli/templates/html5' # HTML5 Mobile template -require 'middleman-core/templates/mobile' - -# SMACSS templates -require 'middleman-more/templates/smacss' +require 'middleman-cli/templates/mobile' # Local templates -require 'middleman-core/templates/local' +require 'middleman-cli/templates/local' # Barebones template -require 'middleman-core/templates/empty' +require 'middleman-cli/templates/empty' diff --git a/middleman-core/lib/middleman-core/templates/default.rb b/middleman-cli/lib/middleman-cli/templates/default.rb similarity index 100% rename from middleman-core/lib/middleman-core/templates/default.rb rename to middleman-cli/lib/middleman-cli/templates/default.rb diff --git a/middleman-core/lib/middleman-core/templates/default/source/images/background.png b/middleman-cli/lib/middleman-cli/templates/default/source/images/background.png similarity index 100% rename from middleman-core/lib/middleman-core/templates/default/source/images/background.png rename to middleman-cli/lib/middleman-cli/templates/default/source/images/background.png diff --git a/middleman-core/lib/middleman-core/templates/default/source/images/middleman.png b/middleman-cli/lib/middleman-cli/templates/default/source/images/middleman.png similarity index 100% rename from middleman-core/lib/middleman-core/templates/default/source/images/middleman.png rename to middleman-cli/lib/middleman-cli/templates/default/source/images/middleman.png diff --git a/middleman-core/lib/middleman-core/templates/default/source/index.html.erb b/middleman-cli/lib/middleman-cli/templates/default/source/index.html.erb similarity index 100% rename from middleman-core/lib/middleman-core/templates/default/source/index.html.erb rename to middleman-cli/lib/middleman-cli/templates/default/source/index.html.erb diff --git a/middleman-core/lib/middleman-core/templates/default/source/javascripts/all.js b/middleman-cli/lib/middleman-cli/templates/default/source/javascripts/all.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/default/source/javascripts/all.js rename to middleman-cli/lib/middleman-cli/templates/default/source/javascripts/all.js diff --git a/middleman-core/lib/middleman-core/templates/default/source/layouts/layout.erb b/middleman-cli/lib/middleman-cli/templates/default/source/layouts/layout.erb similarity index 100% rename from middleman-core/lib/middleman-core/templates/default/source/layouts/layout.erb rename to middleman-cli/lib/middleman-cli/templates/default/source/layouts/layout.erb diff --git a/middleman-core/lib/middleman-core/templates/default/source/stylesheets/all.css b/middleman-cli/lib/middleman-cli/templates/default/source/stylesheets/all.css similarity index 100% rename from middleman-core/lib/middleman-core/templates/default/source/stylesheets/all.css rename to middleman-cli/lib/middleman-cli/templates/default/source/stylesheets/all.css diff --git a/middleman-core/lib/middleman-core/templates/default/source/stylesheets/normalize.css b/middleman-cli/lib/middleman-cli/templates/default/source/stylesheets/normalize.css similarity index 100% rename from middleman-core/lib/middleman-core/templates/default/source/stylesheets/normalize.css rename to middleman-cli/lib/middleman-cli/templates/default/source/stylesheets/normalize.css diff --git a/middleman-core/lib/middleman-core/templates/empty.rb b/middleman-cli/lib/middleman-cli/templates/empty.rb similarity index 100% rename from middleman-core/lib/middleman-core/templates/empty.rb rename to middleman-cli/lib/middleman-cli/templates/empty.rb diff --git a/middleman-core/lib/middleman-core/templates/empty/Gemfile.tt b/middleman-cli/lib/middleman-cli/templates/empty/Gemfile.tt similarity index 100% rename from middleman-core/lib/middleman-core/templates/empty/Gemfile.tt rename to middleman-cli/lib/middleman-cli/templates/empty/Gemfile.tt diff --git a/middleman-core/lib/middleman-core/templates/extension/Gemfile b/middleman-cli/lib/middleman-cli/templates/extension/Gemfile similarity index 100% rename from middleman-core/lib/middleman-core/templates/extension/Gemfile rename to middleman-cli/lib/middleman-cli/templates/extension/Gemfile diff --git a/middleman-core/lib/middleman-core/templates/extension/Rakefile b/middleman-cli/lib/middleman-cli/templates/extension/Rakefile similarity index 100% rename from middleman-core/lib/middleman-core/templates/extension/Rakefile rename to middleman-cli/lib/middleman-cli/templates/extension/Rakefile diff --git a/middleman-core/lib/middleman-core/templates/extension/features/support/env.rb b/middleman-cli/lib/middleman-cli/templates/extension/features/support/env.rb similarity index 100% rename from middleman-core/lib/middleman-core/templates/extension/features/support/env.rb rename to middleman-cli/lib/middleman-cli/templates/extension/features/support/env.rb diff --git a/middleman-core/lib/middleman-core/templates/extension/gemspec b/middleman-cli/lib/middleman-cli/templates/extension/gemspec similarity index 100% rename from middleman-core/lib/middleman-core/templates/extension/gemspec rename to middleman-cli/lib/middleman-cli/templates/extension/gemspec diff --git a/middleman-core/lib/middleman-core/templates/extension/gitignore b/middleman-cli/lib/middleman-cli/templates/extension/gitignore similarity index 100% rename from middleman-core/lib/middleman-core/templates/extension/gitignore rename to middleman-cli/lib/middleman-cli/templates/extension/gitignore diff --git a/middleman-core/lib/middleman-core/templates/extension/lib/lib.rb b/middleman-cli/lib/middleman-cli/templates/extension/lib/lib.rb similarity index 100% rename from middleman-core/lib/middleman-core/templates/extension/lib/lib.rb rename to middleman-cli/lib/middleman-cli/templates/extension/lib/lib.rb diff --git a/middleman-core/lib/middleman-core/templates/extension/lib/middleman_extension.rb b/middleman-cli/lib/middleman-cli/templates/extension/lib/middleman_extension.rb similarity index 100% rename from middleman-core/lib/middleman-core/templates/extension/lib/middleman_extension.rb rename to middleman-cli/lib/middleman-cli/templates/extension/lib/middleman_extension.rb diff --git a/middleman-core/lib/middleman-core/templates/html5.rb b/middleman-cli/lib/middleman-cli/templates/html5.rb similarity index 100% rename from middleman-core/lib/middleman-core/templates/html5.rb rename to middleman-cli/lib/middleman-cli/templates/html5.rb diff --git a/middleman-core/lib/middleman-core/templates/html5/source/.htaccess b/middleman-cli/lib/middleman-cli/templates/html5/source/.htaccess similarity index 100% rename from middleman-core/lib/middleman-core/templates/html5/source/.htaccess rename to middleman-cli/lib/middleman-cli/templates/html5/source/.htaccess diff --git a/middleman-core/lib/middleman-core/templates/html5/source/404.html b/middleman-cli/lib/middleman-cli/templates/html5/source/404.html similarity index 100% rename from middleman-core/lib/middleman-core/templates/html5/source/404.html rename to middleman-cli/lib/middleman-cli/templates/html5/source/404.html diff --git a/middleman-core/lib/middleman-core/templates/html5/source/LICENSE.md b/middleman-cli/lib/middleman-cli/templates/html5/source/LICENSE.md similarity index 100% rename from middleman-core/lib/middleman-core/templates/html5/source/LICENSE.md rename to middleman-cli/lib/middleman-cli/templates/html5/source/LICENSE.md diff --git a/middleman-core/lib/middleman-core/templates/html5/source/README.md b/middleman-cli/lib/middleman-cli/templates/html5/source/README.md similarity index 100% rename from middleman-core/lib/middleman-core/templates/html5/source/README.md rename to middleman-cli/lib/middleman-cli/templates/html5/source/README.md diff --git a/middleman-core/lib/middleman-core/templates/html5/source/apple-touch-icon-114x114-precomposed.png b/middleman-cli/lib/middleman-cli/templates/html5/source/apple-touch-icon-114x114-precomposed.png similarity index 100% rename from middleman-core/lib/middleman-core/templates/html5/source/apple-touch-icon-114x114-precomposed.png rename to middleman-cli/lib/middleman-cli/templates/html5/source/apple-touch-icon-114x114-precomposed.png diff --git a/middleman-core/lib/middleman-core/templates/html5/source/apple-touch-icon-144x144-precomposed.png b/middleman-cli/lib/middleman-cli/templates/html5/source/apple-touch-icon-144x144-precomposed.png similarity index 100% rename from middleman-core/lib/middleman-core/templates/html5/source/apple-touch-icon-144x144-precomposed.png rename to middleman-cli/lib/middleman-cli/templates/html5/source/apple-touch-icon-144x144-precomposed.png diff --git a/middleman-core/lib/middleman-core/templates/html5/source/apple-touch-icon-57x57-precomposed.png b/middleman-cli/lib/middleman-cli/templates/html5/source/apple-touch-icon-57x57-precomposed.png similarity index 100% rename from middleman-core/lib/middleman-core/templates/html5/source/apple-touch-icon-57x57-precomposed.png rename to middleman-cli/lib/middleman-cli/templates/html5/source/apple-touch-icon-57x57-precomposed.png diff --git a/middleman-core/lib/middleman-core/templates/html5/source/apple-touch-icon-72x72-precomposed.png b/middleman-cli/lib/middleman-cli/templates/html5/source/apple-touch-icon-72x72-precomposed.png similarity index 100% rename from middleman-core/lib/middleman-core/templates/html5/source/apple-touch-icon-72x72-precomposed.png rename to middleman-cli/lib/middleman-cli/templates/html5/source/apple-touch-icon-72x72-precomposed.png diff --git a/middleman-core/lib/middleman-core/templates/html5/source/apple-touch-icon-precomposed.png b/middleman-cli/lib/middleman-cli/templates/html5/source/apple-touch-icon-precomposed.png similarity index 100% rename from middleman-core/lib/middleman-core/templates/html5/source/apple-touch-icon-precomposed.png rename to middleman-cli/lib/middleman-cli/templates/html5/source/apple-touch-icon-precomposed.png diff --git a/middleman-core/lib/middleman-core/templates/html5/source/apple-touch-icon.png b/middleman-cli/lib/middleman-cli/templates/html5/source/apple-touch-icon.png similarity index 100% rename from middleman-core/lib/middleman-core/templates/html5/source/apple-touch-icon.png rename to middleman-cli/lib/middleman-cli/templates/html5/source/apple-touch-icon.png diff --git a/middleman-core/lib/middleman-core/templates/html5/source/crossdomain.xml b/middleman-cli/lib/middleman-cli/templates/html5/source/crossdomain.xml similarity index 100% rename from middleman-core/lib/middleman-core/templates/html5/source/crossdomain.xml rename to middleman-cli/lib/middleman-cli/templates/html5/source/crossdomain.xml diff --git a/middleman-core/lib/middleman-core/templates/html5/source/css/main.css b/middleman-cli/lib/middleman-cli/templates/html5/source/css/main.css similarity index 100% rename from middleman-core/lib/middleman-core/templates/html5/source/css/main.css rename to middleman-cli/lib/middleman-cli/templates/html5/source/css/main.css diff --git a/middleman-core/lib/middleman-core/templates/html5/source/css/normalize.css b/middleman-cli/lib/middleman-cli/templates/html5/source/css/normalize.css similarity index 100% rename from middleman-core/lib/middleman-core/templates/html5/source/css/normalize.css rename to middleman-cli/lib/middleman-cli/templates/html5/source/css/normalize.css diff --git a/middleman-core/lib/middleman-core/templates/html5/source/favicon.ico b/middleman-cli/lib/middleman-cli/templates/html5/source/favicon.ico similarity index 100% rename from middleman-core/lib/middleman-core/templates/html5/source/favicon.ico rename to middleman-cli/lib/middleman-cli/templates/html5/source/favicon.ico diff --git a/middleman-core/lib/middleman-core/templates/html5/source/humans.txt b/middleman-cli/lib/middleman-cli/templates/html5/source/humans.txt similarity index 100% rename from middleman-core/lib/middleman-core/templates/html5/source/humans.txt rename to middleman-cli/lib/middleman-cli/templates/html5/source/humans.txt diff --git a/middleman-cli/lib/middleman-cli/templates/html5/source/img/.gitignore b/middleman-cli/lib/middleman-cli/templates/html5/source/img/.gitignore new file mode 100755 index 00000000..e69de29b diff --git a/middleman-core/lib/middleman-core/templates/html5/source/index.html.erb b/middleman-cli/lib/middleman-cli/templates/html5/source/index.html.erb similarity index 100% rename from middleman-core/lib/middleman-core/templates/html5/source/index.html.erb rename to middleman-cli/lib/middleman-cli/templates/html5/source/index.html.erb diff --git a/middleman-core/lib/middleman-core/templates/html5/source/js/main.js b/middleman-cli/lib/middleman-cli/templates/html5/source/js/main.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/html5/source/js/main.js rename to middleman-cli/lib/middleman-cli/templates/html5/source/js/main.js diff --git a/middleman-core/lib/middleman-core/templates/html5/source/js/plugins.js b/middleman-cli/lib/middleman-cli/templates/html5/source/js/plugins.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/html5/source/js/plugins.js rename to middleman-cli/lib/middleman-cli/templates/html5/source/js/plugins.js diff --git a/middleman-core/lib/middleman-core/templates/html5/source/js/vendor/jquery-1.8.0.min.js b/middleman-cli/lib/middleman-cli/templates/html5/source/js/vendor/jquery-1.8.0.min.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/html5/source/js/vendor/jquery-1.8.0.min.js rename to middleman-cli/lib/middleman-cli/templates/html5/source/js/vendor/jquery-1.8.0.min.js diff --git a/middleman-core/lib/middleman-core/templates/html5/source/js/vendor/modernizr-2.6.1.min.js b/middleman-cli/lib/middleman-cli/templates/html5/source/js/vendor/modernizr-2.6.1.min.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/html5/source/js/vendor/modernizr-2.6.1.min.js rename to middleman-cli/lib/middleman-cli/templates/html5/source/js/vendor/modernizr-2.6.1.min.js diff --git a/middleman-core/lib/middleman-core/templates/html5/source/layouts/layout.erb b/middleman-cli/lib/middleman-cli/templates/html5/source/layouts/layout.erb similarity index 100% rename from middleman-core/lib/middleman-core/templates/html5/source/layouts/layout.erb rename to middleman-cli/lib/middleman-cli/templates/html5/source/layouts/layout.erb diff --git a/middleman-core/lib/middleman-core/templates/html5/source/robots.txt b/middleman-cli/lib/middleman-cli/templates/html5/source/robots.txt similarity index 100% rename from middleman-core/lib/middleman-core/templates/html5/source/robots.txt rename to middleman-cli/lib/middleman-cli/templates/html5/source/robots.txt diff --git a/middleman-core/lib/middleman-core/templates/local.rb b/middleman-cli/lib/middleman-cli/templates/local.rb similarity index 100% rename from middleman-core/lib/middleman-core/templates/local.rb rename to middleman-cli/lib/middleman-cli/templates/local.rb diff --git a/middleman-core/lib/middleman-core/templates/mobile.rb b/middleman-cli/lib/middleman-cli/templates/mobile.rb similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile.rb rename to middleman-cli/lib/middleman-cli/templates/mobile.rb diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/404.html b/middleman-cli/lib/middleman-cli/templates/mobile/source/404.html similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/404.html rename to middleman-cli/lib/middleman-cli/templates/mobile/source/404.html diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/README.markdown b/middleman-cli/lib/middleman-cli/templates/mobile/source/README.markdown similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/README.markdown rename to middleman-cli/lib/middleman-cli/templates/mobile/source/README.markdown diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/crossdomain.xml b/middleman-cli/lib/middleman-cli/templates/mobile/source/crossdomain.xml similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/crossdomain.xml rename to middleman-cli/lib/middleman-cli/templates/mobile/source/crossdomain.xml diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/css/style.css b/middleman-cli/lib/middleman-cli/templates/mobile/source/css/style.css similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/css/style.css rename to middleman-cli/lib/middleman-cli/templates/mobile/source/css/style.css diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/humans.txt b/middleman-cli/lib/middleman-cli/templates/mobile/source/humans.txt similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/humans.txt rename to middleman-cli/lib/middleman-cli/templates/mobile/source/humans.txt diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/img/h/apple-touch-icon.png b/middleman-cli/lib/middleman-cli/templates/mobile/source/img/h/apple-touch-icon.png similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/img/h/apple-touch-icon.png rename to middleman-cli/lib/middleman-cli/templates/mobile/source/img/h/apple-touch-icon.png diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/img/h/splash.png b/middleman-cli/lib/middleman-cli/templates/mobile/source/img/h/splash.png similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/img/h/splash.png rename to middleman-cli/lib/middleman-cli/templates/mobile/source/img/h/splash.png diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/img/l/apple-touch-icon-precomposed.png b/middleman-cli/lib/middleman-cli/templates/mobile/source/img/l/apple-touch-icon-precomposed.png similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/img/l/apple-touch-icon-precomposed.png rename to middleman-cli/lib/middleman-cli/templates/mobile/source/img/l/apple-touch-icon-precomposed.png diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/img/l/apple-touch-icon.png b/middleman-cli/lib/middleman-cli/templates/mobile/source/img/l/apple-touch-icon.png similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/img/l/apple-touch-icon.png rename to middleman-cli/lib/middleman-cli/templates/mobile/source/img/l/apple-touch-icon.png diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/img/l/splash.png b/middleman-cli/lib/middleman-cli/templates/mobile/source/img/l/splash.png similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/img/l/splash.png rename to middleman-cli/lib/middleman-cli/templates/mobile/source/img/l/splash.png diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/img/m/apple-touch-icon.png b/middleman-cli/lib/middleman-cli/templates/mobile/source/img/m/apple-touch-icon.png similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/img/m/apple-touch-icon.png rename to middleman-cli/lib/middleman-cli/templates/mobile/source/img/m/apple-touch-icon.png diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/index.html b/middleman-cli/lib/middleman-cli/templates/mobile/source/index.html similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/index.html rename to middleman-cli/lib/middleman-cli/templates/mobile/source/index.html diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/js/libs/modernizr-custom.js b/middleman-cli/lib/middleman-cli/templates/mobile/source/js/libs/modernizr-custom.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/js/libs/modernizr-custom.js rename to middleman-cli/lib/middleman-cli/templates/mobile/source/js/libs/modernizr-custom.js diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/js/libs/respond.min.js b/middleman-cli/lib/middleman-cli/templates/mobile/source/js/libs/respond.min.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/js/libs/respond.min.js rename to middleman-cli/lib/middleman-cli/templates/mobile/source/js/libs/respond.min.js diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/js/mylibs/helper.js b/middleman-cli/lib/middleman-cli/templates/mobile/source/js/mylibs/helper.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/js/mylibs/helper.js rename to middleman-cli/lib/middleman-cli/templates/mobile/source/js/mylibs/helper.js diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/js/plugins.js b/middleman-cli/lib/middleman-cli/templates/mobile/source/js/plugins.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/js/plugins.js rename to middleman-cli/lib/middleman-cli/templates/mobile/source/js/plugins.js diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/js/script.js b/middleman-cli/lib/middleman-cli/templates/mobile/source/js/script.js new file mode 100755 index 00000000..e69de29b diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/robots.txt b/middleman-cli/lib/middleman-cli/templates/mobile/source/robots.txt similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/robots.txt rename to middleman-cli/lib/middleman-cli/templates/mobile/source/robots.txt diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/sitemap.xml b/middleman-cli/lib/middleman-cli/templates/mobile/source/sitemap.xml similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/sitemap.xml rename to middleman-cli/lib/middleman-cli/templates/mobile/source/sitemap.xml diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/test/index.html b/middleman-cli/lib/middleman-cli/templates/mobile/source/test/index.html similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/test/index.html rename to middleman-cli/lib/middleman-cli/templates/mobile/source/test/index.html diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/test/qunit/qunit.css b/middleman-cli/lib/middleman-cli/templates/mobile/source/test/qunit/qunit.css similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/test/qunit/qunit.css rename to middleman-cli/lib/middleman-cli/templates/mobile/source/test/qunit/qunit.css diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/test/qunit/qunit.js b/middleman-cli/lib/middleman-cli/templates/mobile/source/test/qunit/qunit.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/test/qunit/qunit.js rename to middleman-cli/lib/middleman-cli/templates/mobile/source/test/qunit/qunit.js diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/test/tests.js b/middleman-cli/lib/middleman-cli/templates/mobile/source/test/tests.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/test/tests.js rename to middleman-cli/lib/middleman-cli/templates/mobile/source/test/tests.js diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/Readme.PDF b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/Readme.PDF similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/Readme.PDF rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/Readme.PDF diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx1.snippet b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx1.snippet similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx1.snippet rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx1.snippet diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx2.snippet b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx2.snippet similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx2.snippet rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx2.snippet diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/aspx/ga.aspx b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/aspx/ga.aspx similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/aspx/ga.aspx rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/aspx/ga.aspx diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/aspx/sample.aspx b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/aspx/sample.aspx similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/aspx/sample.aspx rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/aspx/sample.aspx diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/jsp/ga.jsp b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/jsp/ga.jsp similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/jsp/ga.jsp rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/jsp/ga.jsp diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp1.snippet b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp1.snippet similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp1.snippet rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp1.snippet diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp2.snippet b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp2.snippet similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp2.snippet rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp2.snippet diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/jsp/sample.jsp b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/jsp/sample.jsp similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/jsp/sample.jsp rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/jsp/sample.jsp diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/php/ga.php b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/php/ga.php similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/php/ga.php rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/php/ga.php diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/php/php1.snippet b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/php/php1.snippet similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/php/php1.snippet rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/php/php1.snippet diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/php/php2.snippet b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/php/php2.snippet similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/php/php2.snippet rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/php/php2.snippet diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/php/sample.php b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/php/sample.php similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/php/sample.php rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/php/sample.php diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/pl/ga.pl b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/pl/ga.pl similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/pl/ga.pl rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/pl/ga.pl diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/pl/perl1.snippet b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/pl/perl1.snippet similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/pl/perl1.snippet rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/pl/perl1.snippet diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/pl/perl2.snippet b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/pl/perl2.snippet similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/pl/perl2.snippet rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/pl/perl2.snippet diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/pl/sample.pl b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/pl/sample.pl similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/pl/sample.pl rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/pl/sample.pl diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/COPYING b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/COPYING similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/COPYING rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/COPYING diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/bookmark_bubble.js b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/bookmark_bubble.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/bookmark_bubble.js rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/bookmark_bubble.js diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/example/example.html b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/example/example.html similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/example/example.html rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/example/example.html diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/example/example.js b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/example/example.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/example/example.js rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/example/example.js diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/images/arrow.png b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/images/arrow.png similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/images/arrow.png rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/images/arrow.png diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/images/close.png b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/images/close.png similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/images/close.png rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/images/close.png diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/images/generate_base64_images b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/images/generate_base64_images similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/images/generate_base64_images rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/images/generate_base64_images diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/images/icon_calendar.png b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/images/icon_calendar.png similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/images/icon_calendar.png rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/images/icon_calendar.png diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/README b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/README similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/README rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/README diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/databasefactory.js b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/databasefactory.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/databasefactory.js rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/databasefactory.js diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/dbworker.js b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbworker.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/dbworker.js rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbworker.js diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/dbworker_test.html b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbworker_test.html similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/dbworker_test.html rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbworker_test.html diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/dbworkerstarter.js b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbworkerstarter.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/dbworkerstarter.js rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbworkerstarter.js diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapper_gears.js b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbwrapper_gears.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapper_gears.js rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbwrapper_gears.js diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapper_gears_test.html b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbwrapper_gears_test.html similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapper_gears_test.html rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbwrapper_gears_test.html diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapper_html5.js b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbwrapper_html5.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapper_html5.js rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbwrapper_html5.js diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapper_html5_test.html b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbwrapper_html5_test.html similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapper_html5_test.html rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbwrapper_html5_test.html diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapperapi.js b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbwrapperapi.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapperapi.js rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbwrapperapi.js diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapperapi_test.html b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbwrapperapi_test.html similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapperapi_test.html rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbwrapperapi_test.html diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/gears_resultset.js b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/gears_resultset.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/gears_resultset.js rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/gears_resultset.js diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/gears_resultset_test.html b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/gears_resultset_test.html similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/gears_resultset_test.html rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/gears_resultset_test.html diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/gears_transaction.js b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/gears_transaction.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/gears_transaction.js rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/gears_transaction.js diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/gears_transaction_test.html b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/gears_transaction_test.html similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/gears_transaction_test.html rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/gears_transaction_test.html diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/gearsutils.js b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/gearsutils.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/gearsutils.js rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/gearsutils.js diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/gearsutils_test.html b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/gearsutils_test.html similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/gearsutils_test.html rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/gearsutils_test.html diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/global_functions.js b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/global_functions.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/global_functions.js rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/global_functions.js diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/simplenotes/index.html b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/simplenotes/index.html similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/simplenotes/index.html rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/simplenotes/index.html diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/simplenotes/simplenotes.js b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/simplenotes/simplenotes.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/simplenotes/simplenotes.js rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/simplenotes/simplenotes.js diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/simplenotes/styles.css b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/simplenotes/styles.css similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/simplenotes/styles.css rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/simplenotes/styles.css diff --git a/middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/simplenotes/template.js b/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/simplenotes/template.js similarity index 100% rename from middleman-core/lib/middleman-core/templates/mobile/source/tools/wspl/simplenotes/template.js rename to middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/simplenotes/template.js diff --git a/middleman-core/lib/middleman-core/templates/shared/Gemfile.tt b/middleman-cli/lib/middleman-cli/templates/shared/Gemfile.tt similarity index 100% rename from middleman-core/lib/middleman-core/templates/shared/Gemfile.tt rename to middleman-cli/lib/middleman-cli/templates/shared/Gemfile.tt diff --git a/middleman-core/lib/middleman-core/templates/shared/config.ru b/middleman-cli/lib/middleman-cli/templates/shared/config.ru similarity index 100% rename from middleman-core/lib/middleman-core/templates/shared/config.ru rename to middleman-cli/lib/middleman-cli/templates/shared/config.ru diff --git a/middleman-core/lib/middleman-core/templates/shared/config.tt b/middleman-cli/lib/middleman-cli/templates/shared/config.tt similarity index 100% rename from middleman-core/lib/middleman-core/templates/shared/config.tt rename to middleman-cli/lib/middleman-cli/templates/shared/config.tt diff --git a/middleman-core/lib/middleman-core/templates/shared/gitignore b/middleman-cli/lib/middleman-cli/templates/shared/gitignore similarity index 100% rename from middleman-core/lib/middleman-core/templates/shared/gitignore rename to middleman-cli/lib/middleman-cli/templates/shared/gitignore diff --git a/middleman-cli/middleman-cli.gemspec b/middleman-cli/middleman-cli.gemspec new file mode 100644 index 00000000..5d9c1b90 --- /dev/null +++ b/middleman-cli/middleman-cli.gemspec @@ -0,0 +1,24 @@ +# -*- encoding: utf-8 -*- +$:.push File.expand_path("../lib", __FILE__) +require File.expand_path("../../middleman-core/lib/middleman-core/version.rb", __FILE__) + +Gem::Specification.new do |s| + s.name = "middleman-cli" + s.version = Middleman::VERSION + s.platform = Gem::Platform::RUBY + s.license = "MIT" + s.authors = ["Thomas Reynolds", "Ben Hollis"] + s.email = ["me@tdreyno.com", "ben@benhollis.net"] + s.homepage = "http://middlemanapp.com" + s.summary = "Hand-crafted frontend development" + s.description = "A static site generator. Provides dozens of templating languages (Haml, Sass, Compass, Slim, CoffeeScript, and more). Makes minification, compression, cache busting, Yaml data (and more) an easy part of your development cycle." + + s.files = `git ls-files -z`.split("\0") + s.test_files = `git ls-files -z -- {fixtures,features}/*`.split("\0") + s.executable = "middleman" + s.require_path = "lib" + s.required_ruby_version = '>= 1.9.3' + + # CLI + s.add_dependency("thor", [">= 0.17.0", "< 2.0"]) +end diff --git a/middleman-cli/spec/middleman/future_spec.rb b/middleman-cli/spec/middleman/future_spec.rb new file mode 100644 index 00000000..e69de29b diff --git a/middleman-cli/spec/spec_helper.rb b/middleman-cli/spec/spec_helper.rb new file mode 100644 index 00000000..e69de29b diff --git a/middleman-core/.yardopts b/middleman-core/.yardopts index b6b437b9..29455a55 100644 --- a/middleman-core/.yardopts +++ b/middleman-core/.yardopts @@ -1,10 +1,5 @@ lib/**/*.rb --exclude lib/vendored-middleman-deps/ --exclude lib/middleman-core/step_definitions ---exclude lib/middleman-core/templates/default/ ---exclude lib/middleman-core/templates/html5/ ---exclude lib/middleman-core/templates/mobile/ ---exclude lib/middleman-core/templates/shared/ ---exclude lib/middleman-core/templates/extension/ --no-private --hide-void-return \ No newline at end of file diff --git a/middleman-core/lib/middleman-core/core_extensions/front_matter.rb b/middleman-core/lib/middleman-core/core_extensions/front_matter.rb index d967e204..155fad6a 100644 --- a/middleman-core/lib/middleman-core/core_extensions/front_matter.rb +++ b/middleman-core/lib/middleman-core/core_extensions/front_matter.rb @@ -163,7 +163,7 @@ module Middleman::CoreExtensions # Get the frontmatter and plain content from a file # @param [String] path - # @return [Array] + # @return [Array] def frontmatter_and_content(path) full_path = if Pathname(path).relative? File.join(app.source_dir, path) diff --git a/middleman-core/lib/middleman-core/util.rb b/middleman-core/lib/middleman-core/util.rb index 02892775..b4d919ca 100644 --- a/middleman-core/lib/middleman-core/util.rb +++ b/middleman-core/lib/middleman-core/util.rb @@ -46,10 +46,10 @@ module Middleman # # @private # @param [Hash] data Normal hash - # @return [Thor::CoreExt::HashWithIndifferentAccess] + # @return [Middleman::Util::HashWithIndifferentAccess] def recursively_enhance(data) if data.is_a? Hash - data = ::Thor::CoreExt::HashWithIndifferentAccess.new(data) + data = ::Middleman::Util::HashWithIndifferentAccess.new(data) data.each do |key, val| data[key] = recursively_enhance(val) end @@ -217,7 +217,7 @@ module Middleman end end - private + private # Is mime type known to be non-binary? # @@ -277,5 +277,81 @@ module Middleman end end end + + # A hash with indifferent access and magic predicates. + # Copied from Thor + # + # hash = Middleman::Application.new 'foo' => 'bar', 'baz' => 'bee', 'force' => true + # + # hash[:foo] #=> 'bar' + # hash['foo'] #=> 'bar' + # hash.foo? #=> true + # + class HashWithIndifferentAccess < ::Hash #:nodoc: + + def initialize(hash={}) + super() + hash.each do |key, value| + self[convert_key(key)] = value + end + end + + def [](key) + super(convert_key(key)) + end + + def []=(key, value) + super(convert_key(key), value) + end + + def delete(key) + super(convert_key(key)) + end + + def values_at(*indices) + indices.collect { |key| self[convert_key(key)] } + end + + def merge(other) + dup.merge!(other) + end + + def merge!(other) + other.each do |key, value| + self[convert_key(key)] = value + end + self + end + + # Convert to a Hash with String keys. + def to_hash + Hash.new(default).merge!(self) + end + + protected + + def convert_key(key) + key.is_a?(Symbol) ? key.to_s : key + end + + # Magic predicates. For instance: + # + # options.force? # => !!options['force'] + # options.shebang # => "/usr/lib/local/ruby" + # options.test_framework?(:rspec) # => options[:test_framework] == :rspec + # + def method_missing(method, *args, &block) + method = method.to_s + if method =~ /^(\w+)\?$/ + if args.empty? + !!self[$1] + else + self[$1] == args.first + end + else + self[method] + end + end + end end -end \ No newline at end of file +end diff --git a/middleman-core/lib/middleman-more/templates/smacss.rb b/middleman-core/lib/middleman-more/templates/smacss.rb deleted file mode 100644 index bfe5c914..00000000 --- a/middleman-core/lib/middleman-more/templates/smacss.rb +++ /dev/null @@ -1,30 +0,0 @@ -# SMACSS -class Middleman::Templates::Smacss < Middleman::Templates::Base - - class_option 'css_dir', - :default => 'stylesheets', - :desc => 'The path to the css files' - class_option 'js_dir', - :default => 'javascripts', - :desc => 'The path to the javascript files' - class_option 'images_dir', - :default => 'images', - :desc => 'The path to the image files' - - # Template files are relative to this file - # @return [String] - def self.source_root - File.dirname(__FILE__) - end - - # Output the files - # @return [void] - def build_scaffold! - template 'shared/config.tt', File.join(location, 'config.rb') - directory 'smacss/source', File.join(location, 'source') - empty_directory File.join(location, 'source') - end -end - -# Register the template -Middleman::Templates.register(:smacss, Middleman::Templates::Smacss) diff --git a/middleman-core/lib/middleman-more/templates/smacss/source/_footer.haml b/middleman-core/lib/middleman-more/templates/smacss/source/_footer.haml deleted file mode 100644 index 59c013fd..00000000 --- a/middleman-core/lib/middleman-more/templates/smacss/source/_footer.haml +++ /dev/null @@ -1 +0,0 @@ -%footer © 2013 diff --git a/middleman-core/lib/middleman-more/templates/smacss/source/index.html.haml b/middleman-core/lib/middleman-more/templates/smacss/source/index.html.haml deleted file mode 100644 index 88a918cc..00000000 --- a/middleman-core/lib/middleman-more/templates/smacss/source/index.html.haml +++ /dev/null @@ -1 +0,0 @@ -%h1 Middleman diff --git a/middleman-core/lib/middleman-more/templates/smacss/source/layouts/layout.haml b/middleman-core/lib/middleman-more/templates/smacss/source/layouts/layout.haml deleted file mode 100644 index 7e54cc78..00000000 --- a/middleman-core/lib/middleman-more/templates/smacss/source/layouts/layout.haml +++ /dev/null @@ -1,13 +0,0 @@ -!!! 5 -%html - %head - %title Middleman - %meta{:charset => "utf-8"} - %meta{:content => "Middleman", :name => "description"} - %meta{:content => "on", "http-equiv" => "cleartype"} - %meta{:content => "IE=edge,chrome=1", "http-equiv" => "X-UA-Compatible"} - %link{:href => "stylesheets/style.css", :rel => "stylesheet"} - - %body - = yield - = render_partial 'footer' diff --git a/middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/base/README.markdown b/middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/base/README.markdown deleted file mode 100644 index 77d0402c..00000000 --- a/middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/base/README.markdown +++ /dev/null @@ -1,11 +0,0 @@ -# SMACSS - -### Base - -> A Base rule is applied to an element using an element selector, a descendent selector, or a child selector, along with any pseudo-classes. It doesn’t include any class or ID selectors. It is defining the default styling for how that element should look in all occurrences on the page. - -> - SMACSS, Jonathan Snook - -Place files here that impact top-level elements to apply global styles. - -This template includes [`normalize.css`](http://necolas.github.com/normalize.css/) to give consistent base styles for all browsers. diff --git a/middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/base/base.scss b/middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/base/base.scss deleted file mode 100644 index 10051c76..00000000 --- a/middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/base/base.scss +++ /dev/null @@ -1 +0,0 @@ -// Placeholder diff --git a/middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/base/normalize.scss b/middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/base/normalize.scss deleted file mode 100644 index 57b5d267..00000000 --- a/middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/base/normalize.scss +++ /dev/null @@ -1,375 +0,0 @@ -/*! normalize.css v2.0.1 | MIT License | git.io/normalize */ - -/* ========================================================================== - HTML5 display definitions - ========================================================================== */ - -/* - * Corrects `block` display not defined in IE 8/9. - */ - -article, -aside, -details, -figcaption, -figure, -footer, -header, -hgroup, -nav, -section, -summary { - display: block; -} - -/* - * Corrects `inline-block` display not defined in IE 8/9. - */ - -audio, -canvas, -video { - display: inline-block; -} - -/* - * Prevents modern browsers from displaying `audio` without controls. - * Remove excess height in iOS 5 devices. - */ - -audio:not([controls]) { - display: none; - height: 0; -} - -/* - * Addresses styling for `hidden` attribute not present in IE 8/9. - */ - -[hidden] { - display: none; -} - -/* ========================================================================== - Base - ========================================================================== */ - -/* - * 1. Sets default font family to sans-serif. - * 2. Prevents iOS text size adjust after orientation change, without disabling - * user zoom. - */ - -html { - font-family: sans-serif; /* 1 */ - -webkit-text-size-adjust: 100%; /* 2 */ - -ms-text-size-adjust: 100%; /* 2 */ -} - -/* - * Removes default margin. - */ - -body { - margin: 0; -} - -/* ========================================================================== - Links - ========================================================================== */ - -/* - * Addresses `outline` inconsistency between Chrome and other browsers. - */ - -a:focus { - outline: thin dotted; -} - -/* - * Improves readability when focused and also mouse hovered in all browsers. - */ - -a:active, -a:hover { - outline: 0; -} - -/* ========================================================================== - Typography - ========================================================================== */ - -/* - * Addresses `h1` font sizes within `section` and `article` in Firefox 4+, - * Safari 5, and Chrome. - */ - -h1 { - font-size: 2em; -} - -/* - * Addresses styling not present in IE 8/9, Safari 5, and Chrome. - */ - -abbr[title] { - border-bottom: 1px dotted; -} - -/* - * Addresses style set to `bolder` in Firefox 4+, Safari 5, and Chrome. - */ - -b, -strong { - font-weight: bold; -} - -/* - * Addresses styling not present in Safari 5 and Chrome. - */ - -dfn { - font-style: italic; -} - -/* - * Addresses styling not present in IE 8/9. - */ - -mark { - background: #ff0; - color: #000; -} - - -/* - * Corrects font family set oddly in Safari 5 and Chrome. - */ - -code, -kbd, -pre, -samp { - font-family: monospace, serif; - font-size: 1em; -} - -/* - * Improves readability of pre-formatted text in all browsers. - */ - -pre { - white-space: pre; - white-space: pre-wrap; - word-wrap: break-word; -} - -/* - * Sets consistent quote types. - */ - -q { - quotes: "\201C" "\201D" "\2018" "\2019"; -} - -/* - * Addresses inconsistent and variable font size in all browsers. - */ - -small { - font-size: 80%; -} - -/* - * Prevents `sub` and `sup` affecting `line-height` in all browsers. - */ - -sub, -sup { - font-size: 75%; - line-height: 0; - position: relative; - vertical-align: baseline; -} - -sup { - top: -0.5em; -} - -sub { - bottom: -0.25em; -} - -/* ========================================================================== - Embedded content - ========================================================================== */ - -/* - * Removes border when inside `a` element in IE 8/9. - */ - -img { - border: 0; -} - -/* - * Corrects overflow displayed oddly in IE 9. - */ - -svg:not(:root) { - overflow: hidden; -} - -/* ========================================================================== - Figures - ========================================================================== */ - -/* - * Addresses margin not present in IE 8/9 and Safari 5. - */ - -figure { - margin: 0; -} - -/* ========================================================================== - Forms - ========================================================================== */ - -/* - * Define consistent border, margin, and padding. - */ - -fieldset { - border: 1px solid #c0c0c0; - margin: 0 2px; - padding: 0.35em 0.625em 0.75em; -} - -/* - * 1. Corrects color not being inherited in IE 8/9. - * 2. Remove padding so people aren't caught out if they zero out fieldsets. - */ - -legend { - border: 0; /* 1 */ - padding: 0; /* 2 */ -} - -/* - * 1. Corrects font family not being inherited in all browsers. - * 2. Corrects font size not being inherited in all browsers. - * 3. Addresses margins set differently in Firefox 4+, Safari 5, and Chrome - */ - -button, -input, -select, -textarea { - font-family: inherit; /* 1 */ - font-size: 100%; /* 2 */ - margin: 0; /* 3 */ -} - -/* - * Addresses Firefox 4+ setting `line-height` on `input` using `!important` in - * the UA stylesheet. - */ - -button, -input { - line-height: normal; -} - -/* - * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` - * and `video` controls. - * 2. Corrects inability to style clickable `input` types in iOS. - * 3. Improves usability and consistency of cursor style between image-type - * `input` and others. - */ - -button, -html input[type="button"], /* 1 */ -input[type="reset"], -input[type="submit"] { - -webkit-appearance: button; /* 2 */ - cursor: pointer; /* 3 */ -} - -/* - * Re-set default cursor for disabled elements. - */ - -button[disabled], -input[disabled] { - cursor: default; -} - -/* - * 1. Addresses box sizing set to `content-box` in IE 8/9. - * 2. Removes excess padding in IE 8/9. - */ - -input[type="checkbox"], -input[type="radio"] { - box-sizing: border-box; /* 1 */ - padding: 0; /* 2 */ -} - -/* - * 1. Addresses `appearance` set to `searchfield` in Safari 5 and Chrome. - * 2. Addresses `box-sizing` set to `border-box` in Safari 5 and Chrome - * (include `-moz` to future-proof). - */ - -input[type="search"] { - -webkit-appearance: textfield; /* 1 */ - -moz-box-sizing: content-box; - -webkit-box-sizing: content-box; /* 2 */ - box-sizing: content-box; -} - -/* - * Removes inner padding and search cancel button in Safari 5 and Chrome - * on OS X. - */ - -input[type="search"]::-webkit-search-cancel-button, -input[type="search"]::-webkit-search-decoration { - -webkit-appearance: none; -} - -/* - * Removes inner padding and border in Firefox 4+. - */ - -button::-moz-focus-inner, -input::-moz-focus-inner { - border: 0; - padding: 0; -} - -/* - * 1. Removes default vertical scrollbar in IE 8/9. - * 2. Improves readability and alignment in all browsers. - */ - -textarea { - overflow: auto; /* 1 */ - vertical-align: top; /* 2 */ -} - -/* ========================================================================== - Tables - ========================================================================== */ - -/* - * Remove most spacing between table cells. - */ - -table { - border-collapse: collapse; - border-spacing: 0; -} diff --git a/middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/layout/README.markdown b/middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/layout/README.markdown deleted file mode 100644 index 9e813661..00000000 --- a/middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/layout/README.markdown +++ /dev/null @@ -1,9 +0,0 @@ -# SMACSS - -### Layout - -> CSS, by its very nature, is used to lay elements out on the page. However, there is a distinction between layouts dictating the major and minor components of a page. The minor components—such as a callout, or login form, or a navigation item—sit within the scope of major components such as a header or footer. I refer to the minor components as Modules [...] The major components are referred to as Layout styles. - -> - SMACSS, Jonathan Snook - -Use this directory for files that contain the CSS to layout major elements on the page. We typically use one file per major component and `@import` them in `style.css.scss`. diff --git a/middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/modules/README.markdown b/middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/modules/README.markdown deleted file mode 100644 index 2b394b8b..00000000 --- a/middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/modules/README.markdown +++ /dev/null @@ -1,9 +0,0 @@ -# SMACSS - -### Modules - -> A Module is a more discrete component of the page. It is your navigation bars and your carousels and your dialogs and your widgets and so on. This is the meat of the page. Modules sit inside Layout components. Modules can sometimes sit within other Modules, too. Each Module should be designed to exist as a standalone component. In doing so, the page will be more flexible. If done right, Modules can easily be moved to different parts of the layout without breaking. - -> - SMACSS, Jonathan Snook - -In this directory we typically use one file per module. diff --git a/middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/states/README.markdown b/middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/states/README.markdown deleted file mode 100644 index c3e56e12..00000000 --- a/middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/states/README.markdown +++ /dev/null @@ -1,12 +0,0 @@ -# SMACSS - -### States - -> A state is something that augments and overrides all other styles. For example, an accordion section may be in a collapsed or expanded state. A message may be in a success or error state. [Modules and states] differ in two key ways: - -> 1. State styles can apply to layout and/or module styles; and -> 2. State styles indicate a JavaScript dependency. - -> - SMACSS, Jonathan Snook - -State styles typically refer to styles that only exist on an element for a short period time, for example: styles for invalid form fields would go in `validations.scss`. diff --git a/middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/style.css.scss b/middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/style.css.scss deleted file mode 100644 index 15e36716..00000000 --- a/middleman-core/lib/middleman-more/templates/smacss/source/stylesheets/style.css.scss +++ /dev/null @@ -1,12 +0,0 @@ -// Import Base Styles -@import "base/normalize" -// @import "base/all_your" - -// Import Layout Styles -// @import "layout/grid" - -// Import Module Styles -// @import "modules/buttons" - -// Import State Styles -// @import "states/validation" diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/server.rb b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/server.rb index f8dd3323..27395fe4 100644 --- a/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/server.rb +++ b/middleman-core/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/server.rb @@ -21,7 +21,7 @@ module Padrino # Starts the application on the available server with specified options. def self.start(app, opts={}) - options = {}.merge(opts) # We use a standard hash instead of Thor::CoreExt::HashWithIndifferentAccess + options = {}.merge(opts) # We use a standard hash instead of Middleman::Util::HashWithIndifferentAccess options.symbolize_keys! options[:Host] = options.delete(:host) || '127.0.0.1' options[:Port] = options.delete(:port) || 3000 diff --git a/middleman-core/middleman-core.gemspec b/middleman-core/middleman-core.gemspec index 4dd98a8e..91a214df 100644 --- a/middleman-core/middleman-core.gemspec +++ b/middleman-core/middleman-core.gemspec @@ -14,7 +14,6 @@ Gem::Specification.new do |s| s.files = `git ls-files -z`.split("\0") s.test_files = `git ls-files -z -- {fixtures,features}/*`.split("\0") - s.executable = "middleman" s.require_path = "lib" s.required_ruby_version = '>= 1.9.3' @@ -26,9 +25,6 @@ Gem::Specification.new do |s| # Builder s.add_dependency("rack-test", ["~> 0.6.2"]) - # CLI - s.add_dependency("thor", [">= 0.17.0", "< 2.0"]) - # Helpers s.add_dependency("activesupport", ["~> 4.0.1"]) diff --git a/middleman/middleman.gemspec b/middleman/middleman.gemspec index dcbbd21f..5e334555 100644 --- a/middleman/middleman.gemspec +++ b/middleman/middleman.gemspec @@ -19,6 +19,7 @@ Gem::Specification.new do |s| s.required_ruby_version = '>= 1.9.3' s.add_dependency("middleman-core", Middleman::VERSION) + s.add_dependency("middleman-cli", Middleman::VERSION) s.add_dependency("middleman-sprockets", ">= 3.1.2") s.add_dependency("haml", [">= 3.1.6"]) s.add_dependency("sass", [">= 3.1.20"]) From c06fbcfc935daddb1eb26827466986f2b68c52f9 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Thu, 2 Jan 2014 17:25:31 -0800 Subject: [PATCH 012/580] rely directly on rack-mock --- middleman-cli/lib/middleman-cli/build.rb | 5 ++-- .../middleman-core/core_extensions/request.rb | 2 +- .../step_definitions/server_steps.rb | 24 +++++++++++-------- .../middleman-more/extensions/asset_hash.rb | 6 ++--- middleman-core/middleman-core.gemspec | 3 --- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/middleman-cli/lib/middleman-cli/build.rb b/middleman-cli/lib/middleman-cli/build.rb index c4d20923..635d750d 100644 --- a/middleman-cli/lib/middleman-cli/build.rb +++ b/middleman-cli/lib/middleman-cli/build.rb @@ -50,9 +50,8 @@ module Middleman::Cli raise Thor::Error, 'Error: Could not find a Middleman project config, perhaps you are in the wrong folder?' end - # Use Rack::Test for inspecting a running server for output require 'rack' - require 'rack/test' + require 'rack/mock' require 'find' @@ -115,7 +114,7 @@ module Middleman::Cli @to_clean = Set.new @logger = @app.logger - @rack = ::Rack::Test::Session.new(@app.class.to_rack_app) + @rack = ::Rack::MockRequest.new(@app.class.to_rack_app) super(base, @build_dir, config) end diff --git a/middleman-core/lib/middleman-core/core_extensions/request.rb b/middleman-core/lib/middleman-core/core_extensions/request.rb index 352dc557..1ef8b3a6 100644 --- a/middleman-core/lib/middleman-core/core_extensions/request.rb +++ b/middleman-core/lib/middleman-core/core_extensions/request.rb @@ -221,7 +221,7 @@ module Middleman run_hook :before # Get the resource object for this path - resource = sitemap.find_resource_by_destination_path(request_path) + resource = sitemap.find_resource_by_destination_path(request_path.gsub(' ', '%20')) # Return 404 if not in sitemap return not_found(res, request_path) unless resource && !resource.ignored? diff --git a/middleman-core/lib/middleman-core/step_definitions/server_steps.rb b/middleman-core/lib/middleman-core/step_definitions/server_steps.rb index 7f51de6e..9e7ccc5d 100644 --- a/middleman-core/lib/middleman-core/step_definitions/server_steps.rb +++ b/middleman-core/lib/middleman-core/step_definitions/server_steps.rb @@ -1,6 +1,6 @@ # encoding: UTF-8 -require 'rack/test' +require 'rack/mock' Given /^a clean server$/ do @initialize_commands = [] @@ -57,7 +57,7 @@ Given /^the Server is running$/ do end app_rack = @server_inst.class.to_rack_app - @browser = ::Rack::Test::Session.new(::Rack::MockSession.new(app_rack)) + @browser = ::Rack::MockRequest.new(app_rack) end Given /^the Server is running at "([^\"]*)"$/ do |app_path| @@ -66,33 +66,37 @@ Given /^the Server is running at "([^\"]*)"$/ do |app_path| end When /^I go to "([^\"]*)"$/ do |url| - @browser.get(URI.escape(url)) + @last_response = @browser.get(URI.escape(url)) end Then /^going to "([^\"]*)" should not raise an exception$/ do |url| - lambda { @browser.get(URI.escape(url)) }.should_not raise_exception + last_response = nil + lambda { + last_response = @browser.get(URI.escape(url)) + }.should_not raise_exception + @last_response = last_response end Then /^the content type should be "([^\"]*)"$/ do |expected| - @browser.last_response.content_type.should start_with(expected) + @last_response.content_type.should start_with(expected) end Then /^I should see "([^\"]*)"$/ do |expected| - @browser.last_response.body.should include(expected) + @last_response.body.should include(expected) end Then /^I should see '([^\']*)'$/ do |expected| - @browser.last_response.body.should include(expected) + @last_response.body.should include(expected) end Then /^I should see:$/ do |expected| - @browser.last_response.body.should include(expected) + @last_response.body.should include(expected) end Then /^I should not see "([^\"]*)"$/ do |expected| - @browser.last_response.body.should_not include(expected) + @last_response.body.should_not include(expected) end Then /^I should see "([^\"]*)" lines$/ do |lines| - @browser.last_response.body.chomp.split($/).length.should == lines.to_i + @last_response.body.chomp.split($/).length.should == lines.to_i end diff --git a/middleman-core/lib/middleman-more/extensions/asset_hash.rb b/middleman-core/lib/middleman-more/extensions/asset_hash.rb index c417446a..0934dbaa 100644 --- a/middleman-core/lib/middleman-more/extensions/asset_hash.rb +++ b/middleman-core/lib/middleman-more/extensions/asset_hash.rb @@ -8,7 +8,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension super require 'digest/sha1' - require 'rack/test' + require 'rack/mock' require 'uri' end @@ -22,7 +22,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension # Update the main sitemap resource list # @return [void] def manipulate_resource_list(resources) - @rack_client ||= ::Rack::Test::Session.new(app.class.to_rack_app) + @rack_client = ::Rack::MockRequest.new(app.class.to_rack_app) # Process resources in order: binary images and fonts, then SVG, then JS/CSS. # This is so by the time we get around to the text files (which may reference @@ -43,7 +43,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension return if ignored_resource?(resource) # Render through the Rack interface so middleware and mounted apps get a shot - response = @rack_client.get(URI.escape(resource.destination_path), {}, { 'bypass_asset_hash' => 'true' }) + response = @rack_client.get(URI.escape(resource.destination_path), { 'bypass_asset_hash' => 'true' }) raise "#{resource.path} should be in the sitemap!" unless response.status == 200 digest = Digest::SHA1.hexdigest(response.body)[0..7] diff --git a/middleman-core/middleman-core.gemspec b/middleman-core/middleman-core.gemspec index 91a214df..30f59c00 100644 --- a/middleman-core/middleman-core.gemspec +++ b/middleman-core/middleman-core.gemspec @@ -22,9 +22,6 @@ Gem::Specification.new do |s| s.add_dependency("rack", [">= 1.4.5"]) s.add_dependency("tilt", ["~> 1.4.1"]) - # Builder - s.add_dependency("rack-test", ["~> 0.6.2"]) - # Helpers s.add_dependency("activesupport", ["~> 4.0.1"]) From f40903e66382b2aa40f74053339963bfd6e75c29 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Fri, 3 Jan 2014 13:15:02 -0800 Subject: [PATCH 013/580] move rendering into specialized File and Template rendering classes. --- .../lib/middleman-core/application.rb | 15 +- .../core_extensions/rendering.rb | 287 ------------------ .../middleman-core/core_extensions/request.rb | 3 +- .../lib/middleman-core/file_renderer.rb | 119 ++++++++ .../lib/middleman-core/sitemap/resource.rb | 7 +- .../lib/middleman-core/template_context.rb | 21 +- .../lib/middleman-core/template_renderer.rb | 230 ++++++++++++++ 7 files changed, 380 insertions(+), 302 deletions(-) create mode 100644 middleman-core/lib/middleman-core/file_renderer.rb create mode 100644 middleman-core/lib/middleman-core/template_renderer.rb diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb index 4103c2b2..0b67d48f 100644 --- a/middleman-core/lib/middleman-core/application.rb +++ b/middleman-core/lib/middleman-core/application.rb @@ -1,6 +1,3 @@ -# Using Tilt for templating -require 'tilt' - # i18n Built-in require 'i18n' @@ -25,6 +22,8 @@ require 'middleman-core/configuration' require 'middleman-core/core_extensions' require 'middleman-core/config_context' +require 'middleman-core/file_renderer' +require 'middleman-core/template_renderer' # Core Middleman Class module Middleman @@ -161,17 +160,21 @@ module Middleman # Template cache attr_reader :cache + attr_reader :template_context_class + attr_reader :generic_template_context delegate :link_to, :image_tag, :to => :generic_template_context # Initialize the Middleman project def initialize(&block) - @cache = ::Tilt::Cache.new @logger = ::Middleman::Logger.singleton @template_context_class = Class.new(Middleman::TemplateContext) @generic_template_context = @template_context_class.new(self) @config_context = ConfigContext.new(self, @template_context_class) + ::Middleman::FileRenderer.cache.clear + ::Middleman::TemplateRenderer.cache.clear + # Setup the default values from calls to set before initialization self.class.config.load_settings(self.class.superclass.config.all_settings) @@ -199,6 +202,10 @@ module Middleman super end + def add_to_instance(name, &func) + self.define_singleton_method(name, &func) + end + def add_to_config_context(name, &func) @config_context.define_singleton_method(name, &func) end diff --git a/middleman-core/lib/middleman-core/core_extensions/rendering.rb b/middleman-core/lib/middleman-core/core_extensions/rendering.rb index 734b9195..12b8e734 100644 --- a/middleman-core/lib/middleman-core/core_extensions/rendering.rb +++ b/middleman-core/lib/middleman-core/core_extensions/rendering.rb @@ -99,10 +99,6 @@ module Middleman end end - # Custom error class for handling - class TemplateNotFound < RuntimeError - end - # Rendering instance methods module InstanceMethods @@ -115,289 +111,6 @@ module Middleman @_template_extensions.merge!(extension_map) if extension_map @_template_extensions end - - # Render a template, with layout, given a path - # - # @param [String] path - # @param [Hash] locs - # @param [Hash] opts - # @return [String] - def render_template(path, locs={}, opts={}, blocks=[]) - extension = File.extname(path) - engine = extension[1..-1].to_sym - - if defined?(::I18n) - old_locale = ::I18n.locale - ::I18n.locale = opts[:lang] if opts[:lang] - end - - # Sandboxed class for template eval - context = @template_context_class.new(self, locs, opts) - - if context.respond_to?(:init_haml_helpers) - context.init_haml_helpers - end - - blocks.each do |block| - context.instance_eval(&block) - end - - # Keep rendering template until we've used up all extensions. This - # handles cases like `style.css.sass.erb` - content = nil - while ::Tilt[path] - begin - opts[:template_body] = content if content - content = render_individual_file(path, locs, opts, context) - path = File.basename(path, File.extname(path)) - rescue LocalJumpError - raise "Tried to render a layout (calls yield) at #{path} like it was a template. Non-default layouts need to be in #{source}/#{layout_dir}." - end - end - - # If we need a layout and have a layout, use it - if layout_path = fetch_layout(engine, opts) - content = render_individual_file(layout_path, locs, opts, context) { content } - end - - # Return result - content - ensure - # Pop all the saved variables from earlier as we may be returning to a - # previous render (layouts, partials, nested layouts). - ::I18n.locale = old_locale if defined?(::I18n) - end - - # Render an on-disk file. Used for everything, including layouts. - # - # @param [String, Symbol] path - # @param [Hash] locs - # @param [Hash] opts - # @param [Class] context - # @return [String] - def render_individual_file(path, locs = {}, opts = {}, context, &block) - path = path.to_s - - # Detect the remdering engine from the extension - extension = File.extname(path) - engine = extension[1..-1].to_sym - - # Store last engine for later (could be inside nested renders) - context.current_engine, engine_was = engine, context.current_engine - - # Save current buffer for later - _buf_was = context.save_buffer - - # Read from disk or cache the contents of the file - body = if opts[:template_body] - opts.delete(:template_body) - else - template_data_for_file(path) - end - - # Merge per-extension options from config - extension = File.extname(path) - options = opts.dup.merge(options_for_ext(extension)) - options[:outvar] ||= '@_out_buf' - options.delete(:layout) - - # Overwrite with frontmatter options - options = options.deep_merge(options[:renderer_options]) if options[:renderer_options] - - template_class = Tilt[path] - # Allow hooks to manipulate the template before render - self.class.callbacks_for_hook(:before_render).each do |callback| - newbody = callback.call(body, path, locs, template_class) - body = newbody if newbody # Allow the callback to return nil to skip it - end - - # Read compiled template from disk or cache - template = cache.fetch(:compiled_template, extension, options, body) do - ::Tilt.new(path, 1, options) { body } - end - - # Render using Tilt - content = template.render(context, locs, &block) - - # Allow hooks to manipulate the result after render - self.class.callbacks_for_hook(:after_render).each do |callback| - content = callback.call(content, path, locs, template_class) - end - - output = ::ActiveSupport::SafeBuffer.new '' - output.safe_concat content - output - ensure - # Reset stored buffer - context.restore_buffer(_buf_was) - context.current_engine = engine_was - end - - # Get the template data from a path - # @param [String] path - # @return [String] - def template_data_for_file(path) - if extensions[:frontmatter] - extensions[:frontmatter].template_data_for_file(path) - else - File.read(File.expand_path(path, source_dir)) - end - end - - # Get a hash of configuration options for a given file extension, from - # config.rb - # - # @param [String] ext - # @return [Hash] - def options_for_ext(ext) - # Read options for extension from config/Tilt or cache - cache.fetch(:options_for_ext, ext) do - options = {} - - # Find all the engines which handle this extension in tilt. Look for - # config variables of that name and merge it - extension_class = ::Tilt[ext] - ::Tilt.mappings.each do |mapping_ext, engines| - next unless engines.include? extension_class - engine_options = config[mapping_ext.to_sym] || {} - options.merge!(engine_options) - end - - options - end - end - - # Find a layout for a given engine - # - # @param [Symbol] engine - # @param [Hash] opts - # @return [String] - def fetch_layout(engine, opts) - # The layout name comes from either the system default or the options - local_layout = opts.has_key?(:layout) ? opts[:layout] : config[:layout] - return false unless local_layout - - # Look for engine-specific options - engine_options = respond_to?(engine) ? send(engine) : {} - - # The engine for the layout can be set in options, engine_options or passed - # into this method - layout_engine = if opts.has_key?(:layout_engine) - opts[:layout_engine] - elsif engine_options.has_key?(:layout_engine) - engine_options[:layout_engine] - else - engine - end - - # Automatic mode - if local_layout == :_auto_layout - # Look for :layout of any extension - # If found, use it. If not, continue - locate_layout(:layout, layout_engine) || false - else - # Look for specific layout - # If found, use it. If not, error. - if layout_path = locate_layout(local_layout, layout_engine) - layout_path - else - raise ::Middleman::CoreExtensions::Rendering::TemplateNotFound, "Could not locate layout: #{local_layout}" - end - end - end - - # Find a layout on-disk, optionally using a specific engine - # @param [String] name - # @param [Symbol] preferred_engine - # @return [String] - def locate_layout(name, preferred_engine=nil) - # Whether we've found the layout - layout_path = false - - # If we prefer a specific engine - if !preferred_engine.nil? - # Check root - layout_path, layout_engine = resolve_template(name, :preferred_engine => preferred_engine) - - # Check layouts folder - if !layout_path - layout_path, layout_engine = resolve_template(File.join(config[:layouts_dir], name.to_s), :preferred_engine => preferred_engine) - end - end - - # Check root, no preference - if !layout_path - layout_path, layout_engine = resolve_template(name) - end - - # Check layouts folder, no preference - if !layout_path - layout_path, layout_engine = resolve_template(File.join(config[:layouts_dir], name.to_s)) - end - - # Return the path - layout_path - end - - # Find a template on disk given a output path - # @param [String] request_path - # @param [Hash] options - # @return [Array, Boolean] - def resolve_template(request_path, options={}) - # Find the path by searching or using the cache - request_path = request_path.to_s - cache.fetch(:resolve_template, request_path, options) do - relative_path = Util.strip_leading_slash(request_path) - on_disk_path = File.expand_path(relative_path, self.source_dir) - - # By default, any engine will do - preferred_engine = '*' - - # Unless we're specifically looking for a preferred engine - if options.has_key?(:preferred_engine) - extension_class = ::Tilt[options[:preferred_engine]] - matched_exts = [] - - # Get a list of extensions for a preferred engine - # TODO: Cache this - ::Tilt.mappings.each do |ext, engines| - next unless engines.include? extension_class - matched_exts << ext - end - - # Change the glob to only look for the matched extensions - if matched_exts.length > 0 - preferred_engine = '{' + matched_exts.join(',') + '}' - else - return false - end - end - - # Look for files that match - path_with_ext = on_disk_path + '.' + preferred_engine - - found_path = Dir[path_with_ext].find do |path| - ::Tilt[path] - end - - if !found_path && options[:try_without_underscore] && - path_no_underscore = path_with_ext. - sub(relative_path, relative_path.sub(/^_/, ''). - sub(/\/_/, '/')) - found_path = Dir[path_no_underscore].find do |path| - ::Tilt[path] - end - end - - # If we found one, return it and the found engine - if found_path || files.exists?(on_disk_path) - engine = found_path ? File.extname(found_path)[1..-1].to_sym : nil - [ found_path || on_disk_path, engine ] - else - false - end - end - end end end end diff --git a/middleman-core/lib/middleman-core/core_extensions/request.rb b/middleman-core/lib/middleman-core/core_extensions/request.rb index 1ef8b3a6..6758a7bf 100644 --- a/middleman-core/lib/middleman-core/core_extensions/request.rb +++ b/middleman-core/lib/middleman-core/core_extensions/request.rb @@ -5,6 +5,7 @@ require 'rack/lint' require 'rack/head' require 'middleman-core/util' +require 'middleman-core/template_renderer' module Middleman module CoreExtensions @@ -242,7 +243,7 @@ module Middleman res.write output # Valid content is a 200 status res.status = 200 - rescue Middleman::CoreExtensions::Rendering::TemplateNotFound => e + rescue Middleman::TemplateRenderer::TemplateNotFound => e res.write "Error: #{e.message}" res.status = 500 end diff --git a/middleman-core/lib/middleman-core/file_renderer.rb b/middleman-core/lib/middleman-core/file_renderer.rb new file mode 100644 index 00000000..0393ad83 --- /dev/null +++ b/middleman-core/lib/middleman-core/file_renderer.rb @@ -0,0 +1,119 @@ +require 'tilt' +require 'active_support/core_ext/string/output_safety' + +module Middleman + + class FileRenderer + + def self.cache + @_cache ||= ::Tilt::Cache.new + end + + delegate :cache, :to => :"self.class" + + def initialize(app, path) + @app = app + @path = path.to_s + end + + # Render an on-disk file. Used for everything, including layouts. + # + # @param [Hash] locs + # @param [Hash] opts + # @param [Class] context + # @return [String] + def render(locs = {}, opts = {}, context, &block) + path = @path.dup + + # Detect the remdering engine from the extension + extension = File.extname(path) + engine = extension[1..-1].to_sym + + # Store last engine for later (could be inside nested renders) + context.current_engine, engine_was = engine, context.current_engine + + # Save current buffer for later + _buf_was = context.save_buffer + + # Read from disk or cache the contents of the file + body = if opts[:template_body] + opts.delete(:template_body) + else + get_template_data_for_file + end + + # Merge per-extension options from config + extension = File.extname(path) + options = opts.dup.merge(options_for_ext(extension)) + options[:outvar] ||= '@_out_buf' + options.delete(:layout) + + # Overwrite with frontmatter options + options = options.deep_merge(options[:renderer_options]) if options[:renderer_options] + + template_class = ::Tilt[path] + # Allow hooks to manipulate the template before render + @app.class.callbacks_for_hook(:before_render).each do |callback| + newbody = callback.call(body, path, locs, template_class) + body = newbody if newbody # Allow the callback to return nil to skip it + end + + # Read compiled template from disk or cache + template = cache.fetch(:compiled_template, extension, options, body) do + ::Tilt.new(path, 1, options) { body } + end + + # Render using Tilt + content = template.render(context, locs, &block) + + # Allow hooks to manipulate the result after render + @app.class.callbacks_for_hook(:after_render).each do |callback| + content = callback.call(content, path, locs, template_class) + end + + output = ::ActiveSupport::SafeBuffer.new '' + output.safe_concat content + output + ensure + # Reset stored buffer + context.restore_buffer(_buf_was) + context.current_engine = engine_was + end + + # Get the template data from a path + # @param [String] path + # @return [String] + def get_template_data_for_file + if @app.extensions[:frontmatter] + @app.extensions[:frontmatter].template_data_for_file(@path) + else + File.read(File.expand_path(@path, source_dir)) + end + end + + protected + + # Get a hash of configuration options for a given file extension, from + # config.rb + # + # @param [String] ext + # @return [Hash] + def options_for_ext(ext) + # Read options for extension from config/Tilt or cache + cache.fetch(:options_for_ext, ext) do + options = {} + + # Find all the engines which handle this extension in tilt. Look for + # config variables of that name and merge it + extension_class = ::Tilt[ext] + ::Tilt.mappings.each do |mapping_ext, engines| + next unless engines.include? extension_class + engine_options = @app.config[mapping_ext.to_sym] || {} + options.merge!(engine_options) + end + + options + end + end + end +end \ No newline at end of file diff --git a/middleman-core/lib/middleman-core/sitemap/resource.rb b/middleman-core/lib/middleman-core/sitemap/resource.rb index d0d39483..0a2cb502 100644 --- a/middleman-core/lib/middleman-core/sitemap/resource.rb +++ b/middleman-core/lib/middleman-core/sitemap/resource.rb @@ -1,5 +1,7 @@ require 'middleman-core/sitemap/extensions/traversal' require 'middleman-core/sitemap/extensions/content_type' +require 'middleman-core/file_renderer' +require 'middleman-core/template_renderer' module Middleman @@ -106,7 +108,7 @@ module Middleman # @return [String] def render(opts={}, locs={}, &block) if !template? - return app.template_data_for_file(source_file) + return ::Middleman::FileRenderer.new(@app, source_file).get_template_data_for_file end relative_source = Pathname(source_file).relative_path_from(Pathname(app.root)) @@ -140,7 +142,8 @@ module Middleman opts[:layout] = false if %w(.js .json .css .txt).include?(self.ext) end - app.render_template(source_file, locs, opts, blocks) + renderer = ::Middleman::TemplateRenderer.new(@app, source_file) + renderer.render(locs, opts, blocks) end end diff --git a/middleman-core/lib/middleman-core/template_context.rb b/middleman-core/lib/middleman-core/template_context.rb index c2d666d8..d26e4667 100644 --- a/middleman-core/lib/middleman-core/template_context.rb +++ b/middleman-core/lib/middleman-core/template_context.rb @@ -1,3 +1,6 @@ +require 'middleman-core/file_renderer' +require 'middleman-core/template_renderer' + module Middleman class TemplateContext attr_reader :app @@ -27,7 +30,7 @@ module Middleman # Save current buffer for later _buf_was = save_buffer - layout_path = @app.locate_layout(layout_name, self.current_engine) + layout_path = ::Middleman::TemplateRenderer.locate_layout(@app, layout_name, self.current_engine) extension = File.extname(layout_path) engine = extension[1..-1].to_sym @@ -46,7 +49,8 @@ module Middleman restore_buffer(_buf_was) end - concat_safe_content @app.render_individual_file(layout_path, @current_locs || {}, @current_opts || {}, self) { content } + file_renderer = ::Middleman::FileRenderer.new(@app, layout_path) + concat_safe_content file_renderer.render(@current_locs || {}, @current_opts || {}, self) { content } ensure self.current_engine = engine_was end @@ -75,30 +79,31 @@ module Middleman relative_dir = File.join(current_dir.sub(%r{^#{Regexp.escape(self.source_dir)}/?}, ''), data) # Try to use the current engine first - found_partial, found_engine = @app.resolve_template(relative_dir, :preferred_engine => engine, :try_without_underscore => true) + found_partial, found_engine = ::Middleman::TemplateRenderer.resolve_template(@app, relative_dir, :preferred_engine => engine, :try_without_underscore => true) # Fall back to any engine available if !found_partial - found_partial, found_engine = @app.resolve_template(relative_dir, :try_without_underscore => true) + found_partial, found_engine = ::Middleman::TemplateRenderer.resolve_template(@app, relative_dir, :try_without_underscore => true) end end # Look in the partials_dir for the partial with the current engine partials_path = File.join(config[:partials_dir], data) if !found_partial && !engine.nil? - found_partial, found_engine = @app.resolve_template(partials_path, :preferred_engine => engine, :try_without_underscore => true) + found_partial, found_engine = ::Middleman::TemplateRenderer.resolve_template(@app, partials_path, :preferred_engine => engine, :try_without_underscore => true) end # Look in the root with any engine if !found_partial - found_partial, found_engine = @app.resolve_template(partials_path, :try_without_underscore => true) + found_partial, found_engine = ::Middleman::TemplateRenderer.resolve_template(@app, partials_path, :try_without_underscore => true) end # Render the partial if found, otherwide throw exception if found_partial - @app.render_individual_file(found_partial, locals, options, self, &block) + file_renderer = ::Middleman::FileRenderer.new(@app, found_partial) + file_renderer.render(locals, options, self, &block) else - raise ::Middleman::CoreExtensions::Rendering::TemplateNotFound, "Could not locate partial: #{data}" + raise ::Middleman::TemplateRenderer::TemplateNotFound, "Could not locate partial: #{data}" end end end diff --git a/middleman-core/lib/middleman-core/template_renderer.rb b/middleman-core/lib/middleman-core/template_renderer.rb new file mode 100644 index 00000000..65585c77 --- /dev/null +++ b/middleman-core/lib/middleman-core/template_renderer.rb @@ -0,0 +1,230 @@ +require 'tilt' +require 'active_support/core_ext/string/output_safety' +require 'middleman-core/template_context' +require 'middleman-core/file_renderer' + +module Middleman + + class TemplateRenderer + + def self.cache + @_cache ||= ::Tilt::Cache.new + end + + delegate :cache, :to => :"self.class" + + # Custom error class for handling + class TemplateNotFound < RuntimeError; end + + def initialize(app, path) + @app = app + @path = path + end + + # Render a template, with layout, given a path + # + # @param [Hash] locs + # @param [Hash] opts + # @return [String] + def render(locs={}, opts={}, blocks=[]) + path = @path.dup + extension = File.extname(path) + engine = extension[1..-1].to_sym + + if defined?(::I18n) + old_locale = ::I18n.locale + ::I18n.locale = opts[:lang] if opts[:lang] + end + + # Sandboxed class for template eval + context = @app.template_context_class.new(@app, locs, opts) + + if context.respond_to?(:init_haml_helpers) + context.init_haml_helpers + end + + blocks.each do |block| + context.instance_eval(&block) + end + + # Keep rendering template until we've used up all extensions. This + # handles cases like `style.css.sass.erb` + content = nil + while ::Tilt[path] + begin + opts[:template_body] = content if content + + content_renderer = ::Middleman::FileRenderer.new(@app, path) + content = content_renderer.render(locs, opts, context) + + path = File.basename(path, File.extname(path)) + rescue LocalJumpError + raise "Tried to render a layout (calls yield) at #{path} like it was a template. Non-default layouts need to be in #{source}/#{layout_dir}." + end + end + + # If we need a layout and have a layout, use it + if layout_path = fetch_layout(engine, opts) + layout_renderer = ::Middleman::FileRenderer.new(@app, layout_path) + content = layout_renderer.render(locs, opts, context) { content } + end + + # Return result + content + ensure + # Pop all the saved variables from earlier as we may be returning to a + # previous render (layouts, partials, nested layouts). + ::I18n.locale = old_locale if defined?(::I18n) + end + + protected + + # Find a layout for a given engine + # + # @param [Symbol] engine + # @param [Hash] opts + # @return [String] + def fetch_layout(engine, opts) + # The layout name comes from either the system default or the options + local_layout = opts.has_key?(:layout) ? opts[:layout] : @app.config[:layout] + return false unless local_layout + + # Look for engine-specific options + engine_options = @app.config.respond_to?(engine) ? @app.config.send(engine) : {} + + # The engine for the layout can be set in options, engine_options or passed + # into this method + layout_engine = if opts.has_key?(:layout_engine) + opts[:layout_engine] + elsif engine_options.has_key?(:layout_engine) + engine_options[:layout_engine] + else + engine + end + + # Automatic mode + if local_layout == :_auto_layout + # Look for :layout of any extension + # If found, use it. If not, continue + locate_layout(:layout, layout_engine) || false + else + # Look for specific layout + # If found, use it. If not, error. + if layout_path = locate_layout(local_layout, layout_engine) + layout_path + else + raise ::Middleman::TemplateRenderer::TemplateNotFound, "Could not locate layout: #{local_layout}" + end + end + end + + # Find a layout on-disk, optionally using a specific engine + # @param [String] name + # @param [Symbol] preferred_engine + # @return [String] + def locate_layout(name, preferred_engine=nil) + self.class.locate_layout(@app, name, preferred_engine) + end + + # Find a layout on-disk, optionally using a specific engine + # @param [String] name + # @param [Symbol] preferred_engine + # @return [String] + def self.locate_layout(app, name, preferred_engine=nil) + # Whether we've found the layout + layout_path = false + + # If we prefer a specific engine + if !preferred_engine.nil? + # Check root + layout_path, layout_engine = resolve_template(app, name, :preferred_engine => preferred_engine) + + # Check layouts folder + if !layout_path + layout_path, layout_engine = resolve_template(app, File.join(app.config[:layouts_dir], name.to_s), :preferred_engine => preferred_engine) + end + end + + # Check root, no preference + if !layout_path + layout_path, layout_engine = resolve_template(app, name) + end + + # Check layouts folder, no preference + if !layout_path + layout_path, layout_engine = resolve_template(app, File.join(app.config[:layouts_dir], name.to_s)) + end + + # Return the path + layout_path + end + + # Find a template on disk given a output path + # @param [String] request_path + # @param [Hash] options + # @return [Array, Boolean] + def resolve_template(request_path, options={}) + self.class.resolve_template(@app, request_path, options) + end + + # Find a template on disk given a output path + # @param [String] request_path + # @param [Hash] options + # @return [Array, Boolean] + def self.resolve_template(app, request_path, options={}) + # Find the path by searching or using the cache + request_path = request_path.to_s + cache.fetch(:resolve_template, request_path, options) do + relative_path = Util.strip_leading_slash(request_path) + on_disk_path = File.expand_path(relative_path, app.source_dir) + + # By default, any engine will do + preferred_engine = '*' + + # Unless we're specifically looking for a preferred engine + if options.has_key?(:preferred_engine) + extension_class = ::Tilt[options[:preferred_engine]] + matched_exts = [] + + # Get a list of extensions for a preferred engine + # TODO: Cache this + ::Tilt.mappings.each do |ext, engines| + next unless engines.include? extension_class + matched_exts << ext + end + + # Change the glob to only look for the matched extensions + if matched_exts.length > 0 + preferred_engine = '{' + matched_exts.join(',') + '}' + else + return false + end + end + + # Look for files that match + path_with_ext = on_disk_path + '.' + preferred_engine + + found_path = Dir[path_with_ext].find do |path| + ::Tilt[path] + end + + if !found_path && options[:try_without_underscore] && + path_no_underscore = path_with_ext. + sub(relative_path, relative_path.sub(/^_/, ''). + sub(/\/_/, '/')) + found_path = Dir[path_no_underscore].find do |path| + ::Tilt[path] + end + end + + # If we found one, return it and the found engine + if found_path || app.files.exists?(on_disk_path) + engine = found_path ? File.extname(found_path)[1..-1].to_sym : nil + [ found_path || on_disk_path, engine ] + else + false + end + end + end + end +end From 614d69dc18796d4cc24d2e2d07b29331ff91c5a8 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Fri, 3 Jan 2014 14:56:16 -0800 Subject: [PATCH 014/580] move current_path in to the template context, one less piece of global state --- .../middleman-core/core_extensions/request.rb | 24 ++----------------- middleman-core/lib/middleman-core/sitemap.rb | 3 +++ .../lib/middleman-core/sitemap/resource.rb | 2 +- .../lib/middleman-core/template_context.rb | 2 +- 4 files changed, 7 insertions(+), 24 deletions(-) diff --git a/middleman-core/lib/middleman-core/core_extensions/request.rb b/middleman-core/lib/middleman-core/core_extensions/request.rb index 6758a7bf..8a001b91 100644 --- a/middleman-core/lib/middleman-core/core_extensions/request.rb +++ b/middleman-core/lib/middleman-core/core_extensions/request.rb @@ -153,20 +153,6 @@ module Middleman # Methods to be mixed-in to Middleman::Application module InstanceMethods - # Accessor for current path - # @return [String] - def current_path - Thread.current[:current_path] - end - - # Set the current path - # - # @param [String] path The new current path - # @return [void] - def current_path=(path) - Thread.current[:current_path] = path - end - delegate :use, :to => :"self.class" delegate :map, :to => :"self.class" @@ -210,7 +196,6 @@ module Middleman # @param [Rack::Response] res def process_request(env, req, res) start_time = Time.now - current_path = nil request_path = URI.decode(env['PATH_INFO'].dup) if request_path.respond_to? :force_encoding @@ -230,17 +215,12 @@ module Middleman # If this path is a binary file, send it immediately return send_file(resource, env) if resource.binary? - current_path = resource.destination_path - res['Content-Type'] = resource.content_type || 'text/plain' begin # Write out the contents of the page - output = resource.render do - self.current_path = current_path - end + res.write resource.render - res.write output # Valid content is a 200 status res.status = 200 rescue Middleman::TemplateRenderer::TemplateNotFound => e @@ -249,7 +229,7 @@ module Middleman end # End the request - logger.debug "== Finishing Request: #{current_path} (#{(Time.now - start_time).round(2)}s)" + logger.debug "== Finishing Request: #{resource.destination_path} (#{(Time.now - start_time).round(2)}s)" halt res.finish end diff --git a/middleman-core/lib/middleman-core/sitemap.rb b/middleman-core/lib/middleman-core/sitemap.rb index 6d7b6518..fbda5b2d 100644 --- a/middleman-core/lib/middleman-core/sitemap.rb +++ b/middleman-core/lib/middleman-core/sitemap.rb @@ -38,6 +38,9 @@ module Middleman # Sitemap instance methods module InstanceMethods + def current_path + @current_locs[:current_path] + end # Get the resource object for the current path # @return [Middleman::Sitemap::Resource] diff --git a/middleman-core/lib/middleman-core/sitemap/resource.rb b/middleman-core/lib/middleman-core/sitemap/resource.rb index 0a2cb502..a02485c6 100644 --- a/middleman-core/lib/middleman-core/sitemap/resource.rb +++ b/middleman-core/lib/middleman-core/sitemap/resource.rb @@ -135,7 +135,7 @@ module Middleman blocks = Array(md[:blocks]).dup blocks << block if block_given? - app.current_path ||= self.destination_path + locs[:current_path] ||= self.destination_path # Certain output file types don't use layouts if !opts.has_key?(:layout) diff --git a/middleman-core/lib/middleman-core/template_context.rb b/middleman-core/lib/middleman-core/template_context.rb index d26e4667..70c97195 100644 --- a/middleman-core/lib/middleman-core/template_context.rb +++ b/middleman-core/lib/middleman-core/template_context.rb @@ -4,7 +4,7 @@ require 'middleman-core/template_renderer' module Middleman class TemplateContext attr_reader :app - attr_accessor :current_engine, :current_path + attr_accessor :current_engine delegate :config, :logger, :sitemap, :build?, :development?, :data, :extensions, :source_dir, :root, :to => :app From 98e3c8aa79b6c311b10abed400bef32298c84e4e Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Fri, 3 Jan 2014 15:49:54 -0800 Subject: [PATCH 015/580] remove instance variable and page block support --- CHANGELOG.md | 5 +++ .../default/source/layouts/layout.erb | 2 +- middleman-core/features/instance_vars.feature | 9 ----- middleman-core/features/proxy_pages.feature | 10 ----- .../fixtures/dynamic-pages-app/config.rb | 40 +++++-------------- .../source/real/index.html.erb | 6 +-- .../fixtures/i18n-force-locale/config.rb | 4 +- .../fixtures/instance-vars-app/config.rb | 7 ---- .../instance-vars-app/source/content.html.erb | 2 - .../instance-vars-app/source/layout.erb | 1 - .../fixtures/proxy-pages-app/config.rb | 3 -- .../source/real/index-ivars.html.erb | 6 --- .../source/content.html.erb | 4 ++ .../stylus-preview-app/source/layout.erb | 1 - .../middleman-core/core_extensions/routing.rb | 18 +++++---- .../sitemap/extensions/proxies.rb | 16 ++++---- .../lib/middleman-core/sitemap/resource.rb | 25 +++--------- .../lib/middleman-core/sitemap/store.rb | 12 +----- .../lib/middleman-core/template_renderer.rb | 6 +-- .../middleman-more/core_extensions/i18n.rb | 16 ++------ 20 files changed, 54 insertions(+), 139 deletions(-) delete mode 100644 middleman-core/features/instance_vars.feature delete mode 100644 middleman-core/fixtures/instance-vars-app/config.rb delete mode 100644 middleman-core/fixtures/instance-vars-app/source/content.html.erb delete mode 100644 middleman-core/fixtures/instance-vars-app/source/layout.erb delete mode 100644 middleman-core/fixtures/proxy-pages-app/source/real/index-ivars.html.erb delete mode 100644 middleman-core/fixtures/stylus-preview-app/source/layout.erb diff --git a/CHANGELOG.md b/CHANGELOG.md index e75ecd71..f3884c16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ master === +* Remove `page` template local. Use `current_resource` instead. +* Dropped support for `page` & `proxy` blocks. +* Dropped support for instance variables inside templates. +* Moved all rendering into `TemplateRenderer` and `FileRenderer` +* Placed all template evaluation inside the `TemplateContext` class * Remove deprecated `request` instance * Remove old module-style extension support * Placed all `config.rb` evaluation inside the `ConfigContext` class diff --git a/middleman-cli/lib/middleman-cli/templates/default/source/layouts/layout.erb b/middleman-cli/lib/middleman-cli/templates/default/source/layouts/layout.erb index 7bdfeb1e..365985b7 100644 --- a/middleman-cli/lib/middleman-cli/templates/default/source/layouts/layout.erb +++ b/middleman-cli/lib/middleman-cli/templates/default/source/layouts/layout.erb @@ -7,7 +7,7 @@ - <%= current_page.data.title || "The Middleman" %> + <%= data.page.title || "The Middleman" %> <%= stylesheet_link_tag "normalize", "all" %> <%= javascript_include_tag "all" %> diff --git a/middleman-core/features/instance_vars.feature b/middleman-core/features/instance_vars.feature deleted file mode 100644 index ef240c57..00000000 --- a/middleman-core/features/instance_vars.feature +++ /dev/null @@ -1,9 +0,0 @@ -Feature: Instance Variables - Scenario: A dynamic page template using instance variables - Given the Server is running at "instance-vars-app" - When I go to "/a.html" - Then I should see "A: 'set'" - Then I should see "B: ''" - When I go to "/b.html" - Then I should see "A: ''" - Then I should see "B: 'set'" diff --git a/middleman-core/features/proxy_pages.feature b/middleman-core/features/proxy_pages.feature index 522f1eb8..4a22727c 100644 --- a/middleman-core/features/proxy_pages.feature +++ b/middleman-core/features/proxy_pages.feature @@ -15,8 +15,6 @@ Feature: Proxy Pages (using proxy rather than page) | fake2/two.html | | fake3/one.html | | fake3/two.html | - | fake4/one.html | - | fake4/two.html | | target_ignore.html | | target_ignore2.html | | target_ignore3.html | @@ -35,8 +33,6 @@ Feature: Proxy Pages (using proxy rather than page) Then I should see "I am real" When I go to "/fake3.html" Then I should see "I am real" - When I go to "/fake4.html" - Then I should see "I am real" Scenario: Preview proxy with variable one Given the Server is running at "proxy-pages-app" @@ -49,9 +45,6 @@ Feature: Proxy Pages (using proxy rather than page) When I go to "/fake3/one.html" Then I should see "I am real: one" - When I go to "/fake4/one.html" - Then I should see "I am real: one" - Scenario: Preview proxy with variable two Given the Server is running at "proxy-pages-app" When I go to "/fake/two.html" @@ -62,9 +55,6 @@ Feature: Proxy Pages (using proxy rather than page) When I go to "/fake3/two.html" Then I should see "I am real: two" - - When I go to "/fake4/two.html" - Then I should see "I am real: two" Scenario: Build proxy with variable one Given a successfully built app at "proxy-pages-app" diff --git a/middleman-core/fixtures/dynamic-pages-app/config.rb b/middleman-core/fixtures/dynamic-pages-app/config.rb index 161b0761..8f62dd0a 100644 --- a/middleman-core/fixtures/dynamic-pages-app/config.rb +++ b/middleman-core/fixtures/dynamic-pages-app/config.rb @@ -15,38 +15,16 @@ page "target_ignore3.html", :proxy => "should_be_ignored7.html", :ignore => true page "/target_ignore4.html", :proxy => "should_be_ignored8.html", :ignore => true %w(one two).each do |num| - page "/fake/#{num}.html", :proxy => "/real/index.html", :ignore => true do - @num = num - end - page "fake2/#{num}.html", :proxy => "/real/index.html", :ignore => true do - @num = num - end - page "fake3/#{num}.html", :proxy => "real/index.html", :ignore => true do - @num = num - end - page "/fake4/#{num}.html", :proxy => "real/index.html", :ignore => true do - @num = num - end + page "/fake/#{num}.html", :proxy => "/real/index.html", :ignore => true, :locals => { :num => num } + page "fake2/#{num}.html", :proxy => "/real/index.html", :ignore => true, :locals => { :num => num } + page "fake3/#{num}.html", :proxy => "real/index.html", :ignore => true, :locals => { :num => num } + page "/fake4/#{num}.html", :proxy => "real/index.html", :ignore => true, :locals => { :num => num } end page "明日ãŒã‚ã‚‹.html", :proxy => "/real.html", :layout => false -page "f*/*" do - @all_glob = "I am all glob" -end - -page "fake/*" do - @glob_var = "I am one glob" -end - -page "fake2/*" do - @glob_var = "I am two glob" -end - -page "fake3/*" do - @glob_var = "I am three glob" -end - -page "fake4/*" do - @glob_var = "I am four glob" -end +page "f*/*", :locals => { :all_glob => "I am all glob" } +page "fake/*", :locals => { :glob_var => "I am one glob" } +page "fake2/*", :locals => { :glob_var => "I am two glob" } +page "fake3/*", :locals => { :glob_var => "I am three glob" } +page "fake4/*", :locals => { :glob_var => "I am four glob" } diff --git a/middleman-core/fixtures/dynamic-pages-app/source/real/index.html.erb b/middleman-core/fixtures/dynamic-pages-app/source/real/index.html.erb index 6e24c740..df64a7cc 100644 --- a/middleman-core/fixtures/dynamic-pages-app/source/real/index.html.erb +++ b/middleman-core/fixtures/dynamic-pages-app/source/real/index.html.erb @@ -2,8 +2,8 @@ layout: false --- -I am real: <%= @num %> +I am real: <%= num %> -Global: <%= @glob_var %> +Global: <%= glob_var %> -All: <%= @all_glob %> \ No newline at end of file +All: <%= all_glob %> \ No newline at end of file diff --git a/middleman-core/fixtures/i18n-force-locale/config.rb b/middleman-core/fixtures/i18n-force-locale/config.rb index 08ee30e5..4058360e 100644 --- a/middleman-core/fixtures/i18n-force-locale/config.rb +++ b/middleman-core/fixtures/i18n-force-locale/config.rb @@ -1,7 +1,5 @@ [:en, :es].each do |locale| - proxy "/#{locale}/index.html", "index.html", :ignore => true do - ::I18n.locale = locale - end + proxy "/#{locale}/index.html", "index.html", :ignore => true, :lang => locale end proxy "/fr/index.html", "index.html", :lang => :fr diff --git a/middleman-core/fixtures/instance-vars-app/config.rb b/middleman-core/fixtures/instance-vars-app/config.rb deleted file mode 100644 index 76367d3f..00000000 --- a/middleman-core/fixtures/instance-vars-app/config.rb +++ /dev/null @@ -1,7 +0,0 @@ -page "a.html", :proxy => 'content.html', :ignore => true do - @a = "set" -end - -page "b.html", :proxy => 'content.html', :ignore => true do - @b = "set" -end diff --git a/middleman-core/fixtures/instance-vars-app/source/content.html.erb b/middleman-core/fixtures/instance-vars-app/source/content.html.erb deleted file mode 100644 index 58b6399d..00000000 --- a/middleman-core/fixtures/instance-vars-app/source/content.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -A: '<%= @a %>' -B: '<%= @b %>' diff --git a/middleman-core/fixtures/instance-vars-app/source/layout.erb b/middleman-core/fixtures/instance-vars-app/source/layout.erb deleted file mode 100644 index cd9bb66d..00000000 --- a/middleman-core/fixtures/instance-vars-app/source/layout.erb +++ /dev/null @@ -1 +0,0 @@ -<%= yield %> \ No newline at end of file diff --git a/middleman-core/fixtures/proxy-pages-app/config.rb b/middleman-core/fixtures/proxy-pages-app/config.rb index 0cd260cf..26afbc7a 100644 --- a/middleman-core/fixtures/proxy-pages-app/config.rb +++ b/middleman-core/fixtures/proxy-pages-app/config.rb @@ -13,9 +13,6 @@ proxy "/target_ignore4.html", "should_be_ignored8.html", :ignore => true proxy "/fake/#{num}.html", "/real/index.html", :ignore => true, :locals => { :num => num } proxy "fake2/#{num}.html", "/real/index.html", :ignore => true, :locals => { :num => num } proxy "fake3/#{num}.html", "real/index.html", :ignore => true, :locals => { :num => num } - proxy "/fake4/#{num}.html", "real/index-ivars.html", :ignore => true do - @num = num - end end proxy "明日ãŒã‚ã‚‹.html", "/real.html", :layout => false diff --git a/middleman-core/fixtures/proxy-pages-app/source/real/index-ivars.html.erb b/middleman-core/fixtures/proxy-pages-app/source/real/index-ivars.html.erb deleted file mode 100644 index 07563e7d..00000000 --- a/middleman-core/fixtures/proxy-pages-app/source/real/index-ivars.html.erb +++ /dev/null @@ -1,6 +0,0 @@ ---- -layout: false ---- - -I am real: <%= @num %> - diff --git a/middleman-core/fixtures/stylus-preview-app/source/content.html.erb b/middleman-core/fixtures/stylus-preview-app/source/content.html.erb index ade1f58b..375933bf 100644 --- a/middleman-core/fixtures/stylus-preview-app/source/content.html.erb +++ b/middleman-core/fixtures/stylus-preview-app/source/content.html.erb @@ -1 +1,5 @@ +--- +layout: false +--- + Hola Mundo \ No newline at end of file diff --git a/middleman-core/fixtures/stylus-preview-app/source/layout.erb b/middleman-core/fixtures/stylus-preview-app/source/layout.erb deleted file mode 100644 index cd9bb66d..00000000 --- a/middleman-core/fixtures/stylus-preview-app/source/layout.erb +++ /dev/null @@ -1 +0,0 @@ -<%= yield %> \ No newline at end of file diff --git a/middleman-core/lib/middleman-core/core_extensions/routing.rb b/middleman-core/lib/middleman-core/core_extensions/routing.rb index c4171b78..8b9a58d6 100644 --- a/middleman-core/lib/middleman-core/core_extensions/routing.rb +++ b/middleman-core/lib/middleman-core/core_extensions/routing.rb @@ -12,9 +12,9 @@ module Middleman @layout_name = layout_name end - def page(url, opts={}, &block) + def page(url, opts={}) opts[:layout] ||= @layout_name - @scope.page(url, opts, &block) + @scope.page(url, opts) end delegate :proxy, :to => :scope @@ -41,10 +41,12 @@ module Middleman # @param [String] url # @param [Hash] opts # @return [void] - def page(url, opts={}, &block) + def page(url, opts={}) + options = opts.dup + # Default layout - opts[:layout] = @app.config[:layout] if opts[:layout].nil? - metadata = { :options => opts, :blocks => Array(block) } + options[:layout] = @app.config[:layout] if options[:layout].nil? + metadata = { :options => options, :locals => options.delete(:locals) || {} } # If the url is a regexp unless url.is_a?(Regexp) || url.include?('*') @@ -55,11 +57,11 @@ module Middleman end # Setup proxy - if target = opts.delete(:proxy) + if target = options.delete(:proxy) # TODO: deprecate proxy through page? - @app.proxy(url, target, opts, &block) + @app.proxy(url, target, opts.dup) return - elsif opts.delete(:ignore) + elsif options.delete(:ignore) # TODO: deprecate ignore through page? @app.ignore(url) end diff --git a/middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb b/middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb index 933e7312..55a0a371 100644 --- a/middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb +++ b/middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb @@ -23,13 +23,14 @@ module Middleman # @param [Hash] opts options to apply to the proxy, including things like # :locals, :ignore to hide the proxy target, :layout, and :directory_indexes. # @return [void] - def create_proxy(path, target, opts={}, &block) - metadata = { :options => {}, :locals => {}, :blocks => [] } - metadata[:blocks] << block if block_given? - metadata[:locals] = opts.delete(:locals) || {} + def create_proxy(path, target, opts={}) + options = opts.dup - @app.ignore(target) if opts.delete(:ignore) - metadata[:options] = opts + metadata = { :options => {}, :locals => {} } + metadata[:locals] = options.delete(:locals) || {} + + @app.ignore(target) if options.delete(:ignore) + metadata[:options] = options @proxy_configs << ProxyConfiguration.new(:path => path, :target => target, :metadata => metadata) @@ -45,6 +46,7 @@ module Middleman config.path ) p.proxy_to(config.target) + p.add_metadata(config.metadata) p end @@ -65,7 +67,7 @@ module Middleman @target = ::Middleman::Util.normalize_path(t) end - # Additional metadata like blocks and locals to apply to the proxy + # Additional metadata like locals to apply to the proxy attr_accessor :metadata # Create a new proxy configuration from hash options diff --git a/middleman-core/lib/middleman-core/sitemap/resource.rb b/middleman-core/lib/middleman-core/sitemap/resource.rb index a02485c6..fd87a0d6 100644 --- a/middleman-core/lib/middleman-core/sitemap/resource.rb +++ b/middleman-core/lib/middleman-core/sitemap/resource.rb @@ -48,7 +48,7 @@ module Middleman @source_file = source_file @destination_path = @path - @local_metadata = { :options => {}, :locals => {}, :page => {}, :blocks => [] } + @local_metadata = { :options => {}, :locals => {}, :page => {}} end # Whether this resource has a template file @@ -64,30 +64,18 @@ module Middleman result = store.metadata_for_path(path).dup file_meta = store.metadata_for_file(source_file).dup - if file_meta.has_key?(:blocks) - result[:blocks] += file_meta.delete(:blocks) - end result.deep_merge!(file_meta) local_meta = @local_metadata.dup - if local_meta.has_key?(:blocks) - result[:blocks] += local_meta.delete(:blocks) - end result.deep_merge!(local_meta) - result[:blocks] = result[:blocks].flatten.compact result end # Merge in new metadata specific to this resource. # @param [Hash] metadata A metadata block like provides_metadata_for_path takes - def add_metadata(metadata={}, &block) - metadata = metadata.dup - if metadata.has_key?(:blocks) - @local_metadata[:blocks] += metadata.delete(:blocks) - end - @local_metadata.deep_merge!(metadata) - @local_metadata[:blocks] += [ block ] if block_given? + def add_metadata(meta={}) + @local_metadata.deep_merge!(meta.dup) end # The output/preview URL for this resource @@ -106,7 +94,7 @@ module Middleman # Render this resource # @return [String] - def render(opts={}, locs={}, &block) + def render(opts={}, locs={}) if !template? return ::Middleman::FileRenderer.new(@app, source_file).get_template_data_for_file end @@ -132,9 +120,6 @@ module Middleman app.data.store('page', md[:page]) end - blocks = Array(md[:blocks]).dup - blocks << block if block_given? - locs[:current_path] ||= self.destination_path # Certain output file types don't use layouts @@ -143,7 +128,7 @@ module Middleman end renderer = ::Middleman::TemplateRenderer.new(@app, source_file) - renderer.render(locs, opts, blocks) + renderer.render(locs, opts) end end diff --git a/middleman-core/lib/middleman-core/sitemap/store.rb b/middleman-core/lib/middleman-core/sitemap/store.rb index a8fcdd22..069c1e73 100644 --- a/middleman-core/lib/middleman-core/sitemap/store.rb +++ b/middleman-core/lib/middleman-core/sitemap/store.rb @@ -137,18 +137,12 @@ module Middleman # @param [String] source_file # @return [Hash] def metadata_for_file(source_file) - blank_metadata = { :options => {}, :locals => {}, :page => {}, :blocks => [] } + blank_metadata = { :options => {}, :locals => {}, :page => {} } provides_metadata.inject(blank_metadata) do |result, (callback, matcher)| next result if matcher && !source_file.match(matcher) metadata = callback.call(source_file).dup - - if metadata.has_key?(:blocks) - result[:blocks] << metadata[:blocks] - metadata.delete(:blocks) - end - result.deep_merge(metadata) end end @@ -171,7 +165,7 @@ module Middleman def metadata_for_path(request_path) return @_cached_metadata[request_path] if @_cached_metadata[request_path] - blank_metadata = { :options => {}, :locals => {}, :page => {}, :blocks => [] } + blank_metadata = { :options => {}, :locals => {}, :page => {} } @_cached_metadata[request_path] = provides_metadata_for_path.inject(blank_metadata) do |result, (callback, matcher)| case matcher @@ -183,8 +177,6 @@ module Middleman metadata = callback.call(request_path).dup - result[:blocks] += Array(metadata.delete(:blocks)) - result.deep_merge(metadata) end end diff --git a/middleman-core/lib/middleman-core/template_renderer.rb b/middleman-core/lib/middleman-core/template_renderer.rb index 65585c77..5a561fe9 100644 --- a/middleman-core/lib/middleman-core/template_renderer.rb +++ b/middleman-core/lib/middleman-core/template_renderer.rb @@ -26,7 +26,7 @@ module Middleman # @param [Hash] locs # @param [Hash] opts # @return [String] - def render(locs={}, opts={}, blocks=[]) + def render(locs={}, opts={}) path = @path.dup extension = File.extname(path) engine = extension[1..-1].to_sym @@ -43,10 +43,6 @@ module Middleman context.init_haml_helpers end - blocks.each do |block| - context.instance_eval(&block) - end - # Keep rendering template until we've used up all extensions. This # handles cases like `style.css.sass.erb` content = nil diff --git a/middleman-core/lib/middleman-more/core_extensions/i18n.rb b/middleman-core/lib/middleman-more/core_extensions/i18n.rb index 24787a04..8047462b 100644 --- a/middleman-core/lib/middleman-more/core_extensions/i18n.rb +++ b/middleman-core/lib/middleman-more/core_extensions/i18n.rb @@ -124,19 +124,11 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension lang = @mount_at_root end - instance_vars = Proc.new do - @lang = lang - @page_id = page_id - end - - locals = { - :lang => lang, - :page_id => page_id - } - { - :blocks => [instance_vars], - :locals => locals, + :locals => { + :lang => lang, + :page_id => page_id + }, :options => { :lang => lang } } end From 504a1c2ebafa6dd32b02b8c19a0cf1a9e26a6874 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Fri, 3 Jan 2014 16:18:16 -0800 Subject: [PATCH 016/580] remove confusing and broken data.page variable --- CHANGELOG.md | 1 + .../asciidoc-app/source/layouts/default.erb | 2 +- .../core_extensions/front_matter.rb | 10 +++++++++- .../lib/middleman-core/renderers/asciidoc.rb | 2 +- .../lib/middleman-core/sitemap/resource.rb | 17 +---------------- .../lib/middleman-core/sitemap/store.rb | 4 ++-- 6 files changed, 15 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3884c16..0aa09762 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ master === +* Asciidoc information now available with the `asciidoc` local, which is a normal hash. * Remove `page` template local. Use `current_resource` instead. * Dropped support for `page` & `proxy` blocks. * Dropped support for instance variables inside templates. diff --git a/middleman-core/fixtures/asciidoc-app/source/layouts/default.erb b/middleman-core/fixtures/asciidoc-app/source/layouts/default.erb index ec05c79c..c426106b 100644 --- a/middleman-core/fixtures/asciidoc-app/source/layouts/default.erb +++ b/middleman-core/fixtures/asciidoc-app/source/layouts/default.erb @@ -1,7 +1,7 @@ -<%= data.page.title || 'Fallback' %> +<%= current_resource.data.title || asciidoc[:title] || 'Fallback' %> <%= yield %> diff --git a/middleman-core/lib/middleman-core/core_extensions/front_matter.rb b/middleman-core/lib/middleman-core/core_extensions/front_matter.rb index 155fad6a..cffd234f 100644 --- a/middleman-core/lib/middleman-core/core_extensions/front_matter.rb +++ b/middleman-core/lib/middleman-core/core_extensions/front_matter.rb @@ -41,11 +41,19 @@ module Middleman::CoreExtensions fmdata = data(path).first data = {} + [:layout, :layout_engine].each do |opt| data[opt] = fmdata[opt] unless fmdata[opt].nil? end + + if fmdata[:renderer_options] + data[:renderer_options] = {} + fmdata[:renderer_options].each do |k, v| + data[:renderer_options][k.to_sym] = v + end + end - { :options => data, :page => ::Middleman::Util.recursively_enhance(fmdata).freeze } + { :options => data } end end diff --git a/middleman-core/lib/middleman-core/renderers/asciidoc.rb b/middleman-core/lib/middleman-core/renderers/asciidoc.rb index 6e89df16..c58f7150 100644 --- a/middleman-core/lib/middleman-core/renderers/asciidoc.rb +++ b/middleman-core/lib/middleman-core/renderers/asciidoc.rb @@ -47,7 +47,7 @@ module Middleman # TODO grab all the author information page[:author] = (doc.attr 'author') unless (doc.attr 'author').nil? - {:options => opts, :page => ::Middleman::Util.recursively_enhance(page)} + { :options => opts, :locals => { :asciidoc => page } } end end end diff --git a/middleman-core/lib/middleman-core/sitemap/resource.rb b/middleman-core/lib/middleman-core/sitemap/resource.rb index fd87a0d6..47d333c9 100644 --- a/middleman-core/lib/middleman-core/sitemap/resource.rb +++ b/middleman-core/lib/middleman-core/sitemap/resource.rb @@ -48,7 +48,7 @@ module Middleman @source_file = source_file @destination_path = @path - @local_metadata = { :options => {}, :locals => {}, :page => {}} + @local_metadata = { :options => {}, :locals => {} } end # Whether this resource has a template file @@ -104,22 +104,7 @@ module Middleman instrument 'render.resource', :path => relative_source do md = metadata.dup opts = md[:options].deep_merge(opts) - - # Pass "renderer_options" hash from frontmatter along to renderer - if md[:page]['renderer_options'] - opts[:renderer_options] = {} - md[:page]['renderer_options'].each do |k, v| - opts[:renderer_options][k.to_sym] = v - end - end - locs = md[:locals].deep_merge(locs) - - # Forward remaining data to helpers - if md.has_key?(:page) - app.data.store('page', md[:page]) - end - locs[:current_path] ||= self.destination_path # Certain output file types don't use layouts diff --git a/middleman-core/lib/middleman-core/sitemap/store.rb b/middleman-core/lib/middleman-core/sitemap/store.rb index 069c1e73..0dc16267 100644 --- a/middleman-core/lib/middleman-core/sitemap/store.rb +++ b/middleman-core/lib/middleman-core/sitemap/store.rb @@ -137,7 +137,7 @@ module Middleman # @param [String] source_file # @return [Hash] def metadata_for_file(source_file) - blank_metadata = { :options => {}, :locals => {}, :page => {} } + blank_metadata = { :options => {}, :locals => {} } provides_metadata.inject(blank_metadata) do |result, (callback, matcher)| next result if matcher && !source_file.match(matcher) @@ -165,7 +165,7 @@ module Middleman def metadata_for_path(request_path) return @_cached_metadata[request_path] if @_cached_metadata[request_path] - blank_metadata = { :options => {}, :locals => {}, :page => {} } + blank_metadata = { :options => {}, :locals => {} } @_cached_metadata[request_path] = provides_metadata_for_path.inject(blank_metadata) do |result, (callback, matcher)| case matcher From 1dc9b97a5ecb10f751ceb28215df8b593d6ecf92 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Sat, 4 Jan 2014 12:44:20 -0800 Subject: [PATCH 017/580] better ruby style on some changes --- .../middleman-more/core_extensions/default_helpers.rb | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb b/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb index d9c70aa5..edd762c8 100644 --- a/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb +++ b/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb @@ -201,9 +201,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension # or a Resource, this will produce the nice URL configured for that # path, respecting :relative_links, directory indexes, etc. def url_for(path_or_resource, options={}) - options_with_resource = options.dup - options_with_resource[:current_resource] ||= current_resource - + options_with_resource = options.merge(current_resource: current_resource) ::Middleman::Util.url_for(app, path_or_resource, options_with_resource) end @@ -236,12 +234,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension args[url_arg_index] = url_for(url, options) # Cleanup before passing to Padrino - options.delete(:relative) - options.delete(:current_resource) - options.delete(:find_resource) - options.delete(:query) - options.delete(:anchor) - options.delete(:fragment) + options.except!(:relative, :current_resource, :find_resource, :query, :anchor, :fragment) end super(*args, &block) From df1236412bcc735f1c20eabf275c2e1574faee94 Mon Sep 17 00:00:00 2001 From: Sam Symons Date: Thu, 9 Jan 2014 19:49:41 -0800 Subject: [PATCH 018/580] Corrected a handful of documentation typos. --- middleman-cli/lib/middleman-cli.rb | 6 +++--- .../lib/middleman-core/sitemap/extensions/traversal.rb | 2 +- middleman-core/lib/middleman-core/sitemap/resource.rb | 2 +- middleman-core/lib/middleman-core/util.rb | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/middleman-cli/lib/middleman-cli.rb b/middleman-cli/lib/middleman-cli.rb index 512ab3ce..10efcd47 100644 --- a/middleman-cli/lib/middleman-cli.rb +++ b/middleman-cli/lib/middleman-cli.rb @@ -2,7 +2,7 @@ libdir = File.expand_path(File.dirname(__FILE__)) $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir) -# Require thor since that's what the who CLI is built around +# Require Thor since that's what the whole CLI is built around require 'thor' require 'thor/group' @@ -11,7 +11,7 @@ module Middleman module Cli - # The base task from which everything else etends + # The base task from which everything else extends class Base < Thor class << self def start(*args) @@ -91,4 +91,4 @@ require 'middleman-cli/bundler' require 'middleman-cli/extension' require 'middleman-cli/server' require 'middleman-cli/build' -require 'middleman-cli/console' \ No newline at end of file +require 'middleman-cli/console' diff --git a/middleman-core/lib/middleman-core/sitemap/extensions/traversal.rb b/middleman-core/lib/middleman-core/sitemap/extensions/traversal.rb index 65c43030..e1920f12 100644 --- a/middleman-core/lib/middleman-core/sitemap/extensions/traversal.rb +++ b/middleman-core/lib/middleman-core/sitemap/extensions/traversal.rb @@ -58,7 +58,7 @@ module Middleman parent.children.reject { |p| p == self } end - # Whether this resource either a directory index, or has the same name as an existing directory in the source + # Whether this resource is either a directory index, or has the same name as an existing directory in the source # @return [Boolean] def directory_index? path.include?(app.config[:index_file]) || path =~ /\/$/ || eponymous_directory? diff --git a/middleman-core/lib/middleman-core/sitemap/resource.rb b/middleman-core/lib/middleman-core/sitemap/resource.rb index 47d333c9..368f1e7b 100644 --- a/middleman-core/lib/middleman-core/sitemap/resource.rb +++ b/middleman-core/lib/middleman-core/sitemap/resource.rb @@ -73,7 +73,7 @@ module Middleman end # Merge in new metadata specific to this resource. - # @param [Hash] metadata A metadata block like provides_metadata_for_path takes + # @param [Hash] meta A metadata block like provides_metadata_for_path takes def add_metadata(meta={}) @local_metadata.deep_merge!(meta.dup) end diff --git a/middleman-core/lib/middleman-core/util.rb b/middleman-core/lib/middleman-core/util.rb index b4d919ca..71ce83f4 100644 --- a/middleman-core/lib/middleman-core/util.rb +++ b/middleman-core/lib/middleman-core/util.rb @@ -113,7 +113,7 @@ module Middleman end end - # Get a recusive list of files inside a set of paths. + # Get a recursive list of files inside a set of paths. # Works with symlinks. # # @param paths Some paths string or Pathname From 164b6bd983a892b95db34b4eb09db452e37d1b1c Mon Sep 17 00:00:00 2001 From: Karl Freeman Date: Wed, 15 Jan 2014 14:54:16 +0000 Subject: [PATCH 019/580] Happy 2014! --- LICENSE.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index b65df181..41ba676e 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2010-2013 Thomas Reynolds +Copyright (c) 2010-2014 Thomas Reynolds Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/README.md b/README.md index a90e252f..6daf2a00 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ The best way to get quick responses to your issues and swift fixes to your bugs ## License -Copyright (c) 2010-2013 Thomas Reynolds. MIT Licensed, see [LICENSE] for details. +Copyright (c) 2010-2014 Thomas Reynolds. MIT Licensed, see [LICENSE] for details. [middleman]: http://middlemanapp.com [gem]: https://rubygems.org/gems/middleman From 89044396d9ddbb8d92262e6f66723823eff1a63d Mon Sep 17 00:00:00 2001 From: yawboakye Date: Thu, 16 Jan 2014 01:19:55 +0000 Subject: [PATCH 020/580] give information on finding help for each command At the end of the tasks lists, the new line added gives information on how to find information on all the possible command that can be ran with `middleman`. Information include options that can be passed to the command --- middleman-cli/lib/middleman-cli.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/middleman-cli/lib/middleman-cli.rb b/middleman-cli/lib/middleman-cli.rb index 10efcd47..ee02429d 100644 --- a/middleman-cli/lib/middleman-cli.rb +++ b/middleman-cli/lib/middleman-cli.rb @@ -50,6 +50,7 @@ module Middleman shell.say 'Tasks:' shell.print_table(list, :ident => 2, :truncate => true) + shell.say %(\nSee 'middleman help ' for more information on specific command.) shell.say end end From 5a974ce75ab481df6b07958ad3f958eb0d6c1f4f Mon Sep 17 00:00:00 2001 From: Yaw Boakye Date: Wed, 22 Jan 2014 02:02:51 +0000 Subject: [PATCH 021/580] added an alias for `console` command Almost every other command has an alias except `console`. Also the comment above the class definition wrongly said `console` was a command for creating new projects. Corrected appropriately --- middleman-cli/lib/middleman-cli/console.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/middleman-cli/lib/middleman-cli/console.rb b/middleman-cli/lib/middleman-cli/console.rb index 21f4c42c..e19e7dc2 100644 --- a/middleman-cli/lib/middleman-cli/console.rb +++ b/middleman-cli/lib/middleman-cli/console.rb @@ -1,7 +1,9 @@ # CLI Module module Middleman::Cli + # Alias "c" to "console" + Base.map({ 'c' => 'console' }) - # A thor task for creating new projects + # The CLI Console class class Console < Thor include Thor::Actions From 247a152d397435bfab10d7d15a0c565a1e930fdb Mon Sep 17 00:00:00 2001 From: Nico Hagenburger Date: Sat, 1 Feb 2014 23:45:46 +0100 Subject: [PATCH 022/580] upgraded hooks to 0.3.3; integrated custom changes as made for 0.2.0 --- .../lib/middleman-core/application.rb | 4 +- .../hooks-0.2.0/CHANGES.textile | 9 - .../hooks-0.2.0/Gemfile | 3 - .../hooks-0.2.0/README.rdoc | 107 --------- .../hooks-0.2.0/test/hooks_test.rb | 141 ------------ .../test/inheritable_attribute_test.rb | 55 ----- .../hooks-0.2.0/test/test_helper.rb | 10 - .../hooks-0.3.3/.gitignore | 2 + .../hooks-0.3.3/.travis.yml | 5 + .../hooks-0.3.3/CHANGES.md | 33 +++ .../hooks-0.3.3/Gemfile | 3 + .../hooks-0.3.3/LICENSE.txt | 20 ++ .../hooks-0.3.3/README.md | 202 ++++++++++++++++ .../{hooks-0.2.0 => hooks-0.3.3}/Rakefile | 0 .../hooks.gemspec | 13 +- .../{hooks-0.2.0 => hooks-0.3.3}/lib/hooks.rb | 95 +++++--- .../hooks-0.3.3/lib/hooks/hook.rb | 81 +++++++ .../lib/hooks/inheritable_attribute.rb | 4 +- .../hooks-0.3.3/lib/hooks/instance_hooks.rb | 25 ++ .../hooks-0.3.3/lib/hooks/version.rb | 3 + .../hooks-0.3.3/test/hook_test.rb | 31 +++ .../hooks-0.3.3/test/hooks_test.rb | 216 ++++++++++++++++++ .../test/inheritable_attribute_test.rb | 53 +++++ .../hooks-0.3.3/test/instance_hooks_test.rb | 55 +++++ .../hooks-0.3.3/test/test_helper.rb | 3 + 25 files changed, 805 insertions(+), 368 deletions(-) delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/CHANGES.textile delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/Gemfile delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/README.rdoc delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/test/hooks_test.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/test/inheritable_attribute_test.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/test/test_helper.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.gitignore create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.travis.yml create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/CHANGES.md create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Gemfile create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/LICENSE.txt create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/README.md rename middleman-core/lib/vendored-middleman-deps/{hooks-0.2.0 => hooks-0.3.3}/Rakefile (100%) rename middleman-core/lib/vendored-middleman-deps/{hooks-0.2.0 => hooks-0.3.3}/hooks.gemspec (71%) rename middleman-core/lib/vendored-middleman-deps/{hooks-0.2.0 => hooks-0.3.3}/lib/hooks.rb (54%) create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/hook.rb rename middleman-core/lib/vendored-middleman-deps/{hooks-0.2.0 => hooks-0.3.3}/lib/hooks/inheritable_attribute.rb (98%) create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/instance_hooks.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/version.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hook_test.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hooks_test.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/inheritable_attribute_test.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/instance_hooks_test.rb create mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/test_helper.rb diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb index 0b67d48f..5110aa36 100644 --- a/middleman-core/lib/middleman-core/application.rb +++ b/middleman-core/lib/middleman-core/application.rb @@ -10,7 +10,7 @@ require 'active_support/json' require 'active_support/core_ext/integer/inflections' # Simple callback library -require 'vendored-middleman-deps/hooks-0.2.0/lib/hooks' +require 'vendored-middleman-deps/hooks-0.3.3/lib/hooks' # Our custom logger require 'middleman-core/logger' @@ -198,7 +198,7 @@ module Middleman # Evaluate a passed block if given @config_context.instance_exec(&block) if block_given? - + super end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/CHANGES.textile b/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/CHANGES.textile deleted file mode 100644 index 3beea91d..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/CHANGES.textile +++ /dev/null @@ -1,9 +0,0 @@ -h2. 0.2.0 - -h3. Changes - * Callback blocks are now executed on the instance using @instance_exec@. If you need to access the class (former context) use @self.class@. - -h2. 0.1.4 - -h3. Bugfixes - * An uninitialized @inheritable_attr@ doesn't crash since it is not cloned anymore. Note that an uncloneable attribute value still causes an exception. diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/Gemfile b/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/Gemfile deleted file mode 100644 index a1b93f3e..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/Gemfile +++ /dev/null @@ -1,3 +0,0 @@ -source :rubygems - -gemspec diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/README.rdoc b/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/README.rdoc deleted file mode 100644 index 4a209500..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/README.rdoc +++ /dev/null @@ -1,107 +0,0 @@ -= Hooks - -Generic hooks with callbacks for Ruby. - - -== Introduction - -_Hooks_ lets you define hooks declaratively in your ruby class. You can add callbacks to your hook, which will be run as soon as _you_ run the hook! - -It's almost like ActiveSupport::Callbacks but 76,6% less complex. Instead, it is not more than 60 lines of code, one method compilation, no +method_missing+ and no magic. - -Also, you may pass additional arguments to your callbacks when invoking a hook. - -== Example - -Let's take... a cat. - - require 'hooks' - - class Cat - include Hooks - - define_hook :after_dinner - -Now you can add callbacks to your hook declaratively in your class. - - after_dinner do - puts "Ice cream for #{self}!" - end - - after_dinner :have_a_desert # => refers to Cat#have_a_desert - - def have_a_desert - puts "Hell, yeah!" - end - -This will run the block and #have_a_desert from above. - - cat.run_hook :after_dinner - # => Ice cream for #! - Hell, yeah! - -Callback blocks and methods will be executed with instance context. Note how +self+ in the block refers to the Cat instance. - - -== Inheritance - -Hooks are inherited, here's a complete example to put it all together. - - class Garfield < Cat - - after_dinner :want_some_more - - def want_some_more - puts "Is that all?" - end - end - - - Garfield.new.run_hook :after_dinner - # => Ice cream for #! - Hell, yeah! - Is that all? - -Note how the callbacks are invoked in the order they were inherited. - - -== Options for Callbacks - -You're free to pass any number of arguments to #run_callback, those will be passed to the callbacks. - - cat.run_hook :before_dinner, cat, Time.now - -The callbacks should be ready for receiving parameters. - - before_dinner :wash_pawns - before_dinner do |who, when| - ... - end - - def wash_pawns(who, when) - - -Not sure why a cat should have ice cream for dinner. Beside that, I was tempted naming this gem _hooker_. - - -== Installation - - gem install hooks - - -== Anybody using it? - -* Hooks is already used in [Apotomo:http://github.com/apotonick/apotomo], a hot widget framework for Rails. Look at +lib/apotomo/widget.rb+ for examples and into +lib/apotomo/tree_node.rb+ to learn how modules-driven code might benefit from hooks. - -== Similar libraries - -* http://github.com/nakajima/aspectory -* http://github.com/auser/backcall -* http://github.com/mmcgrana/simple_callbacks - - -== License - -Copyright (c) 2010, Nick Sutterer - -Released under the MIT License. diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/test/hooks_test.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/test/hooks_test.rb deleted file mode 100644 index 83cb24e4..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/test/hooks_test.rb +++ /dev/null @@ -1,141 +0,0 @@ -require 'test_helper' - -class HooksTest < Test::Unit::TestCase - class TestClass - include Hooks - - def executed - @executed ||= []; - end - end - - - context "Hooks.define_hook" do - setup do - @klass = Class.new(TestClass) - - @mum = @klass.new - @mum.class.define_hook :after_eight - end - - should "provide accessors to the stored callbacks" do - assert_equal [], @klass._after_eight_callbacks - @klass._after_eight_callbacks << :dine - assert_equal [:dine], @klass._after_eight_callbacks - end - - should "respond to Class.callbacks_for_hook" do - assert_equal [], @klass.callbacks_for_hook(:after_eight) - @klass.after_eight :dine - assert_equal [:dine], @klass.callbacks_for_hook(:after_eight) - end - - context "creates a public writer for the hook that" do - should "accepts method names" do - @klass.after_eight :dine - assert_equal [:dine], @klass._after_eight_callbacks - end - - should "accepts blocks" do - @klass.after_eight do true; end - assert @klass._after_eight_callbacks.first.kind_of? Proc - end - - should "be inherited" do - @klass.after_eight :dine - subklass = Class.new(@klass) - - assert_equal [:dine], subklass._after_eight_callbacks - end - end - - context "Hooks#run_hook" do - should "run without parameters" do - @mum.instance_eval do - def a; executed << :a; nil; end - def b; executed << :b; end - - self.class.after_eight :b - self.class.after_eight :a - end - - @mum.run_hook(:after_eight) - - assert_equal [:b, :a], @mum.executed - end - - should "accept arbitrary parameters" do - @mum.instance_eval do - def a(me, arg); executed << arg+1; end - end - @mum.class.after_eight :a - @mum.class.after_eight lambda { |me, arg| me.executed << arg-1 } - - @mum.run_hook(:after_eight, @mum, 1) - - assert_equal [2, 0], @mum.executed - end - - should "execute block callbacks in instance context" do - @mum.class.after_eight { executed << :c } - @mum.run_hook(:after_eight) - assert_equal [:c], @mum.executed - end - end - - context "in class context" do - should "run a callback block" do - executed = [] - @klass.after_eight do - executed << :klass - end - @klass.run_hook :after_eight - - assert_equal [:klass], executed - end - - should "run a class methods" do - executed = [] - @klass.instance_eval do - after_eight :have_dinner - - def have_dinner(executed) - executed << :have_dinner - end - end - @klass.run_hook :after_eight, executed - - assert_equal [:have_dinner], executed - end - end - end - - context "Deriving" do - setup do - @klass = Class.new(TestClass) - - @mum = @klass.new - @mum.class.define_hook :after_eight - end - - should "inherit the hook" do - @klass.class_eval do - after_eight :take_shower - - def take_shower - executed << :take_shower - end - end - - @kid = Class.new(@klass) do - after_eight :have_dinner - - def have_dinner - executed << :have_dinner - end - end.new - - assert_equal [:take_shower, :have_dinner], @kid.run_hook(:after_eight) - end - end -end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/test/inheritable_attribute_test.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/test/inheritable_attribute_test.rb deleted file mode 100644 index 27e10a2d..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/test/inheritable_attribute_test.rb +++ /dev/null @@ -1,55 +0,0 @@ -require 'test_helper' - -class HooksTest < Test::Unit::TestCase - context "Hooks.define_hook" do - setup do - @klass = Class.new(Object) do - extend Hooks::InheritableAttribute - end - - @mum = @klass.new - @klass.inheritable_attr :drinks - end - - should "provide a reader with empty inherited attributes, already" do - assert_equal nil, @klass.drinks - end - - should "provide a reader with empty inherited attributes in a derived class" do - assert_equal nil, Class.new(@klass).drinks - #@klass.drinks = true - #Class.new(@klass).drinks # TODO: crashes. - end - - should "provide an attribute copy in subclasses" do - @klass.drinks = [] - assert @klass.drinks.object_id != Class.new(@klass).drinks.object_id - end - - should "provide a writer" do - @klass.drinks = [:cabernet] - assert_equal [:cabernet], @klass.drinks - end - - should "inherit attributes" do - @klass.drinks = [:cabernet] - - subklass_a = Class.new(@klass) - subklass_a.drinks << :becks - - subklass_b = Class.new(@klass) - - assert_equal [:cabernet], @klass.drinks - assert_equal [:cabernet, :becks], subklass_a.drinks - assert_equal [:cabernet], subklass_b.drinks - end - - should "not inherit attributes if we set explicitely" do - @klass.drinks = [:cabernet] - subklass = Class.new(@klass) - - subklass.drinks = [:merlot] # we only want merlot explicitely. - assert_equal [:merlot], subklass.drinks # no :cabernet, here - end - end -end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/test/test_helper.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/test/test_helper.rb deleted file mode 100644 index f0b0b3cd..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/test/test_helper.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'rubygems' - -# wycats says... -require 'bundler' -Bundler.setup -require 'test/unit' -require 'shoulda' -require 'hooks' - -$:.unshift File.dirname(__FILE__) # add current dir to LOAD_PATHS diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.gitignore b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.gitignore new file mode 100644 index 00000000..80e3957f --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.gitignore @@ -0,0 +1,2 @@ +Gemfile.lock + diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.travis.yml b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.travis.yml new file mode 100644 index 00000000..03107eec --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.travis.yml @@ -0,0 +1,5 @@ +language: ruby +rvm: + - 1.8.7 + - 1.9.3 + - 2.0.0 diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/CHANGES.md b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/CHANGES.md new file mode 100644 index 00000000..277fda61 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/CHANGES.md @@ -0,0 +1,33 @@ +## 0.3.3 + +* Fix a bug where the hook writer method (e.g. `#after_dark`) wasn't available on the instance even when `InstanceHooks` was included. + +## 0.3.2 + +* Added `Hooks::InstanceHooks` to add hooks and/or callbacks on instance level. Thanks to @mpapis for that suggestion. + +## 0.3.1 + +* Fix a bug, string hook names are now treated as symbols. + +## 0.3.0 + +* The callback chain can now be halted by configuring the hook as `halts_on_falsey: true` and returning `nil` or `false` from the callback. +* Internal refactorings: hooks are now encapsulated in `Hook` instances and run their callback chains. + +## 0.2.2 + +* `#run_hook` now returns the list of callback results. + +## 0.2.1 + +* You can now pass multiple hook names to `#define_hooks`. + +## 0.2.0 + +h3. Changes +* Callback blocks are now executed on the instance using `instance_exec`. If you need to access the class (former context) use `self.class`. + +## 0.1.4 + +* An uninitialized `inheritable_attr` doesn't crash since it is not cloned anymore. Note that an uncloneable attribute value still causes an exception. diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Gemfile b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Gemfile new file mode 100644 index 00000000..fa75df15 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Gemfile @@ -0,0 +1,3 @@ +source 'https://rubygems.org' + +gemspec diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/LICENSE.txt b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/LICENSE.txt new file mode 100644 index 00000000..ffbc659d --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/LICENSE.txt @@ -0,0 +1,20 @@ +Copyright (c) 2011-2013 Nick Sutterer + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/README.md b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/README.md new file mode 100644 index 00000000..436d988d --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/README.md @@ -0,0 +1,202 @@ +# Hooks + +_Generic hooks with callbacks for Ruby._ + + +## Introduction + +_Hooks_ lets you define hooks declaratively in your ruby class. You can add callbacks to your hook, which will be run as soon as _you_ run the hook! + +It's almost like ActiveSupport::Callbacks but 76,6% less complex. Instead, it is not more than a few lines of code, one method compilation, no `method_missing` and no magic. + +Also, you may pass additional arguments to your callbacks when invoking a hook. + +## Example + +Let's take... a cat. + +```ruby +require 'hooks' + +class Cat + include Hooks + + define_hooks :before_dinner, :after_dinner +``` + +Now you can add callbacks to your hook declaratively in your class. + +```ruby + before_dinner :wash_paws + + after_dinner do + puts "Ice cream for #{self}!" + end + + after_dinner :have_a_desert # => refers to Cat#have_a_desert + + def have_a_desert + puts "Hell, yeah!" + end +``` + +This will run the block and `#have_a_desert` from above. + +```ruby +cat.run_hook :after_dinner +# => Ice cream for #! + Hell, yeah! +``` + +Callback blocks and methods will be executed with instance context. Note how `self` in the block refers to the Cat instance. + + +## Inheritance + +Hooks are inherited, here's a complete example to put it all together. + +```ruby +class Garfield < Cat + + after_dinner :want_some_more + + def want_some_more + puts "Is that all?" + end +end + + +Garfield.new.run_hook :after_dinner +# => Ice cream for #! + Hell, yeah! + Is that all? +``` + +Note how the callbacks are invoked in the order they were inherited. + + +## Options for Callbacks + +You're free to pass any number of arguments to #run_callback, those will be passed to the callbacks. + +```ruby +cat.run_hook :before_dinner, cat, Time.now +``` + +The callbacks should be ready for receiving parameters. + +```ruby +before_dinner :wash_pawns +before_dinner do |who, when| + ... +end + +def wash_pawns(who, when) +``` + +Not sure why a cat should have ice cream for dinner. Beside that, I was tempted naming this gem _hooker_. + + +## Running And Halting Hooks + +Using `#run_hook` doesn't only run all callbacks for this hook but also returns an array of the results from each callback method or block. + +```ruby +class Garfield + include Hooks + define_hook :after_dark + + after_dark { "Chase mice" } + after_dark { "Enjoy supper" } +end + +Garfield.new.run_hook :after_dark +# => ["Chase mice", "Enjoy supper"] +``` + +This is handy if you need to collect data from your callbacks without having to access a global (brrr) variable. + +With the `:halts_on_falsey` option you can halt the callback chain when a callback returns `nil` or `false`. + +```ruby +class Garfield + include Hooks + define_hook :after_dark, halts_on_falsey: true + + after_dark { "Chase mice" } + after_dark { nil } + after_dark { "Enjoy supper" } +end + +result = Garfield.new.run_hook :after_dark +# => ["Chase mice"] +``` + +This will only run the first two callbacks. Note that the result doesn't contain the `nil` value. You even can check if the chain was halted. + +```ruby +result.halted? #=> true +``` + +## Instance Hooks + +You can also define hooks and/or add callbacks per instance. This is helpful if your class should define a basic set of hooks and callbacks that are then extended by instances. + +```ruby +class Cat + include Hooks + include Hooks::InstanceHooks + + define_hook :after_dark + + after_dark { "Chase mice" } +end +``` + +Note that you have to include `Hooks::InstanceHooks` to get this additional functionality. + +See how callbacks can be added to a separate object, now. + +```ruby +garfield = Cat.new + +garfield.after_dark :sleep +garfield.run_hook(:after_dark) # => invoke "Chase mice" hook and #sleep +``` + +This will copy all callbacks from the `after_dark` hook to the instance and add a second hook. This all happens on the `garfield` instance, only, and leaves the class untouched. + +Naturally, adding new hooks works like-wise. + +```ruby +garfield.define_hook :before_six +garfield.before_six { .. } +``` +This feature was added in 0.3.2. + + +## Installation + +In your Gemfile, do + +```ruby +gem "hooks" +``` + +## Anybody using it? + +* Hooks is already used in [Apotomo](http://github.com/apotonick/apotomo), a hot widget framework for Rails. +* The [datamappify](https://github.com/fredwu/datamappify) gem uses hooks and the author Fred Wu contributed to this gem! + +## Similar libraries + +* http://github.com/nakajima/aspectory +* http://github.com/auser/backcall +* http://github.com/mmcgrana/simple_callbacks + + +## License + +Copyright (c) 2013, Nick Sutterer + +Released under the MIT License. diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/Rakefile b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Rakefile similarity index 100% rename from middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/Rakefile rename to middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Rakefile diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/hooks.gemspec b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/hooks.gemspec similarity index 71% rename from middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/hooks.gemspec rename to middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/hooks.gemspec index 326f75c0..fe7c1cf4 100644 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/hooks.gemspec +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/hooks.gemspec @@ -1,7 +1,7 @@ lib = File.expand_path('../lib/', __FILE__) $:.unshift lib unless $:.include?(lib) -require 'hooks' +require 'hooks/version' Gem::Specification.new do |s| s.name = "hooks" @@ -9,14 +9,17 @@ Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.authors = ["Nick Sutterer"] s.email = ["apotonick@gmail.com"] - s.homepage = "http://nicksda.apotomo.de/tag/hooks" + s.homepage = "http://nicksda.apotomo.de/2010/09/hooks-and-callbacks-for-ruby-but-simple/" s.summary = %q{Generic hooks with callbacks for Ruby.} s.description = %q{Declaratively define hooks, add callbacks and run them with the options you like.} - + s.license = "MIT" + s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") s.require_paths = ["lib"] - - s.add_development_dependency "shoulda" + s.license = 'MIT' + + s.add_development_dependency "minitest", ">= 5.0.0" s.add_development_dependency "rake" + s.add_development_dependency "pry" end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/lib/hooks.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb similarity index 54% rename from middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/lib/hooks.rb rename to middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb index 9c4ca879..02ad0964 100644 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/lib/hooks.rb +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb @@ -1,35 +1,41 @@ require File.join(File.dirname(__FILE__), "hooks/inheritable_attribute") +require File.join(File.dirname(__FILE__), "hooks/hook") # Almost like ActiveSupport::Callbacks but 76,6% less complex. # # Example: # # class CatWidget < Apotomo::Widget -# define_hook :after_dinner +# define_hooks :before_dinner, :after_dinner # # Now you can add callbacks to your hook declaratively in your class. # -# after_dinner do puts "Ice cream!" end +# before_dinner :wash_paws +# after_dinner { puts "Ice cream!" } # after_dinner :have_a_desert # => refers to CatWidget#have_a_desert # # Running the callbacks happens on instances. It will run the block and #have_a_desert from above. # # cat.run_hook :after_dinner module Hooks - VERSION = "0.2.0" - def self.included(base) - base.extend InheritableAttribute - base.extend ClassMethods + base.class_eval do + extend InheritableAttribute + extend ClassMethods + inheritable_attr :_hooks + self._hooks= HookSet.new + end end module ClassMethods - def define_hook(name) - accessor_name = "_#{name}_callbacks" + def define_hooks(*names) + options = extract_options!(names) - setup_hook_accessors(accessor_name) - define_hook_writer(name, accessor_name) + names.each do |name| + setup_hook(name, options) + end end + alias_method :define_hook, :define_hooks # Like Hooks#run_hook but for the class. Note that +:callbacks+ must be class methods. # @@ -46,13 +52,7 @@ module Hooks end def run_hook_for(name, scope, *args) - callbacks_for_hook(name).each do |callback| - if callback.kind_of? Symbol - scope.send(callback, *args) - else - scope.instance_exec(*args, &callback) - end - end + _hooks[name].run(scope, *args) end # Returns the callbacks for +name+. Handy if you want to run the callbacks yourself, say when @@ -67,28 +67,37 @@ module Hooks # # would run callbacks in the object _instance_ context, passing +self+ as block parameter. def callbacks_for_hook(name) - send("_#{name}_callbacks") + _hooks[name] end private - - def define_hook_writer(hook, accessor_name) - self.send(:define_method, hook.to_sym) do |&block| - if self.class.respond_to?(hook) - self.class.send(hook.to_sym, &block) - end - end - - instance_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 - def #{hook}(method=nil, &block) - #{accessor_name} << (block || method) - end - RUBY_EVAL + def setup_hook(name, options) + _hooks[name] = Hook.new(options) + define_hook_writer(name) end - def setup_hook_accessors(accessor_name) - inheritable_attr(accessor_name) - send("#{accessor_name}=", []) # initialize ivar. + def define_hook_writer(name) + self.send(:define_method, name.to_sym) do |&block| + if self.class.respond_to?(name) + self.class.send(name.to_sym, &block) + end + end + instance_eval *hook_writer_args(name) + end + + def hook_writer_args(name) + # DISCUSS: isn't there a simpler way to define a dynamic method? should the internal logic be handled by HooksSet instead? + str = <<-RUBY_EVAL + def #{name}(method=nil, &block) + _hooks[:#{name}] << (block || method) + end + RUBY_EVAL + + [str, __FILE__, __LINE__ + 1] + end + + def extract_options!(args) + args.last.is_a?(Hash) ? args.pop : {} end end @@ -106,4 +115,22 @@ module Hooks def run_hook(name, *args) self.class.run_hook_for(name, self, *args) end + + class HookSet < Hash + def [](name) + super(name.to_sym) + end + + def []=(name, values) + super(name.to_sym, values) + end + + def clone + super.tap do |cloned| + each { |name, callbacks| cloned[name] = callbacks.clone } + end + end + end end + +require File.join(File.dirname(__FILE__), "hooks/instance_hooks") diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/hook.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/hook.rb new file mode 100644 index 00000000..0f4d65a7 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/hook.rb @@ -0,0 +1,81 @@ +module Hooks + class Hook < Array + def initialize(options) + super() + @options = options + end + + # The chain contains the return values of the executed callbacks. + # + # Example: + # + # class Person + # define_hook :before_eating + # + # before_eating :wash_hands + # before_eating :locate_food + # before_eating :sit_down + # + # def wash_hands; :washed_hands; end + # def locate_food; :located_food; false; end + # def sit_down; :sat_down; end + # end + # + # result = person.run_hook(:before_eating) + # result.chain #=> [:washed_hands, false, :sat_down] + # + # If :halts_on_falsey is enabled: + # + # class Person + # define_hook :before_eating, :halts_on_falsey => true + # # ... + # end + # + # result = person.run_hook(:before_eating) + # result.chain #=> [:washed_hands] + def run(scope, *args) + inject(Results.new) do |results, callback| + executed = execute_callback(scope, callback, *args) + + return results.halted! unless continue_execution?(executed) + results << executed + end + end + + private + def execute_callback(scope, callback, *args) + if callback.kind_of?(Symbol) + scope.send(callback, *args) + else + scope.instance_exec(*args, &callback) + end + end + + def continue_execution?(result) + @options[:halts_on_falsey] ? result : true + end + + class Results < Array + # so much code for nothing... + def initialize(*) + super + @halted = false + end + + def halted! + @halted = true + self + end + + # Returns true or false based on whether all callbacks + # in the hook chain were successfully executed. + def halted? + @halted + end + + def not_halted? + not @halted + end + end + end +end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/lib/hooks/inheritable_attribute.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/inheritable_attribute.rb similarity index 98% rename from middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/lib/hooks/inheritable_attribute.rb rename to middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/inheritable_attribute.rb index 88f24b4f..352e28d6 100644 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.2.0/lib/hooks/inheritable_attribute.rb +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/inheritable_attribute.rb @@ -22,12 +22,12 @@ module Hooks def #{name}=(v) @#{name} = v end - + def #{name} return @#{name} unless superclass.respond_to?(:#{name}) and value = superclass.#{name} @#{name} ||= value.clone # only do this once. end } end - end + end end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/instance_hooks.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/instance_hooks.rb new file mode 100644 index 00000000..0f523fa4 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/instance_hooks.rb @@ -0,0 +1,25 @@ +module Hooks + module InstanceHooks + include ClassMethods + + def run_hook(name, *args) + run_hook_for(name, self, *args) + end + + private + def _hooks + @_hooks ||= self.class._hooks.clone # TODO: generify that with representable_attrs. + end + + module ClassMethods + def define_hook_writer(name) + super + class_eval *hook_writer_args(name) + end + end + + def self.included(base) + base.extend(ClassMethods) + end + end +end \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/version.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/version.rb new file mode 100644 index 00000000..788aaf77 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/version.rb @@ -0,0 +1,3 @@ +module Hooks + VERSION = "0.3.3" +end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hook_test.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hook_test.rb new file mode 100644 index 00000000..5d539be1 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hook_test.rb @@ -0,0 +1,31 @@ +require 'test_helper' + +class HookTest < MiniTest::Spec + subject { Hooks::Hook.new({}) } + + it "exposes array behaviour for callbacks" do + subject << :play_music + subject << :drink_beer + + subject.to_a.must_equal [:play_music, :drink_beer] + end +end + +class ResultsTest < MiniTest::Spec + subject { Hooks::Hook::Results.new } + + describe "#halted?" do + it "defaults to false" do + subject.halted?.must_equal false + end + + it "responds to #halted!" do + subject.halted! + subject.halted?.must_equal true + end + + it "responds to #not_halted?" do + subject.not_halted?.must_equal true + end + end +end \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hooks_test.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hooks_test.rb new file mode 100644 index 00000000..151a4b3d --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hooks_test.rb @@ -0,0 +1,216 @@ +require 'test_helper' + +class HooksTest < MiniTest::Spec + class TestClass + include Hooks + + def executed + @executed ||= []; + end + end + + + describe "::define_hook" do + let(:klass) do + Class.new(TestClass) do + define_hook :after_eight + end + end + + subject { klass.new } + + it "respond to Class.callbacks_for_hook" do + assert_equal [], klass.callbacks_for_hook(:after_eight) + klass.after_eight :dine + assert_equal [:dine], klass.callbacks_for_hook(:after_eight) + end + + it 'symbolizes strings when defining a hook' do + subject.class.define_hooks :before_one, 'after_one' + assert_equal [], klass.callbacks_for_hook(:before_one) + assert_equal [], klass.callbacks_for_hook(:after_one) + assert_equal [], klass.callbacks_for_hook('after_one') + end + + it "accept multiple hook names" do + subject.class.define_hooks :before_ten, :after_ten + assert_equal [], klass.callbacks_for_hook(:before_ten) + assert_equal [], klass.callbacks_for_hook(:after_ten) + end + + describe "creates a public writer for the hook that" do + it "accepts method names" do + klass.after_eight :dine + assert_equal [:dine], klass._hooks[:after_eight] + end + + it "accepts blocks" do + klass.after_eight do true; end + assert klass._hooks[:after_eight].first.kind_of? Proc + end + + it "be inherited" do + klass.after_eight :dine + subklass = Class.new(klass) + + assert_equal [:dine], subklass._hooks[:after_eight] + end + # TODO: check if options are not shared! + end + + describe "Hooks#run_hook" do + it "run without parameters" do + subject.instance_eval do + def a; executed << :a; nil; end + def b; executed << :b; end + + self.class.after_eight :b + self.class.after_eight :a + end + + subject.run_hook(:after_eight) + + assert_equal [:b, :a], subject.executed + end + + it "returns empty Results when no callbacks defined" do + subject.run_hook(:after_eight).must_equal Hooks::Hook::Results.new + end + + it "accept arbitrary parameters" do + subject.instance_eval do + def a(me, arg); executed << arg+1; end + end + subject.class.after_eight :a + subject.class.after_eight lambda { |me, arg| me.executed << arg-1 } + + subject.run_hook(:after_eight, subject, 1) + + assert_equal [2, 0], subject.executed + end + + it "execute block callbacks in instance context" do + subject.class.after_eight { executed << :c } + subject.run_hook(:after_eight) + assert_equal [:c], subject.executed + end + + it "returns all callbacks in order" do + subject.class.after_eight { :dinner_out } + subject.class.after_eight { :party_hard } + subject.class.after_eight { :taxi_home } + + results = subject.run_hook(:after_eight) + + assert_equal [:dinner_out, :party_hard, :taxi_home], results + assert_equal false, results.halted? + assert_equal true, results.not_halted? + end + + describe "halts_on_falsey: true" do + let(:klass) do + Class.new(TestClass) do + define_hook :after_eight, :halts_on_falsey => true + end + end + + [nil, false].each do |falsey| + it "returns successful callbacks in order (with #{falsey.inspect})" do + ordered = [] + + subject.class.after_eight { :dinner_out } + subject.class.after_eight { :party_hard; falsey } + subject.class.after_eight { :taxi_home } + + results = subject.run_hook(:after_eight) + + assert_equal [:dinner_out], results + assert_equal true, results.halted? + end + end + end + + describe "halts_on_falsey: false" do + [nil, false].each do |falsey| + it "returns all callbacks in order (with #{falsey.inspect})" do + ordered = [] + + subject.class.after_eight { :dinner_out } + subject.class.after_eight { :party_hard; falsey } + subject.class.after_eight { :taxi_home } + + results = subject.run_hook(:after_eight) + + assert_equal [:dinner_out, falsey, :taxi_home], results + assert_equal false, results.halted? + end + end + end + end + + describe "in class context" do + it "runs callback block" do + executed = [] + klass.after_eight do + executed << :klass + end + klass.run_hook(:after_eight) + + executed.must_equal([:klass]) + end + + it "runs instance methods" do + executed = [] + klass.instance_eval do + after_eight :have_dinner + + def have_dinner(executed) + executed << :have_dinner + end + end + klass.run_hook(:after_eight, executed) + + executed.must_equal([:have_dinner]) + end + end + end + + describe "Inheritance" do + let (:superclass) { + Class.new(TestClass) do + define_hook :after_eight + + after_eight :take_shower + end + } + + let (:subclass) { Class.new(superclass) do after_eight :have_dinner end } + + it "inherits callbacks from the hook" do + subclass.callbacks_for_hook(:after_eight).must_equal [:take_shower, :have_dinner] + end + + it "doesn't mix up superclass hooks" do + subclass.superclass.callbacks_for_hook(:after_eight).must_equal [:take_shower] + end + end +end + +class HookSetTest < MiniTest::Spec + subject { Hooks::HookSet.new } + + let (:first_hook) { Hooks::Hook.new(:halts_on_falsey => true) } + let (:second_hook) { Hooks::Hook.new(:halts_on_falsey => false) } + + it "responds to #clone" do + subject[:after_eight] = [first_hook] + + clone = subject.clone + + clone[:after_eight] << second_hook + + subject.must_equal(:after_eight => [first_hook]) + clone.must_equal(:after_eight => [first_hook, second_hook]) + end + # TODO: test if options get cloned. +end \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/inheritable_attribute_test.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/inheritable_attribute_test.rb new file mode 100644 index 00000000..4cc14e58 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/inheritable_attribute_test.rb @@ -0,0 +1,53 @@ +require 'test_helper' + +class HooksTest < MiniTest::Spec + describe "Hooks.define_hook" do + subject { + Class.new(Object) do + extend Hooks::InheritableAttribute + inheritable_attr :drinks + end + } + + it "provides a reader with empty inherited attributes, already" do + assert_equal nil, subject.drinks + end + + it "provides a reader with empty inherited attributes in a derived class" do + assert_equal nil, Class.new(subject).drinks + #subject.drinks = true + #Class.new(subject).drinks # TODO: crashes. + end + + it "provides an attribute copy in subclasses" do + subject.drinks = [] + assert subject.drinks.object_id != Class.new(subject).drinks.object_id + end + + it "provides a writer" do + subject.drinks = [:cabernet] + assert_equal [:cabernet], subject.drinks + end + + it "inherits attributes" do + subject.drinks = [:cabernet] + + subklass_a = Class.new(subject) + subklass_a.drinks << :becks + + subklass_b = Class.new(subject) + + assert_equal [:cabernet], subject.drinks + assert_equal [:cabernet, :becks], subklass_a.drinks + assert_equal [:cabernet], subklass_b.drinks + end + + it "does not inherit attributes if we set explicitely" do + subject.drinks = [:cabernet] + subklass = Class.new(subject) + + subklass.drinks = [:merlot] # we only want merlot explicitely. + assert_equal [:merlot], subklass.drinks # no :cabernet, here + end + end +end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/instance_hooks_test.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/instance_hooks_test.rb new file mode 100644 index 00000000..ffac3fb5 --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/instance_hooks_test.rb @@ -0,0 +1,55 @@ +require "test_helper" + +class InstanceHooksTest < HooksTest + describe "#define_hook" do + let(:klass) { Class.new(TestClass) do + include Hooks::InstanceHooks + end } + + subject { klass.new.tap do |obj| + obj.instance_eval do + def dine; executed << :dine; end + end + end } + + it "adds hook to instance" do + subject.define_hook :after_eight + + assert_equal [], subject.callbacks_for_hook(:after_eight) + end + + it "copies existing class hook" do + klass.define_hook :after_eight + klass.after_eight :dine + + assert_equal [:dine], subject.callbacks_for_hook(:after_eight) + end + + describe "#after_eight (adding callbacks)" do + before do + subject.define_hook :after_eight + subject.after_eight :dine + end + + it "adds #after_eight hook" do + assert_equal [:dine], subject.callbacks_for_hook(:after_eight) + end + + it "responds to #run_hook" do + subject.run_hook :after_eight + subject.executed.must_equal [:dine] + end + end + + describe "#after_eight from class (no define_hook in instance)" do + it "responds to #after_eight" do + klass.define_hook :after_eight + + subject.after_eight :dine + + subject.run_hook :after_eight + subject.executed.must_equal [:dine] + end + end + end +end \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/test_helper.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/test_helper.rb new file mode 100644 index 00000000..2ece0d0e --- /dev/null +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/test_helper.rb @@ -0,0 +1,3 @@ +require 'minitest/autorun' +require 'pry' +require 'hooks' From 2ad91339bb890b4ebee4c7880ca584f779eb1242 Mon Sep 17 00:00:00 2001 From: Nico Hagenburger Date: Sun, 2 Feb 2014 11:12:57 +0100 Subject: [PATCH 023/580] =?UTF-8?q?use=20instance=20hooks=20provided=20by?= =?UTF-8?q?=20hooks=20instead=20of=20changing=20the=20gem=E2=80=99s=20sour?= =?UTF-8?q?ce?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- middleman-core/lib/middleman-core/application.rb | 7 +++++++ .../lib/middleman-core/core_extensions/extensions.rb | 2 +- .../lib/middleman-more/core_extensions/compass.rb | 2 +- .../lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb | 5 ----- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb index 5110aa36..35a8dc4c 100644 --- a/middleman-core/lib/middleman-core/application.rb +++ b/middleman-core/lib/middleman-core/application.rb @@ -33,6 +33,7 @@ module Middleman # Uses callbacks include Hooks + include Hooks::InstanceHooks # Before request hook define_hook :before @@ -240,5 +241,11 @@ module Middleman end alias :inspect :to_s # Ruby 2.0 calls inspect for NoMethodError instead of to_s + # Hooks clones _hooks from the class to the instance. + # https://github.com/apotonick/hooks/blob/master/lib/hooks/instance_hooks.rb#L10 + # Middleman expects the same list of hooks for class and instance hooks: + def _hooks + self.class._hooks + end end end diff --git a/middleman-core/lib/middleman-core/core_extensions/extensions.rb b/middleman-core/lib/middleman-core/core_extensions/extensions.rb index 9dfea24c..403176e2 100644 --- a/middleman-core/lib/middleman-core/core_extensions/extensions.rb +++ b/middleman-core/lib/middleman-core/core_extensions/extensions.rb @@ -151,7 +151,7 @@ module Middleman run_hook :build_config config_context.execute_configure_callbacks(:build) end - + if development? run_hook :development_config config_context.execute_configure_callbacks(:development) diff --git a/middleman-core/lib/middleman-more/core_extensions/compass.rb b/middleman-core/lib/middleman-more/core_extensions/compass.rb index b46b7639..1947edef 100644 --- a/middleman-core/lib/middleman-more/core_extensions/compass.rb +++ b/middleman-core/lib/middleman-more/core_extensions/compass.rb @@ -49,7 +49,7 @@ class Middleman::CoreExtensions::Compass < ::Middleman::Extension end # Call hook - app.run_hook :compass_config, ::Compass.configuration + app.run_hook_for :compass_config, app, ::Compass.configuration # Tell Tilt to use it as well (for inline sass blocks) ::Tilt.register 'sass', CompassSassTemplate diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb index 02ad0964..d7c6d5dd 100644 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb +++ b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb @@ -77,11 +77,6 @@ module Hooks end def define_hook_writer(name) - self.send(:define_method, name.to_sym) do |&block| - if self.class.respond_to?(name) - self.class.send(name.to_sym, &block) - end - end instance_eval *hook_writer_args(name) end From d6f9e8c6408bc8191dd9e6d8979b43f5a57977f7 Mon Sep 17 00:00:00 2001 From: Nico Hagenburger Date: Sun, 2 Feb 2014 11:18:25 +0100 Subject: [PATCH 024/580] =?UTF-8?q?as=20there=20are=20no=20more=20local=20?= =?UTF-8?q?changes=20in=20the=20hooks=E2=80=99=20source,=20it=20can=20be?= =?UTF-8?q?=20unvendored=20and=20used=20as=20gem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/middleman-core/application.rb | 2 +- .../hooks-0.3.3/.gitignore | 2 - .../hooks-0.3.3/.travis.yml | 5 - .../hooks-0.3.3/CHANGES.md | 33 --- .../hooks-0.3.3/Gemfile | 3 - .../hooks-0.3.3/LICENSE.txt | 20 -- .../hooks-0.3.3/README.md | 202 ---------------- .../hooks-0.3.3/Rakefile | 12 - .../hooks-0.3.3/hooks.gemspec | 25 -- .../hooks-0.3.3/lib/hooks.rb | 131 ----------- .../hooks-0.3.3/lib/hooks/hook.rb | 81 ------- .../lib/hooks/inheritable_attribute.rb | 33 --- .../hooks-0.3.3/lib/hooks/instance_hooks.rb | 25 -- .../hooks-0.3.3/lib/hooks/version.rb | 3 - .../hooks-0.3.3/test/hook_test.rb | 31 --- .../hooks-0.3.3/test/hooks_test.rb | 216 ------------------ .../test/inheritable_attribute_test.rb | 53 ----- .../hooks-0.3.3/test/instance_hooks_test.rb | 55 ----- .../hooks-0.3.3/test/test_helper.rb | 3 - middleman-core/middleman-core.gemspec | 1 + 20 files changed, 2 insertions(+), 934 deletions(-) delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.gitignore delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.travis.yml delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/CHANGES.md delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Gemfile delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/LICENSE.txt delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/README.md delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Rakefile delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/hooks.gemspec delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/hook.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/inheritable_attribute.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/instance_hooks.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/version.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hook_test.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hooks_test.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/inheritable_attribute_test.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/instance_hooks_test.rb delete mode 100644 middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/test_helper.rb diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb index 35a8dc4c..0b30e314 100644 --- a/middleman-core/lib/middleman-core/application.rb +++ b/middleman-core/lib/middleman-core/application.rb @@ -10,7 +10,7 @@ require 'active_support/json' require 'active_support/core_ext/integer/inflections' # Simple callback library -require 'vendored-middleman-deps/hooks-0.3.3/lib/hooks' +require 'hooks' # Our custom logger require 'middleman-core/logger' diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.gitignore b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.gitignore deleted file mode 100644 index 80e3957f..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -Gemfile.lock - diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.travis.yml b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.travis.yml deleted file mode 100644 index 03107eec..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: ruby -rvm: - - 1.8.7 - - 1.9.3 - - 2.0.0 diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/CHANGES.md b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/CHANGES.md deleted file mode 100644 index 277fda61..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/CHANGES.md +++ /dev/null @@ -1,33 +0,0 @@ -## 0.3.3 - -* Fix a bug where the hook writer method (e.g. `#after_dark`) wasn't available on the instance even when `InstanceHooks` was included. - -## 0.3.2 - -* Added `Hooks::InstanceHooks` to add hooks and/or callbacks on instance level. Thanks to @mpapis for that suggestion. - -## 0.3.1 - -* Fix a bug, string hook names are now treated as symbols. - -## 0.3.0 - -* The callback chain can now be halted by configuring the hook as `halts_on_falsey: true` and returning `nil` or `false` from the callback. -* Internal refactorings: hooks are now encapsulated in `Hook` instances and run their callback chains. - -## 0.2.2 - -* `#run_hook` now returns the list of callback results. - -## 0.2.1 - -* You can now pass multiple hook names to `#define_hooks`. - -## 0.2.0 - -h3. Changes -* Callback blocks are now executed on the instance using `instance_exec`. If you need to access the class (former context) use `self.class`. - -## 0.1.4 - -* An uninitialized `inheritable_attr` doesn't crash since it is not cloned anymore. Note that an uncloneable attribute value still causes an exception. diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Gemfile b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Gemfile deleted file mode 100644 index fa75df15..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Gemfile +++ /dev/null @@ -1,3 +0,0 @@ -source 'https://rubygems.org' - -gemspec diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/LICENSE.txt b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/LICENSE.txt deleted file mode 100644 index ffbc659d..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/LICENSE.txt +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2011-2013 Nick Sutterer - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/README.md b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/README.md deleted file mode 100644 index 436d988d..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/README.md +++ /dev/null @@ -1,202 +0,0 @@ -# Hooks - -_Generic hooks with callbacks for Ruby._ - - -## Introduction - -_Hooks_ lets you define hooks declaratively in your ruby class. You can add callbacks to your hook, which will be run as soon as _you_ run the hook! - -It's almost like ActiveSupport::Callbacks but 76,6% less complex. Instead, it is not more than a few lines of code, one method compilation, no `method_missing` and no magic. - -Also, you may pass additional arguments to your callbacks when invoking a hook. - -## Example - -Let's take... a cat. - -```ruby -require 'hooks' - -class Cat - include Hooks - - define_hooks :before_dinner, :after_dinner -``` - -Now you can add callbacks to your hook declaratively in your class. - -```ruby - before_dinner :wash_paws - - after_dinner do - puts "Ice cream for #{self}!" - end - - after_dinner :have_a_desert # => refers to Cat#have_a_desert - - def have_a_desert - puts "Hell, yeah!" - end -``` - -This will run the block and `#have_a_desert` from above. - -```ruby -cat.run_hook :after_dinner -# => Ice cream for #! - Hell, yeah! -``` - -Callback blocks and methods will be executed with instance context. Note how `self` in the block refers to the Cat instance. - - -## Inheritance - -Hooks are inherited, here's a complete example to put it all together. - -```ruby -class Garfield < Cat - - after_dinner :want_some_more - - def want_some_more - puts "Is that all?" - end -end - - -Garfield.new.run_hook :after_dinner -# => Ice cream for #! - Hell, yeah! - Is that all? -``` - -Note how the callbacks are invoked in the order they were inherited. - - -## Options for Callbacks - -You're free to pass any number of arguments to #run_callback, those will be passed to the callbacks. - -```ruby -cat.run_hook :before_dinner, cat, Time.now -``` - -The callbacks should be ready for receiving parameters. - -```ruby -before_dinner :wash_pawns -before_dinner do |who, when| - ... -end - -def wash_pawns(who, when) -``` - -Not sure why a cat should have ice cream for dinner. Beside that, I was tempted naming this gem _hooker_. - - -## Running And Halting Hooks - -Using `#run_hook` doesn't only run all callbacks for this hook but also returns an array of the results from each callback method or block. - -```ruby -class Garfield - include Hooks - define_hook :after_dark - - after_dark { "Chase mice" } - after_dark { "Enjoy supper" } -end - -Garfield.new.run_hook :after_dark -# => ["Chase mice", "Enjoy supper"] -``` - -This is handy if you need to collect data from your callbacks without having to access a global (brrr) variable. - -With the `:halts_on_falsey` option you can halt the callback chain when a callback returns `nil` or `false`. - -```ruby -class Garfield - include Hooks - define_hook :after_dark, halts_on_falsey: true - - after_dark { "Chase mice" } - after_dark { nil } - after_dark { "Enjoy supper" } -end - -result = Garfield.new.run_hook :after_dark -# => ["Chase mice"] -``` - -This will only run the first two callbacks. Note that the result doesn't contain the `nil` value. You even can check if the chain was halted. - -```ruby -result.halted? #=> true -``` - -## Instance Hooks - -You can also define hooks and/or add callbacks per instance. This is helpful if your class should define a basic set of hooks and callbacks that are then extended by instances. - -```ruby -class Cat - include Hooks - include Hooks::InstanceHooks - - define_hook :after_dark - - after_dark { "Chase mice" } -end -``` - -Note that you have to include `Hooks::InstanceHooks` to get this additional functionality. - -See how callbacks can be added to a separate object, now. - -```ruby -garfield = Cat.new - -garfield.after_dark :sleep -garfield.run_hook(:after_dark) # => invoke "Chase mice" hook and #sleep -``` - -This will copy all callbacks from the `after_dark` hook to the instance and add a second hook. This all happens on the `garfield` instance, only, and leaves the class untouched. - -Naturally, adding new hooks works like-wise. - -```ruby -garfield.define_hook :before_six -garfield.before_six { .. } -``` -This feature was added in 0.3.2. - - -## Installation - -In your Gemfile, do - -```ruby -gem "hooks" -``` - -## Anybody using it? - -* Hooks is already used in [Apotomo](http://github.com/apotonick/apotomo), a hot widget framework for Rails. -* The [datamappify](https://github.com/fredwu/datamappify) gem uses hooks and the author Fred Wu contributed to this gem! - -## Similar libraries - -* http://github.com/nakajima/aspectory -* http://github.com/auser/backcall -* http://github.com/mmcgrana/simple_callbacks - - -## License - -Copyright (c) 2013, Nick Sutterer - -Released under the MIT License. diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Rakefile b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Rakefile deleted file mode 100644 index 4799b87b..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/Rakefile +++ /dev/null @@ -1,12 +0,0 @@ -require 'rake' -require 'rake/testtask' - -desc 'Default: run unit tests.' -task :default => :test - -desc 'Test the hooks plugin.' -Rake::TestTask.new(:test) do |test| - test.libs << 'test' - test.test_files = FileList['test/*_test.rb'] - test.verbose = true -end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/hooks.gemspec b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/hooks.gemspec deleted file mode 100644 index fe7c1cf4..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/hooks.gemspec +++ /dev/null @@ -1,25 +0,0 @@ -lib = File.expand_path('../lib/', __FILE__) -$:.unshift lib unless $:.include?(lib) - -require 'hooks/version' - -Gem::Specification.new do |s| - s.name = "hooks" - s.version = Hooks::VERSION - s.platform = Gem::Platform::RUBY - s.authors = ["Nick Sutterer"] - s.email = ["apotonick@gmail.com"] - s.homepage = "http://nicksda.apotomo.de/2010/09/hooks-and-callbacks-for-ruby-but-simple/" - s.summary = %q{Generic hooks with callbacks for Ruby.} - s.description = %q{Declaratively define hooks, add callbacks and run them with the options you like.} - s.license = "MIT" - - s.files = `git ls-files`.split("\n") - s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") - s.require_paths = ["lib"] - s.license = 'MIT' - - s.add_development_dependency "minitest", ">= 5.0.0" - s.add_development_dependency "rake" - s.add_development_dependency "pry" -end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb deleted file mode 100644 index d7c6d5dd..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks.rb +++ /dev/null @@ -1,131 +0,0 @@ -require File.join(File.dirname(__FILE__), "hooks/inheritable_attribute") -require File.join(File.dirname(__FILE__), "hooks/hook") - -# Almost like ActiveSupport::Callbacks but 76,6% less complex. -# -# Example: -# -# class CatWidget < Apotomo::Widget -# define_hooks :before_dinner, :after_dinner -# -# Now you can add callbacks to your hook declaratively in your class. -# -# before_dinner :wash_paws -# after_dinner { puts "Ice cream!" } -# after_dinner :have_a_desert # => refers to CatWidget#have_a_desert -# -# Running the callbacks happens on instances. It will run the block and #have_a_desert from above. -# -# cat.run_hook :after_dinner -module Hooks - def self.included(base) - base.class_eval do - extend InheritableAttribute - extend ClassMethods - inheritable_attr :_hooks - self._hooks= HookSet.new - end - end - - module ClassMethods - def define_hooks(*names) - options = extract_options!(names) - - names.each do |name| - setup_hook(name, options) - end - end - alias_method :define_hook, :define_hooks - - # Like Hooks#run_hook but for the class. Note that +:callbacks+ must be class methods. - # - # Example: - # - # class Cat - # after_eight :grab_a_beer - # - # def self.grab_a_beer(*) # and so on... - # - # where Cat.run_hook :after_eight will call the class method +grab_a_beer+. - def run_hook(name, *args) - run_hook_for(name, self, *args) - end - - def run_hook_for(name, scope, *args) - _hooks[name].run(scope, *args) - end - - # Returns the callbacks for +name+. Handy if you want to run the callbacks yourself, say when - # they should be executed in another context. - # - # Example: - # - # def initialize - # self.class.callbacks_for_hook(:after_eight).each do |callback| - # instance_exec(self, &callback) - # end - # - # would run callbacks in the object _instance_ context, passing +self+ as block parameter. - def callbacks_for_hook(name) - _hooks[name] - end - - private - def setup_hook(name, options) - _hooks[name] = Hook.new(options) - define_hook_writer(name) - end - - def define_hook_writer(name) - instance_eval *hook_writer_args(name) - end - - def hook_writer_args(name) - # DISCUSS: isn't there a simpler way to define a dynamic method? should the internal logic be handled by HooksSet instead? - str = <<-RUBY_EVAL - def #{name}(method=nil, &block) - _hooks[:#{name}] << (block || method) - end - RUBY_EVAL - - [str, __FILE__, __LINE__ + 1] - end - - def extract_options!(args) - args.last.is_a?(Hash) ? args.pop : {} - end - end - - # Runs the callbacks (method/block) for the specified hook +name+. Additional arguments will - # be passed to the callback. - # - # Example: - # - # cat.run_hook :after_dinner, "i want ice cream!" - # - # will invoke the callbacks like - # - # desert("i want ice cream!") - # block.call("i want ice cream!") - def run_hook(name, *args) - self.class.run_hook_for(name, self, *args) - end - - class HookSet < Hash - def [](name) - super(name.to_sym) - end - - def []=(name, values) - super(name.to_sym, values) - end - - def clone - super.tap do |cloned| - each { |name, callbacks| cloned[name] = callbacks.clone } - end - end - end -end - -require File.join(File.dirname(__FILE__), "hooks/instance_hooks") diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/hook.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/hook.rb deleted file mode 100644 index 0f4d65a7..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/hook.rb +++ /dev/null @@ -1,81 +0,0 @@ -module Hooks - class Hook < Array - def initialize(options) - super() - @options = options - end - - # The chain contains the return values of the executed callbacks. - # - # Example: - # - # class Person - # define_hook :before_eating - # - # before_eating :wash_hands - # before_eating :locate_food - # before_eating :sit_down - # - # def wash_hands; :washed_hands; end - # def locate_food; :located_food; false; end - # def sit_down; :sat_down; end - # end - # - # result = person.run_hook(:before_eating) - # result.chain #=> [:washed_hands, false, :sat_down] - # - # If :halts_on_falsey is enabled: - # - # class Person - # define_hook :before_eating, :halts_on_falsey => true - # # ... - # end - # - # result = person.run_hook(:before_eating) - # result.chain #=> [:washed_hands] - def run(scope, *args) - inject(Results.new) do |results, callback| - executed = execute_callback(scope, callback, *args) - - return results.halted! unless continue_execution?(executed) - results << executed - end - end - - private - def execute_callback(scope, callback, *args) - if callback.kind_of?(Symbol) - scope.send(callback, *args) - else - scope.instance_exec(*args, &callback) - end - end - - def continue_execution?(result) - @options[:halts_on_falsey] ? result : true - end - - class Results < Array - # so much code for nothing... - def initialize(*) - super - @halted = false - end - - def halted! - @halted = true - self - end - - # Returns true or false based on whether all callbacks - # in the hook chain were successfully executed. - def halted? - @halted - end - - def not_halted? - not @halted - end - end - end -end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/inheritable_attribute.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/inheritable_attribute.rb deleted file mode 100644 index 352e28d6..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/inheritable_attribute.rb +++ /dev/null @@ -1,33 +0,0 @@ -module Hooks - module InheritableAttribute - # Creates an inheritable attribute with accessors in the singleton class. Derived classes inherit the - # attributes. This is especially helpful with arrays or hashes that are extended in the inheritance - # chain. Note that you have to initialize the inheritable attribute. - # - # Example: - # - # class Cat - # inheritable_attr :drinks - # self.drinks = ["Becks"] - # - # class Garfield < Cat - # self.drinks << "Fireman's 4" - # - # and then, later - # - # Cat.drinks #=> ["Becks"] - # Garfield.drinks #=> ["Becks", "Fireman's 4"] - def inheritable_attr(name) - instance_eval %Q{ - def #{name}=(v) - @#{name} = v - end - - def #{name} - return @#{name} unless superclass.respond_to?(:#{name}) and value = superclass.#{name} - @#{name} ||= value.clone # only do this once. - end - } - end - end -end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/instance_hooks.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/instance_hooks.rb deleted file mode 100644 index 0f523fa4..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/instance_hooks.rb +++ /dev/null @@ -1,25 +0,0 @@ -module Hooks - module InstanceHooks - include ClassMethods - - def run_hook(name, *args) - run_hook_for(name, self, *args) - end - - private - def _hooks - @_hooks ||= self.class._hooks.clone # TODO: generify that with representable_attrs. - end - - module ClassMethods - def define_hook_writer(name) - super - class_eval *hook_writer_args(name) - end - end - - def self.included(base) - base.extend(ClassMethods) - end - end -end \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/version.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/version.rb deleted file mode 100644 index 788aaf77..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/lib/hooks/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module Hooks - VERSION = "0.3.3" -end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hook_test.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hook_test.rb deleted file mode 100644 index 5d539be1..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hook_test.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'test_helper' - -class HookTest < MiniTest::Spec - subject { Hooks::Hook.new({}) } - - it "exposes array behaviour for callbacks" do - subject << :play_music - subject << :drink_beer - - subject.to_a.must_equal [:play_music, :drink_beer] - end -end - -class ResultsTest < MiniTest::Spec - subject { Hooks::Hook::Results.new } - - describe "#halted?" do - it "defaults to false" do - subject.halted?.must_equal false - end - - it "responds to #halted!" do - subject.halted! - subject.halted?.must_equal true - end - - it "responds to #not_halted?" do - subject.not_halted?.must_equal true - end - end -end \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hooks_test.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hooks_test.rb deleted file mode 100644 index 151a4b3d..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/hooks_test.rb +++ /dev/null @@ -1,216 +0,0 @@ -require 'test_helper' - -class HooksTest < MiniTest::Spec - class TestClass - include Hooks - - def executed - @executed ||= []; - end - end - - - describe "::define_hook" do - let(:klass) do - Class.new(TestClass) do - define_hook :after_eight - end - end - - subject { klass.new } - - it "respond to Class.callbacks_for_hook" do - assert_equal [], klass.callbacks_for_hook(:after_eight) - klass.after_eight :dine - assert_equal [:dine], klass.callbacks_for_hook(:after_eight) - end - - it 'symbolizes strings when defining a hook' do - subject.class.define_hooks :before_one, 'after_one' - assert_equal [], klass.callbacks_for_hook(:before_one) - assert_equal [], klass.callbacks_for_hook(:after_one) - assert_equal [], klass.callbacks_for_hook('after_one') - end - - it "accept multiple hook names" do - subject.class.define_hooks :before_ten, :after_ten - assert_equal [], klass.callbacks_for_hook(:before_ten) - assert_equal [], klass.callbacks_for_hook(:after_ten) - end - - describe "creates a public writer for the hook that" do - it "accepts method names" do - klass.after_eight :dine - assert_equal [:dine], klass._hooks[:after_eight] - end - - it "accepts blocks" do - klass.after_eight do true; end - assert klass._hooks[:after_eight].first.kind_of? Proc - end - - it "be inherited" do - klass.after_eight :dine - subklass = Class.new(klass) - - assert_equal [:dine], subklass._hooks[:after_eight] - end - # TODO: check if options are not shared! - end - - describe "Hooks#run_hook" do - it "run without parameters" do - subject.instance_eval do - def a; executed << :a; nil; end - def b; executed << :b; end - - self.class.after_eight :b - self.class.after_eight :a - end - - subject.run_hook(:after_eight) - - assert_equal [:b, :a], subject.executed - end - - it "returns empty Results when no callbacks defined" do - subject.run_hook(:after_eight).must_equal Hooks::Hook::Results.new - end - - it "accept arbitrary parameters" do - subject.instance_eval do - def a(me, arg); executed << arg+1; end - end - subject.class.after_eight :a - subject.class.after_eight lambda { |me, arg| me.executed << arg-1 } - - subject.run_hook(:after_eight, subject, 1) - - assert_equal [2, 0], subject.executed - end - - it "execute block callbacks in instance context" do - subject.class.after_eight { executed << :c } - subject.run_hook(:after_eight) - assert_equal [:c], subject.executed - end - - it "returns all callbacks in order" do - subject.class.after_eight { :dinner_out } - subject.class.after_eight { :party_hard } - subject.class.after_eight { :taxi_home } - - results = subject.run_hook(:after_eight) - - assert_equal [:dinner_out, :party_hard, :taxi_home], results - assert_equal false, results.halted? - assert_equal true, results.not_halted? - end - - describe "halts_on_falsey: true" do - let(:klass) do - Class.new(TestClass) do - define_hook :after_eight, :halts_on_falsey => true - end - end - - [nil, false].each do |falsey| - it "returns successful callbacks in order (with #{falsey.inspect})" do - ordered = [] - - subject.class.after_eight { :dinner_out } - subject.class.after_eight { :party_hard; falsey } - subject.class.after_eight { :taxi_home } - - results = subject.run_hook(:after_eight) - - assert_equal [:dinner_out], results - assert_equal true, results.halted? - end - end - end - - describe "halts_on_falsey: false" do - [nil, false].each do |falsey| - it "returns all callbacks in order (with #{falsey.inspect})" do - ordered = [] - - subject.class.after_eight { :dinner_out } - subject.class.after_eight { :party_hard; falsey } - subject.class.after_eight { :taxi_home } - - results = subject.run_hook(:after_eight) - - assert_equal [:dinner_out, falsey, :taxi_home], results - assert_equal false, results.halted? - end - end - end - end - - describe "in class context" do - it "runs callback block" do - executed = [] - klass.after_eight do - executed << :klass - end - klass.run_hook(:after_eight) - - executed.must_equal([:klass]) - end - - it "runs instance methods" do - executed = [] - klass.instance_eval do - after_eight :have_dinner - - def have_dinner(executed) - executed << :have_dinner - end - end - klass.run_hook(:after_eight, executed) - - executed.must_equal([:have_dinner]) - end - end - end - - describe "Inheritance" do - let (:superclass) { - Class.new(TestClass) do - define_hook :after_eight - - after_eight :take_shower - end - } - - let (:subclass) { Class.new(superclass) do after_eight :have_dinner end } - - it "inherits callbacks from the hook" do - subclass.callbacks_for_hook(:after_eight).must_equal [:take_shower, :have_dinner] - end - - it "doesn't mix up superclass hooks" do - subclass.superclass.callbacks_for_hook(:after_eight).must_equal [:take_shower] - end - end -end - -class HookSetTest < MiniTest::Spec - subject { Hooks::HookSet.new } - - let (:first_hook) { Hooks::Hook.new(:halts_on_falsey => true) } - let (:second_hook) { Hooks::Hook.new(:halts_on_falsey => false) } - - it "responds to #clone" do - subject[:after_eight] = [first_hook] - - clone = subject.clone - - clone[:after_eight] << second_hook - - subject.must_equal(:after_eight => [first_hook]) - clone.must_equal(:after_eight => [first_hook, second_hook]) - end - # TODO: test if options get cloned. -end \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/inheritable_attribute_test.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/inheritable_attribute_test.rb deleted file mode 100644 index 4cc14e58..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/inheritable_attribute_test.rb +++ /dev/null @@ -1,53 +0,0 @@ -require 'test_helper' - -class HooksTest < MiniTest::Spec - describe "Hooks.define_hook" do - subject { - Class.new(Object) do - extend Hooks::InheritableAttribute - inheritable_attr :drinks - end - } - - it "provides a reader with empty inherited attributes, already" do - assert_equal nil, subject.drinks - end - - it "provides a reader with empty inherited attributes in a derived class" do - assert_equal nil, Class.new(subject).drinks - #subject.drinks = true - #Class.new(subject).drinks # TODO: crashes. - end - - it "provides an attribute copy in subclasses" do - subject.drinks = [] - assert subject.drinks.object_id != Class.new(subject).drinks.object_id - end - - it "provides a writer" do - subject.drinks = [:cabernet] - assert_equal [:cabernet], subject.drinks - end - - it "inherits attributes" do - subject.drinks = [:cabernet] - - subklass_a = Class.new(subject) - subklass_a.drinks << :becks - - subklass_b = Class.new(subject) - - assert_equal [:cabernet], subject.drinks - assert_equal [:cabernet, :becks], subklass_a.drinks - assert_equal [:cabernet], subklass_b.drinks - end - - it "does not inherit attributes if we set explicitely" do - subject.drinks = [:cabernet] - subklass = Class.new(subject) - - subklass.drinks = [:merlot] # we only want merlot explicitely. - assert_equal [:merlot], subklass.drinks # no :cabernet, here - end - end -end diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/instance_hooks_test.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/instance_hooks_test.rb deleted file mode 100644 index ffac3fb5..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/instance_hooks_test.rb +++ /dev/null @@ -1,55 +0,0 @@ -require "test_helper" - -class InstanceHooksTest < HooksTest - describe "#define_hook" do - let(:klass) { Class.new(TestClass) do - include Hooks::InstanceHooks - end } - - subject { klass.new.tap do |obj| - obj.instance_eval do - def dine; executed << :dine; end - end - end } - - it "adds hook to instance" do - subject.define_hook :after_eight - - assert_equal [], subject.callbacks_for_hook(:after_eight) - end - - it "copies existing class hook" do - klass.define_hook :after_eight - klass.after_eight :dine - - assert_equal [:dine], subject.callbacks_for_hook(:after_eight) - end - - describe "#after_eight (adding callbacks)" do - before do - subject.define_hook :after_eight - subject.after_eight :dine - end - - it "adds #after_eight hook" do - assert_equal [:dine], subject.callbacks_for_hook(:after_eight) - end - - it "responds to #run_hook" do - subject.run_hook :after_eight - subject.executed.must_equal [:dine] - end - end - - describe "#after_eight from class (no define_hook in instance)" do - it "responds to #after_eight" do - klass.define_hook :after_eight - - subject.after_eight :dine - - subject.run_hook :after_eight - subject.executed.must_equal [:dine] - end - end - end -end \ No newline at end of file diff --git a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/test_helper.rb b/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/test_helper.rb deleted file mode 100644 index 2ece0d0e..00000000 --- a/middleman-core/lib/vendored-middleman-deps/hooks-0.3.3/test/test_helper.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'minitest/autorun' -require 'pry' -require 'hooks' diff --git a/middleman-core/middleman-core.gemspec b/middleman-core/middleman-core.gemspec index 30f59c00..527fdca4 100644 --- a/middleman-core/middleman-core.gemspec +++ b/middleman-core/middleman-core.gemspec @@ -21,6 +21,7 @@ Gem::Specification.new do |s| s.add_dependency("bundler", ["~> 1.1"]) s.add_dependency("rack", [">= 1.4.5"]) s.add_dependency("tilt", ["~> 1.4.1"]) + s.add_dependency("hooks", ["~> 0.3"]) # Helpers s.add_dependency("activesupport", ["~> 4.0.1"]) From c5b0ba17eafc3632f4ae196fd798ce237b5aa974 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Sat, 22 Feb 2014 20:10:25 -0800 Subject: [PATCH 025/580] Fix Padrino integration after merge --- .../middleman-more/core_extensions/default_helpers.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb b/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb index 6bbceb66..288c99b4 100644 --- a/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb +++ b/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb @@ -68,7 +68,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension handler = auto_find_proper_handler(&block) captured_block, captured_html = nil, '' - if handler && handler.block_is_type?(block) + if handler && handler.engine_matches?(block) captured_html, captured_block = handler.capture_from_template(*args, &block) end @@ -80,7 +80,13 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension def auto_find_proper_handler(&block) if block_given? engine = File.extname(block.source_location[0])[1..-1].to_sym - ::Padrino::Helpers::OutputHelpers.handlers.map { |h| h.new(self) }.find { |h| h.engines.include?(engine) && h.block_is_type?(block) } + ::Padrino::Helpers::OutputHelpers.handlers.select do |e, h| + e == engine + end.values.map do |h| + h.new(self) + end.find do |h| + h.engine_matches?(block) + end else find_proper_handler end From e662b6433f4f60ffae0a5d63de805814075a96b6 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Sat, 22 Feb 2014 18:24:40 -0800 Subject: [PATCH 026/580] Reapply changes from 477f87e98a6b19775697c0a25090795a74e591ff to TemplateRenderer/TemplateContext --- .../lib/middleman-core/template_context.rb | 33 +++----- .../lib/middleman-core/template_renderer.rb | 81 ++++++++----------- 2 files changed, 43 insertions(+), 71 deletions(-) diff --git a/middleman-core/lib/middleman-core/template_context.rb b/middleman-core/lib/middleman-core/template_context.rb index 70c97195..d06ca5f0 100644 --- a/middleman-core/lib/middleman-core/template_context.rb +++ b/middleman-core/lib/middleman-core/template_context.rb @@ -68,43 +68,28 @@ module Middleman locals = options[:locals] found_partial = false - engine = nil + resolve_opts = { try_without_underscore: true } # If the path is known to the sitemap if resource = sitemap.find_resource_by_path(current_path) current_dir = File.dirname(resource.source_file) - engine = File.extname(resource.source_file)[1..-1].to_sym + resolve_opts[:preferred_engine] = File.extname(resource.source_file)[1..-1].to_sym # Look for partials relative to the current path relative_dir = File.join(current_dir.sub(%r{^#{Regexp.escape(self.source_dir)}/?}, ''), data) - # Try to use the current engine first - found_partial, found_engine = ::Middleman::TemplateRenderer.resolve_template(@app, relative_dir, :preferred_engine => engine, :try_without_underscore => true) - - # Fall back to any engine available - if !found_partial - found_partial, found_engine = ::Middleman::TemplateRenderer.resolve_template(@app, relative_dir, :try_without_underscore => true) - end + found_partial = ::Middleman::TemplateRenderer.resolve_template(@app, relative_dir, resolve_opts) end - # Look in the partials_dir for the partial with the current engine - partials_path = File.join(config[:partials_dir], data) - if !found_partial && !engine.nil? - found_partial, found_engine = ::Middleman::TemplateRenderer.resolve_template(@app, partials_path, :preferred_engine => engine, :try_without_underscore => true) - end - - # Look in the root with any engine if !found_partial - found_partial, found_engine = ::Middleman::TemplateRenderer.resolve_template(@app, partials_path, :try_without_underscore => true) + partials_path = File.join(@app.config[:partials_dir], data) + found_partial = ::Middleman::TemplateRenderer.resolve_template(@app, partials_path, resolve_opts) end - # Render the partial if found, otherwide throw exception - if found_partial - file_renderer = ::Middleman::FileRenderer.new(@app, found_partial) - file_renderer.render(locals, options, self, &block) - else - raise ::Middleman::TemplateRenderer::TemplateNotFound, "Could not locate partial: #{data}" - end + raise ::Middleman::TemplateRenderer::TemplateNotFound, "Could not locate partial: #{data}" unless found_partial + + file_renderer = ::Middleman::FileRenderer.new(@app, found_partial) + file_renderer.render(locals, options, self, &block) end end end diff --git a/middleman-core/lib/middleman-core/template_renderer.rb b/middleman-core/lib/middleman-core/template_renderer.rb index 5a561fe9..3b0e4c02 100644 --- a/middleman-core/lib/middleman-core/template_renderer.rb +++ b/middleman-core/lib/middleman-core/template_renderer.rb @@ -55,7 +55,7 @@ module Middleman path = File.basename(path, File.extname(path)) rescue LocalJumpError - raise "Tried to render a layout (calls yield) at #{path} like it was a template. Non-default layouts need to be in #{source}/#{layout_dir}." + raise "Tried to render a layout (calls yield) at #{path} like it was a template. Non-default layouts need to be in #{source}/#{@app.config[:layouts_dir]}." end end @@ -130,26 +130,14 @@ module Middleman # Whether we've found the layout layout_path = false - # If we prefer a specific engine - if !preferred_engine.nil? - # Check root - layout_path, layout_engine = resolve_template(app, name, :preferred_engine => preferred_engine) + resolve_opts = {} + resolve_opts[:preferred_engine] = preferred_engine if !preferred_engine.nil? - # Check layouts folder - if !layout_path - layout_path, layout_engine = resolve_template(app, File.join(app.config[:layouts_dir], name.to_s), :preferred_engine => preferred_engine) - end - end + # Check layouts folder + layout_path = resolve_template(app, File.join(app.config[:layouts_dir], name.to_s), resolve_opts) - # Check root, no preference - if !layout_path - layout_path, layout_engine = resolve_template(app, name) - end - - # Check layouts folder, no preference - if !layout_path - layout_path, layout_engine = resolve_template(app, File.join(app.config[:layouts_dir], name.to_s)) - end + # If we didn't find it, check root + layout_path = resolve_template(app, name, resolve_opts) unless layout_path # Return the path layout_path @@ -165,8 +153,9 @@ module Middleman # Find a template on disk given a output path # @param [String] request_path - # @param [Hash] options - # @return [Array, Boolean] + # @option options [Boolean] :preferred_engine If set, try this engine first, then fall back to any engine. + # @option options [Boolean] :try_without_underscore + # @return [String, Boolean] Either the path to the template, or false def self.resolve_template(app, request_path, options={}) # Find the path by searching or using the cache request_path = request_path.to_s @@ -175,48 +164,46 @@ module Middleman on_disk_path = File.expand_path(relative_path, app.source_dir) # By default, any engine will do - preferred_engine = '*' + preferred_engines = ['*'] - # Unless we're specifically looking for a preferred engine + # If we're specifically looking for a preferred engine if options.has_key?(:preferred_engine) extension_class = ::Tilt[options[:preferred_engine]] matched_exts = [] # Get a list of extensions for a preferred engine - # TODO: Cache this - ::Tilt.mappings.each do |ext, engines| - next unless engines.include? extension_class - matched_exts << ext - end + matched_exts = ::Tilt.mappings.select do |ext, engines| + engines.include? extension_class + end.keys - # Change the glob to only look for the matched extensions - if matched_exts.length > 0 - preferred_engine = '{' + matched_exts.join(',') + '}' - else - return false + # Prefer to look for the matched extensions + unless matched_exts.empty? + preferred_engines.unshift('{' + matched_exts.join(',') + '}') end end - # Look for files that match - path_with_ext = on_disk_path + '.' + preferred_engine - - found_path = Dir[path_with_ext].find do |path| - ::Tilt[path] + search_paths = preferred_engines.flat_map do |preferred_engine| + path_with_ext = on_disk_path + '.' + preferred_engine + paths = [path_with_ext] + if options[:try_without_underscore] + paths << path_with_ext.sub(relative_path, relative_path.sub(/^_/, '').sub(/\/_/, '/')) + end + paths end - if !found_path && options[:try_without_underscore] && - path_no_underscore = path_with_ext. - sub(relative_path, relative_path.sub(/^_/, ''). - sub(/\/_/, '/')) - found_path = Dir[path_no_underscore].find do |path| + found_path = nil + search_paths.each do |path_with_ext| + found_path = Dir[path_with_ext].find do |path| ::Tilt[path] end + break if found_path end - # If we found one, return it and the found engine - if found_path || app.files.exists?(on_disk_path) - engine = found_path ? File.extname(found_path)[1..-1].to_sym : nil - [ found_path || on_disk_path, engine ] + # If we found one, return it + if found_path + found_path + elsif File.exists?(on_disk_path) + on_disk_path else false end From 0f9b199bfa42cd5cdeb5a6caab034b93dc8a5a1e Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Sat, 22 Feb 2014 18:46:32 -0800 Subject: [PATCH 027/580] Move some requires around --- middleman-core/lib/middleman-core/extension.rb | 3 +++ middleman-core/lib/middleman-core/extensions.rb | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/middleman-core/lib/middleman-core/extension.rb b/middleman-core/lib/middleman-core/extension.rb index 1ac42d1e..0ad3b6ca 100644 --- a/middleman-core/lib/middleman-core/extension.rb +++ b/middleman-core/lib/middleman-core/extension.rb @@ -1,3 +1,6 @@ +require 'active_support/core_ext/class/attribute' +require 'active_support/core_ext/module/delegation' + module Middleman class Extension class_attribute :supports_multiple_instances, :instance_reader => false, :instance_writer => false diff --git a/middleman-core/lib/middleman-core/extensions.rb b/middleman-core/lib/middleman-core/extensions.rb index 7cfbec45..b6981657 100644 --- a/middleman-core/lib/middleman-core/extensions.rb +++ b/middleman-core/lib/middleman-core/extensions.rb @@ -1,6 +1,3 @@ -require 'active_support/core_ext/class/attribute' -require 'active_support/core_ext/module/delegation' - module Middleman module Extensions From 81baf8c47c3514a8ab37ae6e661e638135a00830 Mon Sep 17 00:00:00 2001 From: Capi Etheriel Date: Sat, 1 Mar 2014 15:19:38 -0300 Subject: [PATCH 028/580] Use no layouts for xml, json and txt by default --- middleman-cli/lib/middleman-cli/templates/shared/config.tt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/middleman-cli/lib/middleman-cli/templates/shared/config.tt b/middleman-cli/lib/middleman-cli/templates/shared/config.tt index f96e0a26..d154431c 100755 --- a/middleman-cli/lib/middleman-cli/templates/shared/config.tt +++ b/middleman-cli/lib/middleman-cli/templates/shared/config.tt @@ -14,7 +14,9 @@ # Per-page layout changes: # # With no layout -# page "/path/to/file.html", :layout => false +page '/*.xml', layout: false +page '/*.json', layout: false +page '/*.txt', layout: false # # With alternative layout # page "/path/to/file.html", :layout => :otherlayout From 5de4e337c118bc50ce8247a170efaed434e77bc3 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Mon, 3 Mar 2014 22:32:12 -0800 Subject: [PATCH 029/580] Merge middleman-more back into middleman-core --- .../lib/middleman-core/core_extensions.rb | 28 +++++++++---------- .../core_extensions/compass.rb | 0 .../core_extensions/default_helpers.rb | 0 .../core_extensions/i18n.rb | 0 .../extensions/asset_hash.rb | 0 .../extensions/asset_host.rb | 0 .../extensions/automatic_alt_tags.rb | 0 .../extensions/automatic_image_sizes.rb | 0 .../extensions/cache_buster.rb | 0 .../extensions/directory_indexes.rb | 0 .../extensions/gzip.rb | 0 .../extensions/lorem.rb | 0 .../extensions/minify_css.rb | 0 .../extensions/minify_javascript.rb | 0 .../extensions/relative_assets.rb | 0 15 files changed, 14 insertions(+), 14 deletions(-) rename middleman-core/lib/{middleman-more => middleman-core}/core_extensions/compass.rb (100%) rename middleman-core/lib/{middleman-more => middleman-core}/core_extensions/default_helpers.rb (100%) rename middleman-core/lib/{middleman-more => middleman-core}/core_extensions/i18n.rb (100%) rename middleman-core/lib/{middleman-more => middleman-core}/extensions/asset_hash.rb (100%) rename middleman-core/lib/{middleman-more => middleman-core}/extensions/asset_host.rb (100%) rename middleman-core/lib/{middleman-more => middleman-core}/extensions/automatic_alt_tags.rb (100%) rename middleman-core/lib/{middleman-more => middleman-core}/extensions/automatic_image_sizes.rb (100%) rename middleman-core/lib/{middleman-more => middleman-core}/extensions/cache_buster.rb (100%) rename middleman-core/lib/{middleman-more => middleman-core}/extensions/directory_indexes.rb (100%) rename middleman-core/lib/{middleman-more => middleman-core}/extensions/gzip.rb (100%) rename middleman-core/lib/{middleman-more => middleman-core}/extensions/lorem.rb (100%) rename middleman-core/lib/{middleman-more => middleman-core}/extensions/minify_css.rb (100%) rename middleman-core/lib/{middleman-more => middleman-core}/extensions/minify_javascript.rb (100%) rename middleman-core/lib/{middleman-more => middleman-core}/extensions/relative_assets.rb (100%) diff --git a/middleman-core/lib/middleman-core/core_extensions.rb b/middleman-core/lib/middleman-core/core_extensions.rb index 45471877..b241c9c5 100644 --- a/middleman-core/lib/middleman-core/core_extensions.rb +++ b/middleman-core/lib/middleman-core/core_extensions.rb @@ -27,13 +27,13 @@ require 'middleman-core/core_extensions/routing' require 'middleman-core/core_extensions/show_exceptions' # Setup default helpers -require 'middleman-more/core_extensions/default_helpers' +require 'middleman-core/core_extensions/default_helpers' -require 'middleman-more/core_extensions/i18n' +require 'middleman-core/core_extensions/i18n' # Compass framework begin - require 'middleman-more/core_extensions/compass' + require 'middleman-core/core_extensions/compass' rescue LoadError end @@ -43,52 +43,52 @@ end # CacheBuster adds a query string to assets in dynamic templates to # avoid browser caches failing to update to your new content. -require 'middleman-more/extensions/cache_buster' +require 'middleman-core/extensions/cache_buster' Middleman::Extensions::CacheBuster.register # RelativeAssets allow any asset path in dynamic templates to be either # relative to the root of the project or use an absolute URL. -require 'middleman-more/extensions/relative_assets' +require 'middleman-core/extensions/relative_assets' Middleman::Extensions::RelativeAssets.register # AssetHost allows you to setup multiple domains to host your static # assets. Calls to asset paths in dynamic templates will then rotate # through each of the asset servers to better spread the load. -require 'middleman-more/extensions/asset_host' +require 'middleman-core/extensions/asset_host' Middleman::Extensions::AssetHost.register # MinifyCss compresses CSS -require 'middleman-more/extensions/minify_css' +require 'middleman-core/extensions/minify_css' Middleman::Extensions::MinifyCss.register # MinifyJavascript compresses JS -require 'middleman-more/extensions/minify_javascript' +require 'middleman-core/extensions/minify_javascript' Middleman::Extensions::MinifyJavascript.register # GZIP assets and pages during build -require 'middleman-more/extensions/gzip' +require 'middleman-core/extensions/gzip' Middleman::Extensions::Gzip.register # AssetHash appends a hash of the file contents to the assets filename # to avoid browser caches failing to update to your new content. -require 'middleman-more/extensions/asset_hash' +require 'middleman-core/extensions/asset_hash' Middleman::Extensions::AssetHash.register # Provide Apache-style index.html files for directories -require 'middleman-more/extensions/directory_indexes' +require 'middleman-core/extensions/directory_indexes' Middleman::Extensions::DirectoryIndexes.register # Lorem provides a handful of helpful prototyping methods to generate # words, paragraphs, fake images, names and email addresses. -require 'middleman-more/extensions/lorem' +require 'middleman-core/extensions/lorem' # AutomaticImageSizes inspects the images used in your dynamic templates # and automatically adds width and height attributes to their HTML # elements. -require 'middleman-more/extensions/automatic_image_sizes' +require 'middleman-core/extensions/automatic_image_sizes' Middleman::Extensions::AutomaticImageSizes.register # AutomaticAltTags uses the file name of the `image_tag` to generate # a default `:alt` value. -require 'middleman-more/extensions/automatic_alt_tags' +require 'middleman-core/extensions/automatic_alt_tags' Middleman::Extensions::AutomaticAltTags.register diff --git a/middleman-core/lib/middleman-more/core_extensions/compass.rb b/middleman-core/lib/middleman-core/core_extensions/compass.rb similarity index 100% rename from middleman-core/lib/middleman-more/core_extensions/compass.rb rename to middleman-core/lib/middleman-core/core_extensions/compass.rb diff --git a/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb b/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb similarity index 100% rename from middleman-core/lib/middleman-more/core_extensions/default_helpers.rb rename to middleman-core/lib/middleman-core/core_extensions/default_helpers.rb diff --git a/middleman-core/lib/middleman-more/core_extensions/i18n.rb b/middleman-core/lib/middleman-core/core_extensions/i18n.rb similarity index 100% rename from middleman-core/lib/middleman-more/core_extensions/i18n.rb rename to middleman-core/lib/middleman-core/core_extensions/i18n.rb diff --git a/middleman-core/lib/middleman-more/extensions/asset_hash.rb b/middleman-core/lib/middleman-core/extensions/asset_hash.rb similarity index 100% rename from middleman-core/lib/middleman-more/extensions/asset_hash.rb rename to middleman-core/lib/middleman-core/extensions/asset_hash.rb diff --git a/middleman-core/lib/middleman-more/extensions/asset_host.rb b/middleman-core/lib/middleman-core/extensions/asset_host.rb similarity index 100% rename from middleman-core/lib/middleman-more/extensions/asset_host.rb rename to middleman-core/lib/middleman-core/extensions/asset_host.rb diff --git a/middleman-core/lib/middleman-more/extensions/automatic_alt_tags.rb b/middleman-core/lib/middleman-core/extensions/automatic_alt_tags.rb similarity index 100% rename from middleman-core/lib/middleman-more/extensions/automatic_alt_tags.rb rename to middleman-core/lib/middleman-core/extensions/automatic_alt_tags.rb diff --git a/middleman-core/lib/middleman-more/extensions/automatic_image_sizes.rb b/middleman-core/lib/middleman-core/extensions/automatic_image_sizes.rb similarity index 100% rename from middleman-core/lib/middleman-more/extensions/automatic_image_sizes.rb rename to middleman-core/lib/middleman-core/extensions/automatic_image_sizes.rb diff --git a/middleman-core/lib/middleman-more/extensions/cache_buster.rb b/middleman-core/lib/middleman-core/extensions/cache_buster.rb similarity index 100% rename from middleman-core/lib/middleman-more/extensions/cache_buster.rb rename to middleman-core/lib/middleman-core/extensions/cache_buster.rb diff --git a/middleman-core/lib/middleman-more/extensions/directory_indexes.rb b/middleman-core/lib/middleman-core/extensions/directory_indexes.rb similarity index 100% rename from middleman-core/lib/middleman-more/extensions/directory_indexes.rb rename to middleman-core/lib/middleman-core/extensions/directory_indexes.rb diff --git a/middleman-core/lib/middleman-more/extensions/gzip.rb b/middleman-core/lib/middleman-core/extensions/gzip.rb similarity index 100% rename from middleman-core/lib/middleman-more/extensions/gzip.rb rename to middleman-core/lib/middleman-core/extensions/gzip.rb diff --git a/middleman-core/lib/middleman-more/extensions/lorem.rb b/middleman-core/lib/middleman-core/extensions/lorem.rb similarity index 100% rename from middleman-core/lib/middleman-more/extensions/lorem.rb rename to middleman-core/lib/middleman-core/extensions/lorem.rb diff --git a/middleman-core/lib/middleman-more/extensions/minify_css.rb b/middleman-core/lib/middleman-core/extensions/minify_css.rb similarity index 100% rename from middleman-core/lib/middleman-more/extensions/minify_css.rb rename to middleman-core/lib/middleman-core/extensions/minify_css.rb diff --git a/middleman-core/lib/middleman-more/extensions/minify_javascript.rb b/middleman-core/lib/middleman-core/extensions/minify_javascript.rb similarity index 100% rename from middleman-core/lib/middleman-more/extensions/minify_javascript.rb rename to middleman-core/lib/middleman-core/extensions/minify_javascript.rb diff --git a/middleman-core/lib/middleman-more/extensions/relative_assets.rb b/middleman-core/lib/middleman-core/extensions/relative_assets.rb similarity index 100% rename from middleman-core/lib/middleman-more/extensions/relative_assets.rb rename to middleman-core/lib/middleman-core/extensions/relative_assets.rb From 9e9bed0043515c3adcd3c4dee248b648dac1343d Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Mon, 3 Mar 2014 23:07:32 -0800 Subject: [PATCH 030/580] pry-debugger is not available on Ruby 2.1 --- Gemfile | 1 - middleman-cli/lib/middleman-cli/bundler.rb | 40 ---------------------- 2 files changed, 41 deletions(-) delete mode 100644 middleman-cli/lib/middleman-cli/bundler.rb diff --git a/Gemfile b/Gemfile index 83cd68cc..6b365575 100644 --- a/Gemfile +++ b/Gemfile @@ -24,7 +24,6 @@ platforms :ruby do gem 'therubyracer' gem 'redcarpet', '~> 3.1' gem 'pry', :require => false, :group => :development - gem 'pry-debugger', :require => false, :group => :development end platforms :jruby do diff --git a/middleman-cli/lib/middleman-cli/bundler.rb b/middleman-cli/lib/middleman-cli/bundler.rb deleted file mode 100644 index 43a0d862..00000000 --- a/middleman-cli/lib/middleman-cli/bundler.rb +++ /dev/null @@ -1,40 +0,0 @@ -# CLI Module -module Middleman::Cli - - # A initializing Bundler - class Bundle < Thor - include Thor::Actions - check_unknown_options! - - namespace :bundle - - desc 'bundle', 'Setup initial bundle', :hide => true - - # The setup task - def bundle - run('bundle install')#, :capture => true) - end - end - - # A upgrading Bundler - class Upgrade < Thor - include Thor::Actions - check_unknown_options! - - namespace :upgrade - - desc 'upgrade', 'Upgrade installed bundle' - - # The upgrade task - def upgrade - inside(ENV['MM_ROOT']) do - run('bundle update')#, :capture => true) - end - end - end - - # Map "u" to "upgrade" - Base.map({ - 'u' => 'upgrade' - }) -end From 220d1e89488a96f209127e9dae371471aab3a5fb Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Mon, 3 Mar 2014 23:08:32 -0800 Subject: [PATCH 031/580] Require Bundler (a Gemfile) for all set up Middleman projects. We still do extension auto-discovery for "init". Gemfile may now be in any parent directory of 'config.rb', in case the Middleman project is in a subdirectory of a larger project. --- CHANGELOG.md | 3 ++ middleman-cli/lib/middleman-cli.rb | 1 - .../lib/middleman-core/load_paths.rb | 53 +++++++++---------- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de7befb1..02e856b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ master === +* Remove 'upgrade' and 'install' CLI commands. +* Gemfile may be in a parent directory of your Middleman project root (where 'config.rb' is). +* All dependencies for your Middleman project must be expressed in `Gemfile` - Bundler is no longer optional. * Asciidoc information now available with the `asciidoc` local, which is a normal hash. * Remove `page` template local. Use `current_resource` instead. * Dropped support for providing a block to `page` & `proxy`. diff --git a/middleman-cli/lib/middleman-cli.rb b/middleman-cli/lib/middleman-cli.rb index ee02429d..48fb1b2d 100644 --- a/middleman-cli/lib/middleman-cli.rb +++ b/middleman-cli/lib/middleman-cli.rb @@ -88,7 +88,6 @@ end # Include the core CLI items require 'middleman-cli/init' -require 'middleman-cli/bundler' require 'middleman-cli/extension' require 'middleman-cli/server' require 'middleman-cli/build' diff --git a/middleman-core/lib/middleman-core/load_paths.rb b/middleman-core/lib/middleman-core/load_paths.rb index 673563f6..d763b003 100644 --- a/middleman-core/lib/middleman-core/load_paths.rb +++ b/middleman-core/lib/middleman-core/load_paths.rb @@ -8,35 +8,16 @@ module Middleman @_is_setup ||= begin # Only look for config.rb if MM_ROOT isn't set - if !ENV['MM_ROOT'] && found_path = locate_root + if !ENV['MM_ROOT'] && (found_path = findup('config.rb')) ENV['MM_ROOT'] = found_path end - is_bundler_setup = false - # If we've found the root, try to setup Bundler if ENV['MM_ROOT'] - - root_gemfile = File.expand_path('Gemfile', ENV['MM_ROOT']) - ENV['BUNDLE_GEMFILE'] ||= root_gemfile - - if !File.exists?(ENV['BUNDLE_GEMFILE']) - git_gemfile = Pathname.new(__FILE__).expand_path.parent.parent.parent + 'Gemfile' - ENV['BUNDLE_GEMFILE'] = git_gemfile.to_s - end - - if File.exists?(ENV['BUNDLE_GEMFILE']) - is_bundler_setup = true - require 'bundler/setup' - end - end - - # Automatically discover extensions in RubyGems - require 'middleman-core/extensions' - - if is_bundler_setup - Bundler.require + setup_bundler else + # Automatically discover extensions in RubyGems + require 'middleman-core/extensions' ::Middleman.load_extensions_in_path end @@ -44,11 +25,29 @@ module Middleman end end - # Recursive method to find config.rb - def locate_root(cwd = Pathname.new(Dir.pwd)) - return cwd.to_s if (cwd + 'config.rb').exist? + private + + # Set BUNDLE_GEMFILE and run Bundler setup. Raises an exception if there is no Gemfile + def setup_bundler + ENV['BUNDLE_GEMFILE'] ||= findup('Gemfile', ENV['MM_ROOT']) + + if !File.exists?(ENV['BUNDLE_GEMFILE']) + ENV['BUNDLE_GEMFILE'] = File.expand_path('../../../../Gemfile', __FILE__) + end + + if File.exists?(ENV['BUNDLE_GEMFILE']) + require 'bundler/setup' + Bundler.require + else + raise "Couldn't find your Gemfile. Middleman projects require a Gemfile for specifying dependencies." + end + end + + # Recursive method to find a file in parent directories + def findup(filename, cwd = Pathname.new(Dir.pwd)) + return cwd.to_s if (cwd + filename).exist? return false if cwd.root? - locate_root(cwd.parent) + findup(cwd.parent) end end From 10f8715bdebb8ba03b5ba63ae2e0dd80911a7d75 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Tue, 4 Mar 2014 22:43:10 -0800 Subject: [PATCH 032/580] Whoops, properly implement findup --- middleman-core/lib/middleman-core/load_paths.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/middleman-core/lib/middleman-core/load_paths.rb b/middleman-core/lib/middleman-core/load_paths.rb index d763b003..968e61ec 100644 --- a/middleman-core/lib/middleman-core/load_paths.rb +++ b/middleman-core/lib/middleman-core/load_paths.rb @@ -47,7 +47,7 @@ module Middleman def findup(filename, cwd = Pathname.new(Dir.pwd)) return cwd.to_s if (cwd + filename).exist? return false if cwd.root? - findup(cwd.parent) + findup(filename, cwd.parent) end end From 23b1b8464dbd9bdb04d067a15e70fc0efd8210dc Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Sun, 9 Mar 2014 17:50:34 -0700 Subject: [PATCH 033/580] move livereload init into dev block --- middleman-cli/lib/middleman-cli/templates/shared/config.tt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/middleman-cli/lib/middleman-cli/templates/shared/config.tt b/middleman-cli/lib/middleman-cli/templates/shared/config.tt index d154431c..f6d586a1 100755 --- a/middleman-cli/lib/middleman-cli/templates/shared/config.tt +++ b/middleman-cli/lib/middleman-cli/templates/shared/config.tt @@ -38,7 +38,9 @@ page '/*.txt', layout: false # activate :automatic_image_sizes # Reload the browser automatically whenever files change -# activate :livereload +# configure :development do +# activate :livereload +# end # Methods defined in the helpers block are available in templates # helpers do From 772de85ce332d8c4e50cb486c8671d8688dfd3a2 Mon Sep 17 00:00:00 2001 From: Karl Freeman Date: Tue, 11 Mar 2014 11:07:55 +0000 Subject: [PATCH 034/580] move to middleman-templates --- Gemfile | 1 + Rakefile | 2 +- middleman-cli/lib/middleman-cli/init.rb | 2 +- middleman-cli/lib/middleman-cli/templates.rb | 99 ------------------ .../source/js/vendor/jquery-1.8.0.min.js | 2 - .../source/js/vendor/modernizr-2.6.1.min.js | 4 - .../.gemtest | 0 middleman-templates/.simplecov | 5 + middleman-templates/.yardopts | 4 + middleman-templates/Rakefile | 5 + middleman-templates/bin/middleman | 18 ++++ .../features/.gitkeep | 0 middleman-templates/fixtures/.gitkeep | 0 .../lib/middleman-templates.rb | 92 ++++++++++++++++ .../lib/middleman-templates}/default.rb | 0 .../default/source/images/background.png | Bin .../default/source/images/middleman.png | Bin .../default/source/index.html.erb | 0 .../default/source/javascripts/all.js | 0 .../default/source/layouts/layout.erb | 0 .../default/source/stylesheets/all.css | 0 .../default/source/stylesheets/normalize.css | 0 .../lib/middleman-templates}/empty.rb | 0 .../lib/middleman-templates}/empty/Gemfile.tt | 0 .../lib/middleman-templates}/html5.rb | 0 .../html5/source/.htaccess | 0 .../html5/source/404.html | 0 .../html5/source/LICENSE.md | 0 .../html5/source/README.md | 0 .../apple-touch-icon-114x114-precomposed.png | Bin .../apple-touch-icon-144x144-precomposed.png | Bin .../apple-touch-icon-57x57-precomposed.png | Bin .../apple-touch-icon-72x72-precomposed.png | Bin .../source/apple-touch-icon-precomposed.png | Bin .../html5/source/apple-touch-icon.png | Bin .../html5/source/crossdomain.xml | 0 .../html5/source/css/main.css | 0 .../html5/source/css/normalize.css | 0 .../html5/source/favicon.ico | Bin .../html5/source/humans.txt | 0 .../html5/source/img/.gitignore | 0 .../html5/source/index.html.erb | 0 .../html5/source/js/main.js | 0 .../html5/source/js/plugins.js | 0 .../html5/source/layouts/layout.erb | 0 .../html5/source/robots.txt | 0 .../lib/middleman-templates}/local.rb | 0 .../lib/middleman-templates}/mobile.rb | 0 .../mobile/source/404.html | 0 .../mobile/source/README.markdown | 0 .../mobile/source/crossdomain.xml | 0 .../mobile/source/css/style.css | 0 .../mobile/source/humans.txt | 0 .../mobile/source/img/h/apple-touch-icon.png | Bin .../mobile/source/img/h/splash.png | Bin .../img/l/apple-touch-icon-precomposed.png | Bin .../mobile/source/img/l/apple-touch-icon.png | Bin .../mobile/source/img/l/splash.png | Bin .../mobile/source/img/m/apple-touch-icon.png | Bin .../mobile/source/index.html | 0 .../mobile/source/js/libs/modernizr-custom.js | 0 .../mobile/source/js/libs/respond.min.js | 0 .../mobile/source/js/mylibs/helper.js | 0 .../mobile/source/js/plugins.js | 0 .../mobile/source/js/script.js | 0 .../mobile/source/robots.txt | 0 .../mobile/source/sitemap.xml | 0 .../mobile/source/test/index.html | 0 .../mobile/source/test/qunit/qunit.css | 0 .../mobile/source/test/qunit/qunit.js | 0 .../mobile/source/test/tests.js | 0 .../tools/googleanalyticsformobile/Readme.PDF | Bin .../aspx/aspx1.snippet | 0 .../aspx/aspx2.snippet | 0 .../googleanalyticsformobile/aspx/ga.aspx | 0 .../googleanalyticsformobile/aspx/sample.aspx | 0 .../tools/googleanalyticsformobile/jsp/ga.jsp | 0 .../googleanalyticsformobile/jsp/jsp1.snippet | 0 .../googleanalyticsformobile/jsp/jsp2.snippet | 0 .../googleanalyticsformobile/jsp/sample.jsp | 0 .../tools/googleanalyticsformobile/php/ga.php | 0 .../googleanalyticsformobile/php/php1.snippet | 0 .../googleanalyticsformobile/php/php2.snippet | 0 .../googleanalyticsformobile/php/sample.php | 0 .../tools/googleanalyticsformobile/pl/ga.pl | 0 .../googleanalyticsformobile/pl/perl1.snippet | 0 .../googleanalyticsformobile/pl/perl2.snippet | 0 .../googleanalyticsformobile/pl/sample.pl | 0 .../tools/mobile-bookmark-bubble/COPYING | 0 .../mobile-bookmark-bubble/bookmark_bubble.js | 0 .../example/example.html | 0 .../mobile-bookmark-bubble/example/example.js | 0 .../mobile-bookmark-bubble/images/arrow.png | Bin .../mobile-bookmark-bubble/images/close.png | Bin .../images/generate_base64_images | 0 .../images/icon_calendar.png | Bin .../mobile/source/tools/wspl/README | 0 .../source/tools/wspl/databasefactory.js | 0 .../mobile/source/tools/wspl/dbworker.js | 0 .../source/tools/wspl/dbworker_test.html | 0 .../source/tools/wspl/dbworkerstarter.js | 0 .../source/tools/wspl/dbwrapper_gears.js | 0 .../tools/wspl/dbwrapper_gears_test.html | 0 .../source/tools/wspl/dbwrapper_html5.js | 0 .../tools/wspl/dbwrapper_html5_test.html | 0 .../mobile/source/tools/wspl/dbwrapperapi.js | 0 .../source/tools/wspl/dbwrapperapi_test.html | 0 .../source/tools/wspl/gears_resultset.js | 0 .../tools/wspl/gears_resultset_test.html | 0 .../source/tools/wspl/gears_transaction.js | 0 .../tools/wspl/gears_transaction_test.html | 0 .../mobile/source/tools/wspl/gearsutils.js | 0 .../source/tools/wspl/gearsutils_test.html | 0 .../source/tools/wspl/global_functions.js | 0 .../source/tools/wspl/simplenotes/index.html | 0 .../tools/wspl/simplenotes/simplenotes.js | 0 .../source/tools/wspl/simplenotes/styles.css | 0 .../source/tools/wspl/simplenotes/template.js | 0 .../middleman-templates}/shared/Gemfile.tt | 0 .../lib/middleman-templates}/shared/config.ru | 0 .../lib/middleman-templates}/shared/config.tt | 0 .../lib/middleman-templates}/shared/gitignore | 0 .../middleman-templates.gemspec | 24 +++++ middleman-templates/spec/middleman/.gitkeep | 1 + middleman-templates/spec/spec_helper.rb | 0 middleman/middleman.gemspec | 1 + 126 files changed, 153 insertions(+), 107 deletions(-) delete mode 100644 middleman-cli/lib/middleman-cli/templates.rb delete mode 100755 middleman-cli/lib/middleman-cli/templates/html5/source/js/vendor/jquery-1.8.0.min.js delete mode 100755 middleman-cli/lib/middleman-cli/templates/html5/source/js/vendor/modernizr-2.6.1.min.js rename middleman-cli/lib/middleman-cli/templates/html5/source/img/.gitignore => middleman-templates/.gemtest (100%) mode change 100755 => 100644 create mode 100644 middleman-templates/.simplecov create mode 100644 middleman-templates/.yardopts create mode 100644 middleman-templates/Rakefile create mode 100755 middleman-templates/bin/middleman rename middleman-cli/lib/middleman-cli/templates/mobile/source/js/script.js => middleman-templates/features/.gitkeep (100%) mode change 100755 => 100644 create mode 100644 middleman-templates/fixtures/.gitkeep create mode 100644 middleman-templates/lib/middleman-templates.rb rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/default.rb (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/default/source/images/background.png (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/default/source/images/middleman.png (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/default/source/index.html.erb (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/default/source/javascripts/all.js (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/default/source/layouts/layout.erb (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/default/source/stylesheets/all.css (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/default/source/stylesheets/normalize.css (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/empty.rb (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/empty/Gemfile.tt (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/html5.rb (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/html5/source/.htaccess (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/html5/source/404.html (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/html5/source/LICENSE.md (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/html5/source/README.md (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/html5/source/apple-touch-icon-114x114-precomposed.png (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/html5/source/apple-touch-icon-144x144-precomposed.png (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/html5/source/apple-touch-icon-57x57-precomposed.png (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/html5/source/apple-touch-icon-72x72-precomposed.png (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/html5/source/apple-touch-icon-precomposed.png (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/html5/source/apple-touch-icon.png (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/html5/source/crossdomain.xml (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/html5/source/css/main.css (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/html5/source/css/normalize.css (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/html5/source/favicon.ico (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/html5/source/humans.txt (100%) create mode 100755 middleman-templates/lib/middleman-templates/html5/source/img/.gitignore rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/html5/source/index.html.erb (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/html5/source/js/main.js (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/html5/source/js/plugins.js (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/html5/source/layouts/layout.erb (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/html5/source/robots.txt (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/local.rb (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile.rb (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/404.html (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/README.markdown (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/crossdomain.xml (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/css/style.css (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/humans.txt (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/img/h/apple-touch-icon.png (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/img/h/splash.png (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/img/l/apple-touch-icon-precomposed.png (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/img/l/apple-touch-icon.png (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/img/l/splash.png (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/img/m/apple-touch-icon.png (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/index.html (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/js/libs/modernizr-custom.js (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/js/libs/respond.min.js (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/js/mylibs/helper.js (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/js/plugins.js (100%) create mode 100755 middleman-templates/lib/middleman-templates/mobile/source/js/script.js rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/robots.txt (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/sitemap.xml (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/test/index.html (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/test/qunit/qunit.css (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/test/qunit/qunit.js (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/test/tests.js (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/googleanalyticsformobile/Readme.PDF (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/googleanalyticsformobile/aspx/aspx1.snippet (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/googleanalyticsformobile/aspx/aspx2.snippet (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/googleanalyticsformobile/aspx/ga.aspx (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/googleanalyticsformobile/aspx/sample.aspx (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/googleanalyticsformobile/jsp/ga.jsp (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/googleanalyticsformobile/jsp/jsp1.snippet (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/googleanalyticsformobile/jsp/jsp2.snippet (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/googleanalyticsformobile/jsp/sample.jsp (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/googleanalyticsformobile/php/ga.php (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/googleanalyticsformobile/php/php1.snippet (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/googleanalyticsformobile/php/php2.snippet (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/googleanalyticsformobile/php/sample.php (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/googleanalyticsformobile/pl/ga.pl (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/googleanalyticsformobile/pl/perl1.snippet (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/googleanalyticsformobile/pl/perl2.snippet (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/googleanalyticsformobile/pl/sample.pl (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/mobile-bookmark-bubble/COPYING (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/mobile-bookmark-bubble/bookmark_bubble.js (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/mobile-bookmark-bubble/example/example.html (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/mobile-bookmark-bubble/example/example.js (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/mobile-bookmark-bubble/images/arrow.png (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/mobile-bookmark-bubble/images/close.png (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/mobile-bookmark-bubble/images/generate_base64_images (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/mobile-bookmark-bubble/images/icon_calendar.png (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/wspl/README (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/wspl/databasefactory.js (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/wspl/dbworker.js (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/wspl/dbworker_test.html (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/wspl/dbworkerstarter.js (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/wspl/dbwrapper_gears.js (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/wspl/dbwrapper_gears_test.html (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/wspl/dbwrapper_html5.js (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/wspl/dbwrapper_html5_test.html (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/wspl/dbwrapperapi.js (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/wspl/dbwrapperapi_test.html (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/wspl/gears_resultset.js (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/wspl/gears_resultset_test.html (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/wspl/gears_transaction.js (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/wspl/gears_transaction_test.html (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/wspl/gearsutils.js (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/wspl/gearsutils_test.html (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/wspl/global_functions.js (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/wspl/simplenotes/index.html (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/wspl/simplenotes/simplenotes.js (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/wspl/simplenotes/styles.css (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/mobile/source/tools/wspl/simplenotes/template.js (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/shared/Gemfile.tt (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/shared/config.ru (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/shared/config.tt (100%) rename {middleman-cli/lib/middleman-cli/templates => middleman-templates/lib/middleman-templates}/shared/gitignore (100%) create mode 100644 middleman-templates/middleman-templates.gemspec create mode 100644 middleman-templates/spec/middleman/.gitkeep create mode 100644 middleman-templates/spec/spec_helper.rb diff --git a/Gemfile b/Gemfile index 6b365575..b34490ca 100644 --- a/Gemfile +++ b/Gemfile @@ -38,5 +38,6 @@ gem 'rubocop', :require => false # Middleman itself gem 'middleman-core', :path => 'middleman-core' gem 'middleman-cli', :path => 'middleman-cli' +gem 'middleman-templates', :path => 'middleman-templates' gem 'middleman-sprockets', :github => 'middleman/middleman-sprockets', :require => false gem 'middleman', :path => 'middleman' diff --git a/Rakefile b/Rakefile index b8b528e4..4c71d31e 100644 --- a/Rakefile +++ b/Rakefile @@ -7,7 +7,7 @@ require File.expand_path('../middleman-core/lib/middleman-core/version.rb', __FI ROOT = File.expand_path(File.dirname(__FILE__)) GEM_NAME = 'middleman' -middleman_gems = %w(middleman-core middleman-cli middleman) +middleman_gems = %w(middleman-core middleman-templates middleman-cli middleman) GEM_PATHS = middleman_gems.freeze def sh_rake(command) diff --git a/middleman-cli/lib/middleman-cli/init.rb b/middleman-cli/lib/middleman-cli/init.rb index 88af7797..0dab0b11 100644 --- a/middleman-cli/lib/middleman-cli/init.rb +++ b/middleman-cli/lib/middleman-cli/init.rb @@ -1,4 +1,4 @@ -require 'middleman-cli/templates' +require 'middleman-templates' # CLI Module module Middleman::Cli diff --git a/middleman-cli/lib/middleman-cli/templates.rb b/middleman-cli/lib/middleman-cli/templates.rb deleted file mode 100644 index c163a903..00000000 --- a/middleman-cli/lib/middleman-cli/templates.rb +++ /dev/null @@ -1,99 +0,0 @@ -# Use thor for template generation -require 'thor' -require 'thor/group' - -# Templates namespace -module Middleman::Templates - - # Static methods - class << self - - # Get list of registered templates and add new ones - # - # Middleman::Templates.register(:ext_name, klass) - # - # @param [Symbol] name The name of the template - # @param [Class] klass The class to be executed for this template - # @return [Hash] List of registered templates - def register(name=nil, klass=nil) - @_template_mappings ||= {} - @_template_mappings[name] = klass if name && klass - @_template_mappings - end - - # Middleman::Templates.register(name, klass) - alias :registered :register - end - - # Base Template class. Handles basic options and paths. - class Base < ::Thor::Group - include Thor::Actions - - def initialize(names, options) - super - source_paths << File.join(File.dirname(__FILE__), 'templates') - end - - # The gemfile template to use. Individual templates can define this class - # method to override the template path. - def self.gemfile_template - 'shared/Gemfile.tt' - end - - # Required path for the new project to be generated - argument :location, :type => :string - - # Name of the template being used to generate the project. - class_option :template, :default => 'default' - - # Output a config.ru file for Rack if --rack is passed - class_option :rack, :type => :boolean, :default => false - - # Write a Rack config.ru file for project - # @return [void] - def generate_rack! - return unless options[:rack] - template 'shared/config.ru', File.join(location, 'config.ru') - end - - class_option :'skip-bundle', :type => :boolean, :default => false - class_option :'skip-gemfile', :type => :boolean, :default => false - - # Write a Bundler Gemfile file for project - # @return [void] - def generate_bundler! - return if options[:'skip-gemfile'] - template self.class.gemfile_template, File.join(location, 'Gemfile') - - return if options[:'skip-bundle'] - inside(location) do - ::Middleman::Cli::Bundle.new.invoke(:bundle) - end unless ENV['TEST'] - end - - # Output a .gitignore file - class_option :'skip-git', :type => :boolean, :default => false - - # Write a .gitignore file for project - # @return [void] - def generate_gitignore! - return if options[:'skip-git'] - copy_file 'shared/gitignore', File.join(location, '.gitignore') - end - end -end - -# Default template -require 'middleman-cli/templates/default' - -# HTML5 template -require 'middleman-cli/templates/html5' - -# HTML5 Mobile template -require 'middleman-cli/templates/mobile' - -# Local templates -require 'middleman-cli/templates/local' - -# Barebones template -require 'middleman-cli/templates/empty' diff --git a/middleman-cli/lib/middleman-cli/templates/html5/source/js/vendor/jquery-1.8.0.min.js b/middleman-cli/lib/middleman-cli/templates/html5/source/js/vendor/jquery-1.8.0.min.js deleted file mode 100755 index 8156913a..00000000 --- a/middleman-cli/lib/middleman-cli/templates/html5/source/js/vendor/jquery-1.8.0.min.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! jQuery v@1.8.0 jquery.com | jquery.org/license */ -(function(a,b){function G(a){var b=F[a]={};return p.each(a.split(s),function(a,c){b[c]=!0}),b}function J(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(I,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:+d+""===d?+d:H.test(d)?p.parseJSON(d):d}catch(f){}p.data(a,c,d)}else d=b}return d}function K(a){var b;for(b in a){if(b==="data"&&p.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function ba(){return!1}function bb(){return!0}function bh(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function bi(a,b){do a=a[b];while(a&&a.nodeType!==1);return a}function bj(a,b,c){b=b||0;if(p.isFunction(b))return p.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return p.grep(a,function(a,d){return a===b===c});if(typeof b=="string"){var d=p.grep(a,function(a){return a.nodeType===1});if(be.test(b))return p.filter(b,d,!c);b=p.filter(b,d)}return p.grep(a,function(a,d){return p.inArray(a,b)>=0===c})}function bk(a){var b=bl.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}function bC(a,b){return a.getElementsByTagName(b)[0]||a.appendChild(a.ownerDocument.createElement(b))}function bD(a,b){if(b.nodeType!==1||!p.hasData(a))return;var c,d,e,f=p._data(a),g=p._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;d").appendTo(e.body),c=b.css("display");b.remove();if(c==="none"||c===""){bI=e.body.appendChild(bI||p.extend(e.createElement("iframe"),{frameBorder:0,width:0,height:0}));if(!bJ||!bI.createElement)bJ=(bI.contentWindow||bI.contentDocument).document,bJ.write(""),bJ.close();b=bJ.body.appendChild(bJ.createElement(a)),c=bH(b,"display"),e.body.removeChild(bI)}return bR[a]=c,c}function ch(a,b,c,d){var e;if(p.isArray(b))p.each(b,function(b,e){c||cd.test(a)?d(a,e):ch(a+"["+(typeof e=="object"?b:"")+"]",e,c,d)});else if(!c&&p.type(b)==="object")for(e in b)ch(a+"["+e+"]",b[e],c,d);else d(a,b)}function cy(a){return function(b,c){typeof b!="string"&&(c=b,b="*");var d,e,f,g=b.toLowerCase().split(s),h=0,i=g.length;if(p.isFunction(c))for(;h)[^>]*$|#([\w\-]*)$)/,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^[\],:{}\s]*$/,x=/(?:^|:|,)(?:\s*\[)+/g,y=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,z=/"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,A=/^-ms-/,B=/-([\da-z])/gi,C=function(a,b){return(b+"").toUpperCase()},D=function(){e.addEventListener?(e.removeEventListener("DOMContentLoaded",D,!1),p.ready()):e.readyState==="complete"&&(e.detachEvent("onreadystatechange",D),p.ready())},E={};p.fn=p.prototype={constructor:p,init:function(a,c,d){var f,g,h,i;if(!a)return this;if(a.nodeType)return this.context=this[0]=a,this.length=1,this;if(typeof a=="string"){a.charAt(0)==="<"&&a.charAt(a.length-1)===">"&&a.length>=3?f=[null,a,null]:f=u.exec(a);if(f&&(f[1]||!c)){if(f[1])return c=c instanceof p?c[0]:c,i=c&&c.nodeType?c.ownerDocument||c:e,a=p.parseHTML(f[1],i,!0),v.test(f[1])&&p.isPlainObject(c)&&this.attr.call(a,c,!0),p.merge(this,a);g=e.getElementById(f[2]);if(g&&g.parentNode){if(g.id!==f[2])return d.find(a);this.length=1,this[0]=g}return this.context=e,this.selector=a,this}return!c||c.jquery?(c||d).find(a):this.constructor(c).find(a)}return p.isFunction(a)?d.ready(a):(a.selector!==b&&(this.selector=a.selector,this.context=a.context),p.makeArray(a,this))},selector:"",jquery:"1.8.0",length:0,size:function(){return this.length},toArray:function(){return k.call(this)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=p.merge(this.constructor(),a);return d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")"),d},each:function(a,b){return p.each(this,a,b)},ready:function(a){return p.ready.promise().done(a),this},eq:function(a){return a=+a,a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(k.apply(this,arguments),"slice",k.call(arguments).join(","))},map:function(a){return this.pushStack(p.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:j,sort:[].sort,splice:[].splice},p.fn.init.prototype=p.fn,p.extend=p.fn.extend=function(){var a,c,d,e,f,g,h=arguments[0]||{},i=1,j=arguments.length,k=!1;typeof h=="boolean"&&(k=h,h=arguments[1]||{},i=2),typeof h!="object"&&!p.isFunction(h)&&(h={}),j===i&&(h=this,--i);for(;i0)return;d.resolveWith(e,[p]),p.fn.trigger&&p(e).trigger("ready").off("ready")},isFunction:function(a){return p.type(a)==="function"},isArray:Array.isArray||function(a){return p.type(a)==="array"},isWindow:function(a){return a!=null&&a==a.window},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):E[m.call(a)]||"object"},isPlainObject:function(a){if(!a||p.type(a)!=="object"||a.nodeType||p.isWindow(a))return!1;try{if(a.constructor&&!n.call(a,"constructor")&&!n.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||n.call(a,d)},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},error:function(a){throw new Error(a)},parseHTML:function(a,b,c){var d;return!a||typeof a!="string"?null:(typeof b=="boolean"&&(c=b,b=0),b=b||e,(d=v.exec(a))?[b.createElement(d[1])]:(d=p.buildFragment([a],b,c?null:[]),p.merge([],(d.cacheable?p.clone(d.fragment):d.fragment).childNodes)))},parseJSON:function(b){if(!b||typeof b!="string")return null;b=p.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(w.test(b.replace(y,"@").replace(z,"]").replace(x,"")))return(new Function("return "+b))();p.error("Invalid JSON: "+b)},parseXML:function(c){var d,e;if(!c||typeof c!="string")return null;try{a.DOMParser?(e=new DOMParser,d=e.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(f){d=b}return(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&p.error("Invalid XML: "+c),d},noop:function(){},globalEval:function(b){b&&r.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(A,"ms-").replace(B,C)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var e,f=0,g=a.length,h=g===b||p.isFunction(a);if(d){if(h){for(e in a)if(c.apply(a[e],d)===!1)break}else for(;f0&&a[0]&&a[i-1]||i===0||p.isArray(a));if(j)for(;h-1)i.splice(c,1),e&&(c<=g&&g--,c<=h&&h--)}),this},has:function(a){return p.inArray(a,i)>-1},empty:function(){return i=[],this},disable:function(){return i=j=c=b,this},disabled:function(){return!i},lock:function(){return j=b,c||l.disable(),this},locked:function(){return!j},fireWith:function(a,b){return b=b||[],b=[a,b.slice?b.slice():b],i&&(!d||j)&&(e?j.push(b):k(b)),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!d}};return l},p.extend({Deferred:function(a){var b=[["resolve","done",p.Callbacks("once memory"),"resolved"],["reject","fail",p.Callbacks("once memory"),"rejected"],["notify","progress",p.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return p.Deferred(function(c){p.each(b,function(b,d){var f=d[0],g=a[b];e[d[1]](p.isFunction(g)?function(){var a=g.apply(this,arguments);a&&p.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f+"With"](this===e?c:this,[a])}:c[f])}),a=null}).promise()},promise:function(a){return typeof a=="object"?p.extend(a,d):d}},e={};return d.pipe=d.then,p.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[a^1][2].disable,b[2][2].lock),e[f[0]]=g.fire,e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=k.call(arguments),d=c.length,e=d!==1||a&&p.isFunction(a.promise)?d:0,f=e===1?a:p.Deferred(),g=function(a,b,c){return function(d){b[a]=this,c[a]=arguments.length>1?k.call(arguments):d,c===h?f.notifyWith(b,c):--e||f.resolveWith(b,c)}},h,i,j;if(d>1){h=new Array(d),i=new Array(d),j=new Array(d);for(;b
a",c=n.getElementsByTagName("*"),d=n.getElementsByTagName("a")[0],d.style.cssText="top:1px;float:left;opacity:.5";if(!c||!c.length||!d)return{};f=e.createElement("select"),g=f.appendChild(e.createElement("option")),h=n.getElementsByTagName("input")[0],b={leadingWhitespace:n.firstChild.nodeType===3,tbody:!n.getElementsByTagName("tbody").length,htmlSerialize:!!n.getElementsByTagName("link").length,style:/top/.test(d.getAttribute("style")),hrefNormalized:d.getAttribute("href")==="/a",opacity:/^0.5/.test(d.style.opacity),cssFloat:!!d.style.cssFloat,checkOn:h.value==="on",optSelected:g.selected,getSetAttribute:n.className!=="t",enctype:!!e.createElement("form").enctype,html5Clone:e.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",boxModel:e.compatMode==="CSS1Compat",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},h.checked=!0,b.noCloneChecked=h.cloneNode(!0).checked,f.disabled=!0,b.optDisabled=!g.disabled;try{delete n.test}catch(o){b.deleteExpando=!1}!n.addEventListener&&n.attachEvent&&n.fireEvent&&(n.attachEvent("onclick",m=function(){b.noCloneEvent=!1}),n.cloneNode(!0).fireEvent("onclick"),n.detachEvent("onclick",m)),h=e.createElement("input"),h.value="t",h.setAttribute("type","radio"),b.radioValue=h.value==="t",h.setAttribute("checked","checked"),h.setAttribute("name","t"),n.appendChild(h),i=e.createDocumentFragment(),i.appendChild(n.lastChild),b.checkClone=i.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=h.checked,i.removeChild(h),i.appendChild(n);if(n.attachEvent)for(k in{submit:!0,change:!0,focusin:!0})j="on"+k,l=j in n,l||(n.setAttribute(j,"return;"),l=typeof n[j]=="function"),b[k+"Bubbles"]=l;return p(function(){var c,d,f,g,h="padding:0;margin:0;border:0;display:block;overflow:hidden;",i=e.getElementsByTagName("body")[0];if(!i)return;c=e.createElement("div"),c.style.cssText="visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px",i.insertBefore(c,i.firstChild),d=e.createElement("div"),c.appendChild(d),d.innerHTML="
t
",f=d.getElementsByTagName("td"),f[0].style.cssText="padding:0;margin:0;border:0;display:none",l=f[0].offsetHeight===0,f[0].style.display="",f[1].style.display="none",b.reliableHiddenOffsets=l&&f[0].offsetHeight===0,d.innerHTML="",d.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",b.boxSizing=d.offsetWidth===4,b.doesNotIncludeMarginInBodyOffset=i.offsetTop!==1,a.getComputedStyle&&(b.pixelPosition=(a.getComputedStyle(d,null)||{}).top!=="1%",b.boxSizingReliable=(a.getComputedStyle(d,null)||{width:"4px"}).width==="4px",g=e.createElement("div"),g.style.cssText=d.style.cssText=h,g.style.marginRight=g.style.width="0",d.style.width="1px",d.appendChild(g),b.reliableMarginRight=!parseFloat((a.getComputedStyle(g,null)||{}).marginRight)),typeof d.style.zoom!="undefined"&&(d.innerHTML="",d.style.cssText=h+"width:1px;padding:1px;display:inline;zoom:1",b.inlineBlockNeedsLayout=d.offsetWidth===3,d.style.display="block",d.style.overflow="visible",d.innerHTML="
",d.firstChild.style.width="5px",b.shrinkWrapBlocks=d.offsetWidth!==3,c.style.zoom=1),i.removeChild(c),c=d=f=g=null}),i.removeChild(n),c=d=f=g=h=i=n=null,b}();var H=/^(?:\{.*\}|\[.*\])$/,I=/([A-Z])/g;p.extend({cache:{},deletedIds:[],uuid:0,expando:"jQuery"+(p.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){return a=a.nodeType?p.cache[a[p.expando]]:a[p.expando],!!a&&!K(a)},data:function(a,c,d,e){if(!p.acceptData(a))return;var f,g,h=p.expando,i=typeof c=="string",j=a.nodeType,k=j?p.cache:a,l=j?a[h]:a[h]&&h;if((!l||!k[l]||!e&&!k[l].data)&&i&&d===b)return;l||(j?a[h]=l=p.deletedIds.pop()||++p.uuid:l=h),k[l]||(k[l]={},j||(k[l].toJSON=p.noop));if(typeof c=="object"||typeof c=="function")e?k[l]=p.extend(k[l],c):k[l].data=p.extend(k[l].data,c);return f=k[l],e||(f.data||(f.data={}),f=f.data),d!==b&&(f[p.camelCase(c)]=d),i?(g=f[c],g==null&&(g=f[p.camelCase(c)])):g=f,g},removeData:function(a,b,c){if(!p.acceptData(a))return;var d,e,f,g=a.nodeType,h=g?p.cache:a,i=g?a[p.expando]:p.expando;if(!h[i])return;if(b){d=c?h[i]:h[i].data;if(d){p.isArray(b)||(b in d?b=[b]:(b=p.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,f=b.length;e1,null,!1))},removeData:function(a){return this.each(function(){p.removeData(this,a)})}}),p.extend({queue:function(a,b,c){var d;if(a)return b=(b||"fx")+"queue",d=p._data(a,b),c&&(!d||p.isArray(c)?d=p._data(a,b,p.makeArray(c)):d.push(c)),d||[]},dequeue:function(a,b){b=b||"fx";var c=p.queue(a,b),d=c.shift(),e=p._queueHooks(a,b),f=function(){p.dequeue(a,b)};d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),delete e.stop,d.call(a,f,e)),!c.length&&e&&e.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return p._data(a,c)||p._data(a,c,{empty:p.Callbacks("once memory").add(function(){p.removeData(a,b+"queue",!0),p.removeData(a,c,!0)})})}}),p.fn.extend({queue:function(a,c){var d=2;return typeof a!="string"&&(c=a,a="fx",d--),arguments.length1)},removeAttr:function(a){return this.each(function(){p.removeAttr(this,a)})},prop:function(a,b){return p.access(this,p.prop,a,b,arguments.length>1)},removeProp:function(a){return a=p.propFix[a]||a,this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,f,g,h;if(p.isFunction(a))return this.each(function(b){p(this).addClass(a.call(this,b,this.className))});if(a&&typeof a=="string"){b=a.split(s);for(c=0,d=this.length;c-1)d=d.replace(" "+c[f]+" "," ");e.className=a?p.trim(d):""}}}return this},toggleClass:function(a,b){var c=typeof a,d=typeof b=="boolean";return p.isFunction(a)?this.each(function(c){p(this).toggleClass(a.call(this,c,this.className,b),b)}):this.each(function(){if(c==="string"){var e,f=0,g=p(this),h=b,i=a.split(s);while(e=i[f++])h=d?h:!g.hasClass(e),g[h?"addClass":"removeClass"](e)}else if(c==="undefined"||c==="boolean")this.className&&p._data(this,"__className__",this.className),this.className=this.className||a===!1?"":p._data(this,"__className__")||""})},hasClass:function(a){var b=" "+a+" ",c=0,d=this.length;for(;c-1)return!0;return!1},val:function(a){var c,d,e,f=this[0];if(!arguments.length){if(f)return c=p.valHooks[f.type]||p.valHooks[f.nodeName.toLowerCase()],c&&"get"in c&&(d=c.get(f,"value"))!==b?d:(d=f.value,typeof d=="string"?d.replace(P,""):d==null?"":d);return}return e=p.isFunction(a),this.each(function(d){var f,g=p(this);if(this.nodeType!==1)return;e?f=a.call(this,d,g.val()):f=a,f==null?f="":typeof f=="number"?f+="":p.isArray(f)&&(f=p.map(f,function(a){return a==null?"":a+""})),c=p.valHooks[this.type]||p.valHooks[this.nodeName.toLowerCase()];if(!c||!("set"in c)||c.set(this,f,"value")===b)this.value=f})}}),p.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,f=a.selectedIndex,g=[],h=a.options,i=a.type==="select-one";if(f<0)return null;c=i?f:0,d=i?f+1:h.length;for(;c=0}),c.length||(a.selectedIndex=-1),c}}},attrFn:{},attr:function(a,c,d,e){var f,g,h,i=a.nodeType;if(!a||i===3||i===8||i===2)return;if(e&&p.isFunction(p.fn[c]))return p(a)[c](d);if(typeof a.getAttribute=="undefined")return p.prop(a,c,d);h=i!==1||!p.isXMLDoc(a),h&&(c=c.toLowerCase(),g=p.attrHooks[c]||(T.test(c)?M:L));if(d!==b){if(d===null){p.removeAttr(a,c);return}return g&&"set"in g&&h&&(f=g.set(a,d,c))!==b?f:(a.setAttribute(c,""+d),d)}return g&&"get"in g&&h&&(f=g.get(a,c))!==null?f:(f=a.getAttribute(c),f===null?b:f)},removeAttr:function(a,b){var c,d,e,f,g=0;if(b&&a.nodeType===1){d=b.split(s);for(;g=0}})});var V=/^(?:textarea|input|select)$/i,W=/^([^\.]*|)(?:\.(.+)|)$/,X=/(?:^|\s)hover(\.\S+|)\b/,Y=/^key/,Z=/^(?:mouse|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=function(a){return p.event.special.hover?a:a.replace(X,"mouseenter$1 mouseleave$1")};p.event={add:function(a,c,d,e,f){var g,h,i,j,k,l,m,n,o,q,r;if(a.nodeType===3||a.nodeType===8||!c||!d||!(g=p._data(a)))return;d.handler&&(o=d,d=o.handler,f=o.selector),d.guid||(d.guid=p.guid++),i=g.events,i||(g.events=i={}),h=g.handle,h||(g.handle=h=function(a){return typeof p!="undefined"&&(!a||p.event.triggered!==a.type)?p.event.dispatch.apply(h.elem,arguments):b},h.elem=a),c=p.trim(_(c)).split(" ");for(j=0;j=0&&(s=s.slice(0,-1),i=!0),s.indexOf(".")>=0&&(t=s.split("."),s=t.shift(),t.sort());if((!f||p.event.customEvent[s])&&!p.event.global[s])return;c=typeof c=="object"?c[p.expando]?c:new p.Event(s,c):new p.Event(s),c.type=s,c.isTrigger=!0,c.exclusive=i,c.namespace=t.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+t.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,m=s.indexOf(":")<0?"on"+s:"";if(!f){h=p.cache;for(j in h)h[j].events&&h[j].events[s]&&p.event.trigger(c,d,h[j].handle.elem,!0);return}c.result=b,c.target||(c.target=f),d=d!=null?p.makeArray(d):[],d.unshift(c),n=p.event.special[s]||{};if(n.trigger&&n.trigger.apply(f,d)===!1)return;q=[[f,n.bindType||s]];if(!g&&!n.noBubble&&!p.isWindow(f)){r=n.delegateType||s,k=$.test(r+s)?f:f.parentNode;for(l=f;k;k=k.parentNode)q.push([k,r]),l=k;l===(f.ownerDocument||e)&&q.push([l.defaultView||l.parentWindow||a,r])}for(j=0;jq&&u.push({elem:this,matches:o.slice(q)});for(d=0;d0?this.on(b,null,a,c):this.trigger(b)},Y.test(b)&&(p.event.fixHooks[b]=p.event.keyHooks),Z.test(b)&&(p.event.fixHooks[b]=p.event.mouseHooks)}),function(a,b){function bd(a,b,c,d){var e=0,f=b.length;for(;e0?h(g,c,f):[]}function bf(a,c,d,e,f){var g,h,i,j,k,l,m,n,p=0,q=f.length,s=L.POS,t=new RegExp("^"+s.source+"(?!"+r+")","i"),u=function(){var a=1,c=arguments.length-2;for(;ai){m=a.slice(i,g.index),i=n,l=[c],B.test(m)&&(k&&(l=k),k=e);if(h=H.test(m))m=m.slice(0,-5).replace(B,"$&*");g.length>1&&g[0].replace(t,u),k=be(m,g[1],g[2],l,k,h)}}k?(j=j.concat(k),(m=a.slice(i))&&m!==")"?B.test(m)?bd(m,j,d,e):Z(m,c,d,e?e.concat(k):k):o.apply(d,j)):Z(a,c,d,e)}return q===1?d:Z.uniqueSort(d)}function bg(a,b,c){var d,e,f,g=[],i=0,j=D.exec(a),k=!j.pop()&&!j.pop(),l=k&&a.match(C)||[""],m=$.preFilter,n=$.filter,o=!c&&b!==h;for(;(e=l[i])!=null&&k;i++){g.push(d=[]),o&&(e=" "+e);while(e){k=!1;if(j=B.exec(e))e=e.slice(j[0].length),k=d.push({part:j.pop().replace(A," "),captures:j});for(f in n)(j=L[f].exec(e))&&(!m[f]||(j=m[f](j,b,c)))&&(e=e.slice(j.shift().length),k=d.push({part:f,captures:j}));if(!k)break}}return k||Z.error(a),g}function bh(a,b,e){var f=b.dir,g=m++;return a||(a=function(a){return a===e}),b.first?function(b,c){while(b=b[f])if(b.nodeType===1)return a(b,c)&&b}:function(b,e){var h,i=g+"."+d,j=i+"."+c;while(b=b[f])if(b.nodeType===1){if((h=b[q])===j)return b.sizset;if(typeof h=="string"&&h.indexOf(i)===0){if(b.sizset)return b}else{b[q]=j;if(a(b,e))return b.sizset=!0,b;b.sizset=!1}}}}function bi(a,b){return a?function(c,d){var e=b(c,d);return e&&a(e===!0?c:e,d)}:b}function bj(a,b,c){var d,e,f=0;for(;d=a[f];f++)$.relative[d.part]?e=bh(e,$.relative[d.part],b):(d.captures.push(b,c),e=bi(e,$.filter[d.part].apply(null,d.captures)));return e}function bk(a){return function(b,c){var d,e=0;for(;d=a[e];e++)if(d(b,c))return!0;return!1}}var c,d,e,f,g,h=a.document,i=h.documentElement,j="undefined",k=!1,l=!0,m=0,n=[].slice,o=[].push,q=("sizcache"+Math.random()).replace(".",""),r="[\\x20\\t\\r\\n\\f]",s="(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+",t=s.replace("w","w#"),u="([*^$|!~]?=)",v="\\["+r+"*("+s+")"+r+"*(?:"+u+r+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+t+")|)|)"+r+"*\\]",w=":("+s+")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|((?:[^,]|\\\\,|(?:,(?=[^\\[]*\\]))|(?:,(?=[^\\(]*\\))))*))\\)|)",x=":(nth|eq|gt|lt|first|last|even|odd)(?:\\((\\d*)\\)|)(?=[^-]|$)",y=r+"*([\\x20\\t\\r\\n\\f>+~])"+r+"*",z="(?=[^\\x20\\t\\r\\n\\f])(?:\\\\.|"+v+"|"+w.replace(2,7)+"|[^\\\\(),])+",A=new RegExp("^"+r+"+|((?:^|[^\\\\])(?:\\\\.)*)"+r+"+$","g"),B=new RegExp("^"+y),C=new RegExp(z+"?(?="+r+"*,|$)","g"),D=new RegExp("^(?:(?!,)(?:(?:^|,)"+r+"*"+z+")*?|"+r+"*(.*?))(\\)|$)"),E=new RegExp(z.slice(19,-6)+"\\x20\\t\\r\\n\\f>+~])+|"+y,"g"),F=/^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,G=/[\x20\t\r\n\f]*[+~]/,H=/:not\($/,I=/h\d/i,J=/input|select|textarea|button/i,K=/\\(?!\\)/g,L={ID:new RegExp("^#("+s+")"),CLASS:new RegExp("^\\.("+s+")"),NAME:new RegExp("^\\[name=['\"]?("+s+")['\"]?\\]"),TAG:new RegExp("^("+s.replace("[-","[-\\*")+")"),ATTR:new RegExp("^"+v),PSEUDO:new RegExp("^"+w),CHILD:new RegExp("^:(only|nth|last|first)-child(?:\\("+r+"*(even|odd|(([+-]|)(\\d*)n|)"+r+"*(?:([+-]|)"+r+"*(\\d+)|))"+r+"*\\)|)","i"),POS:new RegExp(x,"ig"),needsContext:new RegExp("^"+r+"*[>+~]|"+x,"i")},M={},N=[],O={},P=[],Q=function(a){return a.sizzleFilter=!0,a},R=function(a){return function(b){return b.nodeName.toLowerCase()==="input"&&b.type===a}},S=function(a){return function(b){var c=b.nodeName.toLowerCase();return(c==="input"||c==="button")&&b.type===a}},T=function(a){var b=!1,c=h.createElement("div");try{b=a(c)}catch(d){}return c=null,b},U=T(function(a){a.innerHTML="";var b=typeof a.lastChild.getAttribute("multiple");return b!=="boolean"&&b!=="string"}),V=T(function(a){a.id=q+0,a.innerHTML="
",i.insertBefore(a,i.firstChild);var b=h.getElementsByName&&h.getElementsByName(q).length===2+h.getElementsByName(q+0).length;return g=!h.getElementById(q),i.removeChild(a),b}),W=T(function(a){return a.appendChild(h.createComment("")),a.getElementsByTagName("*").length===0}),X=T(function(a){return a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!==j&&a.firstChild.getAttribute("href")==="#"}),Y=T(function(a){return a.innerHTML="",!a.getElementsByClassName||a.getElementsByClassName("e").length===0?!1:(a.lastChild.className="e",a.getElementsByClassName("e").length!==1)}),Z=function(a,b,c,d){c=c||[],b=b||h;var e,f,g,i,j=b.nodeType;if(j!==1&&j!==9)return[];if(!a||typeof a!="string")return c;g=ba(b);if(!g&&!d)if(e=F.exec(a))if(i=e[1]){if(j===9){f=b.getElementById(i);if(!f||!f.parentNode)return c;if(f.id===i)return c.push(f),c}else if(b.ownerDocument&&(f=b.ownerDocument.getElementById(i))&&bb(b,f)&&f.id===i)return c.push(f),c}else{if(e[2])return o.apply(c,n.call(b.getElementsByTagName(a),0)),c;if((i=e[3])&&Y&&b.getElementsByClassName)return o.apply(c,n.call(b.getElementsByClassName(i),0)),c}return bm(a,b,c,d,g)},$=Z.selectors={cacheLength:50,match:L,order:["ID","TAG"],attrHandle:{},createPseudo:Q,find:{ID:g?function(a,b,c){if(typeof b.getElementById!==j&&!c){var d=b.getElementById(a);return d&&d.parentNode?[d]:[]}}:function(a,c,d){if(typeof c.getElementById!==j&&!d){var e=c.getElementById(a);return e?e.id===a||typeof e.getAttributeNode!==j&&e.getAttributeNode("id").value===a?[e]:b:[]}},TAG:W?function(a,b){if(typeof b.getElementsByTagName!==j)return b.getElementsByTagName(a)}:function(a,b){var c=b.getElementsByTagName(a);if(a==="*"){var d,e=[],f=0;for(;d=c[f];f++)d.nodeType===1&&e.push(d);return e}return c}},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(K,""),a[3]=(a[4]||a[5]||"").replace(K,""),a[2]==="~="&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),a[1]==="nth"?(a[2]||Z.error(a[0]),a[3]=+(a[3]?a[4]+(a[5]||1):2*(a[2]==="even"||a[2]==="odd")),a[4]=+(a[6]+a[7]||a[2]==="odd")):a[2]&&Z.error(a[0]),a},PSEUDO:function(a){var b,c=a[4];return L.CHILD.test(a[0])?null:(c&&(b=D.exec(c))&&b.pop()&&(a[0]=a[0].slice(0,b[0].length-c.length-1),c=b[0].slice(0,-1)),a.splice(2,3,c||a[3]),a)}},filter:{ID:g?function(a){return a=a.replace(K,""),function(b){return b.getAttribute("id")===a}}:function(a){return a=a.replace(K,""),function(b){var c=typeof b.getAttributeNode!==j&&b.getAttributeNode("id");return c&&c.value===a}},TAG:function(a){return a==="*"?function(){return!0}:(a=a.replace(K,"").toLowerCase(),function(b){return b.nodeName&&b.nodeName.toLowerCase()===a})},CLASS:function(a){var b=M[a];return b||(b=M[a]=new RegExp("(^|"+r+")"+a+"("+r+"|$)"),N.push(a),N.length>$.cacheLength&&delete M[N.shift()]),function(a){return b.test(a.className||typeof a.getAttribute!==j&&a.getAttribute("class")||"")}},ATTR:function(a,b,c){return b?function(d){var e=Z.attr(d,a),f=e+"";if(e==null)return b==="!=";switch(b){case"=":return f===c;case"!=":return f!==c;case"^=":return c&&f.indexOf(c)===0;case"*=":return c&&f.indexOf(c)>-1;case"$=":return c&&f.substr(f.length-c.length)===c;case"~=":return(" "+f+" ").indexOf(c)>-1;case"|=":return f===c||f.substr(0,c.length+1)===c+"-"}}:function(b){return Z.attr(b,a)!=null}},CHILD:function(a,b,c,d){if(a==="nth"){var e=m++;return function(a){var b,f,g=0,h=a;if(c===1&&d===0)return!0;b=a.parentNode;if(b&&(b[q]!==e||!a.sizset)){for(h=b.firstChild;h;h=h.nextSibling)if(h.nodeType===1){h.sizset=++g;if(h===a)break}b[q]=e}return f=a.sizset-d,c===0?f===0:f%c===0&&f/c>=0}}return function(b){var c=b;switch(a){case"only":case"first":while(c=c.previousSibling)if(c.nodeType===1)return!1;if(a==="first")return!0;c=b;case"last":while(c=c.nextSibling)if(c.nodeType===1)return!1;return!0}}},PSEUDO:function(a,b,c,d){var e=$.pseudos[a]||$.pseudos[a.toLowerCase()];return e||Z.error("unsupported pseudo: "+a),e.sizzleFilter?e(b,c,d):e}},pseudos:{not:Q(function(a,b,c){var d=bl(a.replace(A,"$1"),b,c);return function(a){return!d(a)}}),enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&!!a.checked||b==="option"&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},parent:function(a){return!$.pseudos.empty(a)},empty:function(a){var b;a=a.firstChild;while(a){if(a.nodeName>"@"||(b=a.nodeType)===3||b===4)return!1;a=a.nextSibling}return!0},contains:Q(function(a){return function(b){return(b.textContent||b.innerText||bc(b)).indexOf(a)>-1}}),has:Q(function(a){return function(b){return Z(a,b).length>0}}),header:function(a){return I.test(a.nodeName)},text:function(a){var b,c;return a.nodeName.toLowerCase()==="input"&&(b=a.type)==="text"&&((c=a.getAttribute("type"))==null||c.toLowerCase()===b)},radio:R("radio"),checkbox:R("checkbox"),file:R("file"),password:R("password"),image:R("image"),submit:S("submit"),reset:S("reset"),button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&a.type==="button"||b==="button"},input:function(a){return J.test(a.nodeName)},focus:function(a){var b=a.ownerDocument;return a===b.activeElement&&(!b.hasFocus||b.hasFocus())&&(!!a.type||!!a.href)},active:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b,c){return c?a.slice(1):[a[0]]},last:function(a,b,c){var d=a.pop();return c?a:[d]},even:function(a,b,c){var d=[],e=c?1:0,f=a.length;for(;e$.cacheLength&&delete O[P.shift()],g};Z.matches=function(a,b){return Z(a,null,null,b)},Z.matchesSelector=function(a,b){return Z(b,null,null,[a]).length>0};var bm=function(a,b,e,f,g){a=a.replace(A,"$1");var h,i,j,k,l,m,p,q,r,s=a.match(C),t=a.match(E),u=b.nodeType;if(L.POS.test(a))return bf(a,b,e,f,s);if(f)h=n.call(f,0);else if(s&&s.length===1){if(t.length>1&&u===9&&!g&&(s=L.ID.exec(t[0]))){b=$.find.ID(s[1],b,g)[0];if(!b)return e;a=a.slice(t.shift().length)}q=(s=G.exec(t[0]))&&!s.index&&b.parentNode||b,r=t.pop(),m=r.split(":not")[0];for(j=0,k=$.order.length;j",a.querySelectorAll("[selected]").length||e.push("\\["+r+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),a.querySelectorAll(":checked").length||e.push(":checked")}),T(function(a){a.innerHTML="

",a.querySelectorAll("[test^='']").length&&e.push("[*^$]="+r+"*(?:\"\"|'')"),a.innerHTML="",a.querySelectorAll(":enabled").length||e.push(":enabled",":disabled")}),e=e.length&&new RegExp(e.join("|")),bm=function(a,d,f,g,h){if(!g&&!h&&(!e||!e.test(a)))if(d.nodeType===9)try{return o.apply(f,n.call(d.querySelectorAll(a),0)),f}catch(i){}else if(d.nodeType===1&&d.nodeName.toLowerCase()!=="object"){var j=d.getAttribute("id"),k=j||q,l=G.test(a)&&d.parentNode||d;j?k=k.replace(c,"\\$&"):d.setAttribute("id",k);try{return o.apply(f,n.call(l.querySelectorAll(a.replace(C,"[id='"+k+"'] $&")),0)),f}catch(i){}finally{j||d.removeAttribute("id")}}return b(a,d,f,g,h)},g&&(T(function(b){a=g.call(b,"div");try{g.call(b,"[test!='']:sizzle"),f.push($.match.PSEUDO)}catch(c){}}),f=new RegExp(f.join("|")),Z.matchesSelector=function(b,c){c=c.replace(d,"='$1']");if(!ba(b)&&!f.test(c)&&(!e||!e.test(c)))try{var h=g.call(b,c);if(h||a||b.document&&b.document.nodeType!==11)return h}catch(i){}return Z(c,null,null,[b]).length>0})}(),Z.attr=p.attr,p.find=Z,p.expr=Z.selectors,p.expr[":"]=p.expr.pseudos,p.unique=Z.uniqueSort,p.text=Z.getText,p.isXMLDoc=Z.isXML,p.contains=Z.contains}(a);var bc=/Until$/,bd=/^(?:parents|prev(?:Until|All))/,be=/^.[^:#\[\.,]*$/,bf=p.expr.match.needsContext,bg={children:!0,contents:!0,next:!0,prev:!0};p.fn.extend({find:function(a){var b,c,d,e,f,g,h=this;if(typeof a!="string")return p(a).filter(function(){for(b=0,c=h.length;b0)for(e=d;e=0:p.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c,d=0,e=this.length,f=[],g=bf.test(a)||typeof a!="string"?p(a,b||this.context):0;for(;d-1:p.find.matchesSelector(c,a)){f.push(c);break}c=c.parentNode}}return f=f.length>1?p.unique(f):f,this.pushStack(f,"closest",a)},index:function(a){return a?typeof a=="string"?p.inArray(this[0],p(a)):p.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.prevAll().length:-1},add:function(a,b){var c=typeof a=="string"?p(a,b):p.makeArray(a&&a.nodeType?[a]:a),d=p.merge(this.get(),c);return this.pushStack(bh(c[0])||bh(d[0])?d:p.unique(d))},addBack:function(a){return this.add(a==null?this.prevObject:this.prevObject.filter(a))}}),p.fn.andSelf=p.fn.addBack,p.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return p.dir(a,"parentNode")},parentsUntil:function(a,b,c){return p.dir(a,"parentNode",c)},next:function(a){return bi(a,"nextSibling")},prev:function(a){return bi(a,"previousSibling")},nextAll:function(a){return p.dir(a,"nextSibling")},prevAll:function(a){return p.dir(a,"previousSibling")},nextUntil:function(a,b,c){return p.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return p.dir(a,"previousSibling",c)},siblings:function(a){return p.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return p.sibling(a.firstChild)},contents:function(a){return p.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:p.merge([],a.childNodes)}},function(a,b){p.fn[a]=function(c,d){var e=p.map(this,b,c);return bc.test(a)||(d=c),d&&typeof d=="string"&&(e=p.filter(d,e)),e=this.length>1&&!bg[a]?p.unique(e):e,this.length>1&&bd.test(a)&&(e=e.reverse()),this.pushStack(e,a,k.call(arguments).join(","))}}),p.extend({filter:function(a,b,c){return c&&(a=":not("+a+")"),b.length===1?p.find.matchesSelector(b[0],a)?[b[0]]:[]:p.find.matches(a,b)},dir:function(a,c,d){var e=[],f=a[c];while(f&&f.nodeType!==9&&(d===b||f.nodeType!==1||!p(f).is(d)))f.nodeType===1&&e.push(f),f=f[c];return e},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var bl="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",bm=/ jQuery\d+="(?:null|\d+)"/g,bn=/^\s+/,bo=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bp=/<([\w:]+)/,bq=/]","i"),bv=/^(?:checkbox|radio)$/,bw=/checked\s*(?:[^=]|=\s*.checked.)/i,bx=/\/(java|ecma)script/i,by=/^\s*\s*$/g,bz={option:[1,""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]},bA=bk(e),bB=bA.appendChild(e.createElement("div"));bz.optgroup=bz.option,bz.tbody=bz.tfoot=bz.colgroup=bz.caption=bz.thead,bz.th=bz.td,p.support.htmlSerialize||(bz._default=[1,"X
","
"]),p.fn.extend({text:function(a){return p.access(this,function(a){return a===b?p.text(this):this.empty().append((this[0]&&this[0].ownerDocument||e).createTextNode(a))},null,a,arguments.length)},wrapAll:function(a){if(p.isFunction(a))return this.each(function(b){p(this).wrapAll(a.call(this,b))});if(this[0]){var b=p(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){return p.isFunction(a)?this.each(function(b){p(this).wrapInner(a.call(this,b))}):this.each(function(){var b=p(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=p.isFunction(a);return this.each(function(c){p(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){p.nodeName(this,"body")||p(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){(this.nodeType===1||this.nodeType===11)&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){(this.nodeType===1||this.nodeType===11)&&this.insertBefore(a,this.firstChild)})},before:function(){if(!bh(this[0]))return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=p.clean(arguments);return this.pushStack(p.merge(a,this),"before",this.selector)}},after:function(){if(!bh(this[0]))return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=p.clean(arguments);return this.pushStack(p.merge(this,a),"after",this.selector)}},remove:function(a,b){var c,d=0;for(;(c=this[d])!=null;d++)if(!a||p.filter(a,[c]).length)!b&&c.nodeType===1&&(p.cleanData(c.getElementsByTagName("*")),p.cleanData([c])),c.parentNode&&c.parentNode.removeChild(c);return this},empty:function(){var a,b=0;for(;(a=this[b])!=null;b++){a.nodeType===1&&p.cleanData(a.getElementsByTagName("*"));while(a.firstChild)a.removeChild(a.firstChild)}return this},clone:function(a,b){return a=a==null?!1:a,b=b==null?a:b,this.map(function(){return p.clone(this,a,b)})},html:function(a){return p.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return c.nodeType===1?c.innerHTML.replace(bm,""):b;if(typeof a=="string"&&!bs.test(a)&&(p.support.htmlSerialize||!bu.test(a))&&(p.support.leadingWhitespace||!bn.test(a))&&!bz[(bp.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(bo,"<$1>");try{for(;d1&&typeof j=="string"&&bw.test(j))return this.each(function(){p(this).domManip(a,c,d)});if(p.isFunction(j))return this.each(function(e){var f=p(this);a[0]=j.call(this,e,c?f.html():b),f.domManip(a,c,d)});if(this[0]){e=p.buildFragment(a,this,k),g=e.fragment,f=g.firstChild,g.childNodes.length===1&&(g=f);if(f){c=c&&p.nodeName(f,"tr");for(h=e.cacheable||l-1;i0?this.clone(!0):this).get(),p(g[e])[b](d),f=f.concat(d);return this.pushStack(f,a,g.selector)}}),p.extend({clone:function(a,b,c){var d,e,f,g;p.support.html5Clone||p.isXMLDoc(a)||!bu.test("<"+a.nodeName+">")?g=a.cloneNode(!0):(bB.innerHTML=a.outerHTML,bB.removeChild(g=bB.firstChild));if((!p.support.noCloneEvent||!p.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!p.isXMLDoc(a)){bE(a,g),d=bF(a),e=bF(g);for(f=0;d[f];++f)e[f]&&bE(d[f],e[f])}if(b){bD(a,g);if(c){d=bF(a),e=bF(g);for(f=0;d[f];++f)bD(d[f],e[f])}}return d=e=null,g},clean:function(a,b,c,d){var f,g,h,i,j,k,l,m,n,o,q,r,s=0,t=[];if(!b||typeof b.createDocumentFragment=="undefined")b=e;for(g=b===e&&bA;(h=a[s])!=null;s++){typeof h=="number"&&(h+="");if(!h)continue;if(typeof h=="string")if(!br.test(h))h=b.createTextNode(h);else{g=g||bk(b),l=l||g.appendChild(b.createElement("div")),h=h.replace(bo,"<$1>"),i=(bp.exec(h)||["",""])[1].toLowerCase(),j=bz[i]||bz._default,k=j[0],l.innerHTML=j[1]+h+j[2];while(k--)l=l.lastChild;if(!p.support.tbody){m=bq.test(h),n=i==="table"&&!m?l.firstChild&&l.firstChild.childNodes:j[1]===""&&!m?l.childNodes:[];for(f=n.length-1;f>=0;--f)p.nodeName(n[f],"tbody")&&!n[f].childNodes.length&&n[f].parentNode.removeChild(n[f])}!p.support.leadingWhitespace&&bn.test(h)&&l.insertBefore(b.createTextNode(bn.exec(h)[0]),l.firstChild),h=l.childNodes,l=g.lastChild}h.nodeType?t.push(h):t=p.merge(t,h)}l&&(g.removeChild(l),h=l=g=null);if(!p.support.appendChecked)for(s=0;(h=t[s])!=null;s++)p.nodeName(h,"input")?bG(h):typeof h.getElementsByTagName!="undefined"&&p.grep(h.getElementsByTagName("input"),bG);if(c){q=function(a){if(!a.type||bx.test(a.type))return d?d.push(a.parentNode?a.parentNode.removeChild(a):a):c.appendChild(a)};for(s=0;(h=t[s])!=null;s++)if(!p.nodeName(h,"script")||!q(h))c.appendChild(h),typeof h.getElementsByTagName!="undefined"&&(r=p.grep(p.merge([],h.getElementsByTagName("script")),q),t.splice.apply(t,[s+1,0].concat(r)),s+=r.length)}return t},cleanData:function(a,b){var c,d,e,f,g=0,h=p.expando,i=p.cache,j=p.support.deleteExpando,k=p.event.special;for(;(e=a[g])!=null;g++)if(b||p.acceptData(e)){d=e[h],c=d&&i[d];if(c){if(c.events)for(f in c.events)k[f]?p.event.remove(e,f):p.removeEvent(e,f,c.handle);i[d]&&(delete i[d],j?delete e[h]:e.removeAttribute?e.removeAttribute(h):e[h]=null,p.deletedIds.push(d))}}}}),function(){var a,b;p.uaMatch=function(a){a=a.toLowerCase();var b=/(chrome)[ \/]([\w.]+)/.exec(a)||/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||a.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},a=p.uaMatch(g.userAgent),b={},a.browser&&(b[a.browser]=!0,b.version=a.version),b.webkit&&(b.safari=!0),p.browser=b,p.sub=function(){function a(b,c){return new a.fn.init(b,c)}p.extend(!0,a,this),a.superclass=this,a.fn=a.prototype=this(),a.fn.constructor=a,a.sub=this.sub,a.fn.init=function c(c,d){return d&&d instanceof p&&!(d instanceof a)&&(d=a(d)),p.fn.init.call(this,c,d,b)},a.fn.init.prototype=a.fn;var b=a(e);return a}}();var bH,bI,bJ,bK=/alpha\([^)]*\)/i,bL=/opacity=([^)]*)/,bM=/^(top|right|bottom|left)$/,bN=/^margin/,bO=new RegExp("^("+q+")(.*)$","i"),bP=new RegExp("^("+q+")(?!px)[a-z%]+$","i"),bQ=new RegExp("^([-+])=("+q+")","i"),bR={},bS={position:"absolute",visibility:"hidden",display:"block"},bT={letterSpacing:0,fontWeight:400,lineHeight:1},bU=["Top","Right","Bottom","Left"],bV=["Webkit","O","Moz","ms"],bW=p.fn.toggle;p.fn.extend({css:function(a,c){return p.access(this,function(a,c,d){return d!==b?p.style(a,c,d):p.css(a,c)},a,c,arguments.length>1)},show:function(){return bZ(this,!0)},hide:function(){return bZ(this)},toggle:function(a,b){var c=typeof a=="boolean";return p.isFunction(a)&&p.isFunction(b)?bW.apply(this,arguments):this.each(function(){(c?a:bY(this))?p(this).show():p(this).hide()})}}),p.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=bH(a,"opacity");return c===""?"1":c}}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":p.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!a||a.nodeType===3||a.nodeType===8||!a.style)return;var f,g,h,i=p.camelCase(c),j=a.style;c=p.cssProps[i]||(p.cssProps[i]=bX(j,i)),h=p.cssHooks[c]||p.cssHooks[i];if(d===b)return h&&"get"in h&&(f=h.get(a,!1,e))!==b?f:j[c];g=typeof d,g==="string"&&(f=bQ.exec(d))&&(d=(f[1]+1)*f[2]+parseFloat(p.css(a,c)),g="number");if(d==null||g==="number"&&isNaN(d))return;g==="number"&&!p.cssNumber[i]&&(d+="px");if(!h||!("set"in h)||(d=h.set(a,d,e))!==b)try{j[c]=d}catch(k){}},css:function(a,c,d,e){var f,g,h,i=p.camelCase(c);return c=p.cssProps[i]||(p.cssProps[i]=bX(a.style,i)),h=p.cssHooks[c]||p.cssHooks[i],h&&"get"in h&&(f=h.get(a,!0,e)),f===b&&(f=bH(a,c)),f==="normal"&&c in bT&&(f=bT[c]),d||e!==b?(g=parseFloat(f),d||p.isNumeric(g)?g||0:f):f},swap:function(a,b,c){var d,e,f={};for(e in b)f[e]=a.style[e],a.style[e]=b[e];d=c.call(a);for(e in b)a.style[e]=f[e];return d}}),a.getComputedStyle?bH=function(a,b){var c,d,e,f,g=getComputedStyle(a,null),h=a.style;return g&&(c=g[b],c===""&&!p.contains(a.ownerDocument.documentElement,a)&&(c=p.style(a,b)),bP.test(c)&&bN.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=c,c=g.width,h.width=d,h.minWidth=e,h.maxWidth=f)),c}:e.documentElement.currentStyle&&(bH=function(a,b){var c,d,e=a.currentStyle&&a.currentStyle[b],f=a.style;return e==null&&f&&f[b]&&(e=f[b]),bP.test(e)&&!bM.test(b)&&(c=f.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":e,e=f.pixelLeft+"px",f.left=c,d&&(a.runtimeStyle.left=d)),e===""?"auto":e}),p.each(["height","width"],function(a,b){p.cssHooks[b]={get:function(a,c,d){if(c)return a.offsetWidth!==0||bH(a,"display")!=="none"?ca(a,b,d):p.swap(a,bS,function(){return ca(a,b,d)})},set:function(a,c,d){return b$(a,c,d?b_(a,b,d,p.support.boxSizing&&p.css(a,"boxSizing")==="border-box"):0)}}}),p.support.opacity||(p.cssHooks.opacity={get:function(a,b){return bL.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=p.isNumeric(b)?"alpha(opacity="+b*100+")":"",f=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&p.trim(f.replace(bK,""))===""&&c.removeAttribute){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bK.test(f)?f.replace(bK,e):f+" "+e}}),p(function(){p.support.reliableMarginRight||(p.cssHooks.marginRight={get:function(a,b){return p.swap(a,{display:"inline-block"},function(){if(b)return bH(a,"marginRight")})}}),!p.support.pixelPosition&&p.fn.position&&p.each(["top","left"],function(a,b){p.cssHooks[b]={get:function(a,c){if(c){var d=bH(a,b);return bP.test(d)?p(a).position()[b]+"px":d}}}})}),p.expr&&p.expr.filters&&(p.expr.filters.hidden=function(a){return a.offsetWidth===0&&a.offsetHeight===0||!p.support.reliableHiddenOffsets&&(a.style&&a.style.display||bH(a,"display"))==="none"},p.expr.filters.visible=function(a){return!p.expr.filters.hidden(a)}),p.each({margin:"",padding:"",border:"Width"},function(a,b){p.cssHooks[a+b]={expand:function(c){var d,e=typeof c=="string"?c.split(" "):[c],f={};for(d=0;d<4;d++)f[a+bU[d]+b]=e[d]||e[d-2]||e[0];return f}},bN.test(a)||(p.cssHooks[a+b].set=b$)});var cc=/%20/g,cd=/\[\]$/,ce=/\r?\n/g,cf=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,cg=/^(?:select|textarea)/i;p.fn.extend({serialize:function(){return p.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?p.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||cg.test(this.nodeName)||cf.test(this.type))}).map(function(a,b){var c=p(this).val();return c==null?null:p.isArray(c)?p.map(c,function(a,c){return{name:b.name,value:a.replace(ce,"\r\n")}}):{name:b.name,value:c.replace(ce,"\r\n")}}).get()}}),p.param=function(a,c){var d,e=[],f=function(a,b){b=p.isFunction(b)?b():b==null?"":b,e[e.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=p.ajaxSettings&&p.ajaxSettings.traditional);if(p.isArray(a)||a.jquery&&!p.isPlainObject(a))p.each(a,function(){f(this.name,this.value)});else for(d in a)ch(d,a[d],c,f);return e.join("&").replace(cc,"+")};var ci,cj,ck=/#.*$/,cl=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,cm=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,cn=/^(?:GET|HEAD)$/,co=/^\/\//,cp=/\?/,cq=/)<[^<]*)*<\/script>/gi,cr=/([?&])_=[^&]*/,cs=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,ct=p.fn.load,cu={},cv={},cw=["*/"]+["*"];try{ci=f.href}catch(cx){ci=e.createElement("a"),ci.href="",ci=ci.href}cj=cs.exec(ci.toLowerCase())||[],p.fn.load=function(a,c,d){if(typeof a!="string"&&ct)return ct.apply(this,arguments);if(!this.length)return this;var e,f,g,h=this,i=a.indexOf(" ");return i>=0&&(e=a.slice(i,a.length),a=a.slice(0,i)),p.isFunction(c)?(d=c,c=b):typeof c=="object"&&(f="POST"),p.ajax({url:a,type:f,dataType:"html",data:c,complete:function(a,b){d&&h.each(d,g||[a.responseText,b,a])}}).done(function(a){g=arguments,h.html(e?p("
").append(a.replace(cq,"")).find(e):a)}),this},p.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){p.fn[b]=function(a){return this.on(b,a)}}),p.each(["get","post"],function(a,c){p[c]=function(a,d,e,f){return p.isFunction(d)&&(f=f||e,e=d,d=b),p.ajax({type:c,url:a,data:d,success:e,dataType:f})}}),p.extend({getScript:function(a,c){return p.get(a,b,c,"script")},getJSON:function(a,b,c){return p.get(a,b,c,"json")},ajaxSetup:function(a,b){return b?cA(a,p.ajaxSettings):(b=a,a=p.ajaxSettings),cA(a,b),a},ajaxSettings:{url:ci,isLocal:cm.test(cj[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":cw},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":p.parseJSON,"text xml":p.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:cy(cu),ajaxTransport:cy(cv),ajax:function(a,c){function y(a,c,f,i){var k,s,t,u,w,y=c;if(v===2)return;v=2,h&&clearTimeout(h),g=b,e=i||"",x.readyState=a>0?4:0,f&&(u=cB(l,x,f));if(a>=200&&a<300||a===304)l.ifModified&&(w=x.getResponseHeader("Last-Modified"),w&&(p.lastModified[d]=w),w=x.getResponseHeader("Etag"),w&&(p.etag[d]=w)),a===304?(y="notmodified",k=!0):(k=cC(l,u),y=k.state,s=k.data,t=k.error,k=!t);else{t=y;if(!y||a)y="error",a<0&&(a=0)}x.status=a,x.statusText=""+(c||y),k?o.resolveWith(m,[s,y,x]):o.rejectWith(m,[x,y,t]),x.statusCode(r),r=b,j&&n.trigger("ajax"+(k?"Success":"Error"),[x,l,k?s:t]),q.fireWith(m,[x,y]),j&&(n.trigger("ajaxComplete",[x,l]),--p.active||p.event.trigger("ajaxStop"))}typeof a=="object"&&(c=a,a=b),c=c||{};var d,e,f,g,h,i,j,k,l=p.ajaxSetup({},c),m=l.context||l,n=m!==l&&(m.nodeType||m instanceof p)?p(m):p.event,o=p.Deferred(),q=p.Callbacks("once memory"),r=l.statusCode||{},t={},u={},v=0,w="canceled",x={readyState:0,setRequestHeader:function(a,b){if(!v){var c=a.toLowerCase();a=u[c]=u[c]||a,t[a]=b}return this},getAllResponseHeaders:function(){return v===2?e:null},getResponseHeader:function(a){var c;if(v===2){if(!f){f={};while(c=cl.exec(e))f[c[1].toLowerCase()]=c[2]}c=f[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){return v||(l.mimeType=a),this},abort:function(a){return a=a||w,g&&g.abort(a),y(0,a),this}};o.promise(x),x.success=x.done,x.error=x.fail,x.complete=q.add,x.statusCode=function(a){if(a){var b;if(v<2)for(b in a)r[b]=[r[b],a[b]];else b=a[x.status],x.always(b)}return this},l.url=((a||l.url)+"").replace(ck,"").replace(co,cj[1]+"//"),l.dataTypes=p.trim(l.dataType||"*").toLowerCase().split(s),l.crossDomain==null&&(i=cs.exec(l.url.toLowerCase()),l.crossDomain=!(!i||i[1]==cj[1]&&i[2]==cj[2]&&(i[3]||(i[1]==="http:"?80:443))==(cj[3]||(cj[1]==="http:"?80:443)))),l.data&&l.processData&&typeof l.data!="string"&&(l.data=p.param(l.data,l.traditional)),cz(cu,l,c,x);if(v===2)return x;j=l.global,l.type=l.type.toUpperCase(),l.hasContent=!cn.test(l.type),j&&p.active++===0&&p.event.trigger("ajaxStart");if(!l.hasContent){l.data&&(l.url+=(cp.test(l.url)?"&":"?")+l.data,delete l.data),d=l.url;if(l.cache===!1){var z=p.now(),A=l.url.replace(cr,"$1_="+z);l.url=A+(A===l.url?(cp.test(l.url)?"&":"?")+"_="+z:"")}}(l.data&&l.hasContent&&l.contentType!==!1||c.contentType)&&x.setRequestHeader("Content-Type",l.contentType),l.ifModified&&(d=d||l.url,p.lastModified[d]&&x.setRequestHeader("If-Modified-Since",p.lastModified[d]),p.etag[d]&&x.setRequestHeader("If-None-Match",p.etag[d])),x.setRequestHeader("Accept",l.dataTypes[0]&&l.accepts[l.dataTypes[0]]?l.accepts[l.dataTypes[0]]+(l.dataTypes[0]!=="*"?", "+cw+"; q=0.01":""):l.accepts["*"]);for(k in l.headers)x.setRequestHeader(k,l.headers[k]);if(!l.beforeSend||l.beforeSend.call(m,x,l)!==!1&&v!==2){w="abort";for(k in{success:1,error:1,complete:1})x[k](l[k]);g=cz(cv,l,c,x);if(!g)y(-1,"No Transport");else{x.readyState=1,j&&n.trigger("ajaxSend",[x,l]),l.async&&l.timeout>0&&(h=setTimeout(function(){x.abort("timeout")},l.timeout));try{v=1,g.send(t,y)}catch(B){if(v<2)y(-1,B);else throw B}}return x}return x.abort()},active:0,lastModified:{},etag:{}});var cD=[],cE=/\?/,cF=/(=)\?(?=&|$)|\?\?/,cG=p.now();p.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=cD.pop()||p.expando+"_"+cG++;return this[a]=!0,a}}),p.ajaxPrefilter("json jsonp",function(c,d,e){var f,g,h,i=c.data,j=c.url,k=c.jsonp!==!1,l=k&&cF.test(j),m=k&&!l&&typeof i=="string"&&!(c.contentType||"").indexOf("application/x-www-form-urlencoded")&&cF.test(i);if(c.dataTypes[0]==="jsonp"||l||m)return f=c.jsonpCallback=p.isFunction(c.jsonpCallback)?c.jsonpCallback():c.jsonpCallback,g=a[f],l?c.url=j.replace(cF,"$1"+f):m?c.data=i.replace(cF,"$1"+f):k&&(c.url+=(cE.test(j)?"&":"?")+c.jsonp+"="+f),c.converters["script json"]=function(){return h||p.error(f+" was not called"),h[0]},c.dataTypes[0]="json",a[f]=function(){h=arguments},e.always(function(){a[f]=g,c[f]&&(c.jsonpCallback=d.jsonpCallback,cD.push(f)),h&&p.isFunction(g)&&g(h[0]),h=g=b}),"script"}),p.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){return p.globalEval(a),a}}}),p.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),p.ajaxTransport("script",function(a){if(a.crossDomain){var c,d=e.head||e.getElementsByTagName("head")[0]||e.documentElement;return{send:function(f,g){c=e.createElement("script"),c.async="async",a.scriptCharset&&(c.charset=a.scriptCharset),c.src=a.url,c.onload=c.onreadystatechange=function(a,e){if(e||!c.readyState||/loaded|complete/.test(c.readyState))c.onload=c.onreadystatechange=null,d&&c.parentNode&&d.removeChild(c),c=b,e||g(200,"success")},d.insertBefore(c,d.firstChild)},abort:function(){c&&c.onload(0,1)}}}});var cH,cI=a.ActiveXObject?function(){for(var a in cH)cH[a](0,1)}:!1,cJ=0;p.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&cK()||cL()}:cK,function(a){p.extend(p.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(p.ajaxSettings.xhr()),p.support.ajax&&p.ajaxTransport(function(c){if(!c.crossDomain||p.support.cors){var d;return{send:function(e,f){var g,h,i=c.xhr();c.username?i.open(c.type,c.url,c.async,c.username,c.password):i.open(c.type,c.url,c.async);if(c.xhrFields)for(h in c.xhrFields)i[h]=c.xhrFields[h];c.mimeType&&i.overrideMimeType&&i.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(h in e)i.setRequestHeader(h,e[h])}catch(j){}i.send(c.hasContent&&c.data||null),d=function(a,e){var h,j,k,l,m;try{if(d&&(e||i.readyState===4)){d=b,g&&(i.onreadystatechange=p.noop,cI&&delete cH[g]);if(e)i.readyState!==4&&i.abort();else{h=i.status,k=i.getAllResponseHeaders(),l={},m=i.responseXML,m&&m.documentElement&&(l.xml=m);try{l.text=i.responseText}catch(a){}try{j=i.statusText}catch(n){j=""}!h&&c.isLocal&&!c.crossDomain?h=l.text?200:404:h===1223&&(h=204)}}}catch(o){e||f(-1,o)}l&&f(h,j,l,k)},c.async?i.readyState===4?setTimeout(d,0):(g=++cJ,cI&&(cH||(cH={},p(a).unload(cI)),cH[g]=d),i.onreadystatechange=d):d()},abort:function(){d&&d(0,1)}}}});var cM,cN,cO=/^(?:toggle|show|hide)$/,cP=new RegExp("^(?:([-+])=|)("+q+")([a-z%]*)$","i"),cQ=/queueHooks$/,cR=[cX],cS={"*":[function(a,b){var c,d,e,f=this.createTween(a,b),g=cP.exec(b),h=f.cur(),i=+h||0,j=1;if(g){c=+g[2],d=g[3]||(p.cssNumber[a]?"":"px");if(d!=="px"&&i){i=p.css(f.elem,a,!0)||c||1;do e=j=j||".5",i=i/j,p.style(f.elem,a,i+d),j=f.cur()/h;while(j!==1&&j!==e)}f.unit=d,f.start=i,f.end=g[1]?i+(g[1]+1)*c:c}return f}]};p.Animation=p.extend(cV,{tweener:function(a,b){p.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");var c,d=0,e=a.length;for(;d-1,j={},k={},l,m;i?(k=e.position(),l=k.top,m=k.left):(l=parseFloat(g)||0,m=parseFloat(h)||0),p.isFunction(b)&&(b=b.call(a,c,f)),b.top!=null&&(j.top=b.top-f.top+l),b.left!=null&&(j.left=b.left-f.left+m),"using"in b?b.using.call(a,j):e.css(j)}},p.fn.extend({position:function(){if(!this[0])return;var a=this[0],b=this.offsetParent(),c=this.offset(),d=c$.test(b[0].nodeName)?{top:0,left:0}:b.offset();return c.top-=parseFloat(p.css(a,"marginTop"))||0,c.left-=parseFloat(p.css(a,"marginLeft"))||0,d.top+=parseFloat(p.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(p.css(b[0],"borderLeftWidth"))||0,{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||e.body;while(a&&!c$.test(a.nodeName)&&p.css(a,"position")==="static")a=a.offsetParent;return a||e.body})}}),p.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,c){var d=/Y/.test(c);p.fn[a]=function(e){return p.access(this,function(a,e,f){var g=c_(a);if(f===b)return g?c in g?g[c]:g.document.documentElement[e]:a[e];g?g.scrollTo(d?p(g).scrollLeft():f,d?f:p(g).scrollTop()):a[e]=f},a,e,arguments.length,null)}}),p.each({Height:"height",Width:"width"},function(a,c){p.each({padding:"inner"+a,content:c,"":"outer"+a},function(d,e){p.fn[e]=function(e,f){var g=arguments.length&&(d||typeof e!="boolean"),h=d||(e===!0||f===!0?"margin":"border");return p.access(this,function(c,d,e){var f;return p.isWindow(c)?c.document.documentElement["client"+a]:c.nodeType===9?(f=c.documentElement,Math.max(c.body["scroll"+a],f["scroll"+a],c.body["offset"+a],f["offset"+a],f["client"+a])):e===b?p.css(c,d,e,h):p.style(c,d,e,h)},c,g?e:b,g)}})}),a.jQuery=a.$=p,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return p})})(window); diff --git a/middleman-cli/lib/middleman-cli/templates/html5/source/js/vendor/modernizr-2.6.1.min.js b/middleman-cli/lib/middleman-cli/templates/html5/source/js/vendor/modernizr-2.6.1.min.js deleted file mode 100755 index 52b523fa..00000000 --- a/middleman-cli/lib/middleman-cli/templates/html5/source/js/vendor/modernizr-2.6.1.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/* Modernizr 2.6.1 (Custom Build) | MIT & BSD - * Build: http://modernizr.com/download/#-fontface-backgroundsize-borderimage-borderradius-boxshadow-flexbox-hsla-multiplebgs-opacity-rgba-textshadow-cssanimations-csscolumns-generatedcontent-cssgradients-cssreflections-csstransforms-csstransforms3d-csstransitions-applicationcache-canvas-canvastext-draganddrop-hashchange-history-audio-video-indexeddb-input-inputtypes-localstorage-postmessage-sessionstorage-websockets-websqldatabase-webworkers-geolocation-inlinesvg-smil-svg-svgclippaths-touch-webgl-shiv-mq-cssclasses-addtest-prefixed-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes-load - */ -;window.Modernizr=function(a,b,c){function D(a){j.cssText=a}function E(a,b){return D(n.join(a+";")+(b||""))}function F(a,b){return typeof a===b}function G(a,b){return!!~(""+a).indexOf(b)}function H(a,b){for(var d in a){var e=a[d];if(!G(e,"-")&&j[e]!==c)return b=="pfx"?e:!0}return!1}function I(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:F(f,"function")?f.bind(d||b):f}return!1}function J(a,b,c){var d=a.charAt(0).toUpperCase()+a.slice(1),e=(a+" "+p.join(d+" ")+d).split(" ");return F(b,"string")||F(b,"undefined")?H(e,b):(e=(a+" "+q.join(d+" ")+d).split(" "),I(e,b,c))}function K(){e.input=function(c){for(var d=0,e=c.length;d',a,""].join(""),k.id=h,(l?k:m).innerHTML+=f,m.appendChild(k),l||(m.style.background="",g.appendChild(m)),i=c(k,a),l?k.parentNode.removeChild(k):m.parentNode.removeChild(m),!!i},z=function(b){var c=a.matchMedia||a.msMatchMedia;if(c)return c(b).matches;var d;return y("@media "+b+" { #"+h+" { position: absolute; } }",function(b){d=(a.getComputedStyle?getComputedStyle(b,null):b.currentStyle)["position"]=="absolute"}),d},A=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;return f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=F(e[d],"function"),F(e[d],"undefined")||(e[d]=c),e.removeAttribute(d))),e=null,f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),B={}.hasOwnProperty,C;!F(B,"undefined")&&!F(B.call,"undefined")?C=function(a,b){return B.call(a,b)}:C=function(a,b){return b in a&&F(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=w.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(w.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(w.call(arguments)))};return e}),s.flexbox=function(){return J("flexWrap")},s.canvas=function(){var a=b.createElement("canvas");return!!a.getContext&&!!a.getContext("2d")},s.canvastext=function(){return!!e.canvas&&!!F(b.createElement("canvas").getContext("2d").fillText,"function")},s.webgl=function(){return!!a.WebGLRenderingContext},s.touch=function(){var c;return"ontouchstart"in a||a.DocumentTouch&&b instanceof DocumentTouch?c=!0:y(["@media (",n.join("touch-enabled),("),h,")","{#modernizr{top:9px;position:absolute}}"].join(""),function(a){c=a.offsetTop===9}),c},s.geolocation=function(){return"geolocation"in navigator},s.postmessage=function(){return!!a.postMessage},s.websqldatabase=function(){return!!a.openDatabase},s.indexedDB=function(){return!!J("indexedDB",a)},s.hashchange=function(){return A("hashchange",a)&&(b.documentMode===c||b.documentMode>7)},s.history=function(){return!!a.history&&!!history.pushState},s.draganddrop=function(){var a=b.createElement("div");return"draggable"in a||"ondragstart"in a&&"ondrop"in a},s.websockets=function(){return"WebSocket"in a||"MozWebSocket"in a},s.rgba=function(){return D("background-color:rgba(150,255,150,.5)"),G(j.backgroundColor,"rgba")},s.hsla=function(){return D("background-color:hsla(120,40%,100%,.5)"),G(j.backgroundColor,"rgba")||G(j.backgroundColor,"hsla")},s.multiplebgs=function(){return D("background:url(https://),url(https://),red url(https://)"),/(url\s*\(.*?){3}/.test(j.background)},s.backgroundsize=function(){return J("backgroundSize")},s.borderimage=function(){return J("borderImage")},s.borderradius=function(){return J("borderRadius")},s.boxshadow=function(){return J("boxShadow")},s.textshadow=function(){return b.createElement("div").style.textShadow===""},s.opacity=function(){return E("opacity:.55"),/^0.55$/.test(j.opacity)},s.cssanimations=function(){return J("animationName")},s.csscolumns=function(){return J("columnCount")},s.cssgradients=function(){var a="background-image:",b="gradient(linear,left top,right bottom,from(#9f9),to(white));",c="linear-gradient(left top,#9f9, white);";return D((a+"-webkit- ".split(" ").join(b+a)+n.join(c+a)).slice(0,-a.length)),G(j.backgroundImage,"gradient")},s.cssreflections=function(){return J("boxReflect")},s.csstransforms=function(){return!!J("transform")},s.csstransforms3d=function(){var a=!!J("perspective");return a&&"webkitPerspective"in g.style&&y("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}",function(b,c){a=b.offsetLeft===9&&b.offsetHeight===3}),a},s.csstransitions=function(){return J("transition")},s.fontface=function(){var a;return y('@font-face {font-family:"font";src:url("https://")}',function(c,d){var e=b.getElementById("smodernizr"),f=e.sheet||e.styleSheet,g=f?f.cssRules&&f.cssRules[0]?f.cssRules[0].cssText:f.cssText||"":"";a=/src/i.test(g)&&g.indexOf(d.split(" ")[0])===0}),a},s.generatedcontent=function(){var a;return y(['#modernizr:after{content:"',l,'";visibility:hidden}'].join(""),function(b){a=b.offsetHeight>=1}),a},s.video=function(){var a=b.createElement("video"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,""),c.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,""),c.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")}catch(d){}return c},s.audio=function(){var a=b.createElement("audio"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),c.mp3=a.canPlayType("audio/mpeg;").replace(/^no$/,""),c.wav=a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),c.m4a=(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")).replace(/^no$/,"")}catch(d){}return c},s.localstorage=function(){try{return localStorage.setItem(h,h),localStorage.removeItem(h),!0}catch(a){return!1}},s.sessionstorage=function(){try{return sessionStorage.setItem(h,h),sessionStorage.removeItem(h),!0}catch(a){return!1}},s.webworkers=function(){return!!a.Worker},s.applicationcache=function(){return!!a.applicationCache},s.svg=function(){return!!b.createElementNS&&!!b.createElementNS(r.svg,"svg").createSVGRect},s.inlinesvg=function(){var a=b.createElement("div");return a.innerHTML="",(a.firstChild&&a.firstChild.namespaceURI)==r.svg},s.smil=function(){return!!b.createElementNS&&/SVGAnimate/.test(m.call(b.createElementNS(r.svg,"animate")))},s.svgclippaths=function(){return!!b.createElementNS&&/SVGClipPath/.test(m.call(b.createElementNS(r.svg,"clipPath")))};for(var L in s)C(s,L)&&(x=L.toLowerCase(),e[x]=s[L](),v.push((e[x]?"":"no-")+x));return e.input||K(),e.addTest=function(a,b){if(typeof a=="object")for(var d in a)C(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,f&&(g.className+=" "+(b?"":"no-")+a),e[a]=b}return e},D(""),i=k=null,function(a,b){function k(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function l(){var a=r.elements;return typeof a=="string"?a.split(" "):a}function m(a){var b=i[a[g]];return b||(b={},h++,a[g]=h,i[h]=b),b}function n(a,c,f){c||(c=b);if(j)return c.createElement(a);f||(f=m(c));var g;return f.cache[a]?g=f.cache[a].cloneNode():e.test(a)?g=(f.cache[a]=f.createElem(a)).cloneNode():g=f.createElem(a),g.canHaveChildren&&!d.test(a)?f.frag.appendChild(g):g}function o(a,c){a||(a=b);if(j)return a.createDocumentFragment();c=c||m(a);var d=c.frag.cloneNode(),e=0,f=l(),g=f.length;for(;e",f="hidden"in a,j=a.childNodes.length==1||function(){b.createElement("a");var a=b.createDocumentFragment();return typeof a.cloneNode=="undefined"||typeof a.createDocumentFragment=="undefined"||typeof a.createElement=="undefined"}()}catch(c){f=!0,j=!0}})();var r={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,supportsUnknownElements:j,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:q,createElement:n,createDocumentFragment:o};a.html5=r,q(b)}(this,b),e._version=d,e._prefixes=n,e._domPrefixes=q,e._cssomPrefixes=p,e.mq=z,e.hasEvent=A,e.testProp=function(a){return H([a])},e.testAllProps=J,e.testStyles=y,e.prefixed=function(a,b,c){return b?J(a,b,c):J(a,"pfx")},g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+v.join(" "):""),e}(this,this.document),function(a,b,c){function d(a){return o.call(a)=="[object Function]"}function e(a){return typeof a=="string"}function f(){}function g(a){return!a||a=="loaded"||a=="complete"||a=="uninitialized"}function h(){var a=p.shift();q=1,a?a.t?m(function(){(a.t=="c"?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){a!="img"&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l={},o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};y[c]===1&&(r=1,y[c]=[],l=b.createElement(a)),a=="object"?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),a!="img"&&(r||y[c]===2?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i(b=="c"?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),p.length==1&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&o.call(a.opera)=="[object Opera]",l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return o.call(a)=="[object Array]"},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f :string + + # Name of the template being used to generate the project. + class_option :template, :default => 'default' + + # Output a config.ru file for Rack if --rack is passed + class_option :rack, :type => :boolean, :default => false + + # Write a Rack config.ru file for project + # @return [void] + def generate_rack! + return unless options[:rack] + template 'shared/config.ru', File.join(location, 'config.ru') + end + + class_option :'skip-bundle', :type => :boolean, :default => false + class_option :'skip-gemfile', :type => :boolean, :default => false + + # Write a Bundler Gemfile file for project + # @return [void] + def generate_bundler! + return if options[:'skip-gemfile'] + template self.class.gemfile_template, File.join(location, 'Gemfile') + + return if options[:'skip-bundle'] + inside(location) do + ::Middleman::Cli::Bundle.new.invoke(:bundle) + end unless ENV['TEST'] + end + + # Output a .gitignore file + class_option :'skip-git', :type => :boolean, :default => false + + # Write a .gitignore file for project + # @return [void] + def generate_gitignore! + return if options[:'skip-git'] + copy_file 'shared/gitignore', File.join(location, '.gitignore') + end + end + end +end + +Dir.glob(File.expand_path("../middleman-templates/*.rb", __FILE__), &method(:require)) \ No newline at end of file diff --git a/middleman-cli/lib/middleman-cli/templates/default.rb b/middleman-templates/lib/middleman-templates/default.rb similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/default.rb rename to middleman-templates/lib/middleman-templates/default.rb diff --git a/middleman-cli/lib/middleman-cli/templates/default/source/images/background.png b/middleman-templates/lib/middleman-templates/default/source/images/background.png similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/default/source/images/background.png rename to middleman-templates/lib/middleman-templates/default/source/images/background.png diff --git a/middleman-cli/lib/middleman-cli/templates/default/source/images/middleman.png b/middleman-templates/lib/middleman-templates/default/source/images/middleman.png similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/default/source/images/middleman.png rename to middleman-templates/lib/middleman-templates/default/source/images/middleman.png diff --git a/middleman-cli/lib/middleman-cli/templates/default/source/index.html.erb b/middleman-templates/lib/middleman-templates/default/source/index.html.erb similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/default/source/index.html.erb rename to middleman-templates/lib/middleman-templates/default/source/index.html.erb diff --git a/middleman-cli/lib/middleman-cli/templates/default/source/javascripts/all.js b/middleman-templates/lib/middleman-templates/default/source/javascripts/all.js similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/default/source/javascripts/all.js rename to middleman-templates/lib/middleman-templates/default/source/javascripts/all.js diff --git a/middleman-cli/lib/middleman-cli/templates/default/source/layouts/layout.erb b/middleman-templates/lib/middleman-templates/default/source/layouts/layout.erb similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/default/source/layouts/layout.erb rename to middleman-templates/lib/middleman-templates/default/source/layouts/layout.erb diff --git a/middleman-cli/lib/middleman-cli/templates/default/source/stylesheets/all.css b/middleman-templates/lib/middleman-templates/default/source/stylesheets/all.css similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/default/source/stylesheets/all.css rename to middleman-templates/lib/middleman-templates/default/source/stylesheets/all.css diff --git a/middleman-cli/lib/middleman-cli/templates/default/source/stylesheets/normalize.css b/middleman-templates/lib/middleman-templates/default/source/stylesheets/normalize.css similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/default/source/stylesheets/normalize.css rename to middleman-templates/lib/middleman-templates/default/source/stylesheets/normalize.css diff --git a/middleman-cli/lib/middleman-cli/templates/empty.rb b/middleman-templates/lib/middleman-templates/empty.rb similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/empty.rb rename to middleman-templates/lib/middleman-templates/empty.rb diff --git a/middleman-cli/lib/middleman-cli/templates/empty/Gemfile.tt b/middleman-templates/lib/middleman-templates/empty/Gemfile.tt similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/empty/Gemfile.tt rename to middleman-templates/lib/middleman-templates/empty/Gemfile.tt diff --git a/middleman-cli/lib/middleman-cli/templates/html5.rb b/middleman-templates/lib/middleman-templates/html5.rb similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/html5.rb rename to middleman-templates/lib/middleman-templates/html5.rb diff --git a/middleman-cli/lib/middleman-cli/templates/html5/source/.htaccess b/middleman-templates/lib/middleman-templates/html5/source/.htaccess similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/html5/source/.htaccess rename to middleman-templates/lib/middleman-templates/html5/source/.htaccess diff --git a/middleman-cli/lib/middleman-cli/templates/html5/source/404.html b/middleman-templates/lib/middleman-templates/html5/source/404.html similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/html5/source/404.html rename to middleman-templates/lib/middleman-templates/html5/source/404.html diff --git a/middleman-cli/lib/middleman-cli/templates/html5/source/LICENSE.md b/middleman-templates/lib/middleman-templates/html5/source/LICENSE.md similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/html5/source/LICENSE.md rename to middleman-templates/lib/middleman-templates/html5/source/LICENSE.md diff --git a/middleman-cli/lib/middleman-cli/templates/html5/source/README.md b/middleman-templates/lib/middleman-templates/html5/source/README.md similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/html5/source/README.md rename to middleman-templates/lib/middleman-templates/html5/source/README.md diff --git a/middleman-cli/lib/middleman-cli/templates/html5/source/apple-touch-icon-114x114-precomposed.png b/middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon-114x114-precomposed.png similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/html5/source/apple-touch-icon-114x114-precomposed.png rename to middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon-114x114-precomposed.png diff --git a/middleman-cli/lib/middleman-cli/templates/html5/source/apple-touch-icon-144x144-precomposed.png b/middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon-144x144-precomposed.png similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/html5/source/apple-touch-icon-144x144-precomposed.png rename to middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon-144x144-precomposed.png diff --git a/middleman-cli/lib/middleman-cli/templates/html5/source/apple-touch-icon-57x57-precomposed.png b/middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon-57x57-precomposed.png similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/html5/source/apple-touch-icon-57x57-precomposed.png rename to middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon-57x57-precomposed.png diff --git a/middleman-cli/lib/middleman-cli/templates/html5/source/apple-touch-icon-72x72-precomposed.png b/middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon-72x72-precomposed.png similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/html5/source/apple-touch-icon-72x72-precomposed.png rename to middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon-72x72-precomposed.png diff --git a/middleman-cli/lib/middleman-cli/templates/html5/source/apple-touch-icon-precomposed.png b/middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon-precomposed.png similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/html5/source/apple-touch-icon-precomposed.png rename to middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon-precomposed.png diff --git a/middleman-cli/lib/middleman-cli/templates/html5/source/apple-touch-icon.png b/middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon.png similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/html5/source/apple-touch-icon.png rename to middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon.png diff --git a/middleman-cli/lib/middleman-cli/templates/html5/source/crossdomain.xml b/middleman-templates/lib/middleman-templates/html5/source/crossdomain.xml similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/html5/source/crossdomain.xml rename to middleman-templates/lib/middleman-templates/html5/source/crossdomain.xml diff --git a/middleman-cli/lib/middleman-cli/templates/html5/source/css/main.css b/middleman-templates/lib/middleman-templates/html5/source/css/main.css similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/html5/source/css/main.css rename to middleman-templates/lib/middleman-templates/html5/source/css/main.css diff --git a/middleman-cli/lib/middleman-cli/templates/html5/source/css/normalize.css b/middleman-templates/lib/middleman-templates/html5/source/css/normalize.css similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/html5/source/css/normalize.css rename to middleman-templates/lib/middleman-templates/html5/source/css/normalize.css diff --git a/middleman-cli/lib/middleman-cli/templates/html5/source/favicon.ico b/middleman-templates/lib/middleman-templates/html5/source/favicon.ico similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/html5/source/favicon.ico rename to middleman-templates/lib/middleman-templates/html5/source/favicon.ico diff --git a/middleman-cli/lib/middleman-cli/templates/html5/source/humans.txt b/middleman-templates/lib/middleman-templates/html5/source/humans.txt similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/html5/source/humans.txt rename to middleman-templates/lib/middleman-templates/html5/source/humans.txt diff --git a/middleman-templates/lib/middleman-templates/html5/source/img/.gitignore b/middleman-templates/lib/middleman-templates/html5/source/img/.gitignore new file mode 100755 index 00000000..e69de29b diff --git a/middleman-cli/lib/middleman-cli/templates/html5/source/index.html.erb b/middleman-templates/lib/middleman-templates/html5/source/index.html.erb similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/html5/source/index.html.erb rename to middleman-templates/lib/middleman-templates/html5/source/index.html.erb diff --git a/middleman-cli/lib/middleman-cli/templates/html5/source/js/main.js b/middleman-templates/lib/middleman-templates/html5/source/js/main.js similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/html5/source/js/main.js rename to middleman-templates/lib/middleman-templates/html5/source/js/main.js diff --git a/middleman-cli/lib/middleman-cli/templates/html5/source/js/plugins.js b/middleman-templates/lib/middleman-templates/html5/source/js/plugins.js similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/html5/source/js/plugins.js rename to middleman-templates/lib/middleman-templates/html5/source/js/plugins.js diff --git a/middleman-cli/lib/middleman-cli/templates/html5/source/layouts/layout.erb b/middleman-templates/lib/middleman-templates/html5/source/layouts/layout.erb similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/html5/source/layouts/layout.erb rename to middleman-templates/lib/middleman-templates/html5/source/layouts/layout.erb diff --git a/middleman-cli/lib/middleman-cli/templates/html5/source/robots.txt b/middleman-templates/lib/middleman-templates/html5/source/robots.txt similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/html5/source/robots.txt rename to middleman-templates/lib/middleman-templates/html5/source/robots.txt diff --git a/middleman-cli/lib/middleman-cli/templates/local.rb b/middleman-templates/lib/middleman-templates/local.rb similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/local.rb rename to middleman-templates/lib/middleman-templates/local.rb diff --git a/middleman-cli/lib/middleman-cli/templates/mobile.rb b/middleman-templates/lib/middleman-templates/mobile.rb similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile.rb rename to middleman-templates/lib/middleman-templates/mobile.rb diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/404.html b/middleman-templates/lib/middleman-templates/mobile/source/404.html similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/404.html rename to middleman-templates/lib/middleman-templates/mobile/source/404.html diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/README.markdown b/middleman-templates/lib/middleman-templates/mobile/source/README.markdown similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/README.markdown rename to middleman-templates/lib/middleman-templates/mobile/source/README.markdown diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/crossdomain.xml b/middleman-templates/lib/middleman-templates/mobile/source/crossdomain.xml similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/crossdomain.xml rename to middleman-templates/lib/middleman-templates/mobile/source/crossdomain.xml diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/css/style.css b/middleman-templates/lib/middleman-templates/mobile/source/css/style.css similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/css/style.css rename to middleman-templates/lib/middleman-templates/mobile/source/css/style.css diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/humans.txt b/middleman-templates/lib/middleman-templates/mobile/source/humans.txt similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/humans.txt rename to middleman-templates/lib/middleman-templates/mobile/source/humans.txt diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/img/h/apple-touch-icon.png b/middleman-templates/lib/middleman-templates/mobile/source/img/h/apple-touch-icon.png similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/img/h/apple-touch-icon.png rename to middleman-templates/lib/middleman-templates/mobile/source/img/h/apple-touch-icon.png diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/img/h/splash.png b/middleman-templates/lib/middleman-templates/mobile/source/img/h/splash.png similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/img/h/splash.png rename to middleman-templates/lib/middleman-templates/mobile/source/img/h/splash.png diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/img/l/apple-touch-icon-precomposed.png b/middleman-templates/lib/middleman-templates/mobile/source/img/l/apple-touch-icon-precomposed.png similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/img/l/apple-touch-icon-precomposed.png rename to middleman-templates/lib/middleman-templates/mobile/source/img/l/apple-touch-icon-precomposed.png diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/img/l/apple-touch-icon.png b/middleman-templates/lib/middleman-templates/mobile/source/img/l/apple-touch-icon.png similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/img/l/apple-touch-icon.png rename to middleman-templates/lib/middleman-templates/mobile/source/img/l/apple-touch-icon.png diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/img/l/splash.png b/middleman-templates/lib/middleman-templates/mobile/source/img/l/splash.png similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/img/l/splash.png rename to middleman-templates/lib/middleman-templates/mobile/source/img/l/splash.png diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/img/m/apple-touch-icon.png b/middleman-templates/lib/middleman-templates/mobile/source/img/m/apple-touch-icon.png similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/img/m/apple-touch-icon.png rename to middleman-templates/lib/middleman-templates/mobile/source/img/m/apple-touch-icon.png diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/index.html b/middleman-templates/lib/middleman-templates/mobile/source/index.html similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/index.html rename to middleman-templates/lib/middleman-templates/mobile/source/index.html diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/js/libs/modernizr-custom.js b/middleman-templates/lib/middleman-templates/mobile/source/js/libs/modernizr-custom.js similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/js/libs/modernizr-custom.js rename to middleman-templates/lib/middleman-templates/mobile/source/js/libs/modernizr-custom.js diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/js/libs/respond.min.js b/middleman-templates/lib/middleman-templates/mobile/source/js/libs/respond.min.js similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/js/libs/respond.min.js rename to middleman-templates/lib/middleman-templates/mobile/source/js/libs/respond.min.js diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/js/mylibs/helper.js b/middleman-templates/lib/middleman-templates/mobile/source/js/mylibs/helper.js similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/js/mylibs/helper.js rename to middleman-templates/lib/middleman-templates/mobile/source/js/mylibs/helper.js diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/js/plugins.js b/middleman-templates/lib/middleman-templates/mobile/source/js/plugins.js similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/js/plugins.js rename to middleman-templates/lib/middleman-templates/mobile/source/js/plugins.js diff --git a/middleman-templates/lib/middleman-templates/mobile/source/js/script.js b/middleman-templates/lib/middleman-templates/mobile/source/js/script.js new file mode 100755 index 00000000..e69de29b diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/robots.txt b/middleman-templates/lib/middleman-templates/mobile/source/robots.txt similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/robots.txt rename to middleman-templates/lib/middleman-templates/mobile/source/robots.txt diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/sitemap.xml b/middleman-templates/lib/middleman-templates/mobile/source/sitemap.xml similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/sitemap.xml rename to middleman-templates/lib/middleman-templates/mobile/source/sitemap.xml diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/test/index.html b/middleman-templates/lib/middleman-templates/mobile/source/test/index.html similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/test/index.html rename to middleman-templates/lib/middleman-templates/mobile/source/test/index.html diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/test/qunit/qunit.css b/middleman-templates/lib/middleman-templates/mobile/source/test/qunit/qunit.css similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/test/qunit/qunit.css rename to middleman-templates/lib/middleman-templates/mobile/source/test/qunit/qunit.css diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/test/qunit/qunit.js b/middleman-templates/lib/middleman-templates/mobile/source/test/qunit/qunit.js similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/test/qunit/qunit.js rename to middleman-templates/lib/middleman-templates/mobile/source/test/qunit/qunit.js diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/test/tests.js b/middleman-templates/lib/middleman-templates/mobile/source/test/tests.js similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/test/tests.js rename to middleman-templates/lib/middleman-templates/mobile/source/test/tests.js diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/Readme.PDF b/middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/Readme.PDF similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/Readme.PDF rename to middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/Readme.PDF diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx1.snippet b/middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx1.snippet similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx1.snippet rename to middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx1.snippet diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx2.snippet b/middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx2.snippet similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx2.snippet rename to middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx2.snippet diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/aspx/ga.aspx b/middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/aspx/ga.aspx similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/aspx/ga.aspx rename to middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/aspx/ga.aspx diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/aspx/sample.aspx b/middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/aspx/sample.aspx similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/aspx/sample.aspx rename to middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/aspx/sample.aspx diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/jsp/ga.jsp b/middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/jsp/ga.jsp similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/jsp/ga.jsp rename to middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/jsp/ga.jsp diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp1.snippet b/middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp1.snippet similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp1.snippet rename to middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp1.snippet diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp2.snippet b/middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp2.snippet similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp2.snippet rename to middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp2.snippet diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/jsp/sample.jsp b/middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/jsp/sample.jsp similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/jsp/sample.jsp rename to middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/jsp/sample.jsp diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/php/ga.php b/middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/php/ga.php similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/php/ga.php rename to middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/php/ga.php diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/php/php1.snippet b/middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/php/php1.snippet similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/php/php1.snippet rename to middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/php/php1.snippet diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/php/php2.snippet b/middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/php/php2.snippet similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/php/php2.snippet rename to middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/php/php2.snippet diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/php/sample.php b/middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/php/sample.php similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/php/sample.php rename to middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/php/sample.php diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/pl/ga.pl b/middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/pl/ga.pl similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/pl/ga.pl rename to middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/pl/ga.pl diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/pl/perl1.snippet b/middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/pl/perl1.snippet similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/pl/perl1.snippet rename to middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/pl/perl1.snippet diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/pl/perl2.snippet b/middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/pl/perl2.snippet similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/pl/perl2.snippet rename to middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/pl/perl2.snippet diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/pl/sample.pl b/middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/pl/sample.pl similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/googleanalyticsformobile/pl/sample.pl rename to middleman-templates/lib/middleman-templates/mobile/source/tools/googleanalyticsformobile/pl/sample.pl diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/COPYING b/middleman-templates/lib/middleman-templates/mobile/source/tools/mobile-bookmark-bubble/COPYING similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/COPYING rename to middleman-templates/lib/middleman-templates/mobile/source/tools/mobile-bookmark-bubble/COPYING diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/bookmark_bubble.js b/middleman-templates/lib/middleman-templates/mobile/source/tools/mobile-bookmark-bubble/bookmark_bubble.js similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/bookmark_bubble.js rename to middleman-templates/lib/middleman-templates/mobile/source/tools/mobile-bookmark-bubble/bookmark_bubble.js diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/example/example.html b/middleman-templates/lib/middleman-templates/mobile/source/tools/mobile-bookmark-bubble/example/example.html similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/example/example.html rename to middleman-templates/lib/middleman-templates/mobile/source/tools/mobile-bookmark-bubble/example/example.html diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/example/example.js b/middleman-templates/lib/middleman-templates/mobile/source/tools/mobile-bookmark-bubble/example/example.js similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/example/example.js rename to middleman-templates/lib/middleman-templates/mobile/source/tools/mobile-bookmark-bubble/example/example.js diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/images/arrow.png b/middleman-templates/lib/middleman-templates/mobile/source/tools/mobile-bookmark-bubble/images/arrow.png similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/images/arrow.png rename to middleman-templates/lib/middleman-templates/mobile/source/tools/mobile-bookmark-bubble/images/arrow.png diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/images/close.png b/middleman-templates/lib/middleman-templates/mobile/source/tools/mobile-bookmark-bubble/images/close.png similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/images/close.png rename to middleman-templates/lib/middleman-templates/mobile/source/tools/mobile-bookmark-bubble/images/close.png diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/images/generate_base64_images b/middleman-templates/lib/middleman-templates/mobile/source/tools/mobile-bookmark-bubble/images/generate_base64_images similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/images/generate_base64_images rename to middleman-templates/lib/middleman-templates/mobile/source/tools/mobile-bookmark-bubble/images/generate_base64_images diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/images/icon_calendar.png b/middleman-templates/lib/middleman-templates/mobile/source/tools/mobile-bookmark-bubble/images/icon_calendar.png similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/mobile-bookmark-bubble/images/icon_calendar.png rename to middleman-templates/lib/middleman-templates/mobile/source/tools/mobile-bookmark-bubble/images/icon_calendar.png diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/README b/middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/README similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/README rename to middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/README diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/databasefactory.js b/middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/databasefactory.js similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/databasefactory.js rename to middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/databasefactory.js diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbworker.js b/middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/dbworker.js similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbworker.js rename to middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/dbworker.js diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbworker_test.html b/middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/dbworker_test.html similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbworker_test.html rename to middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/dbworker_test.html diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbworkerstarter.js b/middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/dbworkerstarter.js similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbworkerstarter.js rename to middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/dbworkerstarter.js diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbwrapper_gears.js b/middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/dbwrapper_gears.js similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbwrapper_gears.js rename to middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/dbwrapper_gears.js diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbwrapper_gears_test.html b/middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/dbwrapper_gears_test.html similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbwrapper_gears_test.html rename to middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/dbwrapper_gears_test.html diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbwrapper_html5.js b/middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/dbwrapper_html5.js similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbwrapper_html5.js rename to middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/dbwrapper_html5.js diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbwrapper_html5_test.html b/middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/dbwrapper_html5_test.html similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbwrapper_html5_test.html rename to middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/dbwrapper_html5_test.html diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbwrapperapi.js b/middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/dbwrapperapi.js similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbwrapperapi.js rename to middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/dbwrapperapi.js diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbwrapperapi_test.html b/middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/dbwrapperapi_test.html similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/dbwrapperapi_test.html rename to middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/dbwrapperapi_test.html diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/gears_resultset.js b/middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/gears_resultset.js similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/gears_resultset.js rename to middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/gears_resultset.js diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/gears_resultset_test.html b/middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/gears_resultset_test.html similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/gears_resultset_test.html rename to middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/gears_resultset_test.html diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/gears_transaction.js b/middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/gears_transaction.js similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/gears_transaction.js rename to middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/gears_transaction.js diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/gears_transaction_test.html b/middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/gears_transaction_test.html similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/gears_transaction_test.html rename to middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/gears_transaction_test.html diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/gearsutils.js b/middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/gearsutils.js similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/gearsutils.js rename to middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/gearsutils.js diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/gearsutils_test.html b/middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/gearsutils_test.html similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/gearsutils_test.html rename to middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/gearsutils_test.html diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/global_functions.js b/middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/global_functions.js similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/global_functions.js rename to middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/global_functions.js diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/simplenotes/index.html b/middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/simplenotes/index.html similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/simplenotes/index.html rename to middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/simplenotes/index.html diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/simplenotes/simplenotes.js b/middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/simplenotes/simplenotes.js similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/simplenotes/simplenotes.js rename to middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/simplenotes/simplenotes.js diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/simplenotes/styles.css b/middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/simplenotes/styles.css similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/simplenotes/styles.css rename to middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/simplenotes/styles.css diff --git a/middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/simplenotes/template.js b/middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/simplenotes/template.js similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/mobile/source/tools/wspl/simplenotes/template.js rename to middleman-templates/lib/middleman-templates/mobile/source/tools/wspl/simplenotes/template.js diff --git a/middleman-cli/lib/middleman-cli/templates/shared/Gemfile.tt b/middleman-templates/lib/middleman-templates/shared/Gemfile.tt similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/shared/Gemfile.tt rename to middleman-templates/lib/middleman-templates/shared/Gemfile.tt diff --git a/middleman-cli/lib/middleman-cli/templates/shared/config.ru b/middleman-templates/lib/middleman-templates/shared/config.ru similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/shared/config.ru rename to middleman-templates/lib/middleman-templates/shared/config.ru diff --git a/middleman-cli/lib/middleman-cli/templates/shared/config.tt b/middleman-templates/lib/middleman-templates/shared/config.tt similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/shared/config.tt rename to middleman-templates/lib/middleman-templates/shared/config.tt diff --git a/middleman-cli/lib/middleman-cli/templates/shared/gitignore b/middleman-templates/lib/middleman-templates/shared/gitignore similarity index 100% rename from middleman-cli/lib/middleman-cli/templates/shared/gitignore rename to middleman-templates/lib/middleman-templates/shared/gitignore diff --git a/middleman-templates/middleman-templates.gemspec b/middleman-templates/middleman-templates.gemspec new file mode 100644 index 00000000..c61150b4 --- /dev/null +++ b/middleman-templates/middleman-templates.gemspec @@ -0,0 +1,24 @@ +# -*- encoding: utf-8 -*- +$:.push File.expand_path("../lib", __FILE__) +require File.expand_path("../../middleman-core/lib/middleman-core/version.rb", __FILE__) + +Gem::Specification.new do |s| + s.name = "middleman-templates" + s.version = Middleman::VERSION + s.platform = Gem::Platform::RUBY + s.license = "MIT" + s.authors = ["Thomas Reynolds", "Ben Hollis", "Karl Freeman"] + s.email = ["me@tdreyno.com", "ben@benhollis.net", "karlfreeman@gmail.com"] + s.homepage = "http://middlemanapp.com" + s.summary = "Hand-crafted frontend development" + s.description = "A static site generator. Provides dozens of templating languages (Haml, Sass, Compass, Slim, CoffeeScript, and more). Makes minification, compression, cache busting, Yaml data (and more) an easy part of your development cycle." + + s.files = `git ls-files -z`.split("\0") + s.test_files = `git ls-files -z -- {fixtures,features}/*`.split("\0") + s.executable = "middleman" + s.require_path = "lib" + s.required_ruby_version = '>= 1.9.3' + + # Templates + s.add_dependency("thor", [">= 0.17.0", "< 2.0"]) +end diff --git a/middleman-templates/spec/middleman/.gitkeep b/middleman-templates/spec/middleman/.gitkeep new file mode 100644 index 00000000..45adbb22 --- /dev/null +++ b/middleman-templates/spec/middleman/.gitkeep @@ -0,0 +1 @@ +.gitkeep \ No newline at end of file diff --git a/middleman-templates/spec/spec_helper.rb b/middleman-templates/spec/spec_helper.rb new file mode 100644 index 00000000..e69de29b diff --git a/middleman/middleman.gemspec b/middleman/middleman.gemspec index 5e334555..5fa6f558 100644 --- a/middleman/middleman.gemspec +++ b/middleman/middleman.gemspec @@ -20,6 +20,7 @@ Gem::Specification.new do |s| s.add_dependency("middleman-core", Middleman::VERSION) s.add_dependency("middleman-cli", Middleman::VERSION) + s.add_dependency("middleman-templates", Middleman::VERSION) s.add_dependency("middleman-sprockets", ">= 3.1.2") s.add_dependency("haml", [">= 3.1.6"]) s.add_dependency("sass", [">= 3.1.20"]) From 9fb4470248e13110f15eb9a2dfdce3e7b2566bec Mon Sep 17 00:00:00 2001 From: Karl Freeman Date: Tue, 11 Mar 2014 11:08:41 +0000 Subject: [PATCH 035/580] tidy up logic - the extension template already had a gitignore --- middleman-cli/lib/middleman-cli/extension.rb | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/middleman-cli/lib/middleman-cli/extension.rb b/middleman-cli/lib/middleman-cli/extension.rb index 71bfb38e..5d9b9de9 100644 --- a/middleman-cli/lib/middleman-cli/extension.rb +++ b/middleman-cli/lib/middleman-cli/extension.rb @@ -27,7 +27,7 @@ module Middleman::Cli # The extension task # @param [String] name def extension - generate_gitignore! + copy_file 'extension/gitignore', File.join(name, '.gitignore') unless options[:'skip-git'] template 'extension/Rakefile', File.join(name, 'Rakefile') template 'extension/gemspec', File.join(name, "#{name}.gemspec") template 'extension/Gemfile', File.join(name, 'Gemfile') @@ -40,14 +40,5 @@ module Middleman::Cli # Output a .gitignore file class_option :git, :type => :boolean, :default => true - no_tasks { - # Write a .gitignore file for project - # @return [void] - def generate_gitignore! - return if options[:'skip-git'] - copy_file 'shared/gitignore', File.join(name, '.gitignore') - end - } - end end From 9de092ba5f684a44646524266f3fb6746bfaa5d0 Mon Sep 17 00:00:00 2001 From: Karl Freeman Date: Thu, 13 Mar 2014 09:46:49 +0000 Subject: [PATCH 036/580] gemfiles are required but lets still keep the convenience of bundling --- middleman-cli/lib/middleman-cli/init.rb | 4 ---- middleman-templates/lib/middleman-templates.rb | 6 +----- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/middleman-cli/lib/middleman-cli/init.rb b/middleman-cli/lib/middleman-cli/init.rb index 0dab0b11..4376db2a 100644 --- a/middleman-cli/lib/middleman-cli/init.rb +++ b/middleman-cli/lib/middleman-cli/init.rb @@ -28,10 +28,6 @@ module Middleman::Cli :type => :boolean, :default => false, :desc => 'Include a config.ru file' - method_option 'skip-gemfile', - :type => :boolean, - :default => false, - :desc => "Don't create a Gemfile" method_option 'skip-bundle', :type => :boolean, :aliases => '-B', diff --git a/middleman-templates/lib/middleman-templates.rb b/middleman-templates/lib/middleman-templates.rb index 06c83f55..467c1345 100644 --- a/middleman-templates/lib/middleman-templates.rb +++ b/middleman-templates/lib/middleman-templates.rb @@ -62,17 +62,13 @@ module Middleman end class_option :'skip-bundle', :type => :boolean, :default => false - class_option :'skip-gemfile', :type => :boolean, :default => false # Write a Bundler Gemfile file for project # @return [void] def generate_bundler! - return if options[:'skip-gemfile'] - template self.class.gemfile_template, File.join(location, 'Gemfile') - return if options[:'skip-bundle'] inside(location) do - ::Middleman::Cli::Bundle.new.invoke(:bundle) + run('bundle install') end unless ENV['TEST'] end From 554577b139187d472664f719211e8ae288744342 Mon Sep 17 00:00:00 2001 From: Karl Freeman Date: Thu, 13 Mar 2014 10:05:30 +0000 Subject: [PATCH 037/580] too aggressive with the deletes... --- middleman-templates/lib/middleman-templates.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/middleman-templates/lib/middleman-templates.rb b/middleman-templates/lib/middleman-templates.rb index 467c1345..d6827b4a 100644 --- a/middleman-templates/lib/middleman-templates.rb +++ b/middleman-templates/lib/middleman-templates.rb @@ -66,6 +66,7 @@ module Middleman # Write a Bundler Gemfile file for project # @return [void] def generate_bundler! + template self.class.gemfile_template, File.join(location, 'Gemfile') return if options[:'skip-bundle'] inside(location) do run('bundle install') From 24f71439739e30156a623d52df23df27cbe31b84 Mon Sep 17 00:00:00 2001 From: Karl Freeman Date: Thu, 13 Mar 2014 11:18:20 +0000 Subject: [PATCH 038/580] shouldn't be here --- middleman-templates/bin/middleman | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100755 middleman-templates/bin/middleman diff --git a/middleman-templates/bin/middleman b/middleman-templates/bin/middleman deleted file mode 100755 index 924f905d..00000000 --- a/middleman-templates/bin/middleman +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env ruby - -require 'middleman-core/profiling' -if ARGV.include? '--profile' - Middleman::Profiling.profiler = Middleman::Profiling::RubyProfProfiler.new -end -Middleman::Profiling.start - -require "middleman-core/load_paths" -Middleman.setup_load_paths - -require "middleman-cli" - -# Change directory to the root -Dir.chdir(ENV["MM_ROOT"]) if ENV["MM_ROOT"] - -# Start the CLI -Middleman::Cli::Base.start From 32716f37293cb2ddeeb939d81648a30b2221cd92 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Thu, 13 Mar 2014 20:19:08 -0700 Subject: [PATCH 039/580] Avoid loading middleman-core unless needed. Fixes #1203. --- middleman-cli/lib/middleman-cli/build.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/middleman-cli/lib/middleman-cli/build.rb b/middleman-cli/lib/middleman-cli/build.rb index 403b6aaa..c9bf2ab6 100644 --- a/middleman-cli/lib/middleman-cli/build.rb +++ b/middleman-cli/lib/middleman-cli/build.rb @@ -1,6 +1,3 @@ -require 'middleman-core' -require 'middleman-core/logger' - require 'fileutils' require 'set' @@ -50,6 +47,9 @@ module Middleman::Cli raise Thor::Error, 'Error: Could not find a Middleman project config, perhaps you are in the wrong folder?' end + require 'middleman-core' + require 'middleman-core/logger' + require 'rack' require 'rack/mock' From 87acf687d57bb6a4e259e7e66b7c97cc4543278d Mon Sep 17 00:00:00 2001 From: Karl Freeman Date: Wed, 12 Mar 2014 09:05:43 +0000 Subject: [PATCH 040/580] friendlier localhost print --- middleman-core/lib/middleman-core/preview_server.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/middleman-core/lib/middleman-core/preview_server.rb b/middleman-core/lib/middleman-core/preview_server.rb index 0fceb8ea..d3f38bfa 100644 --- a/middleman-core/lib/middleman-core/preview_server.rb +++ b/middleman-core/lib/middleman-core/preview_server.rb @@ -19,8 +19,8 @@ module Middleman @port = @options[:port] || DEFAULT_PORT mount_instance(new_app) - logger.info "== The Middleman is standing watch at http://#{host}:#{port}" - logger.info "== Inspect your site configuration at http://#{host}:#{port}/__middleman/" + logger.info "== The Middleman is standing watch at #{uri}" + logger.info "== Inspect your site configuration at #{uri + '__middleman'}" @initialized ||= false unless @initialized @@ -226,6 +226,14 @@ module Middleman end end end + + # Returns the URI the preview server will run on + # @return [URI] + def uri + host = (@host == '0.0.0.0') ? 'localhost' : @host + URI("http://#{host}:#{@port}") + end + end class FilteredWebrickLog < ::WEBrick::Log From 8e8ddbc30170b35b97d71b448b9110547a2e5c0c Mon Sep 17 00:00:00 2001 From: Karl Freeman Date: Thu, 13 Mar 2014 10:57:19 +0000 Subject: [PATCH 041/580] rejig templates, deprecate 'empty' template and rubocop them --- .../lib/middleman-templates.rb | 34 +++++++++++++------ .../lib/middleman-templates/default.rb | 15 +++----- .../lib/middleman-templates/empty.rb | 10 ++---- .../lib/middleman-templates/empty/Gemfile.tt | 6 ---- .../lib/middleman-templates/html5.rb | 19 ++++------- .../lib/middleman-templates/local.rb | 15 ++------ .../lib/middleman-templates/mobile.rb | 10 +++--- .../lib/middleman-templates/shared/config.ru | 2 +- 8 files changed, 44 insertions(+), 67 deletions(-) delete mode 100644 middleman-templates/lib/middleman-templates/empty/Gemfile.tt diff --git a/middleman-templates/lib/middleman-templates.rb b/middleman-templates/lib/middleman-templates.rb index d6827b4a..2e8a343c 100644 --- a/middleman-templates/lib/middleman-templates.rb +++ b/middleman-templates/lib/middleman-templates.rb @@ -9,10 +9,8 @@ require 'thor/group' # Templates Module module Middleman module Templates - # Static methods class << self - # Get list of registered templates and add new ones # # Middleman::Templates.register(:ext_name, klass) @@ -20,14 +18,14 @@ module Middleman # @param [Symbol] name The name of the template # @param [Class] klass The class to be executed for this template # @return [Hash] List of registered templates - def register(name=nil, klass=nil) + def register(name = nil, klass = nil) @_template_mappings ||= {} @_template_mappings[name] = klass if name && klass @_template_mappings end # Middleman::Templates.register(name, klass) - alias :registered :register + alias_method :registered, :register end # Base Template class. Handles basic options and paths. @@ -46,13 +44,13 @@ module Middleman end # Required path for the new project to be generated - argument :location, :type => :string + argument :location, type: :string # Name of the template being used to generate the project. - class_option :template, :default => 'default' + class_option :template, default: 'default' # Output a config.ru file for Rack if --rack is passed - class_option :rack, :type => :boolean, :default => false + class_option :rack, type: :boolean, default: false # Write a Rack config.ru file for project # @return [void] @@ -61,7 +59,8 @@ module Middleman template 'shared/config.ru', File.join(location, 'config.ru') end - class_option :'skip-bundle', :type => :boolean, :default => false + # Do not run bundle install + class_option :'skip-bundle', type: :boolean, default: false # Write a Bundler Gemfile file for project # @return [void] @@ -74,7 +73,7 @@ module Middleman end # Output a .gitignore file - class_option :'skip-git', :type => :boolean, :default => false + class_option :'skip-git', type: :boolean, default: false # Write a .gitignore file for project # @return [void] @@ -86,4 +85,19 @@ module Middleman end end -Dir.glob(File.expand_path("../middleman-templates/*.rb", __FILE__), &method(:require)) \ No newline at end of file +# Register all official templates +Dir.glob(File.expand_path('../middleman-templates/*.rb', __FILE__), &method(:require)) + +# Iterate over directories in the templates path and register each one. +Dir[File.join(Middleman::Templates::Local.source_root, '*')].each do |dir| + next unless File.directory?(dir) + template_file = File.join(dir, 'template.rb') + + # If a template.rb file is found require it (therefore registering the template) + # else register the folder as a Local template (which when built, just copies the folder) + if File.exists?(template_file) + require template_file + else + Middleman::Templates.register(File.basename(dir).to_sym, Middleman::Templates::Local) + end +end diff --git a/middleman-templates/lib/middleman-templates/default.rb b/middleman-templates/lib/middleman-templates/default.rb index 7497f98f..3eb1ff52 100644 --- a/middleman-templates/lib/middleman-templates/default.rb +++ b/middleman-templates/lib/middleman-templates/default.rb @@ -1,15 +1,8 @@ # Default Middleman template class Middleman::Templates::Default < Middleman::Templates::Base - - class_option 'css_dir', - :default => 'stylesheets', - :desc => 'The path to the css files' - class_option 'js_dir', - :default => 'javascripts', - :desc => 'The path to the javascript files' - class_option 'images_dir', - :default => 'images', - :desc => 'The path to the image files' + class_option :css_dir, default: 'stylesheets', desc: 'The path to the css files' + class_option :js_dir, default: 'javascripts', desc: 'The path to the javascript files' + class_option :images_dir, default: 'images', desc: 'The path to the image files' # Template files are relative to this file # @return [String] @@ -17,7 +10,7 @@ class Middleman::Templates::Default < Middleman::Templates::Base File.dirname(__FILE__) end - # Actually output the files + # Output the files # @return [void] def build_scaffold! template 'shared/config.tt', File.join(location, 'config.rb') diff --git a/middleman-templates/lib/middleman-templates/empty.rb b/middleman-templates/lib/middleman-templates/empty.rb index e726f1c2..18ac3106 100644 --- a/middleman-templates/lib/middleman-templates/empty.rb +++ b/middleman-templates/lib/middleman-templates/empty.rb @@ -1,21 +1,17 @@ # A barebones template with nothing much in it class Middleman::Templates::Empty < Middleman::Templates::Base - # Template files are relative to this file # @return [String] def self.source_root File.dirname(__FILE__) end - def self.gemfile_template - 'empty/Gemfile.tt' - end - - # Actually output the files + # Output the files # @return [void] def build_scaffold! - create_file File.join(location, 'config.rb'), "\n" + template 'shared/config.tt', File.join(location, 'config.rb') empty_directory File.join(location, 'source') + create_file File.join(location, 'source', '.gitkeep') unless options[:'skip-git'] end end diff --git a/middleman-templates/lib/middleman-templates/empty/Gemfile.tt b/middleman-templates/lib/middleman-templates/empty/Gemfile.tt deleted file mode 100644 index 6d51559a..00000000 --- a/middleman-templates/lib/middleman-templates/empty/Gemfile.tt +++ /dev/null @@ -1,6 +0,0 @@ -source 'https://rubygems.org' - -gem "middleman", "~><%= Middleman::VERSION %>" - -# For faster file watcher updates on Windows: -gem "wdm", "~> 0.1.0", :platforms => [:mswin, :mingw] \ No newline at end of file diff --git a/middleman-templates/lib/middleman-templates/html5.rb b/middleman-templates/lib/middleman-templates/html5.rb index 6e8391cb..de0bf25d 100644 --- a/middleman-templates/lib/middleman-templates/html5.rb +++ b/middleman-templates/lib/middleman-templates/html5.rb @@ -1,17 +1,11 @@ # HTML5 Boilerplate template class Middleman::Templates::Html5 < Middleman::Templates::Base + # Slightly different paths + class_option :css_dir, default: 'css', desc: 'The path to the css files' + class_option :js_dir, default: 'js', desc: 'The path to the javascript files' + class_option :images_dir, default: 'img', desc: 'The path to the image files' - class_option 'css_dir', - :default => 'css', - :desc => 'The path to the css files' - class_option 'js_dir', - :default => 'js', - :desc => 'The path to the javascript files' - class_option 'images_dir', - :default => 'img', - :desc => 'The path to the image files' - - # Templates are relative to this file + # Template files are relative to this file # @return [String] def self.source_root File.dirname(__FILE__) @@ -22,9 +16,8 @@ class Middleman::Templates::Html5 < Middleman::Templates::Base def build_scaffold! template 'shared/config.tt', File.join(location, 'config.rb') directory 'html5/source', File.join(location, 'source') - empty_directory File.join(location, 'source') end end -# Register the template +# Register this template Middleman::Templates.register(:html5, Middleman::Templates::Html5) diff --git a/middleman-templates/lib/middleman-templates/local.rb b/middleman-templates/lib/middleman-templates/local.rb index c5ba9c79..d9a9711a 100644 --- a/middleman-templates/lib/middleman-templates/local.rb +++ b/middleman-templates/lib/middleman-templates/local.rb @@ -1,6 +1,5 @@ # Local templates class Middleman::Templates::Local < Middleman::Templates::Base - # Look for templates in ~/.middleman # @return [String] def self.source_root @@ -14,15 +13,5 @@ class Middleman::Templates::Local < Middleman::Templates::Base end end -# Iterate over the directories in the templates path and register each one. -Dir[File.join(Middleman::Templates::Local.source_root, '*')].each do |dir| - next unless File.directory?(dir) - - template_file = File.join(dir, 'template.rb') - - if File.exists?(template_file) - require template_file - else - Middleman::Templates.register(File.basename(dir).to_sym, Middleman::Templates::Local) - end -end +# Register this template +Middleman::Templates.register(:local, Middleman::Templates::Local) diff --git a/middleman-templates/lib/middleman-templates/mobile.rb b/middleman-templates/lib/middleman-templates/mobile.rb index 8e7e3530..39186271 100644 --- a/middleman-templates/lib/middleman-templates/mobile.rb +++ b/middleman-templates/lib/middleman-templates/mobile.rb @@ -1,10 +1,9 @@ # Mobile HTML5 Boilerplate class Middleman::Templates::Mobile < Middleman::Templates::Base - # Slightly different paths - class_option :css_dir, :default => 'css' - class_option :js_dir, :default => 'js' - class_option :images_dir, :default => 'img' + class_option :css_dir, default: 'css', desc: 'The path to the css files' + class_option :js_dir, default: 'js', desc: 'The path to the javascript files' + class_option :images_dir, default: 'img', desc: 'The path to the image files' # Template files are relative to this file # @return [String] @@ -17,9 +16,8 @@ class Middleman::Templates::Mobile < Middleman::Templates::Base def build_scaffold! template 'shared/config.tt', File.join(location, 'config.rb') directory 'mobile/source', File.join(location, 'source') - empty_directory File.join(location, 'source') end end -# Register the template +# Register this template Middleman::Templates.register(:mobile, Middleman::Templates::Mobile) diff --git a/middleman-templates/lib/middleman-templates/shared/config.ru b/middleman-templates/lib/middleman-templates/shared/config.ru index e091b492..9bff44ef 100644 --- a/middleman-templates/lib/middleman-templates/shared/config.ru +++ b/middleman-templates/lib/middleman-templates/shared/config.ru @@ -1,4 +1,4 @@ require 'rubygems' require 'middleman/rack' -run Middleman.server \ No newline at end of file +run Middleman.server From 1721dff4c70b63b88cd7ae173e07e3486a3cdc3d Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Thu, 20 Mar 2014 10:02:18 -0700 Subject: [PATCH 042/580] add node_modules to filewatcher ignore --- .../lib/middleman-core/core_extensions/file_watcher.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb b/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb index d0ebec77..1b499b5e 100644 --- a/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb +++ b/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb @@ -10,6 +10,7 @@ module Middleman /^\.sass-cache\//, /^\.cache\//, /^\.git\//, + /^node_modules(\/|$)/, /^\.gitignore$/, /\.DS_Store/, /^\.rbenv-.*$/, From ce7636ad18340a41368705c06ecfc6dbab455ebe Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Thu, 20 Mar 2014 17:03:15 -0700 Subject: [PATCH 043/580] remove Implied Extensions feature. Closes #1211 --- CHANGELOG.md | 1 + .../features/front-matter-neighbor.feature | 13 ---- middleman-core/features/front-matter.feature | 6 -- .../features/implied_extensions.feature | 69 ------------------- .../features/more-implied_extensions.feature | 50 -------------- .../source/{code.adoc => code.html.adoc} | 0 ...ribute.adoc => custom-attribute.html.adoc} | 0 .../{gallery.adoc => gallery.html.adoc} | 0 ...-layout.adoc => hello-no-layout.html.adoc} | 0 ...adoc => hello-with-front-matter.html.adoc} | 0 ...ayout.adoc => hello-with-layout.html.adoc} | 0 ...-title.adoc => hello-with-title.html.adoc} | 0 .../source/{hello.adoc => hello.html.adoc} | 0 .../source/{master.adoc => master.html.adoc} | 0 .../source/front-matter-auto.erb | 6 -- .../source/json-front-matter-auto.erb | 6 -- .../source/front-matter-auto.erb | 1 - .../source/front-matter-auto.erb.frontmatter | 4 -- .../source/json-front-matter-auto.erb | 1 - .../json-front-matter-auto.erb.frontmatter | 4 -- .../source/{index.haml => index.html.haml} | 0 .../localizable/{one.en.md => one.en.html.md} | 0 .../localizable/{one.es.md => one.es.html.md} | 0 .../fixtures/implied-extensions-app/config.rb | 0 .../implied-extensions-app/source/index.erb | 1 - .../more-implied-extensions-app/config.rb | 0 .../source/javascripts/app.coffee | 1 - .../source/layouts/layout.erb | 3 - .../source/stylesheets/style.scss | 3 - .../source/stylesheets/style2.sass | 3 - .../source/stylesheets/style3.less | 4 -- .../source/test.haml | 4 -- .../source/test2.markdown | 3 - .../source/test3.slim | 3 - .../source/test4.liquid | 1 - ...out.markdown => with_layout.html.markdown} | 0 ....erb => with_layout_erb.html.markdown.erb} | 0 .../lib/middleman-core/config_context.rb | 2 +- .../core_extensions/rendering.rb | 17 ----- .../lib/middleman-core/renderers/asciidoc.rb | 3 - .../middleman-core/renderers/coffee_script.rb | 1 - .../lib/middleman-core/renderers/erb.rb | 4 -- .../lib/middleman-core/renderers/haml.rb | 4 -- .../lib/middleman-core/renderers/less.rb | 4 -- .../lib/middleman-core/renderers/liquid.rb | 4 -- .../lib/middleman-core/renderers/markdown.rb | 8 --- .../lib/middleman-core/renderers/sass.rb | 5 -- .../lib/middleman-core/renderers/slim.rb | 4 -- .../lib/middleman-core/renderers/stylus.rb | 5 -- .../lib/middleman-core/sitemap/store.rb | 22 +----- 50 files changed, 3 insertions(+), 267 deletions(-) delete mode 100644 middleman-core/features/implied_extensions.feature delete mode 100644 middleman-core/features/more-implied_extensions.feature rename middleman-core/fixtures/asciidoc-app/source/{code.adoc => code.html.adoc} (100%) rename middleman-core/fixtures/asciidoc-app/source/{custom-attribute.adoc => custom-attribute.html.adoc} (100%) rename middleman-core/fixtures/asciidoc-app/source/{gallery.adoc => gallery.html.adoc} (100%) rename middleman-core/fixtures/asciidoc-app/source/{hello-no-layout.adoc => hello-no-layout.html.adoc} (100%) rename middleman-core/fixtures/asciidoc-app/source/{hello-with-front-matter.adoc => hello-with-front-matter.html.adoc} (100%) rename middleman-core/fixtures/asciidoc-app/source/{hello-with-layout.adoc => hello-with-layout.html.adoc} (100%) rename middleman-core/fixtures/asciidoc-app/source/{hello-with-title.adoc => hello-with-title.html.adoc} (100%) rename middleman-core/fixtures/asciidoc-app/source/{hello.adoc => hello.html.adoc} (100%) rename middleman-core/fixtures/asciidoc-app/source/{master.adoc => master.html.adoc} (100%) delete mode 100644 middleman-core/fixtures/frontmatter-app/source/front-matter-auto.erb delete mode 100644 middleman-core/fixtures/frontmatter-app/source/json-front-matter-auto.erb delete mode 100644 middleman-core/fixtures/frontmatter-neighbor-app/source/front-matter-auto.erb delete mode 100644 middleman-core/fixtures/frontmatter-neighbor-app/source/front-matter-auto.erb.frontmatter delete mode 100644 middleman-core/fixtures/frontmatter-neighbor-app/source/json-front-matter-auto.erb delete mode 100644 middleman-core/fixtures/frontmatter-neighbor-app/source/json-front-matter-auto.erb.frontmatter rename middleman-core/fixtures/i18n-force-locale/source/{index.haml => index.html.haml} (100%) rename middleman-core/fixtures/i18n-test-app/source/localizable/{one.en.md => one.en.html.md} (100%) rename middleman-core/fixtures/i18n-test-app/source/localizable/{one.es.md => one.es.html.md} (100%) delete mode 100644 middleman-core/fixtures/implied-extensions-app/config.rb delete mode 100644 middleman-core/fixtures/implied-extensions-app/source/index.erb delete mode 100644 middleman-core/fixtures/more-implied-extensions-app/config.rb delete mode 100644 middleman-core/fixtures/more-implied-extensions-app/source/javascripts/app.coffee delete mode 100644 middleman-core/fixtures/more-implied-extensions-app/source/layouts/layout.erb delete mode 100644 middleman-core/fixtures/more-implied-extensions-app/source/stylesheets/style.scss delete mode 100644 middleman-core/fixtures/more-implied-extensions-app/source/stylesheets/style2.sass delete mode 100644 middleman-core/fixtures/more-implied-extensions-app/source/stylesheets/style3.less delete mode 100644 middleman-core/fixtures/more-implied-extensions-app/source/test.haml delete mode 100644 middleman-core/fixtures/more-implied-extensions-app/source/test2.markdown delete mode 100644 middleman-core/fixtures/more-implied-extensions-app/source/test3.slim delete mode 100644 middleman-core/fixtures/more-implied-extensions-app/source/test4.liquid rename middleman-core/fixtures/more-markdown-app/source/{with_layout.markdown => with_layout.html.markdown} (100%) rename middleman-core/fixtures/more-markdown-app/source/{with_layout_erb.markdown.erb => with_layout_erb.html.markdown.erb} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02e856b3..6990fd72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ master === +* Removed "Implied Extension feature" * Remove 'upgrade' and 'install' CLI commands. * Gemfile may be in a parent directory of your Middleman project root (where 'config.rb' is). * All dependencies for your Middleman project must be expressed in `Gemfile` - Bundler is no longer optional. diff --git a/middleman-core/features/front-matter-neighbor.feature b/middleman-core/features/front-matter-neighbor.feature index b420cba0..f29c554e 100644 --- a/middleman-core/features/front-matter-neighbor.feature +++ b/middleman-core/features/front-matter-neighbor.feature @@ -2,11 +2,6 @@ Feature: Neighboring YAML Front Matter Scenario: Rendering html (yaml) Given the Server is running at "frontmatter-neighbor-app" - When I go to "/front-matter-auto.html" - Then I should see "

This is the title

" - Then I should not see "---" - When I go to "/front-matter-auto.erb.frontmatter" - Then I should see "File Not Found" When I go to "/front-matter-2.php" Then I should see "

This is the title

" Then I should see "This is the title" - Then I should not see ";;;" - When I go to "/json-front-matter-auto.erb.frontmatter" - Then I should see "File Not Found" - When I go to "/json-front-matter.html" - Then I should see "

This is the title

" - Then I should not see ";;;" When I go to "/json-front-matter.html.erb.frontmatter" Then I should see "File Not Found" When I go to "/json-front-matter-2.php" diff --git a/middleman-core/features/front-matter.feature b/middleman-core/features/front-matter.feature index a0440f55..1775bc36 100644 --- a/middleman-core/features/front-matter.feature +++ b/middleman-core/features/front-matter.feature @@ -3,9 +3,6 @@ Feature: YAML Front Matter Scenario: Rendering html (yaml) Given the Server is running at "frontmatter-app" - When I go to "/front-matter-auto.html" - Then I should see "

This is the title

" - Then I should not see "---" When I go to "/front-matter-2.php" Then I should see "

This is the title

" Then I should see "This is the title" - Then I should not see ";;;" When I go to "/json-front-matter.html" Then I should see "

This is the title

" Then I should not see ";;;" diff --git a/middleman-core/features/implied_extensions.feature b/middleman-core/features/implied_extensions.feature deleted file mode 100644 index 63d4e5c4..00000000 --- a/middleman-core/features/implied_extensions.feature +++ /dev/null @@ -1,69 +0,0 @@ -Feature: Use default extensions when user doesn't supply them - - Scenario: Default extensions preview - Given the Server is running at "implied-extensions-app" - When I go to "/" - Then I should see "hello: world" - When I go to "/index.html" - Then I should see "hello: world" - When I go to "/index.erb" - Then I should see "File Not Found" - When I go to "/index" - Then I should see "File Not Found" - - Scenario: Override erb extension - Given a fixture app "implied-extensions-app" - And a file named "config.rb" with: - """ - template_extensions :erb => :htm - """ - And the Server is running - When I go to "/" - Then I should see "File Not Found" - When I go to "/index.htm" - Then I should see "hello: world" - When I go to "/index.erb" - Then I should see "File Not Found" - When I go to "/index" - Then I should see "File Not Found" - When I go to "/index.html" - Then I should see "File Not Found" - - Scenario: Override erb extension - Given a fixture app "implied-extensions-app" - And a file named "config.rb" with: - """ - set :index_file, "index.htm" - template_extensions :erb => :htm - """ - And the Server is running - When I go to "/" - Then I should see "hello: world" - When I go to "/index.htm" - Then I should see "hello: world" - - Scenario: Default extensions build - Given a fixture app "implied-extensions-app" - And a successfully built app at "implied-extensions-app" - When I cd to "build" - Then the following files should exist: - | index.html | - Then the following files should not exist: - | index | - | index.erb | - And the file "index.html" should contain "hello: world" - - Scenario: Default extensions build with override - Given a fixture app "implied-extensions-app" - And a file named "config.rb" with: - """ - template_extensions :erb => :htm - """ - And a successfully built app at "implied-extensions-app" - When I cd to "build" - Then the following files should exist: - | index.htm | - Then the following files should not exist: - | index | - | index.erb | - | index.html | \ No newline at end of file diff --git a/middleman-core/features/more-implied_extensions.feature b/middleman-core/features/more-implied_extensions.feature deleted file mode 100644 index 31567443..00000000 --- a/middleman-core/features/more-implied_extensions.feature +++ /dev/null @@ -1,50 +0,0 @@ -Feature: More default extensions - - Scenario: Default extensions preview - Given the Server is running at "more-implied-extensions-app" - When I go to "/test.html" - Then I should see "Hello" - When I go to "/test2.html" - Then I should see "World" - When I go to "/test3.html" - Then I should see "Howdy" - When I go to "/test4.html" - Then I should see "HELLO" - When I go to "/javascripts/app.js" - Then I should see "derp" - Then I should not see "I am in the layout" - When I go to "/stylesheets/style.css" - Then I should see "section" - Then I should not see "I am in the layout" - When I go to "/stylesheets/style2.css" - Then I should see "section" - Then I should not see "I am in the layout" - When I go to "/stylesheets/style3.css" - Then I should see "color" - Then I should not see "I am in the layout" - - Scenario: Default extensions build - Given a fixture app "more-implied-extensions-app" - And a successfully built app at "more-implied-extensions-app" - When I cd to "build" - Then the following files should exist: - | test.html | - | test2.html | - | test3.html | - | test4.html | - | javascripts/app.js | - | stylesheets/style.css | - | stylesheets/style2.css | - | stylesheets/style3.css | - And the file "test.html" should contain "Hello" - And the file "test2.html" should contain "World" - And the file "test3.html" should contain "Howdy" - And the file "test4.html" should contain "HELLO" - And the file "javascripts/app.js" should contain "derp" - And the file "javascripts/app.js" should not contain "I am in the layout" - And the file "stylesheets/style.css" should contain "section" - And the file "stylesheets/style.css" should not contain "I am in the layout" - And the file "stylesheets/style2.css" should contain "section" - And the file "stylesheets/style2.css" should not contain "I am in the layout" - And the file "stylesheets/style3.css" should contain "color" - And the file "stylesheets/style3.css" should not contain "I am in the layout" \ No newline at end of file diff --git a/middleman-core/fixtures/asciidoc-app/source/code.adoc b/middleman-core/fixtures/asciidoc-app/source/code.html.adoc similarity index 100% rename from middleman-core/fixtures/asciidoc-app/source/code.adoc rename to middleman-core/fixtures/asciidoc-app/source/code.html.adoc diff --git a/middleman-core/fixtures/asciidoc-app/source/custom-attribute.adoc b/middleman-core/fixtures/asciidoc-app/source/custom-attribute.html.adoc similarity index 100% rename from middleman-core/fixtures/asciidoc-app/source/custom-attribute.adoc rename to middleman-core/fixtures/asciidoc-app/source/custom-attribute.html.adoc diff --git a/middleman-core/fixtures/asciidoc-app/source/gallery.adoc b/middleman-core/fixtures/asciidoc-app/source/gallery.html.adoc similarity index 100% rename from middleman-core/fixtures/asciidoc-app/source/gallery.adoc rename to middleman-core/fixtures/asciidoc-app/source/gallery.html.adoc diff --git a/middleman-core/fixtures/asciidoc-app/source/hello-no-layout.adoc b/middleman-core/fixtures/asciidoc-app/source/hello-no-layout.html.adoc similarity index 100% rename from middleman-core/fixtures/asciidoc-app/source/hello-no-layout.adoc rename to middleman-core/fixtures/asciidoc-app/source/hello-no-layout.html.adoc diff --git a/middleman-core/fixtures/asciidoc-app/source/hello-with-front-matter.adoc b/middleman-core/fixtures/asciidoc-app/source/hello-with-front-matter.html.adoc similarity index 100% rename from middleman-core/fixtures/asciidoc-app/source/hello-with-front-matter.adoc rename to middleman-core/fixtures/asciidoc-app/source/hello-with-front-matter.html.adoc diff --git a/middleman-core/fixtures/asciidoc-app/source/hello-with-layout.adoc b/middleman-core/fixtures/asciidoc-app/source/hello-with-layout.html.adoc similarity index 100% rename from middleman-core/fixtures/asciidoc-app/source/hello-with-layout.adoc rename to middleman-core/fixtures/asciidoc-app/source/hello-with-layout.html.adoc diff --git a/middleman-core/fixtures/asciidoc-app/source/hello-with-title.adoc b/middleman-core/fixtures/asciidoc-app/source/hello-with-title.html.adoc similarity index 100% rename from middleman-core/fixtures/asciidoc-app/source/hello-with-title.adoc rename to middleman-core/fixtures/asciidoc-app/source/hello-with-title.html.adoc diff --git a/middleman-core/fixtures/asciidoc-app/source/hello.adoc b/middleman-core/fixtures/asciidoc-app/source/hello.html.adoc similarity index 100% rename from middleman-core/fixtures/asciidoc-app/source/hello.adoc rename to middleman-core/fixtures/asciidoc-app/source/hello.html.adoc diff --git a/middleman-core/fixtures/asciidoc-app/source/master.adoc b/middleman-core/fixtures/asciidoc-app/source/master.html.adoc similarity index 100% rename from middleman-core/fixtures/asciidoc-app/source/master.adoc rename to middleman-core/fixtures/asciidoc-app/source/master.html.adoc diff --git a/middleman-core/fixtures/frontmatter-app/source/front-matter-auto.erb b/middleman-core/fixtures/frontmatter-app/source/front-matter-auto.erb deleted file mode 100644 index fcae7374..00000000 --- a/middleman-core/fixtures/frontmatter-app/source/front-matter-auto.erb +++ /dev/null @@ -1,6 +0,0 @@ ---- -layout: false -title: This is the title ---- - -

<%= current_page.data.title %>

diff --git a/middleman-core/fixtures/frontmatter-app/source/json-front-matter-auto.erb b/middleman-core/fixtures/frontmatter-app/source/json-front-matter-auto.erb deleted file mode 100644 index da001783..00000000 --- a/middleman-core/fixtures/frontmatter-app/source/json-front-matter-auto.erb +++ /dev/null @@ -1,6 +0,0 @@ -;;; - "layout": false, - "title": "This is the title" -;;; - -

<%= current_page.data.title %>

diff --git a/middleman-core/fixtures/frontmatter-neighbor-app/source/front-matter-auto.erb b/middleman-core/fixtures/frontmatter-neighbor-app/source/front-matter-auto.erb deleted file mode 100644 index 1ae95c52..00000000 --- a/middleman-core/fixtures/frontmatter-neighbor-app/source/front-matter-auto.erb +++ /dev/null @@ -1 +0,0 @@ -

<%= current_page.data.title %>

diff --git a/middleman-core/fixtures/frontmatter-neighbor-app/source/front-matter-auto.erb.frontmatter b/middleman-core/fixtures/frontmatter-neighbor-app/source/front-matter-auto.erb.frontmatter deleted file mode 100644 index 6227e9ef..00000000 --- a/middleman-core/fixtures/frontmatter-neighbor-app/source/front-matter-auto.erb.frontmatter +++ /dev/null @@ -1,4 +0,0 @@ ---- -layout: false -title: This is the title ---- diff --git a/middleman-core/fixtures/frontmatter-neighbor-app/source/json-front-matter-auto.erb b/middleman-core/fixtures/frontmatter-neighbor-app/source/json-front-matter-auto.erb deleted file mode 100644 index 1ae95c52..00000000 --- a/middleman-core/fixtures/frontmatter-neighbor-app/source/json-front-matter-auto.erb +++ /dev/null @@ -1 +0,0 @@ -

<%= current_page.data.title %>

diff --git a/middleman-core/fixtures/frontmatter-neighbor-app/source/json-front-matter-auto.erb.frontmatter b/middleman-core/fixtures/frontmatter-neighbor-app/source/json-front-matter-auto.erb.frontmatter deleted file mode 100644 index 415cefbc..00000000 --- a/middleman-core/fixtures/frontmatter-neighbor-app/source/json-front-matter-auto.erb.frontmatter +++ /dev/null @@ -1,4 +0,0 @@ -;;; - "layout": false, - "title": "This is the title" -;;; \ No newline at end of file diff --git a/middleman-core/fixtures/i18n-force-locale/source/index.haml b/middleman-core/fixtures/i18n-force-locale/source/index.html.haml similarity index 100% rename from middleman-core/fixtures/i18n-force-locale/source/index.haml rename to middleman-core/fixtures/i18n-force-locale/source/index.html.haml diff --git a/middleman-core/fixtures/i18n-test-app/source/localizable/one.en.md b/middleman-core/fixtures/i18n-test-app/source/localizable/one.en.html.md similarity index 100% rename from middleman-core/fixtures/i18n-test-app/source/localizable/one.en.md rename to middleman-core/fixtures/i18n-test-app/source/localizable/one.en.html.md diff --git a/middleman-core/fixtures/i18n-test-app/source/localizable/one.es.md b/middleman-core/fixtures/i18n-test-app/source/localizable/one.es.html.md similarity index 100% rename from middleman-core/fixtures/i18n-test-app/source/localizable/one.es.md rename to middleman-core/fixtures/i18n-test-app/source/localizable/one.es.html.md diff --git a/middleman-core/fixtures/implied-extensions-app/config.rb b/middleman-core/fixtures/implied-extensions-app/config.rb deleted file mode 100644 index e69de29b..00000000 diff --git a/middleman-core/fixtures/implied-extensions-app/source/index.erb b/middleman-core/fixtures/implied-extensions-app/source/index.erb deleted file mode 100644 index 89fb406c..00000000 --- a/middleman-core/fixtures/implied-extensions-app/source/index.erb +++ /dev/null @@ -1 +0,0 @@ -hello: <%= "world" %> \ No newline at end of file diff --git a/middleman-core/fixtures/more-implied-extensions-app/config.rb b/middleman-core/fixtures/more-implied-extensions-app/config.rb deleted file mode 100644 index e69de29b..00000000 diff --git a/middleman-core/fixtures/more-implied-extensions-app/source/javascripts/app.coffee b/middleman-core/fixtures/more-implied-extensions-app/source/javascripts/app.coffee deleted file mode 100644 index bd6d320d..00000000 --- a/middleman-core/fixtures/more-implied-extensions-app/source/javascripts/app.coffee +++ /dev/null @@ -1 +0,0 @@ -hello = (args...) -> "derp" \ No newline at end of file diff --git a/middleman-core/fixtures/more-implied-extensions-app/source/layouts/layout.erb b/middleman-core/fixtures/more-implied-extensions-app/source/layouts/layout.erb deleted file mode 100644 index ede19525..00000000 --- a/middleman-core/fixtures/more-implied-extensions-app/source/layouts/layout.erb +++ /dev/null @@ -1,3 +0,0 @@ -I am in the layout - -<%= yield %> \ No newline at end of file diff --git a/middleman-core/fixtures/more-implied-extensions-app/source/stylesheets/style.scss b/middleman-core/fixtures/more-implied-extensions-app/source/stylesheets/style.scss deleted file mode 100644 index d8847a80..00000000 --- a/middleman-core/fixtures/more-implied-extensions-app/source/stylesheets/style.scss +++ /dev/null @@ -1,3 +0,0 @@ -@import "compass"; - -@include global-reset; \ No newline at end of file diff --git a/middleman-core/fixtures/more-implied-extensions-app/source/stylesheets/style2.sass b/middleman-core/fixtures/more-implied-extensions-app/source/stylesheets/style2.sass deleted file mode 100644 index 661ca0a8..00000000 --- a/middleman-core/fixtures/more-implied-extensions-app/source/stylesheets/style2.sass +++ /dev/null @@ -1,3 +0,0 @@ -@import "compass" - -+global-reset \ No newline at end of file diff --git a/middleman-core/fixtures/more-implied-extensions-app/source/stylesheets/style3.less b/middleman-core/fixtures/more-implied-extensions-app/source/stylesheets/style3.less deleted file mode 100644 index 420d50d4..00000000 --- a/middleman-core/fixtures/more-implied-extensions-app/source/stylesheets/style3.less +++ /dev/null @@ -1,4 +0,0 @@ -@base: #f938ab; -.box { - color: @base; -} \ No newline at end of file diff --git a/middleman-core/fixtures/more-implied-extensions-app/source/test.haml b/middleman-core/fixtures/more-implied-extensions-app/source/test.haml deleted file mode 100644 index b79ea27c..00000000 --- a/middleman-core/fixtures/more-implied-extensions-app/source/test.haml +++ /dev/null @@ -1,4 +0,0 @@ -!!! -%html - %body - Hello \ No newline at end of file diff --git a/middleman-core/fixtures/more-implied-extensions-app/source/test2.markdown b/middleman-core/fixtures/more-implied-extensions-app/source/test2.markdown deleted file mode 100644 index 763a7558..00000000 --- a/middleman-core/fixtures/more-implied-extensions-app/source/test2.markdown +++ /dev/null @@ -1,3 +0,0 @@ -# Hello - -## World \ No newline at end of file diff --git a/middleman-core/fixtures/more-implied-extensions-app/source/test3.slim b/middleman-core/fixtures/more-implied-extensions-app/source/test3.slim deleted file mode 100644 index 69eaa720..00000000 --- a/middleman-core/fixtures/more-implied-extensions-app/source/test3.slim +++ /dev/null @@ -1,3 +0,0 @@ -html - body - | Howdy \ No newline at end of file diff --git a/middleman-core/fixtures/more-implied-extensions-app/source/test4.liquid b/middleman-core/fixtures/more-implied-extensions-app/source/test4.liquid deleted file mode 100644 index dab9ce8f..00000000 --- a/middleman-core/fixtures/more-implied-extensions-app/source/test4.liquid +++ /dev/null @@ -1 +0,0 @@ -{{ 'Hello' | upcase }} \ No newline at end of file diff --git a/middleman-core/fixtures/more-markdown-app/source/with_layout.markdown b/middleman-core/fixtures/more-markdown-app/source/with_layout.html.markdown similarity index 100% rename from middleman-core/fixtures/more-markdown-app/source/with_layout.markdown rename to middleman-core/fixtures/more-markdown-app/source/with_layout.html.markdown diff --git a/middleman-core/fixtures/more-markdown-app/source/with_layout_erb.markdown.erb b/middleman-core/fixtures/more-markdown-app/source/with_layout_erb.html.markdown.erb similarity index 100% rename from middleman-core/fixtures/more-markdown-app/source/with_layout_erb.markdown.erb rename to middleman-core/fixtures/more-markdown-app/source/with_layout_erb.html.markdown.erb diff --git a/middleman-core/lib/middleman-core/config_context.rb b/middleman-core/lib/middleman-core/config_context.rb index 40e7ef88..944ff2fb 100644 --- a/middleman-core/lib/middleman-core/config_context.rb +++ b/middleman-core/lib/middleman-core/config_context.rb @@ -6,7 +6,7 @@ module Middleman attr_reader :app # Whitelist methods that can reach out. - delegate :config, :logger, :activate, :use, :map, :mime_type, :data, :template_extensions, :root, :to => :app + delegate :config, :logger, :activate, :use, :map, :mime_type, :data, :root, :to => :app def initialize(app, template_context_class) @app = app diff --git a/middleman-core/lib/middleman-core/core_extensions/rendering.rb b/middleman-core/lib/middleman-core/core_extensions/rendering.rb index 12b8e734..a77f853f 100644 --- a/middleman-core/lib/middleman-core/core_extensions/rendering.rb +++ b/middleman-core/lib/middleman-core/core_extensions/rendering.rb @@ -11,9 +11,6 @@ module Middleman # Once registered def included(app) - # Include methods - app.send :include, InstanceMethods - app.define_hook :before_render app.define_hook :after_render @@ -98,20 +95,6 @@ module Middleman end end end - - # Rendering instance methods - module InstanceMethods - - # Add or overwrite a default template extension - # - # @param [Hash] extension_map - # @return [Hash] - def template_extensions(extension_map=nil) - @_template_extensions ||= {} - @_template_extensions.merge!(extension_map) if extension_map - @_template_extensions - end - end end end end diff --git a/middleman-core/lib/middleman-core/renderers/asciidoc.rb b/middleman-core/lib/middleman-core/renderers/asciidoc.rb index c58f7150..877d4f8f 100644 --- a/middleman-core/lib/middleman-core/renderers/asciidoc.rb +++ b/middleman-core/lib/middleman-core/renderers/asciidoc.rb @@ -12,9 +12,6 @@ module Middleman :attributes => %W(showtitle env=middleman env-middleman middleman-version=#{::Middleman::VERSION}) }, 'AsciiDoc engine options (Hash)' app.config.define_setting :asciidoc_attributes, [], 'AsciiDoc custom attributes (Array)' - app.before_configuration do - template_extensions :adoc => :html - end app.after_configuration do # QUESTION should base_dir be equal to docdir instead? diff --git a/middleman-core/lib/middleman-core/renderers/coffee_script.rb b/middleman-core/lib/middleman-core/renderers/coffee_script.rb index 92b30f38..3f87d1fa 100644 --- a/middleman-core/lib/middleman-core/renderers/coffee_script.rb +++ b/middleman-core/lib/middleman-core/renderers/coffee_script.rb @@ -16,7 +16,6 @@ module Middleman ::Tilt.prefer(DebuggingCoffeeScriptTemplate) app.before_configuration do - template_extensions :coffee => :js DebuggingCoffeeScriptTemplate.middleman_app = self end end diff --git a/middleman-core/lib/middleman-core/renderers/erb.rb b/middleman-core/lib/middleman-core/renderers/erb.rb index 87f91c82..89f93bac 100644 --- a/middleman-core/lib/middleman-core/renderers/erb.rb +++ b/middleman-core/lib/middleman-core/renderers/erb.rb @@ -7,10 +7,6 @@ module Middleman # once registered def registered(app) - app.before_configuration do - template_extensions :erb => :html - end - # After config app.after_configuration do ::Tilt.prefer(Template, :erb) diff --git a/middleman-core/lib/middleman-core/renderers/haml.rb b/middleman-core/lib/middleman-core/renderers/haml.rb index e561de13..fc450417 100644 --- a/middleman-core/lib/middleman-core/renderers/haml.rb +++ b/middleman-core/lib/middleman-core/renderers/haml.rb @@ -44,10 +44,6 @@ module Middleman def registered(app) ::Tilt.prefer(::Middleman::Renderers::HamlTemplate, 'haml') - app.before_configuration do - template_extensions :haml => :html - end - # Add haml helpers to context ::Middleman::TemplateContext.send :include, ::Haml::Helpers end diff --git a/middleman-core/lib/middleman-core/renderers/less.rb b/middleman-core/lib/middleman-core/renderers/less.rb index 2f560073..d09e1ac9 100644 --- a/middleman-core/lib/middleman-core/renderers/less.rb +++ b/middleman-core/lib/middleman-core/renderers/less.rb @@ -14,10 +14,6 @@ module Middleman # Default less options app.config.define_setting :less, {}, 'LESS compiler options' - app.before_configuration do - template_extensions :less => :css - end - app.after_configuration do ::Less.paths << File.join(source_dir, config[:css_dir]) end diff --git a/middleman-core/lib/middleman-core/renderers/liquid.rb b/middleman-core/lib/middleman-core/renderers/liquid.rb index 8bbac6ec..3596432e 100644 --- a/middleman-core/lib/middleman-core/renderers/liquid.rb +++ b/middleman-core/lib/middleman-core/renderers/liquid.rb @@ -12,10 +12,6 @@ module Middleman # Once registerd def registered(app) - app.before_configuration do - template_extensions :liquid => :html - end - # After config, setup liquid partial paths app.after_configuration do ::Liquid::Template.file_system = ::Liquid::LocalFileSystem.new(source_dir) diff --git a/middleman-core/lib/middleman-core/renderers/markdown.rb b/middleman-core/lib/middleman-core/renderers/markdown.rb index 57272896..90889edb 100644 --- a/middleman-core/lib/middleman-core/renderers/markdown.rb +++ b/middleman-core/lib/middleman-core/renderers/markdown.rb @@ -13,14 +13,6 @@ module Middleman app.config.define_setting :markdown_engine, :kramdown, 'Preferred markdown engine' app.config.define_setting :markdown_engine_prefix, ::Tilt, 'The parent module for markdown template engines' - app.before_configuration do - template_extensions :markdown => :html, - :mdown => :html, - :md => :html, - :mkd => :html, - :mkdn => :html - end - # Once configuration is parsed app.after_configuration do markdown_exts = %w(markdown mdown md mkd mkdn) diff --git a/middleman-core/lib/middleman-core/renderers/sass.rb b/middleman-core/lib/middleman-core/renderers/sass.rb index bd38722a..498afbc3 100644 --- a/middleman-core/lib/middleman-core/renderers/sass.rb +++ b/middleman-core/lib/middleman-core/renderers/sass.rb @@ -14,11 +14,6 @@ module Middleman # Default sass options app.config.define_setting :sass, {}, 'Sass engine options' - app.before_configuration do - template_extensions :scss => :css, - :sass => :css - end - # Tell Tilt to use it as well (for inline sass blocks) ::Tilt.register 'sass', SassPlusCSSFilenameTemplate ::Tilt.prefer(SassPlusCSSFilenameTemplate) diff --git a/middleman-core/lib/middleman-core/renderers/slim.rb b/middleman-core/lib/middleman-core/renderers/slim.rb index f9f6a28f..c10727ef 100644 --- a/middleman-core/lib/middleman-core/renderers/slim.rb +++ b/middleman-core/lib/middleman-core/renderers/slim.rb @@ -26,10 +26,6 @@ module Middleman # Once registered def registered(app) - app.before_configuration do - template_extensions :slim => :html - end - # Setup Slim options to work with partials ::Slim::Engine.set_default_options( :buffer => '@_out_buf', diff --git a/middleman-core/lib/middleman-core/renderers/stylus.rb b/middleman-core/lib/middleman-core/renderers/stylus.rb index 72a4cba8..6fbdb455 100644 --- a/middleman-core/lib/middleman-core/renderers/stylus.rb +++ b/middleman-core/lib/middleman-core/renderers/stylus.rb @@ -14,11 +14,6 @@ module Middleman def registered(app) # Default stylus options app.config.define_setting :styl, {}, 'Stylus config options' - - - app.before_configuration do - template_extensions :styl => :css - end end alias :included :registered diff --git a/middleman-core/lib/middleman-core/sitemap/store.rb b/middleman-core/lib/middleman-core/sitemap/store.rb index 0dc16267..217fa6c3 100644 --- a/middleman-core/lib/middleman-core/sitemap/store.rb +++ b/middleman-core/lib/middleman-core/sitemap/store.rb @@ -205,11 +205,7 @@ module Middleman # @return [String] def extensionless_path(file) path = file.dup - path = remove_templating_extensions(path) - - # If there is no extension, look for one - path = find_extension(path, file) if File.extname(strip_away_locale(path)).empty? - path + remove_templating_extensions(path) end # Actually update the resource list, assuming anything has called @@ -271,22 +267,6 @@ module Middleman path end - - # Finds an extension for path according to file's extension - # @param [String] path without extension - # @param [String] file path with original extensions - def find_extension(path, file) - input_ext = File.extname(file) - - if !input_ext.empty? - input_ext = input_ext.split('.').last.to_sym - if @app.template_extensions.has_key?(input_ext) - path << ".#{@app.template_extensions[input_ext]}" - end - end - - path - end end end end From ad147662780b6af454df00170f28f46e85d5b3a7 Mon Sep 17 00:00:00 2001 From: Karl Freeman Date: Mon, 24 Mar 2014 10:29:21 +0000 Subject: [PATCH 044/580] Although equivalent, clearer for non-*nix based systems --- middleman-templates/lib/middleman-templates/local.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/middleman-templates/lib/middleman-templates/local.rb b/middleman-templates/lib/middleman-templates/local.rb index d9a9711a..368c4075 100644 --- a/middleman-templates/lib/middleman-templates/local.rb +++ b/middleman-templates/lib/middleman-templates/local.rb @@ -1,9 +1,9 @@ # Local templates class Middleman::Templates::Local < Middleman::Templates::Base - # Look for templates in ~/.middleman + # Look for templates inside .middleman in the user's home directory # @return [String] def self.source_root - File.join(File.expand_path('~/'), '.middleman') + File.join(Dir.home, '.middleman') end # Just copy from the template path From 845d529a50af33626eb0118b32b608898d2f08d7 Mon Sep 17 00:00:00 2001 From: Karl Freeman Date: Tue, 25 Mar 2014 08:21:53 +0000 Subject: [PATCH 045/580] don't load local templates if no HOME is set --- .../lib/middleman-templates.rb | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/middleman-templates/lib/middleman-templates.rb b/middleman-templates/lib/middleman-templates.rb index 2e8a343c..65ca0a43 100644 --- a/middleman-templates/lib/middleman-templates.rb +++ b/middleman-templates/lib/middleman-templates.rb @@ -88,16 +88,19 @@ end # Register all official templates Dir.glob(File.expand_path('../middleman-templates/*.rb', __FILE__), &method(:require)) -# Iterate over directories in the templates path and register each one. -Dir[File.join(Middleman::Templates::Local.source_root, '*')].each do |dir| - next unless File.directory?(dir) - template_file = File.join(dir, 'template.rb') +# Sometimes HOME doesn't exist, in which case there's no point to local templates +if ENV['HOME'] + # Iterate over directories in the templates path and register each one. + Dir[File.join(Middleman::Templates::Local.source_root, '*')].each do |dir| + next unless File.directory?(dir) + template_file = File.join(dir, 'template.rb') - # If a template.rb file is found require it (therefore registering the template) - # else register the folder as a Local template (which when built, just copies the folder) - if File.exists?(template_file) - require template_file - else - Middleman::Templates.register(File.basename(dir).to_sym, Middleman::Templates::Local) + # If a template.rb file is found require it (therefore registering the template) + # else register the folder as a Local template (which when built, just copies the folder) + if File.exists?(template_file) + require template_file + else + Middleman::Templates.register(File.basename(dir).to_sym, Middleman::Templates::Local) + end end -end +end \ No newline at end of file From c1ef5fc2bf7a29ec6212209238368f1c574b9878 Mon Sep 17 00:00:00 2001 From: Karl Freeman Date: Tue, 25 Mar 2014 08:35:33 +0000 Subject: [PATCH 046/580] refresh travis - indicate that we're keen on caching - test against a larger variety of ruby interpreters however, lets allow some failures - not allow 2.1 to fail? --- .travis.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 520228b1..72b2e475 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,24 @@ language: ruby +cache: bundler +env: TEST=true bundler_args: --without development +before_install: git submodule update --init --recursive rvm: - ruby-head + - ruby + - jruby-head + - jruby + - jruby-19mode - 2.1.0 - 2.0.0 - 1.9.3 - - jruby-19mode + - rbx-2 matrix: fast_finish: true allow_failures: - rvm: ruby-head - - rvm: 2.1.0 + - rvm: ruby + - rvm: jruby-head + - rvm: jruby - rvm: jruby-19mode -env: TEST=true -before_install: git submodule update --init --recursive -script: bundle exec rake test \ No newline at end of file + - rvm: rbx-2 \ No newline at end of file From c5609dc889982cfef68f4bf1f8ad88ae7d0d4383 Mon Sep 17 00:00:00 2001 From: Karl Freeman Date: Tue, 25 Mar 2014 08:46:03 +0000 Subject: [PATCH 047/580] up to date --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6990fd72..40fc0b49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ master === +* Prevent local templates being loaded when $HOME is not set * Removed "Implied Extension feature" * Remove 'upgrade' and 'install' CLI commands. * Gemfile may be in a parent directory of your Middleman project root (where 'config.rb' is). From ce83e502f6865207de096ef7a61d28929860fca4 Mon Sep 17 00:00:00 2001 From: Karl Freeman Date: Tue, 25 Mar 2014 08:50:28 +0000 Subject: [PATCH 048/580] more consistency across all gems - rubocop'd for cosmetics --- middleman-cli/middleman-cli.gemspec | 24 +++++----- middleman-core/middleman-core.gemspec | 35 +++++++------- .../middleman-templates.gemspec | 24 +++++----- middleman/middleman.gemspec | 46 +++++++++---------- 4 files changed, 65 insertions(+), 64 deletions(-) diff --git a/middleman-cli/middleman-cli.gemspec b/middleman-cli/middleman-cli.gemspec index 5d9c1b90..40a1af26 100644 --- a/middleman-cli/middleman-cli.gemspec +++ b/middleman-cli/middleman-cli.gemspec @@ -1,24 +1,24 @@ # -*- encoding: utf-8 -*- -$:.push File.expand_path("../lib", __FILE__) -require File.expand_path("../../middleman-core/lib/middleman-core/version.rb", __FILE__) +$LOAD_PATH.push File.expand_path('../lib', __FILE__) +require File.expand_path('../../middleman-core/lib/middleman-core/version.rb', __FILE__) Gem::Specification.new do |s| - s.name = "middleman-cli" + s.name = 'middleman-cli' s.version = Middleman::VERSION s.platform = Gem::Platform::RUBY - s.license = "MIT" - s.authors = ["Thomas Reynolds", "Ben Hollis"] - s.email = ["me@tdreyno.com", "ben@benhollis.net"] - s.homepage = "http://middlemanapp.com" - s.summary = "Hand-crafted frontend development" - s.description = "A static site generator. Provides dozens of templating languages (Haml, Sass, Compass, Slim, CoffeeScript, and more). Makes minification, compression, cache busting, Yaml data (and more) an easy part of your development cycle." + s.license = 'MIT' + s.authors = ['Thomas Reynolds', 'Ben Hollis'] + s.email = ['me@tdreyno.com', 'ben@benhollis.net'] + s.homepage = 'http://middlemanapp.com' + s.summary = 'Hand-crafted frontend development' + s.description = 'A static site generator. Provides dozens of templating languages (Haml, Sass, Compass, Slim, CoffeeScript, and more). Makes minification, compression, cache busting, Yaml data (and more) an easy part of your development cycle.' s.files = `git ls-files -z`.split("\0") s.test_files = `git ls-files -z -- {fixtures,features}/*`.split("\0") - s.executable = "middleman" - s.require_path = "lib" + s.executable = 'middleman' + s.require_path = 'lib' s.required_ruby_version = '>= 1.9.3' # CLI - s.add_dependency("thor", [">= 0.17.0", "< 2.0"]) + s.add_dependency('thor', ['>= 0.17.0', '< 2.0']) end diff --git a/middleman-core/middleman-core.gemspec b/middleman-core/middleman-core.gemspec index f1fac373..3545a8ee 100644 --- a/middleman-core/middleman-core.gemspec +++ b/middleman-core/middleman-core.gemspec @@ -1,35 +1,36 @@ # -*- encoding: utf-8 -*- -require File.expand_path("../lib/middleman-core/version", __FILE__) +$LOAD_PATH.push File.expand_path('../lib', __FILE__) +require File.expand_path('../lib/middleman-core/version', __FILE__) Gem::Specification.new do |s| - s.name = "middleman-core" + s.name = 'middleman-core' s.version = Middleman::VERSION s.platform = Gem::Platform::RUBY - s.license = "MIT" - s.authors = ["Thomas Reynolds", "Ben Hollis"] - s.email = ["me@tdreyno.com", "ben@benhollis.net"] - s.homepage = "http://middlemanapp.com" - s.summary = "Hand-crafted frontend development" - s.description = "A static site generator. Provides dozens of templating languages (Haml, Sass, Compass, Slim, CoffeeScript, and more). Makes minification, compression, cache busting, Yaml data (and more) an easy part of your development cycle." + s.license = 'MIT' + s.authors = ['Thomas Reynolds', 'Ben Hollis'] + s.email = ['me@tdreyno.com', 'ben@benhollis.net'] + s.homepage = 'http://middlemanapp.com' + s.summary = 'Hand-crafted frontend development' + s.description = 'A static site generator. Provides dozens of templating languages (Haml, Sass, Compass, Slim, CoffeeScript, and more). Makes minification, compression, cache busting, Yaml data (and more) an easy part of your development cycle.' s.files = `git ls-files -z`.split("\0") s.test_files = `git ls-files -z -- {fixtures,features}/*`.split("\0") - s.require_path = "lib" + s.require_path = 'lib' s.required_ruby_version = '>= 1.9.3' # Core - s.add_dependency("bundler", ["~> 1.1"]) - s.add_dependency("rack", [">= 1.4.5"]) - s.add_dependency("tilt", ["~> 1.4.1"]) - s.add_dependency("erubis") - s.add_dependency("hooks", ["~> 0.3"]) + s.add_dependency('bundler', ['~> 1.1']) + s.add_dependency('rack', ['>= 1.4.5']) + s.add_dependency('tilt', ['~> 1.4.1']) + s.add_dependency('erubis') + s.add_dependency('hooks', ['~> 0.3']) # Helpers - s.add_dependency("activesupport", ["~> 4.0.1"]) + s.add_dependency('activesupport', ['~> 4.0.1']) # Watcher - s.add_dependency("listen", ["~> 1.3"]) + s.add_dependency('listen', ['~> 1.3']) # i18n - s.add_dependency("i18n", ["~> 0.6.9"]) + s.add_dependency('i18n', ['~> 0.6.9']) end diff --git a/middleman-templates/middleman-templates.gemspec b/middleman-templates/middleman-templates.gemspec index c61150b4..5ecbca4f 100644 --- a/middleman-templates/middleman-templates.gemspec +++ b/middleman-templates/middleman-templates.gemspec @@ -1,24 +1,24 @@ # -*- encoding: utf-8 -*- -$:.push File.expand_path("../lib", __FILE__) -require File.expand_path("../../middleman-core/lib/middleman-core/version.rb", __FILE__) +$LOAD_PATH.push File.expand_path('../lib', __FILE__) +require File.expand_path('../../middleman-core/lib/middleman-core/version.rb', __FILE__) Gem::Specification.new do |s| - s.name = "middleman-templates" + s.name = 'middleman-templates' s.version = Middleman::VERSION s.platform = Gem::Platform::RUBY - s.license = "MIT" - s.authors = ["Thomas Reynolds", "Ben Hollis", "Karl Freeman"] - s.email = ["me@tdreyno.com", "ben@benhollis.net", "karlfreeman@gmail.com"] - s.homepage = "http://middlemanapp.com" - s.summary = "Hand-crafted frontend development" - s.description = "A static site generator. Provides dozens of templating languages (Haml, Sass, Compass, Slim, CoffeeScript, and more). Makes minification, compression, cache busting, Yaml data (and more) an easy part of your development cycle." + s.license = 'MIT' + s.authors = ['Thomas Reynolds', 'Ben Hollis', 'Karl Freeman'] + s.email = ['me@tdreyno.com', 'ben@benhollis.net', 'karlfreeman@gmail.com'] + s.homepage = 'http://middlemanapp.com' + s.summary = 'Hand-crafted frontend development' + s.description = 'A static site generator. Provides dozens of templating languages (Haml, Sass, Compass, Slim, CoffeeScript, and more). Makes minification, compression, cache busting, Yaml data (and more) an easy part of your development cycle.' s.files = `git ls-files -z`.split("\0") s.test_files = `git ls-files -z -- {fixtures,features}/*`.split("\0") - s.executable = "middleman" - s.require_path = "lib" + s.executable = 'middleman' + s.require_path = 'lib' s.required_ruby_version = '>= 1.9.3' # Templates - s.add_dependency("thor", [">= 0.17.0", "< 2.0"]) + s.add_dependency('thor', ['>= 0.17.0', '< 2.0']) end diff --git a/middleman/middleman.gemspec b/middleman/middleman.gemspec index 5fa6f558..d8803faa 100644 --- a/middleman/middleman.gemspec +++ b/middleman/middleman.gemspec @@ -1,32 +1,32 @@ # -*- encoding: utf-8 -*- -$:.push File.expand_path("../lib", __FILE__) -require File.expand_path("../../middleman-core/lib/middleman-core/version.rb", __FILE__) +$LOAD_PATH.push File.expand_path('../lib', __FILE__) +require File.expand_path('../../middleman-core/lib/middleman-core/version.rb', __FILE__) Gem::Specification.new do |s| - s.name = "middleman" + s.name = 'middleman' s.version = Middleman::VERSION s.platform = Gem::Platform::RUBY - s.license = "MIT" - s.authors = ["Thomas Reynolds", "Ben Hollis"] - s.email = ["me@tdreyno.com", "ben@benhollis.net"] - s.homepage = "http://middlemanapp.com" - s.summary = "Hand-crafted frontend development" - s.description = "A static site generator. Provides dozens of templating languages (Haml, Sass, Compass, Slim, CoffeeScript, and more). Makes minification, compression, cache busting, Yaml data (and more) an easy part of your development cycle." + s.license = 'MIT' + s.authors = ['Thomas Reynolds', 'Ben Hollis'] + s.email = ['me@tdreyno.com', 'ben@benhollis.net'] + s.homepage = 'http://middlemanapp.com' + s.summary = 'Hand-crafted frontend development' + s.description = 'A static site generator. Provides dozens of templating languages (Haml, Sass, Compass, Slim, CoffeeScript, and more). Makes minification, compression, cache busting, Yaml data (and more) an easy part of your development cycle.' - s.files = `git ls-files -z`.split("\0") - s.test_files = `git ls-files -z -- {fixtures,features}/*`.split("\0") - s.require_paths = ["lib"] + s.files = `git ls-files -z`.split("\0") + s.test_files = `git ls-files -z -- {fixtures,features}/*`.split("\0") + s.require_path = 'lib' s.required_ruby_version = '>= 1.9.3' - s.add_dependency("middleman-core", Middleman::VERSION) - s.add_dependency("middleman-cli", Middleman::VERSION) - s.add_dependency("middleman-templates", Middleman::VERSION) - s.add_dependency("middleman-sprockets", ">= 3.1.2") - s.add_dependency("haml", [">= 3.1.6"]) - s.add_dependency("sass", [">= 3.1.20"]) - s.add_dependency("compass", [">= 0.12.2"]) - s.add_dependency("uglifier", ["~> 2.4.0"]) - s.add_dependency("coffee-script", ["~> 2.2.0"]) - s.add_dependency("execjs", ["~> 2.0.2"]) - s.add_dependency("kramdown", ["~> 1.2"]) + s.add_dependency('middleman-core', Middleman::VERSION) + s.add_dependency('middleman-cli', Middleman::VERSION) + s.add_dependency('middleman-templates', Middleman::VERSION) + s.add_dependency('middleman-sprockets', '>= 3.1.2') + s.add_dependency('haml', ['>= 3.1.6']) + s.add_dependency('sass', ['>= 3.1.20']) + s.add_dependency('compass', ['>= 0.12.2']) + s.add_dependency('uglifier', ['~> 2.4.0']) + s.add_dependency('coffee-script', ['~> 2.2.0']) + s.add_dependency('execjs', ['~> 2.0.2']) + s.add_dependency('kramdown', ['~> 1.2']) end From 1de871a57bd6c0ca4afa92472b358a4e6719c634 Mon Sep 17 00:00:00 2001 From: Karl Freeman Date: Tue, 25 Mar 2014 09:07:27 +0000 Subject: [PATCH 049/580] not needed --- middleman-cli/middleman-cli.gemspec | 2 +- middleman-templates/middleman-templates.gemspec | 2 +- middleman/middleman.gemspec | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/middleman-cli/middleman-cli.gemspec b/middleman-cli/middleman-cli.gemspec index 40a1af26..05f5c456 100644 --- a/middleman-cli/middleman-cli.gemspec +++ b/middleman-cli/middleman-cli.gemspec @@ -1,6 +1,6 @@ # -*- encoding: utf-8 -*- $LOAD_PATH.push File.expand_path('../lib', __FILE__) -require File.expand_path('../../middleman-core/lib/middleman-core/version.rb', __FILE__) +require File.expand_path('../../middleman-core/lib/middleman-core/version', __FILE__) Gem::Specification.new do |s| s.name = 'middleman-cli' diff --git a/middleman-templates/middleman-templates.gemspec b/middleman-templates/middleman-templates.gemspec index 5ecbca4f..d3f94284 100644 --- a/middleman-templates/middleman-templates.gemspec +++ b/middleman-templates/middleman-templates.gemspec @@ -1,6 +1,6 @@ # -*- encoding: utf-8 -*- $LOAD_PATH.push File.expand_path('../lib', __FILE__) -require File.expand_path('../../middleman-core/lib/middleman-core/version.rb', __FILE__) +require File.expand_path('../../middleman-core/lib/middleman-core/version', __FILE__) Gem::Specification.new do |s| s.name = 'middleman-templates' diff --git a/middleman/middleman.gemspec b/middleman/middleman.gemspec index d8803faa..7fc4d005 100644 --- a/middleman/middleman.gemspec +++ b/middleman/middleman.gemspec @@ -1,6 +1,6 @@ # -*- encoding: utf-8 -*- $LOAD_PATH.push File.expand_path('../lib', __FILE__) -require File.expand_path('../../middleman-core/lib/middleman-core/version.rb', __FILE__) +require File.expand_path('../../middleman-core/lib/middleman-core/version', __FILE__) Gem::Specification.new do |s| s.name = 'middleman' From 283583629e3fbf3a0dade76718a709558ec13713 Mon Sep 17 00:00:00 2001 From: Karl Freeman Date: Tue, 25 Mar 2014 09:53:21 +0000 Subject: [PATCH 050/580] svg badges [ci skip] --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6daf2a00..d1ea8f67 100644 --- a/README.md +++ b/README.md @@ -62,11 +62,11 @@ Additionally, up-to-date generated code documentation is available on [RubyDoc]. ## Build & Dependency Status -[![Gem Version](https://badge.fury.io/rb/middleman.png)][gem] -[![Build Status](https://travis-ci.org/middleman/middleman.png)][travis] -[![Code Coverage](https://coveralls.io/repos/middleman/middleman/badge.png)][coveralls] -[![Dependency Status](https://gemnasium.com/middleman/middleman.png?travis)][gemnasium] -[![Code Quality](https://codeclimate.com/github/middleman/middleman.png)][codeclimate] +[![Gem Version](http://img.shields.io/gem/v/middleman.svg)][gem] +[![Build Status](http://img.shields.io/travis/middleman/middleman.svg)][travis] +[![Code Coverage](http://img.shields.io/coveralls/middleman/middleman.svg)][coveralls] +[![Dependency Status](http://img.shields.io/gemnasium/middleman/middleman.svg)][gemnasium] +[![Code Quality](http://img.shields.io/codeclimate/github/middleman/middleman.svg)][codeclimate] ## Community From 57534b6e7cce236b64680899b0aab7a79cf4ed96 Mon Sep 17 00:00:00 2001 From: Karl Freeman Date: Tue, 25 Mar 2014 10:06:36 +0000 Subject: [PATCH 051/580] rubocop'd Gemfile - add rubocop as a development dependency --- Gemfile | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/Gemfile b/Gemfile index b34490ca..394fdd83 100644 --- a/Gemfile +++ b/Gemfile @@ -1,29 +1,29 @@ source 'https://rubygems.org' # Build and doc tools -gem 'rake', '~> 10.0.3', :require => false -gem 'yard', '~> 0.8.0', :require => false +gem 'rake', '~> 10.0.3', require: false +gem 'yard', '~> 0.8.0', require: false # Test tools gem 'cucumber', '~> 1.3.1' gem 'fivemat' -gem 'aruba', '~> 0.5.1' -gem 'rspec', '~> 2.12' +gem 'aruba', '~> 0.5.1' +gem 'rspec', '~> 2.12' gem 'simplecov' # Optional middleman dependencies, included for tests -gem 'haml', '~> 4.0.0', :require => false # Make sure to use Haml 4 for tests -gem 'sinatra', :require => false -gem 'slim', :require => false -gem 'liquid', :require => false -gem 'less', '~> 2.3.0', :require => false -gem 'stylus', :require => false -gem 'asciidoctor', :require => false +gem 'haml', '~> 4.0.0', require: false # Make sure to use Haml 4 for tests +gem 'sinatra', require: false +gem 'slim', require: false +gem 'liquid', require: false +gem 'less', '~> 2.3.0', require: false +gem 'stylus', require: false +gem 'asciidoctor', require: false platforms :ruby do gem 'therubyracer' gem 'redcarpet', '~> 3.1' - gem 'pry', :require => false, :group => :development + gem 'pry', require: false, group: :development end platforms :jruby do @@ -31,13 +31,13 @@ platforms :jruby do end # Code Quality -gem 'cane', :platforms => [:mri_19, :mri_20], :require => false -gem 'coveralls', :require => false -gem 'rubocop', :require => false +gem 'cane', platforms: [:mri_19, :mri_20], require: false +gem 'coveralls', require: false +gem 'rubocop', require: false, group: :development # Middleman itself -gem 'middleman-core', :path => 'middleman-core' -gem 'middleman-cli', :path => 'middleman-cli' -gem 'middleman-templates', :path => 'middleman-templates' -gem 'middleman-sprockets', :github => 'middleman/middleman-sprockets', :require => false -gem 'middleman', :path => 'middleman' +gem 'middleman-core', path: 'middleman-core' +gem 'middleman-cli', path: 'middleman-cli' +gem 'middleman-templates', path: 'middleman-templates' +gem 'middleman-sprockets', github: 'middleman/middleman-sprockets', require: false +gem 'middleman', path: 'middleman' From 174c04d5c82894b303b092e9d581fede12cb20cc Mon Sep 17 00:00:00 2001 From: Karl Freeman Date: Tue, 25 Mar 2014 10:09:51 +0000 Subject: [PATCH 052/580] consistency with other gems [ci skip] --- middleman/.simplecov | 5 +++++ middleman/.yardopts | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 middleman/.simplecov create mode 100644 middleman/.yardopts diff --git a/middleman/.simplecov b/middleman/.simplecov new file mode 100644 index 00000000..3720cc52 --- /dev/null +++ b/middleman/.simplecov @@ -0,0 +1,5 @@ +SimpleCov.start do + add_filter '/fixtures/' + add_filter '/features/' + add_filter '/spec/' +end \ No newline at end of file diff --git a/middleman/.yardopts b/middleman/.yardopts new file mode 100644 index 00000000..cfbcbd78 --- /dev/null +++ b/middleman/.yardopts @@ -0,0 +1,3 @@ +lib/**/*.rb +--no-private +--hide-void-return \ No newline at end of file From 5a38827b012f47bd971c0c3584efab9d77501346 Mon Sep 17 00:00:00 2001 From: Karl Freeman Date: Tue, 25 Mar 2014 12:06:31 +0000 Subject: [PATCH 053/580] middleman-templates has no executable [ci skip] --- middleman-templates/middleman-templates.gemspec | 1 - 1 file changed, 1 deletion(-) diff --git a/middleman-templates/middleman-templates.gemspec b/middleman-templates/middleman-templates.gemspec index d3f94284..ee0bcde0 100644 --- a/middleman-templates/middleman-templates.gemspec +++ b/middleman-templates/middleman-templates.gemspec @@ -15,7 +15,6 @@ Gem::Specification.new do |s| s.files = `git ls-files -z`.split("\0") s.test_files = `git ls-files -z -- {fixtures,features}/*`.split("\0") - s.executable = 'middleman' s.require_path = 'lib' s.required_ruby_version = '>= 1.9.3' From f4bcfc885a8a5ac6e767c580787594605571e2ad Mon Sep 17 00:00:00 2001 From: Karl Freeman Date: Tue, 25 Mar 2014 13:09:38 +0000 Subject: [PATCH 054/580] lose the empty files, keep the directory --- middleman-cli/spec/middleman/.gitkeep | 1 + middleman-cli/spec/middleman/future_spec.rb | 0 middleman/spec/middleman/.gitkeep | 1 + middleman/spec/middleman/future_spec.rb | 0 4 files changed, 2 insertions(+) create mode 100644 middleman-cli/spec/middleman/.gitkeep delete mode 100644 middleman-cli/spec/middleman/future_spec.rb create mode 100644 middleman/spec/middleman/.gitkeep delete mode 100644 middleman/spec/middleman/future_spec.rb diff --git a/middleman-cli/spec/middleman/.gitkeep b/middleman-cli/spec/middleman/.gitkeep new file mode 100644 index 00000000..45adbb22 --- /dev/null +++ b/middleman-cli/spec/middleman/.gitkeep @@ -0,0 +1 @@ +.gitkeep \ No newline at end of file diff --git a/middleman-cli/spec/middleman/future_spec.rb b/middleman-cli/spec/middleman/future_spec.rb deleted file mode 100644 index e69de29b..00000000 diff --git a/middleman/spec/middleman/.gitkeep b/middleman/spec/middleman/.gitkeep new file mode 100644 index 00000000..45adbb22 --- /dev/null +++ b/middleman/spec/middleman/.gitkeep @@ -0,0 +1 @@ +.gitkeep \ No newline at end of file diff --git a/middleman/spec/middleman/future_spec.rb b/middleman/spec/middleman/future_spec.rb deleted file mode 100644 index e69de29b..00000000 From 04d9ecbb5a2501dfa7e049723eeea2c7c43d6fa5 Mon Sep 17 00:00:00 2001 From: Karl Freeman Date: Tue, 25 Mar 2014 13:09:54 +0000 Subject: [PATCH 055/580] ignore tempts from Rubocop --- .rubocop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.rubocop.yml b/.rubocop.yml index fb5fd96a..7789d6c2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -13,6 +13,7 @@ AllCops: - middleman-core/fixtures/** - middleman-core/features/** - middleman-core/spec/** + - middleman-templates/lib/middleman-templates/** LineLength: Enabled: false MethodLength: From 6c84ed46746aa3a2cb9be2cf977da5dd03ad9e9d Mon Sep 17 00:00:00 2001 From: Karl Freeman Date: Tue, 25 Mar 2014 13:13:36 +0000 Subject: [PATCH 056/580] whitespace [ci skip] --- middleman-cli/Rakefile | 1 - middleman-core/Rakefile | 2 -- middleman-templates/Rakefile | 1 - middleman/Rakefile | 1 - 4 files changed, 5 deletions(-) diff --git a/middleman-cli/Rakefile b/middleman-cli/Rakefile index f1f8c51e..a7cd6621 100644 --- a/middleman-cli/Rakefile +++ b/middleman-cli/Rakefile @@ -1,5 +1,4 @@ # coding:utf-8 RAKE_ROOT = __FILE__ - GEM_NAME = 'middleman-cli' require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper') diff --git a/middleman-core/Rakefile b/middleman-core/Rakefile index 6e3c4ee8..c36c1d35 100644 --- a/middleman-core/Rakefile +++ b/middleman-core/Rakefile @@ -1,7 +1,5 @@ # coding:utf-8 RAKE_ROOT = __FILE__ - GEM_NAME = ENV['NAME'] || 'middleman-core' - require 'rubygems' require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper') diff --git a/middleman-templates/Rakefile b/middleman-templates/Rakefile index f5cda569..7fc3d2c0 100644 --- a/middleman-templates/Rakefile +++ b/middleman-templates/Rakefile @@ -1,5 +1,4 @@ # coding:utf-8 RAKE_ROOT = __FILE__ - GEM_NAME = 'middleman-templates' require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper') diff --git a/middleman/Rakefile b/middleman/Rakefile index 120b9c7c..034f3633 100644 --- a/middleman/Rakefile +++ b/middleman/Rakefile @@ -1,5 +1,4 @@ # coding:utf-8 RAKE_ROOT = __FILE__ - GEM_NAME = 'middleman' require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper') From d3e9108f12e7f9ea2aa94b2cc3e3cb0e3e7776aa Mon Sep 17 00:00:00 2001 From: Karl Freeman Date: Tue, 25 Mar 2014 13:19:31 +0000 Subject: [PATCH 057/580] already ignored [ci skip] --- middleman.sublime-project | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 middleman.sublime-project diff --git a/middleman.sublime-project b/middleman.sublime-project deleted file mode 100644 index c4df5142..00000000 --- a/middleman.sublime-project +++ /dev/null @@ -1,16 +0,0 @@ -{ - "folders": - [ - { - "path": ".", - "folder_exclude_patterns": [".sass-cache", ".bundle", "tmp", "coverage"], - "file_exclude_patterns": ["*.sublime-workspace"] - } - ], - - "settings": - { - "tab_size": 2, - "translate_tabs_to_spaces": true - } -} From 37a8caf3fae715cd1a2f942b4e17ae72ed0fb067 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Tue, 25 Mar 2014 11:00:43 -0700 Subject: [PATCH 058/580] Bring back extension block register syntax. Closes #1192 --- .../middleman-core/core_extensions/compass.rb | 3 +- .../core_extensions/extensions.rb | 2 +- .../lib/middleman-core/extensions.rb | 30 +++++++++++++++++-- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/middleman-core/lib/middleman-core/core_extensions/compass.rb b/middleman-core/lib/middleman-core/core_extensions/compass.rb index 602bfe42..914169c6 100644 --- a/middleman-core/lib/middleman-core/core_extensions/compass.rb +++ b/middleman-core/lib/middleman-core/core_extensions/compass.rb @@ -1,12 +1,11 @@ require 'middleman-core/renderers/sass' +require 'compass' class Middleman::CoreExtensions::Compass < ::Middleman::Extension def initialize(app, options_hash={}, &block) super - require 'compass' - # Hooks to manually update the compass config after we're # done with it app.define_hook :compass_config diff --git a/middleman-core/lib/middleman-core/core_extensions/extensions.rb b/middleman-core/lib/middleman-core/core_extensions/extensions.rb index 403176e2..3ef4cd01 100644 --- a/middleman-core/lib/middleman-core/core_extensions/extensions.rb +++ b/middleman-core/lib/middleman-core/core_extensions/extensions.rb @@ -88,7 +88,7 @@ module Middleman # @param [Symbol, Module] ext Which extension to activate # @return [void] def activate(ext, options={}, &block) - if extension = ::Middleman::Extensions::registered[ext] + if extension = ::Middleman::Extensions.load(ext) if extension.ancestors.include?(::Middleman::Extension) logger.debug "== Activating: #{ext}" diff --git a/middleman-core/lib/middleman-core/extensions.rb b/middleman-core/lib/middleman-core/extensions.rb index b6981657..0c6fe6d7 100644 --- a/middleman-core/lib/middleman-core/extensions.rb +++ b/middleman-core/lib/middleman-core/extensions.rb @@ -17,11 +17,35 @@ module Middleman # # @param [Symbol] name The name of the extension # @param [Module] namespace The extension module - def register(name, namespace) - if !registered.has_key?(name.to_sym) - registered[name.to_sym] = namespace + # @yield Instead of passing a module in namespace, you can provide + # a block which returns your extension module. This gives + # you the ability to require other files only when the + # extension is activated. + def register(name, namespace=nil, &block) + # If we've already got a matching extension that passed the + # version check, bail out. + return if registered.has_key?(name.to_sym) && !registered[name.to_sym].is_a?(String) + + registered[name.to_sym] = if block_given? + block + elsif namespace + namespace end end + + # Load an extension by name, evaluating block definition if necessary. + def load(name) + name = name.to_sym + return nil unless registered.has_key?(name) + + extension = registered[name] + if extension.is_a?(Proc) + extension = extension.call() || nil + registered[name] = extension + end + + extension + end end end From 1b6af9a4c160b27d448d44fba806bef74145c9a4 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Tue, 25 Mar 2014 11:01:35 -0700 Subject: [PATCH 059/580] Expose asset_path on the main Application object (Sprockets needed it) --- middleman-core/lib/middleman-core/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb index 9ee0dc42..83cb0b75 100644 --- a/middleman-core/lib/middleman-core/application.rb +++ b/middleman-core/lib/middleman-core/application.rb @@ -167,7 +167,7 @@ module Middleman attr_reader :template_context_class attr_reader :generic_template_context - delegate :link_to, :image_tag, :to => :generic_template_context + delegate :link_to, :image_tag, :asset_path, :to => :generic_template_context # Initialize the Middleman project def initialize(&block) From 8bc2fddb9da38661e64220efdddf29723e95d918 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Tue, 25 Mar 2014 16:57:57 -0700 Subject: [PATCH 060/580] Remove static serving of non-Middleman folders --- CHANGELOG.md | 1 + middleman-cli/lib/middleman-cli/server.rb | 4 +--- middleman-core/features/static_server.feature | 6 ------ middleman-core/fixtures/plain-app/index.html | 1 - 4 files changed, 2 insertions(+), 10 deletions(-) delete mode 100644 middleman-core/features/static_server.feature delete mode 100644 middleman-core/fixtures/plain-app/index.html diff --git a/CHANGELOG.md b/CHANGELOG.md index 40fc0b49..2e157514 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ master === +* Removed ability to server folders of content statically (non-Middleman projects). * Prevent local templates being loaded when $HOME is not set * Removed "Implied Extension feature" * Remove 'upgrade' and 'install' CLI commands. diff --git a/middleman-cli/lib/middleman-cli/server.rb b/middleman-cli/lib/middleman-cli/server.rb index 782d9faf..18da26b1 100644 --- a/middleman-cli/lib/middleman-cli/server.rb +++ b/middleman-cli/lib/middleman-cli/server.rb @@ -58,9 +58,7 @@ module Middleman::Cli if !ENV['MM_ROOT'] puts '== Could not find a Middleman project config.rb' - puts '== Treating directory as a static site to be served' - ENV['MM_ROOT'] = Dir.pwd - ENV['MM_SOURCE'] = '' + exit end params = { diff --git a/middleman-core/features/static_server.feature b/middleman-core/features/static_server.feature deleted file mode 100644 index 569b4cd1..00000000 --- a/middleman-core/features/static_server.feature +++ /dev/null @@ -1,6 +0,0 @@ -Feature: Middleman should serve plain directories without config - - Scenario: Preview a folder of static pages - Given the Server is running at "plain-app" - When I go to "/index.html" - Then I should see "I am index" \ No newline at end of file diff --git a/middleman-core/fixtures/plain-app/index.html b/middleman-core/fixtures/plain-app/index.html deleted file mode 100644 index 963a3e93..00000000 --- a/middleman-core/fixtures/plain-app/index.html +++ /dev/null @@ -1 +0,0 @@ -I am index \ No newline at end of file From 91675c4588076c0bcac4f39fe2f32db8eaef8251 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Tue, 25 Mar 2014 17:00:17 -0700 Subject: [PATCH 061/580] move sprockets init --- .../lib/middleman-core/core_extensions/extensions.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/middleman-core/lib/middleman-core/core_extensions/extensions.rb b/middleman-core/lib/middleman-core/core_extensions/extensions.rb index 3ef4cd01..32404273 100644 --- a/middleman-core/lib/middleman-core/core_extensions/extensions.rb +++ b/middleman-core/lib/middleman-core/core_extensions/extensions.rb @@ -128,7 +128,6 @@ module Middleman $LOAD_PATH.unshift(root) ::Middleman::Extension.clear_after_extension_callbacks - run_hook :initialized if config[:autoload_sprockets] begin @@ -138,6 +137,8 @@ module Middleman end end + run_hook :initialized + run_hook :before_configuration # Check for and evaluate local configuration From 10eca91311129f2cca95658c6519c8e7f3fae32d Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Tue, 25 Mar 2014 22:43:43 -0700 Subject: [PATCH 062/580] Fix docs for HashWithIndifferentAccess --- middleman-core/lib/middleman-core/util.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/middleman-core/lib/middleman-core/util.rb b/middleman-core/lib/middleman-core/util.rb index 1bddf938..51b0965d 100644 --- a/middleman-core/lib/middleman-core/util.rb +++ b/middleman-core/lib/middleman-core/util.rb @@ -287,7 +287,7 @@ module Middleman # A hash with indifferent access and magic predicates. # Copied from Thor # - # hash = Middleman::Application.new 'foo' => 'bar', 'baz' => 'bee', 'force' => true + # hash = Middleman::Util::HashWithIndifferentAccess.new 'foo' => 'bar', 'baz' => 'bee', 'force' => true # # hash[:foo] #=> 'bar' # hash['foo'] #=> 'bar' From a6c37f3dd3516e56e82c85e32f131f20ea035598 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Sat, 29 Mar 2014 14:29:42 -0700 Subject: [PATCH 063/580] Clean up extensions a bit. Removes newest form of registering extensions, more consistently sets and uses an extension's ext_name, and makes a lot of things errors instead of just log messages in hopes that people can't get too far with a messed-up config. --- .../fixtures/feature-params-app/config.rb | 2 +- .../fixtures/v4-extension-callbacks/config.rb | 6 +- .../lib/middleman-core/application.rb | 4 +- .../lib/middleman-core/core_extensions.rb | 81 +++++++++++++------ .../middleman-core/core_extensions/compass.rb | 2 - .../core_extensions/default_helpers.rb | 2 - .../core_extensions/extensions.rb | 29 +++---- .../middleman-core/core_extensions/i18n.rb | 2 - .../lib/middleman-core/extension.rb | 12 +-- .../lib/middleman-core/extensions.rb | 40 +++++++-- .../lib/middleman-core/extensions/lorem.rb | 2 - 11 files changed, 107 insertions(+), 75 deletions(-) diff --git a/middleman-core/fixtures/feature-params-app/config.rb b/middleman-core/fixtures/feature-params-app/config.rb index fda7e5a0..7e2bc2ef 100644 --- a/middleman-core/fixtures/feature-params-app/config.rb +++ b/middleman-core/fixtures/feature-params-app/config.rb @@ -11,6 +11,6 @@ class ExtensionA < ::Middleman::Extension option :hola, '', '' end -ExtensionA.register +Middleman::Extensions.register :extension_a, ExtensionA activate :extension_a, :hello => "world", :hola => "mundo" diff --git a/middleman-core/fixtures/v4-extension-callbacks/config.rb b/middleman-core/fixtures/v4-extension-callbacks/config.rb index c9c1c5d4..f62745bc 100644 --- a/middleman-core/fixtures/v4-extension-callbacks/config.rb +++ b/middleman-core/fixtures/v4-extension-callbacks/config.rb @@ -16,7 +16,7 @@ class ExtensionOne < ::Middleman::Extension end end -ExtensionOne.register +Middleman::Extensions.register :extension_one, ExtensionOne class ExtensionTwo < ::Middleman::Extension helpers do @@ -36,7 +36,7 @@ class ExtensionTwo < ::Middleman::Extension end end -ExtensionTwo.register +Middleman::Extensions.register :extension_two, ExtensionTwo activate :extension_one -activate :extension_two \ No newline at end of file +activate :extension_two diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb index 83cb0b75..9a19ba93 100644 --- a/middleman-core/lib/middleman-core/application.rb +++ b/middleman-core/lib/middleman-core/application.rb @@ -196,8 +196,10 @@ module Middleman activate :default_helpers activate :lorem - if defined?(Middleman::CoreExtensions::Compass) + begin activate :compass + rescue LoadError + # Compass is not available, don't complain about it end # Evaluate a passed block if given diff --git a/middleman-core/lib/middleman-core/core_extensions.rb b/middleman-core/lib/middleman-core/core_extensions.rb index b241c9c5..d61e90a7 100644 --- a/middleman-core/lib/middleman-core/core_extensions.rb +++ b/middleman-core/lib/middleman-core/core_extensions.rb @@ -27,68 +27,97 @@ require 'middleman-core/core_extensions/routing' require 'middleman-core/core_extensions/show_exceptions' # Setup default helpers -require 'middleman-core/core_extensions/default_helpers' - -require 'middleman-core/core_extensions/i18n' +Middleman::Extensions.register :default_helpers do + require 'middleman-core/core_extensions/default_helpers' + Middleman::CoreExtensions::DefaultHelpers +end # Compass framework -begin +Middleman::Extensions.register :compass do require 'middleman-core/core_extensions/compass' -rescue LoadError + Middleman::CoreExtensions::Compass end ### # Setup Optional Extensions ### +Middleman::Extensions.register :i18n do + require 'middleman-core/core_extensions/i18n' + Middleman::CoreExtensions::Internationalization +end + # CacheBuster adds a query string to assets in dynamic templates to # avoid browser caches failing to update to your new content. -require 'middleman-core/extensions/cache_buster' -Middleman::Extensions::CacheBuster.register +Middleman::Extensions.register :cache_buster do + require 'middleman-core/extensions/cache_buster' + Middleman::Extensions::CacheBuster +end # RelativeAssets allow any asset path in dynamic templates to be either # relative to the root of the project or use an absolute URL. -require 'middleman-core/extensions/relative_assets' -Middleman::Extensions::RelativeAssets.register +Middleman::Extensions.register :relative_assets do + require 'middleman-core/extensions/relative_assets' + Middleman::Extensions::RelativeAssets +end # AssetHost allows you to setup multiple domains to host your static # assets. Calls to asset paths in dynamic templates will then rotate # through each of the asset servers to better spread the load. -require 'middleman-core/extensions/asset_host' -Middleman::Extensions::AssetHost.register +Middleman::Extensions.register :asset_host do + require 'middleman-core/extensions/asset_host' + Middleman::Extensions::AssetHost +end # MinifyCss compresses CSS -require 'middleman-core/extensions/minify_css' -Middleman::Extensions::MinifyCss.register +Middleman::Extensions.register :minify_css do + require 'middleman-core/extensions/minify_css' + Middleman::Extensions::MinifyCss +end # MinifyJavascript compresses JS -require 'middleman-core/extensions/minify_javascript' -Middleman::Extensions::MinifyJavascript.register +Middleman::Extensions.register :minify_javascript do + require 'middleman-core/extensions/minify_javascript' + Middleman::Extensions::MinifyJavascript +end # GZIP assets and pages during build -require 'middleman-core/extensions/gzip' -Middleman::Extensions::Gzip.register +Middleman::Extensions.register :gzip do + require 'middleman-core/extensions/gzip' + Middleman::Extensions::Gzip +end # AssetHash appends a hash of the file contents to the assets filename # to avoid browser caches failing to update to your new content. -require 'middleman-core/extensions/asset_hash' -Middleman::Extensions::AssetHash.register +Middleman::Extensions.register :asset_hash do + require 'middleman-core/extensions/asset_hash' + Middleman::Extensions::AssetHash +end # Provide Apache-style index.html files for directories -require 'middleman-core/extensions/directory_indexes' -Middleman::Extensions::DirectoryIndexes.register +Middleman::Extensions.register :directory_indexes do + require 'middleman-core/extensions/directory_indexes' + Middleman::Extensions::DirectoryIndexes +end # Lorem provides a handful of helpful prototyping methods to generate # words, paragraphs, fake images, names and email addresses. -require 'middleman-core/extensions/lorem' +Middleman::Extensions.register :lorem do + require 'middleman-core/extensions/lorem' + Middleman::Extensions::Lorem +end # AutomaticImageSizes inspects the images used in your dynamic templates # and automatically adds width and height attributes to their HTML # elements. -require 'middleman-core/extensions/automatic_image_sizes' -Middleman::Extensions::AutomaticImageSizes.register +Middleman::Extensions.register :automatic_image_sizes do + require 'middleman-core/extensions/automatic_image_sizes' + Middleman::Extensions::AutomaticImageSizes +end # AutomaticAltTags uses the file name of the `image_tag` to generate # a default `:alt` value. -require 'middleman-core/extensions/automatic_alt_tags' -Middleman::Extensions::AutomaticAltTags.register +Middleman::Extensions.register :automatic_alt_tags do + require 'middleman-core/extensions/automatic_alt_tags' + Middleman::Extensions::AutomaticAltTags +end diff --git a/middleman-core/lib/middleman-core/core_extensions/compass.rb b/middleman-core/lib/middleman-core/core_extensions/compass.rb index 914169c6..75b04ab3 100644 --- a/middleman-core/lib/middleman-core/core_extensions/compass.rb +++ b/middleman-core/lib/middleman-core/core_extensions/compass.rb @@ -73,5 +73,3 @@ class Middleman::CoreExtensions::Compass < ::Middleman::Extension end end end - -Middleman::CoreExtensions::Compass.register diff --git a/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb b/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb index 288c99b4..1e76674f 100644 --- a/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb +++ b/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb @@ -259,5 +259,3 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension end end end - -Middleman::CoreExtensions::DefaultHelpers.register diff --git a/middleman-core/lib/middleman-core/core_extensions/extensions.rb b/middleman-core/lib/middleman-core/core_extensions/extensions.rb index 32404273..da366272 100644 --- a/middleman-core/lib/middleman-core/core_extensions/extensions.rb +++ b/middleman-core/lib/middleman-core/core_extensions/extensions.rb @@ -88,26 +88,19 @@ module Middleman # @param [Symbol, Module] ext Which extension to activate # @return [void] def activate(ext, options={}, &block) - if extension = ::Middleman::Extensions.load(ext) - if extension.ancestors.include?(::Middleman::Extension) - logger.debug "== Activating: #{ext}" + extension = ::Middleman::Extensions.load(ext) + logger.debug "== Activating: #{ext}" - if extension.supports_multiple_instances? - extensions[ext] ||= {} - key = "instance_#{extensions[ext].keys.length}" - extensions[ext][key] = extension.new(self.class, options, &block) - else - if extensions[ext] - logger.error "== #{ext} already activated." - else - extensions[ext] = extension.new(self.class, options, &block) - end - end - else - logger.error "!! Tried to activate old-style extension: #{ext}" - end + if extension.supports_multiple_instances? + extensions[ext] ||= {} + key = "instance_#{extensions[ext].keys.length}" + extensions[ext][key] = extension.new(self.class, options, &block) else - logger.error "!! Unknown Extension: #{ext}" + if extensions[ext] + raise "#{ext} has already been activated and cannot be re-activated." + else + extensions[ext] = extension.new(self.class, options, &block) + end end end diff --git a/middleman-core/lib/middleman-core/core_extensions/i18n.rb b/middleman-core/lib/middleman-core/core_extensions/i18n.rb index 8047462b..f500d953 100644 --- a/middleman-core/lib/middleman-core/core_extensions/i18n.rb +++ b/middleman-core/lib/middleman-core/core_extensions/i18n.rb @@ -201,5 +201,3 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension end end end - -Middleman::CoreExtensions::Internationalization.register(:i18n) diff --git a/middleman-core/lib/middleman-core/extension.rb b/middleman-core/lib/middleman-core/extension.rb index 25a8a22c..6219f258 100644 --- a/middleman-core/lib/middleman-core/extension.rb +++ b/middleman-core/lib/middleman-core/extension.rb @@ -33,14 +33,6 @@ module Middleman self.defined_helpers += m end - def extension_name - self.ext_name || self.name.underscore.split('/').last.to_sym - end - - def register(n=self.extension_name) - ::Middleman::Extensions.register(n, self) - end - def activate new(::Middleman::Application) end @@ -56,7 +48,7 @@ module Middleman end def activated_extension(instance) - name = instance.class.extension_name + name = instance.class.ext_name return unless @_extension_activation_callbacks && @_extension_activation_callbacks[name] @_extension_activation_callbacks[name].each do |block| block.arity == 1 ? block.call(instance) : block.call() @@ -136,7 +128,7 @@ module Middleman end if ext.respond_to?(:manipulate_resource_list) - ext.app.sitemap.register_resource_list_manipulator(ext.class.extension_name, ext) + ext.app.sitemap.register_resource_list_manipulator(ext.class.ext_name, ext) end end end diff --git a/middleman-core/lib/middleman-core/extensions.rb b/middleman-core/lib/middleman-core/extensions.rb index 0c6fe6d7..c147230d 100644 --- a/middleman-core/lib/middleman-core/extensions.rb +++ b/middleman-core/lib/middleman-core/extensions.rb @@ -13,7 +13,16 @@ module Middleman # activate :my_extension # # Provide your extension module either as the namespace - # parameter, or return it from the block: + # parameter: + # + # Middleman::Extensions.register(:my_extension, MyExtension) + # + # Or return it from a block: + # + # Middleman::Extensions.register(:my_extension) do + # require 'my_extension' + # MyExtension + # end # # @param [Symbol] name The name of the extension # @param [Module] namespace The extension module @@ -22,34 +31,49 @@ module Middleman # you the ability to require other files only when the # extension is activated. def register(name, namespace=nil, &block) - # If we've already got a matching extension that passed the - # version check, bail out. - return if registered.has_key?(name.to_sym) && !registered[name.to_sym].is_a?(String) + # If we've already got an extension registered under this name, bail out + if registered.has_key?(name.to_sym) + raise "There is already an extension registered with the name '#{name}'" + end registered[name.to_sym] = if block_given? block - elsif namespace + elsif namespace && namespace.ancestors.include?(::Middleman::Extension) namespace + else + raise "You must provide a Middleman::Extension or a block that returns a Middleman::Extension" end end # Load an extension by name, evaluating block definition if necessary. def load(name) name = name.to_sym - return nil unless registered.has_key?(name) + + unless registered.has_key?(name) + raise "Unknown Extension: #{name}. Check the name and make sure you have referenced the extension's gem in your Gemfile." + end extension = registered[name] if extension.is_a?(Proc) - extension = extension.call() || nil + extension = extension.call() registered[name] = extension end + if !extension.ancestors.include?(::Middleman::Extension) + raise "Tried to activate old-style extension: #{name}. They are no longer supported." + end + + # Set the extension's name to whatever it was registered as. + extension.ext_name = name + extension end end end - # Where to look in gems for extensions to auto-register + # Where to look in gems for extensions to auto-register. Since most extensions are + # called out in a Gemfile, this is really only useful for template extensions that get + # used by "middleman init". EXTENSION_FILE = File.join('lib', 'middleman_extension.rb') unless const_defined?(:EXTENSION_FILE) class << self diff --git a/middleman-core/lib/middleman-core/extensions/lorem.rb b/middleman-core/lib/middleman-core/extensions/lorem.rb index a69454c6..d13abeeb 100644 --- a/middleman-core/lib/middleman-core/extensions/lorem.rb +++ b/middleman-core/lib/middleman-core/extensions/lorem.rb @@ -174,5 +174,3 @@ class Middleman::Extensions::Lorem < ::Middleman::Extension end end end - -Middleman::Extensions::Lorem.register \ No newline at end of file From abeee38126ff908589626e4805b6d6995e2f2acc Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Sat, 29 Mar 2014 17:17:00 -0700 Subject: [PATCH 064/580] Remove yet another way to register extensions and register/activate FrontMatter like a normal extension. --- middleman-core/lib/middleman-core/application.rb | 8 ++++---- .../lib/middleman-core/core_extensions.rb | 5 ++++- .../middleman-core/core_extensions/extensions.rb | 13 ------------- middleman-core/lib/middleman-core/sitemap.rb | 1 - 4 files changed, 8 insertions(+), 19 deletions(-) diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb index 9a19ba93..8c2c9352 100644 --- a/middleman-core/lib/middleman-core/application.rb +++ b/middleman-core/lib/middleman-core/application.rb @@ -142,10 +142,6 @@ module Middleman # Setup custom rendering include Middleman::CoreExtensions::Rendering - # Parse YAML from templates. Must be before sitemap so sitemap - # extensions see updated frontmatter! - register Middleman::CoreExtensions::FrontMatter - # Sitemap Config options and public api include Middleman::Sitemap @@ -182,6 +178,10 @@ module Middleman # Setup the default values from calls to set before initialization self.class.config.load_settings(self.class.superclass.config.all_settings) + # Parse YAML from templates. Must be before sitemap so sitemap + # extensions see updated frontmatter! + activate :front_matter + # Initialize the Sitemap @sitemap = ::Middleman::Sitemap::Store.new(self) diff --git a/middleman-core/lib/middleman-core/core_extensions.rb b/middleman-core/lib/middleman-core/core_extensions.rb index d61e90a7..340ca2fd 100644 --- a/middleman-core/lib/middleman-core/core_extensions.rb +++ b/middleman-core/lib/middleman-core/core_extensions.rb @@ -12,7 +12,10 @@ require 'middleman-core/core_extensions/extensions' require 'middleman-core/core_extensions/data' # Parse YAML from templates -require 'middleman-core/core_extensions/front_matter' +Middleman::Extensions.register :front_matter do + require 'middleman-core/core_extensions/front_matter' + Middleman::CoreExtensions::FrontMatter +end # External helpers looks in the helpers/ folder for helper modules require 'middleman-core/core_extensions/external_helpers' diff --git a/middleman-core/lib/middleman-core/core_extensions/extensions.rb b/middleman-core/lib/middleman-core/core_extensions/extensions.rb index da366272..cdb0ed87 100644 --- a/middleman-core/lib/middleman-core/core_extensions/extensions.rb +++ b/middleman-core/lib/middleman-core/core_extensions/extensions.rb @@ -62,19 +62,6 @@ module Middleman def configure(env, &block) send("#{env}_config", &block) end - - # Register a new extension - # - # @param [Module] extension Extension modules to register - # @param [Hash] options Per-extension options hash - # @return [void] - def register(extension, options={}, &block) - if extension.ancestors.include?(::Middleman::Extension) - extension.new(self, options, &block) - else - $stderr.puts "!! Tried to register old-style extension: #{extension}" - end - end end # Instance methods diff --git a/middleman-core/lib/middleman-core/sitemap.rb b/middleman-core/lib/middleman-core/sitemap.rb index fbda5b2d..658dc7c5 100644 --- a/middleman-core/lib/middleman-core/sitemap.rb +++ b/middleman-core/lib/middleman-core/sitemap.rb @@ -1,6 +1,5 @@ # Core Sitemap Extensions module Middleman - module Sitemap # Setup Extension From c1f7299cfd8a52bda3616b8b2f2b178b7d95037c Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Sat, 29 Mar 2014 17:21:49 -0700 Subject: [PATCH 065/580] Fix some references to extensions[:frontmatter] --- .../lib/middleman-core/core_extensions/front_matter.rb | 5 ++--- middleman-core/lib/middleman-core/file_renderer.rb | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/middleman-core/lib/middleman-core/core_extensions/front_matter.rb b/middleman-core/lib/middleman-core/core_extensions/front_matter.rb index cffd234f..41ec27ac 100644 --- a/middleman-core/lib/middleman-core/core_extensions/front_matter.rb +++ b/middleman-core/lib/middleman-core/core_extensions/front_matter.rb @@ -32,7 +32,6 @@ module Middleman::CoreExtensions end def after_configuration - app.extensions[:frontmatter] = self app.ignore %r{\.frontmatter$} ::Middleman::Sitemap::Resource.send :include, ResourceInstanceMethods @@ -45,7 +44,7 @@ module Middleman::CoreExtensions [:layout, :layout_engine].each do |opt| data[opt] = fmdata[opt] unless fmdata[opt].nil? end - + if fmdata[:renderer_options] data[:renderer_options] = {} fmdata[:renderer_options].each do |k, v| @@ -71,7 +70,7 @@ module Middleman::CoreExtensions # @private # @return [Hash] def raw_data - app.extensions[:frontmatter].data(source_file).first + app.extensions[:front_matter].data(source_file).first end # This page's frontmatter diff --git a/middleman-core/lib/middleman-core/file_renderer.rb b/middleman-core/lib/middleman-core/file_renderer.rb index 0393ad83..6d3e4dd1 100644 --- a/middleman-core/lib/middleman-core/file_renderer.rb +++ b/middleman-core/lib/middleman-core/file_renderer.rb @@ -84,8 +84,8 @@ module Middleman # @param [String] path # @return [String] def get_template_data_for_file - if @app.extensions[:frontmatter] - @app.extensions[:frontmatter].template_data_for_file(@path) + if @app.extensions[:front_matter] + @app.extensions[:front_matter].template_data_for_file(@path) else File.read(File.expand_path(@path, source_dir)) end @@ -116,4 +116,4 @@ module Middleman end end end -end \ No newline at end of file +end From 5ce8549f0332fb09ba53bc7b235927a5c61ce686 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Sat, 29 Mar 2014 19:24:51 -0700 Subject: [PATCH 066/580] Remove Asciidoc support in favor of a middleman-asciidoc extension. --- Gemfile | 1 - middleman-core/features/asciidoc.feature | 155 ------------------ .../fixtures/asciidoc-app/config.rb | 0 .../asciidoc-app/source/_include.adoc | 1 - .../asciidoc-app/source/code.html.adoc | 3 - .../source/custom-attribute.html.adoc | 3 - .../asciidoc-app/source/gallery.html.adoc | 1 - .../source/hello-no-layout.html.adoc | 2 - .../source/hello-with-front-matter.html.adoc | 5 - .../source/hello-with-layout.html.adoc | 2 - .../source/hello-with-title.html.adoc | 4 - .../asciidoc-app/source/hello.html.adoc | 4 - .../asciidoc-app/source/images/tiger.gif | Bin 43 -> 0 bytes .../asciidoc-app/source/layouts/default.erb | 9 - .../asciidoc-app/source/master.html.adoc | 3 - .../core_extensions/rendering.rb | 7 - .../lib/middleman-core/renderers/asciidoc.rb | 56 ------- 17 files changed, 256 deletions(-) delete mode 100644 middleman-core/features/asciidoc.feature delete mode 100644 middleman-core/fixtures/asciidoc-app/config.rb delete mode 100644 middleman-core/fixtures/asciidoc-app/source/_include.adoc delete mode 100644 middleman-core/fixtures/asciidoc-app/source/code.html.adoc delete mode 100644 middleman-core/fixtures/asciidoc-app/source/custom-attribute.html.adoc delete mode 100644 middleman-core/fixtures/asciidoc-app/source/gallery.html.adoc delete mode 100644 middleman-core/fixtures/asciidoc-app/source/hello-no-layout.html.adoc delete mode 100644 middleman-core/fixtures/asciidoc-app/source/hello-with-front-matter.html.adoc delete mode 100644 middleman-core/fixtures/asciidoc-app/source/hello-with-layout.html.adoc delete mode 100644 middleman-core/fixtures/asciidoc-app/source/hello-with-title.html.adoc delete mode 100755 middleman-core/fixtures/asciidoc-app/source/hello.html.adoc delete mode 100755 middleman-core/fixtures/asciidoc-app/source/images/tiger.gif delete mode 100644 middleman-core/fixtures/asciidoc-app/source/layouts/default.erb delete mode 100644 middleman-core/fixtures/asciidoc-app/source/master.html.adoc delete mode 100644 middleman-core/lib/middleman-core/renderers/asciidoc.rb diff --git a/Gemfile b/Gemfile index 394fdd83..e930dc7c 100644 --- a/Gemfile +++ b/Gemfile @@ -18,7 +18,6 @@ gem 'slim', require: false gem 'liquid', require: false gem 'less', '~> 2.3.0', require: false gem 'stylus', require: false -gem 'asciidoctor', require: false platforms :ruby do gem 'therubyracer' diff --git a/middleman-core/features/asciidoc.feature b/middleman-core/features/asciidoc.feature deleted file mode 100644 index 14bca69e..00000000 --- a/middleman-core/features/asciidoc.feature +++ /dev/null @@ -1,155 +0,0 @@ -Feature: AsciiDoc Support - In order to test included AsciiDoc support - - Scenario: Rendering html - Given the Server is running at "asciidoc-app" - When I go to "/hello.html" - Then I should see: - """ -
-

Hello, AsciiDoc! - Middleman, I am in you.

-
- """ - - Scenario: Rendering html with default layout - Given a fixture app "asciidoc-app" - And a file named "config.rb" with: - """ - set :layout, :default - """ - Given the Server is running at "asciidoc-app" - When I go to "/hello.html" - Then I should see: - """ - - - - Fallback - - -
-

Hello, AsciiDoc! - Middleman, I am in you.

-
- - - """ - - Scenario: Rendering html with explicit layout - Given the Server is running at "asciidoc-app" - When I go to "/hello-with-layout.html" - Then I should see: - """ - - - - Fallback - - -
-

Hello, AsciiDoc!

-
- - - """ - - Scenario: Rendering html with no layout - Given the Server is running at "asciidoc-app" - When I go to "/hello-no-layout.html" - Then I should see: - """ -
-

Hello, AsciiDoc!

-
- """ - - Scenario: Rendering html using title from document - Given the Server is running at "asciidoc-app" - When I go to "/hello-with-title.html" - Then I should see: - """ - - - - Page Title - - -

Page Title

-
-
-
-

Hello, AsciiDoc!

-
-
-
- - - """ - - Scenario: Rendering html with title and layout from front matter - Given the Server is running at "asciidoc-app" - When I go to "/hello-with-front-matter.html" - Then I should see: - """ - - - - Page Title - - -
-

Hello, AsciiDoc!

-
- - - """ - - Scenario: Including a file relative to source root - Given the Server is running at "asciidoc-app" - When I go to "/master.html" - Then I should see: - """ -
-
-
I'm included content.
-
- """ - - Scenario: Linking to an image - Given the Server is running at "asciidoc-app" - When I go to "/gallery.html" - Then I should see: - """ -
-
- tiger -
- """ - - Scenario: Configuring custom AsciiDoc attributes - Given a fixture app "asciidoc-app" - And a file named "config.rb" with: - """ - set :asciidoc_attributes, %w(foo=bar) - """ - Given the Server is running at "asciidoc-app" - When I go to "/custom-attribute.html" - Then I should see "bar" - - Scenario: Highlighting source code - Given a fixture app "asciidoc-app" - And a file named "config.rb" with: - """ - set :asciidoc_attributes, %w(source-highlighter=html-pipeline) - """ - Given the Server is running at "asciidoc-app" - When I go to "/code.html" - Then I should see: - """ -
-
-
puts "Is this mic on?"
-
-
- """ diff --git a/middleman-core/fixtures/asciidoc-app/config.rb b/middleman-core/fixtures/asciidoc-app/config.rb deleted file mode 100644 index e69de29b..00000000 diff --git a/middleman-core/fixtures/asciidoc-app/source/_include.adoc b/middleman-core/fixtures/asciidoc-app/source/_include.adoc deleted file mode 100644 index b0cdec38..00000000 --- a/middleman-core/fixtures/asciidoc-app/source/_include.adoc +++ /dev/null @@ -1 +0,0 @@ -I'm included content. diff --git a/middleman-core/fixtures/asciidoc-app/source/code.html.adoc b/middleman-core/fixtures/asciidoc-app/source/code.html.adoc deleted file mode 100644 index e0d6a519..00000000 --- a/middleman-core/fixtures/asciidoc-app/source/code.html.adoc +++ /dev/null @@ -1,3 +0,0 @@ -```ruby -puts "Is this mic on?" -``` diff --git a/middleman-core/fixtures/asciidoc-app/source/custom-attribute.html.adoc b/middleman-core/fixtures/asciidoc-app/source/custom-attribute.html.adoc deleted file mode 100644 index b4eb729d..00000000 --- a/middleman-core/fixtures/asciidoc-app/source/custom-attribute.html.adoc +++ /dev/null @@ -1,3 +0,0 @@ -++++ -{foo} -++++ diff --git a/middleman-core/fixtures/asciidoc-app/source/gallery.html.adoc b/middleman-core/fixtures/asciidoc-app/source/gallery.html.adoc deleted file mode 100644 index 4a9f37f1..00000000 --- a/middleman-core/fixtures/asciidoc-app/source/gallery.html.adoc +++ /dev/null @@ -1 +0,0 @@ -image::tiger.gif[] diff --git a/middleman-core/fixtures/asciidoc-app/source/hello-no-layout.html.adoc b/middleman-core/fixtures/asciidoc-app/source/hello-no-layout.html.adoc deleted file mode 100644 index 8156a16f..00000000 --- a/middleman-core/fixtures/asciidoc-app/source/hello-no-layout.html.adoc +++ /dev/null @@ -1,2 +0,0 @@ -:page-layout: false -Hello, AsciiDoc! diff --git a/middleman-core/fixtures/asciidoc-app/source/hello-with-front-matter.html.adoc b/middleman-core/fixtures/asciidoc-app/source/hello-with-front-matter.html.adoc deleted file mode 100644 index 5e1f91a3..00000000 --- a/middleman-core/fixtures/asciidoc-app/source/hello-with-front-matter.html.adoc +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Page Title -layout: default ---- -Hello, AsciiDoc! diff --git a/middleman-core/fixtures/asciidoc-app/source/hello-with-layout.html.adoc b/middleman-core/fixtures/asciidoc-app/source/hello-with-layout.html.adoc deleted file mode 100644 index 763ba8c1..00000000 --- a/middleman-core/fixtures/asciidoc-app/source/hello-with-layout.html.adoc +++ /dev/null @@ -1,2 +0,0 @@ -:page-layout: default -Hello, AsciiDoc! diff --git a/middleman-core/fixtures/asciidoc-app/source/hello-with-title.html.adoc b/middleman-core/fixtures/asciidoc-app/source/hello-with-title.html.adoc deleted file mode 100644 index e2c7673b..00000000 --- a/middleman-core/fixtures/asciidoc-app/source/hello-with-title.html.adoc +++ /dev/null @@ -1,4 +0,0 @@ -= Page Title -:page-layout: default - -Hello, AsciiDoc! diff --git a/middleman-core/fixtures/asciidoc-app/source/hello.html.adoc b/middleman-core/fixtures/asciidoc-app/source/hello.html.adoc deleted file mode 100755 index 6c1ab072..00000000 --- a/middleman-core/fixtures/asciidoc-app/source/hello.html.adoc +++ /dev/null @@ -1,4 +0,0 @@ -Hello, AsciiDoc! -ifdef::env-middleman[] -Middleman, I am in you. -endif::env-middleman[] diff --git a/middleman-core/fixtures/asciidoc-app/source/images/tiger.gif b/middleman-core/fixtures/asciidoc-app/source/images/tiger.gif deleted file mode 100755 index 2498f1aac58dab923f0fd99b1c8ee6b8c53c7158..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 43 rcmZ?wbhEHbWMp7uXkcKtd-pB_1B2pE76uT|0TCb>1|}vKMh0sDy$1%8 diff --git a/middleman-core/fixtures/asciidoc-app/source/layouts/default.erb b/middleman-core/fixtures/asciidoc-app/source/layouts/default.erb deleted file mode 100644 index 01d1c485..00000000 --- a/middleman-core/fixtures/asciidoc-app/source/layouts/default.erb +++ /dev/null @@ -1,9 +0,0 @@ - - - -<%= current_resource.data.title || asciidoc[:title] || 'Fallback' %> - - -<%= yield %> - - diff --git a/middleman-core/fixtures/asciidoc-app/source/master.html.adoc b/middleman-core/fixtures/asciidoc-app/source/master.html.adoc deleted file mode 100644 index 1b789b44..00000000 --- a/middleman-core/fixtures/asciidoc-app/source/master.html.adoc +++ /dev/null @@ -1,3 +0,0 @@ -.... -include::_include.adoc[] -.... diff --git a/middleman-core/lib/middleman-core/core_extensions/rendering.rb b/middleman-core/lib/middleman-core/core_extensions/rendering.rb index a77f853f..c61f2f2d 100644 --- a/middleman-core/lib/middleman-core/core_extensions/rendering.rb +++ b/middleman-core/lib/middleman-core/core_extensions/rendering.rb @@ -48,13 +48,6 @@ module Middleman require 'middleman-core/renderers/markdown' app.send :include, Middleman::Renderers::Markdown - # AsciiDoc Support - begin - require 'middleman-core/renderers/asciidoc' - app.send :include, Middleman::Renderers::AsciiDoc - rescue LoadError - end - # Liquid Support begin require 'middleman-core/renderers/liquid' diff --git a/middleman-core/lib/middleman-core/renderers/asciidoc.rb b/middleman-core/lib/middleman-core/renderers/asciidoc.rb deleted file mode 100644 index 877d4f8f..00000000 --- a/middleman-core/lib/middleman-core/renderers/asciidoc.rb +++ /dev/null @@ -1,56 +0,0 @@ -require 'asciidoctor' - -module Middleman - module Renderers - module AsciiDoc - class << self - - def registered(app) - app.config.define_setting :asciidoc, { - :safe => :safe, - :backend => :html5, - :attributes => %W(showtitle env=middleman env-middleman middleman-version=#{::Middleman::VERSION}) - }, 'AsciiDoc engine options (Hash)' - app.config.define_setting :asciidoc_attributes, [], 'AsciiDoc custom attributes (Array)' - - app.after_configuration do - # QUESTION should base_dir be equal to docdir instead? - config[:asciidoc][:base_dir] = source_dir - config[:asciidoc][:attributes].concat(config[:asciidoc_attributes] || []) - config[:asciidoc][:attributes] << %(imagesdir=#{File.join((config[:http_prefix] || '/').chomp('/'), config[:images_dir])}) - sitemap.provides_metadata(/\.adoc$/) do |path| - # read the AsciiDoc header only to set page options and data - # header values can be accessed via app.data.page. in the layout - doc = Asciidoctor.load_file path, :safe => :safe, :parse_header_only => true - - opts = {} - if doc.attr? 'page-layout' - case (layout = (doc.attr 'page-layout')) - when '', 'false' - opts[:layout] = false - else - opts[:layout] = layout - end - end - opts[:layout_engine] = (doc.attr 'page-layout-engine') if (doc.attr? 'page-layout-engine') - # TODO override attributes to set docfile, docdir, docname, etc - # alternative is to set :renderer_options, which get merged into options by the rendering extension - #opts[:attributes] = config[:asciidoc][:attributes].dup - #opts[:attributes].concat %W(docfile=#{path} docdir=#{File.dirname path} docname=#{(File.basename path).sub(/\.adoc$/, '')}) - - page = {} - page[:title] = doc.doctitle - page[:date] = (doc.attr 'date') unless (doc.attr 'date').nil? - # TODO grab all the author information - page[:author] = (doc.attr 'author') unless (doc.attr 'author').nil? - - { :options => opts, :locals => { :asciidoc => page } } - end - end - end - - alias :included :registered - end - end - end -end From 6d2f8cd50cd4055f697cb756cbb395896ecedf3b Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Mon, 31 Mar 2014 14:15:46 -0700 Subject: [PATCH 067/580] Add options hash to asset methods to allow special options to be passed through from extensions --- Gemfile | 2 +- .../middleman-core/core_extensions/default_helpers.rb | 8 +++++--- .../lib/middleman-core/extensions/asset_host.rb | 3 ++- .../lib/middleman-core/extensions/cache_buster.rb | 3 ++- .../lib/middleman-core/extensions/relative_assets.rb | 11 +++++++---- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Gemfile b/Gemfile index e930dc7c..27c59bf3 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ gem 'yard', '~> 0.8.0', require: false # Test tools gem 'cucumber', '~> 1.3.1' -gem 'fivemat' +gem 'fivemat', '~> 1.2.1' gem 'aruba', '~> 0.5.1' gem 'rspec', '~> 2.12' gem 'simplecov' diff --git a/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb b/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb index 1e76674f..14466f25 100644 --- a/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb +++ b/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb @@ -167,8 +167,9 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension # # @param [Symbol] kind The type of file # @param [String] source The path to the file + # @param [Hash] options Data to pass through. # @return [String] - def asset_path(kind, source) + def asset_path(kind, source, options={}) return source if source.to_s.include?('//') || source.to_s.start_with?('data:') asset_folder = case kind when :css then config[:css_dir] @@ -182,15 +183,16 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension source << ".#{kind}" unless ignore_extension || source.end_with?(".#{kind}") asset_folder = '' if source.start_with?('/') # absolute path - asset_url(source, asset_folder) + asset_url(source, asset_folder, options) end # Get the URL of an asset given a type/prefix # # @param [String] path The path (such as "photo.jpg") # @param [String] prefix The type prefix (such as "images") + # @param [Hash] options Data to pass through. # @return [String] The fully qualified asset url - def asset_url(path, prefix='') + def asset_url(path, prefix='', options={}) # Don't touch assets which already have a full path if path.include?('//') or path.start_with?('data:') path diff --git a/middleman-core/lib/middleman-core/extensions/asset_host.rb b/middleman-core/lib/middleman-core/extensions/asset_host.rb index 89cc49d6..b73f74bc 100644 --- a/middleman-core/lib/middleman-core/extensions/asset_host.rb +++ b/middleman-core/lib/middleman-core/extensions/asset_host.rb @@ -31,8 +31,9 @@ class Middleman::Extensions::AssetHost < ::Middleman::Extension # # @param [String] path # @param [String] prefix + # @param [Hash] options Data to pass through. # @return [String] - def asset_url(path, prefix='') + def asset_url(path, prefix='', options={}) controller = extensions[:asset_host] original_output = super diff --git a/middleman-core/lib/middleman-core/extensions/cache_buster.rb b/middleman-core/lib/middleman-core/extensions/cache_buster.rb index 8d1788ce..44652888 100644 --- a/middleman-core/lib/middleman-core/extensions/cache_buster.rb +++ b/middleman-core/lib/middleman-core/extensions/cache_buster.rb @@ -22,7 +22,8 @@ class Middleman::Extensions::CacheBuster < ::Middleman::Extension # asset_url override if we're using cache busting # @param [String] path # @param [String] prefix - def asset_url(path, prefix='') + # @param [Hash] options Data to pass through. + def asset_url(path, prefix='', options={}) http_path = super if http_path.include?('://') || !%w(.css .png .jpg .jpeg .svg .svgz .js .gif).include?(File.extname(http_path)) diff --git a/middleman-core/lib/middleman-core/extensions/relative_assets.rb b/middleman-core/lib/middleman-core/extensions/relative_assets.rb index 3e67d59d..61e54881 100644 --- a/middleman-core/lib/middleman-core/extensions/relative_assets.rb +++ b/middleman-core/lib/middleman-core/extensions/relative_assets.rb @@ -14,14 +14,17 @@ class Middleman::Extensions::RelativeAssets < ::Middleman::Extension # asset_url override for relative assets # @param [String] path # @param [String] prefix + # @param [Hash] options Data to pass through. # @return [String] - def asset_url(path, prefix='') - path = super(path, prefix) + def asset_url(path, prefix='', options={}) + path = super - if path.include?('//') || path.start_with?('data:') || !current_resource + requested_resource = options[:current_resource] || current_resource + + if path.include?('//') || path.start_with?('data:') || !requested_resource path else - current_dir = Pathname('/' + current_resource.destination_path) + current_dir = Pathname('/' + requested_resource.destination_path) Pathname(path).relative_path_from(current_dir.dirname).to_s end end From fac4928d50dd3a50925a1b36726636135372622e Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Thu, 3 Apr 2014 09:53:33 -0700 Subject: [PATCH 068/580] Update haml and sass deps Conflicts: Gemfile middleman/middleman.gemspec --- .gitignore | 3 ++- middleman-core/features/compass-sprites.feature | 2 +- middleman-core/middleman-core.gemspec | 2 +- middleman/middleman.gemspec | 6 +++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 859301bb..535aec06 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ Makefile .mm-pid-* .idea *.sublime-workspace -/bin \ No newline at end of file +/bin +middleman-core/fixtures/compass-sprites-app/source/images/icon-s0de2218f58.png \ No newline at end of file diff --git a/middleman-core/features/compass-sprites.feature b/middleman-core/features/compass-sprites.feature index 2de35eb1..871c277a 100644 --- a/middleman-core/features/compass-sprites.feature +++ b/middleman-core/features/compass-sprites.feature @@ -3,4 +3,4 @@ Feature: Compass sprites should be generated on build and copied Given a successfully built app at "compass-sprites-app" When I cd to "build" Then the following files should exist: - | images/icon-s1a8aa64128.png | \ No newline at end of file + | images/icon-s0de2218f58.png | \ No newline at end of file diff --git a/middleman-core/middleman-core.gemspec b/middleman-core/middleman-core.gemspec index 3545a8ee..ca5d36de 100644 --- a/middleman-core/middleman-core.gemspec +++ b/middleman-core/middleman-core.gemspec @@ -29,7 +29,7 @@ Gem::Specification.new do |s| s.add_dependency('activesupport', ['~> 4.0.1']) # Watcher - s.add_dependency('listen', ['~> 1.3']) + s.add_dependency('listen', ['~> 1.1']) # i18n s.add_dependency('i18n', ['~> 0.6.9']) diff --git a/middleman/middleman.gemspec b/middleman/middleman.gemspec index 7fc4d005..5ccf0169 100644 --- a/middleman/middleman.gemspec +++ b/middleman/middleman.gemspec @@ -22,9 +22,9 @@ Gem::Specification.new do |s| s.add_dependency('middleman-cli', Middleman::VERSION) s.add_dependency('middleman-templates', Middleman::VERSION) s.add_dependency('middleman-sprockets', '>= 3.1.2') - s.add_dependency('haml', ['>= 3.1.6']) - s.add_dependency('sass', ['>= 3.1.20']) - s.add_dependency('compass', ['>= 0.12.2']) + s.add_dependency("haml", [">= 4.0.5"]) + s.add_dependency("sass", [">= 3.3.4"]) + s.add_dependency("compass", [">= 1.0.0.alpha.19"]) s.add_dependency('uglifier', ['~> 2.4.0']) s.add_dependency('coffee-script', ['~> 2.2.0']) s.add_dependency('execjs', ['~> 2.0.2']) From d4d1391bbbf167f46599c274aa6a8b42d87fb0d0 Mon Sep 17 00:00:00 2001 From: Adam Luikart Date: Mon, 7 Apr 2014 17:34:26 -0500 Subject: [PATCH 069/580] Don't hang on to the first Logger instance you see If the main app instance hangs on to the logger that ::Middleman::Logger.singleton returns, then subsequent calls to re-init the logger won't have any effect (for instance, when setting up the preview server's logger based on CLI params). Redefining logger to be a pass-through to ::Middleman::Logger.singleton instead of an ivar seems more in keeping with the sprit of a singleton, anyways. This fixes an issue where running `middleman server --verbose` doesn't output any debug info. --- middleman-core/lib/middleman-core/application.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb index 8c2c9352..91eab8c7 100644 --- a/middleman-core/lib/middleman-core/application.rb +++ b/middleman-core/lib/middleman-core/application.rb @@ -149,7 +149,9 @@ module Middleman include Middleman::CoreExtensions::ExternalHelpers # Reference to Logger singleton - attr_reader :logger + def logger + ::Middleman::Logger.singleton + end # New container for config.rb commands attr_reader :config_context @@ -167,7 +169,6 @@ module Middleman # Initialize the Middleman project def initialize(&block) - @logger = ::Middleman::Logger.singleton @template_context_class = Class.new(Middleman::TemplateContext) @generic_template_context = @template_context_class.new(self) @config_context = ConfigContext.new(self, @template_context_class) From e57318f7c6511efddfb522c1fbb42de91d33607b Mon Sep 17 00:00:00 2001 From: Ted Lilley Date: Sat, 12 Apr 2014 15:17:38 -0400 Subject: [PATCH 070/580] update to html5-boilerplate 4.3.0 --- .../html5/source/.htaccess | 1059 ++++++++++------- .../middleman-templates/html5/source/404.html | 190 +-- .../html5/source/CHANGELOG.md | 197 +++ .../html5/source/CONTRIBUTING.md | 154 +++ .../html5/source/LICENSE.md | 0 .../html5/source/README.md | 17 +- .../apple-touch-icon-114x114-precomposed.png | Bin 2042 -> 0 bytes .../apple-touch-icon-144x144-precomposed.png | Bin 1795 -> 0 bytes .../apple-touch-icon-57x57-precomposed.png | Bin 1144 -> 0 bytes .../apple-touch-icon-72x72-precomposed.png | Bin 1351 -> 0 bytes .../source/apple-touch-icon-precomposed.png | Bin 1144 -> 1076 bytes .../html5/source/apple-touch-icon.png | Bin 1144 -> 0 bytes .../html5/source/crossdomain.xml | 0 .../html5/source/css/main.css | 44 +- .../html5/source/css/normalize.css | 213 ++-- .../html5/source/favicon.ico | Bin 318 -> 766 bytes .../html5/source/humans.txt | 2 +- .../html5/source/img/.gitignore | 0 .../html5/source/js/main.js | 0 .../html5/source/js/plugins.js | 30 +- .../source/js/vendor/jquery-1.11.0.min.js | 4 + .../source/js/vendor/modernizr-2.7.1.min.js | 4 + .../html5/source/layouts/layout.erb | 26 +- .../html5/source/robots.txt | 4 +- 24 files changed, 1188 insertions(+), 756 deletions(-) mode change 100755 => 100644 middleman-templates/lib/middleman-templates/html5/source/.htaccess mode change 100755 => 100644 middleman-templates/lib/middleman-templates/html5/source/404.html create mode 100644 middleman-templates/lib/middleman-templates/html5/source/CHANGELOG.md create mode 100644 middleman-templates/lib/middleman-templates/html5/source/CONTRIBUTING.md mode change 100755 => 100644 middleman-templates/lib/middleman-templates/html5/source/LICENSE.md mode change 100755 => 100644 middleman-templates/lib/middleman-templates/html5/source/README.md delete mode 100755 middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon-114x114-precomposed.png delete mode 100755 middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon-144x144-precomposed.png delete mode 100755 middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon-57x57-precomposed.png delete mode 100755 middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon-72x72-precomposed.png mode change 100755 => 100644 middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon-precomposed.png delete mode 100755 middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon.png mode change 100755 => 100644 middleman-templates/lib/middleman-templates/html5/source/crossdomain.xml mode change 100755 => 100644 middleman-templates/lib/middleman-templates/html5/source/css/main.css mode change 100755 => 100644 middleman-templates/lib/middleman-templates/html5/source/css/normalize.css mode change 100755 => 100644 middleman-templates/lib/middleman-templates/html5/source/favicon.ico mode change 100755 => 100644 middleman-templates/lib/middleman-templates/html5/source/humans.txt mode change 100755 => 100644 middleman-templates/lib/middleman-templates/html5/source/img/.gitignore mode change 100755 => 100644 middleman-templates/lib/middleman-templates/html5/source/js/main.js mode change 100755 => 100644 middleman-templates/lib/middleman-templates/html5/source/js/plugins.js create mode 100644 middleman-templates/lib/middleman-templates/html5/source/js/vendor/jquery-1.11.0.min.js create mode 100644 middleman-templates/lib/middleman-templates/html5/source/js/vendor/modernizr-2.7.1.min.js mode change 100755 => 100644 middleman-templates/lib/middleman-templates/html5/source/layouts/layout.erb mode change 100755 => 100644 middleman-templates/lib/middleman-templates/html5/source/robots.txt diff --git a/middleman-templates/lib/middleman-templates/html5/source/.htaccess b/middleman-templates/lib/middleman-templates/html5/source/.htaccess old mode 100755 new mode 100644 index ee747dfc..63c0aaca --- a/middleman-templates/lib/middleman-templates/html5/source/.htaccess +++ b/middleman-templates/lib/middleman-templates/html5/source/.htaccess @@ -1,287 +1,123 @@ -# Apache configuration file -# httpd.apache.org/docs/2.2/mod/quickreference.html +# Apache Server Configs v2.3.0 | MIT License +# https://github.com/h5bp/server-configs-apache -# Note .htaccess files are an overhead, this logic should be in your Apache -# config if possible: httpd.apache.org/docs/2.2/howto/htaccess.html +# (!) Using `.htaccess` files slows down Apache, therefore, if you have access +# to the main server config file (usually called `httpd.conf`), you should add +# this logic there: http://httpd.apache.org/docs/current/howto/htaccess.html. -# Techniques in here adapted from all over, including: -# Kroc Camen: camendesign.com/.htaccess -# perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/ -# Sample .htaccess file of CMS MODx: modxcms.com +# ############################################################################## +# # CROSS-ORIGIN RESOURCE SHARING (CORS) # +# ############################################################################## +# ------------------------------------------------------------------------------ +# | Cross-domain AJAX requests | +# ------------------------------------------------------------------------------ -# ---------------------------------------------------------------------- -# Better website experience for IE users -# ---------------------------------------------------------------------- - -# Force the latest IE version, in various cases when it may fall back to IE7 mode -# github.com/rails/rails/commit/123eb25#commitcomment-118920 -# Use ChromeFrame if it's installed for a better experience for the poor IE folk - - - Header set X-UA-Compatible "IE=Edge,chrome=1" - # mod_headers can't match by content-type, but we don't want to send this header on *everything*... - - Header unset X-UA-Compatible - - - - -# ---------------------------------------------------------------------- -# Cross-domain AJAX requests -# ---------------------------------------------------------------------- - -# Serve cross-domain Ajax requests, disabled by default. -# enable-cors.org -# code.google.com/p/html5security/wiki/CrossOriginRequestSecurity - -# -# Header set Access-Control-Allow-Origin "*" -# - - -# ---------------------------------------------------------------------- -# CORS-enabled images (@crossorigin) -# ---------------------------------------------------------------------- - -# Send CORS headers if browsers request them; enabled by default for images. -# developer.mozilla.org/en/CORS_Enabled_Image -# blog.chromium.org/2011/07/using-cross-domain-images-in-webgl-and.html -# hacks.mozilla.org/2011/11/using-cors-to-load-webgl-textures-from-cross-domain-images/ -# wiki.mozilla.org/Security/Reviews/crossoriginAttribute - - - - # mod_headers, y u no match by Content-Type?! - - SetEnvIf Origin ":" IS_CORS - Header set Access-Control-Allow-Origin "*" env=IS_CORS - - - - - -# ---------------------------------------------------------------------- -# Webfont access -# ---------------------------------------------------------------------- - -# Allow access from all domains for webfonts. -# Alternatively you could only whitelist your -# subdomains like "subdomain.example.com". - - - - Header set Access-Control-Allow-Origin "*" - - - - -# ---------------------------------------------------------------------- -# Proper MIME type for all files -# ---------------------------------------------------------------------- - -# JavaScript -# Normalize to standard type (it's sniffed in IE anyways) -# tools.ietf.org/html/rfc4329#section-7.2 -AddType application/javascript js jsonp -AddType application/json json - -# Audio -AddType audio/ogg oga ogg -AddType audio/mp4 m4a f4a f4b - -# Video -AddType video/ogg ogv -AddType video/mp4 mp4 m4v f4v f4p -AddType video/webm webm -AddType video/x-flv flv - -# SVG -# Required for svg webfonts on iPad -# twitter.com/FontSquirrel/status/14855840545 -AddType image/svg+xml svg svgz -AddEncoding gzip svgz - -# Webfonts -AddType application/vnd.ms-fontobject eot -AddType application/x-font-ttf ttf ttc -AddType font/opentype otf -AddType application/x-font-woff woff - -# Assorted types -AddType image/x-icon ico -AddType image/webp webp -AddType text/cache-manifest appcache manifest -AddType text/x-component htc -AddType application/xml rss atom xml rdf -AddType application/x-chrome-extension crx -AddType application/x-opera-extension oex -AddType application/x-xpinstall xpi -AddType application/octet-stream safariextz -AddType application/x-web-app-manifest+json webapp -AddType text/x-vcard vcf -AddType application/x-shockwave-flash swf -AddType text/vtt vtt - - -# ---------------------------------------------------------------------- -# Allow concatenation from within specific js and css files -# ---------------------------------------------------------------------- - -# e.g. Inside of script.combined.js you could have -# -# -# and they would be included into this single file. - -# This is not in use in the boilerplate as it stands. You may -# choose to use this technique if you do not have a build process. - -# -# Options +Includes -# AddOutputFilterByType INCLUDES application/javascript application/json -# SetOutputFilter INCLUDES -# - -# -# Options +Includes -# AddOutputFilterByType INCLUDES text/css -# SetOutputFilter INCLUDES -# - - -# ---------------------------------------------------------------------- -# Gzip compression -# ---------------------------------------------------------------------- - - - - # Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/ - - - SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding - RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding - - - - # Compress all output labeled with one of the following MIME-types - - AddOutputFilterByType DEFLATE application/atom+xml \ - application/javascript \ - application/json \ - application/rss+xml \ - application/vnd.ms-fontobject \ - application/x-font-ttf \ - application/xhtml+xml \ - application/xml \ - font/opentype \ - image/svg+xml \ - image/x-icon \ - text/css \ - text/html \ - text/plain \ - text/x-component \ - text/xml - - - - - -# ---------------------------------------------------------------------- -# Expires headers (for better cache control) -# ---------------------------------------------------------------------- - -# These are pretty far-future expires headers. -# They assume you control versioning with filename-based cache busting -# Additionally, consider that outdated proxies may miscache -# www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/ - -# If you don't use filenames to version, lower the CSS and JS to something like -# "access plus 1 week". - - - ExpiresActive on - -# Perhaps better to whitelist expires rules? Perhaps. - ExpiresDefault "access plus 1 month" - -# cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5) - ExpiresByType text/cache-manifest "access plus 0 seconds" - -# Your document html - ExpiresByType text/html "access plus 0 seconds" - -# Data - ExpiresByType text/xml "access plus 0 seconds" - ExpiresByType application/xml "access plus 0 seconds" - ExpiresByType application/json "access plus 0 seconds" - -# Feed - ExpiresByType application/rss+xml "access plus 1 hour" - ExpiresByType application/atom+xml "access plus 1 hour" - -# Favicon (cannot be renamed) - ExpiresByType image/x-icon "access plus 1 week" - -# Media: images, video, audio - ExpiresByType image/gif "access plus 1 month" - ExpiresByType image/png "access plus 1 month" - ExpiresByType image/jpeg "access plus 1 month" - ExpiresByType video/ogg "access plus 1 month" - ExpiresByType audio/ogg "access plus 1 month" - ExpiresByType video/mp4 "access plus 1 month" - ExpiresByType video/webm "access plus 1 month" - -# HTC files (css3pie) - ExpiresByType text/x-component "access plus 1 month" - -# Webfonts - ExpiresByType application/x-font-ttf "access plus 1 month" - ExpiresByType font/opentype "access plus 1 month" - ExpiresByType application/x-font-woff "access plus 1 month" - ExpiresByType image/svg+xml "access plus 1 month" - ExpiresByType application/vnd.ms-fontobject "access plus 1 month" - -# CSS and JavaScript - ExpiresByType text/css "access plus 1 year" - ExpiresByType application/javascript "access plus 1 year" - - - - -# ---------------------------------------------------------------------- -# Prevent mobile network providers from modifying your site -# ---------------------------------------------------------------------- - -# The following header prevents modification of your code over 3G on some -# European providers. -# This is the official 'bypass' suggested by O2 in the UK. +# Allow cross-origin AJAX requests. +# http://code.google.com/p/html5security/wiki/CrossOriginRequestSecurity +# http://enable-cors.org/ # -# Header set Cache-Control "no-transform" +# Header set Access-Control-Allow-Origin "*" # +# ------------------------------------------------------------------------------ +# | CORS-enabled images | +# ------------------------------------------------------------------------------ -# ---------------------------------------------------------------------- -# ETag removal -# ---------------------------------------------------------------------- +# Send the CORS header for images when browsers request it. +# https://developer.mozilla.org/en-US/docs/HTML/CORS_Enabled_Image +# http://blog.chromium.org/2011/07/using-cross-domain-images-in-webgl-and.html +# http://hacks.mozilla.org/2011/11/using-cors-to-load-webgl-textures-from-cross-domain-images/ -# FileETag None is not enough for every server. - - Header unset ETag + + + + SetEnvIf Origin ":" IS_CORS + Header set Access-Control-Allow-Origin "*" env=IS_CORS + + -# Since we're sending far-future expires, we don't need ETags for -# static content. -# developer.yahoo.com/performance/rules.html#etags -FileETag None +# ------------------------------------------------------------------------------ +# | Web fonts access | +# ------------------------------------------------------------------------------ + +# Allow access to web fonts from all domains. + + + + Header set Access-Control-Allow-Origin "*" + + -# ---------------------------------------------------------------------- -# Stop screen flicker in IE on CSS rollovers -# ---------------------------------------------------------------------- +# ############################################################################## +# # ERRORS # +# ############################################################################## -# The following directives stop screen flicker in IE on CSS rollovers - in -# combination with the "ExpiresByType" rules for images (see above). +# ------------------------------------------------------------------------------ +# | 404 error prevention for non-existing redirected folders | +# ------------------------------------------------------------------------------ + +# Prevent Apache from returning a 404 error as the result of a rewrite +# when the directory with the same name does not exist. +# http://httpd.apache.org/docs/current/content-negotiation.html#multiviews +# http://www.webmasterworld.com/apache/3808792.htm + +Options -MultiViews + +# ------------------------------------------------------------------------------ +# | Custom error messages / pages | +# ------------------------------------------------------------------------------ + +# Customize what Apache returns to the client in case of an error. +# http://httpd.apache.org/docs/current/mod/core.html#errordocument + +ErrorDocument 404 /404.html + + +# ############################################################################## +# # INTERNET EXPLORER # +# ############################################################################## + +# ------------------------------------------------------------------------------ +# | Better website experience | +# ------------------------------------------------------------------------------ + +# Force Internet Explorer to render pages in the highest available mode +# in the various cases when it may not. +# http://hsivonen.iki.fi/doctype/ie-mode.pdf + + + Header set X-UA-Compatible "IE=edge" + # `mod_headers` cannot match based on the content-type, however, this + # header should be send only for HTML pages and not for the other resources + + Header unset X-UA-Compatible + + + +# ------------------------------------------------------------------------------ +# | Cookie setting from iframes | +# ------------------------------------------------------------------------------ + +# Allow cookies to be set from iframes in Internet Explorer. +# http://msdn.microsoft.com/en-us/library/ms537343.aspx +# http://www.w3.org/TR/2000/CR-P3P-20001215/ + +# +# Header set P3P "policyref=\"/w3c/p3p.xml\", CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"" +# + +# ------------------------------------------------------------------------------ +# | Screen flicker | +# ------------------------------------------------------------------------------ + +# Stop screen flicker in Internet Explorer on CSS rollovers. + +# IMPORTANT: This will only work in combination with the image related +# `ExpiresByType` directives from below. # BrowserMatch "MSIE" brokenvary=1 # BrowserMatch "Mozilla/4.[0-9]{2}" brokenvary=1 @@ -289,252 +125,555 @@ FileETag None # SetEnvIf brokenvary 1 force-no-vary -# ---------------------------------------------------------------------- -# Set Keep-Alive Header -# ---------------------------------------------------------------------- +# ############################################################################## +# # MIME TYPES AND ENCODING # +# ############################################################################## -# Keep-Alive allows the server to send multiple requests through one -# TCP-connection. Be aware of possible disadvantages of this setting. Turn on -# if you serve a lot of static content. +# ------------------------------------------------------------------------------ +# | Proper MIME types for all files | +# ------------------------------------------------------------------------------ -# -# Header set Connection Keep-Alive -# + + # Audio + AddType audio/mp4 m4a f4a f4b + AddType audio/ogg oga ogg opus -# ---------------------------------------------------------------------- -# Cookie setting from iframes -# ---------------------------------------------------------------------- + # Data interchange + AddType application/json json map + AddType application/ld+json jsonld -# Allow cookies to be set from iframes (for IE only) -# If needed, specify a path or regex in the Location directive. + # JavaScript + # Normalize to standard type. + # http://tools.ietf.org/html/rfc4329#section-7.2 + AddType application/javascript js -# -# Header set P3P "policyref=\"/w3c/p3p.xml\", CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"" -# + # Video + AddType video/mp4 f4v f4p m4v mp4 + AddType video/ogg ogv + AddType video/webm webm + AddType video/x-flv flv + # Web fonts + AddType application/font-woff woff + AddType application/vnd.ms-fontobject eot -# ---------------------------------------------------------------------- -# Start rewrite engine -# ---------------------------------------------------------------------- + # Browsers usually ignore the font MIME types and simply sniff the bytes + # to figure out the font type. + # http://mimesniff.spec.whatwg.org/#matching-a-font-type-pattern -# Turning on the rewrite engine is necessary for the following rules and -# features. FollowSymLinks must be enabled for this to work. + # Chrome however, shows a warning if any other MIME types are used for + # the following fonts. -# Some cloud hosting services require RewriteBase to be set: goo.gl/HOcPN -# If using the h5bp in a subdirectory, use `RewriteBase /foo` instead where -# 'foo' is your directory. + AddType application/x-font-ttf ttc ttf + AddType font/opentype otf -# If your web host doesn't allow the FollowSymlinks option, you may need to -# comment it out and use `Options +SymLinksOfOwnerMatch`, but be aware of the -# performance impact: http://goo.gl/Mluzd + # Make SVGZ fonts work on the iPad. + # https://twitter.com/FontSquirrel/status/14855840545 + AddType image/svg+xml svgz + AddEncoding gzip svgz - - Options +FollowSymlinks -# Options +SymLinksIfOwnerMatch - RewriteEngine On -# RewriteBase / + # Other + AddType application/octet-stream safariextz + AddType application/x-chrome-extension crx + AddType application/x-opera-extension oex + AddType application/x-web-app-manifest+json webapp + AddType application/x-xpinstall xpi + AddType application/xml atom rdf rss xml + AddType image/webp webp + AddType image/x-icon cur + AddType text/cache-manifest appcache manifest + AddType text/vtt vtt + AddType text/x-component htc + AddType text/x-vcard vcf + + + +# ------------------------------------------------------------------------------ +# | UTF-8 encoding | +# ------------------------------------------------------------------------------ + +# Use UTF-8 encoding for anything served as `text/html` or `text/plain`. +AddDefaultCharset utf-8 + +# Force UTF-8 for certain file formats. + + AddCharset utf-8 .atom .css .js .json .jsonld .rss .vtt .webapp .xml -# ---------------------------------------------------------------------- -# Suppress or force the "www." at the beginning of URLs -# ---------------------------------------------------------------------- +# ############################################################################## +# # URL REWRITES # +# ############################################################################## -# The same content should never be available under two different URLs - -# especially not with and without "www." at the beginning, since this can cause -# SEO problems (duplicate content). That's why you should choose one of the -# alternatives and redirect the other one. +# ------------------------------------------------------------------------------ +# | Rewrite engine | +# ------------------------------------------------------------------------------ -# By default option 1 (no "www.") is activated. -# no-www.org/faq.php?q=class_b +# Turn on the rewrite engine and enable the `FollowSymLinks` option (this is +# necessary in order for the following directives to work). -# If you'd prefer to use option 2, just comment out all option 1 lines -# and uncomment option 2. +# If your web host doesn't allow the `FollowSymlinks` option, you may need to +# comment it out and use `Options +SymLinksIfOwnerMatch`, but be aware of the +# performance impact. +# http://httpd.apache.org/docs/current/misc/perf-tuning.html#symlinks + +# Also, some cloud hosting services require `RewriteBase` to be set. +# http://www.rackspace.com/knowledge_center/frequently-asked-question/why-is-mod-rewrite-not-working-on-my-site + + + Options +FollowSymlinks + # Options +SymLinksIfOwnerMatch + RewriteEngine On + # RewriteBase / + + +# ------------------------------------------------------------------------------ +# | Suppressing / Forcing the `www.` at the beginning of URLs | +# ------------------------------------------------------------------------------ + +# The same content should never be available under two different URLs, +# especially not with and without `www.` at the beginning. This can cause +# SEO problems (duplicate content), and therefore, you should choose one +# of the alternatives and redirect the other one. + +# By default `Option 1` (no `www.`) is activated. +# http://no-www.org/faq.php?q=class_b + +# If you would prefer to use `Option 2`, just comment out all the lines +# from `Option 1` and uncomment the ones from `Option 2`. # IMPORTANT: NEVER USE BOTH RULES AT THE SAME TIME! -# ---------------------------------------------------------------------- +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Option 1: -# Rewrite "www.example.com -> example.com". +# Option 1: rewrite www.example.com → example.com - RewriteCond %{HTTPS} !=on - RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] - RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L] + RewriteCond %{HTTPS} !=on + RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] + RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L] -# ---------------------------------------------------------------------- +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Option 2: -# Rewrite "example.com -> www.example.com". -# Be aware that the following rule might not be a good idea if you use "real" +# Option 2: rewrite example.com → www.example.com + +# Be aware that the following might not be a good idea if you use "real" # subdomains for certain parts of your website. # -# RewriteCond %{HTTPS} !=on -# RewriteCond %{HTTP_HOST} !^www\..+$ [NC] -# RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] +# RewriteCond %{HTTPS} !=on +# RewriteCond %{HTTP_HOST} !^www\. [NC] +# RewriteCond %{SERVER_ADDR} !=127.0.0.1 +# RewriteCond %{SERVER_ADDR} !=::1 +# RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # -# ---------------------------------------------------------------------- -# Built-in filename-based cache busting -# ---------------------------------------------------------------------- +# ############################################################################## +# # SECURITY # +# ############################################################################## -# If you're not using the build script to manage your filename version revving, -# you might want to consider enabling this, which will route requests for -# /css/style.20110203.css to /css/style.css +# ------------------------------------------------------------------------------ +# | Clickjacking | +# ------------------------------------------------------------------------------ -# To understand why this is important and a better idea than all.css?v1231, -# read: github.com/h5bp/html5-boilerplate/wiki/cachebusting +# Protect website against clickjacking. -# -# RewriteCond %{REQUEST_FILENAME} !-f -# RewriteCond %{REQUEST_FILENAME} !-d -# RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L] +# The example below sends the `X-Frame-Options` response header with the value +# `DENY`, informing browsers not to display the web page content in any frame. + +# This might not be the best setting for everyone. You should read about the +# other two possible values for `X-Frame-Options`: `SAMEORIGIN` & `ALLOW-FROM`. +# http://tools.ietf.org/html/rfc7034#section-2.1 + +# Keep in mind that while you could send the `X-Frame-Options` header for all +# of your site’s pages, this has the potential downside that it forbids even +# non-malicious framing of your content (e.g.: when users visit your site using +# a Google Image Search results page). + +# Nonetheless, you should ensure that you send the `X-Frame-Options` header for +# all pages that allow a user to make a state changing operation (e.g: pages +# that contain one-click purchase links, checkout or bank-transfer confirmation +# pages, pages that make permanent configuration changes, etc.). + +# Sending the `X-Frame-Options` header can also protect your website against +# more than just clickjacking attacks: https://cure53.de/xfo-clickjacking.pdf. + +# http://tools.ietf.org/html/rfc7034 +# http://blogs.msdn.com/b/ieinternals/archive/2010/03/30/combating-clickjacking-with-x-frame-options.aspx +# https://www.owasp.org/index.php/Clickjacking + +# +# Header set X-Frame-Options "DENY" +# +# Header unset X-Frame-Options +# # +# ------------------------------------------------------------------------------ +# | Content Security Policy (CSP) | +# ------------------------------------------------------------------------------ -# ---------------------------------------------------------------------- -# Prevent SSL cert warnings -# ---------------------------------------------------------------------- +# Mitigate the risk of cross-site scripting and other content-injection attacks. -# Rewrite secure requests properly to prevent SSL cert warnings, e.g. prevent -# https://www.example.com when your cert only allows https://secure.example.com +# This can be done by setting a `Content Security Policy` which whitelists +# trusted sources of content for your website. -# -# RewriteCond %{SERVER_PORT} !^443 -# RewriteRule ^ https://example-domain-please-change-me.com%{REQUEST_URI} [R=301,L] +# The example header below allows ONLY scripts that are loaded from the current +# site's origin (no inline scripts, no CDN, etc). This almost certainly won't +# work as-is for your site! + +# For more details on how to craft a reasonable policy for your site, read: +# http://html5rocks.com/en/tutorials/security/content-security-policy (or the +# specification: http://w3.org/TR/CSP). Also, to make things easier, you can +# use an online CSP header generator such as: http://cspisawesome.com/. + +# +# Header set Content-Security-Policy "script-src 'self'; object-src 'self'" +# +# Header unset Content-Security-Policy +# # +# ------------------------------------------------------------------------------ +# | File access | +# ------------------------------------------------------------------------------ -# ---------------------------------------------------------------------- -# Prevent 404 errors for non-existing redirected folders -# ---------------------------------------------------------------------- +# Block access to directories without a default document. +# You should leave the following uncommented, as you shouldn't allow anyone to +# surf through every directory on your server (which may includes rather private +# places such as the CMS's directories). -# without -MultiViews, Apache will give a 404 for a rewrite if a folder of the -# same name does not exist. -# webmasterworld.com/apache/3808792.htm - -Options -MultiViews - - -# ---------------------------------------------------------------------- -# Custom 404 page -# ---------------------------------------------------------------------- - -# You can add custom pages to handle 500 or 403 pretty easily, if you like. -# If you are hosting your site in subdirectory, adjust this accordingly -# e.g. ErrorDocument 404 /subdir/404.html -ErrorDocument 404 /404.html - - -# ---------------------------------------------------------------------- -# UTF-8 encoding -# ---------------------------------------------------------------------- - -# Use UTF-8 encoding for anything served text/plain or text/html -AddDefaultCharset utf-8 - -# Force UTF-8 for a number of file formats -AddCharset utf-8 .atom .css .js .json .rss .vtt .xml - - -# ---------------------------------------------------------------------- -# A little more security -# ---------------------------------------------------------------------- - -# To avoid displaying the exact version number of Apache being used, add the -# following to httpd.conf (it will not work in .htaccess): -# ServerTokens Prod - -# "-Indexes" will have Apache block users from browsing folders without a -# default document Usually you should leave this activated, because you -# shouldn't allow everybody to surf through every folder on your server (which -# includes rather private places like CMS system folders). - Options -Indexes + Options -Indexes -# Block access to "hidden" directories or files whose names begin with a -# period. This includes directories used by version control systems such as -# Subversion or Git. +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Block access to hidden files and directories. +# This includes directories used by version control systems such as Git and SVN. + - RewriteCond %{SCRIPT_FILENAME} -d [OR] - RewriteCond %{SCRIPT_FILENAME} -f - RewriteRule "(^|/)\." - [F] + RewriteCond %{SCRIPT_FILENAME} -d [OR] + RewriteCond %{SCRIPT_FILENAME} -f + RewriteRule "(^|/)\." - [F] -# Block access to backup and source files. These files may be left by some -# text/html editors and pose a great security danger, when anyone can access -# them. - - Order allow,deny - Deny from all - Satisfy All +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Block access to files that can expose sensitive information. + +# By default, block access to backup and source files that may be left by some +# text editors and can pose a security risk when anyone has access to them. +# http://feross.org/cmsploit/ + +# IMPORTANT: Update the `` regular expression from below to include +# any files that might end up on your production server and can expose sensitive +# information about your website. These files may include: configuration files, +# files that contain metadata about the project (e.g.: project dependencies), +# build scripts, etc.. + + + + # Apache < 2.3 + + Order allow,deny + Deny from all + Satisfy All + + + # Apache ≥ 2.3 + + Require all denied + + -# If your server is not already configured as such, the following directive -# should be uncommented in order to set PHP's register_globals option to OFF. -# This closes a major security hole that is abused by most XSS (cross-site -# scripting) attacks. For more information: http://php.net/register_globals -# -# IF REGISTER_GLOBALS DIRECTIVE CAUSES 500 INTERNAL SERVER ERRORS: -# -# Your server does not allow PHP directives to be set via .htaccess. In that -# case you must make this change in your php.ini file instead. If you are -# using a commercial web host, contact the administrators for assistance in -# doing this. Not all servers allow local php.ini files, and they should -# include all PHP configurations (not just this one), or you will effectively -# reset everything to PHP defaults. Consult www.php.net for more detailed -# information about setting PHP directives. +# ------------------------------------------------------------------------------ +# | Reducing MIME type security risks | +# ------------------------------------------------------------------------------ -# php_flag register_globals Off +# Prevent some browsers from MIME-sniffing the response. -# Rename session cookie to something else, than PHPSESSID -# php_value session.name sid +# This reduces exposure to drive-by download attacks and cross-origin data +# leaks, and should be left uncommented, especially if the web server is +# serving user-uploaded content or content that could potentially be treated +# as executable by the browser. -# Disable magic quotes (This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.) -# php_flag magic_quotes_gpc Off +# http://www.slideshare.net/hasegawayosuke/owasp-hasegawa +# http://blogs.msdn.com/b/ie/archive/2008/07/02/ie8-security-part-v-comprehensive-protection.aspx +# http://msdn.microsoft.com/en-us/library/ie/gg622941.aspx +# http://mimesniff.spec.whatwg.org/ -# Do not show you are using PHP -# Note: Move this line to php.ini since it won't work in .htaccess -# php_flag expose_php Off - -# Level of log detail - log all errors -# php_value error_reporting -1 - -# Write errors to log file -# php_flag log_errors On - -# Do not display errors in browser (production - Off, development - On) -# php_flag display_errors Off - -# Do not display startup errors (production - Off, development - On) -# php_flag display_startup_errors Off - -# Format errors in plain text -# Note: Leave this setting 'On' for xdebug's var_dump() output -# php_flag html_errors Off - -# Show multiple occurrence of error -# php_flag ignore_repeated_errors Off - -# Show same errors from different sources -# php_flag ignore_repeated_source Off - -# Size limit for error messages -# php_value log_errors_max_len 1024 - -# Don't precede error with string (doesn't accept empty string, use whitespace if you need) -# php_value error_prepend_string " " - -# Don't prepend to error (doesn't accept empty string, use whitespace if you need) -# php_value error_append_string " " - -# Increase cookie security - - php_value session.cookie_httponly true + + Header set X-Content-Type-Options "nosniff" + +# ------------------------------------------------------------------------------ +# | Reflected Cross-Site Scripting (XSS) attacks | +# ------------------------------------------------------------------------------ + +# (1) Try to re-enable the Cross-Site Scripting (XSS) filter built into the +# most recent web browsers. +# +# The filter is usually enabled by default, but in some cases it may be +# disabled by the user. However, in Internet Explorer for example, it can +# be re-enabled just by sending the `X-XSS-Protection` header with the +# value of `1`. +# +# (2) Prevent web browsers from rendering the web page if a potential reflected +# (a.k.a non-persistent) XSS attack is detected by the filter. +# +# By default, if the filter is enabled and browsers detect a reflected +# XSS attack, they will attempt to block the attack by making the smallest +# possible modifications to the returned web page. +# +# Unfortunately, in some browsers (e.g.: Internet Explorer), this default +# behavior may allow the XSS filter to be exploited, thereby, it's better +# to tell browsers to prevent the rendering of the page altogether, instead +# of attempting to modify it. +# +# http://hackademix.net/2009/11/21/ies-xss-filter-creates-xss-vulnerabilities +# +# IMPORTANT: Do not rely on the XSS filter to prevent XSS attacks! Ensure that +# you are taking all possible measures to prevent XSS attacks, the most obvious +# being: validating and sanitizing your site's inputs. +# +# http://blogs.msdn.com/b/ie/archive/2008/07/02/ie8-security-part-iv-the-xss-filter.aspx +# http://blogs.msdn.com/b/ieinternals/archive/2011/01/31/controlling-the-internet-explorer-xss-filter-with-the-x-xss-protection-http-header.aspx +# https://www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29 + +# +# # (1) (2) +# Header set X-XSS-Protection "1; mode=block" +# +# Header unset X-XSS-Protection +# +# + +# ------------------------------------------------------------------------------ +# | Secure Sockets Layer (SSL) | +# ------------------------------------------------------------------------------ + +# Rewrite secure requests properly in order to prevent SSL certificate warnings. +# E.g.: prevent `https://www.example.com` when your certificate only allows +# `https://secure.example.com`. + +# +# RewriteCond %{SERVER_PORT} !^443 +# RewriteRule ^ https://example-domain-please-change-me.com%{REQUEST_URI} [R=301,L] +# + +# ------------------------------------------------------------------------------ +# | HTTP Strict Transport Security (HSTS) | +# ------------------------------------------------------------------------------ + +# Force client-side SSL redirection. + +# If a user types `example.com` in his browser, the above rule will redirect +# him to the secure version of the site. That still leaves a window of +# opportunity (the initial HTTP connection) for an attacker to downgrade or +# redirect the request. + +# The following header ensures that browser will ONLY connect to your server +# via HTTPS, regardless of what the users type in the address bar. + +# http://tools.ietf.org/html/draft-ietf-websec-strict-transport-sec-14#section-6.1 +# http://www.html5rocks.com/en/tutorials/security/transport-layer-security/ + +# IMPORTANT: Remove the `includeSubDomains` optional directive if the subdomains +# are not using HTTPS. + +# +# Header set Strict-Transport-Security "max-age=16070400; includeSubDomains" +# + +# ------------------------------------------------------------------------------ +# | Server software information | +# ------------------------------------------------------------------------------ + +# Avoid displaying the exact Apache version number, the description of the +# generic OS-type and the information about Apache's compiled-in modules. + +# ADD THIS DIRECTIVE IN THE `httpd.conf` AS IT WILL NOT WORK IN THE `.htaccess`! + +# ServerTokens Prod + + +# ############################################################################## +# # WEB PERFORMANCE # +# ############################################################################## + +# ------------------------------------------------------------------------------ +# | Compression | +# ------------------------------------------------------------------------------ + + + + # Force compression for mangled headers. + # http://developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping + + + SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding + RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding + + + + # Compress all output labeled with one of the following MIME-types + # (for Apache versions below 2.3.7, you don't need to enable `mod_filter` + # and can remove the `` and `` lines + # as `AddOutputFilterByType` is still in the core directives). + + AddOutputFilterByType DEFLATE application/atom+xml \ + application/javascript \ + application/json \ + application/ld+json \ + application/rss+xml \ + application/vnd.ms-fontobject \ + application/x-font-ttf \ + application/x-web-app-manifest+json \ + application/xhtml+xml \ + application/xml \ + font/opentype \ + image/svg+xml \ + image/x-icon \ + text/css \ + text/html \ + text/plain \ + text/x-component \ + text/xml + + + + +# ------------------------------------------------------------------------------ +# | Content transformations | +# ------------------------------------------------------------------------------ + +# Prevent mobile network providers from modifying the website's content. +# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.5. + +# +# Header set Cache-Control "no-transform" +# + +# ------------------------------------------------------------------------------ +# | ETags | +# ------------------------------------------------------------------------------ + +# Remove `ETags` as resources are sent with far-future expires headers. +# http://developer.yahoo.com/performance/rules.html#etags. + +# `FileETag None` doesn't work in all cases. + + Header unset ETag + + +FileETag None + +# ------------------------------------------------------------------------------ +# | Expires headers | +# ------------------------------------------------------------------------------ + +# The following expires headers are set pretty far in the future. If you +# don't control versioning with filename-based cache busting, consider +# lowering the cache time for resources such as style sheets and JavaScript +# files to something like one week. + + + + ExpiresActive on + ExpiresDefault "access plus 1 month" + + # CSS + ExpiresByType text/css "access plus 1 year" + + # Data interchange + ExpiresByType application/json "access plus 0 seconds" + ExpiresByType application/ld+json "access plus 0 seconds" + ExpiresByType application/xml "access plus 0 seconds" + ExpiresByType text/xml "access plus 0 seconds" + + # Favicon (cannot be renamed!) and cursor images + ExpiresByType image/x-icon "access plus 1 week" + + # HTML components (HTCs) + ExpiresByType text/x-component "access plus 1 month" + + # HTML + ExpiresByType text/html "access plus 0 seconds" + + # JavaScript + ExpiresByType application/javascript "access plus 1 year" + + # Manifest files + ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds" + ExpiresByType text/cache-manifest "access plus 0 seconds" + + # Media + ExpiresByType audio/ogg "access plus 1 month" + ExpiresByType image/gif "access plus 1 month" + ExpiresByType image/jpeg "access plus 1 month" + ExpiresByType image/png "access plus 1 month" + ExpiresByType video/mp4 "access plus 1 month" + ExpiresByType video/ogg "access plus 1 month" + ExpiresByType video/webm "access plus 1 month" + + # Web feeds + ExpiresByType application/atom+xml "access plus 1 hour" + ExpiresByType application/rss+xml "access plus 1 hour" + + # Web fonts + ExpiresByType application/font-woff "access plus 1 month" + ExpiresByType application/vnd.ms-fontobject "access plus 1 month" + ExpiresByType application/x-font-ttf "access plus 1 month" + ExpiresByType font/opentype "access plus 1 month" + ExpiresByType image/svg+xml "access plus 1 month" + + + +# ------------------------------------------------------------------------------ +# | Filename-based cache busting | +# ------------------------------------------------------------------------------ + +# If you're not using a build process to manage your filename version revving, +# you might want to consider enabling the following directives to route all +# requests such as `/css/style.12345.css` to `/css/style.css`. + +# To understand why this is important and a better idea than `*.css?v231`, read: +# http://stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring + +# +# RewriteCond %{REQUEST_FILENAME} !-f +# RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpe?g|gif)$ $1.$3 [L] +# + +# ------------------------------------------------------------------------------ +# | File concatenation | +# ------------------------------------------------------------------------------ + +# Allow concatenation from within specific style sheets and JavaScript files. + +# e.g.: +# +# If you have the following content in a file +# +# +# +# +# Apache will replace it with the content from the specified files. + +# +# +# Options +Includes +# AddOutputFilterByType INCLUDES application/javascript application/json +# SetOutputFilter INCLUDES +# +# +# Options +Includes +# AddOutputFilterByType INCLUDES text/css +# SetOutputFilter INCLUDES +# +# diff --git a/middleman-templates/lib/middleman-templates/html5/source/404.html b/middleman-templates/lib/middleman-templates/html5/source/404.html old mode 100755 new mode 100644 index 04465441..190accc5 --- a/middleman-templates/lib/middleman-templates/html5/source/404.html +++ b/middleman-templates/lib/middleman-templates/html5/source/404.html @@ -1,157 +1,59 @@ - + - - - Page Not Found :( - - - -
-

Not found :(

-

Sorry, but the page you were trying to view does not exist.

-

It looks like this was the result of either:

-
    -
  • a mistyped address
  • -
  • an out-of-date link
  • -
- - -
- + + + +

Page Not Found

+

Sorry, but the page you were trying to view does not exist.

+ + diff --git a/middleman-templates/lib/middleman-templates/html5/source/CHANGELOG.md b/middleman-templates/lib/middleman-templates/html5/source/CHANGELOG.md new file mode 100644 index 00000000..609abef6 --- /dev/null +++ b/middleman-templates/lib/middleman-templates/html5/source/CHANGELOG.md @@ -0,0 +1,197 @@ +### HEAD + +* Update to Apache Server Configs 2.3.0. +* Use `` instead of `` + ([#1522](https://github.com/h5bp/html5-boilerplate/issues/1522)). +* Update to jQuery 1.11.0. +* Add `Disallow:` to `robots.txt` + ([#1487](https://github.com/h5bp/html5-boilerplate/issues/1487)). +* Remove default foreground color from form elements + ([#1390](https://github.com/h5bp/html5-boilerplate/issues/1390)). +* Remove default margin from print styles + ([#1477](https://github.com/h5bp/html5-boilerplate/issues/1477)). +* Update to Modernizr 2.7.1. +* Add vertical centering for `svg` + ([#1453](https://github.com/h5bp/html5-boilerplate/issues/1453)). +* Redesign 404 page + ([#1443](https://github.com/h5bp/html5-boilerplate/pull/1443)). + +### 4.3.0 (September 10, 2013) + +* Use one apple-touch-icon instead of six + ([#1367](https://github.com/h5bp/html5-boilerplate/issues/1367)). +* Move font-related declarations from `body` to `html` + ([#1411](https://github.com/h5bp/html5-boilerplate/issues/1411)). +* Update to Apache Server Configs 1.1.0. +* Add `initial-scale=1` to the viewport `meta` + ([#1398](https://github.com/h5bp/html5-boilerplate/pull/1398)). +* Vertical centering for audio-, canvas- and video-tags + ([#1326](https://github.com/h5bp/html5-boilerplate/issues/1326)). +* Remove Google Chrome Frame related code + ([#1379](https://github.com/h5bp/html5-boilerplate/pull/1379), + [#1396](https://github.com/h5bp/html5-boilerplate/pull/1396)). +* Update to Google Universal Analytics + ([#1347](https://github.com/h5bp/html5-boilerplate/issues/1347)). +* Update to jQuery 1.10.2. +* Update to Normalize.css 1.1.3. + +### 4.2.0 (April 8, 2013) + +* Remove Google Analytics protocol check + ([#1319](https://github.com/h5bp/html5-boilerplate/pull/1319)). +* Update to Normalize.css 1.1.1. +* Update Apache configurations to include the latest changes in the + canonical [`.htaccess`](https://github.com/h5bp/server-configs-apache) + file. +* Use a protocol relative URL for the 404 template script. +* Update to jQuery 1.9.1. + +### 4.1.0 (January 21, 2013) + +* Update to Normalize.css 1.1.0. +* Update to jQuery 1.9.0. + +### 4.0.3 (January 12, 2013) + +* Use 32x32 favicon.ico + ([#1286](https://github.com/h5bp/html5-boilerplate/pull/1286)). +* Remove named function expression in plugins.js + ([#1280](https://github.com/h5bp/html5-boilerplate/pull/1280)). +* Adjust CSS image-replacement code + ([#1239](https://github.com/h5bp/html5-boilerplate/issues/1239)). +* Update HiDPI example media query + ([#1127](https://github.com/h5bp/html5-boilerplate/issues/1127)). + +### 4.0.2 (December 9, 2012) + +* Update placeholder icons. +* Update to Normalize.css 1.0.2. +* Update to jQuery 1.8.3. + +### 4.0.1 (October 20, 2012) + +* Further improvements to `console` method stubbing + ([#1206](https://github.com/h5bp/html5-boilerplate/issues/1206), + [#1229](https://github.com/h5bp/html5-boilerplate/pull/1229)). +* Update to jQuery 1.8.2. +* Update to Modernizr 2.6.2. +* Minor additions to the documentation. + +### 4.0.0 (August 28, 2012) + +* Improve the Apache compression configuration + ([#1012](https://github.com/h5bp/html5-boilerplate/issues/1012), + [#1173](https://github.com/h5bp/html5-boilerplate/issues/1173)). +* Add a HiDPI example media query + ([#1127](https://github.com/h5bp/html5-boilerplate/issues/1127)). +* Add bundled docs + ([#1154](https://github.com/h5bp/html5-boilerplate/issues/1154)). +* Add MIT license + ([#1139](https://github.com/h5bp/html5-boilerplate/issues/1139)). +* Update to Normalize.css 1.0.1. +* Separate Normalize.css from the rest of the CSS + ([#1160](https://github.com/h5bp/html5-boilerplate/issues/1160)). +* Improve `console.log` protection + ([#1107](https://github.com/h5bp/html5-boilerplate/issues/1107)). +* Replace hot pink text selection color with a neutral color. +* Change image replacement technique + ([#1149](https://github.com/h5bp/html5-boilerplate/issues/1149)). +* Code format and consistency changes + ([#1112](https://github.com/h5bp/html5-boilerplate/issues/1112)). +* Rename CSS file and rename JS files and subdirectories. +* Update to jQuery 1.8 + ([#1161](https://github.com/h5bp/html5-boilerplate/issues/1161)). +* Update to Modernizr 2.6.1 + ([#1086](https://github.com/h5bp/html5-boilerplate/issues/1086)). +* Remove uncompressed jQuery + ([#1153](https://github.com/h5bp/html5-boilerplate/issues/1153)). +* Remove superfluous inline comments + ([#1150](https://github.com/h5bp/html5-boilerplate/issues/1150)). + +### 3.0.2 (February 19, 2012) + +* Update to Modernizr 2.5.3. + +### 3.0.1 (February 08, 2012). + +* Update to Modernizr 2.5.2 (includes html5shiv 3.3). + +### 3.0.0 (February 06, 2012) + +* Improvements to `.htaccess`. +* Improve 404 design. +* Simplify JS folder structure. +* Change `html` IE class names changed to target ranges rather than + specific versions of IE. +* Update CSS to include latest normalize.css changes and better + typographic defaults + ([#825](https://github.com/h5bp/html5-boilerplate/issues/825)). +* Update to Modernizr 2.5 (includes yepnope 1.5 and html5shiv 3.2). +* Update to jQuery 1.7.1. +* Revert to async snippet for the Google Analytics script. +* Remove the ant build script + ([#826](https://github.com/h5bp/html5-boilerplate/issues/826)). +* Remove Respond.js + ([#816](https://github.com/h5bp/html5-boilerplate/issues/816)). +* Remove the `demo/` directory + ([#808](https://github.com/h5bp/html5-boilerplate/issues/808)). +* Remove the `test/` directory + ([#808](https://github.com/h5bp/html5-boilerplate/issues/808)). +* Remove Google Chrome Frame script for IE6 users; replace with links + to Chrome Frame and options for alternative browsers. +* Remove `initial-scale=1` from the viewport `meta` + ([#824](https://github.com/h5bp/html5-boilerplate/issues/824)). +* Remove `defer` from all scripts to avoid legacy IE bugs. +* Remove explicit Site Speed tracking for Google Analytics. It's now + enabled by default. + +### 2.0.0 (August 10, 2011) + +* Change starting CSS to be based on normalize.css instead of reset.css + ([#500](https://github.com/h5bp/html5-boilerplate/issues/500)). +* Add Respond.js media query polyfill. +* Add Google Chrome Frame script prompt for IE6 users. +* Simplify the `html` conditional comments for modern browsers and add + an `oldie` class. +* Update clearfix to use "micro clearfix". +* Add placeholder CSS MQs for mobile-first approach. +* Add `textarea { resize: vertical; }` to only allow vertical resizing. +* Add `img { max-width: 100%; }` to the print styles; prevents images + being truncated. +* Add Site Speed tracking for Google Analytics. +* Update to jQuery 1.6.2 (and use minified by default). +* Update to Modernizr 2.0 Complete, Production minified (includes + yepnope, html5shiv, and Respond.js). +* Use `Modernizr.load()` to load the Google Analytics script. +* Much faster build process. +* Add build script options for CSSLint, JSLint, JSHint tools. +* Build script now compresses all images in subfolders. +* Build script now versions files by SHA hash. +* Many `.htaccess` improvements including: disable directory browsing, + improved support for all versions of Apache, more robust and extensive + HTTP compression rules. +* Remove `handheld.css` as it has very poor device support. +* Remove touch-icon `link` elements from the HTML and include improved + touch-icon support. +* Remove the cache-busting query paramaters from files references in + the HTML. +* Remove IE6 PNGFix. + +### 1.0.0 (March 21, 2011) + +* Rewrite build script to make it more customizable and flexible. +* Add a humans.txt. +* Numerous `.htaccess` improvements (including inline documentation). +* Move the alternative server configurations to the H5BP server configs + repo. +* Use a protocol-relative url to reference jQuery and prevent mixed + content warnings. +* Optimize the Google Analytics snippet. +* Use Eric Meyer's recent CSS reset update and the HTML5 Doctor reset. +* More robust `sub`/`sup` CSS styles. +* Add keyboard `.focusable` helper class that extends `.visuallyhidden`. +* Print styles no longer print hash or JavaScript links. +* Add a print reset for IE's proprietary filters. +* Remove IE9-specific conditional class on the `html` element. +* Remove margins from lists within `nav` elements. +* Remove YUI profiling. diff --git a/middleman-templates/lib/middleman-templates/html5/source/CONTRIBUTING.md b/middleman-templates/lib/middleman-templates/html5/source/CONTRIBUTING.md new file mode 100644 index 00000000..89c63e1d --- /dev/null +++ b/middleman-templates/lib/middleman-templates/html5/source/CONTRIBUTING.md @@ -0,0 +1,154 @@ +# Contributing to HTML5 Boilerplate + +♥ [HTML5 Boilerplate](http://html5boilerplate.com) and want to get involved? +Thanks! There are plenty of ways you can help! + +Please take a moment to review this document in order to make the contribution +process easy and effective for everyone involved. + +Following these guidelines helps to communicate that you respect the time of +the developers managing and developing this open source project. In return, +they should reciprocate that respect in addressing your issue or assessing +patches and features. + + +## Using the issue tracker + +The [issue tracker](https://github.com/h5bp/html5-boilerplate/issues) is +the preferred channel for [bug reports](#bugs), [features requests](#features) +and [submitting pull requests](#pull-requests), but please respect the following +restrictions: + +* Please **do not** use the issue tracker for personal support requests (use + [Stack Overflow](http://stackoverflow.com/questions/tagged/html5boilerplate) + or IRC). + +* Please **do not** derail or troll issues. Keep the discussion on topic and + respect the opinions of others. + +* Please **do not** open issues or pull requests regarding the code in + [`.htaccess`](https://github.com/h5bp/server-configs-apache), + [`jQuery`](https://github.com/jquery/jquery/), + [`Modernizr`](https://github.com/Modernizr/Modernizr) or + [`Normalize.css`](https://github.com/necolas/normalize.css) (open them in + their respective repositories). + + + +## Bug reports + +A bug is a _demonstrable problem_ that is caused by the code in the repository. +Good bug reports are extremely helpful - thank you! + +Guidelines for bug reports: + +1. **Use the GitHub issue search** — check if the issue has already been + reported. + +2. **Check if the issue has been fixed** — try to reproduce it using the + latest `master` or development branch in the repository. + +3. **Isolate the problem** — ideally create a [reduced test + case](http://css-tricks.com/6263-reduced-test-cases/) and a live example. + +A good bug report shouldn't leave others needing to chase you up for more +information. Please try to be as detailed as possible in your report. What is +your environment? What steps will reproduce the issue? What browser(s) and OS +experience the problem? What would you expect to be the outcome? All these +details will help people to fix any potential bugs. + +Example: + +> Short and descriptive example bug report title +> +> A summary of the issue and the browser/OS environment in which it occurs. If +> suitable, include the steps required to reproduce the bug. +> +> 1. This is the first step +> 2. This is the second step +> 3. Further steps, etc. +> +> `` - a link to the reduced test case +> +> Any other information you want to share that is relevant to the issue being +> reported. This might include the lines of code that you have identified as +> causing the bug, and potential solutions (and your opinions on their +> merits). + + + +## Feature requests + +Feature requests are welcome. But take a moment to find out whether your idea +fits with the scope and aims of the project. It's up to *you* to make a strong +case to convince the project's developers of the merits of this feature. Please +provide as much detail and context as possible. + + + +## Pull requests + +Good pull requests - patches, improvements, new features - are a fantastic +help. They should remain focused in scope and avoid containing unrelated +commits. + +**Please ask first** before embarking on any significant pull request (e.g. +implementing features, refactoring code, porting to a different language), +otherwise you risk spending a lot of time working on something that the +project's developers might not want to merge into the project. + +Please adhere to the coding conventions used throughout a project (indentation, +accurate comments, etc.) and any other requirements (such as test coverage). + +Adhering to the following this process is the best way to get your work +included in the project: + +1. [Fork](http://help.github.com/fork-a-repo/) the project, clone your fork, + and configure the remotes: + + ```bash + # Clone your fork of the repo into the current directory + git clone https://github.com//html5-boilerplate.git + # Navigate to the newly cloned directory + cd html5-boilerplate + # Assign the original repo to a remote called "upstream" + git remote add upstream https://github.com/h5bp/html5-boilerplate.git + ``` + +2. If you cloned a while ago, get the latest changes from upstream: + + ```bash + git checkout master + git pull upstream master + ``` + +3. Create a new topic branch (off the main project development branch) to + contain your feature, change, or fix: + + ```bash + git checkout -b + ``` + +4. Commit your changes in logical chunks. Please adhere to these [git commit + message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) + or your code is unlikely be merged into the main project. Use Git's + [interactive rebase](https://help.github.com/articles/interactive-rebase) + feature to tidy up your commits before making them public. + +5. Locally merge (or rebase) the upstream development branch into your topic branch: + + ```bash + git pull [--rebase] upstream master + ``` + +6. Push your topic branch up to your fork: + + ```bash + git push origin + ``` + +7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) + with a clear title and description. + +**IMPORTANT**: By submitting a patch, you agree to allow the project owners to +license your work under the the terms of the [MIT License](LICENSE.md). diff --git a/middleman-templates/lib/middleman-templates/html5/source/LICENSE.md b/middleman-templates/lib/middleman-templates/html5/source/LICENSE.md old mode 100755 new mode 100644 diff --git a/middleman-templates/lib/middleman-templates/html5/source/README.md b/middleman-templates/lib/middleman-templates/html5/source/README.md old mode 100755 new mode 100644 index cca26dc9..864900b1 --- a/middleman-templates/lib/middleman-templates/html5/source/README.md +++ b/middleman-templates/lib/middleman-templates/html5/source/README.md @@ -20,8 +20,9 @@ Choose one of the following options: [html5boilerplate.com](http://html5boilerplate.com/) or a custom build from [Initializr](http://www.initializr.com). 2. Clone the git repo — `git clone - https://github.com/h5bp/html5-boilerplate.git` - and checkout the tagged - release you'd like to use. + https://github.com/h5bp/html5-boilerplate.git` - and checkout the [tagged + release](https://github.com/h5bp/html5-boilerplate/releases) you'd like to + use. ## Features @@ -49,15 +50,13 @@ Choose one of the following options: ## Documentation -Take a look at the [documentation table of -contents](/h5bp/html5-boilerplate/blob/master/doc/README.md). This +Take a look at the [documentation table of contents](doc/TOC.md). This documentation is bundled with the project, which makes it readily available for -offline reading and provides a useful starting point for any documentation -you want to write about your project. +offline reading and provides a useful starting point for any documentation you +want to write about your project. ## Contributing -Anyone and everyone is welcome to -[contribute](/h5bp/html5-boilerplate/blob/master/doc/contribute.md). Hundreds -of developers have helped make the HTML5 Boilerplate what it is today. +Anyone and everyone is welcome to [contribute](CONTRIBUTING.md). Hundreds of +developers have helped make the HTML5 Boilerplate what it is today. diff --git a/middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon-114x114-precomposed.png b/middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon-114x114-precomposed.png deleted file mode 100755 index 11477d52e5b8add17752353ab84e34da46a21fc1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2042 zcmeAS@N?(olHy`uVBq!ia0y~yU?>7%4rT@hh8@hM{tOI^4FNtOt}=>BXQH&*Ts2Qc zYF&=gT^p!%K1SzUl-7kPElp!nL!XdKF**mrG_S;HU5nQ<@CiO1sbv?La3VtUM7ZY7 zc-_l!dTNHo7o)XKMQEIf&^#Zhc{NV=O0?$5Xx%drT36%sF2v|ujMY6Ct$ih4?@FBB z=}4_}QJNQGb+5(iUWwH?6Qg@AR{Knp=DA2MRb{1%ak`3%ijPu_6cps|r5L(r6g^Kj zQc_j%$S!%4WpXFkP+U$i%uL-SIon)YwbM&qLtnqlQA^j((J?N~ExjPsTGKPHTwYoE zR+52raHNyInw*^6;}rcZ5k_YcO{V+ltLo{`4>r=aw6X9DHunioR8f{tP`Z|&?`@=} zqOEf{*7$O=iLtx4l9H0HhKhom?9CM88!4tLYHDZF?Uscasi`V$NwB?l7W_*(y3G% zQ~xk&H4Rl$i@S+>3L2V6BX!%(IZH7xu$g+gIEGZjy}5EUPu5VRA<=$P;RH!N<95kY zJ?rmTKUUf6Ykf*-)9#t|xi2qUZsOBe!hUVjVTMy`-T$41@v_WVz0 zS2cDYo#ZyVaMIV_HFtDE|Jp88*&yz*K54poT|}Q`|Fr;>%!-bJNisR>9X&54^s!D7 zD4AI|{h36hXWOf_9z~Plx4!edvW;ETvpsoY%95A-il66(&b+25;^wsUwwHX;y}zas z9kYdQu)lo&<*0i6)7eKKd2F8guI1CcyYp>D+|-W$IzG2V{o!?mFB=tv@~nQ{^!v5Q z;(2-57WEF6izatfFK^#GPjot~txikJWIM~>%8z{hgkCj1@zG)>?~UpG9#_J+;y(3H z@oMm&aKL7-T~+Ayi(dlGFQ5O~zuy0I_toF?n&!_i+IYVve`%@jf33BvOFvglzO(Pg zho^U9A6rdgpY%d~rk(Yt?yH|NeI?i)7ig?akST3`mCB+ns~&neW%JX zjTP<_ay^bdmk?FrZar1G+{opaT*ObO4Y~qBZztq%m9A#pb;(31;JNQMW;b~c`{@ie z$1kmQa*vvM^w~Za#+N~Fjm&@fd92rwy=1hn$*g_1%fzW2es}B=wwYyZ_j)+N!e-lv z<;F{9on90;dxq+S?=z2bY?94vnV9!bH2V9OGjbabC3olSlF2B~xwzt?#ob_oxyMvE zHQIkW9Q?>Mb+=08>sQRbuSa&?Xy57TC~q>|C3VW3mr5tkK9Rn#I8uhc(kBS22bAI;&l;c-M-?R-^i`#5zooFD3flOs?=};m^yrcQXgdcm%9;dnGE{vDa>$jxf6r z=W8EeZcGNnzgN=$fl;s5JQJ@2&>-tPM8 zbF2Ny9fA9Mwlqj^9@{nV+Z6NEw}C-b3h#>doz@gC=s2!yYos!%_DD#b+LpJ|+j5uO z>Nrh(Zk?;cSLEQ z+=APjb;A0~FUiN9dn*>3ni>1bYM0#PTUF6Da;!cY4v|O%`>}aZ*vTNHRI>JTRmSS=5eg#J=5iE^V3E+AajrT*DWyyy0Txb zcIvEqb0;8X{?(HciViClSxT!Mj@LwA?wjC{Fc| zeD!^nY)<@1dmq)DENgydJVh~5RjMZ8rdMFig*7YZOPmPiD1A{pP4}|)_4NJBoI!T! zn@bdYAF}Oa|L~k6Ic)6))AQ+yRzXWwyPk4b>iR%WZ^raQ=BlK1QTKkWIpprvG{G#j zy7Mwa;IHXRGZ+6{$a&90Un^+wGp1dV?DJ+HSZ5dzlT}}``(vbCQDS&}6<6G%>4!^y zo#}x`za|o z-f!FSH0aQFjgW%!e9>LkeL_^)rm69jq$louyMWVSD_8QS28QpalGvkPNwZoxOEo_T zJ2dTA7^A<n+a diff --git a/middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon-144x144-precomposed.png b/middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon-144x144-precomposed.png deleted file mode 100755 index 33051de0a63dc4674fe32249f378e467843a54d8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1795 zcmeAS@N?(olHy`uVBq!ia0y~yV3+{H9Lx+13>Rhybuln7HU#*DxE=}9JQJ<6Cd|;o zNaIejp`n)QVn3~u$ref~%DOIITSK&!RaNxu9c{y6rg>?cjMm*5YnJ1re|O; z-AB{JEYViiK04VhA}+*KRm;jwS3^ZbMR{?Ev7xg|r;nkUo?eNo!Gl!etGUk3`YIX* z2C7dns1;R+7Q#D6O+m+UKHmZYCPs zOEJ2gY>Fz48+0*FFT+M-SBU1VOsjPP8g>R64W0&p=Gq4mEK2OuW(1k6jx_5JFrMmf(B!Of zJ;f~ATrJyL%`Lsaz$;KmN$Fgd;d}-LRy$7@$B>F!Z*Tt&mkJkQeb6alYo#G1;@aW3 z=+T8E`z|f(|1#CYwDYBR*P;ax%KL(j?zwe~<;V5Ia}DM-7Ej-69JePjw*2?(o^#v3 z$+@;Iy;yO4k)zZSROG_!&G26AMZ(Swm8%LBmZ@UdrYbAhRQrD&Sao&65-E|0XzoJ^ zyq;Z-AIhz4Q}>;>>6yYDst}_yH*L11QYwg1W|pj}!Tc~OXR|1~2~(Ei$)88l<{cKw zTP7xQBT-?~Oe2Aq*e$|_;j$N0G*~wteRGzJFT;nELp(Ynr*6a9W3m?~ISJUrW~jQE z1vAeocStcdUGP|zeao~1XLVQ=V%|8uR%TPY<0F~z?_g$|;?ss>QyUj?bKIJ^WoF^J zqxXtc*(UR8uyi@p=3R&{GBZB6b%yknJ2^b&!Hi9s&kmf~X&%hBaWTblMr!ae7n}^j~iz`?7eY*j*0nU59UUX zB>Rt_G#HdN`YZBv)#y%G9DPTIv*zX2oySf+dnVLS;C!$#I@TwjNg-sta%aN|ji1ja z^Y5B+Mw>x9B>kqngAn7zNxL2=eqCeCt0*X-`?C1u$s>$u&ZXgX_A{O~{ZOsdu#D*U z4iRBU^fa=pUNdhk-+B3I7g8cFxnDAx!g^w26@#tF5q(cSb)5iy){ox5+?-loEmWxU zyl#Adp7Fzm43O;0%f(A0`#oPt9<9>wSfKJ>X7{|hiB$qBL6^$yHcu2^$L^@4`u1Jz zdu7o)TeYH^h7C*lZQHLJYsK(4wRnFzw$g`Lgyr=@g`cW(KfF50=<#Q^RKoX5=}np+ zUuh=W);VrbF+A^i@5xo=|Do&-u1Aa+Cft60MVYsyGcAw%31{{0tjfvPl=m+@k-P9n z!qmMdH+a69$S1W=eagIR(elZ^%WRELOk_E9^oWDxwwca{s+Ke-yqcHr=Ion0GhF&= zE4*m0}!*kKKa zRp&0*b8o2L`MGe@%$R_E#T$EVB80z&1urn)$;azJnyIV&jMe3NH@RN zbRun&L-Dum^%HXn)<26}F!dPkH_;ShPlX+q{yb|>k2z~1u;$mTGXilr%G_xai%w}~ ze3)$iaq~>Y9TA%6_Rn%o=V5FVy6GddVtJN*>BT1x&MXz)n_@g)K}y@j^6$0!xk^8G zEl+%yCgix%=&OkD!FuO|XP-2#SRTW0@pi*X$2&e^CuTkPx1n0O_c!~+2j?a1N-Gu5 z8cb6CUV5`?rcG&Oj;0E0i=q07;OXXYF7Aow`HU#*DxSom9R#Z?>R8&+_ zQqpmBGxQ0OkXO7EttF$Nq#!SE;1%eeQS=~5&qPb*Ri?4Am6f%Qsz-Kdj*a?cH?>od zS{*LxPf`ta+!((}kFIT@j)YiX_T>3=#>Ynq3;lCtvESnYKI8dqYpwni8!Svgn- zN6492g&M0^#-the1gmOl_PS}Di_*H4pr>hKrlqcWFk1goirIlMEgjFmT1Rz5J?&Y( zI!-CMSK{;zN9wrht6q%Obk8Yw&n}I(P}edum)AGe(bk;et$QIx=URgP*+|XvQJTji zv`j-|Rcu|%z5I_Sm>!SP^)c1DouC_IsdYI{_hy3L)p)&U>BhT4w9Z9qyQLL)4sQntEj8Z@l?AKuV)t?tD&rTCQ>WfRHey5#oW~JYmSMDf7t$D^=22%6XBX3Ii=@g zbgo2e*_#{gi_kUm^fmPjemR*>fq{W(v!{z=NJZS+YoYy*4MbQU+~RYZIdf*_gqbsE zCeEDs@0Z$3v*7b*%)Gv5F16I})v4X3es!yeY*M0n;zYhui3QEFUO)Ih1sZj<%ATC0 z>35_lV0X$F)5l3Ba?P_;OOq;Y{eGG@|Ek{d`}`JXYfRWoy=GV$^gOGW7oTYA_3DX| zz=toNp8Z`AwlnX8)EnWVSYM&OA53w_`(^5TuZK>ba(tqP${zQk*xaJOPE*9^PuZm< zr2YE)Z|3Qj_FJFHnlR<~Yw^h+yi4oZZhLjKRz3RQUFhSdqvz_)VD`DeXQ^A%Bq`t1 zMzOPvqmF_4h(0m0ugTow~8} z%bS;f=WtKA?QQ&-$RemVb>nO2i63Gs#5QU(N7e{`*mykA=D031;~`bMZ56v3kM`|X z)GM6DQ@_`@A}_1le7-olQ$xrS)uOAjPJGH!`{h{YEP8UssTn%roW*HwEm@NcW#e8x z`SbIpM7{ap*^eDVJtI$fMqcoYns#zig!yIG5Y>{4tcKxR?xw8eyLIIFs;Lo=(tkB} zrTAD|%|06@y1gX->L%yz^UXnbeQZ`JX?mN^u8pnDTUD%b-8O!u*e0`Gf#GY{W?S$6 zds9fsBlGq*w>P(=Z?bA9hP_G>(vM!C{rPUC~+w9z5$$Sk9GP<(ZYM<6`nTt(+HB3a^}Zs=QM2*4A3l zBC}b~k`{awdQqR6x9dik&==ua758U%8QwEpICc7U!0l+Zg||J0&NJ+i7JGI_>$~ug wI~6o+sp*=Ocab*J*pW6pLmFfcH9y85}Sb4q9e087Z<%K!iX diff --git a/middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon-72x72-precomposed.png b/middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon-72x72-precomposed.png deleted file mode 100755 index f72c966fef9a7705a2ffca568b9e02b14140266f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1351 zcmeAS@N?(olHy`uVBq!ia0y~yVDJE84rT@hh9qO>QU(Ubh5(-s*RxUDii(P|ib{q) zA<8N$7os(t^i&PJgCyjY+%t;Y(hC$7ccfHG$gt?tZ5twY&^fFUIP+XBD50)H3!DyPa$(FE1Z%s;*;Y ztE8l)YwIYZrFT6+U)9QCU#!XDNS!I(+7D6;^*sabCh2LLSzL+JIT59kWUhKA$v{?3 z{c(!HwRpYDaeAAAv@XWzWLv9Viq(CdZnVTtQ$bG7IXT-QCgp09(fN1-6&2-V8?8(m zjhC6mH{-MwOe~LtYh8%ZkOiw0TxM!7|kI}gv zr*kDN-F+tSG?F# zDr*F%eqhaspR_bdaIz8^HInN)X@A|dJF}X7!?O)}^d|}tZt)|mFR#d!s zK5Mhu%Kg2XpYDFUV^^?p5=ZXhjtjk&yPvgi`j+>fOgL+Z6p!^_;@AcA~4u^)Du~&o1RYtLb!`LrJmZ%8?uPPPa9bj_kRA z&!pq#!dw->qesn>XZ&d`W6MpMxb=+O>y29io6Ht*%v>-f-@EqWw?+5WJhwS;Glq8w zNu~*OS@)m)cB5vQD(@YxJ+nPaL?vUD7UkJheynUzuRqIl{u!?wvwmHMy7%gyo;8^v zs(I(x_p6(6v#_7Y7vH%=+j}}wPv{lVyq0?`-~-}zq5$Z7kQPMA)Pg``K;)TifV1w&sNJOF8aq|TRZ!7>%v~0L#a=XuPJo$ z-qQE*CttJ1LfQ0U|LzNJA`dsM|IQ~-bNGNny0@D}MDd1x?h9@ribo5d&zN2K_4$F` z2~P9t+TZu;EZXrkfGz&%zhtI9DvTJOg(ZDbGw$vI&bZ(o%fTrmSb@tZ8iax?8y=D{cV;1M?wI7srr_TW@FH zE?aECFiL^Ys!>^#@Kz8rw`+7;he#X7-FdnfNQlw9ny zXVE6Vnq3l$E#d-hILRI;{-Y)#vaKw6llSyI?K6Szo=iOWG^Nx|1!9F zJ%a0_;LP70M)QcpY8HnKip07pSt(-pI*}qA_X#BQ|HdmiCxC$lcW=S z@827he}|q19y5sS-&C^G^FfDR8RumF6E&Gr5^uiO0bAL8(&*HuqT?5qKZre`(r|ii z0Qcn2y9+k<-RImYu;-2PwTZDiW}cXF?XAE3d7re%Ntqob>VcA-#=^P(l{>#ZcHOBb zKEo&K-y~n>s#Vj>1oQj3mzFLNmb$Omn<=z(myL>!?btitb|WRZEjEg|Fk+PJUO#2=GR0s(TAlq>7N&^`goyE|CiMH z>zZ0pAKw)wOwG8sV!g1`%LccpoUFaM50}bkUbyjZM~M2AobJDk>%wOR6vr<9m%88_ zWACYrf>%tL@?IFtyb-Z_m0-)ZYybECHp#vs&){)UpH7LvO) z9iMkL+f0$#ew>x(oYU8(K6jV=`0zP_f37-z(YK&F509sFm)LNhT=Gh&Pj1&f1@Vb$ zeIzopr0EPSwN&o-= literal 1144 zcmeAS@N?(olHy`uVBq!ia0y~yV6X&X4rT@hhTX@Cw=*y>HU#*DxSom9R#Z?>R8&+_ zQqpmBGxQ0OkXO7EttF$Nq#!SE;1%eeQS=~5&qPb*Ri?4Am6f%Qsz-Kdj*a?cH?>od zS{*LxPf`ta+!((}kFIT@j)YiX_T>3=#>Ynq3;lCtvESnYKI8dqYpwni8!Svgn- zN6492g&M0^#-the1gmOl_PS}Di_*H4pr>hKrlqcWFk1goirIlMEgjFmT1Rz5J?&Y( zI!-CMSK{;zN9wrht6q%Obk8Yw&n}I(P}edum)AGe(bk;et$QIx=URgP*+|XvQJTji zv`j-|Rcu|%z5I_Sm>!SP^)c1DouC_IsdYI{_hy3L)p)&U>BhT4w9Z9qyQLL)4sQntEj8Z@l?AKuV)t?tD&rTCQ>WfRHey5#oW~JYmSMDf7t$D^=22%6XBX3Ii=@g zbgo2e*_#{gi_kUm^fmPjemR*>fq{W(v!{z=NJZS+YoYy*4MbQU+~RYZIdf*_gqbsE zCeEDs@0Z$3v*7b*%)Gv5F16I})v4X3es!yeY*M0n;zYhui3QEFUO)Ih1sZj<%ATC0 z>35_lV0X$F)5l3Ba?P_;OOq;Y{eGG@|Ek{d`}`JXYfRWoy=GV$^gOGW7oTYA_3DX| zz=toNp8Z`AwlnX8)EnWVSYM&OA53w_`(^5TuZK>ba(tqP${zQk*xaJOPE*9^PuZm< zr2YE)Z|3Qj_FJFHnlR<~Yw^h+yi4oZZhLjKRz3RQUFhSdqvz_)VD`DeXQ^A%Bq`t1 zMzOPvqmF_4h(0m0ugTow~8} z%bS;f=WtKA?QQ&-$RemVb>nO2i63Gs#5QU(N7e{`*mykA=D031;~`bMZ56v3kM`|X z)GM6DQ@_`@A}_1le7-olQ$xrS)uOAjPJGH!`{h{YEP8UssTn%roW*HwEm@NcW#e8x z`SbIpM7{ap*^eDVJtI$fMqcoYns#zig!yIG5Y>{4tcKxR?xw8eyLIIFs;Lo=(tkB} zrTAD|%|06@y1gX->L%yz^UXnbeQZ`JX?mN^u8pnDTUD%b-8O!u*e0`Gf#GY{W?S$6 zds9fsBlGq*w>P(=Z?bA9hP_G>(vM!C{rPUC~+w9z5$$Sk9GP<(ZYM<6`nTt(+HB3a^}Zs=QM2*4A3l zBC}b~k`{awdQqR6x9dik&==ua758U%8QwEpICc7U!0l+Zg||J0&NJ+i7JGI_>$~ug wI~6o+sp*=Ocab*J*pW6pLmFfcH9y85}Sb4q9e087Z<%K!iX diff --git a/middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon.png b/middleman-templates/lib/middleman-templates/html5/source/apple-touch-icon.png deleted file mode 100755 index 214e44541ed3374cbedcf773b766d847b99dac6f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1144 zcmeAS@N?(olHy`uVBq!ia0y~yV6X&X4rT@hhTX@Cw=*y>HU#*DxSom9R#Z?>R8&+_ zQqpmBGxQ0OkXO7EttF$Nq#!SE;1%eeQS=~5&qPb*Ri?4Am6f%Qsz-Kdj*a?cH?>od zS{*LxPf`ta+!((}kFIT@j)YiX_T>3=#>Ynq3;lCtvESnYKI8dqYpwni8!Svgn- zN6492g&M0^#-the1gmOl_PS}Di_*H4pr>hKrlqcWFk1goirIlMEgjFmT1Rz5J?&Y( zI!-CMSK{;zN9wrht6q%Obk8Yw&n}I(P}edum)AGe(bk;et$QIx=URgP*+|XvQJTji zv`j-|Rcu|%z5I_Sm>!SP^)c1DouC_IsdYI{_hy3L)p)&U>BhT4w9Z9qyQLL)4sQntEj8Z@l?AKuV)t?tD&rTCQ>WfRHey5#oW~JYmSMDf7t$D^=22%6XBX3Ii=@g zbgo2e*_#{gi_kUm^fmPjemR*>fq{W(v!{z=NJZS+YoYy*4MbQU+~RYZIdf*_gqbsE zCeEDs@0Z$3v*7b*%)Gv5F16I})v4X3es!yeY*M0n;zYhui3QEFUO)Ih1sZj<%ATC0 z>35_lV0X$F)5l3Ba?P_;OOq;Y{eGG@|Ek{d`}`JXYfRWoy=GV$^gOGW7oTYA_3DX| zz=toNp8Z`AwlnX8)EnWVSYM&OA53w_`(^5TuZK>ba(tqP${zQk*xaJOPE*9^PuZm< zr2YE)Z|3Qj_FJFHnlR<~Yw^h+yi4oZZhLjKRz3RQUFhSdqvz_)VD`DeXQ^A%Bq`t1 zMzOPvqmF_4h(0m0ugTow~8} z%bS;f=WtKA?QQ&-$RemVb>nO2i63Gs#5QU(N7e{`*mykA=D031;~`bMZ56v3kM`|X z)GM6DQ@_`@A}_1le7-olQ$xrS)uOAjPJGH!`{h{YEP8UssTn%roW*HwEm@NcW#e8x z`SbIpM7{ap*^eDVJtI$fMqcoYns#zig!yIG5Y>{4tcKxR?xw8eyLIIFs;Lo=(tkB} zrTAD|%|06@y1gX->L%yz^UXnbeQZ`JX?mN^u8pnDTUD%b-8O!u*e0`Gf#GY{W?S$6 zds9fsBlGq*w>P(=Z?bA9hP_G>(vM!C{rPUC~+w9z5$$Sk9GP<(ZYM<6`nTt(+HB3a^}Zs=QM2*4A3l zBC}b~k`{awdQqR6x9dik&==ua758U%8QwEpICc7U!0l+Zg||J0&NJ+i7JGI_>$~ug wI~6o+sp*=Ocab*J*pW6pLmFfcH9y85}Sb4q9e087Z<%K!iX diff --git a/middleman-templates/lib/middleman-templates/html5/source/crossdomain.xml b/middleman-templates/lib/middleman-templates/html5/source/crossdomain.xml old mode 100755 new mode 100644 diff --git a/middleman-templates/lib/middleman-templates/html5/source/css/main.css b/middleman-templates/lib/middleman-templates/html5/source/css/main.css old mode 100755 new mode 100644 index 6990a847..6ac6721c --- a/middleman-templates/lib/middleman-templates/html5/source/css/main.css +++ b/middleman-templates/lib/middleman-templates/html5/source/css/main.css @@ -1,6 +1,6 @@ +/*! HTML5 Boilerplate v4.3.0 | MIT License | http://h5bp.com/ */ + /* - * HTML5 Boilerplate - * * What follows is the result of much research on cross-browser styling. * Credit left inline and big thanks to Nicolas Gallagher, Jonathan Neal, * Kroc Camen, and the H5BP dev community and team. @@ -10,22 +10,15 @@ Base styles: opinionated defaults ========================================================================== */ -html, -button, -input, -select, -textarea { +html { color: #222; -} - -body { font-size: 1em; line-height: 1.4; } /* * Remove text-shadow in selection highlight: h5bp.com/i - * These selection declarations have to be separate. + * These selection rule sets have to be separate. * Customize the background color to match your design. */ @@ -53,10 +46,15 @@ hr { } /* - * Remove the gap between images and the bottom of their containers: h5bp.com/i/440 + * Remove the gap between images, videos, audio and canvas and the bottom of + * their containers: h5bp.com/i/440 */ -img { +audio, +canvas, +img, +svg, +video { vertical-align: middle; } @@ -79,10 +77,10 @@ textarea { } /* ========================================================================== - Chrome Frame prompt + Browse Happy prompt ========================================================================== */ -.chromeframe { +.browsehappy { margin: 0.2em 0; background: #ccc; color: #000; @@ -129,7 +127,7 @@ textarea { content: ""; display: block; width: 0; - height: 100%; + height: 150%; } /* @@ -212,7 +210,7 @@ textarea { /* ========================================================================== EXAMPLE Media Queries for Responsive Design. - Theses examples override the primary ('mobile first') styles. + These examples override the primary ('mobile first') styles. Modify as content requires. ========================================================================== */ @@ -220,8 +218,10 @@ textarea { /* Style adjustments for viewports that meet the condition */ } -@media only screen and (-webkit-min-device-pixel-ratio: 1.5), - only screen and (min-resolution: 144dpi) { +@media print, + (-o-min-device-pixel-ratio: 5/4), + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 120dpi) { /* Style adjustments for high resolution devices */ } @@ -234,7 +234,7 @@ textarea { * { background: transparent !important; color: #000 !important; /* Black prints faster: h5bp.com/s */ - box-shadow:none !important; + box-shadow: none !important; text-shadow: none !important; } @@ -280,10 +280,6 @@ textarea { max-width: 100% !important; } - @page { - margin: 0.5cm; - } - p, h2, h3 { diff --git a/middleman-templates/lib/middleman-templates/html5/source/css/normalize.css b/middleman-templates/lib/middleman-templates/html5/source/css/normalize.css old mode 100755 new mode 100644 index d4210aac..42e24d68 --- a/middleman-templates/lib/middleman-templates/html5/source/css/normalize.css +++ b/middleman-templates/lib/middleman-templates/html5/source/css/normalize.css @@ -1,11 +1,11 @@ -/*! normalize.css v1.0.1 | MIT License | git.io/normalize */ +/*! normalize.css v1.1.3 | MIT License | git.io/normalize */ /* ========================================================================== HTML5 display definitions ========================================================================== */ -/* - * Corrects `block` display not defined in IE 6/7/8/9 and Firefox 3. +/** + * Correct `block` display not defined in IE 6/7/8/9 and Firefox 3. */ article, @@ -16,14 +16,15 @@ figure, footer, header, hgroup, +main, nav, section, summary { display: block; } -/* - * Corrects `inline-block` display not defined in IE 6/7/8/9 and Firefox 3. +/** + * Correct `inline-block` display not defined in IE 6/7/8/9 and Firefox 3. */ audio, @@ -34,8 +35,8 @@ video { *zoom: 1; } -/* - * Prevents modern browsers from displaying `audio` without controls. +/** + * Prevent modern browsers from displaying `audio` without controls. * Remove excess height in iOS 5 devices. */ @@ -44,9 +45,8 @@ audio:not([controls]) { height: 0; } -/* - * Addresses styling for `hidden` attribute not present in IE 7/8/9, Firefox 3, - * and Safari 4. +/** + * Address styling not present in IE 7/8/9, Firefox 3, and Safari 4. * Known issue: no IE 6 support. */ @@ -58,21 +58,21 @@ audio:not([controls]) { Base ========================================================================== */ -/* - * 1. Corrects text resizing oddly in IE 6/7 when body `font-size` is set using +/** + * 1. Correct text resizing oddly in IE 6/7 when body `font-size` is set using * `em` units. - * 2. Prevents iOS text size adjust after orientation change, without disabling + * 2. Prevent iOS text size adjust after orientation change, without disabling * user zoom. */ html { font-size: 100%; /* 1 */ - -webkit-text-size-adjust: 100%; /* 2 */ -ms-text-size-adjust: 100%; /* 2 */ + -webkit-text-size-adjust: 100%; /* 2 */ } -/* - * Addresses `font-family` inconsistency between `textarea` and other form +/** + * Address `font-family` inconsistency between `textarea` and other form * elements. */ @@ -84,8 +84,8 @@ textarea { font-family: sans-serif; } -/* - * Addresses margins handled incorrectly in IE 6/7. +/** + * Address margins handled incorrectly in IE 6/7. */ body { @@ -96,16 +96,16 @@ body { Links ========================================================================== */ -/* - * Addresses `outline` inconsistency between Chrome and other browsers. +/** + * Address `outline` inconsistency between Chrome and other browsers. */ a:focus { outline: thin dotted; } -/* - * Improves readability when focused and also mouse hovered in all browsers. +/** + * Improve readability when focused and also mouse hovered in all browsers. */ a:active, @@ -117,9 +117,9 @@ a:hover { Typography ========================================================================== */ -/* - * Addresses font sizes and margins set differently in IE 6/7. - * Addresses font sizes within `section` and `article` in Firefox 4+, Safari 5, +/** + * Address font sizes and margins set differently in IE 6/7. + * Address font sizes within `section` and `article` in Firefox 4+, Safari 5, * and Chrome. */ @@ -149,20 +149,20 @@ h5 { } h6 { - font-size: 0.75em; + font-size: 0.67em; margin: 2.33em 0; } -/* - * Addresses styling not present in IE 7/8/9, Safari 5, and Chrome. +/** + * Address styling not present in IE 7/8/9, Safari 5, and Chrome. */ abbr[title] { border-bottom: 1px dotted; } -/* - * Addresses style set to `bolder` in Firefox 3+, Safari 4/5, and Chrome. +/** + * Address style set to `bolder` in Firefox 3+, Safari 4/5, and Chrome. */ b, @@ -174,16 +174,27 @@ blockquote { margin: 1em 40px; } -/* - * Addresses styling not present in Safari 5 and Chrome. +/** + * Address styling not present in Safari 5 and Chrome. */ dfn { font-style: italic; } -/* - * Addresses styling not present in IE 6/7/8/9. +/** + * Address differences between Firefox and other browsers. + * Known issue: no IE 6/7 normalization. + */ + +hr { + -moz-box-sizing: content-box; + box-sizing: content-box; + height: 0; +} + +/** + * Address styling not present in IE 6/7/8/9. */ mark { @@ -191,8 +202,8 @@ mark { color: #000; } -/* - * Addresses margins set differently in IE 6/7. +/** + * Address margins set differently in IE 6/7. */ p, @@ -200,8 +211,8 @@ pre { margin: 1em 0; } -/* - * Corrects font family set oddly in IE 6, Safari 4/5, and Chrome. +/** + * Correct font family set oddly in IE 6, Safari 4/5, and Chrome. */ code, @@ -213,8 +224,8 @@ samp { font-size: 1em; } -/* - * Improves readability of pre-formatted text in all browsers. +/** + * Improve readability of pre-formatted text in all browsers. */ pre { @@ -223,16 +234,16 @@ pre { word-wrap: break-word; } -/* - * Addresses CSS quotes not supported in IE 6/7. +/** + * Address CSS quotes not supported in IE 6/7. */ q { quotes: none; } -/* - * Addresses `quotes` property not supported in Safari 4. +/** + * Address `quotes` property not supported in Safari 4. */ q:before, @@ -241,16 +252,16 @@ q:after { content: none; } -/* - * Addresses inconsistent and variable font size in all browsers. +/** + * Address inconsistent and variable font size in all browsers. */ small { font-size: 80%; } -/* - * Prevents `sub` and `sup` affecting `line-height` in all browsers. +/** + * Prevent `sub` and `sup` affecting `line-height` in all browsers. */ sub, @@ -273,8 +284,8 @@ sub { Lists ========================================================================== */ -/* - * Addresses margins set differently in IE 6/7. +/** + * Address margins set differently in IE 6/7. */ dl, @@ -288,8 +299,8 @@ dd { margin: 0 0 0 40px; } -/* - * Addresses paddings set differently in IE 6/7. +/** + * Address paddings set differently in IE 6/7. */ menu, @@ -298,8 +309,8 @@ ul { padding: 0 0 0 40px; } -/* - * Corrects list images handled incorrectly in IE 7. +/** + * Correct list images handled incorrectly in IE 7. */ nav ul, @@ -312,9 +323,9 @@ nav ol { Embedded content ========================================================================== */ -/* - * 1. Removes border when inside `a` element in IE 6/7/8/9 and Firefox 3. - * 2. Improves image quality when scaled in IE 7. +/** + * 1. Remove border when inside `a` element in IE 6/7/8/9 and Firefox 3. + * 2. Improve image quality when scaled in IE 7. */ img { @@ -322,8 +333,8 @@ img { -ms-interpolation-mode: bicubic; /* 2 */ } -/* - * Corrects overflow displayed oddly in IE 9. +/** + * Correct overflow displayed oddly in IE 9. */ svg:not(:root) { @@ -334,8 +345,8 @@ svg:not(:root) { Figures ========================================================================== */ -/* - * Addresses margin not present in IE 6/7/8/9, Safari 5, and Opera 11. +/** + * Address margin not present in IE 6/7/8/9, Safari 5, and Opera 11. */ figure { @@ -346,15 +357,15 @@ figure { Forms ========================================================================== */ -/* - * Corrects margin displayed oddly in IE 6/7. +/** + * Correct margin displayed oddly in IE 6/7. */ form { margin: 0; } -/* +/** * Define consistent border, margin, and padding. */ @@ -364,10 +375,10 @@ fieldset { padding: 0.35em 0.625em 0.75em; } -/* - * 1. Corrects color not being inherited in IE 6/7/8/9. - * 2. Corrects text not wrapping in Firefox 3. - * 3. Corrects alignment displayed oddly in IE 6/7. +/** + * 1. Correct color not being inherited in IE 6/7/8/9. + * 2. Correct text not wrapping in Firefox 3. + * 3. Correct alignment displayed oddly in IE 6/7. */ legend { @@ -377,11 +388,11 @@ legend { *margin-left: -7px; /* 3 */ } -/* - * 1. Corrects font size not being inherited in all browsers. - * 2. Addresses margins set differently in IE 6/7, Firefox 3+, Safari 5, +/** + * 1. Correct font size not being inherited in all browsers. + * 2. Address margins set differently in IE 6/7, Firefox 3+, Safari 5, * and Chrome. - * 3. Improves appearance and consistency in all browsers. + * 3. Improve appearance and consistency in all browsers. */ button, @@ -394,8 +405,8 @@ textarea { *vertical-align: middle; /* 3 */ } -/* - * Addresses Firefox 3+ setting `line-height` on `input` using `!important` in +/** + * Address Firefox 3+ setting `line-height` on `input` using `!important` in * the UA stylesheet. */ @@ -404,13 +415,25 @@ input { line-height: normal; } -/* +/** + * Address inconsistent `text-transform` inheritance for `button` and `select`. + * All other form control elements do not inherit `text-transform` values. + * Correct `button` style inheritance in Chrome, Safari 5+, and IE 6+. + * Correct `select` style inheritance in Firefox 4+ and Opera. + */ + +button, +select { + text-transform: none; +} + +/** * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` * and `video` controls. - * 2. Corrects inability to style clickable `input` types in iOS. - * 3. Improves usability and consistency of cursor style between image-type + * 2. Correct inability to style clickable `input` types in iOS. + * 3. Improve usability and consistency of cursor style between image-type * `input` and others. - * 4. Removes inner spacing in IE 7 without affecting normal text inputs. + * 4. Remove inner spacing in IE 7 without affecting normal text inputs. * Known issue: inner spacing remains in IE 6. */ @@ -423,19 +446,19 @@ input[type="submit"] { *overflow: visible; /* 4 */ } -/* +/** * Re-set default cursor for disabled elements. */ button[disabled], -input[disabled] { +html input[disabled] { cursor: default; } -/* - * 1. Addresses box sizing set to content-box in IE 8/9. - * 2. Removes excess padding in IE 8/9. - * 3. Removes excess padding in IE 7. +/** + * 1. Address box sizing set to content-box in IE 8/9. + * 2. Remove excess padding in IE 8/9. + * 3. Remove excess padding in IE 7. * Known issue: excess padding remains in IE 6. */ @@ -447,9 +470,9 @@ input[type="radio"] { *width: 13px; /* 3 */ } -/* - * 1. Addresses `appearance` set to `searchfield` in Safari 5 and Chrome. - * 2. Addresses `box-sizing` set to `border-box` in Safari 5 and Chrome +/** + * 1. Address `appearance` set to `searchfield` in Safari 5 and Chrome. + * 2. Address `box-sizing` set to `border-box` in Safari 5 and Chrome * (include `-moz` to future-proof). */ @@ -460,8 +483,8 @@ input[type="search"] { box-sizing: content-box; } -/* - * Removes inner padding and search cancel button in Safari 5 and Chrome +/** + * Remove inner padding and search cancel button in Safari 5 and Chrome * on OS X. */ @@ -470,8 +493,8 @@ input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; } -/* - * Removes inner padding and border in Firefox 3+. +/** + * Remove inner padding and border in Firefox 3+. */ button::-moz-focus-inner, @@ -480,9 +503,9 @@ input::-moz-focus-inner { padding: 0; } -/* - * 1. Removes default vertical scrollbar in IE 6/7/8/9. - * 2. Improves readability and alignment in all browsers. +/** + * 1. Remove default vertical scrollbar in IE 6/7/8/9. + * 2. Improve readability and alignment in all browsers. */ textarea { @@ -494,7 +517,7 @@ textarea { Tables ========================================================================== */ -/* +/** * Remove most spacing between table cells. */ diff --git a/middleman-templates/lib/middleman-templates/html5/source/favicon.ico b/middleman-templates/lib/middleman-templates/html5/source/favicon.ico old mode 100755 new mode 100644 index 1f2a998670d70716df63fe473f4990f6dd7e0bc2..be74abd69ad6a32de7375df13cab9354798e328f GIT binary patch literal 766 zcmZQzU}RuqP*4zHU}Runc)`TLAjZJJpuxbvpuoVu;J^TqXJNnvB%~D>6crR0_!JBo zST#Kv7)?_d7+hN!7y@Q6FoZ2*U`X7_z?y!Tfg|Sx18?CO2I2B646=>4;l>FP2F_3= z0w!RFK!gF97Gzlhp|!Ruf*4FWMIcI0ko9!3prD|D#qK}|Uu5+TCqY4#)jJ&_e4(yY zTNQ6BHDPS+%CwV%Msz5NSa{>s70Ety;Bm3XHF@Yt^b%t5!pe7ZhYY1>&!P z8ZRg)43=MM2vskj29jR2DhSGFnFHaUZ~_Z3<$$%XTD1o3ZUN6*5b0H`_O>tz3aFid zaaXN66C|j57X)^#TD2NP-w85L4Gj$q?OwI&1c(kR7GwnZHFnkNt6&D$20=mV-FqfO znP7_J_FlN_K?1C|_rhHd;tQWS1#>-!D=5%=9U3@buAo5dRR{w{+HQuiAT(DKgocq~ Ug)kO`7Dh21A_gYm31NU30N^@`#sB~S literal 318 zcmZQzU}Ruq5D*YxU}Run&|qX>5My9q&|qL-5MW?nP+$PbvoPQSipq)%O3JznN@~sw zT6!7`N(N;NdJfJE%KDuQ>b8p+j3etAR6LF`Xn34sFpinSpqIFv!6@ZAgK_F3u#t>l zQha?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(n.isPlainObject(c)||(b=n.isArray(c)))?(b?(b=!1,f=a&&n.isArray(a)?a:[]):f=a&&n.isPlainObject(a)?a:{},g[d]=n.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray||function(a){return"array"===n.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return a-parseFloat(a)>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==n.type(a)||a.nodeType||n.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(l.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&n.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:k&&!k.call("\ufeff\xa0")?function(a){return null==a?"":k.call(a)}:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),n.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||n.guid++,e):void 0},now:function(){return+new Date},support:l}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s="sizzle"+-new Date,t=a.document,u=0,v=0,w=eb(),x=eb(),y=eb(),z=function(a,b){return a===b&&(j=!0),0},A="undefined",B=1<<31,C={}.hasOwnProperty,D=[],E=D.pop,F=D.push,G=D.push,H=D.slice,I=D.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},J="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",K="[\\x20\\t\\r\\n\\f]",L="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",M=L.replace("w","w#"),N="\\["+K+"*("+L+")"+K+"*(?:([*^$|!~]?=)"+K+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+M+")|)|)"+K+"*\\]",O=":("+L+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+N.replace(3,8)+")*)|.*)\\)|)",P=new RegExp("^"+K+"+|((?:^|[^\\\\])(?:\\\\.)*)"+K+"+$","g"),Q=new RegExp("^"+K+"*,"+K+"*"),R=new RegExp("^"+K+"*([>+~]|"+K+")"+K+"*"),S=new RegExp("="+K+"*([^\\]'\"]*?)"+K+"*\\]","g"),T=new RegExp(O),U=new RegExp("^"+M+"$"),V={ID:new RegExp("^#("+L+")"),CLASS:new RegExp("^\\.("+L+")"),TAG:new RegExp("^("+L.replace("w","w*")+")"),ATTR:new RegExp("^"+N),PSEUDO:new RegExp("^"+O),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+K+"*(even|odd|(([+-]|)(\\d*)n|)"+K+"*(?:([+-]|)"+K+"*(\\d+)|))"+K+"*\\)|)","i"),bool:new RegExp("^(?:"+J+")$","i"),needsContext:new RegExp("^"+K+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+K+"*((?:-\\d)?\\d*)"+K+"*\\)|)(?=[^-]|$)","i")},W=/^(?:input|select|textarea|button)$/i,X=/^h\d$/i,Y=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,$=/[+~]/,_=/'|\\/g,ab=new RegExp("\\\\([\\da-f]{1,6}"+K+"?|("+K+")|.)","ig"),bb=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{G.apply(D=H.call(t.childNodes),t.childNodes),D[t.childNodes.length].nodeType}catch(cb){G={apply:D.length?function(a,b){F.apply(a,H.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function db(a,b,d,e){var f,g,h,i,j,m,p,q,u,v;if((b?b.ownerDocument||b:t)!==l&&k(b),b=b||l,d=d||[],!a||"string"!=typeof a)return d;if(1!==(i=b.nodeType)&&9!==i)return[];if(n&&!e){if(f=Z.exec(a))if(h=f[1]){if(9===i){if(g=b.getElementById(h),!g||!g.parentNode)return d;if(g.id===h)return d.push(g),d}else if(b.ownerDocument&&(g=b.ownerDocument.getElementById(h))&&r(b,g)&&g.id===h)return d.push(g),d}else{if(f[2])return G.apply(d,b.getElementsByTagName(a)),d;if((h=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return G.apply(d,b.getElementsByClassName(h)),d}if(c.qsa&&(!o||!o.test(a))){if(q=p=s,u=b,v=9===i&&a,1===i&&"object"!==b.nodeName.toLowerCase()){m=ob(a),(p=b.getAttribute("id"))?q=p.replace(_,"\\$&"):b.setAttribute("id",q),q="[id='"+q+"'] ",j=m.length;while(j--)m[j]=q+pb(m[j]);u=$.test(a)&&mb(b.parentNode)||b,v=m.join(",")}if(v)try{return G.apply(d,u.querySelectorAll(v)),d}catch(w){}finally{p||b.removeAttribute("id")}}}return xb(a.replace(P,"$1"),b,d,e)}function eb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function fb(a){return a[s]=!0,a}function gb(a){var b=l.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function hb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function ib(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||B)-(~a.sourceIndex||B);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function jb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function kb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function lb(a){return fb(function(b){return b=+b,fb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function mb(a){return a&&typeof a.getElementsByTagName!==A&&a}c=db.support={},f=db.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},k=db.setDocument=function(a){var b,e=a?a.ownerDocument||a:t,g=e.defaultView;return e!==l&&9===e.nodeType&&e.documentElement?(l=e,m=e.documentElement,n=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){k()},!1):g.attachEvent&&g.attachEvent("onunload",function(){k()})),c.attributes=gb(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=gb(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=Y.test(e.getElementsByClassName)&&gb(function(a){return a.innerHTML="
",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=gb(function(a){return m.appendChild(a).id=s,!e.getElementsByName||!e.getElementsByName(s).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==A&&n){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(ab,bb);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(ab,bb);return function(a){var c=typeof a.getAttributeNode!==A&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==A?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==A&&n?b.getElementsByClassName(a):void 0},p=[],o=[],(c.qsa=Y.test(e.querySelectorAll))&&(gb(function(a){a.innerHTML="",a.querySelectorAll("[t^='']").length&&o.push("[*^$]="+K+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||o.push("\\["+K+"*(?:value|"+J+")"),a.querySelectorAll(":checked").length||o.push(":checked")}),gb(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&o.push("name"+K+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||o.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),o.push(",.*:")})),(c.matchesSelector=Y.test(q=m.webkitMatchesSelector||m.mozMatchesSelector||m.oMatchesSelector||m.msMatchesSelector))&&gb(function(a){c.disconnectedMatch=q.call(a,"div"),q.call(a,"[s!='']:x"),p.push("!=",O)}),o=o.length&&new RegExp(o.join("|")),p=p.length&&new RegExp(p.join("|")),b=Y.test(m.compareDocumentPosition),r=b||Y.test(m.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},z=b?function(a,b){if(a===b)return j=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===t&&r(t,a)?-1:b===e||b.ownerDocument===t&&r(t,b)?1:i?I.call(i,a)-I.call(i,b):0:4&d?-1:1)}:function(a,b){if(a===b)return j=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],k=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:i?I.call(i,a)-I.call(i,b):0;if(f===g)return ib(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)k.unshift(c);while(h[d]===k[d])d++;return d?ib(h[d],k[d]):h[d]===t?-1:k[d]===t?1:0},e):l},db.matches=function(a,b){return db(a,null,null,b)},db.matchesSelector=function(a,b){if((a.ownerDocument||a)!==l&&k(a),b=b.replace(S,"='$1']"),!(!c.matchesSelector||!n||p&&p.test(b)||o&&o.test(b)))try{var d=q.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return db(b,l,null,[a]).length>0},db.contains=function(a,b){return(a.ownerDocument||a)!==l&&k(a),r(a,b)},db.attr=function(a,b){(a.ownerDocument||a)!==l&&k(a);var e=d.attrHandle[b.toLowerCase()],f=e&&C.call(d.attrHandle,b.toLowerCase())?e(a,b,!n):void 0;return void 0!==f?f:c.attributes||!n?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},db.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},db.uniqueSort=function(a){var b,d=[],e=0,f=0;if(j=!c.detectDuplicates,i=!c.sortStable&&a.slice(0),a.sort(z),j){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return i=null,a},e=db.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=db.selectors={cacheLength:50,createPseudo:fb,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ab,bb),a[3]=(a[4]||a[5]||"").replace(ab,bb),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||db.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&db.error(a[0]),a},PSEUDO:function(a){var b,c=!a[5]&&a[2];return V.CHILD.test(a[0])?null:(a[3]&&void 0!==a[4]?a[2]=a[4]:c&&T.test(c)&&(b=ob(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(ab,bb).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=w[a+" "];return b||(b=new RegExp("(^|"+K+")"+a+"("+K+"|$)"))&&w(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==A&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=db.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),t=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&t){k=q[s]||(q[s]={}),j=k[a]||[],n=j[0]===u&&j[1],m=j[0]===u&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[u,n,m];break}}else if(t&&(j=(b[s]||(b[s]={}))[a])&&j[0]===u)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(t&&((l[s]||(l[s]={}))[a]=[u,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||db.error("unsupported pseudo: "+a);return e[s]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?fb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=I.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:fb(function(a){var b=[],c=[],d=g(a.replace(P,"$1"));return d[s]?fb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:fb(function(a){return function(b){return db(a,b).length>0}}),contains:fb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:fb(function(a){return U.test(a||"")||db.error("unsupported lang: "+a),a=a.replace(ab,bb).toLowerCase(),function(b){var c;do if(c=n?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===m},focus:function(a){return a===l.activeElement&&(!l.hasFocus||l.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return X.test(a.nodeName)},input:function(a){return W.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:lb(function(){return[0]}),last:lb(function(a,b){return[b-1]}),eq:lb(function(a,b,c){return[0>c?c+b:c]}),even:lb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:lb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:lb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:lb(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function qb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=v++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[u,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[s]||(b[s]={}),(h=i[d])&&h[0]===u&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function rb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function sb(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function tb(a,b,c,d,e,f){return d&&!d[s]&&(d=tb(d)),e&&!e[s]&&(e=tb(e,f)),fb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||wb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:sb(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=sb(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?I.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=sb(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):G.apply(g,r)})}function ub(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],i=g||d.relative[" "],j=g?1:0,k=qb(function(a){return a===b},i,!0),l=qb(function(a){return I.call(b,a)>-1},i,!0),m=[function(a,c,d){return!g&&(d||c!==h)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>j;j++)if(c=d.relative[a[j].type])m=[qb(rb(m),c)];else{if(c=d.filter[a[j].type].apply(null,a[j].matches),c[s]){for(e=++j;f>e;e++)if(d.relative[a[e].type])break;return tb(j>1&&rb(m),j>1&&pb(a.slice(0,j-1).concat({value:" "===a[j-2].type?"*":""})).replace(P,"$1"),c,e>j&&ub(a.slice(j,e)),f>e&&ub(a=a.slice(e)),f>e&&pb(a))}m.push(c)}return rb(m)}function vb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,i,j,k){var m,n,o,p=0,q="0",r=f&&[],s=[],t=h,v=f||e&&d.find.TAG("*",k),w=u+=null==t?1:Math.random()||.1,x=v.length;for(k&&(h=g!==l&&g);q!==x&&null!=(m=v[q]);q++){if(e&&m){n=0;while(o=a[n++])if(o(m,g,i)){j.push(m);break}k&&(u=w)}c&&((m=!o&&m)&&p--,f&&r.push(m))}if(p+=q,c&&q!==p){n=0;while(o=b[n++])o(r,s,g,i);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=E.call(j));s=sb(s)}G.apply(j,s),k&&!f&&s.length>0&&p+b.length>1&&db.uniqueSort(j)}return k&&(u=w,h=t),r};return c?fb(f):f}g=db.compile=function(a,b){var c,d=[],e=[],f=y[a+" "];if(!f){b||(b=ob(a)),c=b.length;while(c--)f=ub(b[c]),f[s]?d.push(f):e.push(f);f=y(a,vb(e,d))}return f};function wb(a,b,c){for(var d=0,e=b.length;e>d;d++)db(a,b[d],c);return c}function xb(a,b,e,f){var h,i,j,k,l,m=ob(a);if(!f&&1===m.length){if(i=m[0]=m[0].slice(0),i.length>2&&"ID"===(j=i[0]).type&&c.getById&&9===b.nodeType&&n&&d.relative[i[1].type]){if(b=(d.find.ID(j.matches[0].replace(ab,bb),b)||[])[0],!b)return e;a=a.slice(i.shift().value.length)}h=V.needsContext.test(a)?0:i.length;while(h--){if(j=i[h],d.relative[k=j.type])break;if((l=d.find[k])&&(f=l(j.matches[0].replace(ab,bb),$.test(i[0].type)&&mb(b.parentNode)||b))){if(i.splice(h,1),a=f.length&&pb(i),!a)return G.apply(e,f),e;break}}}return g(a,m)(f,b,!n,e,$.test(a)&&mb(b.parentNode)||b),e}return c.sortStable=s.split("").sort(z).join("")===s,c.detectDuplicates=!!j,k(),c.sortDetached=gb(function(a){return 1&a.compareDocumentPosition(l.createElement("div"))}),gb(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||hb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&gb(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||hb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),gb(function(a){return null==a.getAttribute("disabled")})||hb(J,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),db}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=n.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return n.inArray(a,b)>=0!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=[],d=this,e=d.length;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;e>b;b++)if(n.contains(d[b],this))return!0}));for(b=0;e>b;b++)n.find(a,d[b],c);return c=this.pushStack(e>1?n.unique(c):c),c.selector=this.selector?this.selector+" "+a:a,c},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?n(a):a||[],!1).length}});var y,z=a.document,A=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,B=n.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:A.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:z,!0)),v.test(c[1])&&n.isPlainObject(b))for(c in b)n.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}if(d=z.getElementById(c[2]),d&&d.parentNode){if(d.id!==c[2])return y.find(a);this.length=1,this[0]=d}return this.context=z,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};B.prototype=n.fn,y=n(z);var C=/^(?:parents|prev(?:Until|All))/,D={children:!0,contents:!0,next:!0,prev:!0};n.extend({dir:function(a,b,c){var d=[],e=a[b];while(e&&9!==e.nodeType&&(void 0===c||1!==e.nodeType||!n(e).is(c)))1===e.nodeType&&d.push(e),e=e[b];return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),n.fn.extend({has:function(a){var b,c=n(a,this),d=c.length;return this.filter(function(){for(b=0;d>b;b++)if(n.contains(this,c[b]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.unique(f):f)},index:function(a){return a?"string"==typeof a?n.inArray(this[0],n(a)):n.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.unique(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function E(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return n.dir(a,"parentNode")},parentsUntil:function(a,b,c){return n.dir(a,"parentNode",c)},next:function(a){return E(a,"nextSibling")},prev:function(a){return E(a,"previousSibling")},nextAll:function(a){return n.dir(a,"nextSibling")},prevAll:function(a){return n.dir(a,"previousSibling")},nextUntil:function(a,b,c){return n.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return n.dir(a,"previousSibling",c)},siblings:function(a){return n.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return n.sibling(a.firstChild)},contents:function(a){return n.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(D[a]||(e=n.unique(e)),C.test(a)&&(e=e.reverse())),this.pushStack(e)}});var F=/\S+/g,G={};function H(a){var b=G[a]={};return n.each(a.match(F)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?G[a]||H(a):n.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(c=a.memory&&l,d=!0,f=g||0,g=0,e=h.length,b=!0;h&&e>f;f++)if(h[f].apply(l[0],l[1])===!1&&a.stopOnFalse){c=!1;break}b=!1,h&&(i?i.length&&j(i.shift()):c?h=[]:k.disable())},k={add:function(){if(h){var d=h.length;!function f(b){n.each(b,function(b,c){var d=n.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&f(c)})}(arguments),b?e=h.length:c&&(g=d,j(c))}return this},remove:function(){return h&&n.each(arguments,function(a,c){var d;while((d=n.inArray(c,h,d))>-1)h.splice(d,1),b&&(e>=d&&e--,f>=d&&f--)}),this},has:function(a){return a?n.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],e=0,this},disable:function(){return h=i=c=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,c||k.disable(),this},locked:function(){return!i},fireWith:function(a,c){return!h||d&&!i||(c=c||[],c=[a,c.slice?c.slice():c],b?i.push(c):j(c)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!d}};return k},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&n.isFunction(a.promise)?e:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var I;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){if(a===!0?!--n.readyWait:!n.isReady){if(!z.body)return setTimeout(n.ready);n.isReady=!0,a!==!0&&--n.readyWait>0||(I.resolveWith(z,[n]),n.fn.trigger&&n(z).trigger("ready").off("ready"))}}});function J(){z.addEventListener?(z.removeEventListener("DOMContentLoaded",K,!1),a.removeEventListener("load",K,!1)):(z.detachEvent("onreadystatechange",K),a.detachEvent("onload",K))}function K(){(z.addEventListener||"load"===event.type||"complete"===z.readyState)&&(J(),n.ready())}n.ready.promise=function(b){if(!I)if(I=n.Deferred(),"complete"===z.readyState)setTimeout(n.ready);else if(z.addEventListener)z.addEventListener("DOMContentLoaded",K,!1),a.addEventListener("load",K,!1);else{z.attachEvent("onreadystatechange",K),a.attachEvent("onload",K);var c=!1;try{c=null==a.frameElement&&z.documentElement}catch(d){}c&&c.doScroll&&!function e(){if(!n.isReady){try{c.doScroll("left")}catch(a){return setTimeout(e,50)}J(),n.ready()}}()}return I.promise(b)};var L="undefined",M;for(M in n(l))break;l.ownLast="0"!==M,l.inlineBlockNeedsLayout=!1,n(function(){var a,b,c=z.getElementsByTagName("body")[0];c&&(a=z.createElement("div"),a.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",b=z.createElement("div"),c.appendChild(a).appendChild(b),typeof b.style.zoom!==L&&(b.style.cssText="border:0;margin:0;width:1px;padding:1px;display:inline;zoom:1",(l.inlineBlockNeedsLayout=3===b.offsetWidth)&&(c.style.zoom=1)),c.removeChild(a),a=b=null)}),function(){var a=z.createElement("div");if(null==l.deleteExpando){l.deleteExpando=!0;try{delete a.test}catch(b){l.deleteExpando=!1}}a=null}(),n.acceptData=function(a){var b=n.noData[(a.nodeName+" ").toLowerCase()],c=+a.nodeType||1;return 1!==c&&9!==c?!1:!b||b!==!0&&a.getAttribute("classid")===b};var N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(O,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?n.parseJSON(c):c}catch(e){}n.data(a,b,c)}else c=void 0}return c}function Q(a){var b;for(b in a)if(("data"!==b||!n.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function R(a,b,d,e){if(n.acceptData(a)){var f,g,h=n.expando,i=a.nodeType,j=i?n.cache:a,k=i?a[h]:a[h]&&h;if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||n.guid++:h),j[k]||(j[k]=i?{}:{toJSON:n.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=n.extend(j[k],b):j[k].data=n.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[n.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[n.camelCase(b)])):f=g,f +}}function S(a,b,c){if(n.acceptData(a)){var d,e,f=a.nodeType,g=f?n.cache:a,h=f?a[n.expando]:n.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){n.isArray(b)?b=b.concat(n.map(b,n.camelCase)):b in d?b=[b]:(b=n.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!Q(d):!n.isEmptyObject(d))return}(c||(delete g[h].data,Q(g[h])))&&(f?n.cleanData([a],!0):l.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}n.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?n.cache[a[n.expando]]:a[n.expando],!!a&&!Q(a)},data:function(a,b,c){return R(a,b,c)},removeData:function(a,b){return S(a,b)},_data:function(a,b,c){return R(a,b,c,!0)},_removeData:function(a,b){return S(a,b,!0)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=n.data(f),1===f.nodeType&&!n._data(f,"parsedAttrs"))){c=g.length;while(c--)d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d]));n._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){n.data(this,a)}):arguments.length>1?this.each(function(){n.data(this,a,b)}):f?P(f,a,n.data(f,a)):void 0},removeData:function(a){return this.each(function(){n.removeData(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=n._data(a,b),c&&(!d||n.isArray(c)?d=n._data(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return n._data(a,c)||n._data(a,c,{empty:n.Callbacks("once memory").add(function(){n._removeData(a,b+"queue"),n._removeData(a,c)})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthh;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},X=/^(?:checkbox|radio)$/i;!function(){var a=z.createDocumentFragment(),b=z.createElement("div"),c=z.createElement("input");if(b.setAttribute("className","t"),b.innerHTML="
a",l.leadingWhitespace=3===b.firstChild.nodeType,l.tbody=!b.getElementsByTagName("tbody").length,l.htmlSerialize=!!b.getElementsByTagName("link").length,l.html5Clone="<:nav>"!==z.createElement("nav").cloneNode(!0).outerHTML,c.type="checkbox",c.checked=!0,a.appendChild(c),l.appendChecked=c.checked,b.innerHTML="",l.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,a.appendChild(b),b.innerHTML="",l.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,l.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){l.noCloneEvent=!1}),b.cloneNode(!0).click()),null==l.deleteExpando){l.deleteExpando=!0;try{delete b.test}catch(d){l.deleteExpando=!1}}a=b=c=null}(),function(){var b,c,d=z.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(l[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),l[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var Y=/^(?:input|select|textarea)$/i,Z=/^key/,$=/^(?:mouse|contextmenu)|click/,_=/^(?:focusinfocus|focusoutblur)$/,ab=/^([^.]*)(?:\.(.+)|)$/;function bb(){return!0}function cb(){return!1}function db(){try{return z.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=n._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=n.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return typeof n===L||a&&n.event.triggered===a.type?void 0:n.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(F)||[""],h=b.length;while(h--)f=ab.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=n.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=n.event.special[o]||{},l=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},i),(m=g[o])||(m=g[o]=[],m.delegateCount=0,j.setup&&j.setup.call(a,d,p,k)!==!1||(a.addEventListener?a.addEventListener(o,k,!1):a.attachEvent&&a.attachEvent("on"+o,k))),j.add&&(j.add.call(a,l),l.handler.guid||(l.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,l):m.push(l),n.event.global[o]=!0);a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=n.hasData(a)&&n._data(a);if(r&&(k=r.events)){b=(b||"").match(F)||[""],j=b.length;while(j--)if(h=ab.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=k[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=m.length;while(f--)g=m[f],!e&&q!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(m.splice(f,1),g.selector&&m.delegateCount--,l.remove&&l.remove.call(a,g));i&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete k[o])}else for(o in k)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(k)&&(delete r.handle,n._removeData(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,m,o=[d||z],p=j.call(b,"type")?b.type:b,q=j.call(b,"namespace")?b.namespace.split("."):[];if(h=l=d=d||z,3!==d.nodeType&&8!==d.nodeType&&!_.test(p+n.event.triggered)&&(p.indexOf(".")>=0&&(q=p.split("."),p=q.shift(),q.sort()),g=p.indexOf(":")<0&&"on"+p,b=b[n.expando]?b:new n.Event(p,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=q.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:n.makeArray(c,[b]),k=n.event.special[p]||{},e||!k.trigger||k.trigger.apply(d,c)!==!1)){if(!e&&!k.noBubble&&!n.isWindow(d)){for(i=k.delegateType||p,_.test(i+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),l=h;l===(d.ownerDocument||z)&&o.push(l.defaultView||l.parentWindow||a)}m=0;while((h=o[m++])&&!b.isPropagationStopped())b.type=m>1?i:k.bindType||p,f=(n._data(h,"events")||{})[b.type]&&n._data(h,"handle"),f&&f.apply(h,c),f=g&&h[g],f&&f.apply&&n.acceptData(h)&&(b.result=f.apply(h,c),b.result===!1&&b.preventDefault());if(b.type=p,!e&&!b.isDefaultPrevented()&&(!k._default||k._default.apply(o.pop(),c)===!1)&&n.acceptData(d)&&g&&d[p]&&!n.isWindow(d)){l=d[g],l&&(d[g]=null),n.event.triggered=p;try{d[p]()}catch(r){}n.event.triggered=void 0,l&&(d[g]=l)}return b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(n._data(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,g=0;while((e=f.handlers[g++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,c=((n.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),void 0!==c&&(a.result=c)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!=this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(e=[],f=0;h>f;f++)d=b[f],c=d.selector+" ",void 0===e[c]&&(e[c]=d.needsContext?n(c,this).index(i)>=0:n.find(c,this,null,[i]).length),e[c]&&e.push(d);e.length&&g.push({elem:i,handlers:e})}return h]","i"),ib=/^\s+/,jb=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,kb=/<([\w:]+)/,lb=/\s*$/g,sb={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],_default:l.htmlSerialize?[0,"",""]:[1,"X
","
"]},tb=eb(z),ub=tb.appendChild(z.createElement("div"));sb.optgroup=sb.option,sb.tbody=sb.tfoot=sb.colgroup=sb.caption=sb.thead,sb.th=sb.td;function vb(a,b){var c,d,e=0,f=typeof a.getElementsByTagName!==L?a.getElementsByTagName(b||"*"):typeof a.querySelectorAll!==L?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||n.nodeName(d,b)?f.push(d):n.merge(f,vb(d,b));return void 0===b||b&&n.nodeName(a,b)?n.merge([a],f):f}function wb(a){X.test(a.type)&&(a.defaultChecked=a.checked)}function xb(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function yb(a){return a.type=(null!==n.find.attr(a,"type"))+"/"+a.type,a}function zb(a){var b=qb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function Ab(a,b){for(var c,d=0;null!=(c=a[d]);d++)n._data(c,"globalEval",!b||n._data(b[d],"globalEval"))}function Bb(a,b){if(1===b.nodeType&&n.hasData(a)){var c,d,e,f=n._data(a),g=n._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)n.event.add(b,c,h[c][d])}g.data&&(g.data=n.extend({},g.data))}}function Cb(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!l.noCloneEvent&&b[n.expando]){e=n._data(b);for(d in e.events)n.removeEvent(b,d,e.handle);b.removeAttribute(n.expando)}"script"===c&&b.text!==a.text?(yb(b).text=a.text,zb(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),l.html5Clone&&a.innerHTML&&!n.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&X.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}n.extend({clone:function(a,b,c){var d,e,f,g,h,i=n.contains(a.ownerDocument,a);if(l.html5Clone||n.isXMLDoc(a)||!hb.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(ub.innerHTML=a.outerHTML,ub.removeChild(f=ub.firstChild)),!(l.noCloneEvent&&l.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(d=vb(f),h=vb(a),g=0;null!=(e=h[g]);++g)d[g]&&Cb(e,d[g]);if(b)if(c)for(h=h||vb(a),d=d||vb(f),g=0;null!=(e=h[g]);g++)Bb(e,d[g]);else Bb(a,f);return d=vb(f,"script"),d.length>0&&Ab(d,!i&&vb(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k,m=a.length,o=eb(b),p=[],q=0;m>q;q++)if(f=a[q],f||0===f)if("object"===n.type(f))n.merge(p,f.nodeType?[f]:f);else if(mb.test(f)){h=h||o.appendChild(b.createElement("div")),i=(kb.exec(f)||["",""])[1].toLowerCase(),k=sb[i]||sb._default,h.innerHTML=k[1]+f.replace(jb,"<$1>")+k[2],e=k[0];while(e--)h=h.lastChild;if(!l.leadingWhitespace&&ib.test(f)&&p.push(b.createTextNode(ib.exec(f)[0])),!l.tbody){f="table"!==i||lb.test(f)?""!==k[1]||lb.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;while(e--)n.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j)}n.merge(p,h.childNodes),h.textContent="";while(h.firstChild)h.removeChild(h.firstChild);h=o.lastChild}else p.push(b.createTextNode(f));h&&o.removeChild(h),l.appendChecked||n.grep(vb(p,"input"),wb),q=0;while(f=p[q++])if((!d||-1===n.inArray(f,d))&&(g=n.contains(f.ownerDocument,f),h=vb(o.appendChild(f),"script"),g&&Ab(h),c)){e=0;while(f=h[e++])pb.test(f.type||"")&&c.push(f)}return h=null,o},cleanData:function(a,b){for(var d,e,f,g,h=0,i=n.expando,j=n.cache,k=l.deleteExpando,m=n.event.special;null!=(d=a[h]);h++)if((b||n.acceptData(d))&&(f=d[i],g=f&&j[f])){if(g.events)for(e in g.events)m[e]?n.event.remove(d,e):n.removeEvent(d,e,g.handle);j[f]&&(delete j[f],k?delete d[i]:typeof d.removeAttribute!==L?d.removeAttribute(i):d[i]=null,c.push(f))}}}),n.fn.extend({text:function(a){return W(this,function(a){return void 0===a?n.text(this):this.empty().append((this[0]&&this[0].ownerDocument||z).createTextNode(a))},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=xb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=xb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?n.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||n.cleanData(vb(c)),c.parentNode&&(b&&n.contains(c.ownerDocument,c)&&Ab(vb(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){1===a.nodeType&&n.cleanData(vb(a,!1));while(a.firstChild)a.removeChild(a.firstChild);a.options&&n.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return W(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a)return 1===b.nodeType?b.innerHTML.replace(gb,""):void 0;if(!("string"!=typeof a||nb.test(a)||!l.htmlSerialize&&hb.test(a)||!l.leadingWhitespace&&ib.test(a)||sb[(kb.exec(a)||["",""])[1].toLowerCase()])){a=a.replace(jb,"<$1>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(vb(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,n.cleanData(vb(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,k=this.length,m=this,o=k-1,p=a[0],q=n.isFunction(p);if(q||k>1&&"string"==typeof p&&!l.checkClone&&ob.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(k&&(i=n.buildFragment(a,this[0].ownerDocument,!1,this),c=i.firstChild,1===i.childNodes.length&&(i=c),c)){for(g=n.map(vb(i,"script"),yb),f=g.length;k>j;j++)d=i,j!==o&&(d=n.clone(d,!0,!0),f&&n.merge(g,vb(d,"script"))),b.call(this[j],d,j);if(f)for(h=g[g.length-1].ownerDocument,n.map(g,zb),j=0;f>j;j++)d=g[j],pb.test(d.type||"")&&!n._data(d,"globalEval")&&n.contains(h,d)&&(d.src?n._evalUrl&&n._evalUrl(d.src):n.globalEval((d.text||d.textContent||d.innerHTML||"").replace(rb,"")));i=c=null}return this}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=0,e=[],g=n(a),h=g.length-1;h>=d;d++)c=d===h?this:this.clone(!0),n(g[d])[b](c),f.apply(e,c.get());return this.pushStack(e)}});var Db,Eb={};function Fb(b,c){var d=n(c.createElement(b)).appendTo(c.body),e=a.getDefaultComputedStyle?a.getDefaultComputedStyle(d[0]).display:n.css(d[0],"display");return d.detach(),e}function Gb(a){var b=z,c=Eb[a];return c||(c=Fb(a,b),"none"!==c&&c||(Db=(Db||n("