Page MenuHomePhabricator

Fix Diviner links to articles by title
ClosedPublic

Authored by epriestley on Mar 5 2014, 5:18 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 11, 8:50 AM
Unknown Object (File)
Thu, Apr 11, 8:50 AM
Unknown Object (File)
Thu, Apr 11, 8:50 AM
Unknown Object (File)
Thu, Apr 11, 5:42 AM
Unknown Object (File)
Thu, Apr 11, 5:18 AM
Unknown Object (File)
Wed, Apr 10, 1:49 PM
Unknown Object (File)
Mon, Apr 8, 1:16 AM
Unknown Object (File)
Mon, Apr 1, 10:26 AM
Subscribers

Details

Summary

Ref T988. This fixes the biggest current problem with Diviner, which is dead links to articles.

In the new Diviner, articles can have both a "name" (derived from the file name, and used in the URI) and a "title" (optional, specified explicitly). For example, we have one document with the name "feedback" and the title "Give Feedback! Get Support!".

On disk, we want to use the name for the actual file where the text lives ("feedback.diviner"). We also want to use the name in the URI, to generate a clean URI and to allow us to retitle the document slightly without breaking links to it (for example, we renamed the "Backup" document to "Backups and Migrations").

However, when displaying the article we want to use the title.

Currently, you can only link to the name, not the title. This is inconvenient:

  • We have a bunch of existing docs which link to titles.
  • It's natural/intuitive to link to titles.
  • Linking to titles makes it easier/cheaper to generate documentation, because we don't need to be able to resolve things at render time.

To remedy this, allow links to target either names or titles. If we miss on a name query, we'll do a title query. This is implemented with a slug hash to allow approximately correct titles (wrong case/spacing/punctuation, e.g.) and sidestep all the UTF8/column length issues.

(In the long run, atom resolution should theoretically be more sophistiated than it is now, and we should do render-time lookups on at least some documents to catch bad links. However, this is fairly complicated and a relatively advanced feature, and I think allowing links to titles is desirable no matter what.)

Test Plan

The user documentation book now has valid links to articles when the titles and names differ.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

epriestley updated this revision to Unknown Object (????).Mar 5 2014, 7:32 PM
  • Also include the book name in the atom hash, so that renaming a book doesn't cause a pile of problems.
btrahan edited edge metadata.
btrahan added inline comments.
resources/sql/autopatches/20140305.diviner.1.slugcol.sql
3

why only 12 chars?

This revision is now accepted and ready to land.Mar 5 2014, 7:56 PM

PhabricatorHash::digestForIndex() always produces a 12-character hash, so it's slightly more efficient to use CHAR(12) latin1_bin over other storage types.