Added link previews and fixed bug with replies

This commit is contained in:
nipos 2018-04-27 15:32:45 +02:00
parent 284c44215b
commit 4924089e9e
7 changed files with 138 additions and 5 deletions

View File

@ -10,9 +10,9 @@ Follow or Mastodon account and never miss an important update: [@halcyon@social.
## Instances
These instances are publicly accessible and usable by everyone, no matter which Mastodon instance you use.
- https://halcyon.toromino.de - 1.1.2
- https://halcyon.toromino.de - 1.1.3
- https://social.dev-wiki.de - 1.1.1
- https://halcyon.bka.li - 1.1.2
- https://halcyon.bka.li - 1.1.3
- https://halcyon.tilde.team - 1.1.2
- https://itter.photog.social - 1.1.1
- https://halcyon.cybre.space - Outdated
@ -20,6 +20,7 @@ These instances are publicly accessible and usable by everyone, no matter which
You have your own Halcyon instance and want it to be listed here? Create an issue with the link and we will add it to the list.
## Blog
- Release of Version 1.1.3 - New function link previews introduced and bug when replying an toot which already has replies below it fixed (reply to undefined)
- Release of Version 1.1.2 - Privacy modes are now correctly displayed and used for replies,use username if display name doesn't exist,bugs on search page fixed
- Release of Version 1.1.1 - Fixed error 404 when viewing profile of own instance,numbers below profile on the left do now change during session,added nginx config
- [Release of Version 1.1.0 and upcoming features](http://nikisoft.myblog.de/nikisoft/art/11389499/Halcyon-What-we-did-and-what-we-will-do)

View File

@ -2337,3 +2337,49 @@ border-bottom: none;
.media_detail .toot_entry .media_views {
display: none;
}
.switch {
width: 60px;
height: 30px;
margin:auto;
margin-top:8px;
margin-bottom:16px;
}
.switch input {
width: 60px;
height: 30px;
position: absolute;
filter: alpha(opacity=0);
opacity: 0;
outline: none;
z-index: 9;
}
.switch input:hover {
cursor: pointer;
}
.switch-btn {
background: #AAB8C2;
width: 100%;
height: 100%;
border-radius: 20px;
position: relative;
}
.switch-btn span {
background: #fff;
width: 26px;
height: 26px;
display: block;
border-radius: 50%;
position: absolute;
top: 2px;
left: 2px;
-webkit-transition: all .5s;
-moz-transition: all .5s;
-o-transition: all .5s;
transition: all .5s;
}
.switch input:checked + .switch-btn span {
left: 32px;
}
.switch input:checked + .switch-btn {
background: #189EFC;
}

View File

@ -43,6 +43,71 @@ const tags = $(this).attr('href').match(/https:\/\/.+..+\/tags\/(.+)\/?/);
if (tags) {
$(this).attr('href','/search?q='+tags[1]);
}
if(localStorage.setting_link_previews == "true") {
if(!window.cards) {
cards = new Array();
}
if(!$(this).attr("class") && $(this).parent().parent().parent().parent().parent().attr("sid") != undefined) {
if(!cards[$(this).parent().parent().parent().parent().parent().attr("sid")]) {
var this_id = $(this).parent().parent().parent().parent().parent().attr("sid");
api.get("statuses/"+$(this).parent().parent().parent().parent().parent().attr("sid")+"/card",function(data) {
cards[this_id] = data;
if($(".toot_entry[sid="+this_id+"]").children().children("section").children("article").children(".link_preview").length == 0 && data.url) {
$(".toot_entry[sid="+this_id+"]").children().children("section").children("article").append(
$("<div>").addClass("media_views").addClass("link_preview").attr("sid",this_id).attr("media_length",1).css("height","unset").data("url",data.url).append(
$("<img>").attr("src",data.image).width(data.width).css("max-width","200px").css("float","left").css("margin-right","5px")).append(
$("<strong>").text(data.title)).append($("<br>")).append(
$("<span>").text(data.description)).append($("<br>")).append(
$("<span>").css("color","#777777").text(data.url)).click(function(e) {
e.stopPropagation();
window.open($(this).data("url"),"_blank");
})
);
}
if($(".main_status[sid="+this_id+"]").children().children("section").children("article").children(".link_preview").length == 0 && data.url) {
$(".main_status[sid="+this_id+"]").children().children("section").children("article").append(
$("<div>").addClass("media_views").addClass("link_preview").attr("sid",this_id).attr("media_length",1).css("height","unset").data("url",data.url).append(
$("<img>").attr("src",data.image).width(data.width).css("max-width","200px").css("float","left").css("margin-right","5px")).append(
$("<strong>").text(data.title)).append($("<br>")).append(
$("<span>").text(data.description)).append($("<br>")).append(
$("<span>").css("color","#777777").text(data.url)).click(function(e) {
e.stopPropagation();
window.open($(this).data("url"),"_blank");
})
);
}
});
}
else {
var this_id = $(this).parent().parent().parent().parent().parent().attr("sid");
data = cards[this_id];
if($(".toot_entry[sid="+this_id+"]").children().children("section").children("article").children(".link_preview").length == 0 && data.url) {
$(".toot_entry[sid="+this_id+"]").children().children("section").children("article").append(
$("<div>").addClass("media_views").addClass("link_preview").attr("sid",this_id).attr("media_length",1).css("height","unset").data("url",data.url).append(
$("<img>").attr("src",data.image).width(data.width).css("max-width","200px").css("float","left").css("margin-right","5px")).append(
$("<strong>").text(data.title)).append($("<br>")).append(
$("<span>").text(data.description)).append($("<br>")).append(
$("<span>").css("color","#777777").text(data.url)).click(function(e) {
e.stopPropagation();
window.open($(this).data("url"),"_blank");
})
);
}
if($(".main_status[sid="+this_id+"]").children().children("section").children("article").children(".link_preview").length == 0 && data.url) {
$(".main_status[sid="+this_id+"]").children().children("section").children("article").append(
$("<div>").addClass("media_views").addClass("link_preview").attr("sid",this_id).attr("media_length",1).css("height","unset").data("url",data.url).append(
$("<img>").attr("src",data.image).width(data.width).css("max-width","200px").css("float","left").css("margin-right","5px")).append(
$("<strong>").text(data.title)).append($("<br>")).append(
$("<span>").text(data.description)).append($("<br>")).append(
$("<span>").css("color","#777777").text(data.url)).click(function(e) {
e.stopPropagation();
window.open($(this).data("url"),"_blank");
})
);
}
}
}
}
});
}
function getConversionedDate(key, value) {

View File

@ -1204,7 +1204,7 @@ ${media_views}
</article>
<footer class="toot_footer"${toot_footer_width}>
<div class="toot_reaction">
<button class="reply_button" tid="${status.id}" username="${status.account.username}" display_name="${status.account.display_name}" privacy="${status.visibility}">
<button class="reply_button" tid="${status.id}" acct="@${status.account.acct}" display_name="${status.account.display_name}" privacy="${status.visibility}">
<i class="fa fa-fw fa-reply"></i>
<span class="reaction_count reply_count"></span>
</button>
@ -1310,7 +1310,7 @@ ${media_views}
</article>
<footer class="toot_footer" style="width:320px">
<div class="toot_reaction">
<button class="reply_button" tid="${status.reblog.id}" username="${status.reblog.account.username}" display_name="${status.reblog.account.display_name}" privacy="${status.reblog.visibility}">
<button class="reply_button" tid="${status.reblog.id}" acct="@${status.reblog.account.acct}" display_name="${status.reblog.account.display_name}" privacy="${status.reblog.visibility}">
<i class="fa fa-fw fa-reply"></i>
<span class="reaction_count reply_count"></span>
</button>
@ -2455,6 +2455,9 @@ $('.post_steraming_wrap').html(html_post_steraming)
$('.post_privacy_wrap').html(html_post_privacy);
$('.local_instance_wrap').html(html_local_instance);
$('.search_filter_wrap').html(html_search_filter);
if(localStorage.setting_link_previews == "true") {
$("#setting_link_previews")[0].checked = true;
}
return false;
});
$(document).on('change',".post_steraming_wrap select[name='post_steraming']", function(e) {
@ -2480,6 +2483,16 @@ localStorage.setItem("setting_local_instance", "default" );
}
putMessage("Changed setting to "+$(this).val() );
});
$("#setting_link_previews").change(function() {
if(this.checked) {
localStorage.setItem("setting_link_previews","true");
putMessage("Link preview enabled");
}
else {
localStorage.setItem("setting_link_previews","false");
putMessage("Link preview disabled");
}
});
})
$(function() {
shortcut.add("n",function() {

View File

@ -32,6 +32,7 @@ localStorage.setItem('setting_post_stream', 'auto');
localStorage.setItem('setting_post_privacy', 'public');
localStorage.setItem('setting_local_instance', 'default');
localStorage.setItem('setting_search_filter', 'all');
localStorage.setItem('setting_link_previews', 'true');
localStorage.setItem('what_to_follow_0', JSON.stringify({id:'',username:'Halcyon',display_name:'Halcyon for Mastodon',url:'https://social.csswg.org/@halcyon',avatar:'https://social.csswg.org/system/accounts/avatars/000/005/666/original/e9a158381ce1249a.png'}));
localStorage.setItem('what_to_follow_1', JSON.stringify({id:'',username:'Gargron',display_name:'Eugen',url:'https://mastodon.social/@Gargron',avatar:'https://files.mastodon.social/accounts/avatars/000/000/001/original/4df197532c6b768c.png'}));
localStorage.setItem('what_to_follow_2', JSON.stringify({id:'',username:'Mastodon',display_name:'Mastodon',url:'https://mastodon.social/@Mastodon',avatar:'https://files.mastodon.social/accounts/avatars/000/013/179/original/27bc451c7713091b.jpg'}));

View File

@ -1 +1 @@
1.1.2
1.1.3

View File

@ -16,5 +16,12 @@
<h3>Hashtag search filter</h3>
<div class="search_filter_wrap">
</div>
<h3>Enable link previews</h3>
<div class="switch">
<input type="checkbox" id="setting_link_previews">
<div class="switch-btn">
<span></span>
</div>
</div>
</form>
</div>