From b2f6d0db098dfe52453908de3107b6790a0f6b89 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Sun, 25 Mar 2012 17:38:38 -0700 Subject: [PATCH 1/2] Get rid of some unused stuff in sitemap and complete documentation --- .../lib/middleman-core/sitemap/page.rb | 23 +++---------------- .../lib/middleman-core/sitemap/store.rb | 10 ++------ middleman-more/lib/middleman-more.rb | 2 +- 3 files changed, 6 insertions(+), 29 deletions(-) diff --git a/middleman-core/lib/middleman-core/sitemap/page.rb b/middleman-core/lib/middleman-core/sitemap/page.rb index 730089e7..a3e1b3f9 100644 --- a/middleman-core/lib/middleman-core/sitemap/page.rb +++ b/middleman-core/lib/middleman-core/sitemap/page.rb @@ -11,19 +11,16 @@ module Middleman::Sitemap # @return [String] attr_accessor :path - # @return [Middleman::Sitemap::Page] + # The path of the page this page is proxied to, or nil if it's not proxied. + # @return [String] attr_accessor :proxied_to - # @return [Symbol] - attr_accessor :status - # Initialize page with parent store and URL # @param [Middleman::Sitemap::Store] store # @param [String] path def initialize(store, path) @store = store @path = path - @status = :generic @source_file = nil @proxied_to = nil end @@ -83,30 +80,16 @@ module Middleman::Sitemap # Whether this page is a proxy # @return [Boolean] def proxy? - @status == :proxy + !!@proxied_to end # Set this page to proxy to a target path # @param [String] target # @return [void] def proxy_to(target) - @status = :proxy @proxied_to = target end - # Whether this page is a generic page - # @return [Boolean] - def generic? - @status == :generic - end - - # Set this page to be a generic page - # @return [void] - def make_generic - @status = :generic - # TODO: Remove from ignore array? - end - # Whether this page is ignored # @return [Boolean] def ignored? diff --git a/middleman-core/lib/middleman-core/sitemap/store.rb b/middleman-core/lib/middleman-core/sitemap/store.rb index 80226c87..07b9662a 100644 --- a/middleman-core/lib/middleman-core/sitemap/store.rb +++ b/middleman-core/lib/middleman-core/sitemap/store.rb @@ -91,6 +91,8 @@ module Middleman::Sitemap end # Find a page given its destination path + # @param [String] The destination (output) path of a page. + # @return [Middleman::Sitemap::Page] def page_by_destination(destination_path) # TODO: memoize this destination_path = normalize_path(destination_path) @@ -156,14 +158,6 @@ module Middleman::Sitemap true end - # Whether the sitemap should completely ignore a given file/path - # @param [String] file - # @param [String] path - # @return [Boolean] - def sitemap_should_ignore?(file, path) - @app.sitemap_ignore.every(&:call) - end - protected # Get a path without templating extensions diff --git a/middleman-more/lib/middleman-more.rb b/middleman-more/lib/middleman-more.rb index 1bde2947..f763fed4 100644 --- a/middleman-more/lib/middleman-more.rb +++ b/middleman-more/lib/middleman-more.rb @@ -25,7 +25,7 @@ module Middleman autoload :Sprockets, "middleman-more/core_extensions/sprockets" end - # User-activatable extendions + # User-activatable extensions module Extensions # RelativeAssets allow any asset path in dynamic templates to be either # relative to the root of the project or use an absolute URL. From 3c4578b239cd86954f1271c73188ebce18d684d6 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Mon, 26 Mar 2012 21:39:43 -0700 Subject: [PATCH 2/2] Document Middleman::Extensions.register --- middleman-core/lib/middleman-core.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/middleman-core/lib/middleman-core.rb b/middleman-core/lib/middleman-core.rb index 759a7974..09c14d8a 100755 --- a/middleman-core/lib/middleman-core.rb +++ b/middleman-core/lib/middleman-core.rb @@ -122,6 +122,23 @@ module Middleman @_registered ||= {} end + # Register a new extension. Choose a name which will be + # used to activate the extension in config.rb, like this: + # + # activate :my_extension + # + # Provide your extension module either as the namespace + # parameter, or return it from the block: + # + # @param [Symbol] name The name of the extension + # @param [Module] namespace The extension module + # @param [String] version A RubyGems-style version string stating + # the versions of middleman this extension + # is compatible with. + # @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, version=nil, &block) # If we've already got a matching extension that passed the # version check, bail out.