Commit 2d5cf1ff authored by Alexandra Rogova's avatar Alexandra Rogova

elasticlunr

parent 852f9e93
*~
.DS_Store
.DS_Store?
/node_modules
language: node_js
before_script: "node server.js 3000 &"
script: "phantomjs test/env/runner.js http://localhost:3000/test"
node_js:
- "6.9.5"
This diff is collapsed.
Contributions are very welcome. To make the process as easy as possible please follow these steps:
* Open an issue detailing the bug you've found, or the feature you wish to add. Simplified working examples using something like [jsFiddle](http://jsfiddle.net) make it easier to diagnose your problem.
* Add tests for your code (so I don't accidentally break it in the future).
* Don't change version numbers or make new builds as part of your changes.
* Don't change the built versions of the library; only make changes to code in the `lib` directory.
# Developer Dependencies
A JavaScript runtime is required for building the library.
Run the tests (using PhantomJS):
make test
The tests can also be run in the browser by starting the test server:
make server
This will start a server on port 3000, the tests are then available at `/test`.
Copyright (C) 2017 by Wei Song
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
SRC = lib/elasticlunr.js \
lib/utils.js \
lib/event_emitter.js \
lib/tokenizer.js \
lib/pipeline.js \
lib/index.js \
lib/document_store.js \
lib/stemmer.js \
lib/stop_word_filter.js \
lib/trimmer.js \
lib/inverted_index.js \
lib/configuration.js \
lib/sorted_set.js
YEAR = $(shell date +%Y)
VERSION = $(shell cat VERSION)
SERVER_PORT ?= 3000
TEST_PORT ?= 32423
DOXX ?= ./node_modules/.bin/doxx
NODE ?= /usr/bin/node
NPM ?= /usr/bin/npm
PHANTOMJS ?= ./node_modules/.bin/phantomjs
UGLIFYJS ?= ./node_modules/.bin/uglifyjs
all: node_modules elasticlunr.js elasticlunr.min.js docs bower.json package.json component.json example
elasticlunr.js: $(SRC)
cat build/wrapper_start $^ build/wrapper_end | \
sed "s/@YEAR/${YEAR}/" | \
sed "s/@VERSION/${VERSION}/" > $@
cp $@ ./release/
cp $@ ./example/
elasticlunr.min.js: $(SRC)
cat build/wrapper_start $^ build/wrapper_end | \
sed "s/@YEAR/${YEAR}/" | \
sed "s/@VERSION/${VERSION}/" | \
${UGLIFYJS} --compress --mangle --comments > $@
cp $@ ./release/
cp $@ ./example/
%.json: build/%.json.template
cat $< | sed "s/@VERSION/${VERSION}/" > $@
size: elasticlunr.min.js
@gzip -c elasticlunr.min.js | wc -c
server:
${NODE} server.js ${SERVER_PORT}
test: node_modules
@./test/runner.sh ${TEST_PORT}
docs: node_modules
${DOXX} --source lib --target docs
clean:
rm -f elasticlunr.js
rm -f elasticlunr.min.js
rm -f *.json
rm -f example/example_index.json
rm -rf docs/*
clean_modules:
rm -rf node_modules
reset:
git checkout elasticlunr.* *.json docs/index.html example/example_index.json
example: elasticlunr.min.js
${NODE} example/index_builder.js
node_modules: package.json
${NPM} -s install
.PHONY: test clean docs reset example
This diff is collapsed.
{
"name": "elasticlunr.js",
"version": "0.9.5",
"main": "elasticlunr.js",
"ignore": [
"tests/",
"perf/",
"build/",
"docs/"
]
}
{
"name": "elasticlunr.js",
"version": "@VERSION",
"main": "elasticlunr.js",
"ignore": [
"tests/",
"perf/",
"build/",
"docs/"
]
}
{
"name": "elasticlunr",
"repo": "weixsong/elasticlunr.js",
"version": "@VERSION",
"description": "Lightweight full-text search engine in Javascript for browser search and offline search.",
"license": "MIT",
"main": "elasticlunr.js",
"scripts": ["elasticlunr.js"]
}
{
"name": "elasticlunr",
"description": "Lightweight full-text search engine in Javascript for browser search and offline search.",
"version": "@VERSION",
"author": "Wei Song",
"keywords": ["search", "text retrieval", "offline search", "full text search"],
"homepage": "http://weixsong.github.io",
"bugs": "https://github.com/weixsong/elasticlunr.js/issues",
"main": "elasticlunr.js",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/weixsong/elasticlunr.js"
},
"devDependencies": {
"doxx": "1.4.0",
"phantomjs": "1.9.8",
"uglify-js": "2.4.13"
},
"scripts": {
"test": "make test"
}
}
#!/usr/bin/env bash
file_has_changed () {
if [ ! -f $1 ]; then
return 1
fi
for f in `git ls-files --modified`; do
[[ "$f" == "$1" ]] && return 0
done
return 1
}
version_is_unique () {
for v in `git tag -l`; do
[[ "$v" == "v$1" ]] && return 1
done
return 0
}
on_master_branch () {
[[ $(git symbolic-ref --short -q HEAD) == "master" ]] && return 0
return 1
}
version=$(cat VERSION)
previous_version=$(git describe --abbrev=0)
if ! on_master_branch; then
echo -e "\033[0;31mRefusing to release from non master branch.\033[0m"
exit 1
fi
if ! file_has_changed "VERSION"; then
echo -e "\033[0;31mRefusing to release because VERSION has not changed.\033[0m"
exit 1
fi
if ! file_has_changed "CHANGELOG.mdown"; then
echo -e "\033[0;31mRefusing to release because CHANGELOG.mdown has not been updated.\033[0m"
exit 1
fi
if ! file_has_changed "package.json"; then
echo -e "\033[0;31mRefusing to release because package.json has not been updated.\033[0m"
exit 1
fi
if ! version_is_unique $version; then
echo -e "\033[0;31mRefusing to release because VERSION is not unique.\033[0m"
exit 1
fi
echo -e "\033[1mAbout to release v$version with the following changes:\033[0m"
git log --date=short --pretty=format:"%ad %h%x09%an%x09%s" $previous_version..HEAD
echo
echo -e "\033[1mThe following files will be part of the release commit:\033[0m"
git ls-files --modified
echo
read -e -p "Are you sure you want to release? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo -e "\033[0;32mReleasing...\033[0m"
echo
git commit -a -m "Build version $version"
git tag -a v$version -m "Version $version"
git push origin master
git push --tags
npm publish
git checkout gh-pages
git checkout master example docs README.md elasticlunr.js elasticlunr.min.js
git commit -a -m "Build version $version"
git push origin gh-pages
git checkout master
else
echo -e "\033[0;31mCancelling...\033[0m"
fi
/**
* export the module via AMD, CommonJS or as a browser global
* Export code from https://github.com/umdjs/umd/blob/master/returnExports.js
*/
;(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(factory)
} else if (typeof exports === 'object') {
/**
* Node. Does not work with strict CommonJS, but
* only CommonJS-like enviroments that support module.exports,
* like Node.
*/
module.exports = factory()
} else {
// Browser globals (root is window)
root.elasticlunr = factory()
}
}(this, function () {
/**
* Just return a value to define the module export.
* This example returns an object, but the module
* can return a function as the exported value.
*/
return elasticlunr
}))
})();
/**
* elasticlunr - http://weixsong.github.io
* Lightweight full-text search engine in Javascript for browser search and offline search. - @VERSION
*
* Copyright (C) @YEAR Oliver Nightingale
* Copyright (C) @YEAR Wei Song
* MIT Licensed
* @license
*/
(function(){
{
"name": "elasticlunr",
"repo": "weixsong/elasticlunr.js",
"version": "0.9.5",
"description": "Lightweight full-text search engine in Javascript for browser search and offline search.",
"license": "MIT",
"main": "elasticlunr.js",
"scripts": ["elasticlunr.js"]
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
/* Sticky footer styles
-------------------------------------------------- */
html {
position: relative;
min-height: 100%;
}
body {
/* Margin bottom by footer height */
margin-bottom: 60px;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
/* Set the fixed height of the footer here */
height: 60px;
background-color: #F0EDE3;
}
/* Custom page CSS
-------------------------------------------------- */
/* Not required for template or sticky footer method. */
body > .container {
padding: 90px 15px 0;
}
.container .text-muted {
margin: 0px 0;
}
.footer > .container {
padding-right: 15px;
padding-left: 15px;
}
code {
font-size: 80%;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<div>
<ul style="margin-left: 0px; margin-right: 0px; padding-left: 0px;">
{{#questions}}
<li data-question-id="{{id}}">
<h2><a href="#">{{title}}</a></h2>
<p>{{tags}}</p>
</li>
{{/questions}}
</ul>
</div>
<h2><strong>{{title}}</strong></h2>
<p><i>Tags: {{tags}}</i></p>
<div>{{{body}}}</div>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment