← Back to team overview

zim-wiki team mailing list archive

Re: understanding directory usage

 

On Tue, Jun 21, 2011 at 10:54 AM, Alessandro Magni <magni@xxxxxxxx> wrote:

> Hi everybody,
>
> I'm trying to understand Zim's usage of directories.
> Since I make use a lot of absolute paths, I never noticed that Zim uses
> relative paths in a rather peculiar way
> (please excuse me if it has been already discussed, I didnt find anything).
>
> Just starting from scratch with a test page in a given dir:
> /my/test/dir> zim here.txt
>
> here.txt is of course created in /my/test/dir.
> But if I have the image /my/test/dir/testimage.jpg, why is it that
> {{testimage.jpg}} reports a broken link, while {{../testimage.jpg}} works???
>

Because file links are taken relative to the attachment folder of the
current page. The attachment folder for the page mapped by
/my/test/dir/here.txt is  /my/test/dir/here/, so any file in /my/test/dir/
needs to be linked with "../".

Keep in mind that in zim we use the concept of pages and attachment folders.
The exact mapping of pages to files is determined by the storage backend.
Default layout we have one file per page with attachments in a sub folder,
but other layouts are possible as well (with a bit of code). However the
logic for linking files and pages within the notebook should be agnostic of
this mapping of pages to files, therefore we do not use the page file as
reference for relative links, but the attachment folder.


> Even more confusing: a link like: [[there]] works flawlessly loading
> there.txt from /my/test/dir, so the logic used for images is different here!
>

In this case you are using a page link, not a file link. Logic for page
links has little to do with actual file layout (which may be different for
different backends).

Regards,

Jaap

References