Render images from repository correctly

This adds a markdown renderer for images, so that images
that are referenced by their repository path are resolved
correctly. In this case, the content rest endpoint is
rendered as source url. For this, two new contexts
(RepositoryContext and RepositoryRevisionContext)
have been added, that make the repository and the
current revision available, so that the content url can
be resolved properly. These new contexts may be used
by plugins like the scm-readme-plugin.

Co-authored-by: Eduard Heimbuch <eduard.heimbuch@cloudogu.com>

Reviewed-by: Eduard Heimbuch <eduard.heimbuch@cloudogu.com>
This commit is contained in:
Rene Pfeuffer
2022-12-19 10:12:01 +01:00
committed by SCM-Manager
parent 6ba792e5bc
commit f2f2f29791
22 changed files with 604 additions and 216 deletions

View File

@@ -91,6 +91,9 @@ public class GitCatCommand extends AbstractGitCommand implements CatCommand {
private Loader getLoader(CatCommandRequest request) throws IOException {
org.eclipse.jgit.lib.Repository repo = open();
ObjectId revId = getCommitOrDefault(repo, request.getRevision());
if (revId == null) {
throw notFound(entity("Revision", request.getRevision()).in(repository));
}
logger.info("loading content for file {} for revision {} in repository {}", request.getPath(), revId, repository);
return getLoader(repo, revId, request.getPath());
}