now showing referenced images
This commit is contained in:
parent
7d21000c80
commit
dbad342cbc
3 changed files with 40 additions and 39 deletions
|
@ -86,7 +86,7 @@ function(HostApp, Core, APICalls, URI, ConversationNode) {
|
||||||
|
|
||||||
var status = _statuses.post;
|
var status = _statuses.post;
|
||||||
|
|
||||||
var dom_element = _this.getStatusDOMElement(status);
|
var dom_element = _this.getStatusDOMElement(status, _statuses.refs);
|
||||||
var cNode = new ConversationNode(dom_element);
|
var cNode = new ConversationNode(dom_element);
|
||||||
dom_element.cNode = cNode;
|
dom_element.cNode = cNode;
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ function(HostApp, Core, APICalls, URI, ConversationNode) {
|
||||||
var url = HostApp.serverUrl("post")
|
var url = HostApp.serverUrl("post")
|
||||||
.replace(/\{entity\}/, encodeURIComponent(entity))
|
.replace(/\{entity\}/, encodeURIComponent(entity))
|
||||||
.replace(/\{post\}/, id)
|
.replace(/\{post\}/, id)
|
||||||
+ "?profiles=entity";
|
+ "?profiles=entity&max_refs=20";
|
||||||
|
|
||||||
APICalls.get(url, { callback: callback });
|
APICalls.get(url, { callback: callback });
|
||||||
}
|
}
|
||||||
|
@ -141,15 +141,16 @@ function(HostApp, Core, APICalls, URI, ConversationNode) {
|
||||||
var callback = function(resp) {
|
var callback = function(resp) {
|
||||||
|
|
||||||
var statuses = JSON.parse(resp.responseText).mentions;
|
var statuses = JSON.parse(resp.responseText).mentions;
|
||||||
|
if (statuses) {
|
||||||
|
for (var i = 0; i < statuses.length; i++) {
|
||||||
|
|
||||||
for (var i = 0; i < statuses.length; i++) {
|
var status = statuses[i];
|
||||||
|
|
||||||
var status = statuses[i];
|
// don't load if it is already there
|
||||||
|
var not_already_there = !document.getElementById("post-" + status.post + "-" + _this.action);
|
||||||
// don't load if it is already there
|
if(not_already_there && status.type.startsWith("https://tent.io/types/status/v0")) {
|
||||||
var not_already_there = !document.getElementById("post-" + status.post + "-" + _this.action);
|
_this.append(status.post, status.entity, node, true);
|
||||||
if(not_already_there && status.type.startsWith("https://tent.io/types/status/v0")) {
|
}
|
||||||
_this.append(status.post, status.entity, node, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,9 +78,12 @@ function(Core, APICalls, HostApp, URI) {
|
||||||
this.since_time = status.received_at;
|
this.since_time = status.received_at;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if(status.id == "vBf0UALAJ97LnvJN4f6sBw") debug(status);
|
||||||
|
|
||||||
|
|
||||||
if (status.type.startsWith("https://tent.io/types/status/v0#")) {
|
if (status.type.startsWith("https://tent.io/types/status/v0#")) {
|
||||||
|
|
||||||
var new_node = this.getStatusDOMElement(status);
|
var new_node = this.getStatusDOMElement(status, _statuses.refs);
|
||||||
|
|
||||||
if (!document.getElementById(new_node.id)) {
|
if (!document.getElementById(new_node.id)) {
|
||||||
if(!append && this.body.childNodes.length > 0) {
|
if(!append && this.body.childNodes.length > 0) {
|
||||||
|
@ -133,7 +136,7 @@ function(Core, APICalls, HostApp, URI) {
|
||||||
uri.addSearch("types", post_types.join(","));
|
uri.addSearch("types", post_types.join(","));
|
||||||
//uri.addSearch("sort_by", "published_at");
|
//uri.addSearch("sort_by", "published_at");
|
||||||
uri.addSearch("limit", this.posts_limit);
|
uri.addSearch("limit", this.posts_limit);
|
||||||
//uri.addSearch("max_refs", 20);
|
uri.addSearch("max_refs", 20);
|
||||||
uri.addSearch("profiles", "entity");
|
uri.addSearch("profiles", "entity");
|
||||||
|
|
||||||
if(this.since_time) {
|
if(this.since_time) {
|
||||||
|
|
|
@ -166,7 +166,7 @@ function(jQuery, APICalls, URI, HostApp, Markdown) {
|
||||||
return jQuery.extend(true, {}, this.template);;
|
return jQuery.extend(true, {}, this.template);;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core.prototype.getStatusDOMElement = function(status) {
|
Core.prototype.getStatusDOMElement = function(status, refs) {
|
||||||
|
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
|
@ -260,35 +260,32 @@ function(jQuery, APICalls, URI, HostApp, Markdown) {
|
||||||
template.message.innerHTML = this.replaceURLWithHTMLLinks(text, entities, template.message);
|
template.message.innerHTML = this.replaceURLWithHTMLLinks(text, entities, template.message);
|
||||||
this.afterChangingTextinMessageHTML(template.message)
|
this.afterChangingTextinMessageHTML(template.message)
|
||||||
|
|
||||||
/*
|
if(status.refs) {
|
||||||
if (status.type == "https://tent.io/types/post/photo/v0.1.0") {
|
for (var i = 0; i < status.refs.length; i++) {
|
||||||
|
var ref = status.refs[i];
|
||||||
for (var i = 0; i < status.attachments.length; i++) {
|
if(ref.type == "https://tent.io/types/photo/v0#") {
|
||||||
// closure needed for the callback
|
if(refs) {
|
||||||
(function() {
|
for (var j = 0; j < refs.length; j++) {
|
||||||
|
var r = refs[j];
|
||||||
var attachment = status.attachments[i];
|
if(ref.post == r.id) {
|
||||||
|
for (var k = 0; k < r.attachments.length; k++) {
|
||||||
var img = new Image();
|
var attachment = r.attachments[k];
|
||||||
|
var a = document.createElement("a");
|
||||||
img.className = "photo";
|
var img = document.createElement("img");
|
||||||
template.images.appendChild(img);
|
img.src = HostApp.serverUrl("attachment")
|
||||||
|
.replace(/\{entity\}/, encodeURIComponent(r.entity))
|
||||||
var callback = function(resp) {
|
.replace(/\{digest\}/, attachment.digest);
|
||||||
img.src = "data:" + attachment.type + ";base64," + resp.responseText;
|
a.appendChild(img);
|
||||||
|
a.href = img.src;
|
||||||
|
template.images.appendChild(a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (status.entity == HostApp.stringForKey("entity")) {
|
|
||||||
var url = APICalls.mkApiRootPath("/posts/" + status.id + "/attachments/" + attachment.name);
|
|
||||||
APICalls.http_call(url, "GET", callback, null, null, attachment.type);
|
|
||||||
} else {
|
|
||||||
var url = APICalls.mkApiRootPath("/posts/" + encodeURIComponent(status.entity) + "/" + status.id + "/attachments/" + attachment.name);
|
|
||||||
APICalls.http_call(url, "GET", callback, null, null, attachment.type);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
this.findMentions(template.message, status.mentions);
|
this.findMentions(template.message, status.mentions);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Reference in a new issue