35
36:- module(cp_skin,
37 [ server_address//1, 38 current_page_doc_link//0
39 ]). 40:- use_module(library(http/html_write)). 41:- use_module(library(http/html_head)). 42:- use_module(library(http/http_wrapper)). 43:- use_module(library(http/http_dispatch)). 44:- use_module(library(http/http_path)). 45:- use_module(library(version)). 46:- use_module(components(menu)). 47:- use_module(components(simple_search)). 48:- use_module(applications(help/version)).
86:- http_handler('/favicon.ico',
87 http_reply_file(icons('favicon.ico'), []),
88 []). 89
90:- html_resource(js('cliopatria.js'),
91 [ requires([jquery])
92 ]). 93:- html_resource(plain,
94 [ virtual(true),
95 requires([ css('plain.css')
96 ])
97 ]). 98:- html_resource(cliopatria,
99 [ virtual(true),
100 requires([ css('cliopatria.css'),
101 js('cliopatria.js')
102 ])
103 ]).
110:- multifile
111 user:body//2. 112
113user:body(cliopatria(Style), Body) -->
114 cliopatria:page_body(cliopatria(Style), Body),
115 !.
116user:body(cliopatria(_), Body) -->
117 cliopatria:page_body(Body),
118 !.
119user:body(cliopatria(plain), Body) -->
120 html_requires(plain),
121 html(body(class(['yui-skin-sam', cliopatria]),
122 [ div([id('cp-menu'), class(menu)], \cp_logo_and_menu),
123 \simple_search_form([value(p(q))]),
124 br(clear(all)),
125 div([id('cp-content'), class(content)], Body),
126 br(clear(all)),
127 div([id('cp-footer'), class(footer)], \address)
128 ])).
129user:body(cliopatria(_), Body) -->
130 html_requires(cliopatria),
131 html(body(class(['yui-skin-sam', cliopatria]),
132 [ div([id('cp-menu'), class(menu)], \cp_logo_and_menu),
133 \simple_search_form([value(p(q))]),
134 br(clear(all)),
135 div([id('cp-content'), class(content)], Body),
136 br(clear(all)),
137 div([id('cp-footer'), class(footer)], \address)
138 ])).
139
140cp_logo_and_menu -->
141 cp_logo,
142 cp_menu.
143
144cp_logo -->
145 cliopatria:logo,
146 !.
147cp_logo -->
148 { File = 'cliopatria-logo.png',
149 absolute_file_name(icons(File), _Logo,
150 [access(read), file_errors(fail)]),
151 http_absolute_location(icons(File), Src, []),
152 http_link_to_id(home, [], Home)
153 },
154 html(a([class(logo), href(Home), style('float:left')
155 ],
156 img([src(Src)]))).
166address -->
167 cliopatria:server_address,
168 !.
169address -->
170 server_address('ClioPatria').
189server_address(Component) -->
190 html([ address(class(footer),
191 [ \component_address(Component),
192 \current_page_doc_link
193 ])
194 ]).
200component_address(Component) -->
201 ( { git_module_property(Component, home_url(Home)) }
202 -> html(a([ class(home), href(Home),
203 title(Component+' home')
204 ], Component))
205 ; html(span(class(home), Component))
206 ),
207 html(' (version '),
208 component_version(Component),
209 html(')').
216component_version(Component) -->
217 { ( git_module_property(Component, version(Version))
218 -> true
219 ; Version = 'no GIT?'
220 ),
221 http_link_to_id(version_info, [], VREF)
222 },
223 html(a([title('About versions'),
224 class(version),
225 href(VREF)],
226 Version)).
236:- if(current_predicate(http_help:page_documentation_link//1)). 237current_page_doc_link -->
238 { http_current_request(Request) },
239 http_help:page_documentation_link(Request).
240:- else. 241current_page_doc_link --> [].
242:- endif.
ClioPatria skin
This page defines the overall layout of ClioPatria pages. All pages are returned using reply_html_page/3, using the page class
cliopatria(Id)
, where Id is currently alwaysdefault
. Pages can be redefined by providing a rule for user:body//2, where the first argument must unify with the page class.The default skin provides the overall menu, a simple search form, the content and the `server-address'. Because the search-form uses the YUI autocomplete widgets, the body must include class
yui-skin-sam
. The default body has the classesyui-skin-sam
andcliopatria
.The default skin provided by this can be overruled using two hooks:
This library also provides building blocks, notably for server_address//0:
The CSS file css('cliopatria.css') contains the ClioPatria style that is makes ClioPatria look pretty to our eyes, but is not essential. The plugin config-
available/fix_menu.pl
contains example code to extend the ClioPatria skin. */