* Convert build to use a single JavaScript file on the site (instead of downloading each library separately). This also means that all global variables (e.g., `$` for JQuery, `_` for Underscore.js) can be removed. * Remove unused scripts and/or move them to a more appropriate repo * Update the `deploy` script to work with CircleCI's automation * Update markdown display code to allow images to be located with the markdown data files instead of the pre-rendered index pages
42 lines
1006 B
CoffeeScript
42 lines
1006 B
CoffeeScript
###
|
|
Crafting Guide - underscore_mixins.coffee
|
|
|
|
Copyright (c) 2014-2015 by Redwood Labs
|
|
All rights reserved.
|
|
###
|
|
|
|
_ = require 'underscore'
|
|
{stringMixins} = require 'crafting-guide-common'
|
|
|
|
########################################################################################################################
|
|
|
|
module.exports = _
|
|
|
|
_.mixin
|
|
parseMarkdown: (text)->
|
|
return markdown.parse text, 'Maruku'
|
|
|
|
slugify: (text)->
|
|
return null unless text?
|
|
|
|
result = text.toLowerCase()
|
|
result = result.replace /[^a-zA-Z0-9_]/g, '_'
|
|
result = result.replace /__+/g, '_'
|
|
result = result.replace /^_/, ''
|
|
result = result.replace /_$/, ''
|
|
return result
|
|
|
|
composeSlugs: (part1, part2)->
|
|
return "#{part1}__#{part2}"
|
|
|
|
decomposeSlug: (slug)->
|
|
return [null, null] unless slug?
|
|
|
|
parts = slug.split '__'
|
|
if parts.length is 1
|
|
parts = [ null, parts[0] ]
|
|
|
|
return parts
|
|
|
|
_.mixin stringMixins
|