Page MenuHomePhabricator

Remarkup rule for rendering PHIDs as handles
ClosedPublic

Authored by avivey on Mar 16 2016, 11:15 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Dec 19, 4:57 PM
Unknown Object (File)
Thu, Dec 19, 3:14 PM
Unknown Object (File)
Thu, Dec 19, 12:03 PM
Unknown Object (File)
Sat, Dec 14, 5:07 PM
Unknown Object (File)
Thu, Dec 12, 6:28 AM
Unknown Object (File)
Fri, Dec 6, 2:57 PM
Unknown Object (File)
Thu, Dec 5, 11:32 PM
Unknown Object (File)
Thu, Nov 28, 9:21 AM
Subscribers
Tokens
"Baby Tequila" token, awarded by chad."Love" token, awarded by michaeljs1990.

Details

Reviewers
epriestley
Group Reviewers
Blessed Reviewers
Commits
Restricted Diffusion Commit
rP2b9d4f70ba3a: Remarkup rule for rendering PHIDs as handles
Summary

adds the {{PHID....}} rule. Should mostly be useful in UI code that refers to Objects.

It doesn't add any mention links/transactions.

Test Plan

Comment with this, see email (plain + html) and comment box.

Diff Detail

Repository
rP Phabricator
Branch
stable
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 11185
Build 13878: Run Core Tests
Build 13877: arc lint + arc unit

Event Timeline

avivey retitled this revision from to Remarkup rule for rendering PHIDs as handles.
avivey updated this object.
avivey edited the test plan for this revision. (Show Details)
avivey added a reviewer: epriestley.

web (As renderTag):

pasted_file (102×686 px, 14 KB)

html mail:

pasted_file (152×665 px, 13 KB)

plain:

pasted_file (82×647 px, 9 KB)

I'm not sure if rendering the handle as tag, or link, or hovercardLink is nicest; "tag" looks richest...

avivey edited edge metadata.
epriestley edited edge metadata.

Couple of inlines but this looks good to me overall.

src/applications/phid/remarkup/PhabricatorHandleRemarkupRule.php
10

I think we can just do {PHID-...}, not {{PHID-...}}. It isn't ambiguous with {T123}, etc.

It would maybe even be OK to mark up plain PHID-... in the future, although I don't like changing the text when the reference might be ambiguous. But we could have these still say PHID-... and at least produce hovercards, which would be a little better in all cases and worse in none, I think.

10

Maybe make the PHID-capturing part a little stricter, like [^\s}] (i.e., prevent whitespace). I think this could capture a whole paragraph if you type like:

{{PHID- is how you start a PHID reference and then you end it with }}

...which isn't the most faithful rendering of the original input text.

18

Because the pattern is liberal, we should have an if (!$this->isFlatText($matches[0])) check here which just returns $matches[0] for non-flat text.

This prevents shenanigans like {{PHID-**x**}}, where you put rich text inside the rule. In some cases, this can lead to security issues in the generated markup.

18

I think we should also do a phid_get_type() here and just return $matches[0] if the pattern doesn't have a type or, ideally, if we don't recognize the type. That is, when the user types:

{{PHID-x}}

...the best rendering is just their input text, not "Unknown Object (???)", since that could make a log or table or example which means to include this text as raw text unreadable and confusing.

64

HandleQuery should always produce a handle, even if the PHID is nonsensical or invalid, so this check might be impossible to miss.

A better check might be !$handle->isComplete(), which indicates that the handle is inaccessible or not really referencing valid object.

84

I think you can setPHID() on $link to get a hovercard (which seems like a good/reasonable behavior to me).

This revision now requires changes to proceed.Mar 17 2016, 1:33 PM

Specifically, I'm imagining these as the eventual rules:

  1. {PHID-TASK-nnnn} -> Taaa: Build Better Dogs
  2. PHID-TASK-nnnn -> PHID-TASK-nnnn

In case (1), I think it's OK if {...} (single brackets) trigger the rule. This is consistent with other rules and I don't think it introduces ambiguity or will fire accidentally.

In case (2), we would preserve the input text (in case you were just talking about a PHID and didn't explicitly mean to trigger the rule, so users can still understand and copy/paste it) but augment it with a visual highlight and a hovercard.

avivey edited edge metadata.
avivey marked 6 inline comments as done.
  • Much stricter regexp
  • only one {
  • all other inlines

I can continue with the bare PHID tonight, if you think it's worth doing now.

pasted_file (376×762 px, 63 KB)

epriestley edited edge metadata.

Looks reasonable to me. I don't think we need to deal with the bare PHID for now.

This revision is now accepted and ready to land.Mar 17 2016, 7:37 PM
This revision was automatically updated to reflect the committed changes.