Skip to content

Commit ff4bad2

Browse files
author
NooBxGockeL
committed
Add search feature with google cse, fixes iluwatar#243
1 parent 83a4f90 commit ff4bad2

File tree

2 files changed

+42
-23
lines changed

2 files changed

+42
-23
lines changed

pages/patterns.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<div class="post-list-header">
1717
Patterns
1818
</div>
19+
<div class="pattern-cse">
20+
<gcse:search></gcse:search>
21+
</div>
1922
<div class="post-list-body">
2023

2124
{% assign allPatterns = site.pages | where:"layout","pattern" | sort: 'title' %}
@@ -79,4 +82,16 @@ <h2>{{ page.title }}</h2>
7982
{% endfor %}
8083
</div>
8184
</div>
85+
<script>
86+
(function() {
87+
var cx = '008960609897446712051:upn_v7v8dba';
88+
var gcse = document.createElement('script');
89+
gcse.type = 'text/javascript';
90+
gcse.async = true;
91+
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
92+
'//cse.google.com/cse.js?cx=' + cx;
93+
var s = document.getElementsByTagName('script')[0];
94+
s.parentNode.insertBefore(gcse, s);
95+
})();
96+
</script>
8297
</div>

static/css/index.css

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,6 @@ pre code{
2323
font-size: 16px;
2424
}
2525
26-
table{
27-
border-top:2px solid #777;
28-
border-bottom: 2px solid #777;
29-
margin: 8px 0;
30-
}
31-
table thead{
32-
border-bottom: 1px dashed #777;
33-
background-color: #aaa;
34-
color:#fff;
35-
}
36-
table th{
37-
padding: 2px 10px;
38-
}
39-
table tr:nth-child(2n){
40-
background-color: #E5EAED;
41-
}
42-
table td{
43-
padding: 2px 10px;
44-
vertical-align: top;
45-
}
46-
47-
4826
#index a:link {color: #005} /* 未访问的链接 */
4927
#index a:visited {color: #669} /* 已访问的链接 */
5028
#index a:hover {color: #336;text-decoration: none;} /* 鼠标移动到链接上 */
@@ -75,7 +53,7 @@ nav{
7553
-o-box-shadow: 0 1px 2px rgba(0,0,0,0.4),0 0 30px rgba(10,10,0,0.1) inset;
7654
box-shadow: 0 1px 2px rgba(0,0,0,0.4),0 0 30px rgba(10,10,0,0.1) inset;
7755
}
78-
.post-list-header{
56+
.post-list-header {
7957
padding: 15px 30px;
8058
border-bottom: 1px solid #c0c0c0;
8159
font-size: 30px;
@@ -491,3 +469,29 @@ blockquote:last-child {
491469
.top20 {
492470
margin-top: 20px
493471
}
472+
473+
-- fixes for bootstrap + google cse
474+
input.gsc-input,
475+
.gsc-input-box,
476+
.gsc-input-box-hover,
477+
.gsc-input-box-focus,
478+
.gsc-search-button {
479+
line-height: normal;
480+
}
481+
.cse .gsc-control-cse, .gsc-control-cse {
482+
background-color: rgba(0, 0, 0, 0) !important;
483+
border: rgba(0, 0, 0, 0) !important;
484+
}
485+
.gsc-search-box {
486+
margin-bottom: 0px !important;
487+
}
488+
.pattern-cse {
489+
border-bottom: 1px solid #c0c0c0;
490+
line-height: normal;
491+
}
492+
.pattern-cse * {
493+
box-sizing: content-box;
494+
}
495+
.pattern-cse table {
496+
border-collapse: separate;
497+
}

0 commit comments

Comments
 (0)