NYTimes Opensources Their Deep Linking JS
open.blogs.nytimes.com
open.blogs.nytimes.com
Since you asked…
1) Change tracking. Technical hurdles (and they're huge) aside, it would be great not to have these links break when text is added/removed.
2) Better onsite instructions. I knew how it was supposed to work, and it took me a bit to figure out that clicking a sentence highlighted it. Perhaps a tooltip?
3) A wordpress plugin seems easy/obvious :)
Many, many thanks for the good work!
Rather than the #p[...],h[...] how about #p=...&h=...?
EDIT: Or even #deeplink=p[...],h[...]
Given that there could be a long number of paramaters included for Highlighting I felt the [] gave a sense of belonging.
I like the #deeplink suggestion too, but in the end being as concise as possible was a factor.
.nytd_selection_button { display:none; }
Wikipedia claims it does not exist:
For most cases I imagine 'querySelectorAll' or 'getElementsByTagName' would suffice
Perhaps some kind of alternate src attribute on script tags, so you could list a local copy (for reliability) as well as Google and Microsoft CDN URLs, and the browser would go with the first one it had in its cache. And if individual browsers wanted to distribute jQuery (et al.) along with the browser itself, and define an URN for it, so much the better.
This is just something I thought up in the past few minutes, so take it with a grain of salt, but as a web developer, I would love this.
2. it's another dependency that you don't control
WRT your second point, there's a middle ground of pointing to Google's hosted version for speed and falling back to a local copy if it is not found.
You can see the technique in use within the Boilerplate HTML5 template - http://html5boilerplate.com/ - Scroll down to the index.html file, line 58.
The implementation of this is left as an exercise for the reader.
But is that going to happen? No. Why? Many reasons come from an editorial perspective (which I'm not knowledgeable enough to get into - but a simple one is: corrections), however the big one is also technical:
Providing previous revisions is not trivial feature. It would be a huge effort. There is no way to justify it from the perspective of deep-linking.
An issue with it though, when sending the link to someone, and then they click it, browsers (Chrome here) turn the #h[TArTWw,1] into #h%5BTArTWw,1%5D which then seems to be ignored by the script.
It's simpler, of course. It's in plain JS and as jQuery plugin
The second version generates a Key for the paragraph so it can be moved anywhere in the page, and survive slight modifications if the text changes too.
Nice work though.
My statement wasn't about tests in the slightest.
If you cannot stay with the curve because of your lack of knowledge, maybe you should spend less time flaming on Hackernews and more time studying up, sir.
Going from there to my supposed 'lack of knowledge' is a poor representation of yourself, too.
For example, I could have every paragraph an id say id="p5" and then link ad example.com/story#p5 and voila, deep linking.
Hoorah for reinventing the wheel :)
This addresses this (as stated in the article) without some elaborate server content management solution that tracks paragraphs and their html id links.
The difference is no 'href' tags. The 'tag' is automatically created based on the words in the paragraph, via Javascript, and decoded appropriately.
It is also slightly neat in that you can highlight a specific sentence (multiple sentences actually, see the little tutorial at the bottom).
I actually kind of like it, it would be a neat way to really highlight what you think is interesting in an article when sending someone a link. But doing it as a per site thing is crazy.. seems like it could be a good browser extension though. People who have it installed would instantly get a more functional linking experience. Imagine linking off to some documentation in a blog post for a coding problem, say to a Django documentation page, and when someone clicks the link they are not only taken to the specific part of the page that you are talking about, but the relevant stuff is actually highlighted. That'd be Neat (tm).
My hope tis that this approach is equally unhelpful to everyone :)
Seriously, my hope is that if an approach like this is going to happen that we can keep the usage (syntax) consistent.
Further down the road I'd like the view to also show you what people in your network have highlighted, or on a more aggregate and subtle level, what everyone has...
The upside would be that there would be much less work needed to find edited paragraphs: a paragraph would be identified by its anchor and it could be changed completely, as long as the anchor is still there the link's fine.
This approach has certainly been envisioned: it would be interesting to know why it was put aside?
There would have been deep-linking on the site years ago if it were not such a big undertaking. It had been on my own wish-list for many years but nothing something I decided to do my self actively until I met Kellan at OSCON in 2006(?) and he brought it up too.
Since then, a colleague of mine, Eitan and I started digging into the CMS side, as well as looking at some highly optimized code that outputs the article body. A combination of development time, risk, resources, and testing didn't justify the result - especially since we were trying this on our own time.
There more to it than that. But thats the main point.