grim/hgwebplus

Add a title keyword. Fixes HGWEBPLUS-5

2020-05-17, Gary Kramlich
f2ce0e4ea6ac
Parents 37c96b2be81d
Children 51a54b660a8c
Add a title keyword. Fixes HGWEBPLUS-5
  • +2 -0
    ChangeLog
  • +6 -0
    README.md
  • +11 -0
    src/hgwebplus.py
  • --- a/ChangeLog Sun May 17 04:27:45 2020 -0500
    +++ b/ChangeLog Sun May 17 05:28:54 2020 -0500
    @@ -1,6 +1,8 @@
    0.5.0:
    * Switched to mistune for markdown rendering to fix images. Fixes
    HGWEBPLUS-1.
    + * Added title template keyword to output the value of web.title. Fixes
    + HGWEBPLUS-5.
    0.4.0: (2020-05-04)
    * Added a ChangeLog.
    --- a/README.md Sun May 17 04:27:45 2020 -0500
    +++ b/README.md Sun May 17 05:28:54 2020 -0500
    @@ -71,6 +71,12 @@
    ![diffstat example](images/diffstat.png)
    +## Title
    +
    +Title is a new tempate keyword that will output the value of the `web.title`
    +configuration setting. This allows users to customize a title that themes
    +can then render. It defaults to `Mercurial Repositories`.
    +
    # Issues
    If you have any issues with this extension, please file them at
    --- a/src/hgwebplus.py Sun May 17 04:27:45 2020 -0500
    +++ b/src/hgwebplus.py Sun May 17 05:28:54 2020 -0500
    @@ -286,6 +286,16 @@
    return ""
    +def title(context, mapping):
    + """ title is a template keyword that outputs the configuration value of
    + `web.title`. It defaults to `Mercurial Repositories`.
    + """
    +
    + ui = context.resource(mapping, b'ui')
    +
    + return ui.config(b'web', b'title', b'Mercurial Repositories')
    +
    +
    def repo_custom_templater(orig, self, req):
    """ this function is a wrapper of hgweb_mod.requestcontext.templater. This
    is done to be able to add custom keywords into hgweb. This is not an
    @@ -297,6 +307,7 @@
    templatekeyword = registrar.templatekeyword(templater._proc._defaults)
    templatekeyword(b'readme', requires={b'ctx', b'repo'})(readme)
    + templatekeyword(b'title', requires={b'ui'})(title)
    return templater