Commit graph

57 commits

Author SHA1 Message Date
Martin Hebnes Pedersen
6760cbcf63 Pass automatic locator updates to forms manager 2025-08-31 18:55:35 +02:00
Martin Hebnes Pedersen
713d20a491 Call app.Close from main 2025-06-20 12:58:25 +02:00
Martin Hebnes Pedersen
6ae942e13b Refactor to prepare for hot reloading of config
* Remove singletons
* Split into app, cli and api packages

Ref #6
2025-06-14 07:50:42 +02:00
Martin Hebnes Pedersen
361973623e Search --template path in forms dir if not found 2025-06-12 21:21:52 +02:00
Martin Hebnes Pedersen
d840b17101 Add endpoints for text-template editor in web gui 2025-05-29 16:47:10 +02:00
Martin Hebnes Pedersen
d6701547f0 Fix duplicate subfolders in form catalog listing 2025-05-29 08:36:33 +02:00
Martin Hebnes Pedersen
922b4ba43f templates: Add support for {FormFolder} tag
Resolves #458
2025-05-26 11:37:58 +02:00
Martin Hebnes Pedersen
32448b138b Strip whitespace from Standard Forms version str
Version 1.1.6.0 was released as `1.1.6\t.0`.
2025-01-12 21:32:10 +01:00
Martin Hebnes Pedersen
34f38822b5 Add CLI command templates
With subcommands `update` and `seqset`.

Deprecates command `updateforms`.
2024-12-27 14:43:14 +01:00
Martin Hebnes Pedersen
3a2c12b6b3 Add support for template sequence numbers 2024-12-27 13:55:28 +01:00
Martin Hebnes Pedersen
4d1615fbf8 Enhance support for reply templates
* Add insertion tags MsgOriginal*
* Insert original body as citation at the end of the message.
2024-12-19 23:53:46 +01:00
Martin Hebnes Pedersen
839b147853 Remove use of deprecated ioutil package 2024-12-13 12:13:56 +01:00
Martin Hebnes Pedersen
0a497087b9 Build forms folder using fs.WalkDir 2024-04-13 07:33:20 +02:00
Martin Hebnes Pedersen
4d7ab34e65 Cleanup 2024-04-13 07:33:20 +02:00
Martin Hebnes Pedersen
64dd3cd29d Resolve Form files by referencing the template
By referencing the template instead of the "initial_uri" (Forms
composer), the backend is able to more precisely identify the correct
HTML file for any given template. It also makes handling of reply
templates much easier.

In addition to a less complex implementation, this simplifies the API as
we no longer need to supply the frontend with URIs for all HTML
variants. We also get increased performance because of the simplified
file search, and by not having to parse reply templates upfront.

This also opens up the possibility of serving a specialized HTML-based
composer for text-only templates in the future, without having to change
the existing frontend.
2024-04-13 07:33:20 +02:00
Martin Hebnes Pedersen
6129ee5302 Fallback to global file reference search
Some templates references HTML Forms and reply templates located in
adjecent folders, without specifying a relative path. Examples of this
can be found in `MAPPING-GIS FORMS`.
2024-04-13 07:33:20 +02:00
Martin Hebnes Pedersen
60474bde9e Marshal XML attachment using the xml package 2024-04-13 07:33:20 +02:00
Martin Hebnes Pedersen
bda13dc25e Refactor gridSquare position formatting 2024-04-13 07:33:20 +02:00
Martin Hebnes Pedersen
9db0706843 More refactoring (split source files) 2024-04-13 07:33:20 +02:00
Martin Hebnes Pedersen
55e58e460a Improve form variable prompting in CLI composer
Forms-enabled templates is not written with a CLI user in mind. By
echoing the template line before prompting for a <Var ...>, it will
hopefully be possible to understand the meaning of the variable (by
context).

Also apply a hack to refresh the regular expressions used by
varReplacer, to avoid prompting for the same variable multiple times.
2024-04-13 07:33:20 +02:00
Martin Hebnes Pedersen
780891c19c Distinguish Template from Form
(HTML) Forms is an extension of the Templates feature in RMS Express.
Templates are the .txt files. Some templates support HTML forms,
indicated by the Template Control Field `Form`.
2024-04-13 07:33:20 +02:00
Martin Hebnes Pedersen
87e02d5481 More refactoring (split source files) 2024-04-13 07:33:20 +02:00
Martin Hebnes Pedersen
72238a3038 Cleanup (read form file) 2024-04-13 07:33:20 +02:00
Martin Hebnes Pedersen
d626aedeaf Refactor variable substitution
Variable substitution is essentially the same as tag insertion, so the
two features can share the same underlying implementation.
2024-04-13 07:33:20 +02:00
Martin Hebnes Pedersen
5ff709abe2 Refactor insertion tags and use for all templates
Also make the search case-insentitive since caseness is not strictly
handled in HTML forms. Unsupported insertion tags are logged (debug).
2024-01-20 18:38:09 +00:00
Martin Hebnes Pedersen
c409d48804 Support <Ask> and <Select> prompts in templates
Ref #375
2024-01-20 18:38:09 +00:00
Martin Hebnes Pedersen
b58e0fa78b Support attached_text (formData.txt)
Resolves #437
2023-12-29 11:11:12 +01:00
Martin Hebnes Pedersen
d4d06ae48a Avoid defaults overriding values from form
Fixes ignored MsgTo, MsgBcc and other common fields.
2023-12-29 11:06:00 +01:00
Martin Hebnes Pedersen
87f28ba9c2 Remove unnecessary FormData struct
This was making the code more complex, as it made an unnecessary
fragmentation between the cli composer and the web gui. Many of the
fields exposed via the web api was in fact unused.
2023-12-29 09:58:09 +01:00
Martin Hebnes Pedersen
fadac07de0 Cleanup 2023-12-29 09:57:46 +01:00
Martin Hebnes Pedersen
97d494fede Simplify getFormsVersion()
No need to traverse the whole file system when the exact location to the
.dat file is already known.
2023-12-28 16:13:09 +01:00
Martin Hebnes Pedersen
145aff55dd Solve file references relative to template path
Makes it possible to load templates outside the Standard Forms folder.
Mostly applicable for `composeform --template [path]`.
2023-12-28 16:06:59 +01:00
Martin Hebnes Pedersen
c37e2ec74b Hardening related to resolving Forms files
Improved error handling, more efficient search and make sure we don't
escape the Forms root directory. Also adds debug logging and fixes some
reply templates we missed before.
2023-12-23 15:21:27 +01:00
Martin Hebnes Pedersen
2f30d0f033 Refactor date parsing in forms and add tests 2023-10-16 13:55:02 +00:00
Martin Hebnes Pedersen
6b75f18b78 Only attach Forms XML if a viewer file is defined
Resolves #420
2023-09-22 20:26:17 +02:00
Martin Hebnes Pedersen
09460b59a1 internal/forms: Cleanup for improved readability 2023-04-17 07:59:50 +02:00
Martin Hebnes Pedersen
322113331a Minor cleanup 2023-04-16 14:03:50 +02:00
Emil Sit
b901f76a1a forms: better parse support for to/cc/body
Add support for parsing To/Cc fields and passing an array
of addresses back to the compose window.

Improve handling of Msg. As per the templates [spec][]:

> Msg: -- Start of message body. All text following Msg: is placed in the body of the message.

and a few templates have text and variables on the same line as the "Msg:".
Therefore, simply strip out the Msg: and use that to mark the rest of
the template as being part of the body.

[spec]: http://www.philsherrod.com/Winlink/RMS_Express_Message_Templates.pdf

[Changed "var inBody = true" to "inBody := true" per Martin's
 suggestion]
Signed-off-by: Corey Minyard <cminyard@mvista.com>
2023-04-16 13:57:20 +02:00
richcannings
ebca544fe1 Extend case insensitivity to form file extensions
Form file extensions are case sensitive, issue #384.

This change allows for any case of .html and .txt form files.
2022-12-18 12:13:36 +01:00
Alan Crosswell
46a890059a Add several (some undocumented) insertion tags that are required for the Winlink Check In form. 2022-04-09 21:24:34 +02:00
Martin Hebnes Pedersen
441fda35c4 Graceful shutdown through context cancellation
By doing graceful shutdown, we're able to properly close all of the open
resources such as modem connections and ongoing sessions.

This will allow transport drivers controlling stateful TNCs (e.g.
ptc-go) to recover the initial TNC state before termination.

Resolves #314
2022-02-20 14:48:29 +01:00
Martin Hebnes Pedersen
f387b8e9a0 Use new self-hosted API for Forms updates
Closes #306
2021-12-06 00:53:39 +01:00
Martin Hebnes Pedersen
1ba06731db Cleanup and improve error handling of forms unzip 2021-12-02 18:24:19 +01:00
Martin Hebnes Pedersen
095f6d1cc5 Don't delete /tmp when updating forms
Resolves #300
2021-12-02 18:24:19 +01:00
Chris Keller
966d2b2a11 Include root errors 2021-10-24 22:42:46 +02:00
Chris Keller
5a6764bce1 Revamp customized file paths
* Deprecate `forms_path` in the config file and replace with `--forms` flag
* Clean up `optionsSet()` to show correct defaults
* Clean up places that detected when `forms_path` was not configured (before it had a default)

Resolves https://github.com/la5nta/pat/issues/287
2021-10-24 22:42:46 +02:00
Todd E Johnson
11d115ba03 Update the other MkdirAll to 0755 2021-09-18 18:42:48 +02:00
Todd E Johnson
97a2417266 When unziping forms and mkdir use 0755 2021-09-18 18:41:58 +02:00
Chris Keller
e68850056e Fix some Go linter errors
* Replace(..., -1) with ReplaceAll
* Variable names hiding packages
* Error messages start with lowercase and no end punctuation
* Don't `defer` in a loop
* Etc.
2021-08-20 21:35:21 +02:00
Chris Keller
a6f4bee6b7 Address many linter errors in forms.go 2021-07-30 09:25:38 +02:00