Skip to content

Commit 1a0a2b7

Browse files
committed
Merge pull request ming300#1 from olivernn/master
20140623pull
2 parents a511e35 + f1cdf61 commit 1a0a2b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+11853
-9109
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/node_modules

.travis.yml

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
language: node_js
2-
before_script:
3-
- node server.js &
4-
- sleep 5
2+
before_script: "node server.js 3000 &"
3+
script: "phantomjs test/env/runner.js http://localhost:3000/test"
54
node_js:
6-
- 0.8
7-
script:
8-
- npm test
5+
- "0.8"
6+
- "0.10"

CHANGELOG.mdown

+47
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,52 @@
11
# Changelog
22

3+
## 0.5.3
4+
5+
* Correctly stem words ending with the letter 'y' [#84](https://github.com/olivernn/lunr.js/pull/84) thanks [Mihai Valentin](https://github.com/MihaiValentin)
6+
* Improve build tools and dev dependency installation [#78](https://github.com/olivernn/lunr.js/pull/78) thanks [Ben Pickles](https://github.com/benpickles)
7+
8+
## 0.5.2
9+
10+
* Use npm they said, it'll be easy they said.
11+
12+
## 0.5.1
13+
14+
* Because [npm issues](https://github.com/olivernn/lunr.js/issues/77) :(
15+
16+
## 0.5.0
17+
18+
* Add plugin support to enable i18n and other extensions to lunr.
19+
* Add AMD support [#72](https://github.com/olivernn/lunr.js/issues/72) thanks [lnwdr](https://github.com/lnwdr).
20+
* lunr.Vector now implemented using linked lists for better performance especially in indexes with large numbers of unique tokens.
21+
* Build system clean up.
22+
23+
## 0.4.5
24+
25+
* Fix performance regression introduced in 0.4.4 by fixing #64.
26+
27+
## 0.4.4
28+
29+
* Fix bug [#64](https://github.com/olivernn/lunr.js/issues/64) idf cache should handle tokens with the same name as object properties, thanks [gitgrimbo](https://github.com/gitgrimbo).
30+
* Intersperse source files with a semicolon as part of the build process, fixes [#61](https://github.com/olivernn/lunr.js/issues/61), thanks [shyndman](https://github.com/shyndman).
31+
32+
## 0.4.3
33+
34+
* Fix bug [#49](https://github.com/olivernn/lunr.js/issues/49) tokenizer should handle null and undefined as arguments, thanks [jona](https://github.com/jona).
35+
36+
## 0.4.2
37+
38+
* Fix bug [#47](https://github.com/olivernn/lunr.js/issues/47) tokenizer converts its input to a string before trying to split it into tokens, thanks [mikhailkozlov](https://github.com/mikhailkozlov).
39+
40+
## 0.4.1
41+
42+
* Fix bug [#41](https://github.com/olivernn/lunr.js/issues/41) that caused issues when indexing mixed case tags, thanks [Aptary](https://github.com/Aptary)
43+
44+
## 0.4.0
45+
46+
* Add index mutation events ('add', 'update' and 'remove').
47+
* Performance improvements to searching.
48+
* Penalise non-exact matches so exact matches are better ranked than expanded matches.
49+
350
## 0.3.3
451

552
* Fix bug [#32](https://github.com/olivernn/lunr.js/pull/32) which prevented lunr being used where a `console` object is not present, thanks [Tony Marklove](https://github.com/jjbananas) and [wyuenho](https://github.com/wyuenho)

CNAME

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lunrjs.com

Makefile

+37-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
SRC = lib/lunr.js \
33
lib/utils.js \
4+
lib/event_emitter.js \
45
lib/tokenizer.js \
56
lib/pipeline.js \
67
lib/vector.js \
@@ -9,42 +10,59 @@ SRC = lib/lunr.js \
910
lib/document_store.js \
1011
lib/stemmer.js \
1112
lib/stop_word_filter.js \
12-
lib/token_store.js
13+
lib/trimmer.js \
14+
lib/token_store.js \
1315

1416
YEAR = $(shell date +%Y)
1517
VERSION = $(shell cat VERSION)
1618

17-
all: lunr.js lunr.min.js docs component.json package.json
19+
SERVER_PORT ?= 3000
20+
TEST_PORT ?= 32423
21+
22+
DOX ?= ./node_modules/.bin/dox
23+
DOX_TEMPLATE ?= ./node_modules/.bin/dox-template
24+
NODE ?= /usr/local/bin/node
25+
NPM ?= /usr/local/bin/npm
26+
PHANTOMJS ?= ./node_modules/.bin/phantomjs
27+
UGLIFYJS ?= ./node_modules/.bin/uglifyjs
28+
29+
all: node_modules lunr.js lunr.min.js docs bower.json package.json component.json example
1830

1931
lunr.js: $(SRC)
20-
cat $^ | \
32+
cat build/wrapper_start $^ build/wrapper_end | \
2133
sed "s/@YEAR/${YEAR}/" | \
2234
sed "s/@VERSION/${VERSION}/" > $@
2335

2436
lunr.min.js: lunr.js
25-
uglifyjs --compress --mangle --comments < $< > $@
26-
27-
component.json:
28-
cat build/component.json.template | sed "s/@VERSION/${VERSION}/" > $@
37+
${UGLIFYJS} --compress --mangle --comments < $< > $@
2938

30-
package.json:
31-
cat build/package.json.template | sed "s/@VERSION/${VERSION}/" > $@
39+
%.json: build/%.json.template
40+
cat $< | sed "s/@VERSION/${VERSION}/" > $@
3241

3342
size: lunr.min.js
34-
gzip -c lunr.min.js | wc -c
43+
@gzip -c lunr.min.js | wc -c
3544

36-
test_server:
37-
node server.js 3000
45+
server:
46+
${NODE} server.js ${SERVER_PORT}
3847

39-
test:
40-
phantomjs test/env/runner.js http://localhost:3000/test
48+
test: node_modules
49+
@./test/runner.sh ${TEST_PORT}
4150

42-
docs:
43-
dox < lunr.js | dox-template -n lunr.js -r ${VERSION} > docs/index.html
51+
docs: node_modules
52+
${DOX} < lunr.js | ${DOX_TEMPLATE} -n lunr.js -r ${VERSION} > docs/index.html
4453

4554
clean:
4655
rm -f lunr{.min,}.js
47-
rm component.json
48-
rm package.json
56+
rm *.json
57+
rm example/example_index.json
58+
59+
reset:
60+
git checkout lunr.* *.json docs/index.html example/example_index.json
61+
62+
example: lunr.min.js
63+
${NODE} example/index_builder.js
64+
65+
node_modules: package.json
66+
${NPM} -s install
4967

50-
.PHONY: test clean docs
68+
.PHONY: test clean docs reset example

README.mdown

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Contributions are very welcome, to make the process as easy as possible please f
6565
* 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.
6666
* Add tests for your code (so I don't accidentally break it in the future)
6767
* Don't change version numbers or make new builds as part of your changes
68+
* Don't change the built versions of the library, only make changes to code in the `lib` directory'
6869

6970
### Developer Dependencies
7071

@@ -76,7 +77,7 @@ Run the tests with, this will use phantomjs to run the tests:
7677

7778
The tests can also be run in the browser by starting the test server:
7879

79-
make test_server
80+
make server
8081

8182
This will start a server on port 3000, the tests are then available at '/test'
8283

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.3
1+
0.5.3

bower.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "lunr.js",
3+
"version": "0.5.3",
4+
"main": "lunr.js",
5+
"ignore": [
6+
"tests/",
7+
"perf/",
8+
"build/",
9+
"docs/"
10+
]
11+
}

build/bower.json.template

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "lunr.js",
3+
"version": "@VERSION",
4+
"main": "lunr.js",
5+
"ignore": [
6+
"tests/",
7+
"perf/",
8+
"build/",
9+
"docs/"
10+
]
11+
}

build/component.json.template

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
2-
"name": "lunr.js",
2+
"name": "lunr",
3+
"repo": "olivernn/lunr.js",
34
"version": "@VERSION",
5+
"description": "Simple full-text search in your browser.",
6+
"license": "MIT",
47
"main": "lunr.js",
5-
"ignore": [
6-
"tests/",
7-
"build/",
8-
"docs/"
9-
]
8+
"scripts": ["lunr.js"]
109
}

build/package.json.template

+10-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,18 @@
77
"homepage": "http://lunrjs.com",
88
"bugs": "http://github.com/olivernn/lunr.js/issues",
99
"main": "lunr.js",
10+
"license": "MIT",
11+
"repository": {
12+
"type": "git",
13+
"url": "https://github.com/olivernn/lunr.js.git"
14+
},
1015
"devDependencies": {
11-
"phantomjs": "1.8.1-3"
16+
"dox": "0.4.4",
17+
"dox-template": "0.1.1",
18+
"phantomjs": "1.8.1-3",
19+
"uglify-js": "2.4.13"
1220
},
1321
"scripts": {
14-
"test": "phantomjs test/env/runner.js http://localhost:3000/test"
22+
"test": "make test"
1523
}
1624
}

build/release.sh

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/usr/bin/env bash
2+
3+
file_has_changed () {
4+
if [ ! -f $1 ]; then
5+
return 1
6+
fi
7+
8+
for f in `git ls-files --modified`; do
9+
[[ "$f" == "$1" ]] && return 0
10+
done
11+
12+
return 1
13+
}
14+
15+
version_is_unique () {
16+
for v in `git tag -l`; do
17+
[[ "$v" == "v$1" ]] && return 1
18+
done
19+
20+
return 0
21+
}
22+
23+
on_master_branch () {
24+
[[ $(git symbolic-ref --short -q HEAD) == "master" ]] && return 0
25+
return 1
26+
}
27+
28+
version=$(cat VERSION)
29+
previous_version=$(git tag -l | tail -n 1)
30+
31+
if ! on_master_branch; then
32+
echo -e "\033[0;31mRefusing to release from non master branch.\033[0m"
33+
exit 1
34+
fi
35+
36+
if ! file_has_changed "VERSION"; then
37+
echo -e "\033[0;31mRefusing to release because VERSION has not changed.\033[0m"
38+
exit 1
39+
fi
40+
41+
if ! file_has_changed "CHANGELOG.mdown"; then
42+
echo -e "\033[0;31mRefusing to release because CHANGELOG.ms has not been updated.\033[0m"
43+
exit 1
44+
fi
45+
46+
if ! file_has_changed "package.json"; then
47+
echo -e "\033[0;31mRefusing to release because package.json has not been updated.\033[0m"
48+
exit 1
49+
fi
50+
51+
if ! version_is_unique $version; then
52+
echo -e "\033[0;31mRefusing to release because VERSION is not unique.\033[0m"
53+
exit 1
54+
fi
55+
56+
echo -e "\033[1mAbout to release v$version with the following changes:\033[0m"
57+
git log --date=short --pretty=format:"%ad %h%x09%an%x09%s" $previous_version..HEAD
58+
59+
echo
60+
61+
echo -e "\033[1mThe following files will be part of the release commit:\033[0m"
62+
git ls-files --modified
63+
64+
echo
65+
66+
read -e -p "Are you sure you want to release? " -n 1 -r
67+
echo
68+
if [[ $REPLY =~ ^[Yy]$ ]]; then
69+
echo -e "\033[0;32mReleasing...\033[0m"
70+
echo
71+
git commit -a -m "Build version $version"
72+
git tag -a v$version -m "Version $version"
73+
git push origin master
74+
git push --tags
75+
76+
npm publish
77+
else
78+
echo -e "\033[0;31mCancelling...\033[0m"
79+
fi

build/wrapper_end

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
/**
3+
* export the module via AMD, CommonnJS or as a browser global
4+
* Export code from https://github.com/umdjs/umd/blob/master/returnExports.js
5+
*/
6+
;(function (root, factory) {
7+
if (typeof define === 'function' && define.amd) {
8+
// AMD. Register as an anonymous module.
9+
define(factory)
10+
} else if (typeof exports === 'object') {
11+
/**
12+
* Node. Does not work with strict CommonJS, but
13+
* only CommonJS-like enviroments that support module.exports,
14+
* like Node.
15+
*/
16+
module.exports = factory()
17+
} else {
18+
// Browser globals (root is window)
19+
root.lunr = factory()
20+
}
21+
}(this, function () {
22+
/**
23+
* Just return a value to define the module export.
24+
* This example returns an object, but the module
25+
* can return a function as the exported value.
26+
*/
27+
return lunr
28+
}))
29+
})()

build/wrapper_start

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - @VERSION
3+
* Copyright (C) @YEAR Oliver Nightingale
4+
* MIT Licensed
5+
* @license
6+
*/
7+
8+
(function(){
9+

component.json

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
2-
"name": "lunr.js",
3-
"version": "0.3.3",
2+
"name": "lunr",
3+
"repo": "olivernn/lunr.js",
4+
"version": "0.5.3",
5+
"description": "Simple full-text search in your browser.",
6+
"license": "MIT",
47
"main": "lunr.js",
5-
"ignore": [
6-
"tests/",
7-
"build/",
8-
"docs/"
9-
]
8+
"scripts": ["lunr.js"]
109
}

docs/index.html

+620-147
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)