cookutils rev 903

lighttpd/index.cgi: add OpenSearch: now you can add it to search bar to OpenSearch-able web browser (IE, Firefox). Add 'midnight' color theme.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Thu May 18 13:14:23 2017 +0300 (2017-05-18)
parents b03ac1e1213d
children d41948eec3e6
files lighttpd/cooker-midnight.css lighttpd/index.cgi
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/lighttpd/cooker-midnight.css	Thu May 18 13:14:23 2017 +0300
     1.3 @@ -0,0 +1,24 @@
     1.4 +@import url("cooker.css");
     1.5 +html,body{background:#333;color:#CCC}
     1.6 +section{background-color:#222;box-shadow:none}
     1.7 +tr:nth-child(2n){background:#2E2E2E!important}
     1.8 +tr:nth-child(2n+1){background:#222!important}
     1.9 +h2,h3{color:#999}
    1.10 +section,div.list{padding:2px}
    1.11 +section h2,section h3{background:#333}
    1.12 +.activity td:first-child,.cooknotes td:first-child,td.m{color:#888}
    1.13 +progress::-moz-progress-bar{background-color:hsla(200,40%,40%,0.7)}
    1.14 +progress::-webkit-progress-value{background-color:hsla(200,40%,40%,0.7)}
    1.15 +.meter span{color:#222}
    1.16 +.search input{background:#999;color:#000}
    1.17 +.button{color:#888}
    1.18 +.button.r{background:#444}
    1.19 +.button.receipt{background:hsl(80,100%,15%)}
    1.20 +.button.website{background:hsl(200,100%,15%)}
    1.21 +.button.files{background:hsl(50,100%,15%)}
    1.22 +.button.desc{background:hsl(180,100%,15%)}
    1.23 +.button.download{background:hsl(20,100%,15%)}
    1.24 +.button.source{background:hsl(60,100%,15%)}
    1.25 +.button.browse{background:hsl(170,100%,15%)}
    1.26 +.button.doc{background:hsl(300,100%,15%)}
    1.27 +.button.log{background:hsl(0,0%,15%)}
     2.1 --- a/lighttpd/index.cgi	Fri May 12 17:15:15 2017 +0300
     2.2 +++ b/lighttpd/index.cgi	Thu May 18 13:14:23 2017 +0300
     2.3 @@ -91,6 +91,7 @@
     2.4  	<title>$([ -n "$pkg" ] && echo "$pkg - ")$title</title>
     2.5  	<link rel="stylesheet" href="/$css">
     2.6  	<link rel="icon" type="image/png" href="/slitaz-cooker.png">
     2.7 +	<link rel="search" href="$base/os.xml" title="$title" type="application/opensearchdescription+xml">
     2.8  	<!-- mobile -->
     2.9  	<meta name="viewport" content="width=device-width, initial-scale=1.0">
    2.10  	<meta name="theme-color" content="#222">
    2.11 @@ -282,7 +283,7 @@
    2.12  	<p>Current theme: “${current:-default}”. Select other:</p>
    2.13  	<ul>
    2.14  		$(
    2.15 -			for i in default emerald sky goldenrod like2016 terminal; do
    2.16 +			for i in default emerald sky goldenrod midnight like2016 terminal; do
    2.17  				[ "$i" == "${current:-default}" ] || echo "<li><a href="$base/?theme=$i">$i</a></li>"
    2.18  			done
    2.19  		)
    2.20 @@ -292,7 +293,7 @@
    2.21  			page_footer
    2.22  			exit 0
    2.23  			;;
    2.24 -		default|emerald|sky|goldenrod|like2016|terminal)
    2.25 +		default|emerald|sky|goldenrod|midnight|like2016|terminal)
    2.26  			# Expires in a year
    2.27  			expires=$(date -uRd @$(($(date +%s)+31536000)) | sed 's|UTC|GMT|')
    2.28  			echo -e "HTTP/1.1 302 Found\nLocation: $base/\nCache-Control: no-cache\nSet-Cookie: theme=$theme; expires=$expires\n\n"
    2.29 @@ -359,6 +360,45 @@
    2.30  fi
    2.31  
    2.32  
    2.33 +### OpenSearch ###
    2.34 +
    2.35 +# Query '/os.xml': get OpenSearch Description
    2.36 +
    2.37 +if [ "$pkg" == 'os.xml' ]; then
    2.38 +	cat <<EOT
    2.39 +Content-Type: application/xml; charset=UTF-8
    2.40 +
    2.41 +<?xml version="1.0" encoding="UTF-8"?>
    2.42 +<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
    2.43 +	<ShortName>$title</ShortName>
    2.44 +	<Description>SliTaz packages search</Description>
    2.45 +	<Image width="16" height="16" type="image/png">http://$HTTP_HOST/images/logo.png</Image>
    2.46 +	<Url type="text/html" method="GET" template="http://$HTTP_HOST$base/{searchTerms}"/>
    2.47 +	<Url type="application/x-suggestions+json" method="GET" template="http://$HTTP_HOST$base/">
    2.48 +		<Param name="oss" value="{searchTerms}"/>
    2.49 +	</Url>
    2.50 +	<SearchForm>http://$HTTP_HOST$base/</SearchForm>
    2.51 +	<InputEncoding>UTF-8</InputEncoding>
    2.52 +</OpenSearchDescription>
    2.53 +EOT
    2.54 +	exit 0
    2.55 +fi
    2.56 +
    2.57 +# Query '?oss[=<term>]': OpenSearch suggestions
    2.58 +
    2.59 +if [ -n "$(GET oss)" ]; then
    2.60 +	term="$(GET oss | tr -cd '[:alnum:]+-')"
    2.61 +	echo -e 'Content-Type: application/x-suggestions+json; charset=UTF-8\n'
    2.62 +	cd $wok
    2.63 +	ls | fgrep "$term" | head -n10 | awk -vterm="$term" '
    2.64 +		BEGIN{printf("[\"%s\",[", term)}
    2.65 +		     {printf("%s\"%s\"", NR != 1 ? "," : "", $0)}
    2.66 +		END  {printf("]]")}
    2.67 +		'
    2.68 +		exit 0
    2.69 +fi
    2.70 +
    2.71 +
    2.72  
    2.73  
    2.74  #