Problem/Motivation
See #2418017-65: Implement autocomplete UI for the link widget for a more practical explanation that is necessary.
- Jumplinks
- Currently, it is impossible to create
jumplinks
: menu links that render as<a href="#fragment_to_jump_to">Amazing Llama Tricks!</a>This is because
user-path:maps to<front>(i.e.http://drupal.com/), henceuser-path:#kittenrenders to/#kittens(i.e.http://drupal.com/#kittens). In other words: currently we can only create jump links that jump to a fragment on a specific URL.
But we also want to be able to createuser-path:-scheme URIs that map to<none>, so that we can create jump links that jump to a fragment on whatever the current page is, i.e. URIs that render to#kittens, not/#kittens.To do that, we can assign additional meaning to a leading slash: the leading slash would mean "relative to the Drupal root", no leading slash would mean "relative to the current page".
So, instead of
user-path:<path>, we'd haveuser-path:/<path>. Which then allows us to haveuser-path:#<fragment>, allowing us to create page-relative jumplinks.Note that none of this needs to be exposed to the user! The user would still:
- start to type a title to autocomplete to an
entity:URI - type an path that begins with a slash (
/) to type auser-path:URI (note how this also maps precisely to what is being proposed here) - NEW (kind of, was already planned, but is currently impossible): type a fragment that beings with a hash (
#) to type auser-path:URI. You could do this in HEAD, but it'd always result in a fragment to the front page. With this proposed change it'd allow the user to create an page-relative jumplink.
- start to type a title to autocomplete to an
- Consistency with Symfony
- Currently, we don't store paths in
user-path:URIs in the same way as Symfony does (with a leading slash). This would bring additional consistency.
Proposed resolution
See above.
Remaining tasks
Needs review/discussion.
User interface changes
None.
API changes
user-path:<path> -> user-path:/<path>
| Comment | File | Size | Author |
|---|---|---|---|
| #34 | 2417647-34.patch | 35.1 KB | wim leers |
Comments
Comment #1
webchickBut... why? :( We don't do that with either base: nor entity:
Comment #2
wim leersPair programming with effulgentsia!
Initial patch, still rough, let's see what testbot says.
Comment #4
webchick#2417333: Add support for user-path: scheme to Url class just got committed so this probably needs some adjustment.
Would also love even a single detail in the issue summary explaining why we are doing this. :)
Comment #5
wim leersComment #7
wim leersComment #9
pwolanin commentedComment #10
webchickThanks for the issue summary update. I still worry this creates confusion though, because it's non-standard from the other schemes.
For argument's sake, can't we just prefix the "/" in the link text field on display for "normal" paths? We will already be manipulating the value anyway to strip out the
user-path:part prior to showing it.For the front page, I would think that would be
user-path:<front>For the jump link, I would think that would be
user-path:#jumpDon't want to block this necessarily, but I am concerned that this is going to result in DX headaches. :\ What am I missing?
Comment #11
pwolanin commentedYeah, we could potentially just do it for the widget UI for now, though It would be better to literally store the input the user types into the widget.
Discussing with effulgentsia in person, I think we should get the widget working even if it's not storing literal user input and then re-visiting this.
So, let's postpone this until the widget it working as we want. That means we will need to e.g. store
user-path:<front>as the replacement for the typed/for now.Comment #12
wim leersThis fixes all remaining failures (barring new ones I've introduced), except for one, which will disappear once #2417793: Allow entity: URIs to be entered in link fields lands.
Marking to NR to send to testbot only, then moving back to postponed.
(Also posting an updated issue summary that I had finished 10 hours ago but couldn't post due to Newark International Airport having precisely zero functioning internets. It contains a more complete explanation, hoping that helps clarify the value of doing this. Posting this immediately after landing in Brussels, where 100% more internets are available to me.)
Comment #13
wim leersComment #15
pwolanin commentedComment #16
wim leersSee #2418017-59: Implement autocomplete UI for the link widget, point 3. That issue tried to do something similar to add jumplink support, but in a backward way.
Comment #17
wim leersComment #18
wim leersThis blocks #2418017, see #2418017-65: Implement autocomplete UI for the link widget, hence moving to critical, since that issue is critical.
Comment #19
wim leersIt's clear I wrote #12 while tired, because wow, that patch is *so* riddled with mistakes and inconsistencies it's not even funny.
Comment #20
wim leersAnd voila. This is much better.
There are two very large
@todoblocks. They are a temporary translation layer, while the default link widget still shows NO leading slash in the UI. These @todo blocks can be removed in #2418017: Implement autocomplete UI for the link widget, for which this is a direct blocker.Comment #21
wim leersBetter title.
Comment #22
wim leersComment #23
wim leersComment #24
wim leersThese @todos can be deleted by #2418017: Implement autocomplete UI for the link widget. They make sure users can still enter
<front>and<none>in the UI!Comment #26
wim leersFixing all the test failures.
And grepped the code base for
user-path:, made sure every single one of them was updated.(Those occurrences that are like
$entity = <EntityType>::create(['some_uri' => 'user-path:path'); $entity->save()— usually in tests — don't complain, because calling->save()does NOT validate the values of the entity… it just saves them as-is.)Comment #27
wim leersTo clarify: enabling the distinction below is what the issue is all about, it's what is required for jumplinks, which is what's missing from HEAD, and hence what is blocking #2418017: Implement autocomplete UI for the link widget.
Comment #28
effulgentsia commentedI discussed this a bunch with Wim and xjm, and here's what I believe to be the consensus at least between the 3 of us. Posting it here for feedback from others. TL;DR: +1 to this issue. Reasoning:
tel:+1-201-555-0123is not "consistent" withmailto:admin@example.com(leading+vs. not,-delimiter vs.@), each of our schemes can optimize its syntax within its own scope without concern for what the other schemes do.user-pathis to store a normalized representation of what the user intended to link to when typing a path. With that in mind, I think normalizing that intent into "absolute path" (with leading slash) notation is more logical than "relative path" (no leading slash) notation. When the user enters a path, I think it's clear that the most likely intent is a reference to a resource in the site's structure that is independent of the current Drupal resource that the visitor is viewing. I.e., if the link is to "about", that means "about" regardless of whether I'm currently on the front page, or the "user/login" page. It does not mean the "user/about" page when I'm on the "user/login" page. Such independence is common to represent with a leading slash.user-pathsyntax. So, whetheruser-path:/blogoruser-path:blogis friendlier to UI users is irrelevant; it is only developers who are affected by this decision, and per above, I think with the leading slash is friendlier for developers due to its greater accuracy in modeling the underlying concept.base. Or rather, we should follow the semantics of "base URI" defined by the RFC. Which basically translates intobase:blogmeaning relative to the subfolder that Drupal is installed in, andbase:/blogmeaning relative to the host (i.e., outside of Drupal's subdirectory).user-path:/blogvs. if 'blog' is implemented by another script inside the same subdirectory as Drupal and so you linked to it asbase:blog. However, once we add the methods suggested in #2417459: Provide internal API for special schemes and thin public wrappers for user input and non-routed URLs, you won't be viewing things like that side-by-side in code, so per point 1 above, this is almost a non-issue. I'll add a more detailed comment about that specifically in that issue.Comment #29
dawehnerGreat documentation.
... this sentence stops in the middle of
I'm not entirely sure whether its a good idea to remove the support for and in the link UI, given that other places like block visibility still supports it. Some kind of consistency is nice.
Comment #30
wim leers@todothat references another issue, so we can discuss it there :)Comment #31
dawehnerI just assume it will be green as well
Comment #32
webchickShoot, I'm sorry, I saw #2216271: Regression: Shortcut links access is not checked first, so this needs a quick re-roll.
Comment #33
webchickComment #34
wim leersTwo merge conflicts, easy fixes.
Comment #35
webchickWhile we're waiting for testbot (and these comments aren't going to block a commit):
Hm? These are both totally consistent.
scheme:then paste in the thing you want to link to in full.And in this respect I can actually understand not prefixing
entity:with a slash, because what you want isentity:taxonomy_term/4notentity:/taxonomy/term/4. Lack of leading slash makes it clear.Ok, so far so good...
Here's where you lose me. As a web developer for 20 years but one who doesn't have all of the various RFCs memorized (like at least 99.9% of web developers, I would reckon), it's frightfully confusing that when either way you're talking about putting in a link directly to a given URL, and when either way you want "a reference to a resource in the site's structure that is independent of the current Drupal resource that the visitor is viewing." So why would this not also be a leading slash, or else eliminate
base:altogether in favour of justuser-path:everywhere?Comment #37
webchickThat said... the rationale for this patch makes a lot more sense now thanks to comment #34. And I guess the idea is that whether we bring consistency to
base:or not doesn't really matter, because "in theory" if #2417459: Provide internal API for special schemes and thin public wrappers for user input and non-routed URLs makes it in, developers won't be dealing with these raw schemes directly anyway.So let's get this in, and get to the end of the NJ sprint criticals ASAP so we can take a step back and look at the "big picture" once it's complete, and decide how we want to move from there.
Committed and pushed to 8.0.x. Thanks! See you in #2418017: Implement autocomplete UI for the link widget. :)
Comment #38
webchick