Skip to content
This repository has been archived by the owner on Feb 8, 2019. It is now read-only.

Commit

Permalink
Merge branch 'Antisamy'
Browse files Browse the repository at this point in the history
  • Loading branch information
James Mohler committed Oct 3, 2015
2 parents ffebf55 + 67fbd01 commit d68c4d0
Show file tree
Hide file tree
Showing 83 changed files with 3,468 additions and 1,282 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# BS-4-CF
Bootstrap tags for Adobe ColdFusion
# Bootstrap for ColdFusion


Simplify Bootstrap and ColdFusion
Simplifying both Bootstrap and ColdFusion


# Why is this interesting?
Expand All @@ -14,7 +13,7 @@ The two put together are highly unreadable and difficult to debug. This is where
BootsFaces for JSF shows the way to a cleaner approach. So what I have done is created a similar library for ColdFusion.


### Without BS-4-CF
### Without Bootstrap for ColdFusion
```
<cfif showme>
<button type="button" class="btn btn-default btn-lg">
Expand All @@ -25,7 +24,7 @@ BootsFaces for JSF shows the way to a cleaner approach. So what I have done is c
```


### With BS-4-CF
### With Bootstrap for ColdFusion

```
<b:button processed="#showme#" binding="savelabel" icon="floppy-disk" size="lg" />
Expand Down
20 changes: 15 additions & 5 deletions application.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,32 @@

component {

this.name="bs-4-cf-17";
this.name="bs-4-cf-34";
this.applicationManagement = true;
this.sessionManagement = true;


function onApplicationStart() {
application.Bootstrap = {

// Antisamy options
isSafeHTML = ["buttongroup","buttontoolbar","column","container","dropmenu","fieldset","formgroup","head",
"jumbotron","modal","navbar","navbarlinks","navlink","panel","row","table","tabview","tr","well"], // these tags to not run through getSafeHTML
profile = "", // blank means use system default
throwOnError = false, // Default behavior for getSafeHTML()


actionRoot = cgi.script_name,
IconLibrary = {"default" = "glyphicon glyphicon-", "awesome" = "fa fa-"},
ImageLibrary = {"default" = replace(cgi.script_name, "/index.cfm", "") & "/assets/"},
StyleSheetLibrary = {"default" = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"},
ScriptLibrary = {"default" = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"}
validLook = ["", "link", "default", "primary", "success", "info", "warning", "danger"], // There does not guarantee they are valid

iconLibrary = {"default" = "glyphicon glyphicon-", "awesome" = "fa fa-", "jquery-ui" = "ui-icon ui-icon-"}, // be sure to include ending dashes
imageLibrary = {"default" = replace(cgi.script_name, "/index.cfm", "") & "/assets/"}, // used by b:graphicImage
styleSheetLibrary = {"default" = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"}, // used by b:outputStyleSheet
scriptLibrary = {"default" = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js", local="assets/"} // used by b:outputScript
};



} // end onApplicationStart


Expand Down
45 changes: 32 additions & 13 deletions bootstrap/alert.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,50 @@ case "start" :
variables.result = "";
variables.crlf = chr(13) & chr(10);
param attributes.closable = false;
param attributes.id = "";
param attributes.look = "warning";
param attributes.processed = true;
param attributes.rendered = true;
param attributes.title = "";
param attributes.tooltip = "";
param attributes.closable = false;
param attributes.id = "";
param attributes.isSafeHTML = application.Bootstrap.isSafeHTML.contains("alert");
param attributes.key = "";
param attributes.placeholder = [];
param attributes.look = "warning";
param attributes.processed = true;
param attributes.profile = application.Bootstrap.profile;
param attributes.rendered = true;
param attributes.throwOnError = application.Bootstrap.throwOnError;
param attributes.title = "";
param attributes.tooltip = "";
param attributes.tooltipPosition = "bottom";
if (!attributes.processed) exit "exitTag";
if (!application.Bootstrap.validLook.contains(attributes.look)) throw "This is an invalid look option";
if (!attributes.processed) exit "exitTag";
break;
case "end" :
variables.result &= '<div class="alert alert-#lcase(attributes.look)#';
variables.result &= '<div class="alert alert-#encodeForHTMLAttribute(attributes.look.lcase())#';
if(attributes.closable) variables.result &= ' alert-dismissible';
variables.result &= '"';
if(attributes.id != "") variables.result &= ' id="#attributes.id#"';
if(attributes.tooltip != "") variables.result &= ' tooltip="#attributes.tooltip#"';
if(attributes.id != "") variables.result &= ' id="#encodeForHTMLAttribute(attributes.id)#"';
if(attributes.tooltip != "") variables.result &= ' title="#encodeForHTMLAttribute(attributes.tooltip)#"';
if(attributes.tooltip != "") variables.result &= ' data-placement="#encodeForHTMLAttribute(attributes.tooltipPosition)#"';
if(attributes.tooltip != "") variables.result &= ' data-toggle="tooltip"';
variables.result &= '>';
if(attributes.closable) variables.result &= '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>';
if(attributes.title != "") variables.result &= '<strong>#attributes.title#</strong>';
if(attributes.title != "") variables.result &= '<strong>#encodeForHTML(attributes.title)#</strong>';
variables.result &= variables.crlf;
if(attributes.title != "") variables.result &= '<br />';
variables.result &= thisTag.GeneratedContent; // pass through of content
if(!attributes.isSafeHTML) variables.result &= getSafeHTML(thisTag.GeneratedContent.trim(), attributes.profile, attributes.throwOnError); // pass through of content
if( attributes.isSafeHTML) variables.result &= thisTag.GeneratedContent.trim(); // warning content must already be clean
variables.result &= '</div><!-- /.alert -->';
variables.result &= variables.crlf;
Expand Down
92 changes: 62 additions & 30 deletions bootstrap/badge.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,80 @@
<cfscript>
if (!thisTag.HasEndTag)
abort "An end tag is required for b:badge.";
switch (thisTag.ExecutionMode) {
switch (thisTag.ExecutionMode) {
case "start" :
variables.result = "";
variables.crlf = chr(13) & chr(10);
param attributes.binding = "";
param attributes.id = "";
param attributes.look = "warning";
param attributes.processed = true;
param attributes.rendered = true;
param attributes.tooltip = "";
param attributes.value = "";
param attributes.binding = "";
param attributes.id = "";
param attributes.isSafeHTML = application.Bootstrap.isSafeHTML.contains("badge");
param attributes.look = "warning";
param attributes.key = "";
param attributes.placeholder = [];
param attributes.processed = true;
param attributes.profile = application.Bootstrap.profile;
param attributes.rendered = true;
param attributes.throwOnError = application.Bootstrap.throwOnError;
param attributes.tooltip = "";
param attributes.tooltipPosition = "bottom";
param attributes.value = "";
if (structKeyExists(attributes, "text")) throw "attributes.text is an invalid option. Don't even think of using it";
if (!application.Bootstrap.validLook.contains(attributes.look)) throw "This is an invalid look option";
variables.arAttrSeries = [];
// We will be passing through HTML5 data-, Mouse Events, and Angular JS
for(variables.myKey in attributes) {
if (left(variables.myKey, 5) == "data-" || left(variables.myKey, 2) == "on" || left(variables.myKey, 3) == "ng-") {
ArrayAppend(arAttrSeries, {key = variables.myKey, value = attributes[variables.myKey] });
} // end if
} // end for
if (structKeyExists(attributes, "text")) throw "attributes.text is an invalid option. Don't even think of using it";
if (!attributes.processed) exit "exitTag";
if (!attributes.processed) exit "exitTag";
break;
case "end" :
if(attributes.binding != "" && isDefined("caller.rc.#attributes.binding#")) attributes.text = xmlformat(evaluate("caller.rc.#attributes.binding#"));
variables.result &= '<span class="badge badge-#lcase(attributes.look)#"';
if(attributes.id != "") variables.result &= ' id="#attributes.id#"';
if(attributes.tooltip != "") variables.result &= ' title="#attributes.tooltip#"';
case "end" :
if(attributes.value != "") thisTag.generatedContent = attributes.value;
if(attributes.binding != "" && isDefined("caller.rc.#attributes.binding#")) thisTag.generatedContent = evaluate("caller.rc.#attributes.binding#");
variables.result &= '<span class = "badge badge-#encodeForHTMLAttribute(attributes.look.lcase())#"';
if(attributes.id != "") variables.result &= ' id = "#encodeForHTMLAttribute(attributes.id)#"';
for(variables.myAttr in variables.arAttrSeries) variables.result &= ' #variables.myAttr.key.lcase()#="#encodeForHTMLAttribute(variables.myAttr.value)#"';
if(attributes.tooltip != "") variables.result &= ' title = "#encodeForHTMLAttribute(attributes.tooltip)#"';
if(attributes.tooltip != "") variables.result &= ' data-placement="#encodeForHTMLAttribute(attributes.tooltipPosition)#"';
if(attributes.tooltip != "") variables.result &= ' data-toggle="tooltip"';
variables.result &= '>';
variables.result &= attributes.value; // pass through of content
if(!attributes.isSafeHTML) variables.result &= getSafeHTML(thisTag.GeneratedContent.trim(), attributes.profile, attributes.throwOnError); // pass through of content
if( attributes.isSafeHTML) variables.result &= thisTag.GeneratedContent.trim(); // warning content must already be clean
variables.result &= '</span>';
thisTag.GeneratedContent = ""; // This tag does not have pass through
if (attributes.rendered) writeOutput(variables.result);
if (attributes.rendered) writeOutput(variables.result);
break;
}
</cfscript>
59 changes: 42 additions & 17 deletions bootstrap/blockquote.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,60 @@ case "start" :
variables.result = "";
variables.crlf = chr(13) & chr(10);
param attributes.binding = "";
param attributes.id = "";
param attributes.processed = true;
param attributes.reverse = false;
param attributes.rendered = true; // removes content not actuall td
param attributes.style = "";
param attributes.styleClass = "";
param attributes.text = "";
param attributes.tooltip = "";
param attributes.binding = "";
param attributes.id = "";
param attributes.isSafeHTML = application.Bootstrap.isSafeHTML.contains("blockquote");
param attributes.key = "";
param attributes.placeholder = [];
param attributes.processed = true;
param attributes.profile = application.Bootstrap.profile;
param attributes.reverse = false;
param attributes.rendered = true;
param attributes.style = "";
param attributes.styleClass = "";
param attributes.text = "";
param attributes.throwOnError = application.Bootstrap.throwOnError;
param attributes.tooltip = "";
param attributes.tooltipPosition = "bottom";
variables.arAttrSeries = [];
// We will be passing through HTML5 data-, Mouse Events, and Angular JS
for(variables.myKey in attributes) {
if (left(variables.myKey, 5) == "data-" || left(variables.myKey, 2) == "on" || left(variables.myKey, 3) == "ng-") {
ArrayAppend(arAttrSeries, {key = variables.myKey, value = attributes[variables.myKey] });
} // end if
} // end for
if (!attributes.processed) exit "exitTag";
break;
case "end" :
if(attributes.binding != "" && isDefined("caller.rc.#attributes.binding#")) thisTag.GeneratedContent = xmlFormat(evaluate("caller.rc.#attributes.binding#"));
if(attributes.binding != "" && isDefined("caller.rc.#attributes.binding#")) thisTag.GeneratedContent = evaluate("caller.rc.#attributes.binding#");
variables.result &= '<blockquote class="';
if(attributes.reverse) variables.result &= ' blockquote-reverse';
if(attributes.text != "") variables.result &= ' text-#attributes.text#';
if(attributes.styleClass != "") variables.result &= ' #attributes.styleClass#';
if(attributes.text != "") variables.result &= ' text-#encodeForHTMLAttribute(attributes.text)#';
if(attributes.styleClass != "") variables.result &= ' #encodeForHTMLAttribute(attributes.styleClass)#';
variables.result &= '"';
if(attributes.id != "") variables.result &= ' id="#attributes.id#"';
if(attributes.style != "") variables.result &= ' style="#attributes.style#"';
if(attributes.tooltip != "") variables.result &= ' title="#attributes.tooltip#"';
if(attributes.id != "") variables.result &= ' id="#encodeForHTMLAttribute(attributes.id)#"';
for(variables.myAttr in variables.arAttrSeries) variables.result &= ' #variables.myAttr.key.lcase()#="#encodeForHTMLAttribute(variables.myAttr.value)#"';
if(attributes.style != "") variables.result &= ' style="#encodeForCSS(attributes.style)#"';
if(attributes.tooltip != "") variables.result &= ' title="#encodeForHTMLAttribute(attributes.tooltip)#"';
if(attributes.tooltip != "") variables.result &= ' data-placement="#encodeForHTMLAttribute(attributes.tooltipPosition)#"';
if(attributes.tooltip != "") variables.result &= ' data-toggle="tooltip"';
variables.result &= '>';
variables.result &= trim(thisTag.GeneratedContent); // pass through of content
if(!attributes.isSafeHTML) variables.result &= getSafeHTML(thisTag.GeneratedContent.trim(), attributes.profile, attributes.throwOnError); // pass through of content
if( attributes.isSafeHTML) variables.result &= thisTag.GeneratedContent.trim(); // warning content must already be clean
variables.result &= '</blockquote>';
Expand Down
Loading

0 comments on commit d68c4d0

Please sign in to comment.