The Newt programs are configured in a YAML file. Each Newt program may focus on some properties and ignore others. What is described below is the complete YAML syntax use in a Newt project that uses all of the Newt programs.
These are the top level properties in YAML files.
applicationsmodelsroutestemplatesThe applications properties are optional. Some maybe set via command line. See Newt application’s manual page for specific ones. These properties lets you override the default settings of Newt programs.
routermustachepostgrespostgrestnewt
optionsenvironmentapp_pathnewt
conf_pathnamespaceporthtdocsRoutes hosts a list of request descriptions and their data pipelines. This property is only used by Newt router and Newt code generator.
iddescriptionrequest [METHOD ][PATH]GET /items/{item_id} would make item_id
available in building your service paths in the pipeline. The pattern
takes up a whole path segment so /blog/{year}-{month}-{day}
would not work but /blog/{year}/{month}/{day} would capture
the individual elements. The Newt router sits closely on top of the Go
1.22 HTTP package route handling. For the details on how Go 1.22 and
above request handlers and patterns form see See https://tip.golang.org/doc/go1.22#enhanced_routing_patterns
and https://pkg.go.dev/net/http#hdr-Patterns for
explanations.
pipelinedebugnewt service will log verbose
results to standard out for this specific pipeline
A pipeline is a list of web services containing a type, URL, method and content types
service [METHOD ][URL].application.environment. All the elements extracted from
the elements derived from the request path are passed through strings.
These are then used to construct a simple key-value object of variable
names and objects which are then passed through the Mustache template
representing the target service URL.
descriptiontimeoutModels holds a list of individual models used by our data pipelines. The models are used by Newt code generator and the Newt router. Models were inspired by a subset of GitHub YAML issue template syntax (abbr: GHYITS). Models contain lists of elements, elements are descriptions of HTML5 input elements and their attributes.
The model object is based largely on GitHub YAML issue template syntax with a couple extra properties that are Newt enhancements.
idThe following properties are inspired by GitHub YAML issue template syntax3 (abbr: GHYITS)
descriptionelementsThis is based on HTML5 form input types. They were inspired by GitHub YAML issue template (abbr: GHYITS) input types4.
idtypeattributesprimary_keyThe model types supported in Newt are based on the HTML5 form input types. They are inspired by GHYITS scheme6. Example types include
textinput[type=date].
textareadropdowncheckboxesemailSee https://developer.mozilla.org/en-US/docs/Learn/Forms/HTML5_input_types for more possibilities.
IMPORTANT: Newt does NOT support the file input type because Newt applications do not support file uploads.
Newt extends support for additional identifiers used by galleries, libraries, archives and museum by generating the necessary validation at the SQL level and use regular expressions in the pattern attribute of HTML5 input elements. When expressed as HTML these can be identified by the additional attribute “extended-type”.
<input type="text" extended-type="orcid" pattern="[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9A-Z]">applications:
router:
port: 8010
htdocs: htdocs
template_engine:
port: 8011
postgres:
namespace: people
port: 5432
dsn: postgres://{PGUSER}:{PGPASSWORD}@localhost:5432/people.yaml
postgrest:
app_path: postgrest
conf_path: postgrest.conf
port: 3000
enviroment:
- PGUSER
- PGPASSWORD
models:
- id: people
description: |
This models a curated set of profiles of colleagues
routes:
- id: people_create
request: GET /people_create
description: Handle retrieving the webform for people create
pipeline:
- service: POST http://localhost:8011/people_create
description: Display a people for create
- id: people_create
request: POST /people_create
description: Handle form submission for people create
pipeline:
- service: POST http://localhost:3000/rpc/people_create
description: Access PostgREST API for people create
- service: POST http://localhost:8011/people_create_response
description: This is an result template for people create
- id: people_update
request: GET /people_update/{oid}
description: Handle retrieving the webform for people update
pipeline:
- service: GET http://localhost:3000/rpc/people_read/{oid}
description: Retrieve people from PostgREST API before update
- service: POST http://localhost:8011/people_update
description: Display a people for update
- id: people_update
request: POST /people_update
description: Handle form submission for people update
pipeline:
- service: PUT http://localhost:3000/rpc/people_update/{oid}
description: Access PostgREST API for people update
- service: POST http://localhost:8011/people_update_response
description: This is an result template for people update
- id: people_delete
request: GET /people_delete/{oid}
description: Handle retrieving the webform for people delete
pipeline:
- service: GET http://localhost:3000/rpc/people_read/{oid}
description: Retrieve people from PostgREST API before delete
- service: POST http://localhost:8011/people_delete
description: Display a people for delete
- id: people_delete
request: POST /people_delete
description: Handle form submission for people delete
pipeline:
- service: DELETE http://localhost:3000/rpc/people_delete/{oid}
description: Access PostgREST API for people delete
- service: POST http://localhost:8011/people_delete_response
description: This is an result template for people delete
- id: people_read
request: POST /people_read
description: Retrieve object(s) for people read
pipeline:
- service: GET http://localhost:3000/rpc/people_read/{oid}
description: Access PostgREST API for people read
- service: POST http://localhost:8011/people_read
description: This template handles people read
- id: people_list
request: POST /people_list
description: Retrieve object(s) for people list
pipeline:
- service: GET http://localhost:3000/rpc/people_list
description: Access PostgREST API for people list
- service: POST http://localhost:8011/people_list
description: This template handles people list
templates:
- id: people_create
request: /people_create
template: people_create_form.tmpl
description: Display a people for create
- id: people_create
request: /people_create_response
template: people_create_response.tmpl
description: This is an result template for people create
- id: people_update
request: /people_update
template: people_update_form.tmpl
description: Display a people for update
- id: people_update
request: /people_update_response
template: people_update_response.tmpl
description: This is an result template for people update
- id: people_delete
request: /people_delete
template: people_delete_form.tmpl
description: Display a people for delete
- id: people_delete
request: /people_delete_response
template: people_delete_response.tmpl
description: This is an result template for people delete
- id: people_read
request: /people_read
template: people_read.tmpl
description: This template handles people read
- id: people_list
request: /people_list
template: people_list.tmpl
description: This template handles people listThis property is used by Newt Mustache. It allows Newt Mustache to map a POST to a specific template or template and set of partials.
The template objects are used by Newt Mustache template engine. If you’re not using it you can skip these. Newt Mustache only responds to POST methods which have a defined path in the templates section of the Newt YAML template file.
idrequest [PATH]{name} used in the YAML below.
templatepartials.template.
vocabulariesoptionsdebugExample of newtmustache YAML:
applications:
template_engine:
port: 8012
templates:
- id: hello
request: /hello/{name}
template: testdata/simple.tmpl
- id: hello
request: /hello
template: testdata/simple.tmpl
options:
name: Universe
- id: hi
request: /hi/{name}
template: testdata/hithere.tmpl
partials:
- testdata/name.tmpl
debug: true
- id: hi
request: /hi
template: testdata/hithere.tmpl
partials:
- testdata/name.tmpl
options:
name: Universevariable numbers must start with a letter, may contain numbers but not spaces or punctuation except the underscore↩︎
variable numbers must start with a letter, may contain numbers but not spaces or punctuation except the underscore↩︎
See https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-issue-forms,↩︎
See https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema↩︎
variable numbers must start with a letter, may contain numbers but not spaces or punctuation except the underscore↩︎
See https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema↩︎