2017 © Pedro Peláez
 

sculpin-bundle sculpin-search-bundle

Provides search in static site via indextank search engine

image

jbouzekri/sculpin-search-bundle

Provides search in static site via indextank search engine

  • Monday, July 21, 2014
  • by jbouzekri
  • Repository
  • 1 Watchers
  • 1 Stars
  • 60 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 11 % Grown

The README.md

SculpinSearchBundle

This bundle provides a search engine using indextank service for your static site., (*1)

You can use the service Indexden., (*2)

You can see a working demo on the right column of my personal french blog., (*3)

Installation

Using composer, add the dependancy to your composer.json :, (*4)

``` json "require": { "jbouzekri/sculpin-search-bundle": "1.*", "flaptor/indextank-php": "@dev" }, "repositories": [ { "type": "vcs", "url": "https://github.com/flaptor/indextank-php" } ], (*5)


And run the composer update command (indextank must be declared in your composer.json because the current stable version does not include the composer file moreover it is not yet on packagist so the repositories part is required) Enable the bundle. If you have already have an app/SculpinKernel.php, add this bundle to it otherwise create the file with the following content : ``` php <?php class SculpinKernel extends \Sculpin\Bundle\SculpinBundle\HttpKernel\AbstractKernel { protected function getAdditionalSculpinBundles() { return array( 'Jb\Bundle\SearchBundle\JbSearchBundle' ); } }

Then you need to configure the indextank service in sculpin_kernel.yml :, (*6)

``` yml jb_search: options: url: http://login.api.indexden.com user: "Your login here" password: "Your password here" index: "The name of your index", (*7)


If you use indexden, you can use the private url to fill this parameters : http://:password@login.api.indexden.com Usage ----- On each post you want to index, add the indexed: true data in the markdown part of the file. ``` md --- indexed: true ---

You can now regenerate your site., (*8)

You can now add a form HTML markup to your site :, (*9)

``` html , (*10)


This bundle provides a simple indextank client library in js you can use. Add the Resources/public/js/indextank_client.js to your project. You can now use the following code to update your list of posts when performing a search : ``` js $('#search-form').indexTank({ url: "http://login.api.indexden.com", index: "index_name", display: function(result) { if (result.matches == 0) { $('.entries').html('<li>No result</li>'); return; } var html = ""; for (id in result.results) { var date = new Date(result.results[id].date*1000); html += '\ <li> \ <small>' + date.getDate()+'/'+date.getMonth()+'/'+date.getFullYear() + '</small> \ <a href="' + result.results[id].link + '">' + result.results[id].title + '</a> \ </li>'; } $('.entries').html(html); } });

How it works

An event listener is bind to the afterRun event. It indexes in indextank all documents marked with the indexed flag., (*11)

When indexing, it clears the index and bulk add the selected sources so it can take some times to generate the site when you index a lot of document., (*12)

Because of that, I added a generate command which wrap the original sculpin generate one in order to add an option no-index. When runing this command, you can work on your static site and the content will not be indexed each time you change something in a file. (However do not forget to launch the generate command without this parameter at the end to update your index in the search service)., (*13)

``` bash $ php sculpin generate-search --server --watch --no-index, (*14)


Configuration Reference ----------------------- ``` yml jb_search: enabled: true # enable the indexation at the end of the generate task engine: indextank # change the engine (for now only indextank is supported) options: url: http://login.api.indexden.com user: "Your login here" password: "Your password here" index: "The name of your index"

License

MIT, (*15)

The Versions

21/07 2014

dev-master

9999999-dev https://github.com/jbouzekri/SculpinSearchBundle

Provides search in static site via indextank search engine

  Sources   Download

MIT

The Requires

  • flaptor/indextank-php @dev

 

php search bundle sculpin indextank

16/07 2014

1.0.1

1.0.1.0 https://github.com/jbouzekri/SculpinSearchBundle

Provides search in static site via indextank search engine

  Sources   Download

MIT

The Requires

  • flaptor/indextank-php @dev

 

php search bundle sculpin indextank

16/07 2014

1.0.0

1.0.0.0 https://github.com/jbouzekri/SculpinSearchBundle

Provides search in static site via indextank search engine

  Sources   Download

MIT

The Requires

  • flaptor/indextank-php dev-master

 

php search bundle sculpin indextank