SilvaDocument: relative links are not handled correctly

Bug #100764 reported by Christian Zagrodnick
12
Affects Status Importance Assigned to Milestone
Silva
Fix Released
Medium
Martijn Faassen

Bug Description

Assume a document doc and an asset foo in one container.

If you hit the "add hyperlink" button on a paragraph in doc you it inserts
something like ((foo|foo)). This is what is expected.

The public/preview rendering of this hyperling though will just be "foo". So we
may get URLs like doc/edit/foo or doc/foo which is not indendet. I think if the
Link points to an existing object we should use its absolute_url method to
render the Link. If the target object is not reachable we have to thinkg about
getting the context right.

Revision history for this message
Martijn Faassen (faassen) wrote :

Assigning this to JW. I don't think we should always use absolute url as
care was actually taken to support relative views.. JW should have a
better idea of the issues involved here, I hope.

Revision history for this message
Jan-Wijbrand Kolman (jw-infrae) wrote :

I thought that indeed we wanted to support relative links. E.g. to not make
moving/renaming folders break links to images, files and hyperlinks. But maybe I
just do not understand the issue in the first place - Zagy, could you elaborate
some more?

Revision history for this message
Christian Zagrodnick (zagy) wrote :

The problem is *not* storing relative references. The problem is *not* rendering
relative references.

The problem is rendering *wrong* relative references. As stated before you'll
get relative URLs like doc/edit/foo or doc/foo while foo is the same container
as doc. This only works due to Zope acquisition.

Revision history for this message
Clemens Robbenhaar (crobbenhaar) wrote :

To get the relative links right in the public view, something like

<base href="." tal:attributes="href python:'%s/'
%here.get_container().absolute_url()" />

in the layout_marco.html would hepl. (I guess I have suggested this on some
mailinglist, but I forgot, where ...)

Unfortunately this does not work in the SMI, because all the forms
e.g. in the metadata and publish tab would be broekn, as their
action is relative ... but maybe one can live with some shaken
up links here?

Revision history for this message
Christian Zagrodnick (zagy) wrote :

clemens is right, this seems to solve most cases. From my point of view this
issue could be resolved by putting the base in the default layout_template.

Revision history for this message
Jan-Wijbrand Kolman (jw-infrae) wrote :

I'm currently working on better virtual host support in Silva. Part of this work
is some code in EditorSupport (SilvaDocument - on the
jw-deep_virtual_hosting_support-branch, at this moment still depending on
jw-deep_virtual_hosting_support-branch of Silva ) which tries to render an
absolute_url for objects referenced with an absolute or relative path in link
elements.

This would also solve this issue.

Could the nosies please have a look at the code?

zagy: I'm using a regex copied from silvaparser.py. Is this regex efficient for
this usage?

Revision history for this message
Christian Zagrodnick (zagy) wrote :

uhm, actually I posted this again in issue 800.

Revision history for this message
Martijn Faassen (faassen) wrote :

Resolving this one as issue 800 was resolved.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.