Daniel@0: /* Part of DML (Digital Music Laboratory) Daniel@0: Copyright 2014-2015 Samer Abdallah, University of London Daniel@0: Daniel@0: This program is free software; you can redistribute it and/or Daniel@0: modify it under the terms of the GNU General Public License Daniel@0: as published by the Free Software Foundation; either version 2 Daniel@0: of the License, or (at your option) any later version. Daniel@0: Daniel@0: This program is distributed in the hope that it will be useful, Daniel@0: but WITHOUT ANY WARRANTY; without even the implied warranty of Daniel@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Daniel@0: GNU General Public License for more details. Daniel@0: Daniel@0: You should have received a copy of the GNU General Public Daniel@0: License along with this library; if not, write to the Free Software Daniel@0: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Daniel@0: */ Daniel@0: Daniel@0: :- module(minimal, []). Daniel@0: Daniel@0: Daniel@0: :- use_module(cliopatria(hooks)). Daniel@0: :- use_module(skin(cliopatria)). Daniel@0: :- use_module(components(menu)). Daniel@0: :- use_module(components(simple_search)). Daniel@0: Daniel@0: :- use_module(library(http/html_write)). Daniel@0: :- use_module(library(http/html_head)). Daniel@0: :- use_module(library(lambda)). Daniel@0: :- use_module(library(htmlutils)). Daniel@0: % :- use_module(framework/pure, []). Daniel@0: :- use_module(framework/kube, []). Daniel@0: :- use_module(framework/bootstrap). Daniel@0: Daniel@0: :- set_prolog_flag(double_quotes,string). Daniel@0: Daniel@0: % :- set_setting(htmlutils:appname,"DML"). Daniel@0: :- googlefont(sourcepro,"Source+Sans+Pro:300,600|Source+Code+Pro:400,700"). Daniel@0: Daniel@0: :- html_resource(font_awesome, Daniel@0: [ virtual(true) Daniel@0: , requires("//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css") Daniel@0: ]). Daniel@0: Daniel@0: :- html_resource(css('minimal.css'), [ ordered(true), requires([bootstrap, kube('kube.css')]) ]). Daniel@0: :- html_resource(css('minimal_doc.css'), [ requires([pldoc_css,css('minimal.css')]) ]). Daniel@0: :- html_resource(css('minimal_http_doc.css'), [ requires(css('minimal_doc.css')) ]). Daniel@0: :- html_resource(css('isearch_extra.css'), [ requires([css('minimal.css'),css('interactive_search.css')]) ]). Daniel@0: Daniel@0: :- multifile user:body//2. Daniel@0: Daniel@0: user:body(user(App),Body) --> Daniel@0: {member(App,[search,isearch])}, Daniel@0: use_font("Source Sans Pro",sourcepro), Daniel@0: use_font("pre, code, .code, .editor","Source Code Pro",sourcepro), Daniel@0: html_requires(css('isearch_extra.css')), Daniel@0: html(body(class(kubepage),Body)). Daniel@0: Daniel@0: style_style(cliopatria(http_help), 'margin-left:auto;margin-right:auto;width:95%;max-width:160ex') :- !. Daniel@0: style_style(cliopatria(wide), 'margin-left:auto;margin-right:auto;width:90%'). Daniel@0: style_style(cliopatria(_), 'margin-left:auto;margin-right:auto;width:80%;max-width:105ex'). Daniel@0: style_style(pldoc(object(_)), 'margin-left:auto;margin-right:auto;width:80%;max-width:160ex') :- !. Daniel@0: style_style(pldoc(_), 'margin-left:auto;margin-right:auto;width:80%;max-width:120ex') :- !. Daniel@0: Daniel@0: style_css(cliopatria(http_help), 'minimal_http_doc.css') :- !. Daniel@0: style_css(pldoc(_), 'minimal_doc.css') :- !. Daniel@0: style_css(_, 'minimal.css'). Daniel@0: Daniel@0: cliopatria:page_body(cliopatria(bare), Body) --> !, Daniel@0: {debug(skin,"Serving page with style: ~w.\n",[plain])}, Daniel@0: html_requires(css('minimal.css')), Daniel@0: use_font("Source Sans Pro",sourcepro), Daniel@0: use_font("pre, code, .code, .editor","Source Code Pro",sourcepro), Daniel@0: html(body(class=['kubepage',cliopatria], Body)). Daniel@0: Daniel@0: cliopatria:page_body(cliopatria(bare(http_doc)), Body) --> !, Daniel@0: {debug(skin,"Serving page with style: ~w.\n",[bare(http_doc)])}, Daniel@0: html_requires(css('minimal_http_doc.css')), Daniel@0: use_font("Source Sans Pro",sourcepro), Daniel@0: use_font("pre, code, .code, .editor","Source Code Pro",sourcepro), Daniel@0: html(body(class=['kubepage',cliopatria], Body)). Daniel@0: Daniel@0: cliopatria:page_body(Style, Body) --> !, Daniel@0: {debug(skin,"Serving page with style: ~w.\n",[Style])}, Daniel@0: {style_style(Style,BodyStyle), style_css(Style,CSS)}, Daniel@0: html_post(head, meta([name(viewport), content("width-device-width,initial-scale=1")]) ), Daniel@0: html_requires(css(CSS)), Daniel@0: html_requires('//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js'), Daniel@0: Daniel@0: % html_requires(cliopatria), Daniel@0: %html_requires(kube('kube.css')), Daniel@0: use_font("Source Sans Pro",sourcepro), Daniel@0: use_font("pre, code, .code, .editor","Source Code Pro",sourcepro), Daniel@0: Daniel@0: html(body( [ class=['kubepage',cliopatria]], Daniel@0: Daniel@0: % Version with wide navbar Daniel@0: [ header(class=[group], div(style(BodyStyle), \clio_menu(inline_search))) Daniel@0: , div([ style(BodyStyle) ], Daniel@0: [ div([id('cp-content'), class(content)], Body) Daniel@0: Daniel@0: % Original version with narrow navbar Daniel@0: % [ div([ style(BodyStyle) ], Daniel@0: % [ header(class=[group], \clio_menu(inline_search)) Daniel@0: % , div([id('cp-content'), class(content)], Body) Daniel@0: Daniel@0: , hr([style='margin-top:1em; margin-bottom:0.5em;',clear=all]) Daniel@0: , div([ style('font-size:smaller;text-align:right;') Daniel@0: , id('cp-footer'), class(footer)], Daniel@0: \server_address('ClioPatria')) Daniel@0: ]) Daniel@0: ])). Daniel@0: Daniel@0: cliopatria:page_body(Style,_) --> Daniel@0: {debug(skin,"Not serving page with style ~w.\n",[Style]), fail}. Daniel@0: Daniel@0: Daniel@0: clio_menu(full) --> Daniel@0: { findall(Key-Item, cp_menu:current_menu_item(Key, Item), Pairs0), Daniel@0: sort(Pairs0, Pairs), Daniel@0: group_pairs_by_key(Pairs, ByKey), Daniel@0: cp_menu:sort_menu_popups(ByKey, Menu), Daniel@0: maplist(translate_menu,Menu,Menu1) Daniel@0: }, Daniel@0: navbar('DML',['navbar-static-top'],navbar_menu(left,seqmap(navbar_item,Menu1))), Daniel@0: minimal_search. Daniel@0: Daniel@0: clio_menu(inline_search) --> Daniel@0: { findall(Key-Item, cp_menu:current_menu_item(Key, Item), Pairs0), Daniel@0: sort(Pairs0, Pairs), Daniel@0: group_pairs_by_key(Pairs, ByKey), Daniel@0: cp_menu:sort_menu_popups(ByKey, Menu), Daniel@0: maplist(translate_menu,Menu,Menu1) Daniel@0: }, Daniel@0: navbar('DML',['navbar-static-top'], Daniel@0: html([ \navbar_menu(left,seqmap(navbar_item,Menu1)) Daniel@0: , span(class('navbar-form navbar-right'), div(class('form-group'),\minimal_search)) Daniel@0: ])). Daniel@0: Daniel@0: Daniel@0: translate_menu(_-[Item],Link) :- Daniel@0: translate_item(Item,Link). Daniel@0: translate_menu(Key-Items,Menu) :- Daniel@0: cp_menu:menu_label(Key, Key, Label), Daniel@0: translate_dropdown(Label,Items,Menu). Daniel@0: Daniel@0: translate_dropdown(a(Attribs,Label),Items,menu(Label,[link('OpenID page',URL) | Items1])) :- !, Daniel@0: (Attribs=href(URL)-> true; memberchk(href(URL),Attribs)), Daniel@0: maplist(translate_item, Items, Items1). Daniel@0: Daniel@0: translate_dropdown(Label,Items,menu(Label,Items1)) :- Daniel@0: maplist(translate_item,Items,Items1). Daniel@0: Daniel@0: translate_item(item(_,Spec,Label),link(Label,Location)) :- Daniel@0: atom(Spec), Daniel@0: ( \+sub_atom(Spec, 0, _, _, 'http://'), Daniel@0: catch( http_dispatch:http_location_by_id(Spec, Location), E, Daniel@0: (print_message(informational, E), fail)) Daniel@0: -> true Daniel@0: ; Location = Spec Daniel@0: ). Daniel@0: Daniel@0: Daniel@0: minimal_search --> Daniel@0: html_post(head,style( Daniel@0: % ac_find_literal_container has class .yui-ac-container Daniel@0: [ ".yui-ac-content { background-color:#ffffff;padding:0ex;border: solid 1px #ddd; Daniel@0: box-shadow:0 6px 12px rgba(0,0,0,.175); Daniel@0: text-align:left; z-index:2;margin-top:1ex}" Daniel@0: , ".yui-ac-content { position:absolute;max-height:30em; overflow:auto; overflow-x:hidden; }" Daniel@0: , "input, select, input[type='search'], textarea { z-index:0 }" Daniel@0: , ".yui-ac-content ul {padding:0ex;margin:0ex;list-style-type:none}" Daniel@0: , ".yui-ac-content ul li {margin:0em;padding:0.5ex}" Daniel@0: , "li.yui-ac-highlight { background-color:#eee }" Daniel@0: % , "span.acmatch { background-color: #bbf; }" Daniel@0: , "span.acmatch { text-decoration:underline; Daniel@0: text-decoration-color:#5ca9e4; Daniel@0: -moz-text-decoration-color:#5ca9e4;}" Daniel@0: , "span.ac-builtin { color: blue; }" Daniel@0: , "span.ac-module { color: #888; }" Daniel@0: , "span.ac-exported { color: dark-green; }" Daniel@0: , "span.ac-private { color: red; }" Daniel@0: , "#search_form { margin-top:1ex; margin-bottom:1ex; text-align:right; }" Daniel@0: , "input#ac_find_literal_input { line-height:1.4em }" Daniel@0: ])), Daniel@0: html_post(head,script(type("text/javascript"), Daniel@0: "$(document).ready(function() { Daniel@0: console.log('Adjusting search box...'); Daniel@0: $('.yui-ac-input').attr('type','search').attr('placeholder','Search'); Daniel@0: $('.yui-ac-input').css('box-sizing','border-box').css('width','26ex'); Daniel@0: $('#ac_find_literal_complete').css('width','26ex'); Daniel@0: });")), Daniel@0: html(form([ id(search_form), action(location_by_id(cpa_browse:search)) ], Daniel@0: [ \(cp_simple_search:search_box([ name(q) ])) Daniel@0: % , \cp_menu:filter([]) Daniel@0: % , \cp_menu:select_handler([]) Daniel@0: ])). Daniel@0: