From 1500cb8329b93b4787cfc91ff53472dc3db04547 Mon Sep 17 00:00:00 2001 From: Kelson Date: Sun, 4 Sep 2016 20:11:34 +0200 Subject: [PATCH] Implement ZIM reader getTags() and getName() --- src/common/kiwix/library.cpp | 6 ++++++ src/common/kiwix/library.h | 2 ++ src/common/kiwix/manager.cpp | 10 ++++++++++ 3 files changed, 18 insertions(+) diff --git a/src/common/kiwix/library.cpp b/src/common/kiwix/library.cpp index 4ee7a45f..2399d78d 100644 --- a/src/common/kiwix/library.cpp +++ b/src/common/kiwix/library.cpp @@ -103,6 +103,12 @@ namespace kiwix { if (itr->url.empty()) itr->url = book.url; + + if (itr->tags.empty()) + itr->tags = book.tags; + + if (itr->name.empty()) + itr->name = book.name; if (itr->indexPath.empty()) { itr->indexPath = book.indexPath; diff --git a/src/common/kiwix/library.h b/src/common/kiwix/library.h index 4ae5b3a8..2bc16c8b 100644 --- a/src/common/kiwix/library.h +++ b/src/common/kiwix/library.h @@ -67,6 +67,8 @@ namespace kiwix { string publisher; string date; string url; + string name; + string tags; string origId; string articleCount; string mediaCount; diff --git a/src/common/kiwix/manager.cpp b/src/common/kiwix/manager.cpp index f7fdf765..67d26c35 100644 --- a/src/common/kiwix/manager.cpp +++ b/src/common/kiwix/manager.cpp @@ -50,6 +50,8 @@ namespace kiwix { book.indexPath = bookNode.attribute("indexPath").value(); book.indexType = XAPIAN; book.title = bookNode.attribute("title").value(); + book.name = bookNode.attribute("name").value(); + book.tags = bookNode.attribute("tags").value(); book.description = bookNode.attribute("description").value(); book.language = bookNode.attribute("language").value(); book.date = bookNode.attribute("date").value(); @@ -158,6 +160,12 @@ namespace kiwix { if (itr->origId.empty()) { if (!itr->title.empty()) bookNode.append_attribute("title") = itr->title.c_str(); + + if (!itr->name.empty()) + bookNode.append_attribute("name") = itr->title.c_str(); + + if (!itr->tags.empty()) + bookNode.append_attribute("tags") = itr->tags.c_str(); if (!itr->description.empty()) bookNode.append_attribute("description") = itr->description.c_str(); @@ -262,6 +270,8 @@ namespace kiwix { book->creator = reader->getCreator(); book->publisher = reader->getPublisher(); book->title = reader->getTitle(); + book->name = reader->getName(); + book->tags = reader->getTags(); book->origId = reader->getOrigId(); std::ostringstream articleCountStream; articleCountStream << reader->getArticleCount();