Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Superceeded] Rework sitemap.xml.gz view to fix it for plone.app.multilingual [master] #107

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ Fixes:

- Fixed html validation: element nav does not need a role attribute.
[maurits]
Fixes:

- Rework sitemap.xml.gz to allow filtering of sitemap elements; and supply such
a filter if LinguaPlone is installed.
[djowett]

- Fixed invalid html of social viewlet by moving the schema.org tags
to the body in a new viewlet ``plone.abovecontenttitle.socialtags``
Expand Down
13 changes: 12 additions & 1 deletion plone/app/layout/sitemap/configure.zcml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser">
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:zcml="http://namespaces.zope.org/zcml">

<browser:page
name="sitemap.xml.gz"
Expand All @@ -9,4 +10,14 @@
permission="zope2.Public"
/>

<configure zcml:condition="installed Products.LinguaPlone">
<browser:page
name="sitemap.xml.gz"
for="plone.app.layout.navigation.interfaces.INavigationRoot"
class=".sitemap.LinguaPloneSiteMapView"
permission="zope2.Public"
layer="Products.LinguaPlone.interfaces.ILinguaPloneProductLayer"
/>
</configure>

</configure>
27 changes: 25 additions & 2 deletions plone/app/layout/sitemap/sitemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ def objects(self):

query['is_default_page'] = True
default_page_modified = OOBTree()
for item in catalog.searchResults(query, Language='all'):

keywords = self.extra_search_parameters()

for item in catalog.searchResults(query, **keywords):
key = item.getURL().rsplit('/', 1)[0]
value = (item.modified.micros(), item.modified.ISO8601())
default_page_modified[key] = value
Expand All @@ -78,7 +81,8 @@ def objects(self):
}

query['is_default_page'] = False
for item in catalog.searchResults(query, Language='all'):

for item in catalog.searchResults(query, **keywords):
loc = item.getURL()
date = item.modified
# Comparison must be on GMT value
Expand Down Expand Up @@ -121,3 +125,22 @@ def __call__(self):
'application/octet-stream'
)
return self.generate()

def extra_search_parameters(self):
"""Allows extra filtering of the sitemap
for use (in particular) by LinguaPlone

:returns: a dictionary of keyword parameters to pass into
catalog.searchResults()
"""
return {}


class LinguaPloneSiteMapView(SiteMapView):
"""Overrides SiteMapView with patch for LinguaPlone
"""

def extra_search_parameters(self):
"""Work around LinguaPlone's catalog patch."""
# see https://github.com/plone/Products.LinguaPlone/blob/master/Products/LinguaPlone/catalog.py
return {'Language':'all'}