diff --git a/README.md b/README.md index 1bd1d4a..51d3e09 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ We moved our instances list to our webpage: https://www.halcyon.social/instances or read our new documentation pages to install it manually: https://www.halcyon.social/documentation.php?page=install ## Blog +- Release of Version 2.4.2 - Many bugfixes,add trending hashtags,add URL unshortener,redirect YouTube to Invidious,translation improvements,add Spanish translation - Release of Version 2.4.1 - Improve French and German translation,respect Pleromas/GlitchSocs custom poll limits,add extension download link,many bugfixes - We published the new Halcyon Share Extension at [Firefox Addons](https://addons.mozilla.org/en-US/firefox/addon/halcyon-share/) and [NotABug](https://notabug.org/halcyon-suite/halcyon-share) - Release of Version 2.4.0 - Share links to Halcyon,preview overlays for mentions and more (blog article coming soon) diff --git a/assets/css/style.css b/assets/css/style.css index 9c90ff3..2171162 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -579,10 +579,10 @@ font-weight: 300; .single_reply_status .status_preview,.report_status .status_preview { border-top: 1px solid #E1E8ED; } -.single_reply_status .status_preview .toot_entry .toot_footer,.report_stauts .status_preview .toot_entry .toot_footer { +.single_reply_status .status_preview .toot_entry .toot_footer,.report_status .status_preview .toot_entry .toot_footer { display: none!important; } -.single_reply_status .status_preview .toot_entry .link_preview,.report_stauts .status_preview .toot_entry .link_preview { +.single_reply_status .status_preview .toot_entry .link_preview,.report_status .status_preview .toot_entry .link_preview { display: none!important; } .single_reply_status .status_form .status_bottom,.report_status .status_form .status_bottom { @@ -975,6 +975,9 @@ position: relative; box-sizing: border-box; border: 1px solid #DCDFE1; } +.media_views.link_preview { +cursor:pointer; +} .media_views.media_full_height { height:auto; } @@ -1517,9 +1520,12 @@ overflow: hidden; margin-right: 8px; border-radius: 5px; } -.account_box .label_box { +.what_to_follow .account_box .label_box { width: 200px; } +.trending_hashtags .account_box .label_box { +width:100%; +} .account_box .label_box h3 { overflow: hidden; white-space: nowrap; diff --git a/assets/js/halcyon/halcyonFunctions.js b/assets/js/halcyon/halcyonFunctions.js index 5bfbbe2..e4cfb25 100644 --- a/assets/js/halcyon/halcyonFunctions.js +++ b/assets/js/halcyon/halcyonFunctions.js @@ -59,7 +59,7 @@ di[re[4]] = re[3]; } return di; } -function replaceInternalLink(){ +function replaceInternalLink() { $(".toot_article a,.profile_bio a,.follows_profile_bio a").each(function(i) { const pltags = $(this).attr('href').match(/https?:\/\/.+..+\/tag\/([a-zA-Z\d_%]+)\/?$/); if(pltags) $(this).attr('target','_self').attr('href','/search?q='+pltags[1]); @@ -77,6 +77,24 @@ const gsstatus = $(this).attr('href').match(/https?:\/\/.+..+\/notice\/(\d+)\/?$ if(gsstatus) $(this).attr('target','_self').attr('href',"javascript:openStatus('"+gsstatus[0]+"');void(0)"); const plstatus = $(this).attr('href').match(/https?:\/\/.+..+\/objects\/([\da-z]{8}-[\da-z]{4}-[\da-z]{4}-[\da-z]{4}-[\da-z]{12})\/?$/); if(plstatus) $(this).attr('target','_self').attr('href',"javascript:openStatus('"+plstatus[0]+"');void(0)"); +const ytcom = $(this).attr('href').match(/https?:\/\/(www\.)?youtube\.com\/watch\?v=([a-zA-Z\d_-]+)/); +if(ytcom) $(this).attr('target','_self').attr('href',"javascript:openVideo('"+ytcom[2]+"');void(0)"); +const ytbe = $(this).attr('href').match(/https?:\/\/(www\.)?youtu\.be\/([a-zA-Z\d_-]+)/); +if(ytbe) $(this).attr('target','_self').attr('href',"javascript:openVideo('"+ytbe[2]+"');void(0)"); +if(server_setting_unshorten && checkURLshortener($(this).attr('href'))) { +var linkrand = Math.round(Math.random()*1000000); +$(this).attr("data-random",linkrand); +$.ajax("/unshorten.php?url="+encodeURIComponent($(this).attr('href'))).done(function(data) { +$(".toot_article a,.profile_bio a,.follows_profile_bio a").filter("[data-random="+linkrand+"]").attr("href",data); +$(".toot_article a,.profile_bio a,.follows_profile_bio a").filter("[data-random="+linkrand+"]").children().eq(1).text(data.split("//")[0]); +link = data.replace("https://",""); +link = link.replace("http://",""); +if(link.length > 30) $(".toot_article a,.profile_bio a,.follows_profile_bio a").filter("[data-random="+linkrand+"]").children().eq(1).addClass("ellipsis"); +else $(".toot_article a,.profile_bio a,.follows_profile_bio a").filter("[data-random="+linkrand+"]").children().eq(1).removeClass("ellipsis"); +$(".toot_article a,.profile_bio a,.follows_profile_bio a").filter("[data-random="+linkrand+"]").children().eq(1).text(link.substr(0,30)); +$(".toot_article a,.profile_bio a,.follows_profile_bio a").filter("[data-random="+linkrand+"]").children().eq(2).text(link.substr(30)); +}); +} }); $(".toot_article a").each(function(i) { const ytcom = $(this).attr('href').match(/https?:\/\/(www\.)?youtube\.com\/watch\?v=([a-zA-Z\d_-]+)/); @@ -169,7 +187,6 @@ current_filters = new Array; } localStorage.setItem("current_display_name",AccountObj["display_name"]); localStorage.setItem("current_acct",AccountObj["acct"]); -localStorage.setItem("current_url","/@"+AccountObj["acct"]+"@"+current_instance+"?mid="+current_id); localStorage.setItem("current_header",AccountObj["header"]); localStorage.setItem("current_avatar",AccountObj["avatar"]); localStorage.setItem("current_locked",AccountObj["locked"]); @@ -179,7 +196,6 @@ localStorage.setItem("current_followers_count",AccountObj["followers_count"]); localStorage.setItem("current_follow_loaded","false"); current_display_name = localStorage.getItem("current_display_name"); current_acct = localStorage.getItem("current_acct"); -current_url = localStorage.getItem("current_url"); current_header = localStorage.getItem("current_header"); current_avatar = localStorage.getItem("current_avatar"); current_locked = localStorage.getItem("current_locked"); @@ -263,7 +279,6 @@ api_user_token: authtoken }); current_display_name = localStorage.getItem("current_display_name"); current_acct = localStorage.getItem("current_acct"); -current_url = localStorage.getItem("current_url"); current_header = localStorage.getItem("current_header"); current_avatar = localStorage.getItem("current_avatar"); current_locked = localStorage.getItem("current_locked"); @@ -287,15 +302,15 @@ is_account_locked = " "; } $(".js_current_profile_displayname").html(current_display_name); $(".js_current_profile_username").html(current_acct+is_account_locked); -$(".js_current_profile_link").attr("href", current_url); +$(".js_current_profile_link").attr("href","/@"+current_acct+"@"+current_instance+"?mid="+current_id); $(".js_current_header_image").attr("src", current_header); $(".js_current_profile_image").attr("src", current_avatar); $(".js_current_toots_count").text(current_statuses_count); $(".js_current_following_count").text(current_following_count); $(".js_current_followers_count").text(current_followers_count); -$(".current_toots_count_link").attr("href",current_url); -$(".current_following_count_link").attr("href",current_url); -$(".current_followers_count_link").attr("href",current_url); +$(".current_toots_count_link").attr("href","/@"+current_acct+"@"+current_instance+"?mid="+current_id); +$(".current_following_count_link").attr("href","/@"+current_acct+"@"+current_instance+"/following?mid="+current_id); +$(".current_followers_count_link").attr("href","/@"+current_acct+"@"+current_instance+"/followers?mid="+current_id); if($(window).width() < 1200) { responsive_design = true; $(".left_column").append($("
").attr("class","responsive_left").append($(".right_column").children())); @@ -317,6 +332,7 @@ localStorage.setItem("setting_desktop_notifications","false"); if(localStorage.setting_who_to_follow == "true") { setWhoToFollow(); } +setTrendingHashtags(); if(!localStorage.hide_firefox_download || localStorage.hide_firefox_download != "true") $("#widget_ffdl").show(); replace_emoji(); } @@ -418,6 +434,33 @@ $('.what_to_follow_'+id+' .label_box > .follow_button').attr('data',search.accou follow_loaded++; }); } +function setTrendingHashtags() { +api.get("trends",function(data) { +if(data.length == 0) $("#trends_icon").removeClass("fa-circle-o-notch").removeClass("fa-spin").addClass("fa-hashtag").addClass("fa-stack-1x").after($("").addClass("fa").addClass("fa-ban").addClass("fa-stack-2x")); +else { +for(var i=0;i<5;i++) { +if(i < data.length) { +var ht_toots = 0; +var ht_users = 0; +for(var a=0;a").addClass("fa").addClass("fa-ban").addClass("fa-stack-2x")); +}); +} function checkEmojiSupport() { var ctx = document.createElement("canvas").getContext("2d"); ctx.fillText("😗",-2,4); @@ -437,6 +480,17 @@ window.location.href = "/404"; } }); } +function openVideo(video) { +if(localStorage.setting_redirect_invidious == "true") window.open("https://"+server_setting_invidious+"/watch?v="+video,"_blank"); +else if(localStorage.setting_redirect_invidious == "false") window.open("https://www.youtube.com/watch?v="+video,"_blank"); +else { +$("#js-overlay_content_wrap .temporary_object").empty(); +$('#js-overlay_content_wrap').addClass('view'); +$('#js-overlay_content_wrap').addClass('black_08'); +$('.overlay_redirect_invidious').data("video",video); +$('.overlay_redirect_invidious').removeClass('invisible'); +} +} function embedMedia(source,element,watchid) { if(element.children(".media_views").length == 0) { let media_views = `
`; @@ -449,7 +503,7 @@ media_views += (` else if( source == "youtube" && localStorage.setting_play_invidious == "true") { media_views += (`
- +
`); } else if(source == "vimeo" && server_setting_vimeo == true && localStorage.setting_play_vimeo == "true") { @@ -495,3 +549,21 @@ submitStatusArray(nparams,callback); } }); } +function checkURLshortener(link) { +var short = true; +if(link.indexOf("https://") != -1 || link.indexOf("http://") != -1) { +if(link.indexOf("://www.") != -1) short = false; +link = link.replace("https://",""); +link = link.replace("http://",""); +var short_handle = link.split("/"); +var domain = link.split("."); +if(domain.length == 2) var sld = domain[0]; +else var sld = domain[1]; +if(sld.length < 1 || sld.length > 7) short = false; +if(short_handle.length != 2) short = false; +else if(!short_handle[1].match(/^[a-zA-Z0-9_-]+$/)) short = false; +else if(short_handle[1].length > 10) short = false; +} +else short = false; +return short; +} diff --git a/assets/js/halcyon/halcyonSettings.js b/assets/js/halcyon/halcyonSettings.js index 6869626..e9557df 100644 --- a/assets/js/halcyon/halcyonSettings.js +++ b/assets/js/halcyon/halcyonSettings.js @@ -443,6 +443,12 @@ $("#setting_play_invidious")[0].checked = true; if(localStorage.setting_play_vimeo == "true" && $("#setting_play_vimeo").length == 1) { $("#setting_play_vimeo")[0].checked = true; } +if(localStorage.setting_redirect_invidious == "true") { +$("#setting_redirect_invidious")[0].checked = true; +} +if(localStorage.setting_redirect_invidious != "unset") { +$("#setting_redirect_invidious_reset").show(); +} }); $("#setting_play_gif").change(function() { if(this.checked) { @@ -514,6 +520,23 @@ localStorage.setItem("setting_play_vimeo","false"); putMessage(__("Vimeo embeds disabled")); } }); +$("#setting_redirect_invidious").change(function() { +$("#setting_redirect_invidious_reset").fadeIn(); +if(this.checked) { +localStorage.setItem("setting_redirect_invidious","true"); +putMessage(__("YouTube links redirected to Invidious")); +} +else { +localStorage.setItem("setting_redirect_invidious","false"); +putMessage(__("Youtube links not redirected anymore")); +} +}); +$("#setting_redirect_invidious_reset").click(function() { +localStorage.setItem("setting_redirect_invidious","unset"); +$("#setting_redirect_invidious_reset").fadeOut(); +$("#setting_redirect_invidious")[0].checked = false; +putMessage(__("Youtube link redirect reset to default")); +}); } else if(window.location.pathname == "/settings/blocks") { $('#js-settings_nav_blocks').toggleClass('view'); diff --git a/assets/js/halcyon/halcyonTemplates.js b/assets/js/halcyon/halcyonTemplates.js index d2cb9da..62ff98d 100644 --- a/assets/js/halcyon/halcyonTemplates.js +++ b/assets/js/halcyon/halcyonTemplates.js @@ -87,7 +87,7 @@ media_views += "
"; media_views += "
"; var media_view = $("
"); media_view.append(media_views); -if(status.sensitive) media_view.find(".media_attachment").addClass("sensitive"); +if(status.sensitive && localStorage.setting_show_nsfw == "false") media_view.find(".media_attachment").addClass("sensitive"); for(let i in audio_embeds) { media_view.append(audio_embeds[i]); } @@ -103,11 +103,21 @@ const htbe = card.url.match(/https?:\/\/(www\.)?hooktube\.com\/([a-zA-Z\d_-]+)/) const vimeo = card.url.match(/https?:\/\/(www\.)?vimeo\.com\/([\d]+)/); const peertube = card.url.match(/https?:\/\/.+..+\/videos\/watch\/([\da-z]{8}-[\da-z]{4}-[\da-z]{4}-[\da-z]{4}-[\da-z]{12})\/?$/); if(((!ytcom && !htcom && !ivcom && !ytbe && !htbe) || (localStorage.setting_play_youplay == "false" && localStorage.setting_play_invidious == "false")) && (!vimeo || localStorage.setting_play_vimeo) && (!peertube || localStorage.setting_play_peertube)) { -let preview_html = (`