GithubHelp home page GithubHelp logo

algolia-lansinoh's Introduction

Lansinoh Algolia Search for EE

This is repurposing of the Magento search extension for Algolia integration https://github.com/algolia/algoliasearch-magento-2

It uses:

Files

  • css - /src/css/algoliaSearch.css
  • templates - inline in /src/js/index.html
  • config file - /src/js/algoliaConfig.js (needs to be loaded before js)
  • js (prod) - /dist/algoliaSearch.bundle.js
  • js (dev) - /assets/algoliaSearch.bundle.js (has debug on so autocomplete stays open)
  • html:

For autocomplete:

<form id="search_mini_form" action="#" method="get">
    <div class="form-search">
        <input id="search" type="text" name="search" class="input-text algolia-autocomplete-input" autocomplete="off" spellcheck="false" autocorrect="off" autocapitalize="off" placeholder="Search">
        <button type="submit" title="Search" class="button">Search</button>
    </div>
    <div id="algolia-search-autocomplete-container"></div>
</form>

For instant search results page:

<div class="algolia-search-instant-selector">
    <div id="algolia-search-instant-container"></div>
</div>

Notes about implementation

The algoliaConfig.js is saved to window.algoliaConfig. It is not included in the bundle. It needs to be dynamic and will be generated from ee. This exact implementation will probably be altered once it's hooked up to ee.

The algoliaConfig contains the property indexName: 'lansinoh', the files add a suffix onto this, e.g. '_products' So indicies need to be names accordingly. Multiple indicies can be searched. For the autocomplete search they should be added to autocomplete.sections array. For the instant search, it is setup to look for '_products' and '_pages' indicies.

Templates

Templates were moved to be all inline in html to make them easier to edit. Notes on the additional setup are below, but not necessary.

Some templates are moustache. Those are compiled into one file. Hogan has a non-documented script that will compile the template:

node_modules/hogan.js/bin/hulk src/templates/*.hogan >> src/templates.temp.js

Copy this templates array output items into the src/templates.js file. This copying is necessary so the import wrapper is intact so the templates can be imported. I'm sure this process could be automated if there was active development. The html page does still contain some script templates which are not moustache templates, but referred to in the js via jquery and selectors. That could probably be normalized as well if necessary.

Build

This project uses Webpack to manage dependencies and bundle code.

Get all the dependencies:

npm install

Run webpack server to watch js and bundle:

npm run watch

Create production ready bundle:

npm run dist

algolia-lansinoh's People

Contributors

kellypacker avatar

Watchers

 avatar Alex Glover avatar Brian Larson avatar James Cloos avatar Andre Fredette avatar Shawn Maida avatar Phil Barbato avatar  avatar Adam Hake avatar Megan O'Sullivan avatar Jonathan Cox avatar Mike Smith avatar Brian Bell avatar Bryn Sartain avatar Paul Santos avatar Justin Alei avatar Adrian Calton avatar Steven M. Hernandez avatar Adam Tsai avatar Alan Koger avatar Matthew Zador avatar Alex Mejias 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.