From 9ead81ca0c559fb1b7be740ff8fef7f5bfb9525a Mon Sep 17 00:00:00 2001 From: kelson42 Date: Mon, 2 Apr 2012 19:52:19 +0000 Subject: [PATCH] + compute "default" title if not specified in the ZIM file metadata --- src/common/kiwix/manager.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/common/kiwix/manager.cpp b/src/common/kiwix/manager.cpp index 6bf88772f..2474186ea 100644 --- a/src/common/kiwix/manager.cpp +++ b/src/common/kiwix/manager.cpp @@ -242,12 +242,19 @@ namespace kiwix { book.path = path; book.pathAbsolute = path; book.id = reader.getId(); - book.title = reader.getTitle(); book.description = reader.getDescription(); book.language = reader.getLanguage(); book.date = reader.getDate(); book.creator = reader.getCreator(); book.publisher = reader.getPublisher(); + + book.title = reader.getTitle(); + if (book.title.empty()) { + book.title = getLastPathElement(path); + std::replace(book.title.begin(), book.title.end(), '_', ' '); + size_t pos = book.title.find(".zim"); + book.title = book.title.substr(0, pos); + } std::ostringstream articleCountStream; articleCountStream << reader.getArticleCount();