doap:store, a collaborative DOAP projects directory
I’ve just completed a first release of doap:store, a user-driven directory of DOAP projects.
The goal is to build a database of computing projects that have a DOAP description - as does the Semantic Web Apps and Demo service, but not only SW related here - , thanks to Ping The Semantic Web service. Thus, there is no need to register, projects will be fetched from PTSW, that will get them eitheir by pings, or even better, thanks to Semantic Radar plugin for Firefox when people browse the Web.
Then, doap:store provides a common search engine and browsing interface for these decentralized project description, while authors keep control over their data. Data is updated each time PTSW has a new ping for it (in the future, PTSW should store new pings only if the document has changed, so updated will be made only for real document updates).
From the technical side, it’s using 3store for the storage and of course SPARQL for the queries.
I hope this kind of tool can help to outreach DOAP for developers, and SW in general, as thanks to Semantic Radar, anyone can contribute to build this directory.
SPARQL in command line
Just discovered roquet while talking on #sioc about SPARQL in command line.
Available on Debian within rasqal-utils packages, and really simple to use, eg:
roqet -r json -e "SELECT ?s ?p ?o WHERE { ?s ?p ?o }" -s http://apassant.net/blog/feed/rdf
Ping PTSW service from your weblog
While Semantic Radar allows to automatically send pings to Ping The Semantic Web service when you naturally browse the web, another way to help the service to get real-time information is to automatically sends ping to it when you create Semantic Web documents.
TalkDigger already does it, and I just realized that it was really easy to do with any blog engine, as most of them have native or plugin support for pings. So, you just need to add http://rpc.pingthesemanticweb.com/ URL in the ping services URLs, and as PTSW uses auto-discovery links to find Semantic Web data from HTML documents, if you use a <link rel="alternate" ...> in your header to point to a RDF feed or SIOC export, it will be added to PTSW documents list.
I don’t know if weblogs generally ping services when a new comment is made, but it might be worth hacking it so that if you site is SIOC-enabled each comment will be saved in PTSW as soon as it is created. One more motivation to (re)write SIOC exporter for DotClear2.
Fil RSS 1.0 avec Dotclear2
DC2 installé depuis quelques jourt, et damned, pas de flux RSS 1.0 ! Premier plongeon dans ses entrailles (bien pensées, pour ce que j’en ai vu) pour l’ajouter. Le patch complet est disponible ici et l’explication pas à pas ci-dessous, les liens vers des fichiers correspondant aux fichiers modifiés (à partir de ceux de la 2.0beta2[1]).
Concernant l’écriture du flux en lui-même, il s’agit d’un "banal" template à réaliser - en se basant sur les exports RSS 2.0 et Atom existants afin de récupérer les noms de variables. Les 2 templates rdf.xml et rdf-comments.xml sont à placer dans le répertoire inc/public/default-templates/. Je n’ai pas ajouté de feuille de style pour afficher ces flux en HTML comme c’est le cas pour RSS 2.0 et Atom, notamment puisque Firefox2 s’en charge très bien - et un peu par flemme aussi, il faut bien l’avouer.
La seconde partie consiste à faire accepter à DC un flux nommé ‘rdf’ et non pas ‘rss2′ ou ‘atom’, et se fait en 2 étapes:
- Dans
inc/public/class.dc.template.php, il faut modifier les fonctionsBlogFeedURL(l.542) etCategoryFeedURL(l.637) de façon à pouvoir passer l’argument ‘rdf’ aux fonctions de template qui vont générer les liens de syndication, sans qu’il soit remplacé par ‘rss2′, la valeur par défaut; - Dans
inc/public/lib.urlhandlers.php, il faut maintenant gérer les URL correspondantes (l.346 et l.353) et en profiter pour définir un mime-typeapplication/rdf+xml(l.400) pour le flux en question.
Ces étapes sont à répéter pour les flux par tags, mais tout ce fait cette fois-ci dans le fichier plugins/metadata/_public.php.
Troisième partie, intégrer ce flux dans les templates. Dans les fichiers category.html, post.html et tag.html de votre template (ou du template par défaut si vous voulez ensuite que la modification s’applique à tous vos thèmes qui ne surchargent pas ces fichiers), remplacer respectivement dans les appels de fonctions de template CategoryFeedURL, BlogFeedURL et TagFeedURL l’argument type="rss2" par type = "rdf". Ne modifiez pas ceux des entêtes mais ajoutez la ligne suivante dans _head.html:
<link rel="alternate" type="application/rdf+xml" title="RSS 1.0" href="http://apassant.net/blog/feed/rdf" />
Dernière étape, facultative, modifier les liens de syndication du widget dedié. Pour cela, dans widgets/_defauls_widgets.php, ajoutez RDF aux options l.42, et dans widgets/_widgets_functions.php, modifiez la fonction subscribe pour authoriser ‘rdf’, avec le bon mime-type. D’ailleurs ici, ca serait pas mal que le flux choisi soit récupéré par défaut dans les différentes fonctions XXFeedURL, pour éviter d’avoir à changer les templates - ou alors j’ai loupé un truc[2] ?
Et voila, vous avez maintenant un DC2 avec un flux RSS1.0 ‘de base’, accessible via l’URI /feed/rdf que vous pourrez enrichir avec FOAF par ex, ou d’autres vocabulaires RDF (en attendant un plugin dedié Web Sémantique
Notes
[1] La 2.0beta3 vient de sortir pendant que je finissais ce billet.
[2] Et tant qu’à faire, un flux RDF en natif dans DC2, ça serait également sympa.
Migration réussie
Ce blog tourne maintenant sous Dotclear2.
Migration sans soucis (a part un cafouillage en migrant du répertoire temporaire vers la prod), tags conservés, et une rewrite rule temporaire pour conserver les anciennes URLs en attendant de voir (ou pas) comment indiquer à DC de conserver l’ancien schéma d’adresses pour les nouveaux billets.
Le flux RSS1.0 est également disponible à la même adresse qu’auparavant. DC2 ne fournit qu’un flux Atom ou RSS2, la méthode de template est très intuitive et remettre un flux RSS1.0 - donc RDF - a été très rapide. Je fais la partie pour les commentaires, et je mets ça en ligne.
Edit 01h10: Je viens de voir que mes billets ont été réagrégés sur planete web-sémantique (puisque nouvelle URL, chose à laquelle je n’avais pas pensé), desolé pour ceux qui suivent le fil de la planète et qui vont ravoir les billets en double !
RDF nodes as Python dictionaries
I was recently looking for some code to wrap RDF nodes to Python objects / dictionnaries - something like activerdf in ruby - in order to manipulate RDF nodes easilly, and then use Jinja template engine to render SW documents in HTML.
I didn’t find anything[1] so I wrote a tiny module that does the job, using redland. By finding all (SPO) statements with the given node as subject, it creates a Python dictionnary with predicates as keys, and lists of object nodes as values (using a list even if there’s only one node in order to get something generic). And then, recurse - avoiding infinite loops - for each object.
Regarding literals, they are stored in 3 ways in the dictionnary:
- First, using the "literals" key, to store the literal itself (with its datatype, lang and value);
- Then, using the "strings" key, to store only literal values;
- Finally, for each lang, using the "strings_lang" key, to store literal values for a given language.
It will also save the URI of resource nodes.
Eg with a DOAP file coverted to a python dict. Then, I can use something like node['doap_description'][0]['strings_fr'][0] to get the description of the project in french.
Finally, I just have to pass the dictionary to a Jinja template, and get my DOAP profile rendered as HTML. Result can be seen there.
The module, template and conversion script are available here.
