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 / mura404.cfm
Created July 3, 2014 15:38
Mura CMS: By default, Mura will not throw a 404 on missing ".cfm" files. This is intended behaviour so that you can integrate existing applications with Mura. If you wish to override this behaviour, use the method in this Gist.
<cfscript>
// drop this into your SITE or THEME eventHandler.cfc to trigger a 404 on missing .cfm files
public any function onSiteRequestStart($) {
request.uri = GetPageContext().GetRequest().GetRequestURI();
request.template = Right(request.uri, 1) != '/' ? ListLast(request.uri, '/') : '';
if ( Len(request.template) && !FileExists(ExpandPath(request.template)) ) {
request.currentfilenameadjusted = request.template;
}
}
</cfscript>
@stevewithington
stevewithington / muraGetMyEvents.cfm
Created July 23, 2014 20:27
Mura CMS : getMyEvents()
<cfscript>
public any function getMyEvents(calendarid=variables.$.content('contentid'), months=6) {
var local = {};
local.util = variables.$.getCalendarUtility();
local.rsItems = local.util.getCalendarItems(
calendarid=arguments.calendarid
, start=Now()
, end=DateAdd('m', arguments.months, Now())
);
return rsItems;
@stevewithington
stevewithington / githubLinks.md
Created July 25, 2014 15:23
Linking to line numbers on Github
@stevewithington
stevewithington / muraCustomPrimaryNav.cfm
Created August 8, 2014 00:08
Mura CMS : A Custom Primary Nav Example
<cfscript>
feed = $.getBean('feed')
.setMaxItems(0)
.setNextN(0)
.setSortBy('orderno')
.setSortDirection('asc')
.addParam(
relationship='AND'
,field='tcontent.parentid'
,dataType='varchar'
@stevewithington
stevewithington / muraFW1Example.cfm
Last active August 29, 2015 14:05
MuraFW1 Example : How to allow for arguments in display objects.
<cfscript>
// Let's say you want to pass in some arguments to the file located under /includes/displayObjects.cfc. For example:
public any function dspMuraFW1App3($, someArg='', anotherArg='Something') {
param name='request.context' default='#{}#';
StructAppend(request.context.myArgs, arguments);
// now they'll be available in your subapps as rc.myArgs.argName
return getApplication().doAction('app3:main.default');
}
</cfscript>
#! /bin/sh
# ==================================================================
# ______ __ _____
# /_ __/___ ____ ___ _________ _/ /_ /__ /
# / / / __ \/ __ `__ \/ ___/ __ `/ __/ / /
# / / / /_/ / / / / / / /__/ /_/ / /_ / /
#/_/ \____/_/ /_/ /_/\___/\__,_/\__/ /_/
# Multi-instance Apache Tomcat installation with a focus
# on best-practices as defined by Apache, SpringSource, and MuleSoft
@stevewithington
stevewithington / esapiEncode.cfm
Last active August 29, 2015 14:05
Mura CMS : esapiEncode() for Adobe ColdFusion
<cfif Not StructKeyExists(server, 'railo')>
<cffunction name="esapiEncode" output="false" returntype="string">
<cfargument name="encodeFor" type="string" default="html" hint="encode for what, valid values are: - css: for output inside Cascading Style Sheets (CSS) - dn: for output in LDAP Distinguished Names - html: for output inside HTML - html_attr: for output inside HTML Attributes - javascript: for output inside Javascript - ldap: for output in LDAP queries - url: for output in URL - vbscript: for output inside vbscript - xml: for output inside XML - xml_attr: for output inside XML Attributes - xpath: for output in XPath">
<cfargument name="inputString" type="string" required="true" hint="Required. String to encode">
<cfscript>
var lc = {};
var encodedString = '';
lc.encoder = CreateObject("java", "org.owasp.esapi.ESAPI").encoder();
switch(arguments.encodeFor) {
@stevewithington
stevewithington / nav_kids.cfm
Created August 26, 2014 22:29
Mura CMS : Custom Kids Only Nav
<!---
Drop this into your theme's display_objects directory,
then include it on your template using $.dspThemeInclude('display_objects/nav_kids.cfm')
--->
<cfset itKids = $.content().getKidsIterator().setNextN(0) />
<cfoutput>
<ul class="navSecondary">
<li class="current">
<a class="current" href="#$.content('url')#">#$.content('menuTitle')#</a>
<cfif itKids.hasNext()>
@stevewithington
stevewithington / muraFullCalendar.cfm
Last active August 29, 2015 14:05
Mura CMS : How to override default Calendar display with FullCalendar, a jQuery plugin
<cfscript>
// Drop this in your Site or Theme eventHandler.cfc
public string function onCalendarDefaultBodyRender(event, $) {
var str = '';
savecontent variable='str' {
WriteOutput(arguments.$.dspInclude('display_objects/fullcalendar/index.cfm'));
}
return str;
}
@stevewithington
stevewithington / muraSaveFile.cfm
Last active August 29, 2015 14:06
Mura CMS : How to Dynamically Add Files As Content Items.
<cfscript>
// Will NOT work unless you have 'allowlocalfiles=true' in /config/settings.ini.cfm
try {
filepath = ExpandPath('temp.pdf');
} catch(any e) {
filepath = '';
}
param name='form.thefile' default=filepath;