Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

the Semantic Web moves in! - added two new api files for document metadata: - added a XHTML+RDFa html file shows the document metadata in a format that presents the data for rendering and for metadata retrieval. This is a typical document format for a semantic web data structure. the used RDF vocabulary is Dublin Core - added a xml file that shows the same data as pure DC metadata - integrated the API into the existing IndexControlURLs interface

orbiter4bd927d5131e
diff --git a/htroot/IndexControlURLs_p.html b/htroot/IndexControlURLs_p.html
index 93c58f003..de09abb93 100644
--- a/htroot/IndexControlURLs_p.html
+++ b/htroot/IndexControlURLs_p.html
@@ -112,22 +112,17 @@
#(genUrlProfile)#
::No entry found for URL-hash #[urlhash]#
- ::<table>
- <tr><td class="small">URL String</td><td class="tt"><a href="#[urlNormalform]#">#[urlNormalform]#</a></td></tr>
- <tr><td class="small">Hash</td><td class="tt">#[urlhash]#</td></tr>
- <tr><td class="small">Description</td><td class="tt">#[urlDescr]#</td></tr>
- <tr><td class="small">Modified-Date</td><td class="tt">#[moddate]#</td></tr>
- <tr><td class="small">Loaded-Date</td><td class="tt">#[loaddate]#</td></tr>
- #(referrer)#
- <tr><td class="small">Referrer</td><td class="tt">unknown</td></tr>
- ::
- <tr><td class="small">Referrer</td><td class="tt"><a href="IndexControlURLs_p.html?urlhashsearch=&urlhash=#[hash]#">#[url]#</a></td></tr>
- #(/referrer)#
- <tr><td class="small">Doctype</td><td class="tt">#[doctype]#</td></tr>
- <tr><td class="small">Language</td><td class="tt">#[language]#</td></tr>
- <tr><td class="small">Size</td><td class="tt">#[size]#</td></tr>
- <tr><td class="small">Words</td><td class="tt">#[wordCount]#</td></tr>
- </table><br />
+ ::<iframe src="/api/yacydoc.html?urlhash=#[urlhash]#" width="100%" height="360" frameborder="0" scrolling="no"></iframe><br />
+ <div id="api">
+ <a href="/api/yacydoc.html?urlhash=#[urlhash]#">
+ <img src="env/grafics/api.png"></a>
+ <span>These document details can be retrieved as <a href="http://www.w3.org/TR/xhtml-rdfa-primer/">XHTML+RDFa</a>
+ document containg <a href="http://www.w3.org/RDF/">RDF</a> annotations in <a href="http://dublincore.org/">Dublin Core</a> vocabulary.
+ The XHTML+RDFa data format is both a XML content format and a HTML display format and is considered as an important <a href="http://www.w3.org/2001/sw/">Semantic Web</a> content format.
+ The same content can also be retrieved as pure <a href="/api/yacydoc.xml?urlhash=#[urlhash]#">XML metadata</a> with DC tag name vocabulary.
+ Click the API icon to see an example call to the search rss API.
+ To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de/wiki/index.php/Dev:API">API wiki page</a>.</span>
+ </div>
<form action="IndexControlURLs_p.html" method="post" enctype="multipart/form-data">
<input type="hidden" name="keystring" value="" />
<input type="hidden" name="keyhash" value="" />
diff --git a/htroot/api/yacydoc.html b/htroot/api/yacydoc.html
new file mode 100644
index 000000000..e644b0c62
--- /dev/null
+++ b/htroot/api/yacydoc.html
@@ -0,0 +1,46 @@
+<?xml version="1.0" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<!--
+this is a XHTML+RDFa file. It contains RDF annotations with dublin core properties
+you can validate it with http://validator.w3.org/
+-->
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:foaf="http://xmlns.com/foaf/0.1/">
+
+ <head profile="http://www.w3.org/2003/g/data-view">
+ <link rel="transformation" href="http://www-sop.inria.fr/acacia/soft/RDFa2RDFXML.xsl"/>
+ <title>#[dc_title]#</</title>
+ #%env/templates/metas.template%#
+ </head>
+
+ <body>
+ <form name="yacydoc" method="post" action="yacydoc.html" enctype="multipart/form-data" accept-charset="UTF-8">
+ <fieldset>
+ <h1 property="dc:Title">#[dc_title]#</h1>
+
+ <dl>
+ <dt>Author</dt><dd property="dc:Creator">#[dc_creator]#</dd>
+ <dt>Description</dt><dd property="dc:Description">#[dc_description]#</dd>
+ <dt>Subject</dt><dd property="dc:Subject">#[dc_subject]#</dd>
+ <dt>Publisher</dt><dd property="dc:Publisher">#[dc_publisher]#</dd>
+ <dt>Contributor</dt><dd property="dc:Contributor">#[dc_contributor]#</dd>
+ <dt>Date</dt><dd property="dc:Date">#[dc_date]#</dd>
+ <dt>Type</dt><dd property="dc:Type">yacy:doctype:#[dc_type]#</dd>
+ <dt>Identifier</dt><dd property="dc:Identifier">yacy:urlhash:#[dc_identifier]#</dd>
+ <dt>Sprache</dt><dd property="dc:Language">#[dc_language]#</dd>
+
+ <dt>Load Date</dt><dd property="yacy:loaddate">#[yacy_loaddate]#</dt>
+ <dt>Referrer Identifier</dt><dd property="yacy:referrer.hash">yacy:urlhash:#[yacy_referrer_hash]#</dt>
+ <dt>Referrer URL</dt><dd property="yacy:referrer.url">#[yacy_referrer_url]#</dt>
+ <dt>Document size</dt><dd property="yacy:size">#[yacy_size]#</dt>
+ <dt>Number of Words</dt><dd property="yacy:words">#[yacy_words]#</dt>
+
+ </dl>
+ </fieldset>
+ </form>
+ </body>
+</html>
diff --git a/htroot/api/yacydoc.java b/htroot/api/yacydoc.java
new file mode 100644
index 000000000..341c4ab7a
--- /dev/null
+++ b/htroot/api/yacydoc.java
@@ -0,0 +1,101 @@
+// yacydoc.java
+// -----------------------
+// (C) 2009 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany
+// first published 12.01.2009 on http://yacy.net
+//
+// This is a part of YaCy, a peer-to-peer based web search engine
+//
+// $LastChangedDate: 2007-11-14 01:15:28 +0000 (Mi, 14 Nov 2007) $
+// $LastChangedRevision: 4216 $
+// $LastChangedBy: orbiter $
+//
+// LICENSE
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import java.net.MalformedURLException;
+
+import de.anomic.http.httpRequestHeader;
+import de.anomic.index.indexURLReference;
+import de.anomic.plasma.plasmaSwitchboard;
+import de.anomic.server.serverObjects;
+import de.anomic.server.serverSwitch;
+import de.anomic.yacy.yacySeedDB;
+import de.anomic.yacy.yacyURL;
+
+public class yacydoc {
+
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
+ // return variable that accumulates replacements
+ final plasmaSwitchboard sb = (plasmaSwitchboard) env;
+
+ final serverObjects prop = new serverObjects();
+ prop.put("dc_title", "");
+ prop.put("dc_creator", "");
+ prop.put("dc_description", "");
+ prop.put("dc_subject", "");
+ prop.put("dc_publisher", "");
+ prop.put("dc_contributor", "");
+ prop.put("dc_date", "");
+ prop.put("dc_type", "");
+ prop.put("dc_identifier", "");
+ prop.put("dc_language", "");
+
+ if (post == null) return prop;
+
+ String urlstring = post.get("urlstring", "").trim();
+ String urlhash = post.get("urlhash", "").trim();
+ if (urlstring.length() == 0 && urlhash.length() == 0) return prop;
+
+ if (urlstring.length() > 0 && urlhash.length() == 0) {
+ try {
+ urlhash = (new yacyURL(urlstring, null)).hash();
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ }
+ if (urlhash == null || urlhash.length() == 0) return prop;
+
+ final indexURLReference entry = sb.webIndex.getURL(urlhash, null, 0);
+ if (entry == null) return prop;
+
+ final indexURLReference.Components comp = entry.comp();
+ if (comp.url() == null) {
+ return prop;
+ }
+ final indexURLReference le = ((entry.referrerHash() == null) || (entry.referrerHash().length() != yacySeedDB.commonHashLength)) ? null : sb.webIndex.getURL(entry.referrerHash(), null, 0);
+
+ prop.putHTML("dc_title", comp.dc_title());
+ prop.putHTML("dc_creator", comp.dc_creator());
+ prop.putHTML("dc_description", "");
+ prop.putHTML("dc_subject", comp.dc_subject());
+ prop.putHTML("dc_publisher", comp.url().toNormalform(false, true));
+ prop.putHTML("dc_contributor", "");
+ prop.putHTML("dc_date", entry.moddate().toString());
+ prop.put("dc_type", entry.doctype());
+ prop.putHTML("dc_identifier", urlhash);
+ prop.putHTML("dc_language", entry.language());
+
+ prop.putHTML("yacy_loaddate", entry.loaddate().toString());
+ prop.putHTML("yacy_referrer_hash", (le == null) ? "" : le.hash());
+ prop.putHTML("yacy_referrer_url", (le == null) ? "" : le.comp().url().toNormalform(false, true));
+ prop.put("yacy_size", entry.size());
+ prop.put("yacy_words",entry.wordCount());
+
+ // return rewrite properties
+ return prop;
+ }
+
+}
diff --git a/htroot/api/yacydoc.xml b/htroot/api/yacydoc.xml
new file mode 100644
index 000000000..fbdbfb299
--- /dev/null
+++ b/htroot/api/yacydoc.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE metadata [ <!ELEMENT metadata (#PCDATA)> ]>
+
+<!--
+this is a xml file with embedded dublin core properties
+you can validate it with http://www.stg.brown.edu/service/xmlvalid/
+-->
+
+<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:yacy="http://yacy.net/">
+ <dc:Title LANG="#[dc_language]#">#[dc_title]#</dc:Title>
+ <dc:Creator>#[dc_creator]#</dc:Creator>
+ <dc:Contributor>#[dc_contributor]#</dc:Contributor>
+ <dc:Subject SCHEME="item-list">#[dc_subject]#</dc:Subject>
+ <dc:Description LANG="#[dc_language]#">#[dc_description]#</dc:Description>
+ <dc:Publisher.URL>#[dc_publisher]#</dc:Publisher.URL>
+ <dc:Date>#[dc_date]#</dc:Date>
+ <dc:Type>yacy:doctype:#[dc_type]#</dc:Type>
+ <dc:Identifier SCHEME="yacy:urlhash">yacy:urlhash:#[dc_identifier]#</dc:Identifier>
+ <dc:Identifier SCHEME="URL">#[dc_publisher]#</dc:Identifier>
+ <dc:Format.Extent>#[yacy_size]#</dc:Format.Extent>
+ <dc:Language SCHEME="ISO639-2">#[dc_language]#</dc:Language>
+ <yacy:loaddate>#[yacy_loaddate]#</yacy:loaddate>
+ <yacy:referrer.hash>yacy:urlhash:#[yacy_referrer_hash]#</yacy:referrer.hash>
+ <yacy:referrer.url>#[yacy_referrer_url]#</yacy:referrer.url>
+ <yacy:words>#[yacy_words]#</yacy:words>
+</metadata>