Mercurial > hg
changeset 18628:52305554fd6e
hgweb: apply the websub filter to revision descriptions
In order to use this, add a [websub] section to your configuration and add
websub expressions such as:
italic = s/\b_(\S+)_\b/<i>\1<\/i>/
bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
bugzilla = s!((?:bug|b=|(?=#?\d{4,}))(?:\s*#?)(\d+))!<a href="http://bz.selenic.com/\2">\1</a>!i
This also adds documentation (proofed by Kevin!) to the config help section.
author | Angel Ezquerra <angel.ezquerra@gmail.com> |
---|---|
date | Sat, 09 Feb 2013 16:48:21 +0100 |
parents | 4e949b8e0930 |
children | 013fcd112f13 |
files | mercurial/help/config.txt mercurial/templates/gitweb/changelogentry.tmpl mercurial/templates/gitweb/changeset.tmpl mercurial/templates/gitweb/fileannotate.tmpl mercurial/templates/gitweb/filerevision.tmpl mercurial/templates/monoblue/changelogentry.tmpl mercurial/templates/monoblue/changeset.tmpl mercurial/templates/monoblue/fileannotate.tmpl mercurial/templates/monoblue/filerevision.tmpl mercurial/templates/paper/changeset.tmpl mercurial/templates/paper/fileannotate.tmpl mercurial/templates/paper/filecomparison.tmpl mercurial/templates/paper/filediff.tmpl mercurial/templates/paper/filerevision.tmpl mercurial/templates/spartan/changeset.tmpl mercurial/templates/spartan/fileannotate.tmpl mercurial/templates/spartan/filerevision.tmpl |
diffstat | 17 files changed, 49 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/help/config.txt Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/help/config.txt Sat Feb 09 16:48:21 2013 +0100 @@ -1463,3 +1463,36 @@ ``templates`` Where to find the HTML templates. Default is install path. + +``websub`` +---------- + +Web substitution filter definition. You can use this section to +define a set of regular expression substitution patterns which +let you automatically modify the hgweb server output. + +The default hgweb templates only apply these substitution patterns +on the revision description fields. You can apply them anywhere +you want when you create your own templates by adding calls to the +"websub" filter (usually after calling the "escape" filter). + +This can be used, for example, to convert issue references to links +to your issue tracker, or to convert "markdown-like" syntax into +HTML (see the examples below). + +Each entry in this section names a substitution filter. +The value of each entry defines the substitution expression itself. +The websub expressions follow the old interhg extension syntax, +which in turn imitates the Unix sed replacement syntax:: + + pattername = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i] + +You can use any separator other than "/". The final "i" is optional +and indicates that the search must be case insensitive. + +Examples:: + + [websub] + issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i + italic = s/\b_(\S+)_\b/<i>\1<\/i>/ + bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
--- a/mercurial/templates/gitweb/changelogentry.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/gitweb/changelogentry.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -8,7 +8,7 @@ <i>{author|obfuscate} [{date|rfc822date}] rev {rev}</i><br/> </div> <div class="log_body"> -{desc|strip|escape|addbreaks|nonempty} +{desc|strip|escape|websub|addbreaks|nonempty} <br/> <br/> </div>
--- a/mercurial/templates/gitweb/changeset.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/gitweb/changeset.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -41,7 +41,7 @@ </table></div> <div class="page_body"> -{desc|strip|escape|addbreaks|nonempty} +{desc|strip|escape|websub|addbreaks|nonempty} </div> <div class="list_head"></div> <div class="title_text">
--- a/mercurial/templates/gitweb/fileannotate.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/gitweb/fileannotate.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -56,7 +56,7 @@ </div> <div class="page_path"> -{desc|strip|escape|addbreaks|nonempty} +{desc|strip|escape|websub|addbreaks|nonempty} </div> <div class="page_body"> <table>
--- a/mercurial/templates/gitweb/filerevision.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/gitweb/filerevision.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -56,7 +56,7 @@ </div> <div class="page_path"> -{desc|strip|escape|addbreaks|nonempty} +{desc|strip|escape|websub|addbreaks|nonempty} </div> <div class="page_body">
--- a/mercurial/templates/monoblue/changelogentry.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/monoblue/changelogentry.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -2,5 +2,5 @@ <ul class="changelog-entry"> <li class="age">{date|rfc822date}</li> <li>by <span class="name">{author|obfuscate}</span> <span class="revdate">[{date|rfc822date}] rev {rev}</span></li> - <li class="description">{desc|strip|escape|addbreaks|nonempty}</li> + <li class="description">{desc|strip|escape|websub|addbreaks|nonempty}</li> </ul>
--- a/mercurial/templates/monoblue/changeset.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/monoblue/changeset.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -52,7 +52,7 @@ {child%changesetchild} </dl> - <p class="description">{desc|strip|escape|addbreaks|nonempty}</p> + <p class="description">{desc|strip|escape|websub|addbreaks|nonempty}</p> <table> {files}
--- a/mercurial/templates/monoblue/fileannotate.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/monoblue/fileannotate.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -57,7 +57,7 @@ <dd>{permissions|permissions}</dd> </dl> - <p class="description">{desc|strip|escape|addbreaks|nonempty}</p> + <p class="description">{desc|strip|escape|websub|addbreaks|nonempty}</p> <table class="annotated"> {annotate%annotateline}
--- a/mercurial/templates/monoblue/filerevision.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/monoblue/filerevision.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -57,7 +57,7 @@ <dd>{permissions|permissions}</dd> </dl> - <p class="description">{desc|strip|escape|addbreaks|nonempty}</p> + <p class="description">{desc|strip|escape|websub|addbreaks|nonempty}</p> <div class="source"> {text%fileline}
--- a/mercurial/templates/paper/changeset.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/paper/changeset.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -40,7 +40,7 @@ files, or words in the commit message</div> </form> -<div class="description">{desc|strip|escape|nonempty}</div> +<div class="description">{desc|strip|escape|websub|nonempty}</div> <table id="changesetEntry"> <tr>
--- a/mercurial/templates/paper/fileannotate.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/paper/fileannotate.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -46,7 +46,7 @@ files, or words in the commit message</div> </form> -<div class="description">{desc|strip|escape|nonempty}</div> +<div class="description">{desc|strip|escape|websub|nonempty}</div> <table id="changesetEntry"> <tr>
--- a/mercurial/templates/paper/filecomparison.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/paper/filecomparison.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -45,7 +45,7 @@ files, or words in the commit message</div> </form> -<div class="description">{desc|strip|escape|nonempty}</div> +<div class="description">{desc|strip|escape|websub|nonempty}</div> <table id="changesetEntry"> <tr>
--- a/mercurial/templates/paper/filediff.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/paper/filediff.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -45,7 +45,7 @@ files, or words in the commit message</div> </form> -<div class="description">{desc|strip|escape|nonempty}</div> +<div class="description">{desc|strip|escape|websub|nonempty}</div> <table id="changesetEntry"> <tr>
--- a/mercurial/templates/paper/filerevision.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/paper/filerevision.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -44,7 +44,7 @@ files, or words in the commit message</div> </form> -<div class="description">{desc|strip|escape|nonempty}</div> +<div class="description">{desc|strip|escape|websub|nonempty}</div> <table id="changesetEntry"> <tr>
--- a/mercurial/templates/spartan/changeset.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/spartan/changeset.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -39,7 +39,7 @@ </tr> <tr> <th class="description">description:</th> - <td class="description">{desc|strip|escape|addbreaks|nonempty}</td> + <td class="description">{desc|strip|escape|websub|addbreaks|nonempty}</td> </tr> </table>
--- a/mercurial/templates/spartan/fileannotate.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/spartan/fileannotate.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -38,7 +38,7 @@ </tr> <tr> <td class="metatag">description:</td> - <td>{desc|strip|escape|addbreaks|nonempty}</td> + <td>{desc|strip|escape|websub|addbreaks|nonempty}</td> </tr> </table>
--- a/mercurial/templates/spartan/filerevision.tmpl Fri Feb 08 18:05:32 2013 +0100 +++ b/mercurial/templates/spartan/filerevision.tmpl Sat Feb 09 16:48:21 2013 +0100 @@ -36,7 +36,7 @@ <td>{permissions|permissions}</td></tr> <tr> <td class="metatag">description:</td> - <td>{desc|strip|escape|addbreaks|nonempty}</td> + <td>{desc|strip|escape|websub|addbreaks|nonempty}</td> </tr> </table>