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