View source with raw comments or as raw
   1/*  Part of ClioPatria semantic web server
   2
   3    Author:        Jan Wielemaker
   4    E-mail:        J.Wielemaker@cs.nl
   5    WWW:           http://www.swi-prolog.org
   6    Copyright (C): 2008-2014, 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
  32:- module(cp_parms,
  33	  [
  34	  ]).
  35:- use_module(library(settings)).
  36:- use_module(library(semweb/rdf_db)).
  37:- use_module(library(http/html_write)).
  38:- use_module(library(http/http_hook)).
  39
  40/** <module> ClioPatria parameters
  41
  42This file contains the locations of file-directories and web-directories
  43in addition to settings that can be   managed by the end-user. It should
  44not be necessary to modify this file:
  45
  46    * Web-locations can be modified externally using http:location/3
  47    with an option priority(N), where N > 0. See http_absolute_location/3.
  48
  49    * Settings can be changed using set_setting_default/2.
  50
  51@see run.pl[.in] contains an example startup script.
  52*/
  53
  54		 /*******************************
  55		 *	    FILE PATHS		*
  56		 *******************************/
  57
  58:- multifile
  59	user:file_search_path/2.
  60
  61% ClioPatria specific ones
  62user:file_search_path(rdfql,	        cliopatria(rdfql)).
  63user:file_search_path(cpack,	        cliopatria(cpack)).
  64
  65% Allow local file overwrites
  66user:file_search_path(web,		web).
  67
  68% Configuration
  69user:file_search_path(config_https,	cp_application('config-enabled/https')).
  70
  71% Package merge
  72user:file_search_path(cpacks,	        cliopatria('.')).
  73
  74user:file_search_path(library,		cpacks(lib)).
  75user:file_search_path(rdf,		cpacks(rdf)).
  76user:file_search_path(entailment,	cpacks(entailment)).
  77user:file_search_path(components,	cpacks(components)).
  78user:file_search_path(applications,	cpacks(applications)).
  79user:file_search_path(api,		cpacks(api)).
  80user:file_search_path(user,		cpacks(user)).
  81user:file_search_path(config_available,	cpacks('config-available')).
  82user:file_search_path(skin,		cpacks(skin)).
  83user:file_search_path(web,		cpacks(web)).
  84user:file_search_path(css,		web(css)).
  85user:file_search_path(icons,		web(icons)).
  86user:file_search_path(yui,		web('yui/2.7.0')).
  87user:file_search_path(js,		web(js)).
  88user:file_search_path(html,		web(html)).
  89user:file_search_path(help,		web(help)).
  90user:file_search_path(tutorial,		web(tutorial)).
  91user:file_search_path(flint,		web('FlintSparqlEditor/sparql')).
  92user:file_search_path(yasqe,		web('yasqe/dist')).
  93user:file_search_path(yasr,		web('yasr/dist')).
  94
  95
  96		 /*******************************
  97		 *	     HTTP PATHS		*
  98		 *******************************/
  99
 100http:location(cliopatria,  root(.),	       []).
 101http:location(web,	   cliopatria(web),    []).
 102http:location(sesame,	   root(servlets),     []).
 103http:location(sparql,	   root(sparql),       []).
 104http:location(rdf_browser, cliopatria(browse), []).
 105http:location(flint,       cliopatria(flint),  []).
 106http:location(api,	   cliopatria(api),    []).
 107http:location(json,	   api(json),	       []).
 108http:location(yasgui,      cliopatria(yasgui), []).
 109http:location(yasqe,	   cliopatria(yasqe),  []).
 110http:location(yasr,	   cliopatria(yasr),   []).
 111
 112		 /*******************************
 113		 *	       TYPES		*
 114		 *******************************/
 115
 116%	make the type 'uri' work such  that   we  can  write NS:Local in
 117%	settings defaults.
 118
 119:- multifile
 120	error:has_type/2,
 121	settings:eval_default/3,
 122	settings:convert_text/3,
 123	http_settings:input_item/5.
 124
 125error:has_type(uri, X) :-		% URI is an atom.  We do not use atom
 126	atom(X).			% to allow for conversion
 127
 128					% Convert NS:Local
 129settings:eval_default(URI, uri, URI) :-
 130	atom(URI), !.
 131settings:eval_default(NS:Local, uri, URI) :-
 132	rdf_global_id(NS:Local, URI).
 133
 134settings:convert_text(uri, Text, URI) :- !,
 135	(   sub_atom(Text, B, _, A, :),
 136	    sub_atom(Text, 0, B, _, NS),
 137	    sub_atom(Text, _, A, 0, Local),
 138	    identifier(NS),
 139	    identifier(Local)
 140	->  rdf_global_id(NS:Local, URI)
 141	;   URI = Text
 142	).
 143
 144%%	identifier(+Atom) is semidet.
 145%
 146%	True if Atom contains only alphanumerical characters or
 147%	undercores.
 148%
 149%	@tbd	Must we support unicode here?  Check with Turtle.
 150
 151identifier(Text) :-
 152	atom_codes(Text, Codes),
 153	identifier_codes(Codes).
 154
 155identifier_codes([]).
 156identifier_codes([H|T]) :-
 157	identifier_code(H),
 158	identifier_codes(T).
 159
 160identifier_code(C) :-
 161	code_type(C, csym).
 162
 163					% Render as plain atom
 164http_settings:input_item(uri, Value, Name) -->
 165	html(input([name(Name), size(40), value(Value)])).
 166
 167
 168		 /*******************************
 169		 *	       HTTP		*
 170		 *******************************/
 171
 172:- setting(http:port, any, env('PORT', 3020),
 173	   'Port the http server listens to or interface:port').
 174:- setting(http:workers, between(1, 20), env('PROLOG_HTTP_WORKERS', 5),
 175	   'Number of server threads').
 176:- setting(http:worker_options, list(any), [],
 177	   'Additional options to pass to the HTTP server').
 178:- setting(http:max_idle_time, nonneg, 3600,
 179	   'Session timeout.  If 0, session never times out').
 180:- setting(http:server_url, atom, 'http://localhost:'+setting(http:port),
 181	   'Url of the server itself').
 182:- if(\+current_setting(http:prefix)).
 183:- setting(http:prefix, atom, '',
 184	   'Prefix to rebase the server').
 185:- endif.
 186
 187
 188		 /*******************************
 189		 *      CLIOPATRIA SETTINGS	*
 190		 *******************************/
 191
 192:- setting(cliopatria:user_data, atom, 'users.db',
 193	   'File holding account information').
 194:- setting(cliopatria:enable_self_register, boolean, false,
 195	   'Set to true to allow users to self register'). % using cpa_admin:add_user/1
 196:- setting(cliopatria:default_entailment, atom, rdfs,
 197	   'Default entailment rules applied').
 198:- setting(cliopatria:optimise_query, boolean, true,
 199	   'Optimise queries before execution').
 200:- setting(cliopatria:rdf_db_namespaces, boolean, true,
 201	   'Allow registered namespaces in queries').
 202:- setting(cliopatria:persistent_store, atom, '',
 203	   'Directory for persistent copy of in-memory RDF').
 204:- setting(cliopatria:pre_index_tokens, boolean, false,
 205	   'Build the fulltext token index while loading').
 206:- setting(cliopatria:pre_index_stems, boolean, false,
 207	   'Build the fulltext stem index while loading').
 208
 209
 210		 /*******************************
 211		 *	  QUERY-SETTINGS	*
 212		 *******************************/
 213
 214:- setting(sparql:max_clients, nonneg, 100,
 215	   'Maximum number of concurrent requests').
 216:- setting(sparql:stack_size, nonneg, 1000,
 217	   'Size of the global stack in mega-bytes').