kiwix::Book::getCategory()

This commit is contained in:
Veloman Yunkan 2021-03-05 19:10:01 +04:00
parent 6d43fd065f
commit 58186ffb26
6 changed files with 18 additions and 0 deletions

View File

@ -59,6 +59,7 @@ class Book
const std::string& getDate() const { return m_date; } const std::string& getDate() const { return m_date; }
const std::string& getUrl() const { return m_url; } const std::string& getUrl() const { return m_url; }
const std::string& getName() const { return m_name; } const std::string& getName() const { return m_name; }
std::string getCategory() const;
const std::string& getTags() const { return m_tags; } const std::string& getTags() const { return m_tags; }
std::string getTagStr(const std::string& tagName) const; std::string getTagStr(const std::string& tagName) const;
bool getTagBool(const std::string& tagName) const; bool getTagBool(const std::string& tagName) const;

View File

@ -220,4 +220,16 @@ bool Book::getTagBool(const std::string& tagName) const {
return convertStrToBool(getTagStr(tagName)); return convertStrToBool(getTagStr(tagName));
} }
std::string Book::getCategory() const
{
try
{
return getTagStr("category");
}
catch ( const std::out_of_range& )
{
return "";
}
}
} }

View File

@ -77,6 +77,7 @@ pugi::xml_node OPDSDumper::handleBook(Book book, pugi::xml_node root_node) {
ADD_TEXT_ENTRY(entry_node, "updated", gen_date_from_yyyy_mm_dd(book.getDate())); ADD_TEXT_ENTRY(entry_node, "updated", gen_date_from_yyyy_mm_dd(book.getDate()));
ADD_TEXT_ENTRY(entry_node, "name", book.getName()); ADD_TEXT_ENTRY(entry_node, "name", book.getName());
ADD_TEXT_ENTRY(entry_node, "flavour", book.getFlavour()); ADD_TEXT_ENTRY(entry_node, "flavour", book.getFlavour());
ADD_TEXT_ENTRY(entry_node, "category", book.getCategory());
ADD_TEXT_ENTRY(entry_node, "tags", book.getTags()); ADD_TEXT_ENTRY(entry_node, "tags", book.getTags());
ADD_TEXT_ENTRY(entry_node, "articleCount", to_string(book.getArticleCount())); ADD_TEXT_ENTRY(entry_node, "articleCount", to_string(book.getArticleCount()));
ADD_TEXT_ENTRY(entry_node, "mediaCount", to_string(book.getMediaCount())); ADD_TEXT_ENTRY(entry_node, "mediaCount", to_string(book.getMediaCount()));

View File

@ -69,6 +69,7 @@ GETTER(jstring, getDate)
GETTER(jstring, getUrl) GETTER(jstring, getUrl)
GETTER(jstring, getName) GETTER(jstring, getName)
GETTER(jstring, getFlavour) GETTER(jstring, getFlavour)
GETTER(jstring, getCategory)
GETTER(jstring, getTags) GETTER(jstring, getTags)
GETTER(jlong, getArticleCount) GETTER(jlong, getArticleCount)
GETTER(jlong, getMediaCount) GETTER(jlong, getMediaCount)

View File

@ -24,6 +24,7 @@ public class Book
public native String getUrl(); public native String getUrl();
public native String getName(); public native String getName();
public native String getFlavour(); public native String getFlavour();
public native String getCategory();
public native String getTags(); public native String getTags();
/** /**
* Return the value associated to the tag tagName * Return the value associated to the tag tagName

View File

@ -635,6 +635,7 @@ std::string maskVariableOPDSFeedData(std::string s)
" <updated>2020-03-31T00:00::00Z</updated>\n" \ " <updated>2020-03-31T00:00::00Z</updated>\n" \
" <name>wikipedia_en_ray_charles</name>\n" \ " <name>wikipedia_en_ray_charles</name>\n" \
" <flavour></flavour>\n" \ " <flavour></flavour>\n" \
" <category>jazz</category>\n" \
" <tags>unittest;wikipedia;_category:jazz;_pictures:no;_videos:no;_details:no;_ftindex:yes</tags>\n" \ " <tags>unittest;wikipedia;_category:jazz;_pictures:no;_videos:no;_details:no;_ftindex:yes</tags>\n" \
" <articleCount>284</articleCount>\n" \ " <articleCount>284</articleCount>\n" \
" <mediaCount>2</mediaCount>\n" \ " <mediaCount>2</mediaCount>\n" \
@ -658,6 +659,7 @@ std::string maskVariableOPDSFeedData(std::string s)
" <updated>2020-03-31T00:00::00Z</updated>\n" \ " <updated>2020-03-31T00:00::00Z</updated>\n" \
" <name>wikipedia_en_ray_charles</name>\n" \ " <name>wikipedia_en_ray_charles</name>\n" \
" <flavour></flavour>\n" \ " <flavour></flavour>\n" \
" <category>wikipedia</category>\n" \
" <tags>unittest;wikipedia;_category:wikipedia;_pictures:no;_videos:no;_details:no;_ftindex:yes</tags>\n" \ " <tags>unittest;wikipedia;_category:wikipedia;_pictures:no;_videos:no;_details:no;_ftindex:yes</tags>\n" \
" <articleCount>284</articleCount>\n" \ " <articleCount>284</articleCount>\n" \
" <mediaCount>2</mediaCount>\n" \ " <mediaCount>2</mediaCount>\n" \