Skip to content

Commit

Permalink
fix passthrough evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
jclausen committed Nov 28, 2024
1 parent 9bda6d7 commit fc7a144
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 113 deletions.
144 changes: 38 additions & 106 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,43 @@
# ⚡︎ BoxLang Module: Boxlang UI Forms Module

## Components

This module contributes the following Components to the language:

* `form` - the wrapping HTML `<form...></form>` component other HTML form tag components. Produces an HTML form.
* `input` - the `<input.../>` HTML form component
* `select` - the `<select ... ></select>` HTML form component
* `slider` - generates an [HTML 5 input range slider](https://www.w3schools.com/tags/att_input_type_range.asp)
* `textarea` - the `<textarea>...</textarea>` HTML form component

The majority of attributes to these components serve as pass-through attributes to the generated HTML tag. Exceptions to these, by tag, include:

### `form`

* `format` - this attribute will throw an error if present and is anything other than `HTML`. XML and Flash forms are not supported.
* `passthrough` - this is a list of passthrough attributes which will be added to the form tag.
* `scriptsrc` - this defines an external location for the custom forms javascript file, which is sourced into the HTML output
* `preservedata` - When the form action posts back to the page that contains the form, this attribute determines whether to override the control values with the submitted values.

#### Unsupported `form` Component Attributes

The following attributes are unsupported and generate a warning log message if used.

* `enablecab`
* `skin`
* `preloader`
* `timeout`
* `wmode`
* `accessible`
* `archive`
* `codebase`

### `input`

* `label` - if provided, will generate an HTML `label` tag before the generated `input` tag
* `message` - can be provided as a custom message if validation fails
* `passthrough` - this is a list of passthrough attributes which will be added to the form tag.

```
|:------------------------------------------------------:|
| ⚡︎ B o x L a n g ⚡︎
Expand All @@ -14,113 +52,7 @@
<a href="https://www.ortussolutions.com">www.ortussolutions.com</a>
</blockquote>

<p>&nbsp;</p>

This template can be used to create Ortus based BoxLang Modules. To use, just click the `Use this Template` button in the github repository: https://github.com/boxlang-modules/module-template and run the setup task from where you cloned it.

```bash
box task run taskFile=src/build/SetupTemplate
```

The `SetupTemplate` task will ask you for your module name, id and description and configure the template for you! Enjoy!

## Directory Structure

Here is a brief overview of the directory structure:

* `.github/workflows` - These are the github actions to test and build the module via CI
* `build` - This is a temporary non-sourced folder that contains the build assets for the module that gradle produces
* `gradle` - The gradle wrapper and configuration
* `src` - Where your module source code lives
* `.cfformat.json` - A CFFormat using the Ortus Standards
* `.editorconfig` - Smooth consistency between editors
* `.gitattributes` - Git attributes
* `.gitignore` - Basic ignores. Modify as needed.
* `.markdownlint.json` - A linting file for markdown docs
* `.ortus-java-style.xml` - Ortus Java Style for IntelliJ, VScode, Eclipse.
* `box.json` - The box.json for your module used to publish to ForgeBox
* `build.gradle` - The gradle build file for the module
* `changelog.md` - A nice changelog tracking file
* `CONTRIBUTING.md` - A contribution guideline
* `gradlew` - The gradle wrapper
* `gradlew.bat` - The gradle wrapper for windows
* `ModuleConfig.cfc` - Your module's configuration. Modify as needed.
* `readme.md` - Your module's readme. Modify as needed.
* `settings.gradle` - The gradle settings file

Here is a brief overview of the source directory structure:

* `build` - Build scripts and assets
* `main` - The main module source code
* `bx` - The BoxLang source code
* `ModuleConfig.bx` - The BoxLang module configuration
* `bifs` - BoxLang built-in functions
* `components` - BoxLang components
* `config` - BoxLang configuration, schedulers, etc.
* `interceptors` - BoxLang interceptors
* `libs` - Java libraries to use that are NOT managed by gradle
* `models` - BoxLang models
* `java` - Java source code
* `resources` - Resources for the module placed in final jar
* `test`
* `bx` - The BoxLang test code
* `java` - Java test code
* `resources` - Resources for testing
* `libs` - BoxLang binary goes here for now.

## Project Properties

The project name is defined in the `settings.gradle` file. You can change it there.
The project version, BoxLang Version and JDK version is defined in the `build.gradle` file. You can change it there.

## Gradle Tasks

Before you get started, you need to run the `downloadBoxLang` task in order to download the latest BoxLang binary until we publish to Maven.

```bash
gradle downloadBoxLang
```

This will store the binary under `/src/test/resources/libs` for you to use in your tests and compiler. Here are some basic tasks


| Task | Description |
|---------------------|---------------------------------------------------------------------------------------------------------------------|
| `build` | The default lifecycle task that triggers the build process, including tasks like `clean`, `assemble`, and others. |
| `clean` | Deletes the `build` folders. It helps ensure a clean build by removing any previously generated artifacts. |
| `compileJava` | Compiles Java source code files located in the `src/main/java` directory |
| `compileTestJava` | Compiles Java test source code files located in the `src/test/java` directory |
| `dependencyUpdates` | Checks for updated versions of all dependencies |
| `downloadBoxLang` | Downloads the latest BoxLang binary for testing |
| `jar` | Packages your project's compiled classes and resources into a JAR file `build/libs` folder |
| `javadoc` | Generates the Javadocs for your project and places them in the `build/docs/javadoc` folder |
| `serviceLoader` | Generates the ServiceLoader file for your project |
| `spotlessApply` | Runs the Spotless plugin to format the code |
| `spotlessCheck` | Runs the Spotless plugin to check the formatting of the code |
| `tasks` | Show all the available tasks in the project |
| `test` | Executes the unit tests in your project and produces the reports in the `build/reports/tests` folder |

## Tests

Please use the `src/test` folder for your unit tests. You can either test using TestBox o JUnit if it's Java.

## Github Actions Automation

The github actions will clone, test, package, deploy your module to ForgeBox and the Ortus S3 accounts for API Docs and Artifacts. So please make sure the following environment variables are set in your repository.

> Please note that most of them are already defined at the org level
* `FORGEBOX_TOKEN` - The Ortus ForgeBox API Token
* `AWS_ACCESS_KEY` - The travis user S3 account
* `AWS_ACCESS_SECRET` - The travis secret S3

> Please contact the admins in the `#infrastructure` channel for these credentials if needed

## Ortus Sponsors

BoxLang is a professional open-source project and it is completely funded by the [community](https://patreon.com/ortussolutions) and [Ortus Solutions, Corp](https://www.ortussolutions.com). Ortus Patreons get many benefits like a cfcasts account, a FORGEBOX Pro account and so much more. If you are interested in becoming a sponsor, please visit our patronage page: [https://patreon.com/ortussolutions](https://patreon.com/ortussolutions)

### THE DAILY BREAD

> "I am the way, and the truth, and the life; no one comes to the Father, but by me (JESUS)" Jn 14:1-12
15 changes: 13 additions & 2 deletions src/main/bx/components/Input.bx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class{
var nonHTMLAttributes = [ "sourcefortooltip", "validateat", "range", "validate", "bindattribute", "bindonload", "onvalidate", "form", "formaction", "formenctype", "formmethod", "formnovalidate", "formtarget", "daynames", "firstdayofweek", "monthnames" ];
var unsupportedAttributes = [ "bind" ];
var conditionalAtrributes = [ "checked", "disabled", "autofocus" ];
var evaluativeAttributes = [ "label", "message"];
var evaluativeAttributes = [ "label", "message", "passthrough" ];

// TODO: For now disable all ajax attributes until we implement them in the JS
if( AJAXAttributes.some( ( key ) => !isNull( attributes[ key ] ) ) ){
Expand Down Expand Up @@ -77,7 +77,18 @@ class{
} );

if( !isNull( attributes.passthrough ) ){
tagContent &= " #attributes.passthrough#";
if( isStruct( attributes.passthrough ) ){
attributes.passthrough.each( ( key, value ) => {
tagContent &= " #key#=""#encodeForHTMLAttribute( value )#""";
} );
} else if( isArray ( attributes.passthrough ) ){
attributes.passthrough.each( ( key, value ) => {
tagContent &= " #value#";
} );
}
else{
tagContent &= " #attributes.passthrough#";
}
}

conditionalAtrributes.each( ( key ) => {
Expand Down
17 changes: 14 additions & 3 deletions src/main/bx/components/Select.bx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class{
);
}

var nonHTMLAttributes = [ "casesenstive", "query", "passthrough", "group", "queryposition", "tooltip", "visible", "editable" ];
var nonHTMLAttributes = [ "casesenstive", "query", "group", "queryposition", "tooltip", "visible", "editable" ];
var conditionalAtrributes = [ "disabled", "autofocus", "ondblclick" ];
var evaluativeAttributes = [ "label", "selected", "enabled" ];
var evaluativeAttributes = [ "label", "selected", "enabled", "passthrough" ];
var promotedAttributes = [ "datasrc", "dataformatas", "dir", "lang" ]

var isHTMLAttribute = ( key ) => !nonHTMLAttributes.contains( key ) && !conditionalAtrributes.contains( key ) && !evaluativeAttributes.contains( key ) && !promotedAttributes.contains( key );
Expand All @@ -60,7 +60,18 @@ class{
} );

if( !isNull( attributes.passthrough ) ){
tagContent &= " #attributes.passthrough#";
if( isStruct( attributes.passthrough ) ){
attributes.passthrough.each( ( key, value ) => {
tagContent &= " #key#=""#encodeForHTMLAttribute( value )#""";
} );
} else if( isArray ( attributes.passthrough ) ){
attributes.passthrough.each( ( key, value ) => {
tagContent &= " #value#";
} );
}
else{
tagContent &= " #attributes.passthrough#";
}
}

if( !isNull( attributes.enabled ) && !attributes.enabled ){
Expand Down
15 changes: 13 additions & 2 deletions src/main/bx/components/TextArea.bx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class{

var nonHTMLAttributes = [ "sourcefortooltip", "validateat", "range", "validate", "bind", "bindattribute", "bindonload", "onvalidate", "form", "formaction", "formenctype", "formmethod", "formnovalidate", "formtarget", "daynames", "firstdayofweek", "monthnames" ];
var conditionalAtrributes = [ "disabled", "autofocus" ];
var evaluativeAttributes = [ "label", "message"];
var evaluativeAttributes = [ "label", "message", "passthrough" ];
var unsupportedAttributes = [ "stylesXML", "templatesXML", "richtext", "toolbar", "toolbarOnFocus" ];
var promotedAttributes = [ "datasrc", "dataformatas", "dir", "lang" ]

Expand Down Expand Up @@ -61,7 +61,18 @@ class{
} );

if( !isNull( attributes.passthrough ) ){
tagContent &= " #attributes.passthrough#";
if( isStruct( attributes.passthrough ) ){
attributes.passthrough.each( ( key, value ) => {
tagContent &= " #key#=""#encodeForHTMLAttribute( value )#""";
} );
} else if( isArray ( attributes.passthrough ) ){
attributes.passthrough.each( ( key, value ) => {
tagContent &= " #value#";
} );
}
else{
tagContent &= " #attributes.passthrough#";
}
}

if( !isNull( attributes.enabled ) && !attributes.enabled ){
Expand Down

0 comments on commit fc7a144

Please sign in to comment.