Page MenuHomePhabricator

Creating a document from a link doesn't preserve case
Open, WishlistPublic

Description

Let's say for a moment that I insert a wiki link in a Phriction document like this:

[[TEST PAGE]]

I then click on the link to create the page. The created page doesn't preserve the capitalization of the wiki link, instead creating a page called

Test Page

Event Timeline

wotte raised the priority of this task from to Wishlist.
wotte updated the task description. (Show Details)
wotte added a project: Phriction.
wotte added a subscriber: wotte.

This could be fixed at least partially, I think, but would be somewhat cumbersome.

We don't allow you to create multiple pages which differ only in their capitalization (e.g., you can not create separate pages at /w/TEST/, /w/TeSt/, and /w/test/). When you type [[TEST PAGE]], we canonicalize the text into a URL (/test_page/), which is where the link goes, and then we prefill the title by uncanonicalizing the URL back into a title (replacing underscores with spaces, then titlecasing it), producing Test Page.

We could produce a link like /test_page/?title=TEST%20PAGE and use the GET title to prefill the title if it's present, but that's a bit funky. A case where it gets messy is if you write [[ TEST PAGE | Some Title ]] -- should we preserve the title, or the link case? What if the user types [[ TEST PAGE | click here ]]?

We could produce a link like /test_page/?title=TEST%20PAGE and use the GET title to prefill the title if it's present, but that's a bit funky. A case where it gets messy is if you write [[ TEST PAGE | Some Title ]] -- should we preserve the title, or the link case? What if the user types [[ TEST PAGE | click here ]]?

I'm not so sure that's very tricky at all; we go with TEST PAGE. In most wikis I've ever edited, the canonical title of the page is given in the [[ TEST PAGE]] form, while the alternate construction [[TEST PAGE | some text]] is only really used to include a link in free flowing text. (e.g., the click here case)

I haven't looked at the code, but I'd imagine that Phriction itself doesn't currently do a whole lot of parsing of the page content (beyond a diff of the previous content). I'd guess that a much cleaner solution would be to have Phriction parse the page after an update, storing the canonical title in the database for any new pages created. You could also do a couple other nice things, like letting the user know that they have linked to nonexistent pages - perhaps I made a typo in one of my links; there's currently no way to tell this now. It would also be nice to render links to nonexistent pages in a different color (red) so I can tell at a glance which links don't yet exist.