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.html', 'index.md' ],
   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,	'/').
   86user:url_path(pkg,	swi('pldoc/package/')).
   87user:url_path(pack,	swi('pack/list/')).
   88user:url_path(swipub,	 swi('download/publications/')).
   89user:url_path(fsf,	'https://www.fsf.org').
   90user:url_path(gnu,	'https://www.gnu.org').
   91user:url_path(gpl,	gnu('licences/gpl.html')).
   92user:url_path(lgpl,	gnu('licences/lgpl.html')).
   93user:url_path(wordnet,	'https://wordnet.princeton.edu/').
   94user:url_path(gmp,	'https://gmplib.org/').
   95user:url_path(gitweb,	 'https://github.com/SWI-Prolog').
   96user:url_path(swieditor, 'https://arbeitsplattform.bildung.hessen.de/fach/informatik/swiprolog/indexe.html').
   97user:url_path(git,	 'https://git-scm.com/').
   98user:url_path(macports,	 'https://www.macports.org/').
   99user:url_path(xquartz,	 'https://www.xquartz.org/').
  100user:url_path(json,	 'https://json.org/').
  101user:url_path(thea,	 'http://vangelisv.github.io/thea/').
  102user:url_path(dig,	 'https://dl.kr.org/dig/').
  103user:url_path(sparql,	 'https://www.w3.org/TR/sparql11-query/').
  104
  105
  106		 /*******************************
  107		 *	      RESOURCES		*
  108		 *******************************/
  109
  110:- html_resource(swipl_css,
  111		 [ virtual(true),
  112		   requires([ css('swipl.css') ])
  113		 ]).  114:- html_resource(plweb,
  115		 [ virtual(true),
  116		   requires([ pldoc_css,
  117			      css('plweb.css')
  118			    ])
  119		 ]).  120:- if(\+html_current_resource(jquery)).  121:- html_resource(jquery,
  122		 [ virtual(true),
  123		   requires([ jq('jquery.js')
  124			    ])
  125		 ]).  126:- endif.  127:- html_resource(js('jquery/ui/jquery-ui.min.js'),
  128		 [ requires([ jquery
  129			    ])
  130		 ]).  131:- html_resource(jquery_ui,
  132		 [ virtual(true),
  133		   requires([ js('jquery/ui/jquery-ui.min.js'),
  134			      js('jquery/ui/jquery-ui.min.css')
  135			    ])
  136		 ]).  137:- html_resource(jq('menu.js'),
  138		 [ requires([ jquery
  139			    ])
  140		 ]).  141
  142
  143		 /*******************************
  144		 *	       FILES		*
  145		 *******************************/
  146
  147:- multifile user:file_search_path/2.  148:- dynamic   user:file_search_path/2.  149
  150:- prolog_load_context(directory, Dir),
  151   (   user:file_search_path(plweb, Dir)
  152   ->  true
  153   ;   asserta(user:file_search_path(plweb, Dir))
  154   ).  155
  156user:file_search_path(data,          plweb(data)).
  157user:file_search_path(git_data,      data(git)).
  158user:file_search_path(git_data,      plweb(.)).
  159user:file_search_path(document_root, git_data(www)).
  160user:file_search_path(examples,      git_data(examples)).
  161user:file_search_path(blog,	     git_data(blog)).
  162user:file_search_path(private,       data(private)).
  163user:file_search_path(log,           data(log)).
  164user:file_search_path(download,	     data(download)).
  165user:file_search_path(icons,	     document_root(icons)).
  166user:file_search_path(css,	     document_root(css)).
  167user:file_search_path(js,	     document_root(js)).
  168
  169
  170		 /*******************************
  171		 *	   MASTER/SLAVE		*
  172		 *******************************/
  173
  174%%	server(?Type, ?Host) is nondet.
  175%%	server(?Type, ?Host, ?HostName) is nondet.
  176%
  177%	Describe known servers  and  their   role.  Currently,  the only
  178%	important role is `master`. Logged in sessions are redirected to
  179%	the master to simplify keeping one view   of the data. In future
  180%	versions we might go for a more distributed database.
  181
  182server(Type, Host) :-
  183	server(Type, Host, _HostName).
  184
  185server(cdn,    'www.swi-prolog.org', -).
  186server(slave,  'us.swi-prolog.org', 'swi-prolog.osuosl.org').
  187server(master, 'eu.swi-prolog.org', -).
  188%server(master, 'localhost', -).