Skip to content

Instantly share code, notes, and snippets.

View stevewithington's full-sized avatar
⛑️
solving problems

Steve Withington stevewithington

⛑️
solving problems
View GitHub Profile
@stevewithington
stevewithington / dspDecendants.cfm
Last active September 23, 2020 08:26
Mura CMS: A simple method to output the children, grandchildren, great-grandchildren, etc. of a content item based on the parent's contentid.
<!---
This is an uber simple method to output children, grandchildren, etc. based on the parent's contentid
If you're looking for an easy way to output a child nav, you could also just use Mura's baked-in $.dspNestedNav(contentid) method.
See the file located under /requirements/mura/content/contentRenderer.cfc for details.
--->
<cffunction name="dspDecendants">
<cfargument name="contentid" required="true" />
<cfset var local = {} />
<cfset local.str = '' />
<cfset local.cBean = $.getBean('content').loadBy(contentid=arguments.contentid) />
@stevewithington
stevewithington / dspCarouselByFeedName.cfm
Last active April 28, 2016 17:46
Mura CMS: How to allow for responsive YouTube video embeds in the home page carousel.
<!---
1. Create a "Class Extension" for Link / Video
2. Replace the existing dspCarouselByFeedName() method in the theme's contentRenderer.cfc with the one below
3. Go add some Link/Video content types to your content collection.
For example, copy the YouTube "embed" video src link (Share > Embed) [e.g., https://www.youtube.com/embed/_l09H-3zzgA]
and paste that into the "URL" field when creating a content item.
--->
<cffunction name="dspCarouselByFeedName" output="false">
<cfargument name="feedName" type="string" default="Slideshow" />
@stevewithington
stevewithington / 1-mura-user-notification.cfm
Last active August 29, 2015 14:25
Mura CMS: How to email user notification after being activated
<cfscript>
// Mura CMS example of how to send notifications to users after they've been activated
public any function onAfterUserCreate($) {
user = arguments.$.event('userBean');
// By default, we're going to set all newly created users to 'inactive' ...
// you could also add the user to a group, etc. here if you wanted to as well
user.set('inActive', 1).save();
}
@stevewithington
stevewithington / mura-get-page-views.cfm
Created July 6, 2015 21:07
Mura CMS : Get page views ...
<!---
I recommend using Google Analytics or some other service to track and obtain page view data.
This is due to the fact that tracking session data can be expensive as far as database resources, and bandwidth ...
and the higher the number of days you track, the greater potential for running into performance issues.
Because of this, I usually recommend that clients set this to zero (0) and use an alternate way to obtain this data.
However, if you insist, follow the instructions below ...
--->
<!--- in your /config/settings.ini.cfm file, look for the following --->
sessionhistory=1
@stevewithington
stevewithington / cffeed.cfm
Created July 2, 2015 20:26
ColdFusion/CFML CFFeed Example
<!---
These examples show how to consume and output a RSS feed using CFML's <cffeed> tag
More info:
* http://docs.lucee.org/reference/tags/feed.html
* https://wikidocs.adobe.com/wiki/display/coldfusionen/cffeed
--->
<cfoutput>
<!DOCTYPE html>
<html>
<head>
@stevewithington
stevewithington / mura-json-api.cfm
Last active December 14, 2020 18:11
Mura CMS: JSON API Tests & Examples
<!---
Author: Stephen J. Withington, Jr.
Notes: Place this under a temp directory within your Mura CMS root to test.
For example: http://yourdomain.com/temp/json-test.cfm
--->
<cfscript>
param name="form.endpoint" default="content/new";
param name="form.method" default="GET";
param name="form.context" default="";
param name='session.siteid' default='default';
@stevewithington
stevewithington / mura-exportVersionHistoryAsCSV.cfm
Last active April 27, 2018 19:12
Mura CMS : Example of how to get the version history of all content items, and how to export version history as a CSV file.
<cfscript>
// Example of how to get a CSV report of all content items
// Drop this under a temp directory under the Mura webroot
// You could explicitly set this to any siteid you want, if desired
if ( !IsDefined('$') ) {
siteid = StructKeyExists(session, 'siteid') ? session.siteid : 'default';
$ = application.serviceFactory.getBean('$').init(siteid);
}
@stevewithington
stevewithington / mura-dspBodyByPageTitle.cfm
Last active August 29, 2015 14:17
Mura CMS: Display the "body" of another Page or content item
<cfscript>
// Related to a thread on the Mura CMS Developers Google Group: https://groups.google.com/forum/#!topic/mura-cms-developers/AHp9aUCsU5g
// Please review my response there before using this method! Most importantly, this does not check permissions to view the other content
// and other such things as the normal $.dspBody() does. YOU HAVE BEEN WARNED!
// Drop this in your Site or Theme contentRenderer.cfc
// Display the body of another page
public any function dspBodyByPageTitle(required string pageTitle, string siteid=$.event('siteid')) {
var contentBody = '';
var contentBean = $.getBean('content').loadBy(title=arguments.pageTitle, siteid=arguments.siteid);
@stevewithington
stevewithington / tomcat-web.xml
Created March 12, 2015 14:10
Tomcat CorsFilter Setup for CORS
<!--
Enable CORS on Tomcat : Place under libexec/conf/web.xml or WEB-INF/web.xml
See http://enable-cors.org/server_tomcat.html and http://tomcat.apache.org/tomcat-7.0-doc/config/filter.html#CORS_Filter
-->
<!-- ================== CUSTOM Filter Definitions ===================== -->
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
<init-param>
<param-name>cors.allowed.origins</param-name>
#!/usr/bin/env ruby
# Aside from removing Ruby on Rails specific code this is taken verbatim from
# mislav's git-deploy (http://github.com/mislav/git-deploy) and it's awesome
# - Ryan Florence (http://ryanflorence.com)
#
# Install this hook to a remote repository with a working tree, when you push
# to it, this hook will reset the head so the files are updated
if ENV['GIT_DIR'] == '.'