Bladeren bron

Make links clickable and only show the domain in the text.

pull/76/head
Lapo Luchini 10 jaren geleden
bovenliggende
commit
212dd7f819
3 gewijzigde bestanden met toevoegingen van 14 en 2 verwijderingen
  1. +12
    -0
      pinry/static/js/helpers.js
  2. +1
    -1
      pinry/templates/includes/lightbox.html
  3. +1
    -1
      pinry/templates/includes/pins.html

+ 12
- 0
pinry/static/js/helpers.js Bestand weergeven

@@ -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, '<a href="$&" target="_blank">$1</a>');
t = t.replace(reNL, '<br>');
return new Handlebars.SafeString(t);
};
})());


+ 1
- 1
pinry/templates/includes/lightbox.html Bestand weergeven

@@ -8,7 +8,7 @@
<div class="lightbox-data clearfix">
{{#if description}}
<div class="description">
{{description}}
{{niceLinks description}}
</div>
{{/if}}
<div class="avatar pull-left">


+ 1
- 1
pinry/templates/includes/pins.html Bestand weergeven

@@ -18,7 +18,7 @@
</div>
</a>
{{#if description}}
<p>{{description}}</p>
<p>{{niceLinks description}}</p>
{{/if}}
<div class="pin-footer clearfix">
<div class="avatar pull-left">


Laden…
Annuleren
Opslaan