View source with formatted 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-2024, VU University Amsterdam
    7			      SWI-Prolog Solutions b.v.
    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(plweb_parms,
   32	  [ server/2,			% ?Role, ?Host
   33	    server/3			% ?Role, ?Host, -HostName
   34	  ]).   35:- use_module(library(http/http_log)).   36:- use_module(library(http/http_path)).   37:- use_module(library(http/http_dispatch)).   38:- use_module(library(http/http_cors)).   39:- use_module(library(http/html_head)).   40:- use_module(library(www_browser)).   41:- use_module(library(settings)).   42:- use_module(library(pengines)).   43
   44
   45:- setting(http:served_file_extensions,
   46	   list(atom),
   47	   [ html, gif, png, jpeg, jpg, css, js, tgz, exe, c, zip ],
   48	   'List of extensions that are served as plain files').   49:- setting(http:index_files,
   50	   list(atom),
   51	   [ 'index.txt', 'index.html' ],
   52	   'List of files that provide a directory index').   53:- setting(http:port,
   54	   integer,
   55	   3040,
   56	   'Default port').   57:- setting(http:workers,
   58	   integer,
   59	   10,
   60	   'Number of worker threads').   61
   62:- set_setting_default(pengines:allow_from, []).   63:- set_setting_default(http:logfile, log('httpd.log')).   64:- set_setting_default(http:cors, [*]).   65
   66
   67		 /*******************************
   68		 *	     LOCATIONS		*
   69		 *******************************/
   70
   71http:location(pldoc,	root(pldoc),	   [priority(10)]).
   72http:location(download,	root(download),	   []).
   73http:location(icons,	root(icons),	   []).
   74http:location(css,	root(css),	   []).
   75http:location(jq,	root('js/jquery'), []).
   76
   77
   78		 /*******************************
   79		 *	   EXTERNAL URLS	*
   80		 *******************************/
   81
   82:- multifile
   83	user:url_path/2.   84
   85user:url_path(swi,	'http://www.swi-prolog.org').
   86user:url_path(hcs,	'http://hcs.science.uva.nl').
   87user:url_path(pkg,	pl(package)).
   88user:url_path(dmoz,	'http://dmoz.org').
   89user:url_path(dmoz_pl,	dmoz('Computers/Programming/Languages/Prolog/Implementations/')).
   90user:url_path(ffii,	'http://swpat.ffii.org/index.en.html').
   91user:url_path(fsf,	'http://www.fsf.org').
   92user:url_path(gnu,	'http://www.gnu.org').
   93user:url_path(gpl,	gnu('licences/gpl.html')).
   94user:url_path(lgpl,	gnu('licences/lgpl.html')).
   95user:url_path(wordnet,	'http://www.cogsci.princeton.edu/~wn/').
   96user:url_path(gmp,	'http://gmplib.org/').
   97user:url_path(mailman,	'http://www.list.org/').
   98user:url_path(bonn,	'https://lists.iai.uni-bonn.de/mailman').
   99user:url_path(maillist,	bonn('listinfo.cgi/swi-prolog')).
  100user:url_path(mailarchive, bonn('public/swi-prolog/')).
  101user:url_path(nabble,	'http://www.nabble.com').
  102user:url_path(pl_nabble, nabble('SWI-Prolog-f448.html')).
  103user:url_path(gmane,     'http://blog.gmane.org').
  104user:url_path(pl_gmane,  gmane('gmane.comp.ai.prolog.swi')).
  105user:url_path(chr_mail,  'http://listserv.cc.kuleuven.ac.be/archives/chr.html').
  106user:url_path(bugzilla,  'http://www.swi-prolog.org/bugzilla/').
  107user:url_path(gitweb,	 'http://www.swi-prolog.org/git/').
  108user:url_path(swieditor, 'http://arbeitsplattform.bildung.hessen.de/fach/informatik/swiprolog/indexe.html').
  109user:url_path(pub,	 hcs('projects/SWI-Prolog/articles')).
  110user:url_path(swipub,	 swi('download/publications')).
  111user:url_path(git,	 'http://git-scm.com/').
  112user:url_path(msysgit,	 'http://code.google.com/p/msysgit/').
  113user:url_path(tortoisegit, 'http://code.google.com/p/tortoisegit/').
  114user:url_path(macports,	 'http://www.macports.org/').
  115user:url_path(xquartz,	 'http://xquartz.macosforge.org/').
  116user:url_path(json,	 'http://json.org/').
  117user:url_path(multimedian, 'http://e-culture.multimedian.nl/').
  118user:url_path(thea,	 'http://www.semanticweb.gr/TheaOWLLib/').
  119user:url_path(dig,	 'http://dl.kr.org/dig/interface.html').
  120user:url_path(sparql,	 'http://www.w3.org/TR/rdf-sparql-query/').
  121user:url_path(serql,	 'http://www.openrdf.org').
  122
  123
  124		 /*******************************
  125		 *	      RESOURCES		*
  126		 *******************************/
  127
  128:- html_resource(swipl_css,
  129		 [ virtual(true),
  130		   requires([ css('swipl.css') ])
  131		 ]).  132:- html_resource(plweb,
  133		 [ virtual(true),
  134		   requires([ pldoc_css,
  135			      css('plweb.css')
  136			    ])
  137		 ]).  138:- if(\+html_current_resource(jquery)).  139:- html_resource(jquery,
  140		 [ virtual(true),
  141		   requires([ jq('jquery.js')
  142			    ])
  143		 ]).  144:- endif.  145:- html_resource(js('jquery/ui/jquery-ui.min.js'),
  146		 [ requires([ jquery
  147			    ])
  148		 ]).  149:- html_resource(jquery_ui,
  150		 [ virtual(true),
  151		   requires([ js('jquery/ui/jquery-ui.min.js'),
  152			      js('jquery/ui/jquery-ui.min.css')
  153			    ])
  154		 ]).  155:- html_resource(jq('menu.js'),
  156		 [ requires([ jquery
  157			    ])
  158		 ]).  159
  160
  161		 /*******************************
  162		 *	       FILES		*
  163		 *******************************/
  164
  165:- multifile user:file_search_path/2.  166:- dynamic   user:file_search_path/2.  167
  168:- prolog_load_context(directory, Dir),
  169   (   user:file_search_path(plweb, Dir)
  170   ->  true
  171   ;   asserta(user:file_search_path(plweb, Dir))
  172   ).  173
  174user:file_search_path(data,          plweb(data)).
  175user:file_search_path(git_data,      data(git)).
  176user:file_search_path(git_data,      plweb(.)).
  177user:file_search_path(document_root, git_data(www)).
  178user:file_search_path(examples,      git_data(examples)).
  179user:file_search_path(blog,	     git_data(blog)).
  180user:file_search_path(private,       data(private)).
  181user:file_search_path(log,           data(log)).
  182user:file_search_path(download,	     data(download)).
  183user:file_search_path(icons,	     document_root(icons)).
  184user:file_search_path(css,	     document_root(css)).
  185user:file_search_path(js,	     document_root(js)).
  186
  187
  188		 /*******************************
  189		 *	   MASTER/SLAVE		*
  190		 *******************************/
  191
  192%%	server(?Type, ?Host) is nondet.
  193%%	server(?Type, ?Host, ?HostName) is nondet.
  194%
  195%	Describe known servers  and  their   role.  Currently,  the only
  196%	important role is `master`. Logged in sessions are redirected to
  197%	the master to simplify keeping one view   of the data. In future
  198%	versions we might go for a more distributed database.
  199
  200server(Type, Host) :-
  201	server(Type, Host, _HostName).
  202
  203server(cdn,    'www.swi-prolog.org', -).
  204server(slave,  'us.swi-prolog.org', 'swi-prolog.osuosl.org').
  205server(master, 'eu.swi-prolog.org', -).
  206%server(master, 'localhost', -).