Fix URLs for embedded images in project summaries

This commit is contained in:
Drew DeVault 2020-04-30 08:46:07 -04:00
parent 34e5c1c7c1
commit b90812f934
2 changed files with 9 additions and 1 deletions

View File

@ -7,8 +7,10 @@ from hubsrht.services import git, hg
from hubsrht.types import Feature, Event, EventType
from hubsrht.types import Project, RepoType, Visibility
from hubsrht.types import SourceRepo, MailingList, Tracker
from jinja2 import Markup
from srht.database import db
from srht.flask import paginate_query
from srht.markdown import markdown
from srht.oauth import current_user, loginrequired
from srht.validation import Validation, valid_url
@ -25,10 +27,16 @@ def summary_GET(owner, project_name):
try:
if repo.repo_type == RepoType.git:
summary = git.get_readme(owner, repo.name)
link_prefix = repo.url() + "/blob/refs/heads/master/"
elif repo.repo_type == RepoType.hg:
summary = hg.get_readme(owner, repo.name)
link_prefix = repo.url() + "/raw/"
else:
assert False
# TODO: Pick from default branch
summary = markdown(summary, ["h1", "h2", "h3", "h4", "h5"],
link_prefix=link_prefix)
summary = Markup(summary)
except:
summary = None
summary_error = True

View File

@ -158,7 +158,7 @@
</div>
{% else %}
{% if not summary_error %}
{{summary | extended_md}}
{{summary}}
{% else %}
<div class="alert alert-danger">
An internal error occured fetching the README.md for this project.