ipfs / ipfs/kubo

Recognize symbolic links into mounted /ipfs when adding files

Open
#9,362 0 comments 0 reactions 0 assignees View on GitHub
kind/enhancement
Dominant language
Go
Stars
17.1k
Forks
3.2k
Avg merge
3d 18h
Merged PRs (30d)
11

Description

### Checklist

- [X] My issue is specific & actionable.
- [X] I am not suggesting a protocol enhancement.
- [X] I have searched on the [issue tracker](https://github.com/ipfs/kubo/issues?q=is%3Aissue) for my issue.

### Description

Let's assume I'm writing a webpage that needs to render math formulas. In order to do so I use Mathjax, in order to use it I mount /ipfs and create a symbolic link to point to the the proper hash.

So:

```
$ ls -l page/
total 8
lrwxrwxrwx 1 calmarius calmarius 60 okt 21 10:59 mathjax -> /ipfs/QmNcgYoBYqk84egwy9aver5XSVjAGdrkfWUJRzbuKrFL7B/MathJax
-rw-rw-r-- 1 calmarius calmarius 637 okt 21 11:01 mathproof.html

```

Then I in the HTML I write:

```


Foo



$\LaTeX$



MathJax.Hub.Config({
tex2jax: {
inlineMath: [['$','$'], ['\\(','\\)']],
processEscapes: true,
"HTML-CSS": { linebreaks: { automatic: true } },
SVG: { linebreaks: { automatic: true } }
},
TeX: { equationNumbers: { autoNumber: "all" } }
});

```

Opening the page in browser properly renders the LaTeX logo confirming that MathJax works.

However if I `ipfs add -r page/` it would just add a symlink object for mathjax that does not work.

I know adding support for adding/following symlinks in general is challenging, but in this specific case the intent is clear: /ipfs/QmNcgYoBYqk84egwy9aver5XSVjAGdrkfWUJRzbuKrFL7B/MathJax resolves to /ipfs/QmZZNfft8xStAiC5saxDzCp9536zGeKmKLkN2iRdKd7LD9, therefore I want mathjax to point to QmZZNfft8xStAiC5saxDzCp9536zGeKmKLkN2iRdKd7LD9 in the resulting object after recursive addition.

So the `add` command should recognize symbolic links pointing into the mounted /ipfs, try to resolve the object and create the entry pointing to the resolved object.

This would also make it easy to publish the content on a webserver as a HTTP fallback: as long as /ipfs is mounted the content can be served fine without any extra configuration, there is a good chance that the content is pinned so the server doesn't even need to fetch the content from the network. Also, like in the example above, it's possible to edit and write webpages without using a webserver at all, as the symlink to /ipfs/ works even in the file:// scope.

It also provides a gateway independent way to access external resources when accessing content using subdomain gateways (as path based URIs doesn't work when using subdomain gateways) that gracefully falls back to HTTP and served through the webserver rather than a public gateway - you don't need to add cid.ipfs.dweb.link URL-s if the resource is linked from within the tree.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.