grim/hgwebplus

Parents cf1b7d986f3b
Children 9aa6265f6650
give up on making http_clone_url smart and add an additional http_base_url keyword
--- a/src/hgwebplus.py Mon Nov 02 22:37:34 2020 -0600
+++ b/src/hgwebplus.py Mon Nov 02 23:05:59 2020 -0600
@@ -253,25 +253,19 @@
"""
ui = context.resource(mapping, b'ui')
- repo = context.resource(mapping, b'repo')
- uri = ui.config(b'web', b'http_clone_url', b'')
- if uri == b'':
- base = ui.config(b'web', b'http_base_url', b'')
+ return ui.config(b'web', b'http_clone_url', b'')
+
- if base != '':
- # remove the trailing slash
- if base.endswith(b'/'):
- base = base[:-1]
+def http_base_url(context, mapping):
+ """ http_base_url is a template keyword that outputs the configuration
+ value of `web.http_base_url`. It can be used in themes to make it
+ easier for users to clone repositories.
+ """
- # repo name
- reponame = list(repo.ui.paths)[0]
- if reponame.startswith(b'/'):
- reponame = reponame[1:]
+ ui = context.resource(mapping, b'ui')
- return base + b'/' + reponame
-
- return b''
+ return ui.config(b'web', b'http_base_url', b'')
def readme(context, mapping):
@@ -352,7 +346,8 @@
templatekeyword = registrar.templatekeyword(templater._proc._defaults)
- templatekeyword(b'http_clone_url', requires={b'ui', b'repo'})(http_clone_url)
+ templatekeyword(b'http_clone_url', requires={b'ui'})(http_clone_url)
+ templatekeyword(b'http_base_url', requires={b'ui'})(http_base_url)
templatekeyword(b'readme', requires={b'ctx', b'repo'})(readme)
templatekeyword(b'ssh_clone_url', requires={b'ui', b'repo'})(ssh_clone_url)