Closed claudioc closed 9 years ago
I would be interested in working on this one if you give me a hint about how to approach it. For example, would you add Images to the models so that _getWikiPage can do something different in the case where req.params.page ends in a known image extension ('.png', 'jpg', etc)?
Hi David, that's great news :) Give just a moment to think about it and I'll get back to you!
The idea is to be able to make any image in the document directory available to be linked inside a document. Ideally, given a kitten.png
in the doc directory, one should be able to use it as ![A kitten](kitten.png)
. At the moment this is impossible for obvious reasons.
I think I would approach this using a middleware. The middleware would intercept all the requests and if the requested item is an image, try to serve it right away reading it from the doc directory. The middleware would also send a 404 if the image is not readable.
To be able to read the configuration, the middleware should inherit from a Configurable class (just look for example in namer.js
on how to use this).
What do you think?
OK that seems like a good approach if we're only interested in serving the most recent version of a given image. Thanks, I'll keep you posted on my progress and questions.
I have a potential fix that works by configuring the node-ecstatic middleware to serve static files from the directory specified by the repository configuration. There are a couple remaining issues.
One, it doesn't yet handle the case where docSubdir is specified. I assume I should just path.join() that with the repository if specified? Second, the ecstatic middleware will serve the .md files if requested in the browser. I assume that should be prevented and the markdown files should be hidden?
Git.absPath(yourfile)
and you'll get directly the full path of the file (Git
is global):)
There should be a way to use images from inside the repository