Semantic weblog posts with Movable Type

·

A combination of two things - individual archive templates and dynamic pages - allow Movable Type to easily make RDF versions of every post. Now that Piggy Bank is around, this has become very useful: instead of just bookmarking a blog post, a visitor can add the RDF data to their Semantic Bank.

Here's how I got it to work:

  • In Movable Type's Templates menu, check 'Set Each Template's Build Options Separately' and press Save.
  • Create a new template, called 'Individual Entry RDF'.
  • Check 'Enable dynamic building for this template'.
  • Paste in the following template code, adjusting the <dc:creator> fields as necessary:
    
    <?xml version="1.0" encoding="UTF-8"?>
    <rdf:RDF
    	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
            xmlns:rss="http://purl.org/rss/1.0/"
    	xmlns:dc="http://purl.org/dc/elements/1.1/"
            xmlns:content="http://purl.org/rss/1.0/modules/content/"
    	xmlns:prism="http://prismstandard.org/namespaces/1.2/basic/"
    	xmlns:foaf="http://xmlns.com/foaf/0.1/">
    	<rss:item rdf:about="<$MTEntryPermalink$>">
    		<dc:date><$MTEntryDate format="%Y-%m-%dT%H:%M:%S"$></dc:date>
    		<dc:title><$MTEntryTitle encode_xml="1"$></dc:title>
    		<content:encoded><$MTEntryBody encode_xml="1"$><$MTEntryMore encode_xml="1"$></content:encoded>
    		<MTEntryCategories>
    		<dc:subject><$MTCategoryLabel$></dc:subject>
    		</MTEntryCategories>
    		<dc:creator>
    			<foaf:Person>
    				<foaf:nick><$MTEntryAuthor encode_xml="1"$></foaf:nick>
                                    <foaf:mbox rdf:resource="mailto:<$MTEntryAuthorEmail$>" />
    			</foaf:Person>
    		</dc:creator>
    		<prism:isPartOf rdf:resource="<$MTBlogURL$>"/>
    		<prism:publicationName><$MTBlogName$></prism:publicationName>
    	</rss:item>
    </rdf:RDF>
    
  • Press Save.
  • Back in the Templates menu, choose 'Edit Archive File Options'.
  • Create a new Template/Archive Type Association:
  • Archive Type: Individual
  • Template: Individual Entry RDF
  • Press Add.
  • In the 'Archive File Template' field for the newly added Individual Entry RDF, put
    .rdf
  • Press 'Save Changes'.
  • Follow the instructions for Enabling Dynamic Publishing...
  • The important steps are to create the 'templates_c' directory (chmod 777) then add this to .htaccess or a .conf file:
    RewriteEngine on
    RewriteCond %{HTTP_REQUEST} ^/archives/.*\.rdf$
    RewriteRule ^(.*)$ /mtview.php [L,QSA]
  • Restart Apache if necessary.
  • Back in the Templates menu, edit the original Individual Entry Archive template to add
    <link rel="alternate" type="application/rdf+xml" title="This entry in RDF format" href="<$MTBlogArchiveURL$><$MTEntryID pad="1"$>.rdf">
    into the <head> section.
  • Rebuild your site.