topical media & game development
basic-xml-13-index.htm / htm
<?xml version="1.0" encoding="utf-8"?><!-- generator="wordpress/1.2-epsilon-RC1" -->
<rdf:RDF
xmlns="http://purl.org/rss/1.0/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:admin="http://webns.net/mvcb/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
>
<channel rdf:about="http://purl.org/net/morten/blog/rdf">
<title>Binary Relations</title>
<link>http://purl.org/net/morten/blog>
<description>Reflections on the web</description>
<dc:language>en</dc:language>
<dc:date>2004-05-21T22:40:27Z</dc:date>
<admin:generatorAgent rdf:resource="http://wordpress.org/?v=1.2-epsilon-RC1"/>
<sy:updatePeriod>daily</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
<sy:updateBase>2004-01-01T12:00+00:00</sy:updateBase>
<items>
<rdf:Seq>
<rdf:li rdf:resource="http://purl.org/net/morten/blog/archives/2004/05/21/foaf-output-from-wordpress"/>
<rdf:li rdf:resource="http://purl.org/net/morten/blog/archives/2004/05/21/wordpress-presentation-hacks"/>
<rdf:li rdf:resource="http://purl.org/net/morten/blog/archives/2004/05/20/wordpress-and-i18n"/>
<rdf:li rdf:resource="http://purl.org/net/morten/blog/archives/2004/05/20/improving-rss-output-from-wordpress"/>
<rdf:li rdf:resource="http://purl.org/net/morten/blog/archives/2004/05/20/yet-another-semweb-blogger"/>
</rdf:Seq>
</items>
</channel>
<item rdf:about="http://purl.org/net/morten/blog/archives/2004/05/21/foaf-output-from-wordpress">
<title>FOAF output from WordPress</title>
<link>http://purl.org/net/morten/blog/archives/2004/05/21/foaf-output-from-wordpress>
<dc:date>2004-05-21T21:35:49Z</dc:date>
<dc:creator>mortenf</dc:creator>
<foaf:maker>
<foaf:Person>
<foaf:name>Morten Frederiksen</foaf:name>
<foaf:nick>mortenf</foaf:nick>
<foaf:mbox_sha1sum>65b983bb397fb71849da910996741752ace8369b</foaf:mbox_sha1sum>
<foaf:weblog rdf:resource="http://purl.org/net/morten/blog"/>
</foaf:Person>
</foaf:maker>
<dc:subject>FOAF</dc:subject><foaf:topic rdf:parseType="Resource"><dc:title>FOAF</dc:title><foaf:page rdf:resource="http://www.foaf-project.org/"/></foaf:topic>
<dc:subject>WordPress</dc:subject><foaf:topic rdf:parseType="Resource"><dc:title>WordPress</dc:title><foaf:page rdf:resource="http://wordpress.org/"/></foaf:topic> <description>The one where the author "homepage" is extended and a FOAF profile document is created. </description>
<content:encoded><![CDATA[<p>A few days ago, <a href="http://www.livejournal.com/users/crschmidt/">Christopher Schmidt</a> mentioned <a href="http://www.livejournal.com/users/crschmidt/252710.html?thread=1153318#t1153318">in a comment</a> that he had been hacking on FOAF export for WordPress. He kindly let me take a look at his work, and in addition posted a <a href="http://rdfweb.org/pipermail/rdfweb-dev/2004-May/013286.html">message to rdfweb-dev</a>.</p>
<p>In short, he had created a set of dynamic stand-alone profile pages, one with HTML output and one with RDF/XML output using FOAF, in a single file, <code>/profile2.php</code>.</p>
<p>Seeing that, it dawned on me: WordPress already has a “profile” page for each of the authors, likely at <code>/archives/author/<login>/</code> (depending on the permalink structure defined) — and it even has a template name: <code>the_author_posts_link</code>. In its default incarnation it’s simply a list of the posts by that author, but turning it into a profile page by also showing the basic information and linked friends didn’t seem too hard.</p>
<p><a id="more-7"></a></p>
<p>So, first order of business is making the profile page “visible” by linking to it from the author name displayed with each post, by hacking in <code>/index.php</code>:</p>
<pre class="code"><?php _e("Filed under:"); ?> <?php the_category() ?> &#8212;
<?php the_author<ins>_posts_link</ins>(); ?>
@ <?php the_time() ?>
<?php edit_post_link(); ?></pre>
<p>Next up is actually displaying the profile information when desired — when an author is specified as the search criteria (in <code>/index.php</code>):</p>
<pre class="code"><div id="content">
<ins><?php if ('’ != posts) : foreach (post) : start_wp(); ?> </pre>
<p>This is not enough however, since the template <code>the_profile</code> isn’t defined yet. This is done in <code><a href="/morten/2004/05/wp-profile.php.txt">wp-profile.php.txt</a></code> (rename to <code>wp-profile.php</code> and place in root directory), which is an extended version of Christopher Schmidt’s original.</p>
<p>This new version now also includes relationships based on the <a href="http://gmpg.org/xfn/1">XFN</a> link <code>rel</code> definitions, most of which are also translated into terms from the <a href="http://vocab.org/relationship/">relationship vocabulary</a>. This last task provided for a few challenges.</p>
<p>First, as has been pointed out by <a href="http://www.ldodds.com/blog/">Leigh Dodds</a> in his post simply titled <a href="http://www.ldodds.com/blog/archives/000105.html">XFN</a>, the information expressed with XFN is incomplete as compared to FOAF and a few assumptions are needed, so if you intend to use this code, make sure you fill out the link fields in the link manager as follows, otherwise the FOAF output will be wrong:</p>
<ul>
<li>URI: Link to weblog of the person.</li>
<li>Link Name: Name of the weblog.</li>
<li>Short description: Name of the person.</li>
</ul>
<p>Second, the relationship vocabulary doesn’t have equivalent terms for the XFN relationships <code>muse</code>, <code>crush</code>, <code>date</code>, and <code>sweetheart</code>, so these are simply ignored in the translation process. Also, the relationship terms <code>childOf</code> and <code>parentOf</code> seems to be incorrectly or at least vaguely specified.</p>
<p>Next up is making sure that the actual FOAF output in RDF/XML is sent when requested. For this to work, a few extra lines at the top of <code>/index.php</code> are needed:</p>
<pre class="code"><?php
/* Don't remove this line. */
require('./wp-blog-header.php');
<ins>if ('’ != authordata = get_userdata(author): ?>
<link rel="meta” type="application/rdf+xml” title="FOAF” href="<?php print get_author_link(0, authordata->user_nicename); ?>?format=rdf” />
<?php endif; ?></ins></pre>
<p>Phew, that should do it, see for yourself on <a href="/morten/blog/?author_name=mortenf">my profile page</a>.</p>
<p>Next on the agenda might be integrating with a triple store…</p>]]></content:encoded>
</item>
<item rdf:about="http://purl.org/net/morten/blog/archives/2004/05/21/wordpress-presentation-hacks">
<title>WordPress presentation hacks</title>
<link>http://purl.org/net/morten/blog/archives/2004/05/21/wordpress-presentation-hacks>
<dc:date>2004-05-21T13:30:45Z</dc:date>
<dc:creator>mortenf</dc:creator>
<foaf:maker>
<foaf:Person>
<foaf:name>Morten Frederiksen</foaf:name>
<foaf:nick>mortenf</foaf:nick>
<foaf:mbox_sha1sum>65b983bb397fb71849da910996741752ace8369b</foaf:mbox_sha1sum>
<foaf:weblog rdf:resource="http://purl.org/net/morten/blog"/>
</foaf:Person>
</foaf:maker>
<dc:subject>WordPress</dc:subject><foaf:topic rdf:parseType="Resource"><dc:title>WordPress</dc:title><foaf:page rdf:resource="http://wordpress.org/"/></foaf:topic> <description>The one where next/previous links are added, excerpts are put to use, and categories are styled with icons. </description>
<content:encoded><![CDATA[<p>One thing missing from the default WordPress setup is the lack of previous/next links. Fixing this is not really a problem though, as WordPress includes a number of <a href="http://wordpress.org/docs/template/">template functions</a>, among which are <code>next_post</code> and <code>previous_post</code>. Both of these take care of all the necessary logic, so that the correct links are displayed, and only when necessary, i.e. only when displaying a single post. I decided to put the links at the top of the post page, next to the post metadata such as categories and author (in the file <code>/index.php</code>):</p>
<pre class="code"><div class="meta">
<ins> <span class="nav-prev"><?php previous_post(’&laquo; %’, ‘’); ?></span>
<span class="nav-next"><?php next_post(’% &raquo;’, ‘’); ?></span> </ins>
<?php _e("Filed under:"); ?> <?php the_category() ?> &#8212; <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(); ?>
</div></pre>
<p>Another thing that I thought would be nice, was only showing excerpts on pages with a large number of posts. This is also quite easy, thanks to the <code>get_excerpt</code> template function:</p>
<pre class="code"><ins><?php if(sizeof(cat){ print(’ post-category-’.pad = intval(date('w', thismonth, thisyear)))
pad = <del>7</del><ins>8</ins> - date(’w', mktime(0, 0 , 0, day, weekday[0]</code> (sunday) to the end of the list, after assignment to <code>weekday[6] = __('Saturday');
category->category_description))
category->cat_name.'</dc:title><foaf:page rdf:resource="'.
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.