Browse Source

Updated to sitemap protocol 0.9

pecesama 15 years ago
parent
commit
8330c4613b
4 changed files with 131 additions and 28 deletions
  1. 5 1
      notice.txt
  2. 2 2
      rss.php
  3. 17 25
      sitemap.php
  4. 107 0
      sitemap.xsl

+ 5 - 1
notice.txt View File

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

+ 2 - 2
rss.php View File

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

+ 17 - 25
sitemap.php View File

@@ -12,54 +12,46 @@ if(!defined('entry')) define('entry',true);
12 12
   =========================== */
13 13
 ?>
14 14
 <?php
15
+	require('entry.php');	
16
+	global $conf, $tumble, $db;
17
+	
15 18
 	// Code modified from the one at http://paste.ubuntu-nl.org/44548/
16
-	header("Content-type: text/xml; charset=utf-8");	
17
-
18
-	require(dirname(__FILE__)."/config.php");
19
-	include("classes/configuration.class.php");
20
-	include("classes/gelato.class.php");
21
-	$tumble = new gelato();
22
-	$conf = new configuration();	
19
+	header("Content-type: text/xml; charset=utf-8");
23 20
 	$isFeed = true;
24 21
 	
25 22
 	echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
23
+	echo "<?xml-stylesheet type=\"text/xsl\" href=\"".$conf->urlGelato."/sitemap.xsl\"?>\n";
26 24
 	
27 25
 	$rs = $tumble->getPosts(1);	
28 26
 ?>
29 27
 <!-- generator="gelato CMS" -->
30
-
31
-<urlset 
32
-		xmlns="http://www.google.com/schemas/sitemap/0.84"
33
-        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
34
-        xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84
35
-        	http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">
36
-	
28
+<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">	
37 29
 	<url>
38
-		<loc><?php echo $conf->urlGelato;?></loc>
39
-        <priority>0.9</priority>		
30
+		<loc><?php echo $conf->urlGelato;?></loc>        		
40 31
 <?php
41
-		if ($tumble->contarRegistros()>0) {
32
+		if ($db->contarRegistros()>0) {
42 33
 			$register = mysql_fetch_array($rs);
43 34
 			$formatedDate = gmdate("Y-m-d", strtotime($register["date"]));
44
-			echo "<lastmod>".$formatedDate."</lastmod>";
35
+			echo "\n\t<lastmod>".$formatedDate."</lastmod>";
45 36
 		}
46 37
 ?>
47
-		<changefreq>hourly</changefreq>        
38
+		<changefreq>hourly</changefreq>
39
+        <priority>0.9</priority>
48 40
 	</url>
49 41
 
50 42
 
51 43
 <?php	
52 44
 	$rs = $tumble->getPosts($tumble->getPostsNumber());
53
-	if ($tumble->contarRegistros()>0) {
54
-		while($register = mysql_fetch_array($rs)) {
55
-			$url = htmlspecialchars($conf->urlGelato."/index.php?post=".$register["id_post"]);
45
+	if ($db->contarRegistros()>0) {
46
+		while($register = mysql_fetch_array($rs)) {			
47
+			$url = $tumble->getPermalink($register["id_post"]);
56 48
 			$formatedDate = gmdate("Y-m-d", strtotime($register["date"]));
57 49
 ?>
58 50
 	<url>
59
-		<loc><?php echo $url;?></loc>
60
-        <priority>0.7</priority>
51
+		<loc><?php echo $url;?></loc>        
61 52
 		<lastmod><?php echo $formatedDate;?></lastmod>
62
-        <changefreq>daily</changefreq>        
53
+        <changefreq>daily</changefreq>
54
+        <priority>0.7</priority>
63 55
 	</url>
64 56
 <?php
65 57
 		}

+ 107 - 0
sitemap.xsl View File

@@ -0,0 +1,107 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<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">
3
+	<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
4
+	<xsl:template match="/">
5
+		<html xmlns="http://www.w3.org/1999/xhtml">
6
+			<head>
7
+				<title>XML Sitemap</title>
8
+				<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
9
+				<style type="text/css">
10
+					body {
11
+						font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana;
12
+						font-size:13px;
13
+					}
14
+					
15
+					#intro {
16
+						background-color:#CFEBF7;
17
+						border:1px #2580B2 solid;
18
+						padding:5px 13px 5px 13px;
19
+						margin:10px;
20
+					}
21
+					
22
+					#intro p {
23
+						line-height:	16.8667px;
24
+					}
25
+					
26
+					td {
27
+						font-size:11px;
28
+					}
29
+					
30
+					th {
31
+						text-align:left;
32
+						padding-right:30px;
33
+						font-size:11px;
34
+					}
35
+					
36
+					tr.high {
37
+						background-color:whitesmoke;
38
+					}
39
+					
40
+					#footer {
41
+						padding:2px;
42
+						margin:10px;
43
+						font-size:8pt;
44
+						color:gray;
45
+					}
46
+					
47
+					#footer a {
48
+						color:gray;
49
+					}
50
+					
51
+					a {
52
+						color:black;
53
+					}
54
+				</style>
55
+			</head>
56
+			<body>
57
+				<h1>XML Sitemap</h1>
58
+				<div id="intro">
59
+					<p>
60
+						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/>
61
+						It was generated using the Tumblelogging-Software <a href="http://www.gelatocms.com/">Gelato CMS</a>.<br/>
62
+						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>.
63
+					</p>
64
+				</div>
65
+				<div id="content">
66
+					<table cellpadding="5">
67
+						<tr style="border-bottom: 1px solid black;">
68
+							<th>URL</th>
69
+							<th>Priority</th>
70
+							<th>Change Frequency</th>
71
+							<th>LastChange</th>
72
+						</tr>
73
+						<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
74
+						<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
75
+						<xsl:for-each select="sitemap:urlset/sitemap:url">
76
+							<tr>
77
+								<xsl:if test="position() mod 2 != 1">
78
+									<xsl:attribute name="class">high</xsl:attribute>
79
+								</xsl:if>
80
+								<td>
81
+									<xsl:variable name="itemURL">
82
+										<xsl:value-of select="sitemap:loc"/>
83
+									</xsl:variable>
84
+									<a href="{$itemURL}">
85
+										<xsl:value-of select="sitemap:loc"/>
86
+									</a>
87
+								</td>
88
+								<td>
89
+									<xsl:value-of select="concat(sitemap:priority*100,'%')"/>
90
+								</td>
91
+								<td>
92
+									<xsl:value-of select="concat(translate(substring(sitemap:changefreq, 1, 1),concat($lower, $upper),concat($upper, $lower)),substring(sitemap:changefreq, 2))"/>
93
+								</td>
94
+								<td>
95
+									<xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,5)))"/>
96
+								</td>
97
+							</tr>
98
+						</xsl:for-each>
99
+					</table>
100
+				</div>
101
+				<div id="footer">
102
+					gelato CMS :: PHP/MySQL Tumblelog Content Management System.
103
+				</div>
104
+			</body>
105
+		</html>
106
+	</xsl:template>
107
+</xsl:stylesheet>