Skip to content

Instantly share code, notes, and snippets.

Life's a garden, dig it!

Ben Nadel bennadel

Life's a garden, dig it!
View GitHub Profile
bennadel / test.cfm
Created March 29, 2023 12:26
Getting FusionReactor User Experience Monitoring (UEM) To Play Nicely With Content Security Policy (CSP) In ColdFusion
View test.cfm
frapi = createObject( "java", "com.intergral.fusionreactor.api.FRAPI" )
csp = application.contentSecurityPolicy.getCspConfig();
// Set the strict Content-Security-Policy.
cfheader( attributeCollection = csp.header );
bennadel / snippet-1.js
Created March 24, 2023 12:34
Trying To Get ChatGPT 4 To Solve My Hotwire Form Submission Problem
View snippet-1.js
document.addEventListener("DOMContentLoaded", function() {
// Get the form element
const form = document.querySelector("form");
// Listen for the Turbo Drive form submission event
form.addEventListener("turbo:submit-end", function() {
// Scroll the form back into view
bennadel / about.cfm
Created March 23, 2023 12:55
Disabling Turbo Drive In A Subdirectory Of Your ColdFusion Application
View about.cfm
<cfmodule template="./tags/page.cfm" section="about">
About This Site
Copy copy copy....
bennadel / test.cfm
Created March 22, 2023 12:37
Russian Doll Content Wrapping With CFSaveContent In ColdFusion
View test.cfm
<!--- Define the initial BODY content. --->
<cfsavecontent variable="body">
This is the body!
bennadel / injector.js
Last active March 26, 2023 12:03
Incrementally Applying Hotwire To An Existing ColdFusion Application
View injector.js
// Import application modules.
import { ApiClient } from "./api-client.js";
// ----------------------------------------------------------------------------------- //
// ----------------------------------------------------------------------------------- //
export var apiClient = new ApiClient();
bennadel / ViewHelper.cfc
Created March 15, 2023 13:08
I've Never Had A Good Story For View-Rendering Helpers In ColdFusion
View ViewHelper.cfc
output = false
hint = "I provide utility methods for rendering HTML in a view template."
* I output the given attribute with proper attribute encoding. If the value is a
* complex data structure, it is serialized as JSON.
public string function attr(
bennadel / index.cfm
Created March 14, 2023 11:38
Using Nested Stimulus Controllers With Hotwire And Lucee CFML
View index.cfm
items = [
{ id: 1, name: "Item One" },
{ id: 2, name: "Item Two" },
{ id: 3, name: "Item Three" }
<cfmodule template="./tags/page.cfm">
bennadel / a.cfm
Created March 13, 2023 10:43
Using "return" To Short-Circuit A CFML Template In ColdFusion
View a.cfm
writeOutput( "A-1 <br />" );
writeOutput( "A-2 <br />" );
bennadel / _create.cfm
Created March 12, 2023 16:45
Rendering A Fly-Out Form Panel Using Turbo Frames With Hotwire And Lucee CFML
View _create.cfm
When rendered as a top-level request, we can render the form AS-IS. However, if we're
rendering inside a Turbo Frame (ie, we're trancluding the form into another page), we
have to render the form inside a like-named Turbo Frame so that Hotwire can merge the
results back into the live page.
NOTE: In a more robust architecture, this could be implemented much more seamlessly as
a layout selection, such as a "standard" layout vs a "fly-out" layout. However, to
keep things as simple as possible, I'm rendering both types of layouts right here in
the same template so that we can see the mechanics at play.
bennadel / index.cfm
Created March 7, 2023 12:19
Styling Submit Buttons During Form Submission With Hotwire And Lucee CFML
View index.cfm
if ( request.isPost ) {
// Sleeping to give us time to observe the busy-state of the submit button.
sleep( 2000 );
location( url = "index.htm?signed=true", addToken = false );