Now using full message ID in the person sublevel so that we can reuse the...

Now using full message ID in the person sublevel so that we can reuse the formatters, etc. (for consistency).
parent ecf5fc1b
......@@ -72,7 +72,7 @@ class PublicTimelineWeaver
# Store the messages by person also so we can quickly stream them on their own pages.
personMessagesSublevel = @db.sublevel "#{accountHandle}-messages"
personMessagesSublevel.put timestamp, message
personMessagesSublevel.put messageID, message
#
# Everyone timeline
......
......@@ -71,11 +71,11 @@ module.exports = (app) ->
# Permanent link formatter
permanentLinkFormatter = (messageID) ->
# Get the person handle
personHandleDelimeter = messageID.lastIndexOf('Z-')
personHandle = messageID.substr(personHandleDelimeter+2)
# Get the person handle
personHandleDelimeter = messageID.lastIndexOf('Z-')
personHandle = messageID.substr(personHandleDelimeter+2)
return "/person/#{personHandle}/post/#{messageID}"
return "/person/#{personHandle}/post/#{messageID}"
# Format the post date
......@@ -96,56 +96,6 @@ module.exports = (app) ->
# This should never happen and probably shows that some sort of corrupted ID got through somehow.
return (new Date())
# Format the person’s name
personFormatter = (messageID) ->
personHandleDelimeter = messageID.lastIndexOf('Z-')
profileImagePath = ''
if personHandleDelimeter != -1
# From someone else
personHandle = messageID.substr(personHandleDelimeter+2)
# TODO: Once public profile pages are implemented, link to them.
return " by #{personHandle}."
else
# This is the person themselves.
# TODO: Once the timestamps are in there, just return that.
return ''
addFriendLinkFormatter = (messageID) ->
personHandleDelimeter = messageID.lastIndexOf('Z-')
profileImagePath = ''
if personHandleDelimeter != -1
# From someone else
personHandle = messageID.substr(personHandleDelimeter+2)
addFriendLink = "indie://friend/#{personHandle}"
return addFriendLink
else
# This is the person themselves, no need to display a friend link.
return ''
addFriendTextFormatter = (messageID) ->
personHandleDelimeter = messageID.lastIndexOf('Z-')
profileImagePath = ''
if personHandleDelimeter != -1
return "<img class='add-friend-icon' src='/images/person_add@2x.png' alt='Send friend request'>"
else
# This is the person themselves, no need to display a friend link.
return ''
# Custom formatter for the profile image
profileImagePathFormatter = (messageID) ->
personHandle = messageID.substr(messageID.lastIndexOf('Z-')+2)
# console.log "Person handle for message: #{personHandle}"
profileImagePath = "/public/#{personHandle}/about/me.jpg"
return profileImagePath
#
# Read the person details
#
......@@ -171,4 +121,4 @@ module.exports = (app) ->
(new PublicTimelineWeaver).getTimeline("#{accountHandle}-messages").then (messages) ->
# Reverse the message order to match that of the Cocoa client.
response.render 'person', {indieFriendURL: indieFriendURL, profileImageURL: profileImageURL, profile: profile, messages: messages, __set: { formatters: {messageBodyIDFormatter: messageBodyIDFormatter, messageStatusIDFormatter: messageStatusIDFormatter, profileImagePathFormatter: profileImagePathFormatter, personFormatter:personFormatter, addFriendLinkFormatter: addFriendLinkFormatter, addFriendTextFormatter:addFriendTextFormatter, postDateFormatter:postDateFormatter, timestampFormatter: timestampFormatter, permanentLinkFormatter: permanentLinkFormatter}}}
\ No newline at end of file
response.render 'person', {accountHandle, accountHandle, indieFriendURL: indieFriendURL, profileImageURL: profileImageURL, profile: profile, messages: messages, __set: { formatters: {messageBodyIDFormatter: messageBodyIDFormatter, messageStatusIDFormatter: messageStatusIDFormatter, postDateFormatter:postDateFormatter, timestampFormatter: timestampFormatter, permanentLinkFormatter: permanentLinkFormatter}}}
\ No newline at end of file
......@@ -37,11 +37,17 @@ function getOlderMessages(){
return;
}
var accountHandleDelimeter = oldestPostID.lastIndexOf('Z-');
accountHandle = oldestPostID.substr(accountHandleDelimeter+2);
console.log('Getting posts before ' + oldestPostID);
url = 'http://192.168.59.103:3000/posts-before/' + oldestPostID + '/for/' + accountHandle + '-messages';
console.log('URL: ' + url);
superagent
// .get('https://waystone.ind.ie/posts-before/'+oldestPostID)
.get('http://192.168.59.103:3000/posts-before/'+oldestPostID+'/for/aral-messages')
.get(url)
// .get('//' + set.meta.waystoneURL +'/posts-before/'+oldestPostID)
.end(function(error, posts) {
......@@ -276,13 +282,16 @@ window.addEventListener('load', function(){
var messages = document.getElementById('messages');
var newestPostID = messages.firstElementChild.getAttribute('id');
var accountHandleDelimeter = newestPostID.lastIndexOf('Z-');
accountHandle = newestPostID.substr(accountHandleDelimeter+2);
// console.log('Getting post after ' + newestPostID)
// TODO: Do not hard code this URL.
// TODO: Fix Set injectData so we don’t have to use this metadata injection workaround.
superagent
// .get('https://waystone.ind.ie/posts-after/'+newestPostID)
.get('http://192.168.59.103:3000/posts-after/'+newestPostID+'/for/aral-messages')
.get('http://192.168.59.103:3000/posts-after/' + newestPostID + '/for/' + accountHandle + '-messages')
// .get('//' + set.meta.waystoneURL +'/posts-after/'+newestPostID)
.end(function(error, posts) {
//
......
......@@ -27,9 +27,8 @@
padding-right:5px;
}
</style>
</head>
<body>
<body data-set-attribute='data-accountHandle accountHandle'>
<header>
<img id="profile-image" data-set-attribute='src profileImageURL'>
<h1 id='name'><span data-set-text='profile.displayName'></span><a href='/'><img id='indieHopeBalloonLogo' src='/images/indie-hope-balloon-logo.png'></a></h1>
......@@ -43,7 +42,6 @@
<div class='messageBody' data-set-attribute='id message.key messageBodyIDFormatter'>
<!-- <p class="timestamp" data-set-text='message.key'>Message timestamp</p> -->
<div class="image-and-body">
<!-- <img class="profileImage" data-set-attribute='src message.key profileImagePathFormatter'> -->
<div class="bodyText" data-set-text='html message.value'>Message body HTML</div>
<div class="meta"><a data-set-attribute='href message.key permanentLinkFormatter'><span class='postDate' data-set-attribute='data-timestamp message.key timestampFormatter' data-set-text='message.key postDateFormatter'></span></a></div>
</div>
......
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