Submitter | Angel Ezquerra |
---|---|
Date | Feb. 9, 2013, 10:02 a.m. |
Message ID | <0ca84e16d89af5c0125d.1360404123@Angel-PC.localdomain> |
Download | mbox | patch |
Permalink | /patch/857/ |
State | Superseded, archived |
Headers | show |
Comments
On 02/09/2013 11:02 AM, Angel Ezquerra wrote: > # HG changeset patch > # User Angel Ezquerra <angel.ezquerra@gmail.com> > # Date 1360363571 -3600 > # Node ID 0ca84e16d89af5c0125d19e741605caca09da49f > # Parent d2fe4130209f6877d841926df79ba02842c83e20 > hgweb, templates: 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>/ > bugzilla = s!((?:bug|b=|(?=#?\d{4,}))(?:\s*#?)(\d+))!<a href="http://bz.selenic.com/\2">\1</a>!i This should be documented in mercurial/help/config.txt . I assume these template changes also has some intentional and accidental changes to the test results? /Mads
On Sat, Feb 9, 2013 at 11:28 AM, Mads Kiilerich <mads@kiilerich.com> wrote: > On 02/09/2013 11:02 AM, Angel Ezquerra wrote: >> >> # HG changeset patch >> # User Angel Ezquerra <angel.ezquerra@gmail.com> >> # Date 1360363571 -3600 >> # Node ID 0ca84e16d89af5c0125d19e741605caca09da49f >> # Parent d2fe4130209f6877d841926df79ba02842c83e20 >> hgweb, templates: 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>/ >> bugzilla = s!((?:bug|b=|(?=#?\d{4,}))(?:\s*#?)(\d+))!<a >> href="http://bz.selenic.com/\2">\1</a>!i > > > This should be documented in mercurial/help/config.txt . > > I assume these template changes also has some intentional and accidental > changes to the test results? > > /Mads > I resent a new version that adds the documentation. I also ran the hgweb tests and everything seems fine: $ ./run-tests.py test-hgweb*.t ............. # Ran 13 tests, 0 skipped, 0 failed. Angel
Patch
diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py +++ b/mercurial/hgweb/hgweb_mod.py @@ -8,12 +8,14 @@ import os from mercurial import ui, hg, hook, error, encoding, templater, util, repoview -from mercurial import templatefilters +from mercurial.templatefilters import websub +from mercurial.i18n import _ from common import get_stat, ErrorResponse, permhooks, caching from common import HTTP_OK, HTTP_NOT_MODIFIED, HTTP_BAD_REQUEST from common import HTTP_NOT_FOUND, HTTP_SERVER_ERROR from request import wsgirequest -import webcommands, protocol, webutil +import webcommands, protocol, webutil, re + perms = { 'changegroup': 'pull', @@ -50,10 +52,6 @@ urlel = os.path.dirname(urlel) return reversed(breadcrumb) -from mercurial.i18n import _ -import re -websubtable = [] - class hgweb(object): def __init__(self, repo, name=None, baseui=None): if isinstance(repo, str): @@ -355,7 +353,7 @@ # create the templater tmpl = templater.templater(mapfile, - filters={"websub": lambda text: templatefilters.websub(text, self.websubtable)}, + filters={"websub": lambda text: websub(text, self.websubtable)}, defaults={"url": req.url, "logourl": logourl, "logoimg": logoimg, diff --git a/mercurial/templates/gitweb/changelogentry.tmpl b/mercurial/templates/gitweb/changelogentry.tmpl --- a/mercurial/templates/gitweb/changelogentry.tmpl +++ b/mercurial/templates/gitweb/changelogentry.tmpl @@ -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> diff --git a/mercurial/templates/gitweb/changeset.tmpl b/mercurial/templates/gitweb/changeset.tmpl --- a/mercurial/templates/gitweb/changeset.tmpl +++ b/mercurial/templates/gitweb/changeset.tmpl @@ -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"> diff --git a/mercurial/templates/gitweb/fileannotate.tmpl b/mercurial/templates/gitweb/fileannotate.tmpl --- a/mercurial/templates/gitweb/fileannotate.tmpl +++ b/mercurial/templates/gitweb/fileannotate.tmpl @@ -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> diff --git a/mercurial/templates/gitweb/filerevision.tmpl b/mercurial/templates/gitweb/filerevision.tmpl --- a/mercurial/templates/gitweb/filerevision.tmpl +++ b/mercurial/templates/gitweb/filerevision.tmpl @@ -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"> diff --git a/mercurial/templates/monoblue/changelogentry.tmpl b/mercurial/templates/monoblue/changelogentry.tmpl --- a/mercurial/templates/monoblue/changelogentry.tmpl +++ b/mercurial/templates/monoblue/changelogentry.tmpl @@ -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> diff --git a/mercurial/templates/monoblue/changeset.tmpl b/mercurial/templates/monoblue/changeset.tmpl --- a/mercurial/templates/monoblue/changeset.tmpl +++ b/mercurial/templates/monoblue/changeset.tmpl @@ -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} diff --git a/mercurial/templates/monoblue/fileannotate.tmpl b/mercurial/templates/monoblue/fileannotate.tmpl --- a/mercurial/templates/monoblue/fileannotate.tmpl +++ b/mercurial/templates/monoblue/fileannotate.tmpl @@ -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} diff --git a/mercurial/templates/monoblue/filerevision.tmpl b/mercurial/templates/monoblue/filerevision.tmpl --- a/mercurial/templates/monoblue/filerevision.tmpl +++ b/mercurial/templates/monoblue/filerevision.tmpl @@ -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} diff --git a/mercurial/templates/paper/changeset.tmpl b/mercurial/templates/paper/changeset.tmpl --- a/mercurial/templates/paper/changeset.tmpl +++ b/mercurial/templates/paper/changeset.tmpl @@ -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> diff --git a/mercurial/templates/paper/fileannotate.tmpl b/mercurial/templates/paper/fileannotate.tmpl --- a/mercurial/templates/paper/fileannotate.tmpl +++ b/mercurial/templates/paper/fileannotate.tmpl @@ -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> diff --git a/mercurial/templates/paper/filecomparison.tmpl b/mercurial/templates/paper/filecomparison.tmpl --- a/mercurial/templates/paper/filecomparison.tmpl +++ b/mercurial/templates/paper/filecomparison.tmpl @@ -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> diff --git a/mercurial/templates/paper/filediff.tmpl b/mercurial/templates/paper/filediff.tmpl --- a/mercurial/templates/paper/filediff.tmpl +++ b/mercurial/templates/paper/filediff.tmpl @@ -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> diff --git a/mercurial/templates/paper/filerevision.tmpl b/mercurial/templates/paper/filerevision.tmpl --- a/mercurial/templates/paper/filerevision.tmpl +++ b/mercurial/templates/paper/filerevision.tmpl @@ -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> diff --git a/mercurial/templates/spartan/changeset.tmpl b/mercurial/templates/spartan/changeset.tmpl --- a/mercurial/templates/spartan/changeset.tmpl +++ b/mercurial/templates/spartan/changeset.tmpl @@ -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> diff --git a/mercurial/templates/spartan/fileannotate.tmpl b/mercurial/templates/spartan/fileannotate.tmpl --- a/mercurial/templates/spartan/fileannotate.tmpl +++ b/mercurial/templates/spartan/fileannotate.tmpl @@ -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> diff --git a/mercurial/templates/spartan/filerevision.tmpl b/mercurial/templates/spartan/filerevision.tmpl --- a/mercurial/templates/spartan/filerevision.tmpl +++ b/mercurial/templates/spartan/filerevision.tmpl @@ -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>