1:- module(conf_amalgame, []).

Setup amalgame

*/

    6:- current_prolog_flag(version, Version),
    7   (   Version < 70330
    8   ->  format('Warning: amalgame needs SWI-Prolog version 7.3.30 or higher~n', [])
    9   ;   true
   10   ).   11
   12:- use_module(library(semweb/rdf_library)).   13:- use_module(library(http/http_dispatch)).   14:- use_module(library(http/http_dirindex)).   15:- use_module(library(http/http_server_files)).   16
   17:- use_module(library(void_schema)).   18:- use_module(library(prov_schema)).   19:- use_module(library(skos_schema)).   20:- use_module(library(skos_xl_schema)).   21
   22:- multifile
   23	http:location/3.		% Alias, Expansion, Options
   24:- dynamic
   25	http:location/3.		% Alias, Expansion, Options
   26
   27http:location(amalgame,          cliopatria(amalgame),       []).
   28http:location(alignment_results, root(alignment_results),    [ priority(-100) ]).
   29http:location(img,		 root(img),                  [ priority(-100) ]).
   30
   31:- rdf_attach_library(amalgame(rdf)).   32:- rdf_load_library(amalgame).   33:- rdf_load_library(dc).   34
   35/* Now all namespaces should have been defined,
   36*  we can load the amalgame applications:
   37*/
   38:- use_module(applications(startpage)).   39:- use_module(applications(builder)).   40:- use_module(applications(evaluater)).   41:- use_module(applications(publisher)).   42:- use_module(library(amalgame/hooks/load)).   43
   44% add local web directories from which static files are served.
   45
   46user:file_search_path(alignment_results, web(alignment_results)).
   47user:file_search_path(img, web(img)).
   48
   49:- http_handler(alignment_results(.),
   50		serve_static(alignment_results), [prefix]).   51:- http_handler(img(.),
   52		serve_files_in_directory(img),	 [prefix]).   53
   54serve_static(Alias, Request) :-
   55	memberchk(path_info(PathInfo), Request),
   56	!,
   57	% serve a strategy result directory index or
   58	% a file in a strategy result dir:
   59	Term =.. [Alias,PathInfo],
   60	(   absolute_file_name(Term, _,
   61			       [file_type(directory),
   62				access(read),
   63				file_errors(fail)
   64			       ])
   65	->  http_reply_dirindex(Term, [unsafe(true)], Request)
   66	;   http_reply_file(Term, [], Request)
   67	).
   68
   69serve_static(Alias, Request) :-
   70	\+ memberchk(path_info(_), Request),
   71	!,
   72	% no path info, this can only be a request on the
   73	% alignment_results directory itself (alignment_results(.)).
   74	memberchk(path(Path), Request),
   75	sub_atom(Path,  _, _, 1, Alias),
   76	Term =.. [Alias, '.' ],
   77	http_reply_dirindex(Term, [unsafe(true)], Request)