View source with raw comments or as raw
    1/*  Part of SWI-Prolog
    2
    3    Author:        Jan Wielemaker
    4    E-mail:        J.Wielemaker@cs.vu.nl
    5    WWW:           http://www.swi-prolog.org
    6    Copyright (C): 2009, VU University Amsterdam
    7
    8    This program is free software; you can redistribute it and/or
    9    modify it under the terms of the GNU General Public License
   10    as published by the Free Software Foundation; either version 2
   11    of the License, or (at your option) any later version.
   12
   13    This program is distributed in the hope that it will be useful,
   14    but WITHOUT ANY WARRANTY; without even the implied warranty of
   15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   16    GNU General Public License for more details.
   17
   18    You should have received a copy of the GNU General Public
   19    License along with this library; if not, write to the Free Software
   20    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   21
   22    As a special exception, if you link this library with other files,
   23    compiled with a Free Software compiler, to produce an executable, this
   24    library does not by itself cause the resulting executable to be covered
   25    by the GNU General Public License. This exception does not however
   26    invalidate any other reasons why the executable file might be covered by
   27    the GNU General Public License.
   28*/
   29
   30:- module(plweb_parms,
   31	  [ server/2,			% ?Role, ?Host
   32	    server/3			% ?Role, ?Host, -HostName
   33	  ]).   34:- use_module(library(http/http_log)).   35:- use_module(library(http/http_path)).   36:- use_module(library(http/http_dispatch)).   37:- use_module(library(http/http_cors)).   38:- use_module(library(http/html_head)).   39:- use_module(library(www_browser)).   40:- use_module(library(settings)).   41:- use_module(library(pengines)).   42
   43
   44:- setting(http:served_file_extensions,
   45	   list(atom),
   46	   [ html, gif, png, jpeg, jpg, css, js, tgz, exe, c, zip ],
   47	   'List of extensions that are served as plain files').   48:- setting(http:index_files,
   49	   list(atom),
   50	   [ 'index.txt', 'index.html' ],
   51	   'List of files that provide a directory index').   52:- setting(http:port,
   53	   integer,
   54	   3040,
   55	   'Default port').   56:- setting(http:workers,
   57	   integer,
   58	   10,
   59	   'Number of worker threads').   60
   61:- set_setting_default(pengines:allow_from, []).   62:- set_setting_default(http:logfile, 'log/httpd.log').   63:- set_setting_default(http:cors, [*]).   64
   65
   66		 /*******************************
   67		 *	     LOCATIONS		*
   68		 *******************************/
   69
   70http:location(pldoc,	root(pldoc),	   [priority(10)]).
   71http:location(download,	root(download),	   []).
   72http:location(icons,	root(icons),	   []).
   73http:location(css,	root(css),	   []).
   74http:location(jq,	root('js/jquery'), []).
   75
   76
   77		 /*******************************
   78		 *	   EXTERNAL URLS	*
   79		 *******************************/
   80
   81:- multifile
   82	user:url_path/2.   83
   84user:url_path(swi,	'http://www.swi-prolog.org').
   85user:url_path(hcs,	'http://hcs.science.uva.nl').
   86user:url_path(pkg,	pl(package)).
   87user:url_path(dmoz,	'http://dmoz.org').
   88user:url_path(dmoz_pl,	dmoz('Computers/Programming/Languages/Prolog/Implementations/')).
   89user:url_path(ffii,	'http://swpat.ffii.org/index.en.html').
   90user:url_path(fsf,	'http://www.fsf.org').
   91user:url_path(gnu,	'http://www.gnu.org').
   92user:url_path(gpl,	gnu('licences/gpl.html')).
   93user:url_path(lgpl,	gnu('licences/lgpl.html')).
   94user:url_path(wordnet,	'http://www.cogsci.princeton.edu/~wn/').
   95user:url_path(gmp,	'http://gmplib.org/').
   96user:url_path(mailman,	'http://www.list.org/').
   97user:url_path(bonn,	'https://lists.iai.uni-bonn.de/mailman').
   98user:url_path(maillist,	bonn('listinfo.cgi/swi-prolog')).
   99user:url_path(mailarchive, bonn('public/swi-prolog/')).
  100user:url_path(nabble,	'http://www.nabble.com').
  101user:url_path(pl_nabble, nabble('SWI-Prolog-f448.html')).
  102user:url_path(gmane,     'http://blog.gmane.org').
  103user:url_path(pl_gmane,  gmane('gmane.comp.ai.prolog.swi')).
  104user:url_path(chr_mail,  'http://listserv.cc.kuleuven.ac.be/archives/chr.html').
  105user:url_path(bugzilla,  'http://www.swi-prolog.org/bugzilla/').
  106user:url_path(gitweb,	 'http://www.swi-prolog.org/git/').
  107user:url_path(swieditor, 'http://arbeitsplattform.bildung.hessen.de/fach/informatik/swiprolog/indexe.html').
  108user:url_path(pub,	 hcs('projects/SWI-Prolog/articles')).
  109user:url_path(swipub,	 swi('download/publications')).
  110user:url_path(git,	 'http://git-scm.com/').
  111user:url_path(msysgit,	 'http://code.google.com/p/msysgit/').
  112user:url_path(tortoisegit, 'http://code.google.com/p/tortoisegit/').
  113user:url_path(macports,	 'http://www.macports.org/').
  114user:url_path(xquartz,	 'http://xquartz.macosforge.org/').
  115user:url_path(json,	 'http://json.org/').
  116user:url_path(multimedian, 'http://e-culture.multimedian.nl/').
  117user:url_path(thea,	 'http://www.semanticweb.gr/TheaOWLLib/').
  118user:url_path(dig,	 'http://dl.kr.org/dig/interface.html').
  119user:url_path(sparql,	 'http://www.w3.org/TR/rdf-sparql-query/').
  120user:url_path(serql,	 'http://www.openrdf.org').
  121
  122
  123		 /*******************************
  124		 *	      RESOURCES		*
  125		 *******************************/
  126
  127:- html_resource(swipl_css,
  128		 [ virtual(true),
  129		   requires([ css('swipl.css') ])
  130		 ]).  131:- html_resource(plweb,
  132		 [ virtual(true),
  133		   requires([ pldoc_css,
  134			      css('plweb.css')
  135			    ])
  136		 ]).  137:- if(\+html_current_resource(jquery)).  138:- html_resource(jquery,
  139		 [ virtual(true),
  140		   requires([ jq('jquery.js')
  141			    ])
  142		 ]).  143:- endif.  144:- html_resource(js('jquery/ui/jquery-ui.min.js'),
  145		 [ requires([ jquery
  146			    ])
  147		 ]).  148:- html_resource(jquery_ui,
  149		 [ virtual(true),
  150		   requires([ js('jquery/ui/jquery-ui.min.js'),
  151			      js('jquery/ui/jquery-ui.min.css')
  152			    ])
  153		 ]).  154:- html_resource(jq('menu.js'),
  155		 [ requires([ jquery
  156			    ])
  157		 ]).  158
  159
  160		 /*******************************
  161		 *	       FILES		*
  162		 *******************************/
  163
  164:- multifile user:file_search_path/2.  165:- dynamic   user:file_search_path/2.  166
  167:- prolog_load_context(directory, Dir),
  168   (   user:file_search_path(plweb, Dir)
  169   ->  true
  170   ;   asserta(user:file_search_path(plweb, Dir))
  171   ).  172
  173user:file_search_path(document_root, plweb(www)).
  174user:file_search_path(plgit,	     plweb(git)).
  175user:file_search_path(icons,	     document_root(icons)).
  176user:file_search_path(css,	     document_root(css)).
  177user:file_search_path(js,	     document_root(js)).
  178user:file_search_path(yui,	     document_root('yui/2.7.0')).
  179user:file_search_path(cgi_bin,	     plweb('git-web')).
  180user:file_search_path(download,	     plweb(download)).
  181user:file_search_path(gitweb,	     plweb('git-web')).
  182
  183
  184		 /*******************************
  185		 *	   MASTER/SLAVE		*
  186		 *******************************/
 server(?Type, ?Host) is nondet
 server(?Type, ?Host, ?HostName) is nondet
Describe known servers and their role. Currently, the only important role is master. Logged in sessions are redirected to the master to simplify keeping one view of the data. In future versions we might go for a more distributed database.
  196server(Type, Host) :-
  197	server(Type, Host, _HostName).
  198
  199server(cdn,    'www.swi-prolog.org', -).
  200server(slave,  'us.swi-prolog.org', 'swi-prolog.osuosl.org').
  201server(master, 'eu.swi-prolog.org', -).
  202%server(master, 'localhost', -).