We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 8be6f9e2 authored by tobyink's avatar tobyink

RDFa for artists pages - beginnings.

parent 11b74d96
......@@ -29,6 +29,7 @@ require_once('data/TagCloud.php');
$artist = new Artist($_GET['artist']);
$smarty->assign("name", $artist->name);
$smarty->assign("id", $artist->id);
$smarty->assign("bio_summary", $artist->bio_summary);
$aTagCloud = TagCloud::GenerateTagCloud('Scrobbles', 'artist');
......
......@@ -23,6 +23,7 @@ require_once($install_path . '/database.php');
require_once($install_path . '/data/Artist.php');
require_once($install_path . '/data/Track.php');
require_once($install_path . "/resolve-external.php");
require_once($install_path . '/utils/linkeddata.php');
/**
* Represents album data
......@@ -33,6 +34,7 @@ require_once($install_path . "/resolve-external.php");
class Album {
public $name, $artist_name, $mbid, $releasedate, $image;
public $id;
/**
* Album constructor
......@@ -55,6 +57,8 @@ class Album {
$this->releasedate = $row['releasedate'];
$this->image = resolve_external_url($row['image']);
$this->id = identifierAlbum(null, $this->artist_name, null, $this->name, null, null, null, $this->mbid);
// this hack brought to you by mattl
//if ($row['image'] == ""){
......
......@@ -25,6 +25,7 @@ require_once($install_path . "/data/sanitize.php");
require_once($install_path . "/data/Album.php");
require_once($install_path . "/data/Track.php");
require_once($install_path . "/data/Server.php");
require_once($install_path . '/utils/linkeddata.php');
/**
* Represents artist data
......@@ -36,6 +37,7 @@ class Artist {
public $name, $mbid, $streamable, $bio_content, $bio_published, $bio_summary, $image_small, $image_medium, $image_large;
public $id;
/**
* Artist constructor
......@@ -62,6 +64,8 @@ class Artist {
$this->image_small = $row["image_small"];
$this->image_medium = $row["image_medium"];
$this->image_large = $row["image_large"];
$this->id = identifierArtist(null, $this->name, null, null, null, null, $this->mbid, null);
}
}
......
......@@ -108,10 +108,10 @@ class Server {
$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['artist_mbid'], $row['album_mbid']);
$row['id_artist'] = identifierArtist($row['username'], $row['artist'], $row['track'], $row['time'], $row['mbid'], $row['artist_mbid'], $row['album_mbid']);
$row['id_track'] = identifierTrack($row['username'], $row['artist'], $row['track'], $row['time'], $row['mbid'], $row['artist_mbid'], $row['album_mbid']);
$row['id_album'] = identifierAlbum($row['username'], $row['artist'], $row['track'], $row['time'], $row['mbid'], $row['artist_mbid'], $row['album_mbid']);
$row['id'] = identifierScrobbleEvent($row['username'], $row['artist'], $row['track'], $row['album'], $row['time'], $row['mbid'], $row['artist_mbid'], $row['album_mbid']);
$row['id_artist'] = identifierArtist($row['username'], $row['artist'], $row['track'], $row['album'], $row['time'], $row['mbid'], $row['artist_mbid'], $row['album_mbid']);
$row['id_track'] = identifierTrack($row['username'], $row['artist'], $row['track'], $row['album'], $row['time'], $row['mbid'], $row['artist_mbid'], $row['album_mbid']);
$row['id_album'] = identifierAlbum($row['username'], $row['artist'], $row['track'], $row['album'], $row['time'], $row['mbid'], $row['artist_mbid'], $row['album_mbid']);
if (! $row['album_image'])
$row['album_image'] = '/i/qm50.png';
......
{include file='header.tpl'}
<h2>{$name}</h2>
<div about="{$id}" typeof="mo:MusicalArtist">
<div id="bio">
{$bio_summary}
</div>
<h2 property="foaf:name" rel="foaf:page" rev="foaf:primaryTopic" resource="">{$name}</h2>
<ul id="albums" class="listcloud">
<div id="bio" property="bio:olb" datatype="">{$bio_summary}</div>
<ul id="albums" class="listcloud" rel="foaf:made" rev="foaf:maker">
{section name=i loop=$albums}
<li>
<li about="{$albums[i]->id}">
<dl>
<dt><a href="{$albums[i]->getURL()}">
<img src="{$albums[i]->getAlbumArt()}" alt="{$albums[i]->name}" width="160" /></a></dt>
......
<?php
function identifierScrobbleEvent ($username, $artist, $track, $time, $mbid=NULL, $ambid=NULL, $lmbid=NULL)
function identifierScrobbleEvent ($username, $artist, $track, $album, $time, $mbid=NULL, $ambid=NULL, $lmbid=NULL)
{
global $base_url;
if ($username && $artist && $track && $time)
return null;
$microhash = substr(md5($artist . '//' . $track), 0, 4);
return $base_url . sprintf('/user/%s#%s.%s', urlencode($username), urlencode($time), urlencode($microhash));
}
function identifierTrack ($username, $artist, $track, $time, $mbid=NULL, $ambid=NULL, $lmbid=NULL)
function identifierTrack ($username, $artist, $track, $album, $time, $mbid=NULL, $ambid=NULL, $lmbid=NULL)
{
if (!empty($mbid))
{
......@@ -15,33 +19,37 @@ function identifierTrack ($username, $artist, $track, $time, $mbid=NULL, $ambid=
}
else
{
return identifierScrobbleEvent($username, $artist, $track, $time, $mbid, $ambid, $lmbid) . '.track';
return identifierScrobbleEvent($username, $artist, $track, $album, $time, $mbid, $ambid, $lmbid) . '.track';
}
}
function identifierArtist ($username, $artist, $track, $time, $mbid=NULL, $ambid=NULL, $lmbid=NULL)
function identifierArtist ($username, $artist, $track, $album, $time, $mbid=NULL, $ambid=NULL, $lmbid=NULL)
{
# Eventually look up MBIDs from Artists table?
if (!empty($ambid))
{
return sprintf('http://dbtune.org/musicbrainz/resource/artist/%s', strtolower($ambid));
}
else
{
return identifierScrobbleEvent($username, $artist, $track, $time, $mbid, $ambid, $lmbid) . '.artist';
}
$u = identifierScrobbleEvent($username, $artist, $track, $album, $time, $mbid, $ambid, $lmbid) . '.artist';
if ($u) return $u;
global $base_url;
return $base_url . sprintf('/artist/%s#artist', urlencode($artist));
}
function identifierAlbum ($username, $artist, $track, $time, $mbid=NULL, $ambid=NULL, $lmbid=NULL)
function identifierAlbum ($username, $artist, $track, $album, $time, $mbid=NULL, $ambid=NULL, $lmbid=NULL)
{
# Eventually look up MBIDs from Artists table?
if (!empty($lmbid))
{
return sprintf('http://dbtune.org/musicbrainz/resource/record/%s', strtolower($lmbid));
}
else
{
return identifierScrobbleEvent($username, $artist, $track, $time, $mbid, $ambid, $lmbid) . '.album';
}
$u = identifierScrobbleEvent($username, $artist, $track, $album, $time, $mbid, $ambid, $lmbid) . '.album';
if ($u) return $u;
global $base_url;
return $base_url . sprintf('/artist/%s/album/%s#this', urlencode($artist), urlencode($album));
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment