Fossil User Forum

How to add image files for wiki pages to a repository, from command line?
Login

How to add image files for wiki pages to a repository, from command line?

How to add image files for wiki pages to a repository, from command line?

(1) By anonymous on 2024-06-21 11:02:56 [link] [source]

Consider a standalone, untracked markdown file named `page1.md` with the following content:

```
Wiki page 1
===========

Some content here

![an image](img.jpg)

[page2](page2.md)
```

Another standalone, untracked markdown file named `page2.md` with the following content:

```
Wiki page 2
===========

Some other content here
```

And the image file `img.jpg`, referenced in `page1.md`.

All three files are in the same directory.

When opening `page1.md` in a markdown rendering app (I am using a web browser addon for this, but it's irrelevant), `img.jpg` is displayed properly. The link points to `page2.md` and clicking on it opens that file.

The goal is to import these into a fossil repository as wiki pages and not break anything. By trial and error, I have found that if I use the full file names as PAGENAME, everything works.

So I do:

```
$ fossil wiki create page1.md page1.md -M markdown
$ fossil wiki create page2.md page2.md -M markdown
```

After this, if I do `fossil server` and open `page1.md` in fossil web interface, then click on link to `page2.md`, it works.

My question is, how to import the image `img.jpg` as well into the fossil repository, from command line as well, so it gets displayed properly when `page1.md` wiki page is opened in fossil web interface?

I know I can add and commit the jpg file to the repository, then fossil will see it as `doc/tip/img.jpg`. But the constraint is I can't modify `page1.md` at all. At least because if I do it, then later I need to export the wiki pages back to files, the modified links won't work out of fossil context.

What are my options?

(2) By Warren Young (wyoung) on 2024-06-21 11:32:19 in reply to 1 [link] [source]

What are my options?

Give up on the idea that Fossil is a local Markdown file viewer. In the context you're using it, it's a wiki for stored content. Store the content; all of it, including the images.

Even with the embedded document form of MD, you're going to find mismatches between URLs to in-tree files and on-disk renderings via /doc/ckout type URLs. This is unavoidable given that Fossil has a URL scheme of its own and that its / isn't at your filesystem root.

(3) By Offray (offray) on 2024-06-21 20:22:04 in reply to 1 [source]

If the image is publicly available, I tend to use its absolute URL (i.e. something like https://myrepo.fossil/uv/image.png ). If not, I try to use the Fossil's relative URL scheme, that works with local and remote repositories and test the image addresses using fossil ui.

In general, I try to not add raster files, even images into the repository.

Hope it helps,