anyone know of tools for searching a statically generated site?

95 views
Skip to first unread message

Daniel Higginbotham

unread,
Aug 6, 2012, 2:29:50 PM8/6/12
to boston-r...@googlegroups.com
Are there any tools out there for adding search to a site which only consists of static files? I'm using nanoc (http://nanoc.stoneship.org/) to generate prose-like documentation (as opposed to more structured API documentation) for some projects which exist behind a firewall, so Google can't be used. Solr is possible, but I'd prefer not to use it. I'd like for the documentation to be completely self-contained.

One possibility would be create a static search index when the rest of the site is generated, and to use javascript to search against that index. It looks like this project would allow that: http://jssindex.sourceforge.net/ . However, it's pretty old and that makes me hesitant to try it out.

If anyone has any leads, I'd appreciate it :)

Daniel

Wyatt Greene

unread,
Aug 6, 2012, 3:37:45 PM8/6/12
to boston-r...@googlegroups.com
One possibility (of many) is to convert your app to a Rack app.  Have Rack simply serve up the files that were generated from nanoc.  But also, Rack can react to a POST request generated from a search form.  From there, you are in dynamic-web-app Ruby-land, where anything is possible! :)  If the collection of web pages isn't too big (or you are not expecting tons of traffic), you could even write your own search code in Ruby that simply looks in all of the HTML files and builds an HTML response of the search results.

--
You received this message because you are subscribed to the Boston Ruby Group mailing list
To post to this group, send email to boston-r...@googlegroups.com
To unsubscribe from this group, send email to boston-rubygro...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/boston-rubygroup

Daniel Choi

unread,
Aug 6, 2012, 6:41:36 PM8/6/12
to boston-r...@googlegroups.com


You may want to check out how sdoc generates the Rails API documentation. They seem to follow the same static searchable site generation strategy as jssindex but modernized:

https://github.com/voloko/sdoc/

Daniel Higginbotham

unread,
Aug 7, 2012, 7:22:04 AM8/7/12
to boston-r...@googlegroups.com
Thanks, I'll have a look

Bill Burton

unread,
Aug 7, 2012, 10:26:30 AM8/7/12
to boston-r...@googlegroups.com
Hello Daniel,

On Mon, Aug 6, 2012 at 2:29 PM, Daniel Higginbotham <dan...@flyingmachinestudios.com> wrote:
Are there any tools out there for adding search to a site which only consists of static files? I'm using nanoc (http://nanoc.stoneship.org/) to generate prose-like documentation (as opposed to more structured API documentation) for some projects which exist behind a firewall, so Google can't be used. Solr is possible, but I'd prefer not to use it. I'd like for the documentation to be completely self-contained.

One possibility would be create a static search index when the rest of the site is generated, and to use javascript to search against that index. It looks like this project would allow that: http://jssindex.sourceforge.net/ . However, it's pretty old and that makes me hesitant to try it out.

Since nanoc has a helper to generate a sitemap.xml file, you could try http://www.markus-olbrich.de/javascript/sitesearch/doc.html to support searching the sitemap.

A better approach might be to use Tipue Search (http://www.tipue.com/search/).  It requires generating a .js file with the data to support searching.  With nanoc, this would be extremely easy to implement by generating this .js file in the Rules file preprocess do ... end block in a similar manner to the way a sitemap.xml file is generated.

In either case, performing the normal "nanoc compile" to build the site will also generate the index used for the search and it should not really add much to the compile time unless the site is large or unless you opt to parse all the content to generate the index.

As I also maintain a nanoc site, I'd be interested to know what solution you end up using.

Hope this helps,
-Bill

Daniel Higginbotham

unread,
Aug 7, 2012, 10:45:42 AM8/7/12
to boston-r...@googlegroups.com
Thanks Bill! Tipue looks like exactly what I need. I'll definitely try it and let you know how it goes.

Daniel Higginbotham

unread,
Aug 8, 2012, 3:43:47 PM8/8/12
to boston-r...@googlegroups.com
So I got tipue search working at http://www.whoopsapp.com/ .  It wasn't too difficult. The nanoc project's at https://github.com/flyingmachine/whoops/tree/master/doc/site .

Here's the file where I generate the data for tipue:

Here's the line in my Rules file where I handle the above file (though I should probably just modify the case block on line 44):

Here's the search results page:

In this case I'm not sure how valuable it is as there are only three pages. But I do think it will be helpful for some of my other projects where there are multiple pages.

Thanks for the tip!

Daniel

On Aug 7, 2012, at 10:26 AM, Bill Burton wrote:

Reply all
Reply to author
Forward
0 new messages