View source with formatted comments or as raw
    1/*  Part of ClioPatria SeRQL and SPARQL server
    2
    3    Author:        Jan Wielemaker
    4    E-mail:        J.Wielemaker@cs.vu.nl
    5    WWW:           http://www.swi-prolog.org
    6    Copyright (C): 2010, University of Amsterdam,
    7		   VU University Amsterdam
    8
    9    This program is free software; you can redistribute it and/or
   10    modify it under the terms of the GNU General Public License
   11    as published by the Free Software Foundation; either version 2
   12    of the License, or (at your option) any later version.
   13
   14    This program is distributed in the hope that it will be useful,
   15    but WITHOUT ANY WARRANTY; without even the implied warranty of
   16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17    GNU General Public License for more details.
   18
   19    You should have received a copy of the GNU General Public
   20    License along with this library; if not, write to the Free Software
   21    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   22
   23    As a special exception, if you link this library with other files,
   24    compiled with a Free Software compiler, to produce an executable, this
   25    library does not by itself cause the resulting executable to be covered
   26    by the GNU General Public License. This exception does not however
   27    invalidate any other reasons why the executable file might be covered by
   28    the GNU General Public License.
   29*/
   30
   31:- module(api_lod_crawler,
   32	  [ lod_uri_graph/2
   33	  ]).   34:- use_module(library(uri)).   35:- use_module(library(semweb/rdf_db)).   36:- use_module(library(http/http_dispatch)).   37:- use_module(library(http/http_parameters)).   38:- use_module(components(messages)).   39:- use_module(user(user_db)).   40
   41:- http_handler(api(lod_crawl), lod_crawl, []).   42
   43%%	lod_crawl(+Request)
   44%
   45%	HTTP handler requesting ClioPatria to crawl LOD.
   46
   47lod_crawl(Request) :-
   48	authorized(write(default, load(lod))),
   49	http_parameters(Request,
   50			[ r(URI,
   51			    [ description('URI to start')
   52			    ]),
   53			  return_to(Return,
   54				    [ optional(true),
   55				      description('URI to return to')
   56				    ])
   57			]),
   58	lod_uri_graph(URI, Graph),
   59	return_option(Return, Options),
   60	call_showing_messages(rdf_load(Graph,
   61				       [ graph(Graph)
   62				       ]),
   63			      Options).
   64
   65return_option(Return, []) :-
   66	var(Return), !.
   67return_option(Return, [ return_to(Return) ]).
   68
   69
   70%%	lod_uri_graph(+URI, -Graph)
   71%
   72%	Determine the graph in which to dump   LOD from URI. This simply
   73%	deletes a possible fragment (#...) from the URI.
   74
   75lod_uri_graph(URI, Graph) :-
   76	uri_components(URI, Components),
   77	uri_data(fragment, Components, Fragment),
   78	nonvar(Fragment), !,
   79	uri_data(fragment, Components, _, NewComponents),
   80	uri_components(Graph, NewComponents).
   81lod_uri_graph(URI, URI).
   82
   83:- multifile
   84	rdf_http_plugin:rdf_content_type/2.   85
   86rdf_http_plugin:rdf_content_type('text/xml', xml)