diff --git a/src/odr/html.cpp b/src/odr/html.cpp
index 76c67eae8..ab1a49db3 100644
--- a/src/odr/html.cpp
+++ b/src/odr/html.cpp
@@ -210,34 +210,31 @@ void HtmlResource::write_resource(std::ostream &os) const {
m_impl->write_resource(os);
}
-HtmlService html::translate(const DecodedFile &file,
- const std::string &cache_path,
- const HtmlConfig &config, const Logger &logger) {
+HtmlService html::translate(const DecodedFile &file, const HtmlConfig &config,
+ const Logger &logger) {
if (file.is_text_file()) {
- return translate(file.as_text_file(), cache_path, config, logger);
+ return translate(file.as_text_file(), config, logger);
}
if (file.is_image_file()) {
- return translate(file.as_image_file(), cache_path, config, logger);
+ return translate(file.as_image_file(), config, logger);
}
if (file.is_archive_file()) {
- return translate(file.as_archive_file(), cache_path, config, logger);
+ return translate(file.as_archive_file(), config, logger);
}
if (file.is_document_file()) {
- return translate(file.as_document_file(), cache_path, config, logger);
+ return translate(file.as_document_file(), config, logger);
}
if (file.is_pdf_file()) {
- return translate(file.as_pdf_file(), cache_path, config, logger);
+ return translate(file.as_pdf_file(), config, logger);
}
if (file.is_font_file()) {
- return translate(file.as_font_file(), cache_path, config, logger);
+ return translate(file.as_font_file(), config, logger);
}
// No wrapper type to go through: nothing is decoded, so the plain
// `DecodedFile` already carries the bytes and the type that names them.
if (const FileCategory category = file.file_category();
category == FileCategory::audio || category == FileCategory::video) {
- std::filesystem::create_directories(cache_path);
- return internal::html::create_media_service(file, cache_path, config,
- logger);
+ return internal::html::create_media_service(file, config, logger);
}
throw UnsupportedFileType(file.file_type());
@@ -256,69 +253,113 @@ HtmlResourceLocator html::standard_resource_locator() {
};
}
+HtmlService html::translate(const TextFile &text_file, const HtmlConfig &config,
+ const Logger &logger) {
+ return internal::html::create_text_service(text_file, config, logger);
+}
+
+HtmlService html::translate(const ImageFile &image_file,
+ const HtmlConfig &config, const Logger &logger) {
+ return internal::html::create_image_service(image_file, config, logger);
+}
+
+HtmlService html::translate(const ArchiveFile &archive_file,
+ const HtmlConfig &config, const Logger &logger) {
+ return translate(archive_file.archive(), config, logger);
+}
+
+HtmlService html::translate(const DocumentFile &document_file,
+ const HtmlConfig &config, const Logger &logger) {
+ return translate(document_file.document(), config, logger);
+}
+
+HtmlService html::translate(const PdfFile &pdf_file, const HtmlConfig &config,
+ const Logger &logger) {
+ return internal::html::create_pdf_service(pdf_file, config, logger);
+}
+
+HtmlService html::translate(const FontFile &font_file, const HtmlConfig &config,
+ const Logger &logger) {
+ return internal::html::create_font_service(font_file, config, logger);
+}
+
+HtmlService html::translate(const Filesystem &filesystem,
+ const HtmlConfig &config, const Logger &logger) {
+ return internal::html::create_filesystem_service(filesystem, config, logger);
+}
+
+HtmlService html::translate(const Archive &archive, const HtmlConfig &config,
+ const Logger &logger) {
+ return translate(archive.as_filesystem(), config, logger);
+}
+
+HtmlService html::translate(const Document &document, const HtmlConfig &config,
+ const Logger &logger) {
+ return internal::html::create_document_service(document, config, logger);
+}
+
+// The `cache_path` overloads. Nothing reads the path: no renderer has since the
+// output became a set of streams, and the `create_directories` that used to sit
+// here made a directory nobody wrote into.
+
+HtmlService html::translate(const DecodedFile &file,
+ const std::string & /*cache_path*/,
+ const HtmlConfig &config, const Logger &logger) {
+ return translate(file, config, logger);
+}
+
HtmlService html::translate(const TextFile &text_file,
- const std::string &cache_path,
+ const std::string & /*cache_path*/,
const HtmlConfig &config, const Logger &logger) {
- std::filesystem::create_directories(cache_path);
- return internal::html::create_text_service(text_file, cache_path, config,
- logger);
+ return translate(text_file, config, logger);
}
HtmlService html::translate(const ImageFile &image_file,
- const std::string &cache_path,
+ const std::string & /*cache_path*/,
const HtmlConfig &config, const Logger &logger) {
- std::filesystem::create_directories(cache_path);
- return internal::html::create_image_service(image_file, cache_path, config,
- logger);
+ return translate(image_file, config, logger);
}
HtmlService html::translate(const ArchiveFile &archive_file,
- const std::string &cache_path,
+ const std::string & /*cache_path*/,
const HtmlConfig &config, const Logger &logger) {
- return translate(archive_file.archive(), cache_path, config, logger);
+ return translate(archive_file, config, logger);
}
HtmlService html::translate(const DocumentFile &document_file,
- const std::string &cache_path,
+ const std::string & /*cache_path*/,
const HtmlConfig &config, const Logger &logger) {
- return translate(document_file.document(), cache_path, config, logger);
+ return translate(document_file, config, logger);
}
HtmlService html::translate(const PdfFile &pdf_file,
- const std::string &cache_path,
+ const std::string & /*cache_path*/,
const HtmlConfig &config, const Logger &logger) {
- return internal::html::create_pdf_service(pdf_file, cache_path, config,
- logger);
+ return translate(pdf_file, config, logger);
}
HtmlService html::translate(const FontFile &font_file,
- const std::string &cache_path,
+ const std::string & /*cache_path*/,
const HtmlConfig &config, const Logger &logger) {
- std::filesystem::create_directories(cache_path);
- return internal::html::create_font_service(font_file, cache_path, config,
- logger);
+ return translate(font_file, config, logger);
}
HtmlService html::translate(const Filesystem &filesystem,
- const std::string &cache_path,
+ const std::string & /*cache_path*/,
const HtmlConfig &config, const Logger &logger) {
- std::filesystem::create_directories(cache_path);
- return internal::html::create_filesystem_service(filesystem, cache_path,
- config, logger);
+ return translate(filesystem, config, logger);
}
HtmlService html::translate(const Archive &archive,
- const std::string &cache_path,
+ const std::string & /*cache_path*/,
const HtmlConfig &config, const Logger &logger) {
- return translate(archive.as_filesystem(), cache_path, config, logger);
+ return translate(archive, config, logger);
}
HtmlService html::translate(const Document &document,
- const std::string &cache_path,
+ const std::string & /*cache_path*/,
const HtmlConfig &config, const Logger &logger) {
- std::filesystem::create_directories(cache_path);
- return internal::html::create_document_service(document, cache_path, config,
- logger);
+ return translate(document, config, logger);
}
void html::edit(const Document &document, const std::string_view diff,
diff --git a/src/odr/html.hpp b/src/odr/html.hpp
index e361488f4..412b419a8 100644
--- a/src/odr/html.hpp
+++ b/src/odr/html.hpp
@@ -257,50 +257,78 @@ namespace html {
HtmlResourceLocator standard_resource_locator();
-/// @brief Translates a decoded file to HTML. `cache_path` is the directory
-/// temporary output goes into.
-HtmlService translate(const DecodedFile &file, const std::string &cache_path,
- const HtmlConfig &config,
+/// @brief Translates a decoded file to HTML.
+HtmlService translate(const DecodedFile &file, const HtmlConfig &config,
const Logger &logger = Logger::null());
/// @brief Translates a text file to HTML.
+HtmlService translate(const TextFile &text_file, const HtmlConfig &config,
+ const Logger &logger = Logger::null());
+/// @brief Translates an image file to HTML.
+HtmlService translate(const ImageFile &image_file, const HtmlConfig &config,
+ const Logger &logger = Logger::null());
+/// @brief Translates an archive file to HTML.
+HtmlService translate(const ArchiveFile &archive_file, const HtmlConfig &config,
+ const Logger &logger = Logger::null());
+/// @brief Translates a document file to HTML.
+HtmlService translate(const DocumentFile &document_file,
+ const HtmlConfig &config,
+ const Logger &logger = Logger::null());
+/// @brief Translates a PDF file to HTML.
+HtmlService translate(const PdfFile &pdf_file, const HtmlConfig &config,
+ const Logger &logger = Logger::null());
+
+/// @brief Translates a font file to HTML (a specimen page).
+HtmlService translate(const FontFile &font_file, const HtmlConfig &config,
+ const Logger &logger = Logger::null());
+
+/// @brief Translates a filesystem to HTML.
+HtmlService translate(const Filesystem &filesystem, const HtmlConfig &config,
+ const Logger &logger = Logger::null());
+/// @brief Translates an archive to HTML.
+HtmlService translate(const Archive &archive, const HtmlConfig &config,
+ const Logger &logger = Logger::null());
+/// @brief Translates a document to HTML.
+HtmlService translate(const Document &document, const HtmlConfig &config,
+ const Logger &logger = Logger::null());
+
+/// @name Translation with a cache path
+///
+/// `cache_path` is ignored — nothing on the render path writes to disk, and no
+/// renderer has read it since the output became a set of streams. Kept so
+/// existing callers keep compiling; prefer the overloads above.
+/// @{
+HtmlService translate(const DecodedFile &file, const std::string &cache_path,
+ const HtmlConfig &config,
+ const Logger &logger = Logger::null());
HtmlService translate(const TextFile &text_file, const std::string &cache_path,
const HtmlConfig &config,
const Logger &logger = Logger::null());
-/// @brief Translates an image file to HTML.
HtmlService translate(const ImageFile &image_file,
const std::string &cache_path, const HtmlConfig &config,
const Logger &logger = Logger::null());
-/// @brief Translates an archive file to HTML.
HtmlService translate(const ArchiveFile &archive_file,
const std::string &cache_path, const HtmlConfig &config,
const Logger &logger = Logger::null());
-/// @brief Translates a document file to HTML.
HtmlService translate(const DocumentFile &document_file,
const std::string &cache_path, const HtmlConfig &config,
const Logger &logger = Logger::null());
-/// @brief Translates a PDF file to HTML.
HtmlService translate(const PdfFile &pdf_file, const std::string &cache_path,
const HtmlConfig &config,
const Logger &logger = Logger::null());
-
-/// @brief Translates a font file to HTML (a specimen page).
HtmlService translate(const FontFile &font_file, const std::string &cache_path,
const HtmlConfig &config,
const Logger &logger = Logger::null());
-
-/// @brief Translates a filesystem to HTML.
HtmlService translate(const Filesystem &filesystem,
const std::string &cache_path, const HtmlConfig &config,
const Logger &logger = Logger::null());
-/// @brief Translates an archive to HTML.
HtmlService translate(const Archive &archive, const std::string &cache_path,
const HtmlConfig &config,
const Logger &logger = Logger::null());
-/// @brief Translates a document to HTML.
HtmlService translate(const Document &document, const std::string &cache_path,
const HtmlConfig &config,
const Logger &logger = Logger::null());
+/// @}
/// @brief Applies a diff to a document. The diff is what our JavaScript
/// produces in the browser.
diff --git a/src/odr/internal/html/document.cpp b/src/odr/internal/html/document.cpp
index 40554e6df..73ef2659e 100644
--- a/src/odr/internal/html/document.cpp
+++ b/src/odr/internal/html/document.cpp
@@ -353,7 +353,6 @@ using PageHtmlFragment = ElementHtmlFragment;
namespace odr::internal {
HtmlService html::create_document_service(const Document &document,
- const std::string & /*cache_path*/,
HtmlConfig config,
const Logger &logger) {
std::vector> fragments;
diff --git a/src/odr/internal/html/document.hpp b/src/odr/internal/html/document.hpp
index b50687c27..298cea62e 100644
--- a/src/odr/internal/html/document.hpp
+++ b/src/odr/internal/html/document.hpp
@@ -12,8 +12,7 @@ class Logger;
namespace odr::internal::html {
-HtmlService create_document_service(const Document &document,
- const std::string &cache_path,
- HtmlConfig config, const Logger &logger);
+HtmlService create_document_service(const Document &document, HtmlConfig config,
+ const Logger &logger);
} // namespace odr::internal::html
diff --git a/src/odr/internal/html/filesystem.cpp b/src/odr/internal/html/filesystem.cpp
index ea2bb719d..79a824744 100644
--- a/src/odr/internal/html/filesystem.cpp
+++ b/src/odr/internal/html/filesystem.cpp
@@ -136,7 +136,6 @@ class HtmlServiceImpl final : public HtmlService {
namespace odr::internal {
HtmlService html::create_filesystem_service(const Filesystem &filesystem,
- const std::string & /*cache_path*/,
HtmlConfig config,
const Logger &logger) {
return odr::HtmlService(
diff --git a/src/odr/internal/html/filesystem.hpp b/src/odr/internal/html/filesystem.hpp
index cf3da7c12..5aa095fb3 100644
--- a/src/odr/internal/html/filesystem.hpp
+++ b/src/odr/internal/html/filesystem.hpp
@@ -13,7 +13,6 @@ class Logger;
namespace odr::internal::html {
HtmlService create_filesystem_service(const Filesystem &filesystem,
- const std::string &cache_path,
HtmlConfig config, const Logger &logger);
}
diff --git a/src/odr/internal/html/font_file.cpp b/src/odr/internal/html/font_file.cpp
index 18b5d2329..4b0521783 100644
--- a/src/odr/internal/html/font_file.cpp
+++ b/src/odr/internal/html/font_file.cpp
@@ -162,7 +162,6 @@ class HtmlServiceImpl final : public HtmlService {
} // namespace
odr::HtmlService create_font_service(const FontFile &font_file,
- const std::string & /*cache_path*/,
HtmlConfig config, const Logger &logger) {
return odr::HtmlService(
std::make_unique(font_file, std::move(config), logger));
diff --git a/src/odr/internal/html/font_file.hpp b/src/odr/internal/html/font_file.hpp
index db272a550..6d271b404 100644
--- a/src/odr/internal/html/font_file.hpp
+++ b/src/odr/internal/html/font_file.hpp
@@ -16,8 +16,7 @@ namespace odr::internal::html {
/// name/metrics header plus a glyph grid showing *every* glyph (including ones
/// the original `cmap` never reached), the font served via `@font-face` after
/// the uniform PUA re-encode.
-HtmlService create_font_service(const FontFile &font_file,
- const std::string &cache_path,
- HtmlConfig config, const Logger &logger);
+HtmlService create_font_service(const FontFile &font_file, HtmlConfig config,
+ const Logger &logger);
} // namespace odr::internal::html
diff --git a/src/odr/internal/html/image_file.cpp b/src/odr/internal/html/image_file.cpp
index 7a8da9b34..071bf5e15 100644
--- a/src/odr/internal/html/image_file.cpp
+++ b/src/odr/internal/html/image_file.cpp
@@ -154,7 +154,6 @@ void html::translate_image_src(const ImageFile &image_file, std::ostream &out,
}
HtmlService html::create_image_service(const ImageFile &image_file,
- const std::string & /*cache_path*/,
HtmlConfig config,
const Logger &logger) {
return odr::HtmlService(
diff --git a/src/odr/internal/html/image_file.hpp b/src/odr/internal/html/image_file.hpp
index 704a20100..45225d794 100644
--- a/src/odr/internal/html/image_file.hpp
+++ b/src/odr/internal/html/image_file.hpp
@@ -18,8 +18,7 @@ void translate_image_src(const File &file, std::ostream &out,
void translate_image_src(const ImageFile &image_file, std::ostream &out,
const HtmlConfig &config);
-HtmlService create_image_service(const ImageFile &image_file,
- const std::string &cache_path,
- HtmlConfig config, const Logger &logger);
+HtmlService create_image_service(const ImageFile &image_file, HtmlConfig config,
+ const Logger &logger);
} // namespace odr::internal::html
diff --git a/src/odr/internal/html/media_file.cpp b/src/odr/internal/html/media_file.cpp
index e350479b8..b4d6efad7 100644
--- a/src/odr/internal/html/media_file.cpp
+++ b/src/odr/internal/html/media_file.cpp
@@ -205,10 +205,9 @@ class HtmlServiceImpl final : public HtmlService {
namespace odr::internal {
-HtmlService
-html::create_media_service(const DecodedFile &media_file,
- [[maybe_unused]] const std::string &cache_path,
- HtmlConfig config, const Logger &logger) {
+HtmlService html::create_media_service(const DecodedFile &media_file,
+ HtmlConfig config,
+ const Logger &logger) {
return odr::HtmlService(
std::make_unique(media_file, std::move(config), logger));
}
diff --git a/src/odr/internal/html/media_file.hpp b/src/odr/internal/html/media_file.hpp
index 0d5edaba6..5a2f9a1cc 100644
--- a/src/odr/internal/html/media_file.hpp
+++ b/src/odr/internal/html/media_file.hpp
@@ -15,7 +15,6 @@ namespace odr::internal::html {
/// here — nothing is decoded, so the plain @ref DecodedFile carries everything
/// the page needs: the bytes and the file type they are named by.
HtmlService create_media_service(const DecodedFile &media_file,
- const std::string &cache_path,
HtmlConfig config, const Logger &logger);
} // namespace odr::internal::html
diff --git a/src/odr/internal/html/pdf_file.cpp b/src/odr/internal/html/pdf_file.cpp
index 34fe43d62..5eb75cdd9 100644
--- a/src/odr/internal/html/pdf_file.cpp
+++ b/src/odr/internal/html/pdf_file.cpp
@@ -2577,9 +2577,8 @@ class HtmlServiceImpl final : public HtmlService {
namespace odr::internal {
-HtmlService html::create_pdf_service(const PdfFile &pdf_file,
- const std::string & /*cache_path*/,
- HtmlConfig config, const Logger &logger) {
+HtmlService html::create_pdf_service(const PdfFile &pdf_file, HtmlConfig config,
+ const Logger &logger) {
return odr::HtmlService(
std::make_unique(pdf_file, std::move(config), logger));
}
diff --git a/src/odr/internal/html/pdf_file.hpp b/src/odr/internal/html/pdf_file.hpp
index 953c9d5e4..e20dcf1a7 100644
--- a/src/odr/internal/html/pdf_file.hpp
+++ b/src/odr/internal/html/pdf_file.hpp
@@ -12,8 +12,7 @@ class Logger;
namespace odr::internal::html {
-HtmlService create_pdf_service(const PdfFile &pdf_file,
- const std::string &cache_path, HtmlConfig config,
+HtmlService create_pdf_service(const PdfFile &pdf_file, HtmlConfig config,
const Logger &logger);
}
diff --git a/src/odr/internal/html/text_file.cpp b/src/odr/internal/html/text_file.cpp
index c9755fc29..4ef8168f1 100644
--- a/src/odr/internal/html/text_file.cpp
+++ b/src/odr/internal/html/text_file.cpp
@@ -141,10 +141,8 @@ class HtmlServiceImpl final : public HtmlService {
namespace odr::internal {
-HtmlService
-html::create_text_service(const TextFile &text_file,
- [[maybe_unused]] const std::string &cache_path,
- HtmlConfig config, const Logger &logger) {
+HtmlService html::create_text_service(const TextFile &text_file,
+ HtmlConfig config, const Logger &logger) {
return odr::HtmlService(
std::make_unique(text_file, std::move(config), logger));
}
diff --git a/src/odr/internal/html/text_file.hpp b/src/odr/internal/html/text_file.hpp
index d773012a5..c23a210f8 100644
--- a/src/odr/internal/html/text_file.hpp
+++ b/src/odr/internal/html/text_file.hpp
@@ -12,8 +12,7 @@ class Logger;
namespace odr::internal::html {
-HtmlService create_text_service(const TextFile &text_file,
- const std::string &cache_path,
- HtmlConfig config, const Logger &logger);
+HtmlService create_text_service(const TextFile &text_file, HtmlConfig config,
+ const Logger &logger);
}
diff --git a/test/src/internal/pdf/pdf_file.cpp b/test/src/internal/pdf/pdf_file.cpp
index 35b9aab36..b9ae1721c 100644
--- a/test/src/internal/pdf/pdf_file.cpp
+++ b/test/src/internal/pdf/pdf_file.cpp
@@ -28,7 +28,7 @@ std::shared_ptr open_pdf(const std::string &bytes) {
HtmlService make_service(const std::string &bytes, const HtmlConfig &config) {
const odr::PdfFile file(open_pdf(bytes));
const Logger logger = Logger::null();
- return internal::html::create_pdf_service(file, "", config, logger);
+ return internal::html::create_pdf_service(file, config, logger);
}
std::string render_path(const HtmlService &service, const std::string &path) {