~edwargix/git.sr.ht

567e8f34ec86483f16fe409ff0f15b6abc68c380 — Adnan Maolood 2 years ago 98568b1
Add forge and VCS meta tags

See https://sr.ht/~ancarda/vcs-autodiscovery/

References: https://todo.sr.ht/~sircmpwn/git.sr.ht/163
1 files changed, 16 insertions(+), 0 deletions(-)

M gitsrht/templates/repo.html
M gitsrht/templates/repo.html => gitsrht/templates/repo.html +16 -0
@@ 3,6 3,22 @@
{% if repo.visibility.value =='unlisted' %}
<meta name="robots" content="noindex">
{% endif %}
<meta name="vcs" content="git">
{% if default_branch %}
{% set default_branch_name = default_branch.raw_name.decode("utf-8", "replace")[len("refs/heads/"):] %}
<meta name="vcs:default-branch" content="{{default_branch_name}}">
{% endif %}
{# NOTE: unauthorized clone URLs should be listed first #}
{% for clone_url in (repo | clone_urls) %}
<meta name="vcs:clone" content="{{clone_url}}">
{% endfor %}
{% set project_root = root + url_for("repo.summary", owner=repo.owner.canonical_name, repo=repo.name) %}
<meta name="forge:summary" content="{{project_root}}">
<meta name="forge:dir" content="{{project_root}}/tree/{ref}/item/{path}">
<meta name="forge:file" content="{{project_root}}/tree/{ref}/item/{path}">
<meta name="forge:rawfile" content="{{project_root}}/blob/{ref}/{path}">
<meta name="forge:line" content="{{project_root}}/tree/{ref}/item/{path}#L{line}">

{# Man, this is lame #}
<meta name="go-import"
  content="{{domain}}/{{owner.canonical_name}}/{{repo.name}} git {{(repo | clone_urls)[0]}}">