Mercurial > hg > dml-open-cliopatria
comparison cpack/dml/skin/minimal.pl @ 0:718306e29690 tip
commiting public release
author | Daniel Wolff |
---|---|
date | Tue, 09 Feb 2016 21:05:06 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:718306e29690 |
---|---|
1 /* Part of DML (Digital Music Laboratory) | |
2 Copyright 2014-2015 Samer Abdallah, University of London | |
3 | |
4 This program is free software; you can redistribute it and/or | |
5 modify it under the terms of the GNU General Public License | |
6 as published by the Free Software Foundation; either version 2 | |
7 of the License, or (at your option) any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public | |
15 License along with this library; if not, write to the Free Software | |
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
17 */ | |
18 | |
19 :- module(minimal, []). | |
20 | |
21 | |
22 :- use_module(cliopatria(hooks)). | |
23 :- use_module(skin(cliopatria)). | |
24 :- use_module(components(menu)). | |
25 :- use_module(components(simple_search)). | |
26 | |
27 :- use_module(library(http/html_write)). | |
28 :- use_module(library(http/html_head)). | |
29 :- use_module(library(lambda)). | |
30 :- use_module(library(htmlutils)). | |
31 % :- use_module(framework/pure, []). | |
32 :- use_module(framework/kube, []). | |
33 :- use_module(framework/bootstrap). | |
34 | |
35 :- set_prolog_flag(double_quotes,string). | |
36 | |
37 % :- set_setting(htmlutils:appname,"DML"). | |
38 :- googlefont(sourcepro,"Source+Sans+Pro:300,600|Source+Code+Pro:400,700"). | |
39 | |
40 :- html_resource(font_awesome, | |
41 [ virtual(true) | |
42 , requires("//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css") | |
43 ]). | |
44 | |
45 :- html_resource(css('minimal.css'), [ ordered(true), requires([bootstrap, kube('kube.css')]) ]). | |
46 :- html_resource(css('minimal_doc.css'), [ requires([pldoc_css,css('minimal.css')]) ]). | |
47 :- html_resource(css('minimal_http_doc.css'), [ requires(css('minimal_doc.css')) ]). | |
48 :- html_resource(css('isearch_extra.css'), [ requires([css('minimal.css'),css('interactive_search.css')]) ]). | |
49 | |
50 :- multifile user:body//2. | |
51 | |
52 user:body(user(App),Body) --> | |
53 {member(App,[search,isearch])}, | |
54 use_font("Source Sans Pro",sourcepro), | |
55 use_font("pre, code, .code, .editor","Source Code Pro",sourcepro), | |
56 html_requires(css('isearch_extra.css')), | |
57 html(body(class(kubepage),Body)). | |
58 | |
59 style_style(cliopatria(http_help), 'margin-left:auto;margin-right:auto;width:95%;max-width:160ex') :- !. | |
60 style_style(cliopatria(wide), 'margin-left:auto;margin-right:auto;width:90%'). | |
61 style_style(cliopatria(_), 'margin-left:auto;margin-right:auto;width:80%;max-width:105ex'). | |
62 style_style(pldoc(object(_)), 'margin-left:auto;margin-right:auto;width:80%;max-width:160ex') :- !. | |
63 style_style(pldoc(_), 'margin-left:auto;margin-right:auto;width:80%;max-width:120ex') :- !. | |
64 | |
65 style_css(cliopatria(http_help), 'minimal_http_doc.css') :- !. | |
66 style_css(pldoc(_), 'minimal_doc.css') :- !. | |
67 style_css(_, 'minimal.css'). | |
68 | |
69 cliopatria:page_body(cliopatria(bare), Body) --> !, | |
70 {debug(skin,"Serving page with style: ~w.\n",[plain])}, | |
71 html_requires(css('minimal.css')), | |
72 use_font("Source Sans Pro",sourcepro), | |
73 use_font("pre, code, .code, .editor","Source Code Pro",sourcepro), | |
74 html(body(class=['kubepage',cliopatria], Body)). | |
75 | |
76 cliopatria:page_body(cliopatria(bare(http_doc)), Body) --> !, | |
77 {debug(skin,"Serving page with style: ~w.\n",[bare(http_doc)])}, | |
78 html_requires(css('minimal_http_doc.css')), | |
79 use_font("Source Sans Pro",sourcepro), | |
80 use_font("pre, code, .code, .editor","Source Code Pro",sourcepro), | |
81 html(body(class=['kubepage',cliopatria], Body)). | |
82 | |
83 cliopatria:page_body(Style, Body) --> !, | |
84 {debug(skin,"Serving page with style: ~w.\n",[Style])}, | |
85 {style_style(Style,BodyStyle), style_css(Style,CSS)}, | |
86 html_post(head, meta([name(viewport), content("width-device-width,initial-scale=1")]) ), | |
87 html_requires(css(CSS)), | |
88 html_requires('//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js'), | |
89 | |
90 % html_requires(cliopatria), | |
91 %html_requires(kube('kube.css')), | |
92 use_font("Source Sans Pro",sourcepro), | |
93 use_font("pre, code, .code, .editor","Source Code Pro",sourcepro), | |
94 | |
95 html(body( [ class=['kubepage',cliopatria]], | |
96 | |
97 % Version with wide navbar | |
98 [ header(class=[group], div(style(BodyStyle), \clio_menu(inline_search))) | |
99 , div([ style(BodyStyle) ], | |
100 [ div([id('cp-content'), class(content)], Body) | |
101 | |
102 % Original version with narrow navbar | |
103 % [ div([ style(BodyStyle) ], | |
104 % [ header(class=[group], \clio_menu(inline_search)) | |
105 % , div([id('cp-content'), class(content)], Body) | |
106 | |
107 , hr([style='margin-top:1em; margin-bottom:0.5em;',clear=all]) | |
108 , div([ style('font-size:smaller;text-align:right;') | |
109 , id('cp-footer'), class(footer)], | |
110 \server_address('ClioPatria')) | |
111 ]) | |
112 ])). | |
113 | |
114 cliopatria:page_body(Style,_) --> | |
115 {debug(skin,"Not serving page with style ~w.\n",[Style]), fail}. | |
116 | |
117 | |
118 clio_menu(full) --> | |
119 { findall(Key-Item, cp_menu:current_menu_item(Key, Item), Pairs0), | |
120 sort(Pairs0, Pairs), | |
121 group_pairs_by_key(Pairs, ByKey), | |
122 cp_menu:sort_menu_popups(ByKey, Menu), | |
123 maplist(translate_menu,Menu,Menu1) | |
124 }, | |
125 navbar('DML',['navbar-static-top'],navbar_menu(left,seqmap(navbar_item,Menu1))), | |
126 minimal_search. | |
127 | |
128 clio_menu(inline_search) --> | |
129 { findall(Key-Item, cp_menu:current_menu_item(Key, Item), Pairs0), | |
130 sort(Pairs0, Pairs), | |
131 group_pairs_by_key(Pairs, ByKey), | |
132 cp_menu:sort_menu_popups(ByKey, Menu), | |
133 maplist(translate_menu,Menu,Menu1) | |
134 }, | |
135 navbar('DML',['navbar-static-top'], | |
136 html([ \navbar_menu(left,seqmap(navbar_item,Menu1)) | |
137 , span(class('navbar-form navbar-right'), div(class('form-group'),\minimal_search)) | |
138 ])). | |
139 | |
140 | |
141 translate_menu(_-[Item],Link) :- | |
142 translate_item(Item,Link). | |
143 translate_menu(Key-Items,Menu) :- | |
144 cp_menu:menu_label(Key, Key, Label), | |
145 translate_dropdown(Label,Items,Menu). | |
146 | |
147 translate_dropdown(a(Attribs,Label),Items,menu(Label,[link('OpenID page',URL) | Items1])) :- !, | |
148 (Attribs=href(URL)-> true; memberchk(href(URL),Attribs)), | |
149 maplist(translate_item, Items, Items1). | |
150 | |
151 translate_dropdown(Label,Items,menu(Label,Items1)) :- | |
152 maplist(translate_item,Items,Items1). | |
153 | |
154 translate_item(item(_,Spec,Label),link(Label,Location)) :- | |
155 atom(Spec), | |
156 ( \+sub_atom(Spec, 0, _, _, 'http://'), | |
157 catch( http_dispatch:http_location_by_id(Spec, Location), E, | |
158 (print_message(informational, E), fail)) | |
159 -> true | |
160 ; Location = Spec | |
161 ). | |
162 | |
163 | |
164 minimal_search --> | |
165 html_post(head,style( | |
166 % ac_find_literal_container has class .yui-ac-container | |
167 [ ".yui-ac-content { background-color:#ffffff;padding:0ex;border: solid 1px #ddd; | |
168 box-shadow:0 6px 12px rgba(0,0,0,.175); | |
169 text-align:left; z-index:2;margin-top:1ex}" | |
170 , ".yui-ac-content { position:absolute;max-height:30em; overflow:auto; overflow-x:hidden; }" | |
171 , "input, select, input[type='search'], textarea { z-index:0 }" | |
172 , ".yui-ac-content ul {padding:0ex;margin:0ex;list-style-type:none}" | |
173 , ".yui-ac-content ul li {margin:0em;padding:0.5ex}" | |
174 , "li.yui-ac-highlight { background-color:#eee }" | |
175 % , "span.acmatch { background-color: #bbf; }" | |
176 , "span.acmatch { text-decoration:underline; | |
177 text-decoration-color:#5ca9e4; | |
178 -moz-text-decoration-color:#5ca9e4;}" | |
179 , "span.ac-builtin { color: blue; }" | |
180 , "span.ac-module { color: #888; }" | |
181 , "span.ac-exported { color: dark-green; }" | |
182 , "span.ac-private { color: red; }" | |
183 , "#search_form { margin-top:1ex; margin-bottom:1ex; text-align:right; }" | |
184 , "input#ac_find_literal_input { line-height:1.4em }" | |
185 ])), | |
186 html_post(head,script(type("text/javascript"), | |
187 "$(document).ready(function() { | |
188 console.log('Adjusting search box...'); | |
189 $('.yui-ac-input').attr('type','search').attr('placeholder','Search'); | |
190 $('.yui-ac-input').css('box-sizing','border-box').css('width','26ex'); | |
191 $('#ac_find_literal_complete').css('width','26ex'); | |
192 });")), | |
193 html(form([ id(search_form), action(location_by_id(cpa_browse:search)) ], | |
194 [ \(cp_simple_search:search_box([ name(q) ])) | |
195 % , \cp_menu:filter([]) | |
196 % , \cp_menu:select_handler([]) | |
197 ])). | |
198 |