Added sitemap support on node module.

code cleaning.
This commit is contained in:
2017-02-10 13:34:49 +01:00
parent 1c902db377
commit ccf1040513
7 changed files with 322 additions and 62 deletions

View File

@@ -49,13 +49,7 @@ feature -- Access: router
feature -- Hook
sitemap (a_response: CMS_RESPONSE): CMS_SITEMAP
local
l_user: detachable CMS_USER
-- lnk: FEED_LINK
-- nb: NATURAL_32
-- s: STRING_32
do
l_user := Void -- Public access for the feed!
create Result.make (create {DATE_TIME}.make_now_utc)
if attached a_response.api.hooks.subscribers ({CMS_SITEMAP_HOOK}) as lst then
across
@@ -66,44 +60,6 @@ feature -- Hook
end
end
end
-- create l_feed.make ("CMS Recent changes")
-- l_feed.set_date (create {DATE_TIME}.make_now_utc)
-- nb := a_size
-- across
-- l_changes as ic
-- until
-- nb = 0
-- loop
-- ch := ic.item
-- create l_feed_item.make (ch.link.title)
-- l_feed_item.set_date (ch.date)
--
-- create s.make_empty
-- if attached ch.information as l_information then
-- s.append (l_information)
-- end
-- if attached ch.summary as sum then
-- if not s.is_empty then
-- s.append ("%N%N")
-- end
-- s.append (sum)
-- end
-- l_feed_item.set_description (s)
-- if attached ch.categories as lst then
-- across
-- lst as cats_ic
-- loop
-- l_feed_item.set_category (cats_ic.item)
-- end
-- end
-- create lnk.make (a_response.absolute_url (ch.link.location, Void))
-- l_feed_item.links.force (lnk, "")
-- l_feed.extend (l_feed_item)
-- nb := nb - 1
-- end
-- l_feed.sort
-- Result := l_feed
end
feature -- Handler
@@ -111,13 +67,12 @@ feature -- Handler
handle_sitemp_xml (api: CMS_API; req: WSF_REQUEST; res: WSF_RESPONSE)
local
r: CMS_RESPONSE
-- htdate: HTTP_DATE
mesg: CMS_CUSTOM_RESPONSE_MESSAGE
l_xml: STRING
l_cache: CMS_FILE_STRING_8_CACHE
do
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
create l_cache.make (api.files_location.extended ("sitemap.xml"))
create l_cache.make (api.files_location.extended ("modules").extended ("sitemap").extended ("sitemap.xml"))
if
l_cache.exists and then
not l_cache.expired (Void, 7*24*60*60) and then
@@ -130,17 +85,17 @@ feature -- Handler
elseif attached sitemap (r) as l_sitemap then
create l_xml.make (1_024)
l_xml.append ("<?xml version=%"1.0%" encoding=%"utf-8%"?>%N")
l_xml.append ("<?xml-stylesheet type=%"text/xsl%" href=%"http://geyssans.fr/wp-content/plugins/google-sitemap-plugin/sitemap.xsl%"?>%N")
l_xml.append ("<?xml-stylesheet type=%"text/xsl%" href=%"" + r.absolute_url ("/module/" + name + "/files/sitemap.xsl", Void) + "%"?>%N")
l_xml.append ("<urlset xmlns=%"http://www.sitemaps.org/schemas/sitemap/0.9%">%N")
across
l_sitemap as ic
loop
l_xml.append ("<url>%N")
l_xml.append (" <loc>" + r.absolute_url (ic.item.link.location, Void) + "</loc>%N")
l_xml.append (" <lastmod>"); append_date_output (ic.item.date, l_xml); l_xml.append ("</lastmod>%N")
l_xml.append (" <changefreq>" + ic.item.change_frequency + "</changefreq>%N")
l_xml.append (" <priority>" + ic.item.priority.out + "</priority>%N")
l_xml.append ("</url>%N")
l_xml.append (" <url>%N")
l_xml.append (" <loc>" + r.absolute_url (ic.item.link.location, Void) + "</loc>%N")
l_xml.append (" <lastmod>"); append_date_output (ic.item.date, l_xml); l_xml.append ("</lastmod>%N")
l_xml.append (" <changefreq>" + ic.item.change_frequency + "</changefreq>%N")
l_xml.append (" <priority>" + ic.item.priority.out + "</priority>%N")
l_xml.append (" </url>%N")
end
l_xml.append ("</urlset>%N")
l_cache.put (l_xml)