Skip to content
This repository has been archived by the owner on Mar 26, 2023. It is now read-only.

Commit

Permalink
[Search] move to duckduckgo. close #187 (#353)
Browse files Browse the repository at this point in the history
- Use duckduckgo (#187)
- Add search box to main page
  • Loading branch information
jessesquires committed Jan 20, 2018
1 parent d3a7ac1 commit 428ded6
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 85 deletions.
25 changes: 25 additions & 0 deletions _includes/search_box.html
@@ -0,0 +1,25 @@
<!--
Sources:
https://duckduckgo.com/search_box
https://muffinresearch.co.uk/adding-a-duckduckgo-search-box-to-your-blog/
-->

<div class="row">
<div class="col-xs-12 col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2">
<form name="search" action="//duckduckgo.com/">
<div class="form-group">
<div class="input-group">
<input type="search" class="form-control" placeholder="DuckDuckGo" name="q">
<input type="hidden" value="swiftweekly.github.io" name="sites">
<input type="hidden" value="1" name="kh">
<input type="hidden" value="1" name="kn">
<input type="hidden" value="1" name="kac">
<input type="hidden" value="1" name="kc">
<span class="input-group-btn"><button class="btn btn-default" type="submit">
<i class="fa fa-search" aria-hidden="true"></i></button>
</span>
</div>
</div>
</form>
</div>
</div>
26 changes: 16 additions & 10 deletions index.html
Expand Up @@ -5,18 +5,24 @@

<div>

<div class="row">
<div class="row">
<div class="col-xs-10 col-xs-offset-1 col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
{% include hiatus.html %}
</div>
</div>
</div>

<div class="row">
<div class="col-xs-10 col-xs-offset-1 col-sm-8 col-sm-offset-2 col-md-8 col-md-offset-2">
{% include search_box.html %}
</div>
</div>

{% for post in site.posts %}
<article class="post">
<h1 class="post-title text-center">
<a href="{{ post.url }}">{{ post.title }}</a>
<small class="post-date">{{ post.date | date_to_string }}</small>
</h1>
</article>
{% endfor %}
{% for post in site.posts %}
<article class="post">
<h1 class="post-title text-center">
<a href="{{ post.url }}">{{ post.title }}</a>
<small class="post-date">{{ post.date | date_to_string }}</small>
</h1>
</article>
{% endfor %}
</div> <!-- post-list -->
77 changes: 2 additions & 75 deletions search.html
Expand Up @@ -3,79 +3,6 @@
title: Search issues
---

<style type="text/css">
/*
fix google custom search conflicts with bootstrap
solutions:
http://css-tricks.com/forums/topic/troubles-with-box-sizing-and-google-custom-search/
http://stackoverflow.com/questions/21932819/google-cse-with-twitter-bootstrap-not-displaying-the-search-box-correctly
*/
.cse:before, .cse:after {
-webkit-box-sizing: inherit;
-moz-box-sizing: inherit;
box-sizing: inherit;
}
<h1 class="text-center">{{ page.title }}</h1>

input.gsc-input,
.gsc-input-box,
.gsc-input-box-hover,
.gsc-input-box-focus,
.gsc-search-button {
box-sizing: content-box;
line-height: normal;
}

/*
other hacks for google custom search (gcs)
*/
.gcsc-branding,
.gsc-control-wrapper-cse,
.gsc-control-cse.gsc-control-cse-en {
background-color: #fff;
border-radius: 0.5em;
border-color: #d7d7d7;
}

a.gsst_a,
a.gcsc-branding-clickable {
text-decoration: none;
border-width: 0px;
}

#gs_cb50{
color: #f05138;
}

.gsc-webResult.gsc-result,
.gsc-webResult.gsc-result:hover {
background-color: #fff;
border-color: #fff;
}

.searchbox {
margin: 1rem 0rem 1rem 0rem;
}
</style>

<div class="searchbox">
<h1 class="text-center">{{ page.title }}</h1><br />
<script>
(function() {
var cx = '011538828544940938420:wtjft8gesai';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//cse.google.com/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>

<div class="row">
<div class="col-sm-8 col-sm-offset-2">
<gcse:search></gcse:search>
</div>
</div>

</div>
{% include search_box.html %}

0 comments on commit 428ded6

Please sign in to comment.