Commit 86442372 authored by Aral Balkan's avatar Aral Balkan

Now showing person profile images next to messages. Also, message IDs are now...

Now showing person profile images next to messages. Also, message IDs are now written into the message as a comment and not displayed in the UI. Progress towards #62.
parent b209f4e6
......@@ -389,7 +389,7 @@ class MainInterfaceSplitViewController: NSSplitViewController
println("ℹ️ About to post the new person message. (\(self))\n")
// Create the message, persist it, and notify the timeline to show it.
let messageString = "<img src='\(SetupData.photoPath)'> <p>Hey everyone, <a href='indie://friend/\(SetupData.accountHandle!)'>\(SetupData.displayName!)</a> just joined Ind.ie!</p>"
let messageString = "<p>Hey everyone, <a href='indie://friend/\(SetupData.accountHandle!)'>\(SetupData.displayName!)</a> just joined Ind.ie!</p>"
let messageData = messageString.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)
let messageAttributedString = NSAttributedString(HTML: messageData!, baseURL: NSURL(string: "")!, documentAttributes: nil)!
......
......@@ -31,15 +31,17 @@ public class Message: NSObject
public var html:String
public var synced:Bool
public var messageType:String
public var personHandle:String
public var timelineID:String?
// NOTE: messageType is currently not used/persisted (maybe it should be?)… or removed. TODO
init(id:String, assetURLPrefix:String, folderURL:NSURL, html:String, synced:Bool=false, messageType:String=MessageType.named(.Regular))
init(id:String, assetURLPrefix:String, folderURL:NSURL, html:String, personHandle:String, synced:Bool=false, messageType:String=MessageType.named(.Regular))
{
self.id = id
self.assetURLPrefix = assetURLPrefix
self.folderURL = folderURL
self.html = html
self.personHandle = personHandle
self.synced = synced
self.messageType = messageType
}
......@@ -49,13 +51,13 @@ public class Message: NSObject
{
// Unless we explicitly specify the datatype, adding the timelineID causes a compile-time error.
// (I believe this is a bug.)
var dict:[String: AnyObject] = ["id": id, "assetURLPrefix": assetURLPrefix, "folderURL": folderURL.absoluteString!, "html": html, "synced": synced, "messageType": messageType]
var dict:[String: AnyObject] = ["id": id, "assetURLPrefix": assetURLPrefix, "folderURL": folderURL.absoluteString!, "html": html, "personHandle": personHandle, "synced": synced, "messageType": messageType]
if timelineID != nil
{
dict["timelineID"] = timelineID!
}
let jsonString = JSON(dict).rawString()
if let jsonString = jsonString
......
......@@ -166,8 +166,9 @@ class MessageSplitViewController: NSSplitViewController
//
// Create the message object and broadcast it.
// (An empty string person handle currently signal’s that’s us).
//
let message = Message(id: messageFileName, assetURLPrefix: assetURLPrefix, folderURL: fileURL, html: indexHTML as String, synced: false)
let message = Message(id: messageFileName, assetURLPrefix: assetURLPrefix, folderURL: fileURL, html: indexHTML as String, personHandle: "", synced: false)
message.timelineID = CurrentTimeline.id
//
......
......@@ -61,7 +61,8 @@ public class CurrentTimeline
public static func message(html:String, synced:Bool = false) -> Message
{
return Message(id: self.nextID(), assetURLPrefix: self.assetURLPrefix(), folderURL: self.folderURL()!, html: html, synced: synced)
println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
return Message(id: self.nextID(), assetURLPrefix: self.assetURLPrefix(), folderURL: self.folderURL()!, html: html, personHandle: SetupData.accountHandle!, synced: synced)
}
......
......@@ -321,7 +321,7 @@ class TimelineViewController: NSViewController, WKNavigationDelegate
//
println("Message ID: \(messageID)")
let fromPersonHandle:String = (messageID as NSString).firstMatchedGroupWithRegex(".+?Z-(.+?)$")
var fromPersonHandle:String = (messageID as NSString).firstMatchedGroupWithRegex(".+?Z-(.+?)$")
println("From person: \(fromPersonHandle).")
......@@ -358,10 +358,15 @@ class TimelineViewController: NSViewController, WKNavigationDelegate
println("Message HTML after: \(messageHTML)")
}
else
{
// The message is one of ours.
fromPersonHandle = ""
}
let fileURL:NSURL? = NSURL(fileURLWithPath: filePath, isDirectory: true)
let message = Message(id: messageID, assetURLPrefix: assetURLPrefix, folderURL: fileURL!, html: messageHTML as String, synced: false)
let message = Message(id: messageID, assetURLPrefix: assetURLPrefix, folderURL: fileURL!, html: messageHTML as String, personHandle: fromPersonHandle, synced: false)
post(MessageNotification.named(.ShowMessage), from: self, with: ["message": message])
}
......
......@@ -46,26 +46,27 @@
text-align: center;
}
.new-person-notification
.bodyText
{
margin-left: 96px;
}
.image-and-body
{
width: 100%;
break: both;
overflow: hidden;
margin-bottom: 6px;
}
.new-person-notification p img
.profileImage
{
width: 72px;
border-radius: 36px;
width: 56px;
border-radius: 28px;
float: left;
margin-right: 36px;
}
.new-person-notification p:nth-child(2)
{
padding-top: 26px;
}
</style>
</head>
<body>
......@@ -101,9 +102,12 @@
console.log("Updating the timeline…")
var messageBodyDiv = div();
messageBodyDiv.setAttribute('class', 'messageBody')
messageBodyDiv.setAttribute('id', message.id + '-body')
messageBodyDiv.innerHTML = '<p class="timestamp">' + message.id + '</p>' + message.html
messageBodyDiv.setAttribute('class', 'messageBody');
messageBodyDiv.setAttribute('id', message.id + '-body');
profileImageLinkComponent = (message.personHandle == '') ? 'to' : 'from/'+ message.personHandle;
messageBodyDiv.innerHTML = '<!-- ' + message.id + ' --><div class="image-and-body"><img class="profileImage" src="http://127.0.0.1:42003/all-friends/'+ profileImageLinkComponent +'/about/me.jpg"><div class="bodyText">' + message.html + '</div></div>';
var messageStatusDiv = div();
messageStatusDiv.setAttribute('class', 'messageStatus')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment