mirror of
https://github.com/pinry/pinry.git
synced 2025-11-14 00:55:43 +01:00
Make links clickable and only show the domain in the text.
This commit is contained in:
@@ -58,3 +58,15 @@ function postPinData(data) {
|
|||||||
function getUrlParameter(name) {
|
function getUrlParameter(name) {
|
||||||
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null;
|
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);
|
||||||
|
};
|
||||||
|
})());
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<div class="lightbox-data clearfix">
|
<div class="lightbox-data clearfix">
|
||||||
{{#if description}}
|
{{#if description}}
|
||||||
<div class="description">
|
<div class="description">
|
||||||
{{description}}
|
{{niceLinks description}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<div class="avatar pull-left">
|
<div class="avatar pull-left">
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
{{#if description}}
|
{{#if description}}
|
||||||
<p>{{description}}</p>
|
<p>{{niceLinks description}}</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<div class="pin-footer clearfix">
|
<div class="pin-footer clearfix">
|
||||||
<div class="avatar pull-left">
|
<div class="avatar pull-left">
|
||||||
|
|||||||
Reference in New Issue
Block a user