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
8f574152
Commit
8f574152
authored
Oct 16, 2020
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mynij Search: add query in search page url, show searched text body in result
parent
2f822e9b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
42 deletions
+108
-42
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
+92
-33
bt5/Mynij Search/PathTemplateItem/web_page_module/gadget_mynij_model.js.js
...PathTemplateItem/web_page_module/gadget_mynij_model.js.js
+2
-1
bt5/Mynij Search/PathTemplateItem/web_page_module/gadget_mynij_result.js.js
...athTemplateItem/web_page_module/gadget_mynij_result.js.js
+14
-8
No files found.
bt5/Mynij Search/PathTemplateItem/web_page_module/gadget_erp5_page_mynij_search_js.js
View file @
8f574152
...
...
@@ -7,6 +7,13 @@
model_gadget
:
null
,
result_gadget
:
null
})
.
declareAcquiredMethod
(
"
updateHeader
"
,
"
updateHeader
"
)
.
declareAcquiredMethod
(
"
getUrlParameter
"
,
"
getUrlParameter
"
)
.
declareAcquiredMethod
(
"
getUrlFor
"
,
"
getUrlFor
"
)
.
declareAcquiredMethod
(
"
redirect
"
,
"
redirect
"
)
.
ready
(
function
()
{
var
model_gadget
,
result_gadget
,
...
...
@@ -24,33 +31,93 @@
model_gadget
:
model_gadget
,
result_gadget
:
result
});
})
.
push
(
function
()
{
setTimeout
(
function
()
{
return
gadget
.
fill_available_indices
();
},
100
);
});
})
.
declareMethod
(
"
fill_available_indices
"
,
function
()
{
.
onStateChange
(
function
()
{
})
.
declareMethod
(
"
render
"
,
function
(
options
)
{
var
gadget
=
this
,
drop_list
=
document
.
getElementById
(
"
select_index
"
);
return
gadget
.
state
.
model_gadget
.
get_available_indices
()
.
push
(
function
(
results
)
{
results
.
forEach
((
item
,
i
)
=>
{
var
option_item
=
document
.
createElement
(
"
option
"
);
option_item
.
value
=
item
;
option_item
.
appendChild
(
document
.
createTextNode
(
item
));
drop_list
.
appendChild
(
option_item
);
index_list
,
drop_list
=
gadget
.
element
.
querySelector
(
"
#select_index
"
);
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
all
([
gadget
.
getUrlFor
({
command
:
'
history_previous
'
})
]);
})
.
push
(
function
(
url_list
)
{
return
gadget
.
updateHeader
({
page_title
:
"
Mynij Search
"
//selection_url: url_list[0]
});
})
.
push
(
function
()
{
return
gadget
.
state
.
model_gadget
.
get_available_indices
();
})
.
push
(
function
(
results
)
{
index_list
=
results
;
while
(
drop_list
.
firstChild
)
{
drop_list
.
removeChild
(
drop_list
.
firstChild
);
}
results
.
forEach
((
item
,
i
)
=>
{
var
option_item
=
document
.
createElement
(
"
option
"
);
option_item
.
value
=
item
;
option_item
.
appendChild
(
document
.
createTextNode
(
item
));
drop_list
.
appendChild
(
option_item
);
});
})
.
push
(
function
()
{
var
limit
=
options
.
limit
|
100
,
index
=
options
.
index
;
if
(
options
.
q
)
{
if
(
index_list
.
indexOf
(
index
)
===
-
1
)
index
=
undefined
;
else
drop_list
.
value
=
index
;
gadget
.
element
.
querySelector
(
"
#search_input
"
).
value
=
options
.
q
;
return
gadget
.
defer_search
(
options
.
q
,
index
,
limit
);
}
else
{
return
gadget
.
clear
();
}
});
})
});
.
declareJob
(
"
clear
"
,
function
()
{
this
.
element
.
querySelector
(
"
#search_input
"
).
value
=
""
;
return
this
.
state
.
result_gadget
.
clear
();
})
.
declareMethod
(
"
search
"
,
function
(
key
)
{
.
declareJob
(
"
defer_search
"
,
function
(
search_text
,
index
,
limit
)
{
var
gadget
=
this
,
top
=
document
.
getElementById
(
"
logo-search
"
);
if
(
top
)
{
gadget
.
element
.
removeChild
(
top
);
}
return
gadget
.
state
.
result_gadget
.
startLoading
()
.
push
(
function
()
{
return
gadget
.
state
.
result_gadget
.
showResultBox
();
})
.
push
(
function
()
{
return
gadget
.
search
(
search_text
,
limit
)
})
.
push
(
function
()
{
return
gadget
.
add_searx_results
(
search_text
);
});
})
.
declareMethod
(
"
search
"
,
function
(
key
,
limit
,
index
)
{
var
gadget
=
this
,
chosen_index
;
chosen_index
=
document
.
getElementById
(
"
select_index
"
).
selectedOptions
[
0
];
if
(
index
)
{
chosen_index
=
index
;
}
else
{
chosen_index
=
document
.
getElementById
(
"
select_index
"
).
value
;
}
if
(
chosen_index
===
null
)
{
return
gadget
.
state
.
result_gadget
.
addItem
(
{
...
...
@@ -63,7 +130,7 @@
return
gadget
.
state
.
result_gadget
.
clear
()
.
push
(
function
()
{
console
.
log
(
"
starting search
"
);
return
gadget
.
state
.
model_gadget
.
search
(
key
,
chosen_index
.
value
);
return
gadget
.
state
.
model_gadget
.
search
(
key
,
chosen_index
,
limit
);
})
.
push
(
function
(
result
)
{
console
.
log
(
"
search done
"
);
...
...
@@ -131,20 +198,12 @@
.
onEvent
(
"
submit
"
,
function
(
event
)
{
var
gadget
=
this
,
top
=
document
.
getElementById
(
"
logo-search
"
),
search_key
=
document
.
getElementById
(
"
search_input
"
).
value
;
if
(
top
)
{
gadget
.
element
.
removeChild
(
top
);
}
return
gadget
.
state
.
result_gadget
.
startLoading
()
.
push
(
function
()
{
return
gadget
.
state
.
result_gadget
.
showResultBox
();
})
.
push
(
function
()
{
return
gadget
.
search
(
search_key
)
})
.
push
(
function
()
{
return
gadget
.
add_searx_results
(
search_key
);
});
search_key
=
document
.
getElementById
(
"
search_input
"
).
value
,
index
=
document
.
getElementById
(
"
select_index
"
).
value
;
return
gadget
.
redirect
({
"
command
"
:
"
display
"
,
"
options
"
:
{
page
:
"
mynij_search
"
,
q
:
search_key
,
index
:
index
}});
});
}(
window
,
document
,
rJS
,
RSVP
));
\ No newline at end of file
bt5/Mynij Search/PathTemplateItem/web_page_module/gadget_mynij_model.js.js
View file @
8f574152
...
...
@@ -148,8 +148,9 @@
results
=
[];
return
gadget
.
get_index
(
index_name
)
.
push
(
function
(
index
)
{
var
limit
=
100
;
console
.
log
(
index
.
info
());
return
index
.
search
(
search_key
);
return
index
.
search
(
search_key
,
limit
);
})
.
push
(
function
(
index_results
)
{
return
index_results
;
...
...
bt5/Mynij Search/PathTemplateItem/web_page_module/gadget_mynij_result.js.js
View file @
8f574152
...
...
@@ -59,16 +59,16 @@
loader
.
style
.
display
=
"
none
"
;
body
=
document
.
createElement
(
'
p
'
);
body
.
className
=
"
body
"
;
item
.
body
=
new
DOMParser
().
parseFromString
(
item
.
body
,
"
text/html
"
).
body
.
textContent
||
""
;
if
(
key
===
""
||
item
.
body
===
""
)
{
//
item.body = new DOMParser().parseFromString(
//
item.body,
//
"text/html"
//
).body.textContent || "";
if
(
key
===
""
||
item
.
content
===
""
)
{
body
.
innerHTML
=
""
;
list
.
appendChild
(
list_item
);
}
else
{
//return gadget.cut_description(item.body, item.description, key)
return
gadget
.
cut_description
(
item
.
body
,
key
)
return
gadget
.
cut_description
(
item
.
content
,
key
)
.
push
(
function
(
result
)
{
var
array
=
[...
result
.
matchAll
(
key
)],
i
;
...
...
@@ -139,8 +139,14 @@
})
.
declareMethod
(
"
cut_description
"
,
function
(
body
,
key
)
{
//function(body, description, key)
var
result
=
new
RegExp
(
'
[^.?!]*
'
+
'
'
+
key
+
'
'
+
'
[^.?!]*[.?!]
'
,
'
gm
'
).
exec
(
body
);
var
result
,
key_list
=
key
.
split
(
'
'
),
search_key
=
key
;
if
(
key_list
.
length
>
0
)
search_key
=
[
key
].
concat
(
key_list
).
join
(
"
|
"
);
result
=
new
RegExp
(
'
[^;?.?!]*
\
s?(
'
+
search_key
+
'
)
\
s?[^.?!]*[.?!]
'
,
'
i
'
).
exec
(
body
);
if
(
result
===
null
)
{
//if (description !== "") return description; else....
...
...
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