Add search functionality.

This commit is contained in:
Martin Taillefer 2017-04-29 11:07:05 -07:00
parent 93a42b5d4c
commit 183e3b6b30
11 changed files with 241 additions and 6 deletions

View File

@ -9,7 +9,7 @@ layout: docs
type: markdown
---
<script language="JavaScript">
<script type="text/javascript">
var forwarding=window.location.hash.replace("#","");
$( document ).ready(function() {
if(forwarding) {

17
_docs/search/index.md Normal file
View File

@ -0,0 +1,17 @@
---
title: Search Results
layout: search-results
bodyclass: search-results
---
<script>
(function() {
var cx = '013699703217164175118:veyyqmfmpj4';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:search></gcse:search>

View File

@ -10,8 +10,9 @@
<li role="presentation" {% if page.url == cat.url %}class='active'{% endif %}><a href="{{home}}{{ cat.url }}">{{ cat_name }}</a></li>
{% endif %}
{% endfor %}
</ul>
{% include contribute-links.html %}
</ul>
{% include search-box.html %}
{% include contribute-links.html %}
</div>
</div>
</div>

View File

@ -0,0 +1,3 @@
<div class="search-box">
<input type="text" class="search-input" placeholder="Search istio.io" onkeydown="if (event.keyCode==13) window.location.replace('/docs/search/?q=' + this.value)" autofocus="autofocus">
</div>

View File

@ -65,7 +65,8 @@
<![endif]-->
</head>
<body class={{page.bodyclass}}>
<script src="{{home}}/js/navtree.js"></script>
<script src="{{home}}/js/navtree.js"></script>
{{ content }}
<!-- Include all compiled plugins (below), or include individual files as needed -->

View File

@ -0,0 +1,18 @@
---
title: Search Results
layout: default
---
** WARNING ** The formatting on this page is under construction ** WARNING **
<div class="container">
<div class="row">
<div class="col-md-11 nofloat center-block ">
<div class="col-sm-7 {{page.type }}">
<div class="search-results">
{{ content }}
</div>
</div>
</div>
</div>
</div>

View File

@ -1,6 +1,6 @@
// Contribute links for Docs page
.docs .contribute-links {
top: 16px;
top: 3px;
}
// Contribute links for other pages
@ -11,7 +11,7 @@
// Contribute links
.contribute-links {
position: absolute;
right: 45px;
right: 245px;
top: 0;
display: none;
font-weight: 300;

View File

@ -0,0 +1,46 @@
.search-box {
width: 200px;
right: 10px;
top: 3px;
display: block;
position: absolute;
}
.search-box input {
position: relative;
height: 30px;
padding: 0 10px;
line-height: 30px;
font-size: 16px;
vertical-align: top;
background: #fff;
text-indent: 18px;
border-color: $mainBrandColor;
border-radius: 4px;
border-width: 1px;
background-image: url(/img/search-icon.svg);
background-repeat: no-repeat;
background-size: 16px 16px;
background-position: 4px 6px;
}
.search-box input::placeholder {
color: lighten($gray, 35%);
font-style: italic;
}
::-webkit-input-placeholder { /* Chrome/Opera/Safari */
color: pink;
}
::-moz-placeholder { /* Firefox 19+ */
color: pink;
}
:-ms-input-placeholder { /* IE 10+ */
color: pink;
}
:-moz-placeholder { /* Firefox 18- */
color: pink;
}

View File

@ -0,0 +1,133 @@
.search-results {
animation : none;
backface-visibility : visible;
background : 0;
background-attachment : scroll;
background-clip : border-box;
background-color : transparent;
background-image : none;
background-origin : padding-box;
background-position : 0 0;
background-position-x : 0;
background-position-y : 0;
background-repeat : repeat;
background-size : auto auto;
border : 0;
border-style : none;
border-width : medium;
border-color : inherit;
border-bottom : 0;
border-bottom-color : inherit;
border-bottom-left-radius : 0;
border-bottom-right-radius : 0;
border-bottom-style : none;
border-bottom-width : medium;
border-collapse : separate;
border-image : none;
border-left : 0;
border-left-color : inherit;
border-left-style : none;
border-left-width : medium;
border-radius : 0;
border-right : 0;
border-right-color : inherit;
border-right-style : none;
border-right-width : medium;
border-spacing : 0;
border-top : 0;
border-top-color : inherit;
border-top-left-radius : 0;
border-top-right-radius : 0;
border-top-style : none;
border-top-width : medium;
bottom : auto;
box-shadow : none;
box-sizing : content-box;
caption-side : top;
clear : none;
clip : auto;
color : inherit;
columns : auto;
column-count : auto;
column-fill : balance;
column-gap : normal;
column-rule-color : currentColor;
column-rule-style : none;
column-width : auto;
content : normal;
counter-increment : none;
counter-reset : none;
cursor : auto;
direction : ltr;
display : inline;
empty-cells : show;
float : none;
font-family : inherit;
font-size : medium;
font-style : normal;
font-variant : normal;
font-weight : normal;
height : auto;
hyphens : none;
left : auto;
letter-spacing : normal;
line-height : normal;
list-style : none;
list-style-image : none;
list-style-position : outside;
list-style-type : disc;
margin : 0;
margin-bottom : 0;
margin-left : 0;
margin-right : 0;
margin-top : 0;
max-height : none;
max-width : none;
min-height : 0;
min-width : 0;
opacity : 1;
outline : 0;
outline-style : none;
outline-width : medium;
overflow : visible;
overflow-x : visible;
overflow-y : visible;
padding : 0;
padding-bottom : 0;
padding-left : 0;
padding-right : 0;
padding-top : 0;
page-break-after : auto;
page-break-before : auto;
page-break-inside : auto;
perspective : none;
perspective-origin : 50% 50%;
position : static;
right : auto;
tab-size : 8;
table-layout : auto;
text-align : inherit;
text-align-last : auto;
text-decoration : none;
text-decoration-color : inherit;
text-decoration-line : none;
text-decoration-style : solid;
text-indent : 0;
text-shadow : none;
text-transform : none;
top : auto;
transform : none;
transform-style : flat;
transition : none;
transition-delay : 0s;
transition-duration : 0s;
transition-property : none;
transition-timing-function : ease;
unicode-bidi : normal;
vertical-align : baseline;
visibility : visible;
white-space : normal;
width : auto;
word-spacing : normal;
z-index : auto;
}

View File

@ -18,6 +18,7 @@ sitemap_exclude: y
@import "modules/_hero";
@import "modules/_nav";
@import "modules/_contribute-links";
@import "modules/_search-box";
@import "modules/_section-index";
@import "modules/_subscribe-form";
@ -28,4 +29,6 @@ sitemap_exclude: y
@import "pages/_about";
@import "pages/_community";
@import "pages/_contribute";
@import "pages/_search-results";
@import "materialize/materialize.scss";

13
img/search-icon.svg Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="575.996px" height="576px" viewBox="512 32 575.996 576" enable-background="new 512 32 575.996 576" xml:space="preserve">
<path fill="#3371E3" d="M1076.525,541.14L960.947,425.562c70.432-96.992,61.952-233.465-25.498-320.915
C887.015,56.218,823.533,32,760.051,32c-63.481,0-126.963,24.218-175.398,72.653c-96.87,96.871-96.87,253.926,0,350.796
c48.436,48.436,111.917,72.653,175.398,72.653c51.13,0,102.24-15.737,145.511-47.155l115.577,115.577
c7.643,7.648,17.671,11.476,27.693,11.476s20.051-3.827,27.693-11.476C1091.82,581.235,1091.82,556.436,1076.525,541.14z
M623.424,416.679c-75.334-75.335-75.334-197.92,0-273.255c36.493-36.493,85.018-56.595,136.627-56.595
c51.61,0,100.135,20.096,136.628,56.595c75.334,75.334,75.334,197.92,0,273.255c-36.493,36.492-85.018,56.595-136.628,56.595
C708.441,473.273,659.923,453.171,623.424,416.679z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB