utils.coffee 803 B

1234567891011121314151617181920212223
  1. # Bunch of utility functions
  2. settings = require('settings/root')
  3. exports.msg = {
  4. DATE_NOT_VALID: "Date format is wrong. Use this format: 'Feb 20 2012 6:30 PM'"
  5. }
  6. exports.cleanCode = (code) ->
  7. code.toLowerCase().replace(/[\ \-]/g, '_').replace(/[\/\\\=\.\'\"\`\:\,\;\&\?\!\#\+\@]/g, '')
  8. exports.cleanSlug = (slug) ->
  9. slug.toLowerCase().replace(/[\ \_]/g, '-').replace(/[\/\\\=\.\'\"\`\:\,\;\&\?\!\#\+\@]/g, '')
  10. exports.cleanContent = (content) ->
  11. if content
  12. protocol = "http(s)?:\/\/"
  13. if settings.app.dev_host
  14. dev_host = new RegExp(protocol+settings.app.dev_host, "g")
  15. content = content.replace(dev_host, '')
  16. if settings.app.prod_host
  17. prod_host = new RegExp(protocol+settings.app.prod_host, "g")
  18. content = content.replace(prod_host, '')
  19. return content