mirror of https://github.com/kiwix/libkiwix.git
Rename methods `title()` into `getTitle()`.
Same for all attributes.
This commit is contained in:
parent
e0704b3b21
commit
1e8f85eaff
|
@ -66,25 +66,25 @@ class Book
|
||||||
string getHumanReadableIdFromPath();
|
string getHumanReadableIdFromPath();
|
||||||
|
|
||||||
bool readOnly() const { return m_readOnly; }
|
bool readOnly() const { return m_readOnly; }
|
||||||
const string& id() const { return m_id; }
|
const string& getId() const { return m_id; }
|
||||||
const string& path() const { return m_path; }
|
const string& getPath() const { return m_path; }
|
||||||
const string& indexPath() const { return m_indexPath; }
|
const string& getIndexPath() const { return m_indexPath; }
|
||||||
const supportedIndexType& indexType() const { return m_indexType; }
|
const supportedIndexType& getIndexType() const { return m_indexType; }
|
||||||
const string& title() const { return m_title; }
|
const string& getTitle() const { return m_title; }
|
||||||
const string& description() const { return m_description; }
|
const string& getDescription() const { return m_description; }
|
||||||
const string& language() const { return m_language; }
|
const string& getLanguage() const { return m_language; }
|
||||||
const string& creator() const { return m_creator; }
|
const string& getCreator() const { return m_creator; }
|
||||||
const string& publisher() const { return m_publisher; }
|
const string& getPublisher() const { return m_publisher; }
|
||||||
const string& date() const { return m_date; }
|
const string& getDate() const { return m_date; }
|
||||||
const string& url() const { return m_url; }
|
const string& getUrl() const { return m_url; }
|
||||||
const string& name() const { return m_name; }
|
const string& getName() const { return m_name; }
|
||||||
const string& tags() const { return m_tags; }
|
const string& getTags() const { return m_tags; }
|
||||||
const string& origId() const { return m_origId; }
|
const string& getOrigId() const { return m_origId; }
|
||||||
const uint64_t& articleCount() const { return m_articleCount; }
|
const uint64_t& getArticleCount() const { return m_articleCount; }
|
||||||
const uint64_t& mediaCount() const { return m_mediaCount; }
|
const uint64_t& getMediaCount() const { return m_mediaCount; }
|
||||||
const uint64_t& size() const { return m_size; }
|
const uint64_t& getSize() const { return m_size; }
|
||||||
const string& favicon() const { return m_favicon; }
|
const string& getFavicon() const { return m_favicon; }
|
||||||
const string& faviconMimeType() const { return m_faviconMimeType; }
|
const string& getFaviconMimeType() const { return m_faviconMimeType; }
|
||||||
|
|
||||||
void setReadOnly(bool readOnly) { m_readOnly = readOnly; }
|
void setReadOnly(bool readOnly) { m_readOnly = readOnly; }
|
||||||
void setId(const std::string& id) { m_id = id; }
|
void setId(const std::string& id) { m_id = id; }
|
||||||
|
|
|
@ -229,11 +229,11 @@ bool Library::addBook(const Book& book)
|
||||||
/* Try to find it */
|
/* Try to find it */
|
||||||
std::vector<kiwix::Book>::iterator itr;
|
std::vector<kiwix::Book>::iterator itr;
|
||||||
try {
|
try {
|
||||||
auto& oldbook = books.at(book.id());
|
auto& oldbook = books.at(book.getId());
|
||||||
oldbook.update(book);
|
oldbook.update(book);
|
||||||
return false;
|
return false;
|
||||||
} catch (std::out_of_range&) {
|
} catch (std::out_of_range&) {
|
||||||
books[book.id()] = book;
|
books[book.getId()] = book;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -255,8 +255,8 @@ unsigned int Library::getBookCount(const bool localBooks,
|
||||||
unsigned int result = 0;
|
unsigned int result = 0;
|
||||||
for (auto& pair: books) {
|
for (auto& pair: books) {
|
||||||
auto& book = pair.second;
|
auto& book = pair.second;
|
||||||
if ((!book.path().empty() && localBooks)
|
if ((!book.getPath().empty() && localBooks)
|
||||||
|| (book.path().empty() && remoteBooks)) {
|
|| (book.getPath().empty() && remoteBooks)) {
|
||||||
result++;
|
result++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,8 +272,8 @@ Library Library::filter(const std::string& search) {
|
||||||
|
|
||||||
for(auto& pair:books) {
|
for(auto& pair:books) {
|
||||||
auto& book = pair.second;
|
auto& book = pair.second;
|
||||||
if (matchRegex(book.title(), "\\Q" + search + "\\E")
|
if (matchRegex(book.getTitle(), "\\Q" + search + "\\E")
|
||||||
|| matchRegex(book.description(), "\\Q" + search + "\\E")) {
|
|| matchRegex(book.getDescription(), "\\Q" + search + "\\E")) {
|
||||||
library.addBook(book);
|
library.addBook(book);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -283,6 +283,7 @@ Library Library::filter(const std::string& search) {
|
||||||
|
|
||||||
bool Library::writeToFile(const std::string& path) {
|
bool Library::writeToFile(const std::string& path) {
|
||||||
pugi::xml_document doc;
|
pugi::xml_document doc;
|
||||||
|
auto baseDir = removeLastPathElement(path, true, false);
|
||||||
|
|
||||||
/* Add the library node */
|
/* Add the library node */
|
||||||
pugi::xml_node libraryNode = doc.append_child("library");
|
pugi::xml_node libraryNode = doc.append_child("library");
|
||||||
|
@ -295,67 +296,67 @@ bool Library::writeToFile(const std::string& path) {
|
||||||
auto& book = pair.second;
|
auto& book = pair.second;
|
||||||
if (!book.readOnly()) {
|
if (!book.readOnly()) {
|
||||||
pugi::xml_node bookNode = libraryNode.append_child("book");
|
pugi::xml_node bookNode = libraryNode.append_child("book");
|
||||||
bookNode.append_attribute("id") = book.id().c_str();
|
bookNode.append_attribute("id") = book.getId().c_str();
|
||||||
|
|
||||||
if (!book.path().empty()) {
|
if (!book.getPath().empty()) {
|
||||||
bookNode.append_attribute("path") = computeRelativePath(
|
bookNode.append_attribute("path") = computeRelativePath(
|
||||||
removeLastPathElement(path, true, false), book.path()).c_str();
|
baseDir, book.getPath()).c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!book.indexPath().empty()) {
|
if (!book.getIndexPath().empty()) {
|
||||||
bookNode.append_attribute("indexPath") = computeRelativePath(
|
bookNode.append_attribute("indexPath") = computeRelativePath(
|
||||||
removeLastPathElement(path, true, false), book.indexPath()).c_str();
|
baseDir, book.getIndexPath()).c_str();
|
||||||
bookNode.append_attribute("indexType") = "xapian";
|
bookNode.append_attribute("indexType") = "xapian";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (book.origId().empty()) {
|
if (book.getOrigId().empty()) {
|
||||||
if (!book.title().empty())
|
if (!book.getTitle().empty())
|
||||||
bookNode.append_attribute("title") = book.title().c_str();
|
bookNode.append_attribute("title") = book.getTitle().c_str();
|
||||||
|
|
||||||
if (!book.name().empty())
|
if (!book.getName().empty())
|
||||||
bookNode.append_attribute("name") = book.name().c_str();
|
bookNode.append_attribute("name") = book.getName().c_str();
|
||||||
|
|
||||||
if (!book.tags().empty())
|
if (!book.getTags().empty())
|
||||||
bookNode.append_attribute("tags") = book.tags().c_str();
|
bookNode.append_attribute("tags") = book.getTags().c_str();
|
||||||
|
|
||||||
if (!book.description().empty())
|
if (!book.getDescription().empty())
|
||||||
bookNode.append_attribute("description") = book.description().c_str();
|
bookNode.append_attribute("description") = book.getDescription().c_str();
|
||||||
|
|
||||||
if (!book.language().empty())
|
if (!book.getLanguage().empty())
|
||||||
bookNode.append_attribute("language") = book.language().c_str();
|
bookNode.append_attribute("language") = book.getLanguage().c_str();
|
||||||
|
|
||||||
if (!book.creator().empty())
|
if (!book.getCreator().empty())
|
||||||
bookNode.append_attribute("creator") = book.creator().c_str();
|
bookNode.append_attribute("creator") = book.getCreator().c_str();
|
||||||
|
|
||||||
if (!book.publisher().empty())
|
if (!book.getPublisher().empty())
|
||||||
bookNode.append_attribute("publisher") = book.publisher().c_str();
|
bookNode.append_attribute("publisher") = book.getPublisher().c_str();
|
||||||
|
|
||||||
if (!book.favicon().empty())
|
if (!book.getFavicon().empty())
|
||||||
bookNode.append_attribute("favicon") = base64_encode(book.favicon()).c_str();
|
bookNode.append_attribute("favicon") = base64_encode(book.getFavicon()).c_str();
|
||||||
|
|
||||||
if (!book.faviconMimeType().empty())
|
if (!book.getFaviconMimeType().empty())
|
||||||
bookNode.append_attribute("faviconMimeType")
|
bookNode.append_attribute("faviconMimeType")
|
||||||
= book.faviconMimeType().c_str();
|
= book.getFaviconMimeType().c_str();
|
||||||
} else {
|
} else {
|
||||||
bookNode.append_attribute("origId") = book.origId().c_str();
|
bookNode.append_attribute("origId") = book.getOrigId().c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!book.date().empty()) {
|
if (!book.getDate().empty()) {
|
||||||
bookNode.append_attribute("date") = book.date().c_str();
|
bookNode.append_attribute("date") = book.getDate().c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!book.url().empty()) {
|
if (!book.getUrl().empty()) {
|
||||||
bookNode.append_attribute("url") = book.url().c_str();
|
bookNode.append_attribute("url") = book.getUrl().c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!book.articleCount())
|
if (!book.getArticleCount())
|
||||||
bookNode.append_attribute("articleCount") = to_string(book.articleCount()).c_str();
|
bookNode.append_attribute("articleCount") = to_string(book.getArticleCount()).c_str();
|
||||||
|
|
||||||
if (!book.mediaCount())
|
if (!book.getMediaCount())
|
||||||
bookNode.append_attribute("mediaCount") = to_string(book.mediaCount()).c_str();
|
bookNode.append_attribute("mediaCount") = to_string(book.getMediaCount()).c_str();
|
||||||
|
|
||||||
if (!book.size()) {
|
if (!book.getSize()) {
|
||||||
bookNode.append_attribute("size") = to_string(book.size()).c_str();
|
bookNode.append_attribute("size") = to_string(book.getSize()).c_str();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -371,9 +372,9 @@ std::vector<std::string> Library::getBooksLanguages()
|
||||||
|
|
||||||
for (auto& pair: books) {
|
for (auto& pair: books) {
|
||||||
auto& book = pair.second;
|
auto& book = pair.second;
|
||||||
auto& language = book.language();
|
auto& language = book.getLanguage();
|
||||||
if (booksLanguagesMap.find(language) == booksLanguagesMap.end()) {
|
if (booksLanguagesMap.find(language) == booksLanguagesMap.end()) {
|
||||||
if (book.origId().empty()) {
|
if (book.getOrigId().empty()) {
|
||||||
booksLanguagesMap[language] = true;
|
booksLanguagesMap[language] = true;
|
||||||
booksLanguages.push_back(language);
|
booksLanguages.push_back(language);
|
||||||
}
|
}
|
||||||
|
@ -390,9 +391,9 @@ std::vector<std::string> Library::getBooksCreators()
|
||||||
|
|
||||||
for (auto& pair: books) {
|
for (auto& pair: books) {
|
||||||
auto& book = pair.second;
|
auto& book = pair.second;
|
||||||
auto& creator = book.creator();
|
auto& creator = book.getCreator();
|
||||||
if (booksCreatorsMap.find(creator) == booksCreatorsMap.end()) {
|
if (booksCreatorsMap.find(creator) == booksCreatorsMap.end()) {
|
||||||
if (book.origId().empty()) {
|
if (book.getOrigId().empty()) {
|
||||||
booksCreatorsMap[creator] = true;
|
booksCreatorsMap[creator] = true;
|
||||||
booksCreators.push_back(creator);
|
booksCreators.push_back(creator);
|
||||||
}
|
}
|
||||||
|
@ -420,9 +421,9 @@ std::vector<std::string> Library::getBooksPublishers()
|
||||||
|
|
||||||
for (auto& pair:books) {
|
for (auto& pair:books) {
|
||||||
auto& book = pair.second;
|
auto& book = pair.second;
|
||||||
auto& publisher = book.publisher();
|
auto& publisher = book.getPublisher();
|
||||||
if (booksPublishersMap.find(publisher) == booksPublishersMap.end()) {
|
if (booksPublishersMap.find(publisher) == booksPublishersMap.end()) {
|
||||||
if (book.origId().empty()) {
|
if (book.getOrigId().empty()) {
|
||||||
booksPublishersMap[publisher] = true;
|
booksPublishersMap[publisher] = true;
|
||||||
booksPublishers.push_back(publisher);
|
booksPublishers.push_back(publisher);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,8 +52,8 @@ bool Manager::parseXmlDom(const pugi::xml_document& doc,
|
||||||
if (libraryVersion.empty()
|
if (libraryVersion.empty()
|
||||||
|| atoi(libraryVersion.c_str()) <= atoi(KIWIX_LIBRARY_VERSION)) {
|
|| atoi(libraryVersion.c_str()) <= atoi(KIWIX_LIBRARY_VERSION)) {
|
||||||
ok = false;
|
ok = false;
|
||||||
if (!book.path().empty()) {
|
if (!book.getPath().empty()) {
|
||||||
ok = this->readBookFromPath(book.path());
|
ok = this->readBookFromPath(book.getPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,11 +183,11 @@ string Manager::addBookFromPathAndGetId(const string pathToOpen,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!checkMetaData
|
if (!checkMetaData
|
||||||
|| (checkMetaData && !book.title().empty() && !book.language().empty()
|
|| (checkMetaData && !book.getTitle().empty() && !book.getLanguage().empty()
|
||||||
&& !book.date().empty())) {
|
&& !book.getDate().empty())) {
|
||||||
book.setUrl(url);
|
book.setUrl(url);
|
||||||
library->addBook(book);
|
library->addBook(book);
|
||||||
return book.id();
|
return book.getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,30 +54,30 @@ std::string gen_date_str()
|
||||||
|
|
||||||
pugi::xml_node OPDSDumper::handleBook(Book book, pugi::xml_node root_node) {
|
pugi::xml_node OPDSDumper::handleBook(Book book, pugi::xml_node root_node) {
|
||||||
auto entry_node = root_node.append_child("entry");
|
auto entry_node = root_node.append_child("entry");
|
||||||
ADD_TEXT_ENTRY(entry_node, "title", book.title());
|
ADD_TEXT_ENTRY(entry_node, "title", book.getTitle());
|
||||||
ADD_TEXT_ENTRY(entry_node, "id", "urn:uuid:"+book.id());
|
ADD_TEXT_ENTRY(entry_node, "id", "urn:uuid:"+book.getId());
|
||||||
ADD_TEXT_ENTRY(entry_node, "icon", rootLocation + "/meta?name=favicon&content=" + book.getHumanReadableIdFromPath());
|
ADD_TEXT_ENTRY(entry_node, "icon", rootLocation + "/meta?name=favicon&content=" + book.getHumanReadableIdFromPath());
|
||||||
ADD_TEXT_ENTRY(entry_node, "updated", date);
|
ADD_TEXT_ENTRY(entry_node, "updated", date);
|
||||||
ADD_TEXT_ENTRY(entry_node, "summary", book.description());
|
ADD_TEXT_ENTRY(entry_node, "summary", book.getDescription());
|
||||||
|
|
||||||
auto content_node = entry_node.append_child("link");
|
auto content_node = entry_node.append_child("link");
|
||||||
content_node.append_attribute("type") = "text/html";
|
content_node.append_attribute("type") = "text/html";
|
||||||
content_node.append_attribute("href") = (rootLocation + "/" + book.getHumanReadableIdFromPath()).c_str();
|
content_node.append_attribute("href") = (rootLocation + "/" + book.getHumanReadableIdFromPath()).c_str();
|
||||||
|
|
||||||
auto author_node = entry_node.append_child("author");
|
auto author_node = entry_node.append_child("author");
|
||||||
ADD_TEXT_ENTRY(author_node, "name", book.creator());
|
ADD_TEXT_ENTRY(author_node, "name", book.getCreator());
|
||||||
|
|
||||||
if (! book.url().empty()) {
|
if (! book.getUrl().empty()) {
|
||||||
auto acquisition_link = entry_node.append_child("link");
|
auto acquisition_link = entry_node.append_child("link");
|
||||||
acquisition_link.append_attribute("rel") = "http://opds-spec.org/acquisition/open-access";
|
acquisition_link.append_attribute("rel") = "http://opds-spec.org/acquisition/open-access";
|
||||||
acquisition_link.append_attribute("type") = "application/x-zim";
|
acquisition_link.append_attribute("type") = "application/x-zim";
|
||||||
acquisition_link.append_attribute("href") = book.url().c_str();
|
acquisition_link.append_attribute("href") = book.getUrl().c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! book.faviconMimeType().empty() ) {
|
if (! book.getFaviconMimeType().empty() ) {
|
||||||
auto image_link = entry_node.append_child("link");
|
auto image_link = entry_node.append_child("link");
|
||||||
image_link.append_attribute("rel") = "http://opds-spec.org/image/thumbnail";
|
image_link.append_attribute("rel") = "http://opds-spec.org/image/thumbnail";
|
||||||
image_link.append_attribute("type") = book.faviconMimeType().c_str();
|
image_link.append_attribute("type") = book.getFaviconMimeType().c_str();
|
||||||
image_link.append_attribute("href") = (rootLocation + "/meta?name=favicon&content=" + book.getHumanReadableIdFromPath()).c_str();
|
image_link.append_attribute("href") = (rootLocation + "/meta?name=favicon&content=" + book.getHumanReadableIdFromPath()).c_str();
|
||||||
}
|
}
|
||||||
return entry_node;
|
return entry_node;
|
||||||
|
|
Loading…
Reference in New Issue