mirror of https://github.com/kiwix/libkiwix.git
Add tags in tiles for /nojs endpoint
Adds span elements for tags
This commit is contained in:
parent
6071b98fb7
commit
c1d7cc37fd
|
@ -1,6 +1,7 @@
|
|||
#include "html_dumper.h"
|
||||
#include "libkiwix-resources.h"
|
||||
#include "tools/otherTools.h"
|
||||
#include "tools.h"
|
||||
|
||||
namespace kiwix
|
||||
{
|
||||
|
@ -15,6 +16,23 @@ HTMLDumper::~HTMLDumper()
|
|||
{
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
kainjow::mustache::list getTagList(std::string tags)
|
||||
{
|
||||
const auto tagsList = kiwix::split(tags, ";", true, false);
|
||||
kainjow::mustache::list finalTagList;
|
||||
for (auto tag : tagsList) {
|
||||
if (tag[0] != '_')
|
||||
finalTagList.push_back(kainjow::mustache::object{
|
||||
{"tag", tag}
|
||||
});
|
||||
}
|
||||
return finalTagList;
|
||||
}
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
std::string HTMLDumper::dumpPlainHTML() const
|
||||
{
|
||||
kainjow::mustache::list booksData;
|
||||
|
@ -24,12 +42,14 @@ std::string HTMLDumper::dumpPlainHTML() const
|
|||
const auto bookDescription = bookObj.getDescription();
|
||||
const auto langCode = bookObj.getCommaSeparatedLanguages();
|
||||
const auto bookIconUrl = rootLocation + "/catalog/v2/illustration/" + bookId + "/?size=48";
|
||||
const auto tags = bookObj.getTags();
|
||||
std::string faviconAttr = "style=background-image:url(" + bookIconUrl + ")";
|
||||
booksData.push_back(kainjow::mustache::object{
|
||||
{"title", bookTitle},
|
||||
{"description", bookDescription},
|
||||
{"langCode", langCode},
|
||||
{"faviconAttr", faviconAttr}
|
||||
{"faviconAttr", faviconAttr},
|
||||
{"tagList", getTagList(tags)}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,10 @@
|
|||
.book__wrapper:hover {
|
||||
transform: scale(1.0);
|
||||
}
|
||||
|
||||
.tag__link {
|
||||
pointer-events: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -57,7 +61,11 @@
|
|||
</div>
|
||||
</a>
|
||||
<div class="book__languageTag" {{languageAttr}}>{{langCode}}</div>
|
||||
<div class="book__tags"><div class="book__tags--wrapper">TO DO: TAGS</div>
|
||||
<div class="book__tags"><div class="book__tags--wrapper">
|
||||
{{#tagList}}
|
||||
<span class="tag__link" aria-label='{{tag}}' title='{{tag}}'>{{tag}}</span>
|
||||
{{/tagList}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/books}}
|
||||
|
|
Loading…
Reference in New Issue