merged reposts
This commit is contained in:
parent
919ba97744
commit
b676a33c7b
2 changed files with 171 additions and 57 deletions
|
@ -38,23 +38,23 @@ ol li, .error, header.profile {
|
||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
|
|
||||||
ol li:first-child {
|
body > ol > li:first-child {
|
||||||
border-top: 0;
|
border-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ol li:nth-child(odd), .error, header.profile {
|
body > ol > li:nth-child(odd), .error, header.profile {
|
||||||
background: url(../img/odd-bg.png) repeat-x bottom #fafafa;
|
background: url(../img/odd-bg.png) repeat-x bottom #fafafa;
|
||||||
}
|
}
|
||||||
|
|
||||||
ol li:nth-child(even) {
|
body > ol > li:nth-child(even) {
|
||||||
background: url(../img/even-bg.png) repeat-x bottom #f2f2f2;
|
background: url(../img/even-bg.png) repeat-x bottom #f2f2f2;
|
||||||
}
|
}
|
||||||
|
|
||||||
ol li:hover {
|
body > ol > li:hover {
|
||||||
background: #dedede;
|
background: #dedede;
|
||||||
}
|
}
|
||||||
|
|
||||||
ol li:after, header.profile:after {
|
body > ol > li:after, header.profile:after {
|
||||||
content: ".";
|
content: ".";
|
||||||
display: block;
|
display: block;
|
||||||
clear: both;
|
clear: both;
|
||||||
|
@ -249,6 +249,70 @@ li.mentioned {
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.reposted_by {
|
||||||
|
position: relative;
|
||||||
|
color: #00317a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reposted_by ul {
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
list-style-type: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 3px 6px;
|
||||||
|
background: black;
|
||||||
|
border-radius: 3px;
|
||||||
|
box-shadow: 0 0 5px rgba(0,0,0,0.7);
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reposted_by:hover ul {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reposted_by:hover ul:empty {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reposted_by li {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
background: black;
|
||||||
|
text-align: center;
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reposted_by li:hover {
|
||||||
|
background: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reposted_by li a {
|
||||||
|
color: white;
|
||||||
|
background: black;
|
||||||
|
font-weight: normal;
|
||||||
|
text-decoration: none;
|
||||||
|
border: none;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reposted_by ul:after {
|
||||||
|
bottom: 100%;
|
||||||
|
border: solid transparent;
|
||||||
|
content: " ";
|
||||||
|
height: 0;
|
||||||
|
width: 0;
|
||||||
|
position: absolute;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reposted_by ul:after {
|
||||||
|
border-color: rgba(0, 0, 0, 0);
|
||||||
|
border-bottom-color: #000000;
|
||||||
|
border-width: 5px;
|
||||||
|
left: 50%;
|
||||||
|
margin-left: -5px;
|
||||||
|
}
|
||||||
|
|
||||||
header.profile button {
|
header.profile button {
|
||||||
background: #09F;
|
background: #09F;
|
||||||
float: right;
|
float: right;
|
||||||
|
|
|
@ -88,9 +88,17 @@ function(jQuery, Paths, URI, HostApp, Cache) {
|
||||||
|
|
||||||
head.appendChild(space.cloneNode());
|
head.appendChild(space.cloneNode());
|
||||||
|
|
||||||
var reposted_by = a.cloneNode();
|
var reposted_by = document.createElement("span");
|
||||||
reposted_by.className = "reposted_by";
|
reposted_by.className = "reposted_by";
|
||||||
reposted_by.style.display = "none";
|
reposted_by.style.display = "none";
|
||||||
|
|
||||||
|
var reposted_count = document.createElement("span");
|
||||||
|
reposted_count.innerText = "by 0 people";
|
||||||
|
reposted_by.appendChild(reposted_count)
|
||||||
|
|
||||||
|
var reposted_list = document.createElement("ul");
|
||||||
|
reposted_by.appendChild(reposted_list);
|
||||||
|
|
||||||
head.appendChild(reposted_by)
|
head.appendChild(reposted_by)
|
||||||
|
|
||||||
|
|
||||||
|
@ -132,7 +140,7 @@ function(jQuery, Paths, URI, HostApp, Cache) {
|
||||||
remove: remove
|
remove: remove
|
||||||
}
|
}
|
||||||
|
|
||||||
return jQuery.extend(true, {}, this.template);
|
return jQuery.extend(true, {}, this.template);;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core.prototype.getStatusDOMElement = function(status) {
|
Core.prototype.getStatusDOMElement = function(status) {
|
||||||
|
@ -233,24 +241,17 @@ function(jQuery, Paths, URI, HostApp, Cache) {
|
||||||
|
|
||||||
if (typeof status.__repost != "undefined") {
|
if (typeof status.__repost != "undefined") {
|
||||||
|
|
||||||
template.reposted_by.href = status.__repost.entity;
|
$(template.reposted_by).show();
|
||||||
template.reposted_by.innerText = status.__repost.entity;
|
var a = $("<a/>");
|
||||||
template.reposted_by.title = status.__repost.entity;
|
$(template.reposted_by).find("span").html(a)
|
||||||
template.reposted_by.style.display = '';
|
|
||||||
template.reposted_by.onclick = function(e) {
|
a.attr("href", status.__repost.entity)
|
||||||
|
a.html(status.__repost.entity);
|
||||||
|
a.attr("title", status.__repost.entity);
|
||||||
|
a.click(function(e) {
|
||||||
HostApp.showProfileForEntity(status.__repost.entity);
|
HostApp.showProfileForEntity(status.__repost.entity);
|
||||||
return false;
|
return false;
|
||||||
}
|
});
|
||||||
|
|
||||||
var repost_profile = this.cache.profiles.getItem(status.__repost.entity)
|
|
||||||
if (repost_profile) {
|
|
||||||
|
|
||||||
var basic = repost_profile["https://tent.io/types/info/basic/v0.1.0"];
|
|
||||||
if (basic) {
|
|
||||||
template.reposted_by.innerText = basic.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
Paths.findProfileURL(status.__repost.entity, function(profile_url) {
|
Paths.findProfileURL(status.__repost.entity, function(profile_url) {
|
||||||
if (profile_url) {
|
if (profile_url) {
|
||||||
|
@ -261,7 +262,7 @@ function(jQuery, Paths, URI, HostApp, Cache) {
|
||||||
|
|
||||||
var basic = _p["https://tent.io/types/info/basic/v0.1.0"];
|
var basic = _p["https://tent.io/types/info/basic/v0.1.0"];
|
||||||
if (basic && basic.name) {
|
if (basic && basic.name) {
|
||||||
template.reposted_by.innerText = basic.name;
|
a.html("by " + basic.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -270,7 +271,6 @@ function(jQuery, Paths, URI, HostApp, Cache) {
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (status && status.permissions && !status.permissions.public) {
|
if (status && status.permissions && !status.permissions.public) {
|
||||||
template.is_private.style.display = '';
|
template.is_private.style.display = '';
|
||||||
|
@ -371,6 +371,61 @@ function(jQuery, Paths, URI, HostApp, Cache) {
|
||||||
|
|
||||||
Core.prototype.getRepost = function(repost, before_node) {
|
Core.prototype.getRepost = function(repost, before_node) {
|
||||||
|
|
||||||
|
var post = document.getElementById("post-" + repost.content.id);
|
||||||
|
if (post) {
|
||||||
|
|
||||||
|
var reposted_count = $(post).find(".reposted_by ul li").length + 1;
|
||||||
|
|
||||||
|
if (reposted_count == 1) {
|
||||||
|
|
||||||
|
$(post).find(".reposted_by").show();
|
||||||
|
var a = $("<a/>");
|
||||||
|
a.attr("href", repost.entity);
|
||||||
|
a.attr("title", repost.entity);
|
||||||
|
a.html(repost.entity);
|
||||||
|
$(post).find(".reposted_by span").html(a);
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
var people_person = reposted_count == 1 ? "person" : "people";
|
||||||
|
|
||||||
|
$(post).find(".reposted_by span").html("by " + reposted_count + " " + people_person);
|
||||||
|
$(post).find(".reposted_by").show();
|
||||||
|
|
||||||
|
var li = $("<li/>");
|
||||||
|
var a = $("<a/>");
|
||||||
|
a.attr("href", repost.entity);
|
||||||
|
a.attr("title", repost.entity);
|
||||||
|
a.html(repost.entity);
|
||||||
|
li.append(a);
|
||||||
|
$(post).find(".reposted_by ul").append(li);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
a.click(function(e) {
|
||||||
|
HostApp.showProfileForEntity(repost.entity);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
var _this = this;
|
||||||
|
Paths.findProfileURL(repost.entity, function(profile_url) {
|
||||||
|
if (profile_url) {
|
||||||
|
Paths.getURL(profile_url, "GET", function(resp) {
|
||||||
|
if (resp.status >= 200 && resp.status < 400) {
|
||||||
|
var _p = JSON.parse(resp.responseText);
|
||||||
|
_this.cache.profiles.setItem(repost.entity, _p);
|
||||||
|
|
||||||
|
var basic = _p["https://tent.io/types/info/basic/v0.1.0"];
|
||||||
|
if (basic && basic.name) {
|
||||||
|
a.html(basic.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}, null, false); // do not send auth-headers
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var callback = function(resp) {
|
var callback = function(resp) {
|
||||||
if (resp.status >= 200 && resp.status < 300 && before_node) {
|
if (resp.status >= 200 && resp.status < 300 && before_node) {
|
||||||
|
@ -381,11 +436,6 @@ function(jQuery, Paths, URI, HostApp, Cache) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var profile = this.cache.profiles.getItem(repost.content.entity);
|
|
||||||
if (profile && profile != "null") {
|
|
||||||
var server = profile["https://tent.io/types/info/core/v0.1.0"].servers[0];
|
|
||||||
Paths.getURL(URI(server + "/posts/" + repost.content.id).toString(), "GET", callback, null, false);
|
|
||||||
} else {
|
|
||||||
Paths.findProfileURL(repost.content.entity, function(profile_url) {
|
Paths.findProfileURL(repost.content.entity, function(profile_url) {
|
||||||
if (profile_url) {
|
if (profile_url) {
|
||||||
|
|
||||||
|
@ -397,7 +447,7 @@ function(jQuery, Paths, URI, HostApp, Cache) {
|
||||||
|
|
||||||
}, null, false); // do not send auth-headers
|
}, null, false); // do not send auth-headers
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue