30
31:- module(plweb_parms,
32 [ server/2, 33 server/3 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 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 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 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 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 173
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', -).