localsearch

Create data files for local search via Tipue

To install, run nikola plugin -i localsearch

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 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.

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)

Suggested Configuration:

# 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.

SEARCH_FORM = """
<span class="navbar-form navbar-left">
<input type="text" id="tipue_search_input" class="form-control" placeholder="Search">
</span>"""

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>
$(document).ready(function() {
    $.when(
        $.getScript( "/assets/js/tipuesearch_set.js" ),
        $.getScript( "/assets/js/tipuesearch.js" ),
        $.Deferred(function( deferred ){
            $( deferred.resolve );
        })
    ).done(function() {
        $('#tipue_search_input').tipuesearch({
            'mode': 'json',
            'contentLocation': '/assets/js/tipuesearch_content.json'
        });
        $('#tipue_search_input').keyup(function (e) {
            if (e.keyCode == 13) {
                $('#search-results').modal()
            }
        });
    });
});
</script>
"""

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

Issues? Questions?

You can report issues with this plugin and request help via GitHub Issues.