mirror of
https://github.com/discourse/discourse.git
synced 2025-03-28 11:11:48 +08:00
FIX: Oneboxes with incorrect URL
This commit is contained in:
parent
dbbc5248aa
commit
de3c657ea3
@ -23,14 +23,12 @@ if ((typeof console !== 'undefined') && console.groupCollapsed) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Adds a child node underneath this node. It also creates a reference between
|
Adds a child node underneath this node.
|
||||||
the child and the parent.
|
|
||||||
|
|
||||||
@method addChild
|
@method addChild
|
||||||
@param {ProfileNode} node the node we want as a child
|
@param {ProfileNode} node the node we want as a child
|
||||||
**/
|
**/
|
||||||
ProfileNode.prototype.addChild = function(node) {
|
ProfileNode.prototype.addChild = function(node) {
|
||||||
node.parent = this;
|
|
||||||
this.children.push(node);
|
this.children.push(node);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -41,8 +39,7 @@ if ((typeof console !== 'undefined') && console.groupCollapsed) {
|
|||||||
@method log
|
@method log
|
||||||
**/
|
**/
|
||||||
ProfileNode.prototype.log = function(type) {
|
ProfileNode.prototype.log = function(type) {
|
||||||
var time = this.end - this.start;
|
if (this.time < 1) { return; }
|
||||||
if (time < 1) { return; }
|
|
||||||
|
|
||||||
var description = "";
|
var description = "";
|
||||||
if (this.payload) {
|
if (this.payload) {
|
||||||
@ -54,13 +51,18 @@ if ((typeof console !== 'undefined') && console.groupCollapsed) {
|
|||||||
description += this.payload.object.toString() + " ";
|
description += this.payload.object.toString() + " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
description += (Math.round(time * 100) / 100).toString() + "ms";
|
description += (Math.round(this.time * 100) / 100).toString() + "ms";
|
||||||
|
|
||||||
console.groupCollapsed(type + ": " + description);
|
if (this.children.length === 0) {
|
||||||
this.children.forEach(function (c) {
|
console.log(type + ": " + description);
|
||||||
c.log(type);
|
} else {
|
||||||
});
|
// render a collapsed group when there are children
|
||||||
console.groupEnd();
|
console.groupCollapsed(type + ": " + description);
|
||||||
|
this.children.forEach(function (c) {
|
||||||
|
c.log(type);
|
||||||
|
});
|
||||||
|
console.groupEnd();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up our instrumentation of Ember below
|
// Set up our instrumentation of Ember below
|
||||||
@ -69,15 +71,21 @@ if ((typeof console !== 'undefined') && console.groupCollapsed) {
|
|||||||
|
|
||||||
before: function(name, timestamp, payload) {
|
before: function(name, timestamp, payload) {
|
||||||
var node = new ProfileNode(timestamp, payload);
|
var node = new ProfileNode(timestamp, payload);
|
||||||
if (this.depth) { this.depth.addChild(node); }
|
if (this.depth) { node.parent = this.depth; }
|
||||||
this.depth = node;
|
this.depth = node;
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
},
|
},
|
||||||
|
|
||||||
after: function(name, timestamp, payload, profileNode) {
|
after: function(name, timestamp, payload, profileNode) {
|
||||||
|
|
||||||
|
var parent = profileNode.parent;
|
||||||
|
profileNode.time = (timestamp - profileNode.start);
|
||||||
this.depth = profileNode.parent;
|
this.depth = profileNode.parent;
|
||||||
profileNode.end = timestamp;
|
|
||||||
|
if (this.depth && (profileNode.time > 1)) {
|
||||||
|
this.depth.addChild(profileNode);
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.depth) {
|
if (!this.depth) {
|
||||||
profileNode.log("Render");
|
profileNode.log("Render");
|
||||||
@ -87,4 +95,4 @@ if ((typeof console !== 'undefined') && console.groupCollapsed) {
|
|||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ module Oneboxer
|
|||||||
return BaseOnebox.image_html(parsed['url'] || parsed['thumbnail_url'], parsed['title'], parsed['web_page'] || @url)
|
return BaseOnebox.image_html(parsed['url'] || parsed['thumbnail_url'], parsed['title'], parsed['web_page'] || @url)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
parsed['original_url'] = parsed['url']
|
||||||
parsed['html'] ||= parsed['abstract']
|
parsed['html'] ||= parsed['abstract']
|
||||||
parsed['host'] = nice_host
|
parsed['host'] = nice_host
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user