1:- module(simple_bootstrap,
2 [
3 ]
4). 5
7:- prolog_load_context(directory, Dir),
8 asserta(user:file_search_path(bs_app, Dir)),
9 asserta(user:file_search_path(bs_templates, bs_app(templates))),
10 asserta(user:file_search_path(bs_static, bs_app(static))). 11
12:- use_module(library(sw/simple_web)). 13
15:- asserta(sw_config_handling:config(st_undefined, false)). 16
18:- asserta((sw_template_handling:render_reply(bootstrap_base, Data, Opts) :- bootstrap_reply(Data, Opts))). 19
20
21:- use_module(library(st/st_expr)). 22:- use_module(library(st/st_render)). 23
25:- st_set_function(sw_templates, 1, sw_templates). 26:- st_set_function(bootstrap, 1, bootstrap). 27
29sw_templates(File, Path) :-
30 absolute_file_name(sweb_templates(File), Path, []).
31
33bootstrap(File, Path) :-
34 absolute_file_name(bs_templates(File), Path, []).
39bootstrap_reply(Data, Opts) :-
40 current_output(Out),
41 format("Content-type: text/html~n~n"),
42 st_render_file(bs_templates(bootstrap_base), Data, Out, Opts).
43
45:- use_module(library(http/http_dispatch)). 46:- use_module(library(http/http_files)). 47
48http:location(bootstrap_static, "/bootstrap", []).
49
50:- http_handler(bootstrap_static(.),
51 http_reply_from_files(bs_static(.), []),
52 [prefix]).