Support for emoji categories,added links to admin panel,rewrite links to Invidious and Nitter at compose,bugfixes

This commit is contained in:
nipos 2019-10-13 18:34:02 +02:00
parent d120e6438c
commit 875c3e0b17
16 changed files with 248 additions and 13 deletions

View File

@ -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.5 - Support for emoji categories,added links to admin panel,rewrite links to Invidious and Nitter at compose,bugfixes
- Release of Version 2.4.4 - Option to rewrite all Twitter links to Nitter,click on animated GIF works like image now,full height for images option now works for animated GIF
- Release of Version 2.4.3 - Fixed login,fixed YouPlay/Invidious embeds,fixed empty image placeholder when audio available,improved status template code
- Release of Version 2.4.2 - Many bugfixes,add trending hashtags,add URL unshortener,redirect YouTube to Invidious,translation improvements,add Spanish translation

View File

@ -5,6 +5,12 @@ width: 33px;
height: 35px;
cursor: pointer;
}
.lsx-emojipicker-emoji p {
font-size:12px;
color:#66757F;
text-align:center;
border-bottom:1px solid #E6ECF0;
}
.lsx-emojipicker-appender {
position: relative;
}
@ -42,7 +48,7 @@ ul.lsx-emojipicker-tabs li:HOVER {
border-bottom: 3px solid #189EFC;
}
.lsx-emojipicker-tabs img.emoji {
margin: 5px 10px;
margin: 0;
cursor: pointer;
}
.lsx-emojipicker-tabs img.emoji:HOVER,

View File

@ -1,4 +1,5 @@
function searchlocalfill() {
if(current_search_history.length > 0) {
var dropdown = $("<ul>").addClass("account_list");
var searchsuggestions = new Array();
current_search_history.reverse();
@ -16,6 +17,7 @@ current_search_history.reverse();
$(".header_search_suggestions").empty().removeClass("invisible").append(dropdown);
replace_emoji();
}
}
function searchremotefill(text) {
if(text == "@") searchlocalfill();
else {

View File

@ -10,7 +10,7 @@ $(this).children().remove();
}
else {
settings = $.extend({
width: 265,
width: 280,
height: 200,
twemoji: false,
closeOnSelect: true,
@ -235,8 +235,17 @@ container.append(emoticon);
}
function createCustomEmojiTab(container,wrapper) {
var customemojis = JSON.parse(localStorage.current_custom_emojis);
for(var i = 0;i < customemojis.length;i++){
var selectedEmoji = customemojis[i];
var sortedemojis = new Object();
for(var i = 0;i < customemojis.length;i++) {
if(!customemojis[i].category) customemojis[i].category = __("General");
if(!sortedemojis[customemojis[i].category]) sortedemojis[customemojis[i].category] = new Array();
sortedemojis[customemojis[i].category].push(customemojis[i]);
}
for(var category in sortedemojis) {
if(sortedemojis.hasOwnProperty(category)) {
if(Object.keys(sortedemojis).length != 1 || !sortedemojis.hasOwnProperty(__("General"))) container.append($("<p>").text(category));
for(var i=0;i < sortedemojis[category].length;i++) {
var selectedEmoji = sortedemojis[category][i];
var emoticon = $('<span></span>')
.data('value',selectedEmoji.url)
.attr('title',selectedEmoji.code)
@ -254,5 +263,7 @@ wrapper.hide();
container.append(emoticon);
}
}
}
}
}(jQuery, window));
}

View File

@ -244,6 +244,7 @@ for(i=0;i<data.length;i++) {
var emoji = new Object();
emoji.code = data[i].shortcode;
emoji.url = data[i].url;
if(data[i].category) emoji.category = data[i].category;
emojis.push(emoji);
}
localStorage.setItem("current_custom_emojis",JSON.stringify(emojis));
@ -546,7 +547,43 @@ textarea.trigger({"type":"keyup","key":":"});
}});
}
}
function submitStatusArray(params,callback) {
function submitStatusArray(params,callback,invidious="unset",nitter="unset") {
const ytcom = params.status.first().val().match(/https?:\/\/(www\.)?youtube\.com\/watch\?v=([a-zA-Z\d_-]+)/);
const ytbe = params.status.first().val().match(/https?:\/\/(www\.)?youtu\.be\/([a-zA-Z\d_-]+)/);
const twcom = params.status.first().val().match(/https?:\/\/(www\.)?twitter\.com\/(.*)/);
if((ytcom || ytbe) && localStorage.setting_rewrite_invidious == "unset" && invidious == "unset") {
$("#js-overlay_content_wrap .temporary_object").empty();
$('#js-overlay_content_wrap').addClass('view');
$('#js-overlay_content_wrap').addClass('black_08');
$('.overlay_rewrite_invidious').data("params",params);
$('.overlay_rewrite_invidious').data("callback",callback);
$('.overlay_rewrite_invidious').data("nitter",nitter);
$('.overlay_rewrite_invidious').removeClass('invisible');
}
else if(twcom && localStorage.setting_rewrite_nitter == "unset" && nitter == "unset") {
$("#js-overlay_content_wrap .temporary_object").empty();
$('#js-overlay_content_wrap').addClass('view');
$('#js-overlay_content_wrap').addClass('black_08');
$('.overlay_rewrite_nitter').data("params",params);
$('.overlay_rewrite_nitter').data("callback",callback);
$('.overlay_rewrite_nitter').data("invidious",invidious);
$('.overlay_rewrite_nitter').removeClass('invisible');
}
if(ytcom && (localStorage.setting_rewrite_invidious == "true" || invidious == "true")) {
params.status.first().val(params.status.first().val().replace(/https?:\/\/(www\.)?youtube\.com\/watch\?v=([a-zA-Z\d_-]+)/,"https://"+server_setting_invidious+"/watch?v=$2"));
submitStatusArray(params,callback,invidious,nitter);
}
else if(ytbe && (localStorage.setting_rewrite_invidious == "true" || invidious == "true")) {
params.status.first().val(params.status.first().val().replace(/https?:\/\/(www\.)?youtu\.be\/([a-zA-Z\d_-]+)/,"https://"+server_setting_invidious+"/watch?v=$2"));
submitStatusArray(params,callback,invidious,nitter);
}
else if(twcom && (localStorage.setting_rewrite_nitter == "true" || nitter == "true")) {
params.status.first().val(params.status.first().val().replace(/https?:\/\/(www\.)?twitter\.com\/(.*)/,"https://"+server_setting_nitter+"/$2"));
submitStatusArray(params,callback,invidious,nitter);
}
else if(((!ytcom && !ytbe) || localStorage.setting_rewrite_invidious == "false" || invidious == "false") && (!twcom || localStorage.setting_rewrite_nitter == "false" || nitter == "false")) submitStatusArrayNow(params,callback);
}
function submitStatusArrayNow(params,callback,invidious,nitter) {
var statuses = params.status;
params.status = params.status.first().val();
api.post("statuses",params,function(data) {
@ -560,7 +597,7 @@ nparams.status = statuses;
nparams.visibility = params.visibility;
nparams.spoiler_text = params.spoiler_text;
nparams.in_reply_to_id = data.id;
submitStatusArray(nparams,callback);
submitStatusArray(nparams,callback,invidious,nitter);
}
});
}
@ -617,7 +654,7 @@ status.halcyon.poll_object = "";
status.halcyon.preview_object = "";
if(status.spoiler_text && localStorage.setting_show_content_warning == "false") {
status.halcyon.alert_text = "<span>"+status.spoiler_text+"</span><button class='cw_button'>"+__('SHOW MORE')+"</button>",
status.halcyonarticle_option = "content_warning";
status.halcyon.article_option = "content_warning";
}
else if(status.spoiler_text && localStorage.setting_show_content_warning == "true")
status.halcyon.alert_text = "<span>"+status.spoiler_text+"</span><button class='cw_button'>"+__('SHOW LESS')+"</button>";
@ -661,6 +698,10 @@ status.halcyon.own_toot_buttons = (`<li><a class="mute_button" mid="${status.acc
<li><a class="block_button" mid="${status.account.id}" sid="${status.id}">${__('Block')} @${status.account.username}</a></li>
<li><a class="addlist_button" mid="${status.account.id}" sid="${status.id}" display_name="${status.account.display_name}">${__('Add to list')} @${status.account.username}</a></li>
<li><a class="report_button" mid="${status.account.id}" sid="${status.id}" display_name="${status.account.display_name}">${__('Report this Toot')}</a></li>`);
if(localStorage.setting_show_admin && localStorage.setting_show_admin == "true") {
status.halcyon.own_toot_buttons += (`</ul><ul><li><a href="https://${current_instance}/admin/accounts/${status.account.id}" target="_blank" class="admin_user_button">${__('Open user as admin')}</a></li>
<li><a href="https://${current_instance}/admin/accounts/${status.account.id}/statuses/${status.id}" target="_blank" class="admin_post_button">${__('Open post as admin')}</a></li>`);
}
}
status.halcyon.account_state_icons = "";
if(status.account.locked == true) status.halcyon.account_state_icons += " <i class='fa fa-lock'></i>";

View File

@ -10,6 +10,18 @@ $("#setting_post_sensitive")[0].checked = true;
if(localStorage.setting_compose_autocomplete == "true") {
$("#setting_compose_autocomplete")[0].checked = true;
}
if(localStorage.setting_rewrite_invidious == "true") {
$("#setting_rewrite_invidious")[0].checked = true;
}
if(localStorage.setting_rewrite_invidious != "unset") {
$("#setting_rewrite_invidious_reset").show();
}
if(localStorage.setting_rewrite_nitter == "true") {
$("#setting_rewrite_nitter")[0].checked = true;
}
if(localStorage.setting_rewrite_nitter != "unset") {
$("#setting_rewrite_nitter_reset").show();
}
if(localStorage.setting_who_to_follow == "true") {
$("#setting_who_to_follow")[0].checked = true;
}
@ -41,6 +53,40 @@ localStorage.setItem("setting_compose_autocomplete","false");
putMessage(__("Autocomplete disabled"));
}
});
$("#setting_rewrite_invidious").change(function() {
$("#setting_rewrite_invidious_reset").fadeIn();
if(this.checked) {
localStorage.setItem("setting_rewrite_invidious","true");
putMessage(__("YouTube links rewritten to Invidious"));
}
else {
localStorage.setItem("setting_rewrite_invidious","false");
putMessage(__("Youtube links not rewritten anymore"));
}
});
$("#setting_rewrite_invidious_reset").click(function() {
localStorage.setItem("setting_rewrite_invidious","unset");
$("#setting_rewrite_invidious_reset").fadeOut();
$("#setting_rewrite_invidious")[0].checked = false;
putMessage(__("Youtube link rewrite reset to default"));
});
$("#setting_rewrite_nitter").change(function() {
$("#setting_rewrite_nitter_reset").fadeIn();
if(this.checked) {
localStorage.setItem("setting_rewrite_nitter","true");
putMessage(__("Twitter links rewritten to Nitter"));
}
else {
localStorage.setItem("setting_rewrite_nitter","false");
putMessage(__("Twitter links not rewritten anymore"));
}
});
$("#setting_rewrite_nitter_reset").click(function() {
localStorage.setItem("setting_rewrite_nitter","unset");
$("#setting_rewrite_nitter_reset").fadeOut();
$("#setting_rewrite_nitter")[0].checked = false;
putMessage(__("Twitter link rewrite reset to default"));
});
$(document).on('change',".local_instance_wrap input[name='local_instance']", function(e) {
if($(this).val()) {
localStorage.setItem("setting_local_instance","https://"+$(this).val());
@ -223,6 +269,9 @@ $("#setting_full_height")[0].checked = true;
if(localStorage.setting_thread_view == "true") {
$("#setting_thread_view")[0].checked = true;
}
if(localStorage.setting_show_admin == "true") {
$("#setting_show_admin")[0].checked = true;
}
});
$(document).on('change',".post_streaming_wrap input[name='post_streaming']:checked", function(e) {
localStorage.setItem("setting_post_stream", $(this).val());
@ -366,6 +415,16 @@ localStorage.setItem("setting_thread_view","false");
putMessage(__("Threads shown in chronological order"));
}
});
$("#setting_show_admin").change(function() {
if(this.checked) {
localStorage.setItem("setting_show_admin","true");
putMessage(__("Administrator options shown"));
}
else {
localStorage.setItem("setting_show_admin","false");
putMessage(__("Administrator options hidden"));
}
});
}
else if(window.location.pathname == "/settings/filters") {
$('#js-settings_nav_filters').toggleClass('view');

View File

@ -355,7 +355,7 @@ const html=$(`
<li sid="${NotificationObj.status.id}" class="toot_entry">
${poll_notify}
<div class="toot_entry_body">
<a href="${NotificationObj.status.halcyon.author_link}">
<a href="${notice_author_link}">
<div class="icon_box">
<img src="${NotificationObj.status.account.avatar}">
</div>
@ -363,7 +363,7 @@ ${poll_notify}
<section class="toot_content">
<header class="toot_header">
<div class="text_ellipsis">
<a href="${NotificationObj.status.halcyon.author_link}">
<a href="${notice_author_link}">
<span class="displayname emoji_poss">
${NotificationObj.status.account.display_name}
</span>

View File

@ -1771,7 +1771,7 @@ replace_emoji();
});
initStatusEditor("single_reply");
$(document).on('click', function(e) {
if(!$(e.target).closest('#header_status_form').length) {
if(!$(e.target).closest('#header_status_form').length && !$(e.target).closest('.close_button').length) {
$('#header_status_form .submit_status_label').removeClass('active_submit_button');
$('#header_status_form .expand_privacy_menu').addClass('invisible');
$('#header_status_form .status_textarea textarea').removeClass('focus');
@ -1996,6 +1996,10 @@ $('#js-overlay_content_wrap .overlay_confirm').addClass('invisible');
$('#js-overlay_content_wrap .overlay_prompt').addClass('invisible');
$('#js-overlay_content_wrap .overlay_addlist').addClass('invisible');
$('#js-overlay_content_wrap .overlay_filter').addClass('invisible');
$('#js-overlay_content_wrap .overlay_redirect_invidious').addClass('invisible');
$('#js-overlay_content_wrap .overlay_redirect_nitter').addClass('invisible');
$('#js-overlay_content_wrap .overlay_rewrite_invidious').addClass('invisible');
$('#js-overlay_content_wrap .overlay_rewrite_nitter').addClass('invisible');
$('#js-overlay_content .temporary_object, #js-overlay_content .parmanent_object').removeClass('visible');
$('#js-overlay_content_wrap .overlay_status.submit_status_label').removeClass('active_submit_button');
$('#js-overlay_content_wrap .single_reply_status .submit_status_label').removeClass('active_submit_button');
@ -2032,7 +2036,6 @@ $("#widget_ffdl").slideUp();
$("#search_form").focus(function() {
if($("#search_form").val() == "") searchlocalfill();
else searchremotefill($("#search_form").val());
$(".header_search_suggestions").removeClass("invisible");
}).keyup(function() {
if($("#search_form").val() == "") searchlocalfill();
else searchremotefill($("#search_form").val());
@ -2064,6 +2067,26 @@ $('.close_button').click();
window.open("https://twitter.com/"+$(".overlay_redirect_nitter").data("path"),"_blank");
if($("#redirect_nitter_permanent")[0].checked) localStorage.setting_redirect_nitter = "false";
});
$('.overlay_rewrite_invidious_yes').click(function() {
$('.close_button').click();
submitStatusArray($(".overlay_rewrite_invidious").data("params"),$(".overlay_rewrite_invidious").data("callback"),"true",$(".overlay_rewrite_invidious").data("nitter"));
if($("#rewrite_invidious_permanent")[0].checked) localStorage.setting_rewrite_invidious = "true";
});
$('.overlay_rewrite_invidious_no').click(function() {
$('.close_button').click();
submitStatusArray($(".overlay_rewrite_invidious").data("params"),$(".overlay_rewrite_invidious").data("callback"),"false",$(".overlay_rewrite_invidious").data("nitter"));
if($("#rewrite_invidious_permanent")[0].checked) localStorage.setting_rewrite_invidious = "false";
});
$('.overlay_rewrite_nitter_yes').click(function() {
$('.close_button').click();
submitStatusArray($(".overlay_rewrite_nitter").data("params"),$(".overlay_rewrite_nitter").data("callback"),$(".overlay_rewrite_nitter").data("invidious"),"true");
if($("#rewrite_nitter_permanent")[0].checked) localStorage.setting_rewrite_nitter = "true";
});
$('.overlay_rewrite_nitter_no').click(function() {
$('.close_button').click();
submitStatusArray($(".overlay_rewrite_nitter").data("params"),$(".overlay_rewrite_nitter").data("callback"),$(".overlay_rewrite_nitter").data("invidious"),"false");
if($("#rewrite_nitter_permanent")[0].checked) localStorage.setting_rewrite_nitter = "false";
});
if($("#js-overlay_content_wrap").hasClass("view")) $(document.body).css("overflow-y","hidden");
$("#js-overlay_content_wrap").attrchange(function(attr) {
if(attr == "class" && $("#js-overlay_content_wrap").hasClass("view")) $(document.body).css("overflow-y","hidden");

View File

@ -17,6 +17,8 @@ include dirname(__FILE__).('/widgets/overlay_prompt.php');
include dirname(__FILE__).('/widgets/overlay_addlist.php');
include dirname(__FILE__).('/widgets/overlay_redirect_invidious.php');
include dirname(__FILE__).('/widgets/overlay_redirect_nitter.php');
include dirname(__FILE__).('/widgets/overlay_rewrite_invidious.php');
include dirname(__FILE__).('/widgets/overlay_rewrite_nitter.php');
if($_SERVER["REQUEST_URI"] == "/settings/filters") include dirname(__FILE__).('/widgets/overlay_filter.php');
?>
</div>

View File

@ -124,7 +124,7 @@ server_setting_nitter = <?=$config["Media"]["nitter"] ? "'".$config["Media"]["ni
<ul class="header_nav_list">
<li class="header_nav_item search_form_wrap">
<form class="search_form" action="/search" method="GET">
<input id="search_form" class="search_form_input" placeholder="<?=_('Search Mastodon')?>" type="text" name="q" accesskey="/">
<input id="search_form" class="search_form_input" placeholder="<?=_('Search Mastodon')?>" type="text" name="q" accesskey="/" autocomplete="off">
<span class="search_form_submit">
<button type="submit">
<i class="fa fa-fw fa-search"></i>

View File

@ -47,6 +47,7 @@ localStorage.setItem('setting_show_content_warning', 'false');
localStorage.setItem('setting_show_nsfw', 'false');
localStorage.setItem('setting_full_height', 'false');
localStorage.setItem('setting_thread_view', 'true');
localStorage.setItem('setting_show_admin','false');
localStorage.setItem('setting_compose_autocomplete', 'true');
localStorage.setItem('setting_play_gif','true');
localStorage.setItem('setting_play_video','true');
@ -59,6 +60,8 @@ localStorage.setItem('setting_post_privacy','".$profile["source"]["privacy"]."')
localStorage.setItem('setting_post_sensitive','".$profile["source"]["sensitive"]."');
localStorage.setItem('setting_redirect_invidious','unset');
localStorage.setItem('setting_redirect_nitter','unset');
localStorage.setItem('setting_rewrite_invidious','unset');
localStorage.setItem('setting_rewrite_nitter','unset');
$.cookie('darktheme','unset',{path:'/',expires:3650});
if(sessionStorage.return && sessionStorage.return == 'share') location.href = '/intent/toot?action=send';
else location.href = '/';

View File

@ -123,6 +123,17 @@
</div>
</div>
</div>
<div style="float:left;width:50%;text-align:right;margin-top:16px">
<h3><?=_('Show administrator options')?></h3>
</div>
<div class="show_admin_wrap" style="float:left;width:50%">
<div class="switch">
<input type="checkbox" id="setting_show_admin">
<div class="switch-btn">
<span></span>
</div>
</div>
</div>
<span style="visibility:hidden">-</span>
</div>
</article>

View File

@ -76,6 +76,34 @@ echo "<option value='".$languages[$i]."'".$selected.">"._('Language_'.$languages
</div>
</div>
<div style="float:left;width:50%;text-align:right;margin-top:16px">
<h3><?=_('Rewrite YouTube to Invidious at compose')?></h3>
</div>
<div class="rewrite_invidious_wrap" style="float:left;width:50%">
<div class="switch" style="float:left">
<input type="checkbox" id="setting_rewrite_invidious">
<div class="switch-btn">
<span></span>
</div>
</div>
<a href="javascript:void(0)" id="setting_rewrite_invidious_reset" style="float:left;display:none">
<i class="fa fa-2x fa-times" style="margin-top:8px"></i>
</a>
</div>
<div style="float:left;width:50%;text-align:right;margin-top:16px">
<h3><?=_('Rewrite Twitter to Nitter at compose')?></h3>
</div>
<div class="rewrite_nitter_wrap" style="float:left;width:50%">
<div class="switch" style="float:left">
<input type="checkbox" id="setting_rewrite_nitter">
<div class="switch-btn">
<span></span>
</div>
</div>
<a href="javascript:void(0)" id="setting_rewrite_nitter_reset" style="float:left;display:none">
<i class="fa fa-2x fa-times" style="margin-top:8px"></i>
</a>
</div>
<div style="float:left;width:50%;text-align:right;margin-top:16px">
<h3><?=_('Local instance')?></h3>
</div>
<div class="local_instance_wrap" style="float:left;width:50%">

View File

@ -1 +1 @@
2.4.4
2.4.5

View File

@ -0,0 +1,24 @@
<div class="overlay_simple overlay_rewrite_invidious invisible">
<header class="overlay_simple_header">
<span><?=_('Protect your privacy!')?></span>
</header>
<div class="overlay_simple_body">
<div class="overlay_rewrite_invidious_text" style="margin-bottom:10px">
<?=_("Halcyon has detected that you're trying to post a link to the privacy-invasive video platform YouTube. Halcyon can automatically rewrite that link to Invidious, a privacy-friendly way to watch this video for free and without any ads. Do you want to replace your link with Invidious?")?><br/>
<center><a href="https://github.com/omarroth/invidious" class="halcyon_link" target="_blank"><?=_("Tell me more about Invidious!")?></a></center>
<div style="margin-bottom:20px;width:100%">
<div class="switch" style="margin:0;float:left">
<input type="checkbox" id="rewrite_invidious_permanent">
<div class="switch-btn">
<span></span>
</div>
</div>
<label for="rewrite_invidious_permanent" style="margin-left:5px;vertical-align:sub"><?=_('Remember my decision')?></label>
</div>
</div>
<div class="overlay_simple_controls">
<button class="overlay_rewrite_invidious_yes toot_button" style="float:right;width:180px"><div class="toot_button_label"><i class="fa fa-fw fa-check"></i><span><?=_('Rewrite to Invidious')?></span></div></button>
<a href="javascript:void(0)" class="overlay_rewrite_invidious_no halcyon_link" style="float:right;margin-top:5px;margin-right:10px"><i class="fa fa-times"></i> <?=_('No, thanks')?></a>
</div>
</div>
</div>

View File

@ -0,0 +1,24 @@
<div class="overlay_simple overlay_rewrite_nitter invisible">
<header class="overlay_simple_header">
<span><?=_('Protect your privacy!')?></span>
</header>
<div class="overlay_simple_body">
<div class="overlay_rewrite_nitter_text" style="margin-bottom:10px">
<?=_("Halcyon has detected that you're trying to post a link to the centralized microblogging platform Twitter. Halcyon can automatically rewrite that link to Nitter, a privacy-friendly and faster way to view this content for free and without any ads. Do you want to replace your link with Nitter?")?><br/>
<center><a href="https://github.com/zedeus/nitter" class="halcyon_link" target="_blank"><?=_("Tell me more about Nitter!")?></a></center>
<div style="margin-bottom:20px;width:100%">
<div class="switch" style="margin:0;float:left">
<input type="checkbox" id="rewrite_nitter_permanent">
<div class="switch-btn">
<span></span>
</div>
</div>
<label for="redirect_nitter_permanent" style="margin-left:5px;vertical-align:sub"><?=_('Remember my decision')?></label>
</div>
</div>
<div class="overlay_simple_controls">
<button class="overlay_rewrite_nitter_yes toot_button" style="float:right;width:150px"><div class="toot_button_label"><i class="fa fa-fw fa-check"></i><span><?=_('Rewrite to Nitter')?></span></div></button>
<a href="javascript:void(0)" class="overlay_rewrite_nitter_no halcyon_link" style="float:right;margin-top:5px;margin-right:10px"><i class="fa fa-times"></i> <?=_('No, thanks')?></a>
</div>
</div>
</div>