Skip to content

Commit

Permalink
Enabled open search integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Paddy Foran committed Mar 1, 2012
1 parent c6a03ec commit 0f6ea7c
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
2 changes: 2 additions & 0 deletions _config.yml
@@ -1,3 +1,5 @@
permalink: /:title permalink: /:title
auto: true auto: true
server: true server: true
domain: "localhost:4000"
google_cse_id: 012672112220120861281:u1mwwky5lri
6 changes: 6 additions & 0 deletions _layouts/default.html
Expand Up @@ -39,6 +39,12 @@
{% if page.section == "worker" %} {% if page.section == "worker" %}
{% include sidemenu_worker.html %} {% include sidemenu_worker.html %}
{% endif %} {% endif %}

{% if page.section == "search" %}
<p style="width: 100%; text-align: center;">
<a href="#" id="addSearch">Search From Your Browser</a>
</p>
{% endif %}
</div> </div>


<div style="float: left; width: 688px" class="content"> <div style="float: left; width: 688px" class="content">
Expand Down
27 changes: 27 additions & 0 deletions open-search.xml
@@ -0,0 +1,27 @@
---
---
<?xml version="1.0" encoding="UTF-8"?>
<!--
open-search.xhtml
Copyright 2009 Jack Leow
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--><OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>Iron.io Docs</ShortName>
<Description>Documentation for Iron.io services.</Description>
<Image width="16" height="16" type="image/x-icon">http://{{ site.domain }}/favicon.ico
</Image>
<Url type="text/html" method="get" template="http://{{ site.domain }}/search/?q={searchTerms}"></Url>
<Url type="application/x-suggestions+json" method="get" template="http://www.google.com/complete/search?q={searchTerms}&amp;partnerid={{ site.google_cse_id }}&amp;ds=cse&amp;output=firefox"></Url>
</OpenSearchDescription>
12 changes: 10 additions & 2 deletions search/index.html
@@ -1,6 +1,7 @@
--- ---
title: Search Results title: Search Results
layout: default layout: default
section: search
--- ---


<h1>Search Results</h1> <h1>Search Results</h1>
Expand All @@ -25,7 +26,7 @@ <h1>Search Results</h1>
google.setOnLoadCallback(function () { google.setOnLoadCallback(function () {
var customSearchOptions = {}; var customSearchOptions = {};
var customSearchControl = new google.search.CustomSearchControl( var customSearchControl = new google.search.CustomSearchControl(
'012672112220120861281:u1mwwky5lri', customSearchOptions); '{{ site.google_cse_id }}', customSearchOptions);
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET); customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
var options = new google.search.DrawOptions(); var options = new google.search.DrawOptions();
options.enableSearchResultsOnly(); options.enableSearchResultsOnly();
Expand All @@ -35,6 +36,13 @@ <h1>Search Results</h1>
customSearchControl.execute(queryFromUrl); customSearchControl.execute(queryFromUrl);
} }
}, true); }, true);

$('#addSearch').click(function(e) {
e.preventDefault();
var url = "http://{{ site.domain }}/open-search.xml";
window.external.AddSearchProvider(url);
});

</script> </script>
<link rel="stylesheet" href="http://www.google.com/cse/style/look/default.css" type="text/css" /> <link rel="stylesheet" href="http://www.google.com/cse/style/look/default.css" type="text/css" />
<style type="text/css"> <style type="text/css">
Expand Down Expand Up @@ -212,4 +220,4 @@ <h1>Search Results</h1>
background : none repeat scroll 0% 0% white !important; background : none repeat scroll 0% 0% white !important;
} }


</style> </style>

0 comments on commit 0f6ea7c

Please sign in to comment.