Kurkistan he/him Posted September 29, 2016 Report Share Posted September 29, 2016 It looks like in the transition from the old site to the new the way that individual-post links within threads are formatted has changed. Before, if I wanted to link to a post about Peter confirming Hoid drinking metal, I'd get this:http://www.17thshard.com/forum/topic/6411-hoids-powers-from-around-the-cosmere/#entry104532 Now the link to that post is this:http://www.17thshard.com/forum/topic/6411-hoids-powers-from-around-the-cosmere/#comment-104532 Clicking on that first link will bring you to the thread, while the second will properly bring you to the specific post. Obviously the numbers are the same, so would it be possible to do some parsing here and convert "entryX" URLs into "comment-X" URLs when people navigate to them? As is there are a fair number of old links/bookmarks that aren't very helpful because they go to threads rather than posts. 2 Quote Link to comment Share on other sites More sharing options...
Chaos he/him Posted September 30, 2016 Report Share Posted September 30, 2016 I don't know if this is possible... 0 Quote Link to comment Share on other sites More sharing options...
Kurkistan he/him Posted September 30, 2016 Author Report Share Posted September 30, 2016 (edited) I believe there's a way to do it more intelligently than just with JavaScript (the existence of this massive MSDN page suggests as much, though I haven't read through it), but if you execute this JS code then it works. if (window.location.hash && window.location.hash.slice(1,6) === "entry") { window.location.hash = "comment-" + window.location.hash.slice(6); } EDIT: There's obviously some level of link parsing (though on reflection this is more of query-resolving) already being done by IPB, or else the links in emails wouldn't work. When I clicked on the email alert for your post, I got this link: http://www.17thshard.com/forum/topic/56107-request-mapping-from-old-single-post-links-to-new-format/?do=findComment&comment=491781 That gets parsed into the appropriate: http://www.17thshard.com/forum/topic/56107-request-mapping-from-old-single-post-links-to-new-format/#comment-491781 Edited September 30, 2016 by Kurkistan 0 Quote Link to comment Share on other sites More sharing options...
Eki Posted October 2, 2016 Report Share Posted October 2, 2016 On 2016-09-30 at 3:39 PM, Kurkistan said: I believe there's a way to do it more intelligently than just with JavaScript (the existence of this massive MSDN page suggests as much, though I haven't read through it), but if you execute this JS code then it works. if (window.location.hash && window.location.hash.slice(1,6) === "entry") { window.location.hash = "comment-" + window.location.hash.slice(6); } I don't know javascript, but I think this breaks if there is a thread with "entry" in the title. 0 Quote Link to comment Share on other sites More sharing options...
Kurkistan he/him Posted October 3, 2016 Author Report Share Posted October 3, 2016 4 hours ago, Eki said: I don't know javascript, but I think this breaks if there is a thread with "entry" in the title. Likely if we went the JS route there'd need to be some tweaking/testing to be sure (for one thing I'm not sure that window or window.location always necessarily exists, since I haven't dealt with it before), but that specific concern shouldn't be a problem. The "hash" by my understanding, is entirely the text that follows after the '#' at the end of the URL. window.location for this thread, for instance, has an empty hash if you just click on the thread link itself rather than navigating to an individual post: Location {hash: "", search: "", pathname: "/forum/topic/56107-request-mapping-from-old-single-post-links-to-new-format/", port: "", hostname: "www.17thshard.com"…} 0 Quote Link to comment Share on other sites More sharing options...
Eki Posted October 3, 2016 Report Share Posted October 3, 2016 Ah, ok. The coder in me just had to react, you know. I've never really tried to do javascript before. 0 Quote Link to comment Share on other sites More sharing options...
Djarskublar he/him Posted October 5, 2016 Report Share Posted October 5, 2016 If you aren't sure of it, you could make it look for the string from the end of the URL backwards, and if it doesn't find it within a certain number of characters, just stops looking. There has to be a limit to how large the comment can be, so just look back as far as necessary. You can also add in qualifiers to make sure that it only executes if there are certain character types after the #comment. Overall, it should be an easy fix even if the .hash doesn't work the way you presented it as working. It is simple string conversion, right? I don't know javascript well enough to say, and I really don't know enough about how URLs work, but the coder in me says this should be easy. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.