From 4bd927d5131ef2c21e51c4c384090b1e33999748 Mon Sep 17 00:00:00 2001 From: orbiter Date: Tue, 13 Jan 2009 22:04:38 +0000 Subject: [PATCH] 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 With about one billion metadata files (URL metadata) this extension makes the freeworld YaCy network to one of the probably largest metadata document provider for the semantic web! git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5490 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/IndexControlURLs_p.html | 27 ++++----- htroot/api/yacydoc.html | 46 +++++++++++++++ htroot/api/yacydoc.java | 101 +++++++++++++++++++++++++++++++++ htroot/api/yacydoc.xml | 26 +++++++++ 4 files changed, 184 insertions(+), 16 deletions(-) create mode 100644 htroot/api/yacydoc.html create mode 100644 htroot/api/yacydoc.java create mode 100644 htroot/api/yacydoc.xml 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]# - :: - - - - - - #(referrer)# - - :: - - #(/referrer)# - - - - -
URL String#[urlNormalform]#
Hash#[urlhash]#
Description#[urlDescr]#
Modified-Date#[moddate]#
Loaded-Date#[loaddate]#
Referrerunknown
Referrer#[url]#
Doctype#[doctype]#
Language#[language]#
Size#[size]#
Words#[wordCount]#

+ ::
+
+ + + These document details can be retrieved as XHTML+RDFa + document containg RDF annotations in Dublin Core vocabulary. + The XHTML+RDFa data format is both a XML content format and a HTML display format and is considered as an important Semantic Web content format. + The same content can also be retrieved as pure XML metadata 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 API wiki page. +
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 @@ + + + + + + + + + + #[dc_title]#</ + #%env/templates/metas.template%# + + + + +
+

#[dc_title]#

+ +
+
Author
#[dc_creator]#
+
Description
#[dc_description]#
+
Subject
#[dc_subject]#
+
Publisher
#[dc_publisher]#
+
Contributor
#[dc_contributor]#
+
Date
#[dc_date]#
+
Type
yacy:doctype:#[dc_type]#
+
Identifier
yacy:urlhash:#[dc_identifier]#
+
Sprache
#[dc_language]#
+ +
Load Date
#[yacy_loaddate]# +
Referrer Identifier
yacy:urlhash:#[yacy_referrer_hash]# +
Referrer URL
#[yacy_referrer_url]# +
Document size
#[yacy_size]# +
Number of Words
#[yacy_words]# + +
+
+
+ + 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; mc@yacy.net, 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 @@ + + ]> + + + + + #[dc_title]# + #[dc_creator]# + #[dc_contributor]# + #[dc_subject]# + #[dc_description]# + #[dc_publisher]# + #[dc_date]# + yacy:doctype:#[dc_type]# + yacy:urlhash:#[dc_identifier]# + #[dc_publisher]# + #[yacy_size]# + #[dc_language]# + #[yacy_loaddate]# + yacy:urlhash:#[yacy_referrer_hash]# + #[yacy_referrer_url]# + #[yacy_words]# +