Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 113 lines (102 sloc) 3.62 KB
#!/usr/bin/env python
Messy little hack to print a bunch of twitter avatars for dev8d
attendees as rdfa xhtml using the triples that are crawled from
semantic media wiki and elsewhere.
import rdflib
wiki = rdflib.Namespace("")
foaf = rdflib.Namespace("")
owl = rdflib.Namespace("")
def attendee(graph, person):
A hack to use owl:sameAs assertions created during crawling
to determine if a given user on semantictweet is a dev8d attendee
for other_uri in graph.subjects(predicate=owl.sameAs, object=person):
if '' in other_uri:
return other_uri
return False
def people(graph):
for person, avatar in graph.subject_objects(predicate=foaf.img):
dev8d_uri = attendee(graph, person)
if not dev8d_uri:
name = graph.value(subject=person,
nick = graph.value(subject=person, predicate=foaf.nick)
twitter = '' % nick
yield dev8d_uri, person, name, twitter, avatar
def print_avatars_html(graph):
print \
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "">
<html xmlns=""
<title>dev8d attendees</title>
<style type="text/css">
body {
text-align: center;
font-family: Verdana;
margin-left: 7%;
margin-right: 7%;
#about {
margin: 0px auto;
border: thin solid gray;
background-color: #ccffcc;
width: 60%;
padding: 10px;
<div id="banner">
<h1><a href="">dev8d</a> attendees on
<a href="">twitter</a></h1>
<a href=";uri=">
<img alt="rdfa" title="get turtle for this page" src="" />
<br />
<br />
<div id="avatars">
for dev8d_uri, person, name, twitter, avatar in people(graph):
chunk = \
<span about="%s" typeof="foaf:Person">
<a rel="foaf:homepage" href="%s">
<img resource="%s" rev="foaf:img" title="%s"
alt="%s" width="80" src="%s" />
<span rel="owl:sameAs" resource="%s"></span>
""" % (person, twitter, person, name, name, avatar, dev8d_uri)
print chunk.encode('utf-8')
print \
<br />
<br />
<p id="about">
This page is <a
every four hours based on information stored in the <a
href="">dev8d semantic media wiki</a>
and social graph information in
<a href="">semantictweeet</a>.
If you want to show up here add your twitter id to your
user profile, see <a href="">dfflanders</a>
profile for an example.
<br />
if __name__ == '__main__':
graph = rdflib.ConjunctiveGraph('Sleepycat')'store')