Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Mynij
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Alexandra Rogova
Mynij
Commits
982ea41f
Commit
982ea41f
authored
5 years ago
by
Alexandra Rogova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented elasticlunr, search is now much faster!
parent
f90ac3f3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
33 deletions
+60
-33
gadget_model.html
gadget_model.html
+3
-0
gadget_model.js
gadget_model.js
+41
-11
gadget_result.js
gadget_result.js
+1
-1
search.html
search.html
+3
-0
search.js
search.js
+12
-21
No files found.
gadget_model.html
View file @
982ea41f
...
...
@@ -5,6 +5,9 @@
<script
src=
"../jio/external/rsvp-2.0.4.js"
></script>
<script
src=
"../jio/dist/jio-latest.js"
></script>
<script
src=
"../renderjs/dist/renderjs-latest.js"
></script>
<script
src=
"./elasticlunr/elasticlunr.js"
></script>
<script
src=
"./lunr-languages/lunr.stemmer.support.js"
></script>
<script
src=
"./lunr-languages/lunr.fr.js"
></script>
<script
src=
"gadget_model.js"
></script>
</head>
<body>
...
...
This diff is collapsed.
Click to expand it.
gadget_model.js
View file @
982ea41f
...
...
@@ -6,6 +6,14 @@
.
ready
(
function
(){
this
.
index
=
elasticlunr
(
function
()
{
this
.
use
(
elasticlunr
.
fr
);
this
.
addField
(
'
title
'
);
this
.
addField
(
'
body
'
);
this
.
addField
(
'
link
'
);
this
.
setRef
(
'
id
'
);
//id = x."/a/b" where x = substorage id, "/a/b" = item id in x
});
this
.
feeds
=
jIO
.
createJIO
({
type
:
"
indexeddb
"
,
database
:
"
mynij-v1.2
"
...
...
@@ -22,7 +30,7 @@
})
.
declareMethod
(
"
add_attachment
"
,
function
(
title
,
rss
){
var
gadget
=
this
;
var
gadget
=
this
,
sub_id
;
return
this
.
feeds
.
putAttachment
(
"
feeds_doc
"
,
title
,
new
Blob
([
rss
],
{
type
:
"
text/xml
"
}))
.
push
(
function
(){
var
new_sub_storage
=
{
...
...
@@ -37,6 +45,28 @@
};
var
tmp
=
jIO
.
createJIO
(
new_sub_storage
);
gadget
.
sub_storages
.
push
(
tmp
);
sub_id
=
gadget
.
sub_storages
.
length
-
1
;
return
gadget
.
sub_storages
[
sub_id
].
allDocs
();
})
.
push
(
function
(
all_new_items
){
var
i
,
promise_list
=
[];
for
(
i
=
0
;
i
<
all_new_items
.
data
.
rows
.
length
;
i
+=
1
){
promise_list
.
push
(
gadget
.
sub_storages
[
sub_id
].
get
(
all_new_items
.
data
.
rows
[
i
].
id
));
}
return
RSVP
.
all
(
promise_list
);
})
.
push
(
function
(
items
){
var
i
,
id
,
doc
;
for
(
i
=
1
;
i
<
items
.
length
;
i
++
){
id
=
sub_id
+
"
./0/
"
+
i
;
doc
=
{
"
id
"
:
id
,
"
title
"
:
items
[
i
].
title
,
"
body
"
:
items
[
i
].
description
,
"
link
"
:
items
[
i
].
link
};
gadget
.
index
.
addDoc
(
doc
);
}
});
})
...
...
@@ -54,7 +84,7 @@
})
.
declareMethod
(
"
search
"
,
function
()
{
return
this
.
search_storage
.
allDocs
.
apply
(
this
.
search_storage
,
arguments
);
return
this
.
index
.
search
(
arguments
[
0
]
);
})
.
declareMethod
(
"
loaded_doc
"
,
function
(){
...
...
This diff is collapsed.
Click to expand it.
gadget_result.js
View file @
982ea41f
...
...
@@ -37,7 +37,7 @@
body
.
innerHTML
=
""
;
list
.
appendChild
(
list_item
);
}
else
{
return
this
.
cut_description
(
item
.
description
,
key
)
return
this
.
cut_description
(
item
.
body
,
key
)
.
push
(
function
(
result
){
if
(
result
===
null
)
body
.
innerHTML
=
""
;
else
body
.
innerHTML
=
result
.
slice
(
1
);
...
...
This diff is collapsed.
Click to expand it.
search.html
View file @
982ea41f
...
...
@@ -6,6 +6,9 @@
<script
src=
"../jio/dist/jio-latest.js"
></script>
<script
src=
"jio.my_parser_storage.js"
></script>
<script
src=
"../renderjs/dist/renderjs-latest.js"
></script>
<script
src=
"./elasticlunr/elasticlunr.js"
></script>
<script
src=
"./lunr-languages/lunr.stemmer.support.js"
></script>
<script
src=
"./lunr-languages/lunr.fr.js"
></script>
<script
src=
"search.js"
></script>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"mynij.css"
>
</head>
...
...
This diff is collapsed.
Click to expand it.
search.js
View file @
982ea41f
...
...
@@ -69,30 +69,21 @@
var
gadget
=
this
;
return
gadget
.
state
.
result_gadget
.
clear
()
.
push
(
function
(){
return
gadget
.
state
.
model_gadget
.
allDocs
(
);
return
gadget
.
state
.
model_gadget
.
search
(
key
);
})
.
push
(
function
(
all_attachments
){
var
i
,
j
,
promise_list
=
[];
for
(
i
=
0
;
i
<
all_attachments
.
length
;
i
+=
1
){
for
(
j
=
1
;
j
<
all_attachments
[
i
].
data
.
rows
.
length
;
j
+=
1
){
promise_list
.
push
(
gadget
.
state
.
model_gadget
.
get
(
i
,
all_attachments
[
i
].
data
.
rows
[
j
].
id
));
}
}
return
RSVP
.
all
(
promise_list
);
}).
push
(
function
(
all_items
){
var
i
,
regEx
=
new
RegExp
(
'
((.*
'
+
key
+
'
.*)|(
'
+
key
+
'
.*))
'
,
'
gi
'
),
promise_list
=
[];
for
(
i
=
0
;
i
<
all_items
.
length
;
i
+=
1
){
if
(
regEx
.
test
(
all_items
[
i
].
title
)
||
regEx
.
test
(
all_items
[
i
].
description
))
promise_list
.
push
(
gadget
.
state
.
result_gadget
.
addItem
(
all_items
[
i
],
key
));
}
if
(
promise_list
.
length
===
0
)
{
.
push
(
function
(
result
){
if
(
result
.
length
===
0
)
{
return
gadget
.
state
.
result_gadget
.
addItem
({
title
:
"
No results found
"
,
link
:
""
},
""
);
}
else
{
var
i
,
promise_list
=
[];
for
(
i
=
0
;
i
<
result
.
length
;
i
+=
1
){
promise_list
.
push
(
gadget
.
state
.
result_gadget
.
addItem
(
result
[
i
].
doc
,
key
));
}
return
RSVP
.
all
(
promise_list
);
}
else
return
RSVP
.
all
(
promise_list
);
});
})
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment