Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mynij
mynij
Commits
0c11cdcc
Commit
0c11cdcc
authored
Oct 19, 2020
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mynij Search: description in search result hax maximum 250 characters
Fix search form also
parent
8f574152
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
14 deletions
+73
-14
bt5/Mynij Search/PathTemplateItem/web_page_module/gadget_erp5_page_mynij_search_html.html
...m/web_page_module/gadget_erp5_page_mynij_search_html.html
+4
-2
bt5/Mynij Search/PathTemplateItem/web_page_module/gadget_erp5_page_mynij_search_js.js
...eItem/web_page_module/gadget_erp5_page_mynij_search_js.js
+8
-3
bt5/Mynij Search/PathTemplateItem/web_page_module/gadget_mynij_model.js.js
...PathTemplateItem/web_page_module/gadget_mynij_model.js.js
+1
-1
bt5/Mynij Search/PathTemplateItem/web_page_module/gadget_mynij_result.js.js
...athTemplateItem/web_page_module/gadget_mynij_result.js.js
+53
-7
bt5/Mynij Search/PathTemplateItem/web_page_module/gadget_mynij_style.css.css
...thTemplateItem/web_page_module/gadget_mynij_style.css.css
+7
-1
No files found.
bt5/Mynij Search/PathTemplateItem/web_page_module/gadget_erp5_page_mynij_search_html.html
View file @
0c11cdcc
...
...
@@ -13,9 +13,11 @@
</div>
<div
id=
"search_div"
>
<form
id=
"search_bar"
>
<input
type=
"search"
id=
"search_input"
required
>
</form>
<input
type=
"search"
id=
"search_input"
name=
"search"
value
>
<select
id=
"select_index"
></select>
<button
class=
"search-button ui-btn-icon-notext ui-icon-search"
type=
"submit"
>
</button>
</form>
</div>
<div
id=
"gadget_result"
data-gadget-url=
"gadget_mynij_result.html"
data-gadget-scope=
"result"
data-gadget-sandbox=
"public"
></div>
...
...
bt5/Mynij Search/PathTemplateItem/web_page_module/gadget_erp5_page_mynij_search_js.js
View file @
0c11cdcc
...
...
@@ -88,8 +88,13 @@
})
.
declareJob
(
"
clear
"
,
function
()
{
var
gadget
=
this
;
this
.
element
.
querySelector
(
"
#search_input
"
).
value
=
""
;
return
this
.
state
.
result_gadget
.
clear
();
return
this
.
state
.
result_gadget
.
clear
()
.
push
(
function
()
{
document
.
getElementById
(
"
logo-search
"
).
classList
.
remove
(
'
hide
'
);
return
gadget
.
state
.
result_gadget
.
hideResultBox
();
});
})
.
declareJob
(
"
defer_search
"
,
function
(
search_text
,
index
,
limit
)
{
...
...
@@ -97,7 +102,7 @@
top
=
document
.
getElementById
(
"
logo-search
"
);
if
(
top
)
{
gadget
.
element
.
removeChild
(
top
);
top
.
classList
.
add
(
"
hide
"
);
}
return
gadget
.
state
.
result_gadget
.
startLoading
()
.
push
(
function
()
{
...
...
@@ -175,7 +180,7 @@
var
error_html
;
error_html
=
document
.
createElement
(
"
p
"
);
error_html
.
className
=
"
no-result
"
;
error_html
.
textContent
=
"
A
N
error occured, please try again.
"
+
error_html
.
textContent
=
"
A
n
error occured, please try again.
"
+
error
.
message
||
''
;
return
gadget
.
state
.
result_gadget
.
show_searx_result
(
error_html
);
})
...
...
bt5/Mynij Search/PathTemplateItem/web_page_module/gadget_mynij_model.js.js
View file @
0c11cdcc
...
...
@@ -98,7 +98,7 @@
index_id
=
"
index-
"
+
index_name
,
new_index
;
new_index
=
FlexSearch
.
create
(
"
memory
"
,
{
stemmer
:
"
en
"
,
filter
:
"
en
"
});
new_index
=
FlexSearch
.
create
(
"
memory
"
,
{
stemmer
:
"
en
"
,
filter
:
"
en
"
,
encode
:
"
icase
"
});
return
gadget
.
state
.
db
.
getAttachment
(
index_id
,
"
ids
"
,
{
"
format
"
:
"
text
"
})
.
push
(
function
(
result
)
{
ids
=
result
;
...
...
bt5/Mynij Search/PathTemplateItem/web_page_module/gadget_mynij_result.js.js
View file @
0c11cdcc
...
...
@@ -13,6 +13,13 @@
box
.
classList
.
remove
(
"
hide
"
);
}
})
.
declareMethod
(
"
hideResultBox
"
,
function
()
{
var
box
=
document
.
getElementById
(
"
results
"
);
if
(
!
box
.
classList
.
contains
(
"
hide
"
))
{
box
.
classList
.
add
(
"
hide
"
);
}
})
.
declareMethod
(
"
startLoading
"
,
function
()
{
var
loader
;
...
...
@@ -143,23 +150,62 @@
key_list
=
key
.
split
(
'
'
),
search_key
=
key
;
function
extract_description
(
description
)
{
var
regex
,
max_length
=
250
,
start
,
end
,
count
=
0
,
i
;
description
=
description
.
replace
(
/
[\t\r\n]
+/g
,
''
)
.
replace
(
/ +
(?=
)
/g
,
''
);
if
(
description
.
length
<=
max_length
)
return
description
;
regex
=
new
RegExp
(
'
(
'
+
search_key
+
'
)
'
,
'
i
'
).
exec
(
description
);
if
(
regex
!==
null
)
{
start
=
regex
.
index
;
end
=
start
+
regex
[
0
].
length
;
i
=
start
;
while
(
i
>
0
&&
count
<
10
)
{
if
(
description
[
i
]
===
'
'
)
{
count
+=
1
;
start
=
i
+
1
;
}
i
-=
1
;
}
if
(
i
===
0
)
start
=
0
;
end
=
max_length
+
start
;
if
(
end
>
description
.
length
)
end
=
description
.
length
;
return
description
.
slice
(
start
,
end
)
+
"
...
"
;
}
return
description
;
}
if
(
key_list
.
length
>
0
)
search_key
=
[
key
].
concat
(
key_list
).
join
(
"
|
"
);
result
=
new
RegExp
(
'
[^;?.?!]*
\
s?(
'
+
search_key
+
'
)
\
s?[^.?!]*[.?!]
'
,
'
i
'
).
exec
(
body
);
'
[^;?.?!]*
\
\
s?(
'
+
search_key
+
'
)
\
\
s?[^.?!]*[.?!]
'
,
'
i
'
).
exec
(
body
);
if
(
result
===
null
)
{
//if (description !== "") return description; else....
result
=
new
RegExp
(
'
[^.?!]*[.?!]
'
).
exec
(
body
);
if
(
result
===
null
)
return
""
;
else
return
result
[
0
];
if
(
result
===
null
)
return
""
;
else
return
result
[
0
];
}
else
return
result
[
0
];
else
return
extract_description
(
result
[
0
]);
})
.
declareMethod
(
"
cut_link
"
,
function
(
link
)
{
if
(
link
===
undefined
)
return
""
;
if
(
link
.
length
>
70
)
return
link
.
slice
(
0
,
70
)
+
"
...
"
;
else
return
link
;
if
(
link
===
undefined
)
return
""
;
if
(
link
.
length
>
70
)
return
link
.
slice
(
0
,
70
)
+
"
...
"
;
else
return
link
;
});
}(
window
,
RSVP
,
rJS
,
document
,
DOMParser
));
\ No newline at end of file
bt5/Mynij Search/PathTemplateItem/web_page_module/gadget_mynij_style.css.css
View file @
0c11cdcc
...
...
@@ -6,10 +6,16 @@
#search_bar
{
width
:
100%
;
padding-right
:
1%
;
display
:
inline-flex
;
}
.search-button
{
margin-left
:
10px
;
}
#select_index
{
width
:
20%
;
max-width
:
20%
;
margin-left
:
5px
;
}
.search
{
...
...
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