LibraryDumper::content{Server -> Access}Url

Renamed contentServerUrl in LibraryDumper to contentAccessUrl to avoid
confusion with contentServerUrl concept at Server/InternalServer level
(roughly, contentAccessUrl = contentServerUrl + "/content").
This commit is contained in:
Veloman Yunkan 2025-09-13 18:01:57 +04:00
parent 67b7e25494
commit d0a48cc9cc
7 changed files with 20 additions and 20 deletions

View File

@ -130,7 +130,7 @@ std::string HTMLDumper::dumpPlainHTML(kiwix::Filter filter) const
RESOURCE::templates::no_js_library_page_html, RESOURCE::templates::no_js_library_page_html,
kainjow::mustache::object{ kainjow::mustache::object{
{"root", rootLocation}, {"root", rootLocation},
{"contentServerUrl", onlyAsNonEmptyMustacheValue(contentServerUrl)}, {"contentAccessUrl", onlyAsNonEmptyMustacheValue(contentAccessUrl)},
{"books", booksData }, {"books", booksData },
{"searchQuery", searchQuery}, {"searchQuery", searchQuery},
{"languages", languages}, {"languages", languages},

View File

@ -51,11 +51,11 @@ class LibraryDumper
void setRootLocation(const std::string& rootLocation) { this->rootLocation = rootLocation; } void setRootLocation(const std::string& rootLocation) { this->rootLocation = rootLocation; }
/** /**
* Set the URL of the content server. * Set the URL for accessing book content
* *
* @param url the URL of the content server to use. * @param url the URL of the /content endpoint of the content server
*/ */
void setContentServerUrl(const std::string& url) { this->contentServerUrl = url; } void setContentAccessUrl(const std::string& url) { this->contentAccessUrl = url; }
/** /**
* Set some informations about the search results. * Set some informations about the search results.
@ -88,7 +88,7 @@ class LibraryDumper
const kiwix::NameMapper* const nameMapper; const kiwix::NameMapper* const nameMapper;
std::string libraryId; std::string libraryId;
std::string rootLocation; std::string rootLocation;
std::string contentServerUrl; std::string contentAccessUrl;
std::string m_userLang; std::string m_userLang;
int m_totalResults; int m_totalResults;
int m_startIndex; int m_startIndex;

View File

@ -64,13 +64,13 @@ IllustrationInfo getBookIllustrationInfo(const Book& book)
std::string fullEntryXML(const Book& book, std::string fullEntryXML(const Book& book,
const std::string& rootLocation, const std::string& rootLocation,
const std::string& contentServerUrl, const std::string& contentAccessUrl,
const std::string& contentId) const std::string& contentId)
{ {
const auto bookDate = book.getDate() + "T00:00:00Z"; const auto bookDate = book.getDate() + "T00:00:00Z";
const kainjow::mustache::object data{ const kainjow::mustache::object data{
{"root", rootLocation}, {"root", rootLocation},
{"contentServerUrl", onlyAsNonEmptyMustacheValue(contentServerUrl)}, {"contentAccessUrl", onlyAsNonEmptyMustacheValue(contentAccessUrl)},
{"id", book.getId()}, {"id", book.getId()},
{"name", book.getName()}, {"name", book.getName()},
{"title", book.getTitle()}, {"title", book.getTitle()},
@ -111,7 +111,7 @@ BooksData getBooksData(const Library* library,
const NameMapper* nameMapper, const NameMapper* nameMapper,
const std::vector<std::string>& bookIds, const std::vector<std::string>& bookIds,
const std::string& rootLocation, const std::string& rootLocation,
const std::string& contentServerUrl, const std::string& contentAccessUrl,
bool partial) bool partial)
{ {
BooksData booksData; BooksData booksData;
@ -121,7 +121,7 @@ BooksData getBooksData(const Library* library,
const std::string contentId = nameMapper->getNameForId(bookId); const std::string contentId = nameMapper->getNameForId(bookId);
const auto entryXML = partial const auto entryXML = partial
? partialEntryXML(book, rootLocation) ? partialEntryXML(book, rootLocation)
: fullEntryXML(book, rootLocation, contentServerUrl, contentId); : fullEntryXML(book, rootLocation, contentAccessUrl, contentId);
booksData.push_back(kainjow::mustache::object{ {"entry", entryXML} }); booksData.push_back(kainjow::mustache::object{ {"entry", entryXML} });
} catch ( const std::out_of_range& ) { } catch ( const std::out_of_range& ) {
// the book was removed from the library since its id was obtained // the book was removed from the library since its id was obtained
@ -136,7 +136,7 @@ BooksData getBooksData(const Library* library,
string OPDSDumper::dumpOPDSFeed(const std::vector<std::string>& bookIds, const std::string& query) const string OPDSDumper::dumpOPDSFeed(const std::vector<std::string>& bookIds, const std::string& query) const
{ {
const auto booksData = getBooksData(library, nameMapper, bookIds, rootLocation, contentServerUrl, false); const auto booksData = getBooksData(library, nameMapper, bookIds, rootLocation, contentAccessUrl, false);
const kainjow::mustache::object template_data{ const kainjow::mustache::object template_data{
{"date", gen_date_str()}, {"date", gen_date_str()},
{"root", rootLocation}, {"root", rootLocation},
@ -154,7 +154,7 @@ string OPDSDumper::dumpOPDSFeed(const std::vector<std::string>& bookIds, const s
string OPDSDumper::dumpOPDSFeedV2(const std::vector<std::string>& bookIds, const std::string& query, bool partial) const string OPDSDumper::dumpOPDSFeedV2(const std::vector<std::string>& bookIds, const std::string& query, bool partial) const
{ {
const auto endpointRoot = rootLocation + "/catalog/v2"; const auto endpointRoot = rootLocation + "/catalog/v2";
const auto booksData = getBooksData(library, nameMapper, bookIds, rootLocation, contentServerUrl, partial); const auto booksData = getBooksData(library, nameMapper, bookIds, rootLocation, contentAccessUrl, partial);
const char* const endpoint = partial ? "/partial_entries" : "/entries"; const char* const endpoint = partial ? "/partial_entries" : "/entries";
const std::string url = endpoint + (query.empty() ? "" : "?" + query); const std::string url = endpoint + (query.empty() ? "" : "?" + query);
@ -179,7 +179,7 @@ std::string OPDSDumper::dumpOPDSCompleteEntry(const std::string& bookId) const
const std::string contentId = nameMapper->getNameForId(bookId); const std::string contentId = nameMapper->getNameForId(bookId);
return XML_HEADER return XML_HEADER
+ "\n" + "\n"
+ fullEntryXML(book, rootLocation, contentServerUrl, contentId); + fullEntryXML(book, rootLocation, contentAccessUrl, contentId);
} }
std::string OPDSDumper::categoriesOPDSFeed() const std::string OPDSDumper::categoriesOPDSFeed() const

View File

@ -858,9 +858,9 @@ std::unique_ptr<Response> InternalServer::handle_no_js(const RequestContext& req
htmlDumper.setRootLocation(m_root); htmlDumper.setRootLocation(m_root);
htmlDumper.setLibraryId(getLibraryId()); htmlDumper.setLibraryId(getLibraryId());
if ( !m_contentServerUrl.empty() ) { if ( !m_contentServerUrl.empty() ) {
htmlDumper.setContentServerUrl(m_contentServerUrl + "/content"); htmlDumper.setContentAccessUrl(m_contentServerUrl + "/content");
} else if ( !m_catalogOnlyMode ) { } else if ( !m_catalogOnlyMode ) {
htmlDumper.setContentServerUrl(m_root + "/content"); htmlDumper.setContentAccessUrl(m_root + "/content");
} }
auto userLang = request.get_user_language(); auto userLang = request.get_user_language();
htmlDumper.setUserLanguage(userLang); htmlDumper.setUserLanguage(userLang);

View File

@ -57,9 +57,9 @@ OPDSDumper InternalServer::getOPDSDumper() const
opdsDumper.setRootLocation(m_root); opdsDumper.setRootLocation(m_root);
opdsDumper.setLibraryId(getLibraryId()); opdsDumper.setLibraryId(getLibraryId());
if ( !m_contentServerUrl.empty() ) { if ( !m_contentServerUrl.empty() ) {
opdsDumper.setContentServerUrl(m_contentServerUrl + "/content"); opdsDumper.setContentAccessUrl(m_contentServerUrl + "/content");
} else if ( !m_catalogOnlyMode ) { } else if ( !m_catalogOnlyMode ) {
opdsDumper.setContentServerUrl(m_root + "/content"); opdsDumper.setContentAccessUrl(m_root + "/content");
} }
return opdsDumper; return opdsDumper;
} }

View File

@ -13,8 +13,8 @@
{{#icons}}<link rel="http://opds-spec.org/image/thumbnail" {{#icons}}<link rel="http://opds-spec.org/image/thumbnail"
href="{{root}}/catalog/v2/illustration/{{{id}}}/?size={{icon_size}}" href="{{root}}/catalog/v2/illustration/{{{id}}}/?size={{icon_size}}"
type="{{icon_mimetype}};width={{icon_size}};height={{icon_size}};scale=1"/> type="{{icon_mimetype}};width={{icon_size}};height={{icon_size}};scale=1"/>
{{/icons}}{{#contentServerUrl}}<link type="text/html" href="{{contentServerUrl}}/{{{content_id}}}" /> {{/icons}}{{#contentAccessUrl}}<link type="text/html" href="{{contentAccessUrl}}/{{{content_id}}}" />
{{/contentServerUrl}} {{/contentAccessUrl}}
<author> <author>
<name>{{author_name}}</name> <name>{{author_name}}</name>
</author> </author>

View File

@ -107,7 +107,7 @@
<h3 class="kiwixHomeBody__results">{{translations.count-of-matching-books}}</h3> <h3 class="kiwixHomeBody__results">{{translations.count-of-matching-books}}</h3>
{{#books}} {{#books}}
<div class="book__wrapper"> <div class="book__wrapper">
{{#contentServerUrl}}<a class="book__link" href="{{contentServerUrl}}/{{id}}" title="{{translations.preview-book}}" aria-label="{{translations.preview-book}}">{{/contentServerUrl}} {{#contentAccessUrl}}<a class="book__link" href="{{contentAccessUrl}}/{{id}}" title="{{translations.preview-book}}" aria-label="{{translations.preview-book}}">{{/contentAccessUrl}}
<div class="book__link__wrapper"> <div class="book__link__wrapper">
<div class="book__icon" {{faviconAttr}}></div> <div class="book__icon" {{faviconAttr}}></div>
<div class="book__header"> <div class="book__header">
@ -115,7 +115,7 @@
</div> </div>
<div class="book__description" title="{{description}}">{{description}}</div> <div class="book__description" title="{{description}}">{{description}}</div>
</div> </div>
{{#contentServerUrl}}</a>{{/contentServerUrl}} {{#contentAccessUrl}}</a>{{/contentAccessUrl}}
<div class="book__meta"> <div class="book__meta">
<div class="book__languageTag" title="{{langTag.langFullString}}" aria-label="{{langTag.langFullString}}">{{langTag.langShortString}}</div> <div class="book__languageTag" title="{{langTag.langFullString}}" aria-label="{{langTag.langFullString}}">{{langTag.langShortString}}</div>
<div class="book__tags"><div class="book__tags--wrapper"> <div class="book__tags"><div class="book__tags--wrapper">