mirror of https://github.com/kiwix/libkiwix.git
fixup! Add catalog filtering using ZIM aliasname
This commit is contained in:
parent
956c597e80
commit
8a3a0b08c2
|
@ -54,6 +54,7 @@ class HumanReadableNameMapper : public NameMapper {
|
|||
virtual ~HumanReadableNameMapper() = default;
|
||||
virtual std::string getNameForId(const std::string& id) const;
|
||||
virtual std::string getIdForName(const std::string& name) const;
|
||||
static std::string removeDateFromBookId(const std::string& bookId);
|
||||
};
|
||||
|
||||
class UpdatableNameMapper : public NameMapper {
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "tools/stringTools.h"
|
||||
#include "tools/otherTools.h"
|
||||
#include "tools/concurrent_cache.h"
|
||||
#include "name_mapper.h"
|
||||
|
||||
#include <pugixml.hpp>
|
||||
#include <algorithm>
|
||||
|
@ -462,7 +463,7 @@ void Library::updateBookDB(const Book& book)
|
|||
indexer.index_text(normalizeText(book.getName()), 1, "XN");
|
||||
indexer.index_text(normalizeText(book.getCategory()), 1, "XC");
|
||||
const auto bookName = book.getHumanReadableIdFromPath();
|
||||
const auto aliasName = replaceRegex(bookName, "", "_[[:digit:]]{4}-[[:digit:]]{2}$");
|
||||
const auto aliasName = HumanReadableNameMapper::removeDateFromBookId(bookName);
|
||||
indexer.index_text(normalizeText(aliasName), 1, "XF");
|
||||
|
||||
for ( const auto& tag : split(normalizeText(book.getTags()), ";") ) {
|
||||
|
|
|
@ -34,7 +34,7 @@ HumanReadableNameMapper::HumanReadableNameMapper(kiwix::Library& library, bool w
|
|||
if (!withAlias)
|
||||
continue;
|
||||
|
||||
auto aliasName = replaceRegex(bookName, "", "_[[:digit:]]{4}-[[:digit:]]{2}$");
|
||||
auto aliasName = removeDateFromBookId(bookName);
|
||||
if (aliasName == bookName) {
|
||||
continue;
|
||||
}
|
||||
|
@ -51,6 +51,10 @@ HumanReadableNameMapper::HumanReadableNameMapper(kiwix::Library& library, bool w
|
|||
}
|
||||
}
|
||||
|
||||
std::string HumanReadableNameMapper::removeDateFromBookId(const std::string& bookId) {
|
||||
return replaceRegex(bookId, "", "_[[:digit:]]{4}-[[:digit:]]{2}$");
|
||||
}
|
||||
|
||||
std::string HumanReadableNameMapper::getNameForId(const std::string& id) const {
|
||||
return m_idToName.at(id);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue