Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ The release run heads these entries with the version and opens a fresh

## Unreleased

- CLI `meta` accepts every decoded file type, `server` detects the input instead
of forcing ZIP, and `back_translate` supports editable text and CSV files.
The CLI container preserves executable permissions and forwards arguments.

- WebAssembly CSV editing, saving and rendering share one document. CSV and
Markdown capability and locale queries now use their document interfaces.

Expand Down
6 changes: 3 additions & 3 deletions cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:26.04@sha256:f3d28607ddd78734bb7f71f117f3c6706c666b8b76cbff7c9ff6e5718d46ff64

RUN mkdir -p /install/bin
ADD install/bin /install/bin
COPY install/bin /install/bin
RUN chmod +x /install/bin/*

ENTRYPOINT /install/bin/translate
ENTRYPOINT ["/install/bin/translate"]
20 changes: 13 additions & 7 deletions cli/src/back_translate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,25 @@ int main(const int argc, char **argv) {
const std::string diff_path{argv[2]};
const std::string output{argv[3]};

const DocumentFile document_file = open(input).as_document_file();
const DecodedFile file = open(input);

if (document_file.password_encrypted()) {
if (file.password_encrypted()) {
ODR_FATAL(logger, "encrypted documents are not supported");
return 1;
}

const Document document = document_file.document();

const std::string diff = internal::util::file::read(diff_path);
document.edit(diff);

document.save(output);
if (file.is_text_file()) {
const TextFile text = file.as_text_file();
text.edit(diff, logger);
text.save(output);
} else {
const Document document = file.is_csv_file()
? file.as_csv_file().document()
: file.as_document_file().document();
document.edit(diff, logger);
document.save(output);
}

return 0;
} catch (const std::exception &e) {
Expand Down
9 changes: 4 additions & 5 deletions cli/src/meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,22 @@ int main(const int argc, char **argv) {
password = argv[2];
}

DocumentFile document_file = open(input).as_document_file();
DecodedFile file = open(input);

if (document_file.password_encrypted()) {
if (file.password_encrypted()) {
if (!password) {
ODR_FATAL(logger, "document encrypted but no password given");
return 2;
}
try {
document_file = document_file.decrypt(*password);
file = file.decrypt(*password);
} catch (const WrongPasswordError &) {
ODR_FATAL(logger, "wrong password");
return 1;
}
}

const auto json =
internal::util::meta::meta_to_json(document_file.file_meta());
const auto json = internal::util::meta::meta_to_json(file.file_meta());
std::cout << json.dump(4) << '\n';

return 0;
Expand Down
9 changes: 3 additions & 6 deletions cli/src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@ int main(const int argc, char **argv) {
try {
const Logger logger = Logger::create_stdio("odr-server", LogLevel::verbose);

std::string input{argv[1]};
const std::string input{argv[1]};

std::optional<std::string> password;
if (argc >= 3) {
password = argv[2];
}

// the server offers the container's own entries beside the render, so a
// package is opened as the zip it is
DecodedFile decoded_file =
open(input, DecodeOptions::as(FileType::zip), logger);
DecodedFile decoded_file = open(input, {}, logger);

if (decoded_file.password_encrypted()) {
if (!password) {
Expand Down Expand Up @@ -64,7 +61,7 @@ int main(const int argc, char **argv) {
const HtmlService service =
html::translate(decoded_file, html_config, logger);
server.connect_service(service, prefix);
const HtmlViews views = service.list_views();
const HtmlViews &views = service.list_views();
ODR_INFO(logger, "hosted decoded file with id: " << prefix);
for (const auto &view : views) {
ODR_INFO(logger, base_url << "/file/" << prefix << "/" << view.path());
Expand Down
Loading