~edwargix/git.sr.ht

358b2d0f8ec39b80d641584e9cfbde8a060e6fc3 — Drew DeVault 8 years ago 25981d5
Hack, add clone URLs to cgit pages
2 files changed, 19 insertions(+), 3 deletions(-)

M gitsrht/blueprints/public.py
M gitsrht/templates/user.html
M gitsrht/blueprints/public.py => gitsrht/blueprints/public.py +17 -1
@@ 24,8 24,24 @@ def index():
@public.route("/~<user>/<repo>/<path:cgit_path>")
def cgit_passthrough(user, repo, cgit_path):
    r = requests.get("{}/{}".format(upstream, request.full_path))
    if r.status_code != 200:
        abort(r.status_code)
    base = cfg("network", "git").replace("http://", "").replace("https://", "")
    clone_urls = [
        "git@" + base + ":~{}/{}",
        "https://" + base + "/~{}/{}",
        "git://" + base + "/~{}/{}"
    ]
    clone_text = "<tr><td colspan='3'>" +\
        "<a rel='vcs-git' href='__CLONE_URL__' title='~{}/{} Git repository'>__CLONE_URL__</a>".format(user, repo) +\
        "</td></tr>"
    text = r.text.replace(
        clone_text,
        " ".join(["<tr><td colspan='3'><a href='{0}'>{0}</a></td></tr>".format(
            url.format(user, repo)) for url in clone_urls])
    )
    return render_template("cgit.html",
            cgit_html=r.text,
            cgit_html=text,
            owner_name="~" + user,
            repo_name=repo)


M gitsrht/templates/user.html => gitsrht/templates/user.html +2 -2
@@ 39,8 39,8 @@
      </form>
      {% for repo in repos %}
        <h4>
          <a href="/~{{current_user.username}}/{{repo.name}}">
            ~{{current_user.username}}/{{repo.name}}
          <a href="/~{{user.username}}/{{repo.name}}">
            ~{{user.username}}/{{repo.name}}
          </a>
          {% if repo.visibility.value != 'public' %}
          <small class="text-muted">