Updated to sitemap protocol 0.9

Implementation of getPermalink on rss.php
master
pecesama 2008-11-08 07:18:35 +00:00
parent eb69c37903
commit 8330c4613b
4 changed files with 131 additions and 28 deletions

View File

@ -11,8 +11,12 @@ Juan del Rio [ http://elcaminante.net/ ]
= COPYRIGHT NOTICES =
This product includes code and libraries developed by third parties, which are governed by different licenses. These components, and their licenses, are listed below.
= XSLT template for sitemap =
Copyright (c) Arne Brachhold, http://www.arnebrachhold.de/
XSLT template for sitemap available under GNU General Public License.
= Services_JSON =
Copyright (c)Michal Migurski, Matt Knapp and Brett Stimmerman, http://mike.teczno.com/JSON/JSON.phps
Copyright (c) Michal Migurski, Matt Knapp and Brett Stimmerman, http://mike.teczno.com/JSON/JSON.phps
Services_JSON is available under BSD license.
= Archive based on code from: simple Tumblr API processor =

View File

@ -77,8 +77,8 @@ if(!defined('entry')) define('entry',true);
break;
}
$tit = util::trimString($tit);
$strEnd = ($conf->urlFriendly) ? "/" : "";
$url = $conf->urlGelato.($conf->urlFriendly ? "/post/" : "/index.php?post=").$register["id_post"].$strEnd;
$strEnd = ($conf->urlFriendly) ? "/" : "";
$url = $tumble->getPermalink($register["id_post"]);
$formatedDate = gmdate("r", strtotime($register["date"]) + util::transform_offset($conf->offsetTime));
?>
<item>

View File

@ -12,54 +12,46 @@ if(!defined('entry')) define('entry',true);
=========================== */
?>
<?php
require('entry.php');
global $conf, $tumble, $db;
// Code modified from the one at http://paste.ubuntu-nl.org/44548/
header("Content-type: text/xml; charset=utf-8");
require(dirname(__FILE__)."/config.php");
include("classes/configuration.class.php");
include("classes/gelato.class.php");
$tumble = new gelato();
$conf = new configuration();
header("Content-type: text/xml; charset=utf-8");
$isFeed = true;
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<?xml-stylesheet type=\"text/xsl\" href=\"".$conf->urlGelato."/sitemap.xsl\"?>\n";
$rs = $tumble->getPosts(1);
?>
<!-- generator="gelato CMS" -->
<urlset
xmlns="http://www.google.com/schemas/sitemap/0.84"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84
http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc><?php echo $conf->urlGelato;?></loc>
<priority>0.9</priority>
<loc><?php echo $conf->urlGelato;?></loc>
<?php
if ($tumble->contarRegistros()>0) {
if ($db->contarRegistros()>0) {
$register = mysql_fetch_array($rs);
$formatedDate = gmdate("Y-m-d", strtotime($register["date"]));
echo "<lastmod>".$formatedDate."</lastmod>";
echo "\n\t<lastmod>".$formatedDate."</lastmod>";
}
?>
<changefreq>hourly</changefreq>
<changefreq>hourly</changefreq>
<priority>0.9</priority>
</url>
<?php
$rs = $tumble->getPosts($tumble->getPostsNumber());
if ($tumble->contarRegistros()>0) {
while($register = mysql_fetch_array($rs)) {
$url = htmlspecialchars($conf->urlGelato."/index.php?post=".$register["id_post"]);
if ($db->contarRegistros()>0) {
while($register = mysql_fetch_array($rs)) {
$url = $tumble->getPermalink($register["id_post"]);
$formatedDate = gmdate("Y-m-d", strtotime($register["date"]));
?>
<url>
<loc><?php echo $url;?></loc>
<priority>0.7</priority>
<loc><?php echo $url;?></loc>
<lastmod><?php echo $formatedDate;?></lastmod>
<changefreq>daily</changefreq>
<changefreq>daily</changefreq>
<priority>0.7</priority>
</url>
<?php
}

107
sitemap.xsl Normal file
View File

@ -0,0 +1,107 @@
<?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;
}
#intro {
background-color:#CFEBF7;
border:1px #2580B2 solid;
padding:5px 13px 5px 13px;
margin:10px;
}
#intro p {
line-height: 16.8667px;
}
td {
font-size:11px;
}
th {
text-align:left;
padding-right:30px;
font-size:11px;
}
tr.high {
background-color:whitesmoke;
}
#footer {
padding:2px;
margin:10px;
font-size:8pt;
color:gray;
}
#footer a {
color:gray;
}
a {
color:black;
}
</style>
</head>
<body>
<h1>XML Sitemap</h1>
<div id="intro">
<p>
This is a XML Sitemap which is supposed to be processed by search engines like <a href="http://www.google.com/">Google</a>, <a href="http://search.msn.com/">MSN Search</a> and <a href="http://www.yahoo.com/">YAHOO</a>.<br/>
It was generated using the Tumblelogging-Software <a href="http://www.gelatocms.com/">Gelato CMS</a>.<br/>
You can find more information about XML sitemaps on <a href="http://sitemaps.org/">sitemaps.org</a> and Google's <a href="http://code.google.com/sm_thirdparty.html">list of sitemap programs</a>.
</p>
</div>
<div id="content">
<table cellpadding="5">
<tr style="border-bottom: 1px solid black;">
<th>URL</th>
<th>Priority</th>
<th>Change Frequency</th>
<th>LastChange</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>
<div id="footer">
gelato CMS :: PHP/MySQL Tumblelog Content Management System.
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>