From 30cbcbf1091dedfd99538ecd97498590c6599734 Mon Sep 17 00:00:00 2001 From: Shigeaki Matsumura Date: Tue, 20 Dec 2016 09:38:35 +0900 Subject: [PATCH 1/3] escape_html -> h --- lib/middleman-sitemap/extension.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/middleman-sitemap/extension.rb b/lib/middleman-sitemap/extension.rb index 2751f1d..8b4d4f5 100644 --- a/lib/middleman-sitemap/extension.rb +++ b/lib/middleman-sitemap/extension.rb @@ -3,6 +3,8 @@ class Sitemap < ::Middleman::Extension option :gzip, true, 'Whether or not to GZIP the resulting file' option :hostname, "http://www.example.com", "The hostname for your website" + include Padrino::Helpers + def initialize(app, options_hash={}, &block) # Call super to build options from the options_hash super @@ -91,7 +93,7 @@ def gzip_file(sitemap) # Returns a URL with proper HTML entities def encode(path) - str = path.split("/").map { |f| app.escape_html(f) }.join("/") + str = path.split("/").map { |f| h(f) }.join('/') return str end From b52c2256d4188761122804cbb79ceb6cd1afdf6b Mon Sep 17 00:00:00 2001 From: Shigeaki Matsumura Date: Tue, 20 Dec 2016 10:04:01 +0900 Subject: [PATCH 2/3] fix to work with middleman v4 --- lib/middleman-sitemap/extension.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/middleman-sitemap/extension.rb b/lib/middleman-sitemap/extension.rb index 8b4d4f5..ca4efa1 100644 --- a/lib/middleman-sitemap/extension.rb +++ b/lib/middleman-sitemap/extension.rb @@ -33,7 +33,7 @@ def generate_sitemap if options.gzip sitemaps.each do |sitemap| gzip_file(sitemap) - @builder.say_status :create, "#{sitemap}.gz" if @builder + @builder.thor.say_status :create, "#{sitemap}.gz" if @builder end end end @@ -45,12 +45,12 @@ def build_sitemap_index(number_of_sitemaps) template = Tilt::ERBTemplate.new(File.expand_path(File.join("#{File.dirname(__FILE__)}", "../../templates/sitemapindex.xml.erb"))) sitemap = template.render(self) - outfile = File.join(app.build_dir, "sitemap.xml") + outfile = File.join(app.config.build_dir, "sitemap.xml") File.open(outfile, 'w') {|f| f.write(sitemap) } - @builder.say_status :create, "#{app.build_dir}/sitemap.xml" + @builder.thor.say_status :create, "#{app.config.build_dir}/sitemap.xml" - return "#{app.build_dir}/sitemap.xml" + return "#{app.config.build_dir}/sitemap.xml" end def build_sitemap(name, pages) @@ -60,12 +60,12 @@ def build_sitemap(name, pages) template = Tilt::ERBTemplate.new(templates_path, 0, :trim => '>') sitemap = template.render(self) - outfile = File.join(app.build_dir, name) + outfile = File.join(app.config.build_dir, name) File.open(outfile, 'w') {|f| f.write(sitemap) } - @builder.say_status :create, "#{app.build_dir}/#{name}" + @builder.thor.say_status :create, "#{app.config.build_dir}/#{name}" - return "#{app.build_dir}/#{name}" + return "#{app.config.build_dir}/#{name}" end def build_multiple_sitemaps(pages) From 15efdded087fbf2475bc878e02aec1c2c480a3e9 Mon Sep 17 00:00:00 2001 From: Weston Ganger Date: Thu, 20 Aug 2020 12:37:25 -0700 Subject: [PATCH 3/3] Fix for undefined method `find_all' for Middleman::Sitemap::ResourceListContainer --- lib/middleman-sitemap/extension.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/middleman-sitemap/extension.rb b/lib/middleman-sitemap/extension.rb index ca4efa1..73f19b4 100644 --- a/lib/middleman-sitemap/extension.rb +++ b/lib/middleman-sitemap/extension.rb @@ -100,7 +100,7 @@ def encode(path) private def get_pages - app.sitemap.resources.find_all { |p| p.ext == ".html" && !p.data.ignore } + app.sitemap.resources.to_a.find_all { |p| p.ext == ".html" && !p.data.ignore } end end