Index: rdfa3/web/themes/librefm/templates/header.tpl
===================================================================
--- rdfa3/web/themes/librefm/templates/header.tpl	(revision 441)
+++ rdfa3/web/themes/librefm/templates/header.tpl	(working copy)
@@ -1,26 +1,30 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  
-<head>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
+    "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
+<html
+	version="XHTML+RDFa 1.0"
+	xmlns="http://www.w3.org/1999/xhtml"
+	xmlns:bio="http://purl.org/vocab/bio/0.1/"
+	xmlns:dc="http://purl.org/dc/terms/"
+	xmlns:foaf="http://xmlns.com/foaf/0.1/"
+	xmlns:gob="http://purl.org/ontology/last-fm/"
+	xmlns:mo="http://purl.org/ontology/mo/"
+	xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
+	xmlns:sioc="http://rdfs.org/sioc/ns#"
+	xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
+	xml:lang="en">
+	
+<head profile="http://www.w3.org/1999/xhtml/vocab">
 	<title>Libre.fm &mdash; discover new music</title>
 	<link rel="stylesheet" href="http://turtle.libre.fm/reset-fonts-grids.css" type="text/css" />
 	<link rel="stylesheet" href="http://turtle.libre.fm/base.css" type="text/css" />
 	<link rel="stylesheet" href="http://turtle.libre.fm/librefm.css" type="text/css" />
 	<link rel="stylesheet" href="{$base_url}/themes/librefm/alpha.css" type="text/css" />
-  <link rel="icon" href="{$base_url}/favicon.ico" type="image/x-icon">
+	<link rel="icon" href="{$base_url}/favicon.ico" type="image/x-icon">
 	<script type="text/javascript" src="{$base_url}/js/player.js"></script>
 	<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
-<!--
-<rdf:RDF xmlns="http://web.resource.org/cc/"
-         xmlns:dc="http://purl.org/dc/elements/1.1/"
-         xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
-<license rdf:resource="http://creativecommons.org/licenses/by-sa/3.0/us/" />
-</Work>
-<License rdf:about="http://creativecommons.org/licenses/by-sa/3.0/us/">
-</License>
-</rdf:RDF>
--->
+	<link rel="license" rdf:resource="http://creativecommons.org/licenses/by-sa/3.0/us/" />
 </head>
+
 <body>
 <div id="doc2" class="yui-t7">
 	<div id="hd" role="navigation" class='vcard'><h1 class='fn org'><a href="{$base_url}" class='url'>Libre.fm</a></h1>
Index: rdfa3/web/themes/librefm/templates/profile.tpl
===================================================================
--- rdfa3/web/themes/librefm/templates/profile.tpl	(revision 441)
+++ rdfa3/web/themes/librefm/templates/profile.tpl	(working copy)
@@ -1,25 +1,31 @@
 {include file='header.tpl'}
 
-<h2>{$user}'{if $user|substr:-1 != 's'}s{/if} profile</h2>
-<dl class='user vcard'>
-    <dt class='fn'>
-        <span class='family-name'>{$fullname|utf8_encode}</span>
-        (<span class='nickname'>{$user}</span>)
-    </dt>
-    <dd class='avatar'>
-        <!-- Avatar placeholder  -->
-        <img src='{$avatar}' class='photo' alt="avatar" />
-    </dd>
-    <dd class='org'>
-        <a href='{$homepage}' rel='bookmark' class='url'>{$homepage}</a>
-    </dd>
-    <dd class='adr'>
-        <span class='locality'>{$location}</span>
-    </dd>
-    <dd class='bio'>
-        <p>{$bio}</p>
-    </dd>
+<h2 property="dc:title">{$user}'{if $user|substr:-1 != 's'}s{/if} profile</h2>
+<dl about="{$id}" typeof="foaf:Agent" class="user vcard">
+	<dt>
+		<span class="fn" property="foaf:name">{$fullname|utf8_encode}</span>
+		<span rel="foaf:holdsAccount" rev="sioc:account_of">
+			<span about="{$acctid}" typeof="sioc:User">
+				(<span class="nickname" property="foaf:accountName">{$user}</span>)
+				<span rel="foaf:accountServiceHomepage" resource="{$base_url}"></span>
+				<span rel="foaf:homepage" rev="foaf:primaryTopic" resource=""></span>
+			</span>
+		</span>
+	</dt>
+	<dd class='avatar'>
+		<!-- Avatar placeholder  -->
+		<img rel="foaf:depiction" src="{$avatar}" class="photo" alt="avatar" />
+	</dd>
+	<dd>
+		<a href="{$homepage}" rel="foaf:homepage" rev="foaf:primaryTopic" class="url">{$homepage}</a>
+	</dd>
+	<dd rel="foaf:based_near">
+		<span class="label" property="rdfs:label">{$location}</span>
+	</dd>
+	<dd class="note" property="bio:olb">{$bio}</dd>
 </dl>
+
+
 {if $nowplaying|@count > 0}
 <h3>Now Playing:</h3>
 <dl class='now-playing'>
@@ -32,21 +38,29 @@
 {/if}
 
 <h3>Latest {$scrobbles|@count} Gobbles:</h3>
+
+<ul id="scrobbles" class="listcloud" about="{$id}" rev="gob:user">
 {section name=i loop=$scrobbles}
-    {if $smarty.capture.artist_last <> $scrobbles[i].artist}
-        {if $scrobbles[i] != $scrobbles[0]} 
-        </dl>
-        {/if}
-        <dl class='gobbles'>
-            <dt class='artist'>
-                <a href="{$scrobbles[i].artisturl}">{$scrobbles[i].artist}</a>
-            </dt>
-    {/if}
-      <dd class='gobble'><span class='track-name'><a href="{$scrobbles[i].trackurl}">{$scrobbles[i].track|stripslashes}</a></span><small>{$scrobbles[i].timehuman}</small></dd>
-      {capture name=artist_last}{$scrobbles[i].artist}{/capture}
+
+	<li about="{$scrobbles[i].id}" typeof="gob:ScrobbleEvent" rel="gob:track_played">
+		<dl about="{$scrobbles[i].id_track}" typeof="mo:Track">
+			<dt rel="foaf:maker">
+				<a about="{$scrobbles[i].id_artist}" typeof="mo:MusicArtist" property="foaf:name" rel="foaf:page"
+					href="{$scrobbles[i].artisturl}"
+					>{$scrobbles[i].artist}</a>
+			</dt>
+			<dd>
+				<a property="dc:title" rel="foaf:page" href="{$scrobbles[i].trackurl}">{$scrobbles[i].track}</a>
+				<small about="{$scrobbles[i].id}" property="dc:date" content="{$scrobbles[i].timeiso}" datatype="xsd:dateTime">{$scrobbles[i].timehuman}</small>
+			</dd>
+		</dl>
+	</li>
+	
 {/section}
-    </dl>
+</ul>
+   
 </div></div>
+
     <div class="yui-u" id="sidebar">
     <div style="padding: 10px;">
       <h3>User's favorite artists</h3>
Index: rdfa3/web/profile.php
===================================================================
--- rdfa3/web/profile.php	(revision 441)
+++ rdfa3/web/profile.php	(working copy)
@@ -34,6 +34,8 @@
 $user = new User($_GET['user']);
 
 if(isset($user->name)) {
+	$smarty->assign("id", $user->id);
+	$smarty->assign("acctid", $user->acctid);
 	$smarty->assign('user', $user->name);
 	$smarty->assign('email', $user->email);
 	$smarty->assign('fullname', $user->fullname);
Index: rdfa3/web/data/User.php
===================================================================
--- rdfa3/web/data/User.php	(revision 441)
+++ rdfa3/web/data/User.php	(working copy)
@@ -19,10 +19,10 @@
 
 */
 
-
 require_once($install_path . '/database.php');
 require_once($install_path . '/data/sanitize.php');
 require_once($install_path . '/utils/human-time.php');
+require_once($install_path . '/utils/linkeddata.php');
 require_once($install_path . '/data/Server.php');
 
 /**
@@ -35,6 +35,7 @@
 
 
 	public $name, $email, $fullname, $bio, $location, $homepage, $error, $userlevel;
+	public $id, $acctid;
 
 	/**
 	 * User constructor
@@ -42,9 +43,14 @@
 	 * @param string $name The name of the user to load
 	 */
 	function __construct($name) {
+
+		global $base_url;
+		$base = preg_replace('#/$#', '', $base_url);
+
 		global $mdb2;
 		$res = $mdb2->query('SELECT * FROM Users WHERE '
 			. 'username = ' . $mdb2->quote($name, 'text'));
+
 		if($res->numRows()) {
 			$row = sanitize($res->fetchRow(MDB2_FETCHMODE_ASSOC));
 			$this->name	  = $row['username'];
@@ -54,7 +60,12 @@
 			$this->bio	   = $row['bio'];
 			$this->location  = $row['location'];
 			$this->userlevel = $row['userlevel'];
+			$this->id = $row["webid"];
+			$this->acctid = $base.'/user/' . urlencode($this->name) . '#acct';
 		}
+		
+		if (! strlen($this->id))
+			$this->id = $base.'/user/' . urlencode($this->name) . '#me';
 	}
 
 	/**
@@ -66,9 +77,6 @@
 	function getScrobbles($number) {
 		$data = Server::getRecentScrobbles($number, $this->name);
 		if(!isset($data)) { return array(); }
-		foreach($data as &$i) {
-  			$i['timehuman'] = human_timestamp($i['time']);
-		}
 		return $data;
 	} 

Index: rdfa3/web/data/Server.php
===================================================================
--- rdfa3/web/data/Server.php	(revision 441)
+++ rdfa3/web/data/Server.php	(working copy)
@@ -24,6 +24,7 @@
 require_once($install_path . '/data/Track.php');
 require_once($install_path . '/data/User.php');
 require_once($install_path . "/data/sanitize.php");
+require_once($install_path . '/utils/linkeddata.php');
 
 /**
  * Provides access to server-wide data
@@ -42,9 +43,9 @@
 		global $mdb2;
 
 		if($username) {
-			$res = $mdb2->query('SELECT username, artist, track, album, time FROM Scrobbles WHERE rating<>"S" AND username = ' . $mdb2->quote($username, "text") . ' ORDER BY time DESC LIMIT ' . $mdb2->quote($number, "integer"));
+			$res = $mdb2->query('SELECT username, artist, track, album, time, mbid FROM Scrobbles WHERE rating<>"S" AND username = ' . $mdb2->quote($username, "text") . ' ORDER BY time DESC LIMIT ' . $mdb2->quote($number, "integer"));
 		} else {
-			$res = $mdb2->query('SELECT username, artist, track, album, time FROM Scrobbles WHERE rating<>"S" ORDER BY time DESC LIMIT ' . $mdb2->quote($number, "integer"));
+			$res = $mdb2->query('SELECT username, artist, track, album, time, mbid FROM Scrobbles WHERE rating<>"S" ORDER BY time DESC LIMIT ' . $mdb2->quote($number, "integer"));
 		}
 
 		if(PEAR::isError($res)) {
@@ -54,9 +55,18 @@
 		$data = $res->fetchAll(MDB2_FETCHMODE_ASSOC);
 		foreach($data as $i) {
 			$row = sanitize($i);
+			
 			$row["userurl"] = Server::getUserURL($row["username"]);
 			$row["artisturl"] = Server::getArtistURL($row["artist"]);
 			$row["trackurl"] = Server::getTrackURL($row['artist'], $row['album'], $row['track']);
+
+  			$row['timehuman'] = human_timestamp($row['time']);
+			$row["timeiso"]   = date('c', (int)$row['time']);
+			
+			$row['id']        = identifierScrobbleEvent($row['username'], $row['artist'], $row['track'], $row['time'], $row['mbid']);
+			$row['id_artist'] = identifierArtist($row['username'], $row['artist'], $row['track'], $row['time'], $row['mbid']);
+			$row['id_track']  = identifierTrack($row['username'], $row['artist'], $row['track'], $row['time'], $row['mbid']);
+
 			$result[] = $row;
 		}
 

