grim/hgwebplus

Parents f2ce0e4ea6ac
Children fcddd5cbac21
Add http_clone_url and ssh_clone_url template keywords. Fixes HGWEBPLUS-7.
  • +2 -0
    ChangeLog
  • +15 -6
    README.md
  • +24 -0
    src/hgwebplus.py
  • --- a/ChangeLog Sun May 17 05:28:54 2020 -0500
    +++ b/ChangeLog Sun May 17 06:00:49 2020 -0500
    @@ -3,6 +3,8 @@
    HGWEBPLUS-1.
    * Added title template keyword to output the value of web.title. Fixes
    HGWEBPLUS-5.
    + * Added http_clone_url and ssh_clone_url template keywords. Fixes
    + HGWEBPLUS-7.
    0.4.0: (2020-05-04)
    * Added a ChangeLog.
    --- a/README.md Sun May 17 05:28:54 2020 -0500
    +++ b/README.md Sun May 17 06:00:49 2020 -0500
    @@ -22,14 +22,13 @@
    ## Readme Rendering
    -The most notable feature is that a new template keyword named `readme` has been
    -added. Since this is a keyword, it can be used in any template. This keyword
    -will look for files named `README.md`, `README.txt`, and `README` in a case
    -insensitive fashion, and return their contents rendered with a Markdown
    -renderer.
    +Readme rendering is supported via a template keyword named `readme`. Since
    +this is a keyword, it can be used in any template. It will look for files
    +named `README.md`, `README.txt`, and `README` in a case insensitive fashion,
    +and return their contents rendered with a Markdown renderer.
    The Markdown rendering uses [mistune](https://pypi.org/project/mistune/) to
    -support Markdown. However, there is no styling associated witha this render.
    +support Markdown. However, there is no styling associated with this renderer.
    To do that, I recommend you use [sindresorhus's
    github-markdown-css](https://github.com/sindresorhus/github-markdown-css/) in
    your theme and adjust it accordingly.
    @@ -77,6 +76,16 @@
    configuration setting. This allows users to customize a title that themes
    can then render. It defaults to `Mercurial Repositories`.
    +## Clone URLS
    +
    +Previously there was no way for an administrator to tell a theme how to clone
    +the repositories. This meant that there was no interface a theme could build
    +to tell users how to clone a repository.
    +
    +To fix this, hgwebplus adds two new template keywords `http_clone_url` and
    +`ssh_clone_url`. These are controlled via the `web.http_clone_url` and
    +`web.ssh_clone_url` configuration settings.
    +
    # Issues
    If you have any issues with this extension, please file them at
    --- a/src/hgwebplus.py Sun May 17 05:28:54 2020 -0500
    +++ b/src/hgwebplus.py Sun May 17 06:00:49 2020 -0500
    @@ -244,6 +244,17 @@
    yield data
    +def http_clone_url(context, mapping):
    + """ http_clone_url is a template keyword that outputs the configuration
    + value of `web.http_clone_url`. It can be used in themes to make it
    + easier for users to clone repositories.
    + """
    +
    + ui = context.resource(mapping, b'ui')
    +
    + return ui.config(b'web', b'http_clone_url', b'')
    +
    +
    def readme(context, mapping):
    """ readme is a template keyword that will attempt to render a readme file
    that is available in the repository. It currently supports github
    @@ -286,6 +297,17 @@
    return ""
    +def ssh_clone_url(context, mapping):
    + """ ssh_clone_url is a template keyword that outputs the configuration
    + value of `web.ssh_clone_url`. It can be used in themes to make it
    + easier for users to clone repositories.
    + """
    +
    + ui = context.resource(mapping, b'ui')
    +
    + return ui.config(b'web', b'ssh_clone_url', b'')
    +
    +
    def title(context, mapping):
    """ title is a template keyword that outputs the configuration value of
    `web.title`. It defaults to `Mercurial Repositories`.
    @@ -306,7 +328,9 @@
    templatekeyword = registrar.templatekeyword(templater._proc._defaults)
    + templatekeyword(b'http_clone_url', requires={b'ui'})(http_clone_url)
    templatekeyword(b'readme', requires={b'ctx', b'repo'})(readme)
    + templatekeyword(b'ssh_clone_url', requires={b'ui'})(ssh_clone_url)
    templatekeyword(b'title', requires={b'ui'})(title)
    return templater