hub.sr.ht: Prefix README links to rendered pages v1 APPLIED

Nolan Prescott: 1
 Prefix README links to rendered pages

 1 files changed, 6 insertions(+), 4 deletions(-)
#362216 alpine.yml success
#362217 archlinux.yml success
#362218 debian.yml success
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/15845/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH hub.sr.ht] Prefix README links to rendered pages Export this patch

Relative links from project summaries resulted in raw pages rather
than rendered pages for both mercurial and git repositories.

This patch is intended to match the behavior of git.sr.ht and hg.sr.ht
README rendering by passing the previous raw links as secondary link
prefixes (for rendering images) but otherwise link to rendered

related ticket: todo.sr.ht/~sircmpwn/hub.sr.ht/67

diff --git a/hubsrht/services.py b/hubsrht/services.py
--- a/hubsrht/services.py
+++ b/hubsrht/services.py
@@ -120,8 +120,9 @@

        content = repo["md"] or repo["markdown"]
        if content:
            link_prefix = repo_url + "/blob/HEAD/"
            html = markdown(content["object"]["text"], link_prefix=link_prefix)
            blob_prefix = repo_url + "/blob/HEAD/"
            rendered_prefix = repo_url + "/tree/HEAD/"
            html = markdown(content["object"]["text"], link_prefix=[rendered_prefix, blob_prefix])
            return Markup(html)

        content = repo["plaintext"]
@@ -271,7 +272,8 @@
        override = try_html_readme(self.session, _hgsrht, user, repo_name)
        if override is not None:
            return override
        link_prefix = repo_url + "/raw/"
        blob_prefix = repo_url + "/raw/"
        rendered_prefix = repo_url + "/browse/"
        for readme_name in readme_names:
            r = self.session.get(f"{_hgsrht}/api/repos/{repo_name}/raw/{readme_name}",
@@ -279,7 +281,7 @@
            elif r.status_code != 200:
                raise Exception(r.text)
            return format_readme(r.text, readme_name, link_prefix)
            return format_readme(r.text, readme_name, link_prefix=[rendered_prefix, blob_prefix])
        return format_readme("")

    def create_repo(self, user, valid, visibility):
hub.sr.ht/patches: SUCCESS in 2m22s

[Prefix README links to rendered pages][0] from [Nolan Prescott][1]

[0]: https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/15845
[1]: mailto:mail@nprescott.com

✓ #362217 SUCCESS hub.sr.ht/patches/archlinux.yml https://builds.sr.ht/~sircmpwn/job/362217
✓ #362218 SUCCESS hub.sr.ht/patches/debian.yml    https://builds.sr.ht/~sircmpwn/job/362218
✓ #362216 SUCCESS hub.sr.ht/patches/alpine.yml    https://builds.sr.ht/~sircmpwn/job/362216

To git@git.sr.ht:~sircmpwn/hub.sr.ht
   64cd1e0..5c97b72  master -> master