Ghosts to SilvaDocuments with relative urls to images

Bug #101098 reported by Samuel Schluep
12
Affects Status Importance Assigned to Milestone
Silva
Fix Released
Wishlist
Jan-Wijbrand Kolman

Bug Description

Links to the hires_image in a Ghost pointing to a SilvaDocument may break. This
is the case, if the SilvaDocuments contains images, which are addressed with
relative urls.

Let's say the document '/folder/doc' contains the image '/folder/img' and the
image link will point to the hires_image: then the hires_image-link in '/ghost',
pointing to '/folder/doc', will break.

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

Zagy, can you look into this for 1.0?

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

Before doing work on it, let me know first what it entails and when it could be
done. If it's big and not a minor fix we'll need to drop it for 1.0.0.

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

Will have a look today.

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

Well. I think this (right now) a general problem with *all* relative URLs in
haunted content.

Since the document is not ware of beeing rendered in a different context it
doesn't care. But in my oppinion the document should not even be aware of it.
The ghost should probably "redirect" those links (maybe transform the xhtml
returned by the content object?).

I think this needs some disuccion and time -- so we probably do not want to
delay 1.0 by that.

Revision history for this message
Samuel Schluep (schluep) wrote :

Transforming all the xhtml seems to be a very expensive
process. I was thinking of rendering all links as absolute
urls. Then the document does not have to be aware of beeing
rendered in a different context. Relative links would then
only be used for storage in the Silva system.

The problem with hires_images is, how does the renderer know
if it is a link to a Silva object or a link outside the
system, before making the url absolute.

The dLCMS extension product relies heaviliy on Ghosts, so I
would prefer to have this fixed rather quickly.

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

hmm... guess you're right. Just putting out absolute URLs
might solve the problem. And it would be rather easy do to.
And it's KISS.

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

I checked in a fix into zagy-issue984-branch of
SilvaDocument. It's in a branch since I don't want to break
anything this late in the beta phase.

Concerns: the 'make it absolute' seems to work. But I just
don't know how it behaves in virtual hosting situations.
Nosying in JW.

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

Once JW has given feedback and it looks positive, we should
merge this (after RC1).

I don't think there are virtual hosting issues with this,
but I haven't thought very hard. :)

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

> I don't think there are virtual hosting issues with this,
 > but I haven't thought very hard. :)

 Hm, if a ghost haunts an object which is not visible via the current
virtual root (except via weird acquisition path's), where do the
absolute urls point to ... ?

(I guess such cases are not supported yet anyway, though one could set
up such cross vh-site hauntings ...)

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

Clemens is right: The situation where ghosts point to anything "outside" of the
context/scope of the virtual host (in which the ghost resides, that is) is
inherently difficult.

I'm not sure at all if forcing a Document to always render absolute URLs for
things it references (e.g. images) will work, since the absolute_url() method
works by looking at information in the REQUEST object. The information
(SERVER_NAME amongst others) in the REQUEST object however is based on the
request to the virtual host in the first place!

Apart from that, I don't really understand the change in zagy's branch. It seems
to try to create an absolute *path* to images, and I wonder how that should work
for objects outside the scope the virtual host...

I really don't see *any* good solution to fully support ghosting objects outside
of the virtual host's scope. Of course I might miss something obvious here.

Martijn, can we brainstorm face-to-face on this a little?

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

We have some ideas on possible directions to take for links pointing outside the
current virtual host, but those are definitely not doable in 1.0. I'm going to
move this to 1.1. It's very well possible it's not in scope for 1.1 too, but at
least we can review it.

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

Moving it along to 1.2. We need a linking review, this can be a part of a review
of referencing in general.

Revision history for this message
Samuel Schluep (schluep) wrote :

This is still an open issue and we have Silva 1.4 now! I have some code, which
also works in virtual hosting situations (probably the smart guys from Infrae
could provide much more elegant code ;-). It works also for hires images that
are outside the virtual host, but in the same Silva instance (thanks to
acquisition). However, I doubt that this can be used for XSLT rendering.
Therefore a more general linking review is still needed.

is_url = link.split('://')
if not (link == '' or link == None) and len(is_url) == 1:
    # it's not a url, make path absolute if it is not already
    link_path = link.split('/')
    model_path = context.REQUEST.model.getPhysicalPath()
    link_path = mangle.Path.toAbsolute(model_path, link_path)
    # adapt path for virtual hosting
    virtual_root_path = context.REQUEST.get('VirtualRootPhysicalPath', [])
    # ommit the virtual root base path
    i = 0
    while i < len(virtual_root_path):
        if link_path[i] != virtual_root_path[i]:
            i = -1
            break
        i += 1
    if i > -1:
        link_path[1:i] = []
    link = '/'.join(link_path)

Revision history for this message
Samuel Schluep (schluep) wrote :

Taking a closer look: Ghosts to Documents with relative URLs to images do not
display the images with XSLT rendering (if the image cannot be acquired from the
ghost context) on a pure Silva 1.4.1-all installation.

However, I am quite confused: on my Silva 1.4.1 Vienna Sprint instance with
Silva Layout and WUW Layout in the Products directory (installed or uninstalled,
with or without the XSLT rendering setting) everything works fine. The ghost
displays the image and the image link points correctly to the hi-resolution
version. (I don't even manage to customize the tag.py widget -- it does not seem
to have an effect on the preview or public rendering).

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

Still needs review from JW; deferring before beta release.

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

After some discussion here:

relative paths, ghosts, ghost folder are interacting in ways that are not always
desirable. Improving the situation piecemeal is something we continue to try,
but this is really a deeper issue that needs rethinking in general. We expect
this line of thinking will result in Silva dealing with relative paths or
ghosts, or both, in a fundamentally different way.

Since this is all not easy, I'm moving this to 'silva-future'.

Revision history for this message
Sylvain Viollon (thefunny) wrote :

This issue does no longer apply since this migration to references for links and images.

Changed in silva:
milestone: none → 2.3.6
status: Confirmed → Fix Released
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.