diff --git a/pinry/static/js/helpers.js b/pinry/static/js/helpers.js index 33e95e8..9f22a4e 100644 --- a/pinry/static/js/helpers.js +++ b/pinry/static/js/helpers.js @@ -58,3 +58,15 @@ function postPinData(data) { function getUrlParameter(name) { return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null; } + +Handlebars.registerHelper('niceLinks', (function () { + var reNL = /\r?\n/g, + reURL = /https?:[/][/](?:www[.])?([^/]+)(?:[/]([.]?[^\s,.])+)?/g; + return function (text) { + var t = Handlebars.Utils.escapeExpression(text); + t = t.replace(reURL, '$1'); + t = t.replace(reNL, '
'); + return new Handlebars.SafeString(t); + }; +})()); + diff --git a/pinry/templates/includes/lightbox.html b/pinry/templates/includes/lightbox.html index 1c558c7..d903575 100644 --- a/pinry/templates/includes/lightbox.html +++ b/pinry/templates/includes/lightbox.html @@ -8,7 +8,7 @@