exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit 825321ec6cbd0112eeea0e3a444dee8b0ed4c49e
parent 3080a6c63b6e9842af94a9f82eec4001bd2a55e2
Author: Christian Grothoff <christian@grothoff.org>
Date:   Wed,  4 Mar 2026 22:52:43 +0100

update libtalermhd to find typst templates in local packages if that is specified

Diffstat:
Msrc/exchange/exchange.conf | 2+-
Msrc/exchange/taler-exchange-httpd_aml-attributes-get.c | 6++++++
Msrc/include/taler/taler_mhd_lib.h | 5+++++
Msrc/mhd/mhd_typst.c | 37++++++++++++++++++-------------------
Msrc/mhd/test_typst.c | 4++--
Msrc/mhd/test_typst.conf | 2+-
6 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/src/exchange/exchange.conf b/src/exchange/exchange.conf @@ -134,7 +134,7 @@ PRIVACY_DIR = ${TALER_DATA_HOME}terms/ PRIVACY_ETAG = exchange-pp-v0 # Where are the Typst templates for form rendering. -TYPST_TEMPLATES = ${DATADIR}typst-forms/ +TYPST_TEMPLATES = @taler-exchange [exchange-sanctionscheck] # Name where we store the sanctions check offset. diff --git a/src/exchange/taler-exchange-httpd_aml-attributes-get.c b/src/exchange/taler-exchange-httpd_aml-attributes-get.c @@ -216,6 +216,8 @@ dump_attachment (struct ResponseContext *rc, = json_incref ((json_t *) attach); rc->details.pdf.docs[rc->details.pdf.off].form_name = NULL; /* inline PDF */ + rc->details.pdf.docs[rc->details.pdf.off].form_version + = NULL; /* none */ rc->details.pdf.docs[rc->details.pdf.off].data = rc->details.pdf.jdata[rc->details.pdf.off]; rc->details.pdf.off++; @@ -421,6 +423,8 @@ detail_cb ( = attrs; rc->details.pdf.docs[rc->details.pdf.off].form_name = form_id; + rc->details.pdf.docs[rc->details.pdf.off].form_version + = NULL; /* not yet supported! */ rc->details.pdf.docs[rc->details.pdf.off].data = rc->details.pdf.jdata[rc->details.pdf.off]; rc->details.pdf.off++; @@ -527,6 +531,8 @@ build_cover_page ( = cover; rc->details.pdf.docs[rc->details.pdf.off].form_name = "_cover_"; + rc->details.pdf.docs[rc->details.pdf.off].form_version + = NULL; /* not yet supported! */ rc->details.pdf.docs[rc->details.pdf.off].data = rc->details.pdf.jdata[rc->details.pdf.off]; rc->details.pdf.off++; diff --git a/src/include/taler/taler_mhd_lib.h b/src/include/taler/taler_mhd_lib.h @@ -1173,6 +1173,11 @@ struct TALER_MHD_TypstDocument const char *form_name; /** + * Typst version of the form, if NULL we will use "0.0.0". + */ + const char *form_version; + + /** * Form data. */ const json_t *data; diff --git a/src/mhd/mhd_typst.c b/src/mhd/mhd_typst.c @@ -616,25 +616,26 @@ setup_stage (struct TypstStage *stage, /* setup main input Typst file */ { char *intyp; - char *template_fn; - - GNUNET_asprintf (&template_fn, - "%s%s.typ", - template_path, - doc->form_name); - if (GNUNET_YES != - GNUNET_DISK_file_test_read (template_fn)) - { - GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, - "access", - template_fn); - GNUNET_free (template_fn); - return false; - } + size_t slen = strlen (doc->form_name); + bool is_dot_typ = ( (slen > 4) && + (0 == memcmp (&doc->form_name[slen - 4], + ".typ", + 4)) ); + + /* We do not append the ":$VERSION" if a filename ending with ".typ" + is given. Otherwise we append the version, or ":0.0.0" if no + explicit version is given. */ GNUNET_asprintf (&intyp, - "#import \"%s\": form\n" + "#import \"%s/%s%s%s\": form\n" "#form(json(\"%s/%u/input.json\"))\n", - template_fn, + template_path, + doc->form_name, + is_dot_typ ? "" : ":", + is_dot_typ + ? "" + : ( (NULL == doc->form_version) + ? "0.0.0" + : doc->form_version), tmpdir, i); GNUNET_asprintf (&input, @@ -652,10 +653,8 @@ setup_stage (struct TypstStage *stage, input); GNUNET_free (input); GNUNET_free (intyp); - GNUNET_free (template_fn); return false; } - GNUNET_free (template_fn); GNUNET_free (intyp); } diff --git a/src/mhd/test_typst.c b/src/mhd/test_typst.c @@ -98,11 +98,11 @@ run (void *cls, }; struct TALER_MHD_TypstDocument docs[] = { { - .form_name = "test_typst_1", + .form_name = "test_typst_1.typ", .data = forms[0], }, { - .form_name = "test_typst_1", + .form_name = "test_typst_1.typ", .data = forms[1], }, }; diff --git a/src/mhd/test_typst.conf b/src/mhd/test_typst.conf @@ -1,2 +1,2 @@ [test-typst] -TYPST_TEMPLATES = ${PWD}/ +TYPST_TEMPLATES = ${PWD}