The wiki global offers plugins an implementation of Collaborative Link called doInternalLink.
We have noticed that Graphviz diagrams don't resolve links when rendered in a ghost page. Is this expected behavior, we inquire.
Graphviz 0.10.0 did call this function. github
wiki.doInternalLink(title, $page)
We will trace through this call and establish where the collaborative resolution takes place.
The wiki global initialization pulls this function from links.coffee. github
wiki.doInternalLink = link.doInternalLink
Link.coffee delegates to its own showPage and creatPage which allocates panel space in the lineup and runs the primitive refresh.cycle. github
showPage(slug, site, title)
Link's showPage creates the panel dom structure and guesses where the page will be found. This will be revised later in the collaborative linking process. github
class="favicon" src="#{wiki.site(site).flag()}"
Refresh.coffee assembles a pageInfo structure and then calls pageHandler's get function with success and fail callbacks. github
pageHandler.get whenGotten: whenGotten whenNotGotten: whenNotGotten pageInformation: pageInformation
PageHandler.coffee enters the recursive enumeration of possible sites mysteriously constructed as pageHander.context. github
.
It is worth comparing how graphviz is calling `doInternalLink()` with how it gets call in the client.
In the client, clicking on a link is handled in legacy.coffee (lines 178-184):
.delegate '.internal', 'click', (e) -> $link = $(e.target) title = $link.text() or $link.data 'pageName' # ensure that name is a string (using string interpolation) title = "#{title}" pageHandler.context = $(e.target).attr('title').split(' => ') finishClick e, title
with `finishClick()` making the call to `doInternalLink()`
finishClick = (e, name) -> e.preventDefault() page = $(e.target).parents('.page') unless e.shiftKey link.doInternalLink name, page, $(e.target).data('site') return false
This in turn calls `showPage()`, which adds a panel for the dom. Which gets picked up by refresh, and a call made to `pageHandler.get()`.
In `pageHandler.get()`, if the context is not already set it will get set to `view`. Which is then used in the recursive enumeration of possible sites.
**IMPORTANT** If the context is not set before calling `doInternalLink()` it will either get set to `view` or use any value that was set by a previous call. *this explains why if the page is found in the neighbourhood, and opened. Which is why a click that previously opened a ghost page will might find one.
Anywhere that a call to `doInternalLink()` is made without setting `pageHandler.context` first will end up using the value set elsewhere.