diff -r c175d505e40d -r 4a1e6952afe5 web/src/js/live-polemic.js --- a/web/src/js/live-polemic.js Tue Oct 22 10:01:37 2024 +0200 +++ b/web/src/js/live-polemic.js Thu Nov 07 22:38:14 2024 +0100 @@ -54,13 +54,22 @@ return typeof(global[varkey]) == "undefined" ? defaultValue : global[varkey]; } +function getSocialGroupUri(social_group) { + const groupParts = social_group.replace(/^\@+/,"").split('@'); + return `https://${groupParts[1]}/u/${groupParts[0]}` +} + + //var i10n = getGlobal('i10n', { "rechercher" : "Rechercher" }); -var suggested_keywords = getGlobal('suggested_keywords',[]); +const suggested_keywords = getGlobal('suggested_keywords',[]); + +const max_pages = getGlobal('max_pages', 5); -var max_pages = getGlobal('max_pages', 5); - -var social_network = getGlobal('social_network', 'Twitter'); +const social_network = getGlobal('social_network', 'Twitter'); +const social_login_domain = getGlobal('social_login_domain'); +const social_access_token = getGlobal('social_access_token'); +const social_group = getGlobal('social_group'); tracking_keywords = _(getGlobal('tracking_keywords', [])).map(function(_w) { return _w.toLowerCase(); @@ -111,6 +120,29 @@ ] } +function getSocialData() { + return $.ajax({ + beforeSend: function(request) { + request.setRequestHeader('Authorization', `Bearer ${social_access_token}`); + }, + type: "GET", + dataType: "json", + url: `https://${social_login_domain}/api/v1/accounts/verify_credentials`, + }); +} + +function getFollowing(user_id) { + return $.ajax({ + beforeSend: function(request) { + request.setRequestHeader('Authorization', `Bearer ${social_access_token}`); + }, + type: "GET", + dataType: "json", + url: `https://${social_login_domain}/api/v1/accounts/${user_id}/following`, + }); +} + + function getTweets(options) { function getTweetUrl(url) { @@ -283,9 +315,13 @@ tweet.retweeted_status_id = tweet.retweeted_status.id_str; backRef( tweet.id, tweet.retweeted_status_id, "retweet" ); } - - - var tab = tweet.full_text.replace(twCx.urlRegExp,'').match(twCx.wordRegExp); + + // clean full text from html + const temp_div_element = document.createElement("div"); + temp_div_element.innerHTML = tweet.full_text; + const full_text = temp_div_element.textContent || temp_div_element.innerText || tweet.full_text; + + var tab = full_text.replace(twCx.urlRegExp,'').match(twCx.wordRegExp); _(tab).each(function(w) { var word = w.toLowerCase(); if (_(twCx.stopWords).indexOf(word) == -1 && _(tracking_keywords).indexOf(word) == -1 && word[0] != '@') { @@ -607,11 +643,11 @@ txt += highlight( full_text.substring(lastend) ); html += '
' + a_user + '' +highlight('@' + tweet.user.name) + '' + ( className == 'full' ? ' (' + tweet.user.name + ')
' : ' : ') + txt + '