-
-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Small search improvement. #724
Conversation
8b50187
to
a83e99d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second commit (the one titled "Introduce SearchInfo.") is a little two big and a little too different to validate. It will benefit from being split into smaller changes.
static/templates/400.html
Outdated
<h1>Invalid request</h1> | ||
{{#url}} | ||
<p> | ||
The requested URL "{{.}}" is not a valid request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The {.}
mustache syntax is a revelation for me. Is it documented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot find it in the mustache manual (https://mustache.github.io/mustache.5.html)
But it is in kainjow mustache library : https://github.com/kainjow/Mustache/blob/master/tests/tests.cpp#L273-L281
Codecov Report
@@ Coverage Diff @@
## master #724 +/- ##
==========================================
+ Coverage 58.31% 58.98% +0.66%
==========================================
Files 56 56
Lines 3697 3735 +38
Branches 2069 2083 +14
==========================================
+ Hits 2156 2203 +47
+ Misses 1540 1531 -9
Partials 1 1
Continue to review full report at Codecov.
|
@mgautierfr I reviewed the PR again before realizing that you forgot to push your changes. |
@mgautierfr Can we move one please with this PR? |
@kelson42 I would like to bring to your attention the situation with this PR described in #727 (comment). If we postpone this PR until the preparatory work for internationalizing kiwix-serve is completed, then it can be rewritten in a slightly cleaner way (while at the same time minimizing the need for addressing conflicts in a larger WIP PR #679). |
@veloman-yunkan Not against the principle, but concerned about the overall timelime and interdependences. Considering that we have an XSS issue in the field with kiwix-serve... I would like that we consider a minor release within the next 2-3 weeks. |
The "problem" is that this PR is somehow a preparatory work for other PRs introducing opensearch feature. |
7a3e6fb
to
f2e4f25
Compare
No
I will do it tomorrow. |
f2e4f25
to
34cb506
Compare
Rebased on last master (with #727 merged) |
The new PR extracted from #679 is #732. Unfortunately, a few changes that I intended to include in #732 were too tightly coupled with internationalization of kiwix-serve so I left them for another smaller follow-up PR. |
@mgautierfr I guess this is now ready to fix/merge. |
34cb506
to
544bcb1
Compare
HTTP400HtmlResponse is build on the same design than HTTP404HtmlResponse.
544bcb1
to
3aca36f
Compare
Rebased on master (with #732 merged) |
3aca36f
to
ea4e9cb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. But I am also including couple of optional suggestions for minor improvements that could be made while moving the code around.
I've fixed your comment in two fixup commits |
src/server/internalServer.h
Outdated
} | ||
|
||
public: //data | ||
std::string pattern; | ||
bool has_geo_query; | ||
GeoQuery geo_query; | ||
std::pair<bool, GeoQuery> geoQuery; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this. A better solution is to take advantage of the fact that GeoQuery
can have an invalid state (for example when distance < 0
) without adding a new data field to it. Add a proper default constructor to GeoQuery
and a bool isValid() const
member function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done with a operator bool
operator
SearchInfo is a small helper structure to store information about the queried search. It regroup already existing information (`patternString`, geo query, ...) in one structure. It is also used as key in the cache instead of using a generated string.
It is better to directly try to get the `Search` from the cache instead of getting the `Searcher` first which could be useless in Search already exist.
If user request for a non existent book, we must return a 400 page. (This is done by throwing a `std::invalid_argument` and let the catch handle it)
The `searchPattern` is already "diples encoded". So we can simply using it without protecting us from script injection. Fix #723
There is no reason to not use the pattern if there is a geo_query. If both the pattern and the qeo_query are provided, we must use both.
701a416
to
311f783
Compare
This PR fixes small issues found on search handling on the server.
It is somehow a preparatory work for openSearch feature coming soon.
Fixes #723