Skip to content
Permalink
Browse files
localsearch: replace strange config samples with working setup from i…
…rclogs-site

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Mar 26, 2018
1 parent 889c863 commit b37106608ecdae59249afc515cf99a998b35f30e
@@ -1,11 +1,14 @@
If you don't want to depend on Google or DuckDuckGo to implement search for you,
or just want it to work even if you are offline, enable this plugin and the
search will be performed client side. It uses [Tipue](http://www.tipue.com/search/) as its engine.
search will be performed client side. It uses [Tipue Search](http://www.tipue.com/search/) as its engine.

After you build your site, you will have several new files in assets/css and assets/js
and a tipue_search.html that you can use as a basis for using this in your site.
In ordrer to set up Tipue, you will need:

For more information about how to customize it and use it, please refer to the tipue
* the sample config from `conf.py.sample`
* a page set up to render `localsearch.tmpl` (which you may customize) —
an example is in `search-EXAMPLE.html`

For more information about how to customize it and use it, please refer to the Tipue
docs at http://www.tipue.com/search/

Tipue is under an MIT license (see MIT-LICENSE.txt)
@@ -1,57 +1,17 @@
# This is an example that works well with Nikola's default Bootstrap3 theme.
# It displays the search field in the navigation bar, and the results
# in a modal dialog.
import json
# on a separate page (which needs to be configured, see README.md).
# This snippet assumes the page ends up at /search/.

SEARCH_FORM = """
<span class="navbar-form navbar-left">
<input type="text" id="tipue_search_input" class="form-control" placeholder="Search">
</span>"""
<form class="navbar-form navbar-left" action="/search/" role="search">
<div class="form-group">
<input type="text" class="form-control" id="tipue_search_input" name="q" placeholder="Search" autocomplete="off">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
"""

EXTRA_HEAD_DATA = """
<link rel="stylesheet" type="text/css" href="/assets/css/tipuesearch.css">
"""

BODY_END = """
<!-- Modal -->
<div id="search-results" class="modal fade" role="dialog" style="height: 80%;">
<div class="modal-dialog">

<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Search Results:</h4>
</div>
<div class="modal-body" id="tipue_search_content" style="max-height: 600px; overflow-y: auto;">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>

</div>
</div>
<script>
var siteUrl = """ + json.dumps(SITE_URL) + """
$(document).ready(function() {
$.when(
$.getScript( siteUrl + "/assets/js/tipuesearch_set.js" ),
$.getScript( siteUrl + "/assets/js/tipuesearch.js" ),
$.Deferred(function( deferred ){
$( deferred.resolve );
})
).done(function() {
$('#tipue_search_input').tipuesearch({
'mode': 'json',
'contentLocation': siteUrl + '/assets/js/tipuesearch_content.json'
});
$('#tipue_search_input').keyup(function (e) {
if (e.keyCode == 13) {
$('#search-results').modal()
}
});
});
});
</script>
"""
@@ -6,7 +6,7 @@ Module = localsearch
PluginCategory = LateTask

[Documentation]
Author = Roberto Alsina
Version = 0.1
Author = Roberto Alsina, Chris Warrick
Version = 0.2.0
Website = http://plugins.getnikola.com/#localsearch
Description = Create data files for local search via Tipue

This file was deleted.

@@ -0,0 +1,21 @@
{# -*- coding: utf-8 -*- #}
{% extends 'base.tmpl' %}
{% block content %}
<h1>Search</h1>
<noscript>Search requires JavaScript, sorry for the inconvenience.</noscript>
<div id="tipue_search_content">Use the search box in the navigation bar to search.</div>
{% endblock %}

{% block extra_js %}
<script src="/assets/js/tipuesearch_set.js"></script>
<script src="/assets/js/tipuesearch.js"></script>
<script>
$(document).ready(function() {
$('#tipue_search_input').tipuesearch({
'mode': 'json',
'contentLocation': '/assets/js/tipuesearch_content.json',
'showUrl': false
});
});
</script>
{% endblock %}
@@ -0,0 +1,21 @@
## -*- coding: utf-8 -*-
<%inherit file="base.tmpl"/>
<%block name="content">
<h1>Search</h1>
<noscript>Search requires JavaScript, sorry for the inconvenience.</noscript>
<div id="tipue_search_content">Use the search box in the navigation bar to search.</div>
</%block>

<%block name="extra_js">
<script src="/assets/js/tipuesearch_set.js"></script>
<script src="/assets/js/tipuesearch.js"></script>
<script>
$(document).ready(function() {
$('#tipue_search_input').tipuesearch({
'mode': 'json',
'contentLocation': '/assets/js/tipuesearch_content.json',
'showUrl': false
});
});
</script>
</%block>
@@ -0,0 +1,13 @@
<!--
.. title: Search
.. slug: search
.. date: 1970-01-01 00:00:00Z
.. tags:
.. category:
.. link:
.. description:
.. type: text
.. template: localsearch.tmpl
-->

<p style="display: none;">Search results appear here.</p>

0 comments on commit b371066

Please sign in to comment.