Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gromnitsky/nfts

A FTS server for static blogs; uses sqlite under the hood.
https://github.com/gromnitsky/nfts

fts5 full-text-search jekyll sqlite

Last synced: about 4 hours ago
JSON representation

A FTS server for static blogs; uses sqlite under the hood.

Awesome Lists containing this project

README

        

# Naif Full Text Search

An FTS server for static blogs; uses sqlite under the hood.

# npm -g i nfts

## Jekyll Integration

To show how a real static blog can be augmented w/ FTS, we are going
to use the repo for the RoR blog:

~~~
$ git clone https://github.com/rails/weblog.git
$ cd weblog
$ bundle install
$ jekyll s --no-watch
~~~

Open http://127.0.0.1:4000 to browse the blog.

From a diff terminal:

~~~
$ cd weblog
$ nfts-create -o db.sqlite3 -p _posts/ _posts/*
$ nfts-server db.sqlite3
~~~

To test the server:

$ curl 'http://localhost:3000/?q=omg'

This should return an array of snippets.

Now

1. Edit `_includes/navigation.html` to add a link that is going to
invoke a search dialog:

  • Search
  • 2. Copy `web.js` file from the nfts installation dir to `weblog` dir &
    rename it to `nfts.js`. It's an es6 UMD w/ 0 dependencies.

    3. Add to `_config.yml`:

    ~~~
    nfts:
    dialog_toggle_btn: '#nfts__dialog_toggle'
    parent_container: 'main > article'
    server: http://localhost:3000
    debounce: 200
    ~~~

    4. Add the nfts initialisation to `_includes/navigation.html`:

    ~~~


    document.addEventListener('DOMContentLoaded', () => {
    new NftsDialog(JSON.parse('{{site.nfts | jsonify }}'),
    file => { // post
    let prefix = NftsDialog.date_fmt(file.slice(0,10))
    let basename = file.slice(10+1).replace(/\.[^.]+$/, '')
    return '{{site.url}}' + '/' + prefix + '/' + basename
    })
    })

    ~~~

    nfts integration is complete. Restart Jekyll, make sure it has
    completed the site regeneration & refresh the blog page in the
    browser, click "Search" & type "omg" (you don't need to press Enter).

    ## API

    TODO.

    ## License

    MIT