Changed the permalink URL structure to remove redundancy (person handle was being repeated).

parent 24b08ecd
......@@ -75,7 +75,9 @@ module.exports = (app) ->
personHandleDelimeter = messageID.lastIndexOf('Z-')
personHandle = messageID.substr(personHandleDelimeter+2)
return "/person/#{personHandle}/post/#{messageID}"
messageIDWithoutThePersonHandle = messageID.substr(0, personHandleDelimeter+1)
return "/person/#{personHandle}/post/#{messageIDWithoutThePersonHandle}"
# Format the post date
......
......@@ -95,6 +95,11 @@ module.exports = (app) ->
messageID = request.param 'messageID'
accountHandle = request.param 'accountHandle'
# Massage the message ID from links that do not have the account handle suffix
# (which is how we are going to use them to remove redundancy in the URLs) to add it.
if messageID.indexOf "-#{accountHandle}" == -1
messageID = "#{messageID}-#{accountHandle}"
console.log "Account handle: #{accountHandle}"
mainFolderForPerson = (new TeleportationAPI).folderForHandle(accountHandle)
......
......@@ -70,7 +70,9 @@ module.exports = (app) ->
personHandleDelimeter = messageID.lastIndexOf('Z-')
personHandle = messageID.substr(personHandleDelimeter+2)
return "/person/#{personHandle}/post/#{messageID}"
messageIDWithoutThePersonHandle = messageID.substr(0, personHandleDelimeter+1)
return "/person/#{personHandle}/post/#{messageIDWithoutThePersonHandle}"
# Format the post date
......
......@@ -225,7 +225,8 @@ function getOlderMessages(){
var personHandleDelimeter = messageID.lastIndexOf('Z-');
var personHandle = messageID.substr(personHandleDelimeter+2);
return '/person/' + personHandle + '/post/' + messageID
var messageIDWithoutThePersonHandle = messageID.substr(0, personHandleDelimeter+1);
return '/person/' + personHandle + '/post/' + messageIDWithoutThePersonHandle
}
// Update the repeater node
......@@ -412,7 +413,8 @@ window.addEventListener('load', function(){
var personHandleDelimeter = messageID.lastIndexOf('Z-');
personHandle = messageID.substr(personHandleDelimeter+2);
return '/person/' + personHandle + '/post/' + messageID
var messageIDWithoutThePersonHandle = messageID.substr(0, personHandleDelimeter+1);
return '/person/' + personHandle + '/post/' + messageIDWithoutThePersonHandle
}
// Format the person’s name
......
......@@ -219,7 +219,8 @@ function getOlderMessages(){
var personHandleDelimeter = messageID.lastIndexOf('Z-');
var personHandle = messageID.substr(personHandleDelimeter+2);
return '/person/' + personHandle + '/post/' + messageID
var messageIDWithoutThePersonHandle = messageID.substr(0, personHandleDelimeter+1);
return '/person/' + personHandle + '/post/' + messageIDWithoutThePersonHandle
}
// Update the repeater node
......@@ -450,6 +451,18 @@ window.addEventListener('load', function(){
// }
}
// Permanent link formatter
set.format['permanentLinkFormatter'] = function (messageID) {
// Get the person handle
var personHandleDelimeter = messageID.lastIndexOf('Z-');
var personHandle = messageID.substr(personHandleDelimeter+2);
var messageIDWithoutThePersonHandle = messageID.substr(0, personHandleDelimeter+1);
return '/person/' + personHandle + '/post/' + messageIDWithoutThePersonHandle
}
// Update the repeater node
set(repeaterNode, {messages: posts})
});
......
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