), elements using an ID, and classes if you use a '.' to prefix the class name.
Usage to remove our postData tag that indicates that LD+Json is being used: removeStr(value, "postData")
Usage to remove the 'foo' class from a string: removeStrBetween(str, '.foo');
*/
var removeStrBetween = function(str, selector) {
// Create a new container to operate on
var wrapped = $(" " + str + " ");
// Remove the content between the tags.
wrapped.find(selector).remove();
// Return it
return wrapped.html();
}
// Function to truncate and add an elipsis if the text exceeds a certain value
function truncateWithEllipses(text, max) {
return text.substr(0,max-1)+(text.length>max?'...':'');
}
function stripHtml(html){
html.replace(/<[^>]*>?/gm, '');
return html;
}
// Determine if a string has a space
function hasWhiteSpace(s) {
const whitespaceChars = [' ', '\t', '\n'];
return whitespaceChars.some(char => s.includes(char));
}
// ColdFusion like string functions
// ReplaceNoCase, scope is either 'all' or 'one'.
// Gregory Alexander
function replaceNoCase(string,subString,replacement, scope){
if (scope == 'all'){
// i is a RegEx ignore case flag, g is global flag
var regEx = new RegExp(subString, "ig");
} else {
// i is an RegEx ignore case flag
var regEx = new RegExp(subString, "i");
}
// i is an ignore case flag, g is global flag
var regEx = new RegExp(subString, "ig");
var result = string.replace(regEx, replacement);
return result;
}
// ColdFusion like list functions
function listLen(list, delimiter){
// Gregory Alexander
if(delimiter == null) { delimiter = ','; }
var thisLen = list.split(delimiter);
return thisLen.length;
}
function listGetAt(list, position, delimiter, zeroIndex) {
// Gregory Alexander
if(delimiter == null) { delimiter = ','; }
if(zeroIndex == null) { zeroIndex = true; }
list = list.split(delimiter);
if(list.length > position) {
if(zeroIndex){
// Better handling for JavaScript arrays
return list[position];
} else {
// Handles like the CF version without a zero-index
return list[position-1];
}
} else {
return 0;
}
}
function listFind(list, value, delimiter) {
// Adapted from a variety of sources by Gregory Alexander
var result = 0;
if(delimiter == null) delimiter = ',';
list = list.split(delimiter);
for ( var i = 0; i < list.length; i++ ) {
if ( value == list[i] ) {
result = i + 1;
return result;
}
}
return result;
}
// Compares two lists of comma seperated strings. Used to determine if the selected capabilities match the default capabilities for a given role. Function based on the listCompare method found in cflib.
function listCompare(string1, string2){
// Adapted from a variety of sources by Gregory Alexander
var s = string1.split(",");
for(var k = 0 ;k < s.length; k++){
if(string2.indexOf("," + s[k] + ",") ){
return true;
}
}
return false;
}
// Adds a value to a comma separated list. Will not add the value if the list already contains the value.
function listAppend(list, value) {
// Adapted from a variety of sources by Gregory Alexander
var re = new RegExp('(^|\\b)' + value + '(\\b|$)');
if (!re.test(list)) {
return list + (list.length? ',' : '') + value;
}
return list;
}
// Removes a value to a comma separated list. Based on the ListDeleteValue function by Ben Nadel CF fuction https://gist.github.com/bennadel/9753040
var listDeleteValue = function(list, value){
// Adapted from a variety of sources by Gregory Alexander
var values = list.split(",");
for(var i = 0 ; i < values.length ; i++) {
if (values[i] == value) {
values.splice(i, 1);
return values.join(",");
}
}
return list;
}
// URL functions
//
// parseUri 1.2.2
// (c) Steven Levithan
// MIT License
/*
Splits any well-formed URI into the following parts (all are optional):
----------------------
- source (since the exec method returns the entire match as key 0, we might as well use it)
- protocol (i.e., scheme)
- authority (includes both the domain and port)
- domain (i.e., host; can be an IP address)
- port
- path (includes both the directory path and filename)
- directoryPath (supports directories with periods, and without a trailing backslash)
- fileName
- query (does not include the leading question mark)
- anchor (i.e., fragment) */
function parseUri (str) {
var o = parseUri.options,
m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
uri = {},
i = 14;
while (i--) uri[o.key[i]] = m[i] || "";
uri[o.q.name] = {};
uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
if ($1) uri[o.q.name][$1] = $2;
});
return uri;
};
parseUri.options = {
strictMode: false,
key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
q: {
name: "queryKey",
parser: /(?:^|&)([^&=]*)=?([^&]*)/g
},
parser: {
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
}
};
// Dump function. Use like you would with cfdump.
// function to dump out a a javascript object.
function mydump(arr,level) {
var dumped_text = "";
if(!level) level = 0;
var level_padding = "";
for(var j=0;j \"" + value + "\"\n";
}
}
} else {
dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
}
console.log(dumped_text);
}
CFBlogs.org 2.0 Released
by Gregory Alexander
The new version of CFBlogs ColdFusion Blog Aggregator has been released.
This version displays all blog posts in an attractive three-column card layout and shows the open graph image or a site image at the top of the post. The card images should allow the user to convey the post's author. Users can sort the grids by author by clicking on the card image.
This page also has several data grids to analyze ColdFusion blogging trends. I have made extra data available to the grids, including the generating blog software. Data from the grids and calendar widget on the bottom of the sidebar (opened by clicking on the hamburger) suggests that the current state of the ColdFusion blogging community is stronger than ever.
Advanced search capabilities are also present. Users can search from one or more active blog sites. Nearly 150 ColdFusion-related blogs have several years of data, which should prove helpful for ColdFusion developers wanting to research a particular ColdFusion-related topic.
This site should improve the SEO score of each blog covered as it provides a backlink to the blog postings. Google and other search engines consider backlinks 'votes' for a particular post, and hopefully, this will improve the search scores for all the blogs covered. There is also a ColdFusion community menu at the top of the page, allowing users to find other ColdFusion-related resources.
CFBlogs also displays the posts from CFOverflow and aggregates all of the posts to the CFBlogsFeed on Twitter. The RSS feed can show the ColdFusion blog posts on your websites; instructions are below.
The CFBlogs website can be found at https://www.cfblogs.org/
If you have any suggestions or want to add your blog to the CfBlogs aggregator, please contact me.
How to put the CFBlogs Feed on your Website
If you want to place the CFBlogs Feed on your website, copy and paste the following code. An example of the following code can be found by clicking on the hamburger on this site.
<table align="center" class="k-content fixedPodTableWithWrap" width="100%" cellpadding="7" cellspacing="0">
<cftry>
<cfsilent>
<cfset theURL = "https://gregoryalexander.com/cfblogs/rss.cfm">
<cfhttp url="#theURL#" timeout="5">
<cfset xml = xmlParse(cfhttp.filecontent)>
<cfset items = xmlSearch(xml, "//*[local-name() = 'item']")>
<!--- Set a loop counter to keep track of the current row for display purposes. --->
<cfset feedLoopCount = 1>
</cfsilent>
<cfloop index="x" from="1" to="#min(arrayLen(items),5)#">
<cfsilent>
<cfset item = items[x]>
<!-- Create alternating rows in the table. The Kendo classes which we will use are k-alt and k-content.
We will create a border between the rows if the current row is not the first row. -->
<cfif feedLoopCount mod 2>
<cfset thisClass = 'k-content'>
<cfelse>
<cfset thisClass = 'k-alt'>
</cfif>
</cfsilent>
<tr class="<cfoutput>#thisClass#</cfoutput>" height="35px;">
<!--Create the nice borders after the first row.-->
<cfif feedLoopCount eq 1>
<td valign="top">
<cfelse>
<td align="left" valign="top" class="border">
</cfif>
<!--Display the content.-->
<cfoutput>
#item.comments.xmlText#<br/>
<a href="#item.link.xmlText#" <cfif darkTheme>style="color:whitesmoke"</cfif>>#item.title.xmlText#</a><br />
</cfoutput>
</td>
</tr>
<!---Increment the loop counter--->
<cfset feedLoopCount = feedLoopCount + 1>
</cfloop>
<cfcatch>
<tr>
<td>
<cfoutput>
CFBloggers down
</cfoutput>
</td>
</tr>
</cfcatch>
</cftry>
</table>
<br/>
Tags
CfBlogs Aggregator
|
Gregory Alexander
|
Hi, my name is Gregory! I have several degrees in computer graphics and multimedia authoring, and I have been developing enterprise web applications for the last 25 years. I love web technologies and the outdoors and am passionate about giving back to the community.
|
This entry was posted on December 5, 2022 at 5:49 PM and has received 2630 views.
|