From c898d17554a2f065f4904ac11d1b804ac9f2ab5f Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Sun, 28 Sep 2014 00:45:22 +0200 Subject: [PATCH] Lutim images integration in timeline Lutim is a free software for image sharing. This patch displays images from the official instance (https://lut.im) in the Twister timeline. --- js/twister_formatpost.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/js/twister_formatpost.js b/js/twister_formatpost.js index 87b6d167..b4d125e4 100644 --- a/js/twister_formatpost.js +++ b/js/twister_formatpost.js @@ -167,6 +167,8 @@ function htmlFormatMsg( msg, output, mentions ) { var strSplitCounterR = "\\(\\d{1,2}\\/\\d{1,2}\\)$"; var reAll = new RegExp("(?:^|[ \\n\\t.,:\\/?!])(#|@|" + strUrlRegexp + "|" + strEmailRegexp + "|" + strSplitCounterR + ")"); var reHttp = new RegExp(strUrlRegexp); + var reLutim = new RegExp("https://lut.im/[a-zA-Z0-9]+(/[a-zA-Z0-9]+)?([^a-zA-Z0-9]t)?$"); + var reLutim2 = new RegExp("https://lut.im/(about|stats)"); var reEmail = new RegExp(strEmailRegexp); var reSplitCounter = new RegExp(strSplitCounterR); @@ -222,8 +224,17 @@ function htmlFormatMsg( msg, output, mentions ) { extLinkTemplate.attr("href",url); } - extLinkTemplate.text(url); extLinkTemplate.attr("title",url); + if (reLutim.exec(url) && ! reLutim2.exec(url)) { + var re = new RegExp("[^a-zA-Z0-9]t$"); + if (re.exec(url)) { + url = url.replace(re, ''); + } + url = ''; + extLinkTemplate.html(url); + } else { + extLinkTemplate.text(url); + } output.append(extLinkTemplate); continue; }