against the upstream version of this module.
* lib/common.py
(TemplateData): Moved here...
* lib/ezt.py
...from here.
* lib/query.py,
* lib/viewvc.py
Import 'TemplateData' from 'common' now, and update references to this
relocated class.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2711 8cb11bc2-c004-0410-86c3-e597b4017df7
current only-use-the-most-recently-noticed formatter approach.
* lib/ezt.py
(Template._cmd_format): Rename 'printer' parameter to 'formatter'.
(_print_formatted): New helper function.
(_write_value): Now pop/restore the whole stack of formatters, and
use _print_formatted() to do the real output writing.
(Context.__init__): Rename 'printers' member to 'formatters'.
Consumers updated.
(_raw_formatter, _html_formatter, _uri_formatter): Renamed from
_raw_printer(), _html_printer(), and _uri_printer() respectively.
Consumers updated.
(_xml_formatter): New.
(_formatters): Renamed from _printers. Consumers updated.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2376 8cb11bc2-c004-0410-86c3-e597b4017df7
in all of its templated views. Do this with a custom, dictionary-like
class that prevents the creation of new keys after an initial
instantiation of keys and (possibly dummy) values.
* lib/ezt.py
(TemplateData): New.
* lib/viewvc.py
(common_template_data): Now return an ezt.TemplateData() object.
(make_comma_sep_list_string): New.
(markup_or_annotate): Use new ezt.TemplateData() interface now. Use
make_comma_sep_list_string() where applicable.
(view_roots, view_log, view_cvsgraph, view_diff, view_revision,
view_queryform, view_query): Use new ezt.TemplateData() interface now.
(view_directory): Use new ezt.TemplateData() interface now. Drop
'search_re_form' dictionary item.
* lib/query.py
(main): Use new ezt.TemplateData() interface now. While here, drop
'script_name' calculation (it isn't used).
* templates/include/dir_header.ezt
Display the search form if 'search_re_action' is set, not 'search_re_form'.
* docs/template-authoring-guide.html
Remove 'search_re_form'. Update 'search_re_action' description.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2123 8cb11bc2-c004-0410-86c3-e597b4017df7
(Template._cmd_for): Raise a more useful exception message when the
to-be-looped-over variable ain't a sequence.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2115 8cb11bc2-c004-0410-86c3-e597b4017df7
(Template._cmd_print): Raise a more helpful exception to give some
clues to template authors who tried to, say, print a sequence
reference.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2111 8cb11bc2-c004-0410-86c3-e597b4017df7
NOTE: This is not currently used in ViewVC. I needed it in another
piece of software, but wanted the tweaks to be publicly available
somewhere.
* lib/ezt.py
(FORMAT_URI, _uri_printer): New.
(_printers): Add mapping for new URI-formatting code.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1495 8cb11bc2-c004-0410-86c3-e597b4017df7
to the output, callbacks can also write formatted output (controlled by
[format] directives.) EZT now passes Context object arguments to callbacks
instead of file pointers, so more functionality can be exposed to Callbacks
in the future without loss of backwards compatibility.
Also make improvements to implementation of [format] so directives will
take effect in files included through variable references ([include path])
just like files included through string constants ([include "path"]).
And make it possible to specify custom format types (beyond "raw" "html"
"xml") with callbacks and without the need to modify ezt.py.
* lib/ezt.py
(__doc__): update documentation
(Template._printers, Template._cmd_print_html, Template._cmd_print_xml):
remove
(Template._parse, Template._cmd_format, Template._cmd_end_format,
_raw_printer, _html_printer, _printers): update [format] implementation
(Template.parse): update call to _parse
(Template.execute): update call to _execute
(Template.generate, Template._execute, Template._cmd_print,
Template._cmd_format, Template._cmd_include, Template._cmd_if_any,
Template._cmd_if_index, Template._cmd_is, Template._do_if,
Template._cmd_for, Template._cmd_define):
move file pointer into Context object
(_write_value): handle callbacks as printers and callbacks that use printers
(_context, Context): rename _context class to Context and fill out methods
since object is now exposed outside EZT as an interface for accessing EZT
functionality from callback functions
* lib/viewcvs.py
(MarkupPipeWrapper.__call__, MarkupShell.__call__):
update for new (futureproofed) callback implementation
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1252 8cb11bc2-c004-0410-86c3-e597b4017df7
like generator functions. This patch was attached to issue 201. I am the
author, but credit goes to Greg Stein for valuable feedback which allowed
me to simplify the initial implementation.
* lib/ezt.py
(Template.generate, Template._cmd_if_index, Template._cmd_for,
_get_value): replace ctx.for_index member with ctx.for_iterators
(_Iterator, OldIterator, _iter): new
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1243 8cb11bc2-c004-0410-86c3-e597b4017df7
Strict. Changes have been made in the EZT templates, the CSS files,
HTML code embedded in the Python files as well as in the help
files. The original code structure and design is the very same. No
other improvements have been made to the browser code and it still
uses the old layout tables to create the page grid.
Apart from the XHTML/CSS code changes, the patch adds an argument (-x
x) for CVSGraph in viewcvs.py in the view_cvsgraph function to tell
CVSGraph to generate XHTML code. For Mozilla/Firefox to recognize the
id attribute in the image map generated, the content-type must be set
to application/xhtml+xml (see
https://bugzilla.mozilla.org/show_bug.cgi?id=109445). This patch does
however not change the content-type, but uses an ugly hack to make the
CVSGraph output work in Mozilla with the current text/html
content-type: a name attribute is merged into the id attribute in the
map_name defined in the cvsgraph.conf.dist file.
The XHTML code does not contain the standard XML declaration, just the
XHTML 1.0 Strict Doctype. This is to keep ViewCVS as encoding agnostic
as before and let the browser decide which encoding to use. An XML
file without the encoding declared must be interpreted as UTF-8 (or
UTF-16 if the byte order mark is included).
* viewcvs/cvsgraph.conf.dist
Add name="" hack to the 'map_name' variable so Mozilla/Firefox will work.
* viewcvs/lib/ezt.py
XHTML-ize sample output.
* viewcvs/lib/viewcvs.py
XHTML-ize hard-coded output.
(view_cvsgraph): Pass "-x x" to cvsgraph to force XHTML production.
* viewcvs/lib/blame.py
* viewcvs/lib/debug.py
* viewcvs/lib/py2html.py
* viewcvs/lib/query.py
* viewcvs/lib/vclib/bincvs/__init__.py
* viewcvs/templates/annotate.ezt
* viewcvs/templates/diff.ezt
* viewcvs/templates/dir_alternate.ezt
* viewcvs/templates/directory.ezt
* viewcvs/templates/error.ezt
* viewcvs/templates/graph.ezt
* viewcvs/templates/log.ezt
* viewcvs/templates/log_table.ezt
* viewcvs/templates/markup.ezt
* viewcvs/templates/query.ezt
* viewcvs/templates/query_form.ezt
* viewcvs/templates/query_results.ezt
* viewcvs/templates/revision.ezt
* viewcvs/templates/roots.ezt
* viewcvs/templates/docroot/help_dirview.html
* viewcvs/templates/docroot/help_log.html
* viewcvs/templates/docroot/help_logtable.html
* viewcvs/templates/docroot/help_query.html
* viewcvs/templates/docroot/help_rootview.html
* viewcvs/templates/docroot/styles.css
* viewcvs/templates/include/branch.ezt
* viewcvs/templates/include/branch_form.ezt
* viewcvs/templates/include/diff_form.ezt
* viewcvs/templates/include/dir_footer.ezt
* viewcvs/templates/include/dir_header.ezt
* viewcvs/templates/include/file_header.ezt
* viewcvs/templates/include/footer.ezt
* viewcvs/templates/include/header.ezt
* viewcvs/templates/include/paging.ezt
* viewcvs/templates/include/sort.ezt
* viewcvs/templates/include/view_tag.ezt
XHTML-ize hard-coded output and templatized data.
* viewcvs/CHANGES
Note this change.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1109 8cb11bc2-c004-0410-86c3-e597b4017df7
- make substitution pattern implementation to use current format instead
of writing directly to output
- make it possible to pass python functions to ezt templates as simple
callbacks
- update documentation with information about callbacks, file pointers,
and the [format] directive
* lib/ezt.py
(__doc__):
update documentation
(_write_value):
add code to implement callbacks and substitution patterns
(Template._parse, Template._cmd_print, Templte._cmd_print_html):
update to work with changed _write_value function
(Template._cmd_subst):
removed, functionality moved into _write_value
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1088 8cb11bc2-c004-0410-86c3-e597b4017df7
* lib/viewcvs.py
(view_diff): Little comment fix.
* lib/vclib/svn_ra/__init__.py
(ChangedPath): Remove; use the one from vclib.svn.
* lib/ezt.py
Update to latest upstream version, but reapply "the LongType fix".
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1054 8cb11bc2-c004-0410-86c3-e597b4017df7
construct. Patch by James Henstridge <james@daa.com.au>, tweaked to
conform with Greg Stein's review, and stripped of the template changes
that made use of the new functionality by C. Michael Pilato (that's me).
* viewcvs/lib/ezt.py
import cStringIO, and failing that, import StringIO.
(_block_cmd_specs): Add 'define' to the list of block specs.
(Template.generate): Init defines member.
(Template._parse): Don't prepare references for 'define' commands.
(Template._cmd_define): New.
(_get_value): Look for items in the defines dictionary before
falling back to the data dictionary.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@832 8cb11bc2-c004-0410-86c3-e597b4017df7
Import LongType from types, too.
(_get_value): Handle conversion of LongType as well.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@806 8cb11bc2-c004-0410-86c3-e597b4017df7
Remove HTML-speak throughout. This module is quite useful for much
more than just HTML. Also:
(Template.__init__): Add 'compress_whitespace' parameter (defaulting
to 1) to control whether or not runs of whitespace are compressed.
(Template._parse): Only compress whitespace if the
compress_whitespace variable is non-zero.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@770 8cb11bc2-c004-0410-86c3-e597b4017df7
This is a minor improvement on ezt template syntax error reporting.
Added two examples of bad template syntax to doctest section of the
module docstring. Added doc string to the exception classes.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@524 8cb11bc2-c004-0410-86c3-e597b4017df7
in additional arguments to the target EZT file. The target file can
refer to the arguments as [arg0] thru [argN].
Example usage: [include "header.ezt" "annotate"]
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@418 8cb11bc2-c004-0410-86c3-e597b4017df7
as a formatting command. Prepare the arguments and pass them to the
new _cmd_format function.
_cmd_format splits up the format/value and then delivers it to the
output file with any potential substitutions.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@409 8cb11bc2-c004-0410-86c3-e597b4017df7
* [include] now uses the current template's directory as a base for
including other templates. Thus, you can [include "header.ezt"] to
refer to a header.ezt template in the same directory.
* _cmd_print() now looks for a "read" attribute on the value, to
determine whether it is a stream (rather than a simple string). It
can now copy a stream to the output.
* added a simple catch for unclosed blocks. It doesn't say *what* is
unclosed, but it will at least give you an error about it, rather
than quiet failure.
* [for] loops now iterate until the end of a list (determined
internally by the interpreter when an IndexError occurs), rather
than using len(list). This allows for lists of an indeterminate
length to be used.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@392 8cb11bc2-c004-0410-86c3-e597b4017df7
1) don't include the surrounded [ ] in the regex group, this avoids the need
to slice them off (the [1:-1] stuff)
2) use a new regex to properly parse the args: loose double quotes, strict
symbols.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@390 8cb11bc2-c004-0410-86c3-e597b4017df7
to be restrictive on what a refname can contain.
Add some basic tests for the parsing regex.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@388 8cb11bc2-c004-0410-86c3-e597b4017df7
* _prepare_ref() and _get_value() can now handle string constants
* change [is] processing to stop special-casing strings
* single quotes are not allowed, so simplify [include] parsing
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@381 8cb11bc2-c004-0410-86c3-e597b4017df7
account. Using this opportunity to update another not related
part of the module doc string.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@343 8cb11bc2-c004-0410-86c3-e597b4017df7
tasks. Add a bit of instrumentation for EZT template parsing.
Add whitespace reduction to EZT. On my box, this doubles the parse time of
directory.ezt from .03 to .06 seconds, and log.ezt from 0.047 to 0.1
seconds. (about double in both cases) My two samples showed a reduction in
the response size by about 25%.
Instrument the overall execution of ViewCVS to examine relative percentage
of template parsing.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@341 8cb11bc2-c004-0410-86c3-e597b4017df7
* Added much more "denglish" text to the module doc string!
Attention: The docstring is probably not yet DOC-SIG (DPS) compatible.
I lost track following the exciting work done there lately.
Please correct any bad english grammar. May be I will be able
to improve my english from reviewing your diffs <wink>.
* Reworked the initial (one-and-only) test case so far to include
at least one if block directive and fixed some typos.
* Added more doc strings to functions and methods.
* implemented an include directive. My implementation might not be very
elegant. I wanted to optimize the case, where the include
directive occurs within a for block, but the name of the include
file is a string constant. The include file is readed in only once then.
To be able do this I wanted to recursivly call the parse_file method
and append the returned 'program' to the 'program' assembled so far.
To do this, I renamed 'parse' and 'parse_file' into '_parse' and
'_parse_file' which return the program sequence instead of assigning
to instance attribute directly. To avoid a change in the interface,
I added two new wrapper methods 'parse' and 'parse_file', which
simply call these new private methods.
The other case (include filename given as a value reference) is
handled in a way similar to what was suggested by Greg: I added a
_cmd_include() method which will invoke _parse() and _execute()
each time again, if its execution is encountered. This however
will avoid (delay) reading the include file, if the directives
happens to be in an if or else clause, which is not executed.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@297 8cb11bc2-c004-0410-86c3-e597b4017df7
cleanup.
It was possible to do [for one.two], but it was impossible to refer to
[one.two] or [one.two.field]. The _get_value() function was only checking
the first part of the dotted name for use in an iteration.
We now maintain a stack of iterations in progress (in scope, basically).
When we prepare a value reference, we pass that list and do an up-front
check for the use of an iteration variable. The preparation returns the
starting point of the value lookup, and the rest of the attribute names.
(before, we returned a (refname, split-ref) tuple, now we return (refname,
start, rest-of-ref) tuple)
We also optimize _get_value() to use 'start' rather than ref[0] and 'rest'
rather than ref[1:] (i.e. skip an index and a slice).
The value-references in the code were changed to avoid tuple-unpacking and
just pass the whole reference to _get_value() (which does the unpacking as
part of its argument definition). This effectively hides most of the
internal format of a prepared value reference.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@253 8cb11bc2-c004-0410-86c3-e597b4017df7
did that anyways (except for one spot -- noted below)
*) In download_link(), open the window initially pointing at about:blank
rather than an *incorrect* URL (it didn't have amp_query). Using
about:blank will be faster anyways; and the TARGET stuff in the anchor
will direct it to the proper URL.
*) Add templates/log.ezt for the file-log page
*) Change view_log() to begin using the new template. It is now used for the
top portion of the file. (e.g. more work to do on the entries and bottom
portion of the page)
*) ezt.py now allows '/' in the directives (typically, for quoted stuff)
(this regex stuff really should be tweaked to allow just about anything
in the quoted portions)
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@247 8cb11bc2-c004-0410-86c3-e597b4017df7
statement, comparing the two values for equality. runs the first section if
they match, the else-section if they do not.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@216 8cb11bc2-c004-0410-86c3-e597b4017df7
it allows everything but the closing bracket.
Add some commentary for the regex since it is central to the operation of
the templating engine.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@215 8cb11bc2-c004-0410-86c3-e597b4017df7
directory page is generated via template.
* viewcvs.conf.dist, config.py: remove [text] options and defaults; those
values are now simply text within the template.
* viewcvs.py: load the template, define information to pass to it, and
invoke it.
* directory.ezt: template for the directory page (and top-level root
selection and module page).
* ezt.py: templating library from the "edna" project. no changes from the
HEAD in edna's cvs.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@213 8cb11bc2-c004-0410-86c3-e597b4017df7