complete the PR #88 by including only visible content entries

did committed Mar 08, 2017
commit 44e232c9f0811c1bd4897fe9cbdbdd69419d3041
Showing 3 changed files with 5 additions and 3 deletions
locomotive/steam/middlewares/sitemap.rb b/lib/locomotive/steam/middlewares/sitemap.rb +3 -1
@@ @@ -28,7 +28,7 @@ module Locomotive::Steam
def build_pages_to_xml
page_repository.published.map do |page|
- next if page.index? || page.not_found? || page.layout? || !page.listed?
+ next if page.index? || page.not_found? || page.layout? || (!page.templatized? && !page.listed?)
build_page_xml(page)
end.flatten.join.strip
@@ @@ -56,6 +56,8 @@ module Locomotive::Steam
return nil unless build_templatized_page_xml?(page, content_type, locale)
repositories.content_entry.with(content_type).all.map do |entry|
+ next unless entry.visible? # only visible content entry
+
_entry = Locomotive::Steam::Decorators::I18nDecorator.new(entry, locale)
next if _entry._label.blank? # should be translated
spec/fixtures/default/app/views/pages/songs/template.liquid.haml +1 -1
@@ @@ -15,4 +15,4 @@ handle: a-song-template
#content_type_size{content_type_size: "{{ page.content_type.size }}"}
#content_type_count{content_type_count: "{{ page.content_type.count }}"}
- {% endblock %}
\ No newline at end of file
+ {% endblock %}
spec/integration/server/sitemap_spec.rb +1 -1
@@ @@ -21,7 +21,7 @@ describe Locomotive::Steam::Server do
it 'checks if it looks valid' do
expect(Nokogiri::XML(subject).errors.empty?).to eq true
- expect(subject.scan(/<url>/).size).to eq 45
+ expect(subject.scan(/<url>/).size).to eq 27
expect(subject).to match("<loc>http://example.org/songs/song-number-2/band</loc>")
expect(subject).to match((<<-EOF
<url>