mozilla/kuma — pull request #156 by ubernostrum (2012-04-06 15:44:09+00:00)
Title: 710726 mindtouch links

So, after discussion in the bug that went one direction on the original comments, then another, then discussion on IRC that pushed it back the original way... this got done as a catch-all URL pattern and a couple of views.

A few important notes:

1. Since enabling this comes down to including the catch-all URL pattern, and since so far as I know we can't do that off a flag right now, that pattern's commented out. Similarly, the tests for it skip right now. But if you un-comment and un-skip, they run and pass.

2. The URLs being generated are as close as I could reliably get them (given imperfect information) to the URLs the wiki app already generates for its own natural redirects. They may not always be perfect, but they have enough information that the document view will at least catch them and be able to figure out where to go from there.

3. If it looks like there's a corner case that's not tested, that's most likely due to the LocaleMiddleware; it transparently migrates locales for us in most cases. Only the three Chinese locales that get explicit test documents in this commit will actually slip through it ('en' to 'en-US' is handled by LocaleMiddleware, but also has a bit of redundant support in this commit just in case).

4. The namespaced URLs (Talk, Special, etc.) are handled as follows: Talk carries its locale in its MindTouch slug, so we can deduce that and generate a URL for it. Users we can sometimes guess from edits they've made. Everything else (including users we can't guess from edits) gets redirected into en-US for lack of any better option.