Added sitemap support on node module.
code cleaning.
This commit is contained in:
@@ -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)
|
||||
|
||||
141
modules/sitemap/site/files/sitemap.xsl
Normal file
141
modules/sitemap/site/files/sitemap.xsl
Normal file
@@ -0,0 +1,141 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xsl:stylesheet version="2.0"
|
||||
xmlns:html="http://www.w3.org/TR/REC-html40"
|
||||
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
|
||||
<xsl:template match="/">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>XML Sitemap</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
#header {
|
||||
text-align: center;
|
||||
padding-top: 14px;
|
||||
padding-bottom: 29px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-weight: normal;
|
||||
font-size: 24px;
|
||||
line-height: 20px;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-weight: normal;
|
||||
font-size: 13px;
|
||||
color: #aaaaaa;
|
||||
line-height: 10px;
|
||||
}
|
||||
|
||||
#content {
|
||||
background: #f8f8f8;
|
||||
border-top: 1px solid #dddddd;
|
||||
padding-top: 50px;
|
||||
}
|
||||
|
||||
#content a:visited,
|
||||
#content tr:hover a:visited {
|
||||
color: #68009c;
|
||||
}
|
||||
|
||||
table {
|
||||
margin: 0 auto;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
tr#table-header:hover {
|
||||
background: none;
|
||||
}
|
||||
|
||||
tr:hover {
|
||||
background: #ebebeb;
|
||||
}
|
||||
|
||||
#content tr:hover a {
|
||||
color: #6e6e6e;
|
||||
}
|
||||
|
||||
td {
|
||||
color: #6e6e6e;
|
||||
font-size: 12px;
|
||||
border-bottom: 1px solid #dddddd;
|
||||
padding: 11px 5px 13px;
|
||||
}
|
||||
|
||||
th {
|
||||
color: #333333;
|
||||
font-size: 12px;
|
||||
border-bottom: 1px solid #dddddd;
|
||||
padding: 5px 50px 17px 5px;
|
||||
}
|
||||
|
||||
#footer {
|
||||
background: #f8f8f8;
|
||||
font-size: 13px;
|
||||
color: #aaaaaa;
|
||||
padding: 54px 0 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #2384c6;
|
||||
}
|
||||
a:hover {
|
||||
color: #6e6e6e;
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="header">
|
||||
<h1>XML Sitemap</h1>
|
||||
<h2>This is a XML Sitemap which is supposed to be processed by <a href="http://www.google.com">Google search engine</a>.</h2>
|
||||
</div>
|
||||
<div id="content">
|
||||
<table cellpadding="5" cellspacing="0">
|
||||
<tr id="table-header">
|
||||
<th>URL</th>
|
||||
<th>Priority</th>
|
||||
<th>Change Frequency</th>
|
||||
<th>LastChange (GMT)</th>
|
||||
</tr>
|
||||
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
|
||||
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
|
||||
<xsl:for-each select="sitemap:urlset/sitemap:url">
|
||||
<tr>
|
||||
<xsl:if test="position() mod 2 != 1">
|
||||
<xsl:attribute name="class">high</xsl:attribute>
|
||||
</xsl:if>
|
||||
<td>
|
||||
<xsl:variable name="itemURL">
|
||||
<xsl:value-of select="sitemap:loc"/>
|
||||
</xsl:variable>
|
||||
<a href="{$itemURL}">
|
||||
<xsl:value-of select="sitemap:loc"/>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<xsl:value-of select="concat(sitemap:priority*100,'%')"/>
|
||||
</td>
|
||||
<td>
|
||||
<xsl:value-of select="concat(translate(substring(sitemap:changefreq, 1, 1),concat($lower, $upper),concat($upper, $lower)),substring(sitemap:changefreq, 2))"/>
|
||||
</td>
|
||||
<td>
|
||||
<xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,5)))"/>
|
||||
</td>
|
||||
</tr>
|
||||
</xsl:for-each>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
Reference in New Issue
Block a user