Commit Graph

38 Commits

Author SHA1 Message Date
Patrick Mezard
d297dd65c7 help: extract items doc generation function 2011-03-12 12:46:31 +01:00
Patrick Mezard
daf132553b templatefilters: move doc from templates.txt to docstrings 2011-03-12 12:46:31 +01:00
Patrick Mezard
456bc03d53 templatefilters: wrap all filters in dedicated functions
This will highly simplify the docstring integration. I measured "hg log
--style=changelog" duration on mercurial itself and could not detect any
difference.
2011-03-12 12:46:31 +01:00
Patrick Mezard
b7b401fb97 templatefilters: prefix helper functions 2011-03-12 12:46:31 +01:00
Patrick Mezard
7d70363658 templatefilters: sort function definitions 2011-03-12 12:46:31 +01:00
Patrick Mezard
9a81e9d084 templatefilters: match filter keys and function names 2011-03-12 12:46:31 +01:00
Patrick Mezard
be156e05ac templatefilters: sort filters table 2011-03-12 12:46:31 +01:00
Dan Villiom Podlaski Christiansen
9c75aee050 templater: add hex filter. 2010-09-22 00:14:57 +02:00
Patrick Mezard
cfb0a4943f templatefilters: unnest uescape() 2010-08-15 17:50:52 +02:00
Yuya Nishihara
f6cfbe6d14 templatefilters: use \uxxxx style escape for JSON string
It's embeddable in plain javascript, and also conforms to JSON standard.
2010-08-11 01:06:21 +09:00
Yuya Nishihara
aaffe8d6bf templatefilters: make json filter handle multibyte characters correctly
It aims to fix javascript error of hgweb's graph view in Japanese 'cp932'
encoding.

'cp932' contains multibyte characters ending with '\x5c' (backslash),
e.g. '\x94\x5c' for Japanese Kanji 'Noh'.
Due to json filter escapes '\' to '\\', multibyte string ending with
'\x5c' is translated to "xxx\", resulting javascript parse error on
a web browser.

This patch changes json() to pass unicode to jsonescape().

Unicode decoding error handler changed to 'replace' by Patrick Mézard.
2010-08-07 16:27:16 +09:00
FUJIWARA Katsunori
9cce255bec replace Python standard textwrap by MBCS sensitive one for i18n text
Mercurial has problem around text wrapping/filling in MBCS encoding
environment, because standard 'textwrap' module of Python can not
treat it correctly. It splits byte sequence for one character into two
lines.

According to unicode specification, "east asian width" classifies
characters into:

   W(ide), N(arrow), F(ull-width), H(alf-width), A(mbiguous)


W/N/F/H can be always recognized as 2/1/2/1 bytes in byte sequence,
but 'A' can not. Size of 'A' depends on language in which it is used.

Unicode specification says:

   If the context(= language) cannot be established reliably they
   should be treated as narrow characters by default

but many of class 'A' characters are full-width, at least, in Japanese
environment.

So, this patch treats class 'A' characters as full-width always for
safety wrapping.

This patch focuses only on MBCS safe-ness, not on writing/printing
rule strict wrapping for each languages

MBCS sensitive textwrap class is originally implemented
by ITO Nobuaki <daydream.trippers@gmail.com>.
2010-06-06 17:20:10 +09:00
Matt Mackall
0c7546ee5b templatefilters: fix check-code warning 2010-03-29 16:11:40 -05:00
Benoit Boissinot
10e5d90501 templatefilters: store the agescales in reverseorder directly 2010-03-06 13:29:54 +01:00
Matt Mackall
8d99be19f0 many, many trivial check-code fixups 2010-01-25 00:05:27 -06:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Dirkjan Ochtman
c08c589861 templater: readable dates older than 24 months revert to ISO8601 (issue1006) 2009-11-05 15:19:54 +01:00
Dirkjan Ochtman
2f9a035003 templater: put 'ago' inside the age template filter 2009-11-05 14:44:29 +01:00
Nicolas Dumazet
fbdff4820a templatefilters: indent: do not compute text.endswith('\n') in each iteration 2009-08-22 19:40:15 +02:00
Nicolas Dumazet
7eadbe8d42 for calls expecting bool args, pass bool instead of int
str.splitlines and email.message.as_string both expect a bool argument
defaulting at False: replace f(1) by f(True) and f(0) by f()
2009-07-13 09:50:26 +09:00
Alejandro Santos
3183e52503 compat: use // for integer division 2009-07-05 11:00:44 +02:00
Marco Beck
47e33d1f81 templater: retain author's full name if no email is supplied (issue1685) 2009-06-03 14:50:03 +02:00
Henrik Stuart
01c54d72e3 templatefilters: add filter to convert date to local date (issue1674)
Issue1674 suggests the localdate filter be applied as default to log,
but this patch only introduces the filter, not the changed default
behaviour.
2009-05-24 11:41:07 +02:00
Peter Arrenbrecht
a75765cf7f drop unused imports 2009-05-14 15:35:46 +02:00
Peter Arrenbrecht
3d9bf2f616 indentation cleanup 2009-05-14 15:24:36 +02:00
Dirkjan Ochtman
5c6c43b746 templater: provide the standard template filters by default 2009-05-12 12:04:05 +02:00
Rocco Rutte
9aa9232b09 templatefilters: add "nonempty" template filter
It ensures that at least "(none)" is returned in case the argument
passed is None or ''. This is primarily useful to render empty
changelog messages for hgweb but may be useful for others, too.
2009-04-20 11:34:15 +02:00
Martin Geisler
750183bdad updated license to be explicit about GPL version 2 2009-04-26 01:08:54 +02:00
Aleix Conchillo Flaque
95a32f54b8 templatefilters: add new stripdir filter
Adds a new template filter for removing directory levels from a
string. Examples:

{foo|stripdir} -> 'foo'
{foo/bar|stripdir} -> 'foo'
{foo/bar/more|stripdir} -> 'foo/bar'
{foo/bar/more|stripdir|stripdir} -> 'foo'
2009-04-24 18:37:44 +02:00
Dirkjan Ochtman
813ed2656a templatefilters: split out jsonescape() function 2009-04-06 10:51:45 +02:00
Matt Mackall
642f4d7151 move encoding bits from util to encoding
In addition to cleaning up util, this gets rid of some circular dependencies.
2009-04-03 14:51:48 -05:00
Dirkjan Ochtman
4e4940dc82 templater: fix age filter to state the obvious on future timestamps 2009-01-22 16:07:44 +01:00
Dirkjan Ochtman
4f94568371 add graph page to hgweb 2008-06-18 07:06:41 +02:00
Giorgos Keramidas
54f4ca2511 Add an {isodatesec} template, to show seconds too. 2008-03-17 19:17:54 +02:00
Matt Mackall
555abf8390 dates: improve timezone handling
datestr:
- add format specifiers %1 and %2 for timezone hours and minutes
- remove timezone and timezone format options
- correctly find timezone hours and minutes for fractional and negative timezones
- update users

strdate:
- correctly find timezone hours and minutes for fractional and negative timezones
2008-03-11 17:42:41 -05:00
Jesse Glick
cf2fd9f31a Permit XML entities to be escaped in template output.
Useful for creating XML documents directly from Hg logging. Can also be used for
HTML. For use in content, will escape '&', '<', and for completeness '>'
(although it is not strictly necessary). For use in attributes, will also escape
' and ". Will also replace nonprinting (ASCII) control characters with spaces,
since these are illegal in XML.
2008-01-28 22:19:12 -05:00
Thomas Arendsen Hein
728ba019da Make annotae/grep print short dates with -q/--quiet.
Move shortdate() from templatefilters to util to avoid code duplication.
2008-02-16 13:33:38 +01:00
Matt Mackall
41e5c79455 templates: move filters to their own module
This eliminates just about all Mercurial dependencies in templater.py
2008-01-31 14:44:19 -06:00