Form processing with Total.js and jComponent
masterjComponent library. It provides a pattern for capturing user input via UI components and rendering the resulting data within the application.repository·master·Indexed 19 days ago
https://github.com/totaljs/examplesA collection of practical examples for the Total.js framework. It demonstrates the implementation of common web patterns including CRUD, GraphQL, mail controllers, Basic Access Authentication (BAA), and the use of Blocks for conditional rendering in HTML, CSS, and JS files. The repository also covers FlowStream workflows, image processing middleware, and form processing using jComponent.
jComponent library. It provides a pattern for capturing user input via UI components and rendering the resulting data within the application.The controller-mail example demonstrates how to implement e-mail templating within a Total.js application. It covers the core components required for email functionality:
https://github.com/totaljs/examples/tree/master/controller-mailThe Auth example demonstrates how to implement authentication in a Total.js application using the following core components:
AUTH() delegate: The primary mechanism for handling authentication logic and checking user credentials.SESSION() object: Used to manage user session state on the server-side.To implement similar functionality, you should leverage the AUTH() delegate to intercept requests and validate them against your session management logic.
By default, controller.baa() only checks HTTP headers. To support credentials embedded directly in the URI (e.g., https://user:password@example.com/), you must manually check this.req.uri.auth and populate the auth object.
function authorization() {
var auth = this.baa();
if (auth.empty) {
if (this.req.uri.auth) {
// Parse credentials from URI: user:password
let creds = this.req.uri.auth.split(':');
auth.user = creds[0];
auth.password = creds[1];
auth.empty = false;
} else {
this.baa('Admin Login Required.');
return;
}
}
}Total.js supports inline Flow files (located in flowstreams/*.flow) that allow you to create workflows, services, or extend application functionality.
Key characteristics:
flowstreams/*.flow files and automatically restarts the application whenever a change is detected..flow files into the Total.js Flow editor.Total.js views use specific tags to handle layouts, conditional logic, and data injection:
@{layout('name')}: Sets the layout for the view. Use @{layout('')} for no layout.@{if condition} ... @{fi}: Conditional block. You can check for the existence of query parameters using @{if query.key}.@{model.key}: Outputs a property from the data model passed to the view.@{query.key}: Outputs a value from the URL query string.<!-- Example: Conditional logic based on query string and layout usage -->
@{layout('')}
@{if query.success}
<div style="background-color:#E0E0E0;padding:10px">E-mail was sent.</div
<br />
@{fi}
<!-- Example: Accessing model data -->
<h1
@{model.name}</h1>Blocks are conditional statements used in HTML templates (views), CSS, and JS files. They allow you to maintain a single source file that can be rendered into multiple versions by enabling specific blocks. This minimizes file maintenance and reduces the payload size sent to clients by only including code relevant to the current scenario (e.g., admin-only vs. user-only code).
Key Rules:
@{BLOCK} and @{END} tags must always be on separate lines.MAP() method or conditionally via @{if}/@{import} in HTML templates.You can listen for specific lifecycle events in the TMS using the SUBSCRIBE() method. In this example, you can subscribe to events related to the users schema, such as:
users_insertusers_updateusers_removeWhen a new user is created, a subscriber to users_insert will receive a message containing the newly created user object.
users schema located in schemas/users.js. The application uses a declared array USERS as the underlying storage for user data. You can perform standard CRUD operations (list, read, create, update, remove) on users using either a REST API or Total's built-in API routing.Basic Access Authentication (BAA) allows you to authenticate users via the Authorization: Basic <mime-encoded-userid-and-password> HTTP header.
Security Warning: BAA does not encrypt credentials. It should only be used over HTTPS connections.
Default credentials for this example:
totaljs123456function authorization() {
var auth = this.baa(); // 'this' refers to the controller
// auth contains:
// auth.empty (boolean)
// auth.user (string)
// auth.password (string)
}node index.js, open your web browser and navigate to http://127.0.0.1:8000 to interact with the remote terminal.http://127.0.0.1:8000To set up the Vue.js CRUD App with Vue Router & Axios, install the project dependencies using npm.
npm install