From 4a0130343882e06f6e86e091367ece0cd4fff524 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 7 Jan 2020 17:06:12 +0100 Subject: [PATCH 1/3] Correctly set the id of the opds stream. Set the id of the stream *after* the uuid is generated. --- ChangeLog | 5 +++++ src/server.cpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 9172b7357..a2e542550 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +kiwix-lib 8.2.3 +=============== + + * [OPDS] Correctly set the id of the OPDS stream. + kiwix-lib 8.2.2 =============== diff --git a/src/server.cpp b/src/server.cpp index 180a1c101..7ff57360a 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -742,7 +742,6 @@ Response InternalServer::handle_catalog(const RequestContext& request) kiwix::OPDSDumper opdsDumper; opdsDumper.setRootLocation(m_root); opdsDumper.setSearchDescriptionUrl("catalog/searchdescription.xml"); - opdsDumper.setId(kiwix::to_string(uuid)); opdsDumper.setLibrary(mp_library); response.set_mimeType("application/atom+xml;profile=opds-catalog;kind=acquisition; charset=utf-8"); std::vector bookIdsToDump; @@ -792,6 +791,7 @@ Response InternalServer::handle_catalog(const RequestContext& request) opdsDumper.setOpenSearchInfo(totalResults, startIndex, bookIdsToDump.size()); } + opdsDumper.setId(kiwix::to_string(uuid)); response.set_content(opdsDumper.dumpOPDSFeed(bookIdsToDump)); return response; } From 071e9e3fec1cc28961ad28064745047c587b1d74 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 7 Jan 2020 17:08:39 +0100 Subject: [PATCH 2/3] Correctly filter the catalog when we don't what to filter. Set the different filter's fields only when we are requested to filter them. Else, we ends to requests that some fields are empty. If the request has no argument, we raise an exception (catched) and so we don't set the corresponding field in the filter. Fix #303 --- ChangeLog | 2 ++ src/server.cpp | 21 +++++++-------------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index a2e542550..b50297a02 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ kiwix-lib 8.2.3 =============== * [OPDS] Correctly set the id of the OPDS stream. + * [OPDS] Do not try to filter the catalog if no filter field is given in the + request. kiwix-lib 8.2.2 =============== diff --git a/src/server.cpp b/src/server.cpp index 7ff57360a..fe33181b1 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -750,17 +750,16 @@ Response InternalServer::handle_catalog(const RequestContext& request) uuid = zim::Uuid::generate(host); bookIdsToDump = mp_library->filter(kiwix::Filter().valid(true).local(true).remote(true)); } else if (url == "search") { - std::string query; - std::string language; - std::vector tags; - std::vector noTags; + auto filter = kiwix::Filter().valid(true).local(true).remote(true); + string query(""); size_t count(10); size_t startIndex(0); try { query = request.get_argument("q"); + filter.query(query); } catch (const std::out_of_range&) {} try { - language = request.get_argument("lang"); + filter.lang(request.get_argument("lang")); } catch (const std::out_of_range&) {} try { count = extractFromString(request.get_argument("count")); @@ -769,20 +768,14 @@ Response InternalServer::handle_catalog(const RequestContext& request) startIndex = extractFromString(request.get_argument("start")); } catch (...) {} try { - tags = kiwix::split(request.get_argument("notag"), ";"); + filter.acceptTags(kiwix::split(request.get_argument("notag"), ";")); } catch (...) {} try { - noTags = kiwix::split(request.get_argument("notag"), ";"); + filter.rejectTags(kiwix::split(request.get_argument("notag"), ";")); } catch (...) {} opdsDumper.setTitle("Search result for " + query); uuid = zim::Uuid::generate(); - bookIdsToDump = mp_library->filter( - kiwix::Filter().valid(true).local(true).remote(true) - .query(query) - .lang(language) - .acceptTags(tags) - .rejectTags(noTags) - ); + bookIdsToDump = mp_library->filter(filter); auto totalResults = bookIdsToDump.size(); bookIdsToDump.erase(bookIdsToDump.begin(), bookIdsToDump.begin()+startIndex); if (count>0 && bookIdsToDump.size() > count) { From 02a0d592f9dcb31c0ad78332dbf131f82a43ea4c Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Thu, 9 Jan 2020 10:08:47 +0100 Subject: [PATCH 3/3] Install python3 in Travis MacOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For some reason, `homebrew install gcovr` now install python3 as dependency. This is a dependency since a long time, I don't know why it was not installing it before. But the installation fails because it cannot link correctly python3 because python2 is already installed. Then meson, when it tries to run the conversion script, fails because the script cannot find python3. The solution I've found is to unlink python2 and relink python3 to have a correct installation of python3. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 00a9e5d63..855b79df9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ sudo: true cache: ccache before_install: - PATH=$PATH:$HOME/bin +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew unlink python@2; brew link --overwrite python@3; fi install: travis/install_deps.sh script: travis/compile.sh env: