Recent Topics

1 Jan 30, 2005 05:04    

EdB asked me to post this hack here, since I just finished monkeying my way through it. Basically, Technorati has this new [url=http://www.technorati.com/tag/]tag system[/url] that lets you add a link in your posts to organize your post on Technorati by subject. Technorati also can just read your RSS feeds, and automatically tag your post by the category name of the post.

But, they only recognize the <dc:subject> style subject/category tags. Problem is, I noticed that three of our feeds (Atom, RSS 0.92, and RSS 2.0) don't include that style of tag (or doesn't have one at all). So, here's how to modify your feeds to include <dc:subject> tags for Technorati compliance.

All the files are in your xmlsrv folder.

Open atom.php and change:

<feed version="0.3" xml:lang="<?php $Blog->disp( 'locale', 'xml' ) ?>" xmlns="http://purl.org/atom/ns#">

To:

<feed version="0.3" xml:lang="<?php $Blog->disp( 'locale', 'xml' ) ?>" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">

Then add the following anywhere between your <entry> tags:

<dc:subject><?php $Item->main_category( 'xml' ) ?></dc:subject>

Then open rss2.php and replace:

<?php $Item->categories( false, '<category domain="main">', '</category>', '<category domain="alt">', '</category>', '<category domain="external">', '</category>', "\n", 'xml' ) ?>

With:

<dc:subject><?php $Item->main_category( 'xml' ) ?></dc:subject>

Then open rss.php and change:

<rss version="0.92">

To:

<rss version="0.92" xmlns:dc="http://purl.org/dc/elements/1.1/">

Then add the following anywhere between the <item> tags:

<dc:subject><?php $Item->main_category( 'xml' ) ?></dc:subject>

And you're done. Your feed is technorati compliant :) You don't need to alter rdf.php (RSS 1.0) because it already uses the dc:subject tags.

2 Jan 30, 2005 05:34

Thanks! When I followed the other thread I gave up on .92 because the validator choked. Not knowing all that much about it I figured 'oh well!'. Now I'll go do my .92 feed to make all of them serve up a dc:thingamajig tag.

3 Jan 30, 2005 08:58

No problem. If you could've seen me pulling my hair out trying to figure out how to modify those things, you wouldn't feel bad at all :P

4 Jul 05, 2005 10:26

I've tried implementing this and have the following validation error for the Atom feed; it does validate for the RSSv2 feed.


This feed does not validate.

    *

      line 17, column 16: Undefined entry element: dc:subject (5 occurrences) [help]

                <dc:subject>Open Source</dc:subject>
               ^

Source: http://press.teleinteractive.net/xmlsrv/atom.php?blog=2

   1. <?xml version="1.0" encoding="utf-8"?><feed version="0.3" xml:lang="en-US" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
   2. <title>The TeleInterActive Lifestyle</title>
   3. <link rel="alternate" type="text/html" href="http://press.teleinteractive.net/tia_life" />
   4. <tagline>The TeleInterActive Lifestyle is all about living and supporting access to information on the go.</tagline>
   5. <generator url="http://b2evolution.net/" version="0.9.0.11">b2evolution</generator>
   6. <modified>2005-07-01T19:00:28Z</modified>
   7. <entry>
   8. <title type="text/plain" mode="xml">Why Open Source</title>
   9. <link rel="alternate" type="text/html" href="http://press.teleinteractive.net/tia_life/2005/07/01/why_open_source" />
  10. <author>
  11. <name>Joseph A. di Paolantonio</name>
  12. <url>http://press.teleinteractive.net</url>
  13. </author>
  14. <id>http://press.teleinteractive.net/tia_life/2005/07/01/why_open_source</id>
  15. <issued>2005-07-01T16:51:13Z</issued>
  16. <modified>2005-07-01T18:58:51Z</modified>
  17. <dc:subject>Open Source</dc:subject>

As you can see in line 01, we did add the XML namespace URI for the dublin core elements, but the validator doesn't seem to recognize it for Atom. It does for RSSv2.

Any ideas? Thanks in advance.

5 Jul 05, 2005 22:42

You know... I'm almost positive I validated all the feeds after I figured all this out. But you're right, it's not valid now, and I'll be damned if I can figure out why.

I'll get back to you. I'm running this by some of the feed validator expert guys.

6 Jul 05, 2005 23:23

FYI, I just checked with a couple people who did the same change to their Atom feed, and it WAS valid a few months back. For whatever reason, it's no longer valid, but we're looking into how to fix it.

7 Jul 06, 2005 03:31

Hmm, since the same thing is valid in RSSv2, maybe its a validator problem.

Thank you for the quick response.

8 Jul 06, 2005 08:13

Do try different Validators as they do sometimes vary in their results.

9 Jul 10, 2005 16:21

Actually, I just heard back from the feed validator guys. Apparently, this was a bug in the validator. The feed should be valid now, and mine is showing that way again.

10 Jul 10, 2005 16:48

Yes, our's too, except for cross-posting, where b2evo surrounds the main blog's main category with em markup tags. Have to determine how to stop that. ;)

Thank you, wrabbit.

Oddly though, technorati doesn't seem to be showing our posts. Even searching on their site results in the last posts being from about six months ago, even though we are getting back a positive acknowledgement when we post.

11 Sep 15, 2006 05:18

How can this be implemented in 1.8.1?


Form is loading...