parent
fff75df0df
commit
eb540fae1d
6 changed files with 121 additions and 33 deletions
|
@ -81,6 +81,7 @@
|
||||||
|
|
||||||
- (IBAction)showConversationForPostId:(NSString *)postId andEntity:(NSString *)entity;
|
- (IBAction)showConversationForPostId:(NSString *)postId andEntity:(NSString *)entity;
|
||||||
|
|
||||||
|
- (IBAction)clearCache:(id)sender;
|
||||||
|
|
||||||
OSStatus handler(EventHandlerCallRef nextHandler, EventRef theEvent, void* userData);
|
OSStatus handler(EventHandlerCallRef nextHandler, EventRef theEvent, void* userData);
|
||||||
|
|
||||||
|
|
|
@ -476,6 +476,11 @@
|
||||||
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
|
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (IBAction)clearCache:(id)sender
|
||||||
|
{
|
||||||
|
[timelineView stringByEvaluatingJavaScriptFromString:@"tentia_instance.cache.clear()"];
|
||||||
|
}
|
||||||
|
|
||||||
- (IBAction)showProfileForEntity:(NSString *)entity
|
- (IBAction)showProfileForEntity:(NSString *)entity
|
||||||
{
|
{
|
||||||
NSString *js = [NSString stringWithFormat:@"tentia_instance.showProfileForEntity('%@');", entity];
|
NSString *js = [NSString stringWithFormat:@"tentia_instance.showProfileForEntity('%@');", entity];
|
||||||
|
|
|
@ -104,6 +104,14 @@
|
||||||
<reference key="NSOnImage" ref="1033313550"/>
|
<reference key="NSOnImage" ref="1033313550"/>
|
||||||
<reference key="NSMixedImage" ref="310636482"/>
|
<reference key="NSMixedImage" ref="310636482"/>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="NSMenuItem" id="481623318">
|
||||||
|
<reference key="NSMenu" ref="110575045"/>
|
||||||
|
<string key="NSTitle">Clear cache</string>
|
||||||
|
<string key="NSKeyEquiv"/>
|
||||||
|
<int key="NSMnemonicLoc">2147483647</int>
|
||||||
|
<reference key="NSOnImage" ref="1033313550"/>
|
||||||
|
<reference key="NSMixedImage" ref="310636482"/>
|
||||||
|
</object>
|
||||||
<object class="NSMenuItem" id="304266470">
|
<object class="NSMenuItem" id="304266470">
|
||||||
<reference key="NSMenu" ref="110575045"/>
|
<reference key="NSMenu" ref="110575045"/>
|
||||||
<bool key="NSIsDisabled">YES</bool>
|
<bool key="NSIsDisabled">YES</bool>
|
||||||
|
@ -851,7 +859,6 @@
|
||||||
</object>
|
</object>
|
||||||
<string key="NSFrameSize">{397, 581}</string>
|
<string key="NSFrameSize">{397, 581}</string>
|
||||||
<reference key="NSSuperview" ref="332867700"/>
|
<reference key="NSSuperview" ref="332867700"/>
|
||||||
<reference key="NSWindow"/>
|
|
||||||
<reference key="NSNextKeyView"/>
|
<reference key="NSNextKeyView"/>
|
||||||
<string key="FrameName"/>
|
<string key="FrameName"/>
|
||||||
<string key="GroupName"/>
|
<string key="GroupName"/>
|
||||||
|
@ -871,7 +878,6 @@
|
||||||
</object>
|
</object>
|
||||||
<string key="NSFrameSize">{397, 581}</string>
|
<string key="NSFrameSize">{397, 581}</string>
|
||||||
<reference key="NSSuperview"/>
|
<reference key="NSSuperview"/>
|
||||||
<reference key="NSWindow"/>
|
|
||||||
<reference key="NSNextKeyView" ref="690752143"/>
|
<reference key="NSNextKeyView" ref="690752143"/>
|
||||||
</object>
|
</object>
|
||||||
<string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string>
|
<string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string>
|
||||||
|
@ -922,7 +928,6 @@
|
||||||
</object>
|
</object>
|
||||||
<string key="NSFrameSize">{376, 581}</string>
|
<string key="NSFrameSize">{376, 581}</string>
|
||||||
<reference key="NSSuperview" ref="438898709"/>
|
<reference key="NSSuperview" ref="438898709"/>
|
||||||
<reference key="NSWindow"/>
|
|
||||||
<reference key="NSNextKeyView"/>
|
<reference key="NSNextKeyView"/>
|
||||||
<string key="FrameName"/>
|
<string key="FrameName"/>
|
||||||
<string key="GroupName"/>
|
<string key="GroupName"/>
|
||||||
|
@ -940,7 +945,6 @@
|
||||||
</object>
|
</object>
|
||||||
<string key="NSFrameSize">{376, 581}</string>
|
<string key="NSFrameSize">{376, 581}</string>
|
||||||
<reference key="NSSuperview"/>
|
<reference key="NSSuperview"/>
|
||||||
<reference key="NSWindow"/>
|
|
||||||
<reference key="NSNextKeyView" ref="126069112"/>
|
<reference key="NSNextKeyView" ref="126069112"/>
|
||||||
</object>
|
</object>
|
||||||
<string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string>
|
<string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string>
|
||||||
|
@ -988,7 +992,6 @@
|
||||||
</object>
|
</object>
|
||||||
<string key="NSFrameSize">{376, 581}</string>
|
<string key="NSFrameSize">{376, 581}</string>
|
||||||
<reference key="NSSuperview" ref="469460548"/>
|
<reference key="NSSuperview" ref="469460548"/>
|
||||||
<reference key="NSWindow"/>
|
|
||||||
<reference key="NSNextKeyView"/>
|
<reference key="NSNextKeyView"/>
|
||||||
<string key="FrameName"/>
|
<string key="FrameName"/>
|
||||||
<string key="GroupName"/>
|
<string key="GroupName"/>
|
||||||
|
@ -999,7 +1002,6 @@
|
||||||
</object>
|
</object>
|
||||||
<string key="NSFrameSize">{376, 581}</string>
|
<string key="NSFrameSize">{376, 581}</string>
|
||||||
<reference key="NSSuperview"/>
|
<reference key="NSSuperview"/>
|
||||||
<reference key="NSWindow"/>
|
|
||||||
<reference key="NSNextKeyView" ref="352293288"/>
|
<reference key="NSNextKeyView" ref="352293288"/>
|
||||||
</object>
|
</object>
|
||||||
<string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string>
|
<string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string>
|
||||||
|
@ -1047,7 +1049,6 @@
|
||||||
</object>
|
</object>
|
||||||
<string key="NSFrameSize">{376, 581}</string>
|
<string key="NSFrameSize">{376, 581}</string>
|
||||||
<reference key="NSSuperview" ref="352860314"/>
|
<reference key="NSSuperview" ref="352860314"/>
|
||||||
<reference key="NSWindow"/>
|
|
||||||
<reference key="NSNextKeyView"/>
|
<reference key="NSNextKeyView"/>
|
||||||
<string key="FrameName"/>
|
<string key="FrameName"/>
|
||||||
<string key="GroupName"/>
|
<string key="GroupName"/>
|
||||||
|
@ -1058,7 +1059,6 @@
|
||||||
</object>
|
</object>
|
||||||
<string key="NSFrameSize">{376, 581}</string>
|
<string key="NSFrameSize">{376, 581}</string>
|
||||||
<reference key="NSSuperview"/>
|
<reference key="NSSuperview"/>
|
||||||
<reference key="NSWindow"/>
|
|
||||||
<reference key="NSNextKeyView" ref="106985301"/>
|
<reference key="NSNextKeyView" ref="106985301"/>
|
||||||
</object>
|
</object>
|
||||||
<string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string>
|
<string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string>
|
||||||
|
@ -1076,7 +1076,7 @@
|
||||||
<nil key="NSViewClass"/>
|
<nil key="NSViewClass"/>
|
||||||
<nil key="NSUserInterfaceItemIdentifier"/>
|
<nil key="NSUserInterfaceItemIdentifier"/>
|
||||||
<object class="NSView" key="NSWindowView" id="503676418">
|
<object class="NSView" key="NSWindowView" id="503676418">
|
||||||
<reference key="NSNextResponder"/>
|
<nil key="NSNextResponder"/>
|
||||||
<int key="NSvFlags">256</int>
|
<int key="NSvFlags">256</int>
|
||||||
<object class="NSMutableArray" key="NSSubviews">
|
<object class="NSMutableArray" key="NSSubviews">
|
||||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||||
|
@ -1228,7 +1228,6 @@
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<string key="NSFrameSize">{480, 186}</string>
|
<string key="NSFrameSize">{480, 186}</string>
|
||||||
<reference key="NSSuperview"/>
|
|
||||||
<reference key="NSNextKeyView" ref="433812480"/>
|
<reference key="NSNextKeyView" ref="433812480"/>
|
||||||
<string key="NSReuseIdentifierKey">_NS:20</string>
|
<string key="NSReuseIdentifierKey">_NS:20</string>
|
||||||
</object>
|
</object>
|
||||||
|
@ -1716,6 +1715,14 @@
|
||||||
</object>
|
</object>
|
||||||
<int key="connectionID">663</int>
|
<int key="connectionID">663</int>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="IBConnectionRecord">
|
||||||
|
<object class="IBActionConnection" key="connection">
|
||||||
|
<string key="label">clearCache:</string>
|
||||||
|
<reference key="source" ref="408500656"/>
|
||||||
|
<reference key="destination" ref="481623318"/>
|
||||||
|
</object>
|
||||||
|
<int key="connectionID">665</int>
|
||||||
|
</object>
|
||||||
<object class="IBConnectionRecord">
|
<object class="IBConnectionRecord">
|
||||||
<object class="IBActionConnection" key="connection">
|
<object class="IBActionConnection" key="connection">
|
||||||
<string key="label">makeKeyAndOrderFront:</string>
|
<string key="label">makeKeyAndOrderFront:</string>
|
||||||
|
@ -2055,6 +2062,7 @@
|
||||||
<reference ref="342932134"/>
|
<reference ref="342932134"/>
|
||||||
<reference ref="1073310099"/>
|
<reference ref="1073310099"/>
|
||||||
<reference ref="670714241"/>
|
<reference ref="670714241"/>
|
||||||
|
<reference ref="481623318"/>
|
||||||
</object>
|
</object>
|
||||||
<reference key="parent" ref="694149608"/>
|
<reference key="parent" ref="694149608"/>
|
||||||
</object>
|
</object>
|
||||||
|
@ -2591,6 +2599,11 @@
|
||||||
<reference key="object" ref="106985301"/>
|
<reference key="object" ref="106985301"/>
|
||||||
<reference key="parent" ref="352860314"/>
|
<reference key="parent" ref="352860314"/>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="IBObjectRecord">
|
||||||
|
<int key="objectID">664</int>
|
||||||
|
<reference key="object" ref="481623318"/>
|
||||||
|
<reference key="parent" ref="110575045"/>
|
||||||
|
</object>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<object class="NSMutableDictionary" key="flattenedProperties">
|
<object class="NSMutableDictionary" key="flattenedProperties">
|
||||||
|
@ -2714,6 +2727,7 @@
|
||||||
<string>658.NSWindowTemplate.visibleAtLaunch</string>
|
<string>658.NSWindowTemplate.visibleAtLaunch</string>
|
||||||
<string>659.IBPluginDependency</string>
|
<string>659.IBPluginDependency</string>
|
||||||
<string>660.IBPluginDependency</string>
|
<string>660.IBPluginDependency</string>
|
||||||
|
<string>664.IBPluginDependency</string>
|
||||||
<string>72.IBPluginDependency</string>
|
<string>72.IBPluginDependency</string>
|
||||||
<string>73.IBPluginDependency</string>
|
<string>73.IBPluginDependency</string>
|
||||||
<string>79.IBPluginDependency</string>
|
<string>79.IBPluginDependency</string>
|
||||||
|
@ -2846,6 +2860,7 @@
|
||||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
|
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<object class="NSMutableDictionary" key="unlocalizedProperties">
|
<object class="NSMutableDictionary" key="unlocalizedProperties">
|
||||||
|
@ -2860,7 +2875,7 @@
|
||||||
<reference key="dict.values" ref="0"/>
|
<reference key="dict.values" ref="0"/>
|
||||||
</object>
|
</object>
|
||||||
<nil key="sourceID"/>
|
<nil key="sourceID"/>
|
||||||
<int key="maxID">663</int>
|
<int key="maxID">665</int>
|
||||||
</object>
|
</object>
|
||||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||||
|
@ -2872,24 +2887,43 @@
|
||||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||||
<object class="NSArray" key="dict.sortedKeys">
|
<object class="NSArray" key="dict.sortedKeys">
|
||||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||||
|
<string>clearCache:</string>
|
||||||
<string>login:</string>
|
<string>login:</string>
|
||||||
<string>logout:</string>
|
<string>logout:</string>
|
||||||
|
<string>openNewMessageWindow:</string>
|
||||||
|
<string>sendTweet:</string>
|
||||||
|
<string>showConversationForPostId:andEntity:</string>
|
||||||
|
<string>showProfileForEntity:</string>
|
||||||
</object>
|
</object>
|
||||||
<object class="NSArray" key="dict.values">
|
<object class="NSArray" key="dict.values">
|
||||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||||
<string>id</string>
|
<string>id</string>
|
||||||
<string>id</string>
|
<string>id</string>
|
||||||
|
<string>id</string>
|
||||||
|
<string>id</string>
|
||||||
|
<string>id</string>
|
||||||
|
<string>NSString</string>
|
||||||
|
<string>NSString</string>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<object class="NSMutableDictionary" key="actionInfosByName">
|
<object class="NSMutableDictionary" key="actionInfosByName">
|
||||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||||
<object class="NSArray" key="dict.sortedKeys">
|
<object class="NSArray" key="dict.sortedKeys">
|
||||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||||
|
<string>clearCache:</string>
|
||||||
<string>login:</string>
|
<string>login:</string>
|
||||||
<string>logout:</string>
|
<string>logout:</string>
|
||||||
|
<string>openNewMessageWindow:</string>
|
||||||
|
<string>sendTweet:</string>
|
||||||
|
<string>showConversationForPostId:andEntity:</string>
|
||||||
|
<string>showProfileForEntity:</string>
|
||||||
</object>
|
</object>
|
||||||
<object class="NSArray" key="dict.values">
|
<object class="NSArray" key="dict.values">
|
||||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||||
|
<object class="IBActionInfo">
|
||||||
|
<string key="name">clearCache:</string>
|
||||||
|
<string key="candidateClassName">id</string>
|
||||||
|
</object>
|
||||||
<object class="IBActionInfo">
|
<object class="IBActionInfo">
|
||||||
<string key="name">login:</string>
|
<string key="name">login:</string>
|
||||||
<string key="candidateClassName">id</string>
|
<string key="candidateClassName">id</string>
|
||||||
|
@ -2898,6 +2932,22 @@
|
||||||
<string key="name">logout:</string>
|
<string key="name">logout:</string>
|
||||||
<string key="candidateClassName">id</string>
|
<string key="candidateClassName">id</string>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="IBActionInfo">
|
||||||
|
<string key="name">openNewMessageWindow:</string>
|
||||||
|
<string key="candidateClassName">id</string>
|
||||||
|
</object>
|
||||||
|
<object class="IBActionInfo">
|
||||||
|
<string key="name">sendTweet:</string>
|
||||||
|
<string key="candidateClassName">id</string>
|
||||||
|
</object>
|
||||||
|
<object class="IBActionInfo">
|
||||||
|
<string key="name">showConversationForPostId:andEntity:</string>
|
||||||
|
<string key="candidateClassName">NSString</string>
|
||||||
|
</object>
|
||||||
|
<object class="IBActionInfo">
|
||||||
|
<string key="name">showProfileForEntity:</string>
|
||||||
|
<string key="candidateClassName">NSString</string>
|
||||||
|
</object>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<object class="NSMutableDictionary" key="outlets">
|
<object class="NSMutableDictionary" key="outlets">
|
||||||
|
|
|
@ -91,6 +91,7 @@ function(Core, Paths, HostApp, URI) {
|
||||||
url.addSearch("post_types", post_types.join(","));
|
url.addSearch("post_types", post_types.join(","));
|
||||||
|
|
||||||
url.addSearch("limit", this.max_length);
|
url.addSearch("limit", this.max_length);
|
||||||
|
|
||||||
if(this.since_id) {
|
if(this.since_id) {
|
||||||
url.addSearch("since_id", this.since_id);
|
url.addSearch("since_id", this.since_id);
|
||||||
url.addSearch("since_id_entity", this.since_id_entity);
|
url.addSearch("since_id_entity", this.since_id_entity);
|
||||||
|
@ -119,6 +120,7 @@ function(Core, Paths, HostApp, URI) {
|
||||||
var data = null;
|
var data = null;
|
||||||
|
|
||||||
if (HostApp.stringForKey("user_access_token")) {
|
if (HostApp.stringForKey("user_access_token")) {
|
||||||
|
|
||||||
if (!this.reload_blocked) {
|
if (!this.reload_blocked) {
|
||||||
this.reload_blocked = true;
|
this.reload_blocked = true;
|
||||||
Paths.getURL(url.toString(), http_method, callback, data); // FIXME: error callback
|
Paths.getURL(url.toString(), http_method, callback, data); // FIXME: error callback
|
||||||
|
|
|
@ -183,6 +183,7 @@ function(jQuery, Paths, URI, HostApp, Cache) {
|
||||||
|
|
||||||
template.username.innerText = status.entity;
|
template.username.innerText = status.entity;
|
||||||
template.username.href = status.entity;
|
template.username.href = status.entity;
|
||||||
|
template.username.title = status.entity;
|
||||||
template.username.onclick = function() {
|
template.username.onclick = function() {
|
||||||
HostApp.showProfileForEntity(status.entity);
|
HostApp.showProfileForEntity(status.entity);
|
||||||
return false;
|
return false;
|
||||||
|
@ -208,6 +209,7 @@ function(jQuery, Paths, URI, HostApp, Cache) {
|
||||||
var p = this.cache.profiles.getItem(status.entity);
|
var p = this.cache.profiles.getItem(status.entity);
|
||||||
|
|
||||||
if (p && p != "null") {
|
if (p && p != "null") {
|
||||||
|
|
||||||
profile_callback(p);
|
profile_callback(p);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -215,9 +217,7 @@ function(jQuery, Paths, URI, HostApp, Cache) {
|
||||||
Paths.findProfileURL(status.entity, function(profile_url) {
|
Paths.findProfileURL(status.entity, function(profile_url) {
|
||||||
|
|
||||||
if (profile_url) {
|
if (profile_url) {
|
||||||
|
|
||||||
Paths.getURL(profile_url, "GET", function(resp) {
|
Paths.getURL(profile_url, "GET", function(resp) {
|
||||||
|
|
||||||
var p = JSON.parse(resp.responseText);
|
var p = JSON.parse(resp.responseText);
|
||||||
if (p && p != "null") {
|
if (p && p != "null") {
|
||||||
_this.cache.profiles.setItem(status.entity, p);
|
_this.cache.profiles.setItem(status.entity, p);
|
||||||
|
@ -371,7 +371,7 @@ function(jQuery, Paths, URI, HostApp, Cache) {
|
||||||
|
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var callback = function(resp) {
|
var callback = function(resp) {
|
||||||
if (resp.status >= 200 && resp.status < 300) {
|
if (resp.status >= 200 && resp.status < 300 && before_node) {
|
||||||
var status = JSON.parse(resp.responseText);
|
var status = JSON.parse(resp.responseText);
|
||||||
status.__repost = repost;
|
status.__repost = repost;
|
||||||
var li = _this.getStatusDOMElement(status);
|
var li = _this.getStatusDOMElement(status);
|
||||||
|
@ -522,6 +522,7 @@ function(jQuery, Paths, URI, HostApp, Cache) {
|
||||||
|
|
||||||
if (confirm("Really delete this post?")) {
|
if (confirm("Really delete this post?")) {
|
||||||
var url = URI(Paths.mkApiRootPath("/posts/" + id));
|
var url = URI(Paths.mkApiRootPath("/posts/" + id));
|
||||||
|
|
||||||
Paths.getURL(url.toString(), "DELETE", callback);
|
Paths.getURL(url.toString(), "DELETE", callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -595,11 +596,15 @@ function(jQuery, Paths, URI, HostApp, Cache) {
|
||||||
var basic = profile["https://tent.io/types/info/basic/v0.1.0"];
|
var basic = profile["https://tent.io/types/info/basic/v0.1.0"];
|
||||||
|
|
||||||
if (profile && basic) {
|
if (profile && basic) {
|
||||||
if(basic.name) {
|
var name = mention.text;
|
||||||
|
if (basic.name) {
|
||||||
|
name = basic.name;
|
||||||
|
}
|
||||||
|
|
||||||
var new_text = node.innerHTML.replace(
|
var new_text = node.innerHTML.replace(
|
||||||
mention.text,
|
mention.text,
|
||||||
"<a href='" + mention.entity + "' class='name' title='" + mention.entity + "'>"
|
"<a href='" + mention.entity + "' class='name' title='" + mention.entity + "'>"
|
||||||
+ basic.name
|
+ name
|
||||||
+ "</a>"
|
+ "</a>"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -608,7 +613,7 @@ function(jQuery, Paths, URI, HostApp, Cache) {
|
||||||
HostApp.showProfileForEntity(e.target.title);
|
HostApp.showProfileForEntity(e.target.title);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,13 +25,13 @@ function(jQuery, HostApp, Hmac, Cache) {
|
||||||
|
|
||||||
Paths.getURL = function(url, http_method, callback, data, auth_header, accepts) {
|
Paths.getURL = function(url, http_method, callback, data, auth_header, accepts) {
|
||||||
|
|
||||||
accepts = accepts || "application/vnd.tent.v0+json";
|
if(accepts !== false) accepts = accepts || "application/vnd.tent.v0+json; charset=utf-8";
|
||||||
|
|
||||||
jQuery.ajax({
|
var options = {
|
||||||
|
|
||||||
beforeSend: function(xhr) {
|
beforeSend: function(xhr) {
|
||||||
|
|
||||||
xhr.setRequestHeader("Accept", accepts);
|
if(accepts !== false) xhr.setRequestHeader("Accept", accepts);
|
||||||
|
|
||||||
if (data) xhr.setRequestHeader("Content-Length", data.length);
|
if (data) xhr.setRequestHeader("Content-Length", data.length);
|
||||||
|
|
||||||
|
@ -64,7 +64,9 @@ function(jQuery, HostApp, Hmac, Cache) {
|
||||||
error: function(xhr, ajaxOptions, thrownError) {
|
error: function(xhr, ajaxOptions, thrownError) {
|
||||||
console.error("getURL (" + xhr.status + ")" + xhr.statusText + " " + http_method + " (" + url + "): '" + xhr.responseText + "'");
|
console.error("getURL (" + xhr.status + ")" + xhr.statusText + " " + http_method + " (" + url + "): '" + xhr.responseText + "'");
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
jQuery.ajax(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
Paths.postMultipart = function(url, callback, data, boundary, accepts) {
|
Paths.postMultipart = function(url, callback, data, boundary, accepts) {
|
||||||
|
@ -105,7 +107,6 @@ function(jQuery, HostApp, Hmac, Cache) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Paths.findProfileURL = function(entity, callback, errorCallback) {
|
Paths.findProfileURL = function(entity, callback, errorCallback) {
|
||||||
|
|
||||||
var profile_url = Paths.cache.profile_urls.getItem(entity);
|
var profile_url = Paths.cache.profile_urls.getItem(entity);
|
||||||
|
|
||||||
if (profile_url && profile_url != "null") {
|
if (profile_url && profile_url != "null") {
|
||||||
|
@ -133,9 +134,33 @@ function(jQuery, HostApp, Hmac, Cache) {
|
||||||
if (profile_url) {
|
if (profile_url) {
|
||||||
Paths.cache.profile_urls.setItem(entity, profile_url);
|
Paths.cache.profile_urls.setItem(entity, profile_url);
|
||||||
callback(profile_url);
|
callback(profile_url);
|
||||||
|
} else {
|
||||||
|
Paths.getURL(entity, "GET", function(resp) {
|
||||||
|
|
||||||
|
if (resp.status >= 200 && resp.status < 300) {
|
||||||
|
var div = document.createElement("div");
|
||||||
|
div.innerHTML = resp.responseText;
|
||||||
|
var links = $(div).find("link[rel='https://tent.io/rels/profile']");
|
||||||
|
|
||||||
|
if (links.length > 0) {
|
||||||
|
var href = links.get(0).href;
|
||||||
|
Paths.cache.profile_urls.setItem(entity, href);
|
||||||
|
if (!href.startsWith("http")) {
|
||||||
|
href = entity + "/profile";
|
||||||
|
}
|
||||||
|
callback(href);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if(errorCallback) errorCallback(entity + " has no profile URL");
|
if(errorCallback) errorCallback(entity + " has no profile URL");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if(errorCallback) errorCallback(entity + " has no profile URL");
|
||||||
|
}
|
||||||
|
|
||||||
|
}, null, false, false);
|
||||||
|
|
||||||
|
//if(errorCallback) errorCallback(entity + " has no profile URL");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(xhr, ajaxOptions, thrownError) {
|
error: function(xhr, ajaxOptions, thrownError) {
|
||||||
|
|
Reference in a new issue