added profile view
This commit is contained in:
parent
0728d2e669
commit
fa62ef3629
12 changed files with 539 additions and 68 deletions
|
@ -23,6 +23,8 @@
|
|||
IBOutlet NSWindow *mentionsViewWindow;
|
||||
IBOutlet WebView *conversationView;
|
||||
IBOutlet NSWindow *conversationViewWindow;
|
||||
WebView *profileView;
|
||||
NSWindow *profileViewWindow;
|
||||
NSWindow *loginViewWindow;
|
||||
NSTextField *loginEntityTextField;
|
||||
NSProgressIndicator *loginActivityIndicator;
|
||||
|
@ -34,12 +36,15 @@
|
|||
|
||||
}
|
||||
|
||||
@property (retain, nonatomic) IBOutlet WebView *timelineView;
|
||||
@property (retain, nonatomic) IBOutlet NSWindow *timelineViewWindow;
|
||||
@property (retain, nonatomic) IBOutlet WebView *mentionsView;
|
||||
@property (retain, nonatomic) IBOutlet NSWindow *mentionsViewWindow;
|
||||
@property (retain, nonatomic) IBOutlet WebView *conversationView;
|
||||
@property (retain, nonatomic) IBOutlet NSWindow *conversationViewWindow;
|
||||
@property (assign) IBOutlet WebView *timelineView;
|
||||
@property (assign) IBOutlet NSWindow *timelineViewWindow;
|
||||
@property (assign) IBOutlet WebView *mentionsView;
|
||||
@property (assign) IBOutlet NSWindow *mentionsViewWindow;
|
||||
@property (assign) IBOutlet WebView *conversationView;
|
||||
@property (assign) IBOutlet NSWindow *conversationViewWindow;
|
||||
@property (assign) IBOutlet WebView *profileView;
|
||||
@property (assign) IBOutlet NSWindow *profileViewWindow;
|
||||
|
||||
@property (assign) IBOutlet NSWindow *loginViewWindow;
|
||||
@property (assign) IBOutlet NSTextField *loginEntityTextField;
|
||||
@property (assign) IBOutlet NSProgressIndicator *loginActivityIndicator;
|
||||
|
|
|
@ -15,8 +15,7 @@
|
|||
@synthesize loginViewWindow;
|
||||
@synthesize loginEntityTextField;
|
||||
@synthesize loginActivityIndicator;
|
||||
|
||||
@synthesize timelineView, timelineViewWindow, mentionsView, mentionsViewWindow, conversationView, conversationViewWindow;
|
||||
@synthesize timelineView, timelineViewWindow, mentionsView, mentionsViewWindow, conversationView, conversationViewWindow, profileView, profileViewWindow;
|
||||
@synthesize globalHotkeyMenuItem, viewDelegate;
|
||||
@synthesize logoLayer;
|
||||
@synthesize oauthView, accessToken;
|
||||
|
@ -136,12 +135,20 @@
|
|||
[conversationView setPolicyDelegate:viewDelegate];
|
||||
[conversationView setUIDelegate:viewDelegate];
|
||||
[[conversationView windowScriptObject] setValue:self forKey:@"controller"];
|
||||
|
||||
viewDelegate.profileView = profileView;
|
||||
[[profileView mainFrame] loadHTMLString:index_string baseURL:url];
|
||||
[profileView setFrameLoadDelegate:viewDelegate];
|
||||
[profileView setPolicyDelegate:viewDelegate];
|
||||
[profileView setUIDelegate:viewDelegate];
|
||||
[[profileView windowScriptObject] setValue:self forKey:@"controller"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[timelineView stringByEvaluatingJavaScriptFromString:@"start('timeline')"];
|
||||
[mentionsView stringByEvaluatingJavaScriptFromString:@"start('mentions')"];
|
||||
[conversationView stringByEvaluatingJavaScriptFromString:@"start('conversation')"];
|
||||
[profileView stringByEvaluatingJavaScriptFromString:@"start('profile')"];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -445,6 +452,13 @@
|
|||
[conversationViewWindow makeKeyAndOrderFront:self];
|
||||
}
|
||||
|
||||
- (IBAction)showProfileForEntity:(NSString *)entity
|
||||
{
|
||||
NSString *js = [NSString stringWithFormat:@"tentia_instance.showProfileForEntity('%@');", entity];
|
||||
[profileView stringByEvaluatingJavaScriptFromString:js];
|
||||
[profileViewWindow makeKeyAndOrderFront:self];
|
||||
}
|
||||
|
||||
- (void)growlNotificationWasClicked:(id)clickContext
|
||||
{
|
||||
NSDictionary *userInfo = (NSDictionary *)clickContext;
|
||||
|
|
|
@ -958,7 +958,7 @@
|
|||
<nil key="NSViewClass"/>
|
||||
<nil key="NSUserInterfaceItemIdentifier"/>
|
||||
<object class="NSView" key="NSWindowView" id="469460548">
|
||||
<nil key="NSNextResponder"/>
|
||||
<reference key="NSNextResponder"/>
|
||||
<int key="NSvFlags">256</int>
|
||||
<object class="NSMutableArray" key="NSSubviews">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
|
@ -988,6 +988,7 @@
|
|||
</object>
|
||||
<string key="NSFrameSize">{376, 581}</string>
|
||||
<reference key="NSSuperview" ref="469460548"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView"/>
|
||||
<string key="FrameName"/>
|
||||
<string key="GroupName"/>
|
||||
|
@ -997,11 +998,72 @@
|
|||
</object>
|
||||
</object>
|
||||
<string key="NSFrameSize">{376, 581}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="352293288"/>
|
||||
</object>
|
||||
<string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string>
|
||||
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
|
||||
<string key="NSFrameAutosaveName">conversations</string>
|
||||
<string key="NSFrameAutosaveName">conversation</string>
|
||||
<bool key="NSWindowIsRestorable">YES</bool>
|
||||
</object>
|
||||
<object class="NSWindowTemplate" id="1038715190">
|
||||
<int key="NSWindowStyleMask">15</int>
|
||||
<int key="NSWindowBacking">2</int>
|
||||
<string key="NSWindowRect">{{1292, 328}, {376, 581}}</string>
|
||||
<int key="NSWTFlags">1685586944</int>
|
||||
<string key="NSWindowTitle">Profile</string>
|
||||
<string key="NSWindowClass">NSWindow</string>
|
||||
<nil key="NSViewClass"/>
|
||||
<nil key="NSUserInterfaceItemIdentifier"/>
|
||||
<object class="NSView" key="NSWindowView" id="352860314">
|
||||
<reference key="NSNextResponder"/>
|
||||
<int key="NSvFlags">256</int>
|
||||
<object class="NSMutableArray" key="NSSubviews">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="WebView" id="106985301">
|
||||
<reference key="NSNextResponder" ref="352860314"/>
|
||||
<int key="NSvFlags">274</int>
|
||||
<object class="NSMutableSet" key="NSDragTypes">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="set.sortedObjects">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>Apple HTML pasteboard type</string>
|
||||
<string>Apple PDF pasteboard type</string>
|
||||
<string>Apple PICT pasteboard type</string>
|
||||
<string>Apple URL pasteboard type</string>
|
||||
<string>Apple Web Archive pasteboard type</string>
|
||||
<string>NSColor pasteboard type</string>
|
||||
<string>NSFilenamesPboardType</string>
|
||||
<string>NSStringPboardType</string>
|
||||
<string>NeXT RTFD pasteboard type</string>
|
||||
<string>NeXT Rich Text Format v1.0 pasteboard type</string>
|
||||
<string>NeXT TIFF v4.0 pasteboard type</string>
|
||||
<string>WebURLsWithTitlesPboardType</string>
|
||||
<string>public.png</string>
|
||||
<string>public.url</string>
|
||||
<string>public.url-name</string>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrameSize">{376, 581}</string>
|
||||
<reference key="NSSuperview" ref="352860314"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView"/>
|
||||
<string key="FrameName"/>
|
||||
<string key="GroupName"/>
|
||||
<reference key="Preferences" ref="561166140"/>
|
||||
<bool key="UseBackForwardList">NO</bool>
|
||||
<bool key="AllowsUndo">YES</bool>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrameSize">{376, 581}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="106985301"/>
|
||||
</object>
|
||||
<string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string>
|
||||
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
|
||||
<string key="NSFrameAutosaveName">profile</string>
|
||||
<bool key="NSWindowIsRestorable">YES</bool>
|
||||
</object>
|
||||
<object class="NSWindowTemplate" id="842998572">
|
||||
|
@ -1035,7 +1097,6 @@
|
|||
</object>
|
||||
<string key="NSFrame">{{20, 20}, {146, 146}}</string>
|
||||
<reference key="NSSuperview" ref="503676418"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="215157023"/>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSImageCell" key="NSCell" id="266676500">
|
||||
|
@ -1058,7 +1119,6 @@
|
|||
<int key="NSvFlags">268</int>
|
||||
<string key="NSFrame">{{194, 82}, {266, 22}}</string>
|
||||
<reference key="NSSuperview" ref="503676418"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="1063247419"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
|
@ -1105,7 +1165,6 @@
|
|||
<int key="NSvFlags">268</int>
|
||||
<string key="NSFrame">{{191, 112}, {163, 17}}</string>
|
||||
<reference key="NSSuperview" ref="503676418"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="643973685"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:1535</string>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
|
@ -1139,8 +1198,6 @@
|
|||
<int key="NSvFlags">268</int>
|
||||
<string key="NSFrame">{{391, 46}, {75, 32}}</string>
|
||||
<reference key="NSSuperview" ref="503676418"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSButtonCell" key="NSCell" id="54847478">
|
||||
|
@ -1164,7 +1221,6 @@
|
|||
<int key="NSvFlags">268</int>
|
||||
<string key="NSFrame">{{373, 55}, {16, 16}}</string>
|
||||
<reference key="NSSuperview" ref="503676418"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="251531186"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:945</string>
|
||||
<int key="NSpiFlags">28938</int>
|
||||
|
@ -1173,7 +1229,6 @@
|
|||
</object>
|
||||
<string key="NSFrameSize">{480, 186}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="433812480"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:20</string>
|
||||
</object>
|
||||
|
@ -1645,6 +1700,22 @@
|
|||
</object>
|
||||
<int key="connectionID">643</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">profileView</string>
|
||||
<reference key="source" ref="408500656"/>
|
||||
<reference key="destination" ref="106985301"/>
|
||||
</object>
|
||||
<int key="connectionID">662</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">profileViewWindow</string>
|
||||
<reference key="source" ref="408500656"/>
|
||||
<reference key="destination" ref="1038715190"/>
|
||||
</object>
|
||||
<int key="connectionID">663</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBActionConnection" key="connection">
|
||||
<string key="label">makeKeyAndOrderFront:</string>
|
||||
|
@ -1709,6 +1780,14 @@
|
|||
</object>
|
||||
<int key="connectionID">631</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">delegate</string>
|
||||
<reference key="source" ref="1038715190"/>
|
||||
<reference key="destination" ref="408500656"/>
|
||||
</object>
|
||||
<int key="connectionID">661</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<object class="NSArray" key="orderedObjects">
|
||||
|
@ -2413,7 +2492,7 @@
|
|||
<reference ref="469460548"/>
|
||||
</object>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">Mentions</string>
|
||||
<string key="objectName">Conversation</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">629</int>
|
||||
|
@ -2488,6 +2567,30 @@
|
|||
<reference key="object" ref="687127612"/>
|
||||
<reference key="parent" ref="730994513"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">658</int>
|
||||
<reference key="object" ref="1038715190"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="352860314"/>
|
||||
</object>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">Profile</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">659</int>
|
||||
<reference key="object" ref="352860314"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="106985301"/>
|
||||
</object>
|
||||
<reference key="parent" ref="1038715190"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">660</int>
|
||||
<reference key="object" ref="106985301"/>
|
||||
<reference key="parent" ref="352860314"/>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="flattenedProperties">
|
||||
|
@ -2606,6 +2709,11 @@
|
|||
<string>653.IBPluginDependency</string>
|
||||
<string>654.IBPluginDependency</string>
|
||||
<string>657.IBPluginDependency</string>
|
||||
<string>658.IBPluginDependency</string>
|
||||
<string>658.IBWindowTemplateEditedContentRect</string>
|
||||
<string>658.NSWindowTemplate.visibleAtLaunch</string>
|
||||
<string>659.IBPluginDependency</string>
|
||||
<string>660.IBPluginDependency</string>
|
||||
<string>72.IBPluginDependency</string>
|
||||
<string>73.IBPluginDependency</string>
|
||||
<string>79.IBPluginDependency</string>
|
||||
|
@ -2728,6 +2836,11 @@
|
|||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>{{344, 175}, {376, 581}}</string>
|
||||
<boolean value="NO"/>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.WebKitIBPlugin</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>
|
||||
|
@ -2747,7 +2860,7 @@
|
|||
<reference key="dict.values" ref="0"/>
|
||||
</object>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">657</int>
|
||||
<int key="maxID">663</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
|
@ -2800,6 +2913,8 @@
|
|||
<string>logoLayer</string>
|
||||
<string>mentionsView</string>
|
||||
<string>mentionsViewWindow</string>
|
||||
<string>profileView</string>
|
||||
<string>profileViewWindow</string>
|
||||
<string>timelineView</string>
|
||||
<string>timelineViewWindow</string>
|
||||
<string>viewDelegate</string>
|
||||
|
@ -2817,6 +2932,8 @@
|
|||
<string>NSWindow</string>
|
||||
<string>WebView</string>
|
||||
<string>NSWindow</string>
|
||||
<string>WebView</string>
|
||||
<string>NSWindow</string>
|
||||
<string>ViewDelegate</string>
|
||||
</object>
|
||||
</object>
|
||||
|
@ -2833,6 +2950,8 @@
|
|||
<string>logoLayer</string>
|
||||
<string>mentionsView</string>
|
||||
<string>mentionsViewWindow</string>
|
||||
<string>profileView</string>
|
||||
<string>profileViewWindow</string>
|
||||
<string>timelineView</string>
|
||||
<string>timelineViewWindow</string>
|
||||
<string>viewDelegate</string>
|
||||
|
@ -2875,6 +2994,14 @@
|
|||
<string key="name">mentionsViewWindow</string>
|
||||
<string key="candidateClassName">NSWindow</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo">
|
||||
<string key="name">profileView</string>
|
||||
<string key="candidateClassName">WebView</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo">
|
||||
<string key="name">profileViewWindow</string>
|
||||
<string key="candidateClassName">NSWindow</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo">
|
||||
<string key="name">timelineView</string>
|
||||
<string key="candidateClassName">WebView</string>
|
||||
|
|
|
@ -14,12 +14,14 @@
|
|||
WebView *timelineView;
|
||||
WebView *mentionsView;
|
||||
WebView *conversationView;
|
||||
WebView *profileView;
|
||||
WebView *oauthView;
|
||||
}
|
||||
|
||||
@property (nonatomic, assign) WebView *timelineView;
|
||||
@property (nonatomic, assign) WebView *mentionsView;
|
||||
@property (nonatomic, assign) WebView *conversationView;
|
||||
@property (nonatomic, assign) WebView *profileView;
|
||||
@property (nonatomic, assign) WebView *oauthView;
|
||||
|
||||
@end
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
@implementation ViewDelegate
|
||||
|
||||
@synthesize timelineView, mentionsView, conversationView, oauthView;
|
||||
@synthesize timelineView, mentionsView, conversationView, profileView, oauthView;
|
||||
|
||||
- (void)webView:(WebView *)sender addMessageToConsole:(NSDictionary *)message;{
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
|||
if (sender == mentionsView) viewName = @"MentionsView";
|
||||
if (sender == conversationView) viewName = @"ConversationView";
|
||||
if (sender == oauthView) viewName = @"OauthView";
|
||||
if (sender == profileView) viewName = @"ProfileView";
|
||||
|
||||
NSLog(@"js<%@>: %@:%@: %@",
|
||||
viewName,
|
||||
|
@ -80,6 +81,10 @@
|
|||
|
||||
[conversationView stringByEvaluatingJavaScriptFromString:@"function HostAppGo() { start('conversation') }"];
|
||||
|
||||
} else if(sender == profileView) {
|
||||
|
||||
[profileView stringByEvaluatingJavaScriptFromString:@"function HostAppGo() { start('profile') }"];
|
||||
|
||||
} else {
|
||||
|
||||
NSString *action = @"timeline";
|
||||
|
|
|
@ -20,7 +20,7 @@ ol {
|
|||
padding: 0;
|
||||
}
|
||||
|
||||
li, .error {
|
||||
ol li, .error, header.profile {
|
||||
clear: both;
|
||||
padding: 8px;
|
||||
background: #eee;
|
||||
|
@ -37,23 +37,23 @@ li, .error {
|
|||
color: red;
|
||||
}
|
||||
|
||||
li:first-child {
|
||||
ol li:first-child {
|
||||
border-top: 0;
|
||||
}
|
||||
|
||||
li:nth-child(odd), .error {
|
||||
ol li:nth-child(odd), .error, header.profile {
|
||||
background: url(../img/odd-bg.png) repeat-x bottom #fafafa;
|
||||
}
|
||||
|
||||
li:nth-child(even) {
|
||||
ol li:nth-child(even) {
|
||||
background: url(../img/even-bg.png) repeat-x bottom #f2f2f2;
|
||||
}
|
||||
|
||||
li:hover {
|
||||
ol li:hover {
|
||||
background: #dedede;
|
||||
}
|
||||
|
||||
li:after {
|
||||
ol li:after, header.profile:after {
|
||||
content: ".";
|
||||
display: block;
|
||||
clear: both;
|
||||
|
@ -62,6 +62,28 @@ li:after {
|
|||
height: 0;
|
||||
}
|
||||
|
||||
header.profile img {
|
||||
float: left;
|
||||
margin: 0 10px 10px 0;
|
||||
max-width: 100px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
header.profile table {
|
||||
border-collapse: collapse;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
header.profile th {
|
||||
text-align: left;
|
||||
padding-right: 1em;
|
||||
}
|
||||
|
||||
header.profile h1 + p {
|
||||
color: #aaa;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.highlight {
|
||||
border-right: 5px solid #f17779;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ define([
|
|||
"lib/URI"
|
||||
],
|
||||
|
||||
function(HostApp, Core, Paths, URI, Followings) {
|
||||
function(HostApp, Core, Paths, URI) {
|
||||
|
||||
|
||||
function Conversation() {
|
||||
|
|
270
WebKit/scripts/controller/Profile.js
Normal file
270
WebKit/scripts/controller/Profile.js
Normal file
|
@ -0,0 +1,270 @@
|
|||
define([
|
||||
"helper/HostApp",
|
||||
"helper/Core",
|
||||
"helper/Paths",
|
||||
"lib/URI"
|
||||
],
|
||||
|
||||
function(HostApp, Core, Paths, URI) {
|
||||
|
||||
|
||||
function Profile() {
|
||||
|
||||
Core.call(this);
|
||||
|
||||
this.action = "profile";
|
||||
|
||||
this.initProfileTemplate();
|
||||
}
|
||||
|
||||
Profile.prototype = Object.create(Core.prototype);
|
||||
|
||||
Profile.prototype.showProfileForEntity = function(entity) {
|
||||
|
||||
this.clear();
|
||||
this.entity = entity;
|
||||
this.profile_template.entity.innerHTML = entity;
|
||||
this.profile_template.entity.href = entity;
|
||||
this.getProfile();
|
||||
}
|
||||
|
||||
Profile.prototype.initProfileTemplate = function() {
|
||||
|
||||
var header = document.createElement("header");
|
||||
header.className = "profile"
|
||||
document.body.appendChild(header);
|
||||
|
||||
this.profile_template = {
|
||||
avatar: document.createElement("img"),
|
||||
name: document.createElement("h1"),
|
||||
entity: document.createElement("a"),
|
||||
bio: document.createElement("p"),
|
||||
posts: document.createElement("td"),
|
||||
following: document.createElement("td"),
|
||||
followed: document.createElement("td"),
|
||||
birthdate: document.createElement("td"),
|
||||
location: document.createElement("td"),
|
||||
gender: document.createElement("td"),
|
||||
url: document.createElement("a")
|
||||
};
|
||||
|
||||
header.appendChild(this.profile_template.avatar);
|
||||
this.profile_template.avatar.src = "img/default-avatar.png";
|
||||
var div = document.createElement("div");
|
||||
header.appendChild(div);
|
||||
|
||||
div.appendChild(this.profile_template.name);
|
||||
|
||||
var p = document.createElement("p");
|
||||
p.appendChild(this.profile_template.entity);
|
||||
div.appendChild(p);
|
||||
|
||||
div.appendChild(this.profile_template.bio);
|
||||
|
||||
var table = document.createElement("table");
|
||||
div.appendChild(table);
|
||||
|
||||
function mkLi(name, template) {
|
||||
var tr = document.createElement("tr");
|
||||
var th = document.createElement("th");
|
||||
tr.style.display = "none";
|
||||
th.innerText = name + ": ";
|
||||
tr.appendChild(th);
|
||||
tr.appendChild(template);
|
||||
table.appendChild(tr);
|
||||
}
|
||||
|
||||
mkLi("Birth date", this.profile_template.birthdate);
|
||||
mkLi("Location", this.profile_template.location);
|
||||
mkLi("Gender", this.profile_template.gender);
|
||||
|
||||
var td = document.createElement("td");
|
||||
td.appendChild(this.profile_template.url);
|
||||
mkLi("Homepage", td);
|
||||
|
||||
mkLi("Posts", this.profile_template.posts);
|
||||
mkLi("Following", this.profile_template.following);
|
||||
mkLi("Followed by", this.profile_template.followed);
|
||||
|
||||
|
||||
this.body = document.createElement("ol");
|
||||
this.body.className = this.action;
|
||||
document.body.appendChild(this.body);
|
||||
}
|
||||
|
||||
Profile.prototype.clear = function() {
|
||||
|
||||
this.profile_template.avatar.src = "img/default-avatar.png";
|
||||
|
||||
this.profile_template.name.innerText = "";
|
||||
this.profile_template.entity.innerText = "";
|
||||
this.profile_template.bio.innerText = "";
|
||||
this.profile_template.posts.innerText = "";
|
||||
this.profile_template.following.innerText = "";
|
||||
this.profile_template.followed.innerText = "";
|
||||
this.profile_template.birthdate.innerText = "";
|
||||
this.profile_template.location.innerText = "";
|
||||
this.profile_template.gender.innerText = "";
|
||||
this.profile_template.url.innerText = "";
|
||||
this.profile_template.url.href = "";
|
||||
|
||||
this.profile_template.posts.parentNode.style.display = "none";
|
||||
this.profile_template.following.parentNode.style.display = "none";
|
||||
this.profile_template.followed.parentNode.style.display = "none";
|
||||
this.profile_template.birthdate.parentNode.style.display = "none";
|
||||
this.profile_template.location.parentNode.style.display = "none";
|
||||
this.profile_template.gender.parentNode.style.display = "none";
|
||||
this.profile_template.url.parentNode.parentNode.style.display = "none";
|
||||
|
||||
this.body.innerHTML = "";
|
||||
};
|
||||
|
||||
Profile.prototype.getProfile = function() {
|
||||
|
||||
var _this = this;
|
||||
|
||||
Paths.findProfileURL(this.entity, function(profile_url) {
|
||||
|
||||
if (profile_url) {
|
||||
|
||||
Paths.getURL(profile_url, "GET", function(resp) {
|
||||
|
||||
_this.showProfile(JSON.parse(resp.responseText));
|
||||
|
||||
}, null, false); // do not send auth-headers
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Profile.prototype.showProfile = function(profile) {
|
||||
|
||||
var basic = profile["https://tent.io/types/info/basic/v0.1.0"];
|
||||
|
||||
if (profile && basic) {
|
||||
|
||||
if(basic.avatar_url) {
|
||||
this.profile_template.avatar.onerror = function() { this.profile_template.avatar.src = 'img/default-avatar.png' };
|
||||
this.profile_template.avatar.src = basic.avatar_url;
|
||||
}
|
||||
|
||||
this.populate(this.profile_template.name, basic.name);
|
||||
this.populate(this.profile_template.birthdate, basic.birthdate);
|
||||
this.populate(this.profile_template.location, basic.location);
|
||||
this.populate(this.profile_template.gender, basic.gender);
|
||||
this.populate(this.profile_template.bio, basic.bio);
|
||||
|
||||
if(basic.url) {
|
||||
|
||||
var url = basic.url;
|
||||
this.profile_template.url.innerText = url;
|
||||
this.profile_template.url.parentNode.parentNode.style.display = "";
|
||||
|
||||
if (!url.startsWith("http")) {
|
||||
url = "http://" + url;
|
||||
}
|
||||
|
||||
this.profile_template.url.href = url;
|
||||
}
|
||||
}
|
||||
|
||||
if (profile) {
|
||||
var server = profile["https://tent.io/types/info/core/v0.1.0"]["servers"][0];
|
||||
this.getMeta(server);
|
||||
this.getStatuses(server);
|
||||
}
|
||||
}
|
||||
|
||||
Profile.prototype.populate = function(t, v) {
|
||||
if (v) {
|
||||
t.innerText = v;
|
||||
t.parentNode.style.display = "";
|
||||
}
|
||||
}
|
||||
|
||||
Profile.prototype.getMeta = function(root_url) {
|
||||
|
||||
var _this = this;
|
||||
Paths.getURL(URI(root_url + "/followings/count").toString(), "GET", function(resp) {
|
||||
|
||||
_this.populate(_this.profile_template.following, resp.responseText);
|
||||
}, null, false);
|
||||
|
||||
Paths.getURL(URI(root_url + "/followers/count").toString(), "GET", function(resp) {
|
||||
|
||||
_this.populate(_this.profile_template.followed, resp.responseText);
|
||||
}, null, false);
|
||||
|
||||
Paths.getURL(URI(root_url + "/posts/count").toString(), "GET", function(resp) {
|
||||
|
||||
_this.populate(_this.profile_template.posts, resp.responseText);
|
||||
}, null, false);
|
||||
}
|
||||
|
||||
|
||||
Profile.prototype.getStatuses = function(root_url) {
|
||||
var _this = this;
|
||||
|
||||
var url = URI(root_url + "/posts");
|
||||
url.addSearch("limit", 20);
|
||||
|
||||
var post_types = [
|
||||
"https://tent.io/types/post/repost/v0.1.0",
|
||||
"https://tent.io/types/post/status/v0.1.0",
|
||||
"https://tent.io/types/post/delete/v0.1.0",
|
||||
//"https://tent.io/types/post/photo/v0.1.0"
|
||||
];
|
||||
url.addSearch("post_types", post_types.join(","));
|
||||
|
||||
Paths.getURL(url.toString(), "GET", function(resp) {
|
||||
|
||||
var statuses = JSON.parse(resp.responseText);
|
||||
|
||||
_this.newStatus(statuses);
|
||||
|
||||
}, null, false);
|
||||
}
|
||||
|
||||
Profile.prototype.newStatus = function(statuses) {
|
||||
if(statuses != null && statuses.length > 0) {
|
||||
for(var i = statuses.length-1, c=0; i>=c; --i) {
|
||||
|
||||
var status = statuses[i];
|
||||
this.since_id = status.id;
|
||||
this.since_id_entity = status.entity;
|
||||
|
||||
if (status.type == "https://tent.io/types/post/status/v0.1.0" || status.type == "https://tent.io/types/post/photo/v0.1.0") {
|
||||
|
||||
var new_node = this.getStatusDOMElement(status);
|
||||
|
||||
if(this.body.childNodes.length > 0) {
|
||||
|
||||
if(this.body.childNodes.length > this.max_length) {
|
||||
|
||||
this.body.removeChild(this.body.lastChild);
|
||||
}
|
||||
|
||||
this.body.insertBefore(new_node, this.body.firstChild);
|
||||
|
||||
} else {
|
||||
|
||||
this.body.appendChild(new_node);
|
||||
}
|
||||
|
||||
} else if (status.type == "https://tent.io/types/post/delete/v0.1.0") {
|
||||
|
||||
var li = document.getElementById("post-" + status.content.id);
|
||||
if (li) {
|
||||
this.body.removeChild(li);
|
||||
}
|
||||
} else if (status.type == "https://tent.io/types/post/repost/v0.1.0") {
|
||||
|
||||
this.getRepost(status, this.body.firstChild);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Profile;
|
||||
|
||||
});
|
|
@ -86,7 +86,7 @@ function(Core, Paths, HostApp, URI) {
|
|||
"https://tent.io/types/post/repost/v0.1.0",
|
||||
"https://tent.io/types/post/status/v0.1.0",
|
||||
"https://tent.io/types/post/delete/v0.1.0",
|
||||
"https://tent.io/types/post/photo/v0.1.0"
|
||||
//"https://tent.io/types/post/photo/v0.1.0"
|
||||
];
|
||||
url.addSearch("post_types", post_types.join(","));
|
||||
|
||||
|
@ -125,30 +125,6 @@ function(Core, Paths, HostApp, URI) {
|
|||
}
|
||||
}
|
||||
|
||||
Timeline.prototype.getRepost = function(repost, before_node) {
|
||||
|
||||
var _this = this;
|
||||
var callback = function(resp) {
|
||||
var status = JSON.parse(resp.responseText);
|
||||
status.__repost = repost;
|
||||
var li = _this.getStatusDOMElement(status);
|
||||
before_node.parentNode.insertBefore(li, before_node);
|
||||
}
|
||||
|
||||
Paths.findProfileURL(repost.content.entity, function(profile_url) {
|
||||
if (profile_url) {
|
||||
|
||||
Paths.getURL(profile_url, "GET", function(resp) {
|
||||
|
||||
var profile = JSON.parse(resp.responseText);
|
||||
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);
|
||||
|
||||
}, null, false); // do not send auth-headers
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Timeline.prototype.sendNewMessage = function(content, in_reply_to_status_id, in_reply_to_entity, location, image_data_uri) {
|
||||
var _this = this;
|
||||
var callback = function(data) { _this.getNewData(); }
|
||||
|
|
|
@ -177,7 +177,6 @@ function(jQuery, Paths, URI, HostApp, Followings) {
|
|||
return false;
|
||||
}
|
||||
|
||||
//template.retweet.onclick = function() { template.retweet.className = "hidden"; _this.retweet(status.id_str, template.item); return false; }
|
||||
template.repost.onclick = function() {
|
||||
template.repost.className = "hidden";
|
||||
_this.repost(status.id, status.entity);
|
||||
|
@ -186,6 +185,10 @@ function(jQuery, Paths, URI, HostApp, Followings) {
|
|||
|
||||
template.username.innerText = status.entity;
|
||||
template.username.href = status.entity; // FIXME open profile
|
||||
template.username.onclick = function() {
|
||||
HostApp.showProfileForEntity(status.entity);
|
||||
return false;
|
||||
}
|
||||
|
||||
var profile = function(profile) {
|
||||
|
||||
|
@ -258,8 +261,10 @@ function(jQuery, Paths, URI, HostApp, Followings) {
|
|||
if (status.type == "https://tent.io/types/post/photo/v0.1.0") {
|
||||
text = status.content.caption;
|
||||
} else {
|
||||
if (status.content && status.content.text) {
|
||||
text = status.content.text;
|
||||
}
|
||||
}
|
||||
|
||||
text = text.escapeHTML().replace(/\n/g, "<br>");
|
||||
|
||||
|
@ -336,6 +341,31 @@ function(jQuery, Paths, URI, HostApp, Followings) {
|
|||
return template.item;
|
||||
}
|
||||
|
||||
|
||||
Core.prototype.getRepost = function(repost, before_node) {
|
||||
|
||||
var _this = this;
|
||||
var callback = function(resp) {
|
||||
var status = JSON.parse(resp.responseText);
|
||||
status.__repost = repost;
|
||||
var li = _this.getStatusDOMElement(status);
|
||||
before_node.parentNode.insertBefore(li, before_node);
|
||||
}
|
||||
|
||||
Paths.findProfileURL(repost.content.entity, function(profile_url) {
|
||||
if (profile_url) {
|
||||
|
||||
Paths.getURL(profile_url, "GET", function(resp) {
|
||||
|
||||
var profile = JSON.parse(resp.responseText);
|
||||
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);
|
||||
|
||||
}, null, false); // do not send auth-headers
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Core.prototype.sendNewMessage = function(content, in_reply_to_status_id, in_reply_to_entity, location, image_file_path, callback) {
|
||||
|
||||
if (image_file_path) {
|
||||
|
@ -528,11 +558,16 @@ function(jQuery, Paths, URI, HostApp, Followings) {
|
|||
if(basic.name) {
|
||||
var new_text = node.innerHTML.replace(
|
||||
mention.text,
|
||||
"<strong class='name' title='" + mention.entity + "'" + ">"
|
||||
"<a href='" + mention.entity + "' class='name' title='" + mention.entity + "'>"
|
||||
+ basic.name
|
||||
+ "</strong>"
|
||||
+ "</a>"
|
||||
);
|
||||
|
||||
node.innerHTML = new_text;
|
||||
$(node).find("a.name").click(function(e) {
|
||||
HostApp.showProfileForEntity(e.target.href);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,6 +87,15 @@ define(function() {
|
|||
}
|
||||
}
|
||||
|
||||
HostApp.showProfileForEntity = function(entity) {
|
||||
|
||||
if (OS_TYPE == "mac") {
|
||||
controller.showProfileForEntity_(entity);
|
||||
} else {
|
||||
controller.showProfileForEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
HostApp.notificateUserAboutMention = function(text, name, post_id, entity) {
|
||||
if (OS_TYPE == "mac") {
|
||||
controller.notificateUserAboutMention_fromName_withPostId_andEntity_(text, name, post_id, entity);
|
||||
|
|
|
@ -33,6 +33,12 @@ function start(view) {
|
|||
|
||||
} else if (view == "profile") {
|
||||
|
||||
require(["controller/Profile"], function(Profile) {
|
||||
|
||||
tentia_instance = new Profile();
|
||||
|
||||
});
|
||||
|
||||
} else if (view == "follow") {
|
||||
|
||||
} else if (view == "conversation") {
|
||||
|
@ -55,17 +61,17 @@ String.prototype.endsWith = function(suffix) {
|
|||
return this.match(suffix+"$") == suffix;
|
||||
};
|
||||
|
||||
var __entityMap = {
|
||||
var __entityMap = {
|
||||
"&": "&",
|
||||
"<": "<",
|
||||
">": ">"
|
||||
};
|
||||
};
|
||||
|
||||
String.prototype.escapeHTML = function() {
|
||||
String.prototype.escapeHTML = function() {
|
||||
return String(this).replace(/[&<>]/g, function (s) {
|
||||
return __entityMap[s];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var console = {
|
||||
log: function(s) {
|
||||
|
|
Reference in a new issue