Skip to content

Instantly share code, notes, and snippets.

View rgriffith's full-sized avatar

Ryan Griffith rgriffith

View GitHub Profile
@rgriffith
rgriffith / tag_blocks_subscribing_to_dd.js
Last active October 12, 2018 14:47
Uses Cascade CMS REST API to iterate over XHTML/SD Blocks which subscribe to a specific Data Definition and adds a tag to each one.
// To install module, run: `npm i node-fetch`
const fetch = require("node-fetch");
const AUTHENTICATION = {username: '...', password: '...'};
const REST_API_URL = 'https://CASCADE_URL/api/v1/';
const SITE_NAME = 'www.example.com';
const DATA_DEFINITION_NAME = 'foo';
const TAG_TO_PUSH = 'bar';
@rgriffith
rgriffith / abbreviateHtmlString.vm
Last active December 20, 2015 05:59
Abbreviates a String which can contain html tags. Html tags are not counted in String length. It also try to handle open tags and html entities. Adopted from http://www.displaytag.org/1.2/displaytag/apidocs/org/displaytag/util/HtmlTagUtil.html
#*
Abbreviates a String which can contain html tags. Html tags are not counted in String length. It also try to handle open tags and html entities.
Adopted from http://www.displaytag.org/1.2/displaytag/apidocs/org/displaytag/util/HtmlTagUtil.html
@param str full String. null is handled by returning null
@param maxLength maximum number of characters (excluding tags)
@param byNumberOfWords if true maxLength will be the number of words returned, elsewhere will represent the number of characters.
@return abbreviated String
*#