This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(opts){ | |
var fs = require('fs') | |
,md5 = require('MD5') | |
,_ = require('underscore') | |
,cache_helper = {} | |
,settings = _.extend({ | |
cache_dir: __dirname + '/cache/' | |
}, opts || {}) | |
,timenow = function(){ | |
return (new Date()).getTime(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//border radius, takes any acceptable border-radius string | |
.border-radius(@rad){ | |
border-radius: @rad; | |
-moz-border-radius: @rad; | |
-webkit-border-radius: @rad; | |
} | |
//round top corners | |
.border-radius-top(@rad){ | |
.border-radius(@rad @rad 0 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_.mixin({ | |
slugify: function(title){ | |
var replace = '-'; | |
var str = title.toString() | |
.replace(/[\s\.]+/g,replace) | |
.toLowerCase() | |
.replace(new RegExp('[^a-z0-9'+replace+']','g'), replace) | |
.replace(new RegExp(replace+'+','g'),replace) | |
; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// remove key from object | |
_.mixin({ | |
remove: function(obj, key){ | |
delete obj[key]; | |
return obj; | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//get a key from an object if it exists, otherwise use default | |
_.mixin({ | |
get: function(obj, key, default_val){ | |
if (obj && _.has(obj, key)){ | |
return obj[key]; | |
} | |
else{ | |
return default_val != undefined ? default_val : ''; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this replace method can take multiple finds and one or multiple replacements at a time | |
//if find is an array, replace will be called on every find | |
//if replace is an array, the indexes must match with find to do replacements. | |
//if replace is a string, it will be used for all replace calls if find is an array | |
//if find and replace are both strings, this will simply mimmick a normal str.replace(find, replace) call | |
//the result of all replacements will be returned at the end | |
_.mixin({ | |
replace: function(str, find, replace){ | |
//if str is null, just give up now | |
if (str === null){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Date.format = function(d, format, custom_months, custom_days){ | |
var months = custom_months || ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] | |
,days = custom_days || ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] | |
,replacements = [ | |
//day | |
[ '%d', (d.getDate() < 10 ? '0' : '') + d.getDate() ] //leading 0: 01-31 | |
, [ '%D', days[ d.getDay() ].substr(0, 3) ] //3 letter representation (Mon-Sun) | |
, [ '%j', d.getDate() ] //no leading 0: 1-31 | |
, [ '%l', days[ d.getDay() ] ] //[lowercase L], full textual representation (Monday-Sunday) | |
, [ '%N', (d.getDay() + 1) ] //day #: 1-7 (1=monday, 7=sunday) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h1 Page Title | |
p This is a sentance, woo! |
NewerOlder