Code Monkey home page Code Monkey logo

nesta-plugin-search's Introduction

README

nesta-plugin-search is a plugin for the Nesta CMS use Ferret to index and search your site.

Installation

To install it as a gem add nesta-search to the Gemfile in your Nesta project, and then re-run bundle:

$ echo "gem 'nesta-plugin-search'" >> Gemfile
$ bundle

Text Search Usage

Create a /search page -- content/pages/search.haml -- here's an example:

%h1 Search Results
- if (results = search_results( search_index, params[:q] )) && !results.empty?
  %section.articles= article_summaries(results)
- else
  %h3 No articles found!

Add a searchbox to your layout, something like:

%form{:action => "/search"}
    %input{:type => "text", :name => "q", :value => "#{params[:q]||''}"}

Text Search Configuration

Set search_index_timeout to the number of seconds you want your default indexes to be stored for. By default, this is false, which never expires the index. It should be noted that reindexing is slow.

Set search_ignore_list to the abspath of the pages you want to be excluded from the search index. "/search" is forcefully excluded always and "/" is the default.

Example:

search_index_timeout: 3600
search_ignore_list:
- /
- /foo
- /foo/bar

IMPORTANT NOTE: If you're not using "/search" as your search page, please add it to this list or bad things may happen.

Advanced Usage Notes

Provided Index Helpers:

  • search_index -- an index of all pages and articles.
  • article_index -- an index of articles only.

Creating your own index:

- my_index = Nesta::Plugin::Search::Index.new( :my_find_method ).index
%h1 Search Results
- if (results = search_results( my_index, params[:q] )) && !results.empty?
  %section.articles= article_summaries(results)
- else
  %h3 No articles found!

If you want to pregenerate your cache to disk and load it that way, it would be something like this:

- existing_index = Ferret::Index::Index.new(:path => "/path/to/existing/index")
%h1 Search Results
- if (results = search_results( existing_index, params[:q] )) && !results.empty?
  %section.articles= article_summaries(results)
- else
  %h3 No articles found!

nesta-plugin-search's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.