On Freitag, 28. September 2007, Sean O'Connor wrote:
Dan, thanks, I'll look at semantic mediawiki.
SMW has means of using Dublin Core and any other
vocabulary, but it
does not embedd the annotations into the XHTML-header (as I know some
webpages do with DC).
Markus, that would be a problem for me. Part of the reason I need DC
on my site is to interact with applications such as Zotero [1],
allowing researchers to grab bibliography/citation information from
the page.
It would be possible to make certain properties available in the XHTML header,
but this is clearly not useful for all data SMW collects (this would make the
header really large). So the best solution would probably be an extension to
SMW which "knows" the DC properties and treats them in a special way. We are
planning to put together the infrastructure for adding predefined properties
in extensions more easily, but an ad hoc solution can be done with the
current version already. There might be some performance issues though, since
Meta-tags added to wiki-output are not cached. Should be OK for smaller
wikis.
But anyway, here is a sketch of the solution. Install SMW1.0alpha(SVN) and add
the following to your LocalSettings.php:
$wgHooks['BeforePageDisplay'][] = 'metaTest';
function metaTest(&$out) {
if ($out->isArticle()) {
$page = Title::newFromText($out->getPageTitle());
$dccreator = Title::newFromText('dccreator', SMW_NS_PROPERTY);
$res = smwfGetStore()->getPropertyValues($page, $dccreator);
foreach ($res as $creator) {
$out->addMeta('DC.Creator', $creator->getShortHTMLText());
}
}
return true;
}
Then, whenever you use a property called "dccreator" in your wiki (the name is
hardcoded above, feel free to change it), a metatag will appear in the
according XHTML page. A test page for instance could
contain "[[Dccreator::John Doe]]" (no page for Property:Dccreator is needed
if you want dccreators to be given by pages in the wiki).
Of course, this method is just a 15min hack -- there might be encoding issues
in some cases; the datatype of the property does not matter (use what you
think is cool); there are no proper URIs, only plain text strings here (of
course this could be changed, if your tool can handle URIs); and there is
this performance thingy of querying the store on every page view (if there
would be more properties, a general condition for checking through all of
those would be handy, e.g. one could do this only when the page is in a
certain category). I am also unsure whether the above method of finding the
current page title is really right, but it worked for me so far.
-- Markus
--
Markus Krötzsch
Institut AIFB, Universät Karlsruhe (TH), 76128 Karlsruhe
phone +49 (0)721 608 7362 fax +49 (0)721 608 5998
mak(a)aifb.uni-karlsruhe.de www
http://korrekt.org