Sitemap Plugin (was Google Sitemap Plugin)

Creating and modifying plugins.
Boris

Sitemap Plugin (was Google Sitemap Plugin)

Post by Boris »

I wrote a plugin to create a sitemap for the Google-Crawler. It's far from perfect, but I works for me and does everything I expect from it.

Download it via spartacus or from CVS and please report all problems with the plugin. Comments are welcome too.
The queries are tested with mysql and some (but not all) with postgres and sqlite. If they work, please report too. :)

Developers: Feel free to use this for every purpose you like.

--
EDIT1: Linked to CVS
EDIT2: Updated download-advise
Last edited by Boris on Fri Nov 17, 2006 3:51 pm, edited 3 times in total.
mreys
Posts: 3
Joined: Mon Jun 13, 2005 12:11 pm
Location: Brussels
Contact:

I have just done the same...

Post by mreys »

But much simpler, as I don't see the requirement for having each and every link.

I have noticed with my plugin that the plugin does not register the entry I am saving (as it is not in the database yet).

I haven't tried yours, but have you checked ?

Mike
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: I have just done the same...

Post by garvinhicking »

This plugin should work with every saved entry; of course it will not update the sitemap if a draft entry is saved only.

On a sidenote, I've just committed the plugin as event_google_sitemap, thank you Boris! Do you have or want a CVS account to maintain your plugin? Your code looks well thought of, so I'd love if you can maintain your script there. Like for example it is not yet compatible with Serendipity's 0.9 changes in the Permalink generation.

For example:

Code: Select all

$url = serendipity_rewriteURL(PATH_CATEGORIES . '/' . serendipity_makePermalink(PERM_CATEGORIES, array('id' => $category['id'], 'title' => $category['name'])));
needs to be changed to

Code: Select all

$url = serendipity_makePermalink(PERM_CATEGORIES, array('id' => $category['id'], 'title' => $category['name']), 'category');
thanks a lot for your contribution!

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Boris

Re: I have just done the same...

Post by Boris »

mreys wrote:But much simpler, as I don't see the requirement for having each and every link.
Googles Sitemap-Generator adds every link you have in your logs, so
IMO the sitemap should contain every link the Googlebot is able to crawl.
mreys wrote:I have noticed with my plugin that the plugin does not register the entry I am saving (as it is not in the database yet).

I haven't tried yours, but have you checked ?
As Garvin said: it generates a new sitemap on every "save" and "publish"-hook. But the queries only fetch published entries.
garvinhicking wrote:Do you have or want a CVS account to maintain your plugin?
That would make maintaining easier for both of us. :)
mreys
Posts: 3
Joined: Mon Jun 13, 2005 12:11 pm
Location: Brussels
Contact:

system() call not reliable! that caused the hickup

Post by mreys »

I used the system call the gzip my file...
Problem is, if gzipped file already exists, it is not overwritten. Because of the way I was testing I thought that the file did not get updated!
backend_publish was the right way of doing things! (entry update should then work as well, as soon as it gets tested).

Forgive myself for looking immediately at the serendipity code, not at the basic system() code.

I'm not a php programmer, and I was relying on php too much. Anyway, my code was not portable for windows as the gzip command probably doesn't exist. Just found out (thanks to the code above) that php contains a gzip functionality (if properly compiled?)
Hathor
Regular
Posts: 118
Joined: Tue Mar 22, 2005 11:48 pm

Post by Hathor »

Um, I'm new to Google Sitemaps. Do I need to go to Google and generate one before using this plug-in, or will this plug-in do that?

Where it says " URL for Google pingback (%s is replaced with sitemap URL)", does that mean I need to replace it with something, or it will do that automatically? I have no idea what to replace %s with, because I don't already have a sitemap.

I guess I just need really simple instructions on this, sorry. :)
gwilsonmail
Regular
Posts: 146
Joined: Tue Jul 12, 2005 9:12 pm
Location: Ottawa, Canada
Contact:

Post by gwilsonmail »

it's automatic.
when you add a new article it will update the map and tell google.

You might also want to go to google and register your site so it gets indexed by the usual google mechanisms.
gw
Hathor
Regular
Posts: 118
Joined: Tue Mar 22, 2005 11:48 pm

Post by Hathor »

So just by installing the plug-in and setting it to send updates, I'm all set up?

(My site is already indexed in Google, but that's important advice for anyone not aware they need to do that. :) )
gwilsonmail
Regular
Posts: 146
Joined: Tue Jul 12, 2005 9:12 pm
Location: Ottawa, Canada
Contact:

Post by gwilsonmail »

Install and save a new entry (must be published not draft).

It's that simple. :D
gw
Hathor
Regular
Posts: 118
Joined: Tue Mar 22, 2005 11:48 pm

Post by Hathor »

Wow, that's too cool. :D
gwilsonmail
Regular
Posts: 146
Joined: Tue Jul 12, 2005 9:12 pm
Location: Ottawa, Canada
Contact:

Post by gwilsonmail »

If you want to check the sitemap generated is actually working you should go here - http://www.google.com/webmasters/sitemaps/login

Log in using either your gmail email account or your google account id (for adsense). You'll be presented with a page where you can manually ask google to come and check out your sitemap.

After entering your root URL, it might take several hours before you are indexed. When you return you'll find the result and hopefull all is well.

This should take away the "faith" aspect of this wonderful plugin and substitute "living proof" that it works.
gw
gwilsonmail
Regular
Posts: 146
Joined: Tue Jul 12, 2005 9:12 pm
Location: Ottawa, Canada
Contact:

Post by gwilsonmail »

Following my own advice ... Google read my sitemap.gz file successfully!

But it's important that you include the name of the sitemap at the end of the URL you enter.

So enter http://www.yoursitename.com/blog/sitemap.gz

not http://www.yoursitename.com/blog/
gw
Hathor
Regular
Posts: 118
Joined: Tue Mar 22, 2005 11:48 pm

Post by Hathor »

This thing works great on one of my S9 sites. But on the other, it just won't generate the sitemap file. Today I finally got an error message (instead of it just hanging up in the "saving your entry" stage):
Warning: fopen(/home/bluemus/public_html//sitemap.gz): failed to open stream: Permission denied in /home/bluemus/public_html/plugins/serendipity_event_google_sitemap/serendipity_event_google_sitemap.php on line 313
Could not open the outfile for writing.
I did see that my host had changed permissions on the main directory (where S9 sits) so I changed them back to 755. But it still isn't creating that sitemap. I also got 1.4 of this plug in from CVS, and that didn't help either.

Any suggestions?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

This definitely sounded like a permission thing! Do you still get the same error? Please check the permissions, if the host maybe changed it back?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Hathor
Regular
Posts: 118
Joined: Tue Mar 22, 2005 11:48 pm

Post by Hathor »

The permissions setting on public_html (where S9 sits) is still 755, as I set it yesterday. I just published a new entry, and it did what it's been doing ever since I installed the plug-in. It sits on this page:
Serendipity is now saving your entry, creating trackbacks and performing possible XML-RPC calls. This may take a while..
indefinitely. It never gives me the list of URL's it successfully pinged, nor does it report updating the sitemap. The entry is published successfully, but the backend page just hangs up at that point.
Post Reply