Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

First Commit with all the code and stuff to show you how I hosted the…

… Google CSE
  • Loading branch information...
commit 0b94b0193785472005f14301273e1c219512f889 0 parents
Paul Kinlan authored
30 app.yaml
@@ -0,0 +1,30 @@
+application: html5search
+version: 1
+runtime: python
+api_version: 1
+
+handlers:
+- url: /favicon\.ico
+ static_files: favicon.ico
+ upload: favicon\.ico
+
+- url: /
+ static_files: static/index.html
+ upload: static/index\.html
+
+- url: /index.html
+ static_files: static/index.html
+ upload: static/index\.html
+
+- url: /opensearch.xml
+ static_files: static/opensearch.xml
+ mime_type: application/opensearchdescription+xml
+ upload: static/opensearch.xml
+
+- url: /scripts
+ static_dir: scripts
+ mime_type: application/javascript
+
+- url: /search/.*
+ static_files: static/index.html
+ upload: static/index\.html5search
BIN  favicon.ico
Binary file not shown
11 index.yaml
@@ -0,0 +1,11 @@
+indexes:
+
+# AUTOGENERATED
+
+# This index.yaml is automatically updated whenever the dev_appserver
+# detects that a new type of query is run. If you want to manage the
+# index.yaml file manually, remove the above marker line (the line
+# saying "# AUTOGENERATED"). If you want to manage some indexes
+# manually, move them above the marker line. The index.yaml file is
+# automatically uploaded to the admin console when you next deploy
+# your application using appcfg.py.
33 main.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+#
+# Copyright 2007 Google Inc.
+#
+# 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.
+#
+from google.appengine.ext import webapp
+from google.appengine.ext.webapp import util
+
+
+class MainHandler(webapp.RequestHandler):
+ def get(self):
+ self.response.out.write('Hello world!')
+
+
+def main():
+ application = webapp.WSGIApplication([('/', MainHandler)],
+ debug=True)
+ util.run_wsgi_app(application)
+
+
+if __name__ == '__main__':
+ main()
15 scripts/leviroutes.js
@@ -0,0 +1,15 @@
+/*
+ Copyright 2011 Paul Kinlan
+
+ 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.
+*/var routes=function(){var a=[],b=this;this.parseRoute=function(a){return this.parseGroups=function(a){var b=new RegExp(":([^/.\\\\]+)","g"),c=""+a,d={},e=null,f=0;while(e=b.exec(a))d[e[1]]=f++,c=c.replace(e[0],"([^/.\\\\]+)");return c+="$",{groups:d,regexp:new RegExp(c)}},this.parseGroups(a)};var c=function(b,c){var d=null;for(var e=0;d=a[e];e++){var f=d.regex.regexp.exec(b);if(!!f==0)continue;var g={};for(var h in d.regex.groups){var i=d.regex.groups[h];g[h]=f[i+1]}var j={};if(c&&c.target instanceof HTMLFormElement){var k=c.target,l=k.length,m;for(var n=0;m=k[n];n++)!m.name||(j[m.name]=m.value)}return d.callback({url:b,params:g,values:j,e:c}),!0}return!1};this.get=function(b,c){a.push({regex:this.parseRoute(b),callback:c,method:"get"})},this.post=function(b,c){a.push({regex:this.parseRoute(b),callback:c,method:"post"})},this.test=function(a){c(a)},this.getRoutes=function(){return a};var d=function(){var a=!1,d=!1,e=!1;if(!!window.history&&!!window.history.pushState){var f=history.__proto__.pushState;history.__proto__.pushState=function(a,b,c){f.apply(history,arguments);var d=document.createEvent("Event");d.initEvent("statechanged",!1,!1),d.state=a,window.dispatchEvent(d);return}}b.run=function(){a||(c(document.location.pathname),a=!0)},window.addEventListener("submit",function(a){return a.target.method=="post"&&c(a.target.action,a)?(a.preventDefault(),!1):!0}),window.addEventListener("popstate",function(a){if(e){e=!1,d=!1;return}c(document.location.pathname),d=!0},!1),window.addEventListener("load",function(b){a||(c(document.location.pathname),a=!0),d=!0,e=!0},!1),window.addEventListener("hashchange",function(a){if(d){d=!1,e=!1;return}c(document.location.pathname)},!1)};d()}
210 static/index.html
@@ -0,0 +1,210 @@
+<title>HTML5 Search</title>
+<script src="/scripts/leviroutes.js"></script>
+<link rel="search"
+ href="http://www.html5search.com/opensearch.xml"
+ type="application/opensearchdescription+xml"
+ title="HTML5 Search" />
+<!-- Place this tag in the <head> of your document -->
+<div id="cse" style="width: 100%;">HTML5 Search Engine - searching all the best resources for HTML5, JS and CSS.</div>
+<script src="http://www.google.com/jsapi" type="text/javascript"></script>
+<script type="text/javascript">
+ google.load('search', '1', {language : 'en'});
+ google.setOnLoadCallback(function() {
+ var csc = new google.search.CustomSearchControl(
+ '012887599717425551906:mepdx2iop00');
+
+ csc.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
+ csc.draw('cse');
+ csc.setSearchStartingCallback(undefined, function(a,b,q) {
+ window.history.pushState(q, 'Results for ' + q, '/search/' + q);
+ })
+ var app = new routes();
+
+ app.get("/search/:query", function(req) {
+ var query = req.params.query;
+ // Do a search.
+ csc.execute(decodeURI(query));
+ });
+ }, true);
+</script>
+<link rel="stylesheet" href="http://www.google.com/cse/style/look/default.css" type="text/css" />
+<style type="text/css">
+body {
+ margin: 0;
+}
+
+#cse {
+ padding-top: 10px;
+ background: #eee;
+}
+
+form.gsc-search-box {
+ background: #eee;
+ -webkit-box-shadow: 0px 5px 5px #555;
+ margin-bottom: 5px;
+ padding:10px;
+ box-sizing: border-box;
+}
+
+
+ .gsc-control-cse {
+ font-family: Arial, sans-serif;
+ border-color: #eee;
+ padding: 0px 0px 0px 0px;
+ border: none;
+ }
+
+ .gsc-control-wrapper-cse {
+ }
+
+ .gsc-result-info {
+ padding: 10px;
+ }
+
+ input.gsc-input {
+ border-color: #BCCDF0;
+ font-size: 2em;
+ background-image: none !important;
+ }
+ input.gsc-search-button {
+ border-color: #666666;
+ background-color: #CECECE;
+ font-size: 2em;
+ }
+ .gsc-tabHeader.gsc-tabhInactive {
+ border-color: #E9E9E9;
+ background-color: #E9E9E9;
+ }
+ .gsc-tabHeader.gsc-tabhActive {
+ border-top-color: #FF9900;
+ border-left-color: #E9E9E9;
+ border-right-color: #E9E9E9;
+ background-color: #FFFFFF;
+ }
+ .gsc-tabsArea {
+ border-color: #E9E9E9;
+ }
+ .gsc-webResult.gsc-result,
+ .gsc-results .gsc-imageResult {
+ border-color: #FFFFFF;
+ background-color: #FFFFFF;
+ }
+ .gsc-webResult.gsc-result:hover,
+ .gsc-imageResult:hover {
+ border-color: #FFFFFF;
+ background-color: #FFFFFF;
+ }
+ .gs-webResult.gs-result a.gs-title:link,
+ .gs-webResult.gs-result a.gs-title:link b,
+ .gs-imageResult a.gs-title:link,
+ .gs-imageResult a.gs-title:link b {
+ color: #0000CC;
+ }
+ .gs-webResult.gs-result a.gs-title:visited,
+ .gs-webResult.gs-result a.gs-title:visited b,
+ .gs-imageResult a.gs-title:visited,
+ .gs-imageResult a.gs-title:visited b {
+ color: #0000CC;
+ }
+ .gs-webResult.gs-result a.gs-title:hover,
+ .gs-webResult.gs-result a.gs-title:hover b,
+ .gs-imageResult a.gs-title:hover,
+ .gs-imageResult a.gs-title:hover b {
+ color: #0000CC;
+ }
+ .gs-webResult.gs-result a.gs-title:active,
+ .gs-webResult.gs-result a.gs-title:active b,
+ .gs-imageResult a.gs-title:active,
+ .gs-imageResult a.gs-title:active b {
+ color: #0000CC;
+ }
+ .gsc-cursor-page {
+ color: #0000CC;
+ }
+ a.gsc-trailing-more-results:link {
+ color: #0000CC;
+ }
+ .gs-webResult .gs-snippet,
+ .gs-imageResult .gs-snippet,
+ .gs-fileFormatType {
+ color: #000000;
+ }
+ .gs-webResult div.gs-visibleUrl,
+ .gs-imageResult div.gs-visibleUrl {
+ color: #008000;
+ }
+ .gs-webResult div.gs-visibleUrl-short {
+ color: #008000;
+ }
+ .gs-webResult div.gs-visibleUrl-short {
+ display: none;
+ }
+ .gs-webResult div.gs-visibleUrl-long {
+ display: block;
+ }
+ .gsc-cursor-box {
+ border-color: #FFFFFF;
+ }
+ .gsc-results .gsc-cursor-box .gsc-cursor-page {
+ border-color: #E9E9E9;
+ background-color: #FFFFFF;
+ color: #0000CC;
+ }
+ .gsc-results .gsc-cursor-box .gsc-cursor-current-page {
+ border-color: #FF9900;
+ background-color: #FFFFFF;
+ color: #0000CC;
+ }
+ .gs-promotion {
+ border-color: #336699;
+ background-color: #FFFFFF;
+ }
+ .gs-promotion a.gs-title:link,
+ .gs-promotion a.gs-title:link *,
+ .gs-promotion .gs-snippet a:link {
+ color: #0000CC;
+ }
+ .gs-promotion a.gs-title:visited,
+ .gs-promotion a.gs-title:visited *,
+ .gs-promotion .gs-snippet a:visited {
+ color: #0000CC;
+ }
+ .gs-promotion a.gs-title:hover,
+ .gs-promotion a.gs-title:hover *,
+ .gs-promotion .gs-snippet a:hover {
+ color: #0000CC;
+ }
+ .gs-promotion a.gs-title:active,
+ .gs-promotion a.gs-title:active *,
+ .gs-promotion .gs-snippet a:active {
+ color: #0000CC;
+ }
+ .gs-promotion .gs-snippet,
+ .gs-promotion .gs-title .gs-promotion-title-right,
+ .gs-promotion .gs-title .gs-promotion-title-right * {
+ color: #000000;
+ }
+ .gs-promotion .gs-visibleUrl,
+ .gs-promotion .gs-visibleUrl-short {
+ color: #008000;
+ }
+ .gsc-adBlock {
+ padding: 5px;
+ background-color: #eee;
+ }
+</style>
+<script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-28238845-1']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+</script>
+<script>
+
+</script>
9 static/opensearch.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
+ <ShortName>HTML5 Search</ShortName>
+ <Description>Searches only the best HTML5, JS and CSS sites on the web.</Description>
+ <Tags>html5 html css js css3 web</Tags>
+ <Contact>paul.kinlan@gmail.com</Contact>
+ <Url type="text/html"
+ template="http://www.html5search.com/search/{searchTerms}"/>
+ </OpenSearchDescription>
Please sign in to comment.
Something went wrong with that request. Please try again.