I have enqued the task to prepare the files/patch. I need to do some
repacking/renaming to match the current TR/VL state.
Should the files/patches be targetted to VL instead of turbine?
The tools are designed to be able to write better controlling
templates in VTL - similar, as stated, as the texen ANT task.
Therefore I (and, sooner or later, others) need some more
programming power reachable within VTL...
The JDOM support (from anakia) is an extremely valuable addition
to VL, now complex structures can be defined/configured (which I
initially defined as a hierarchy of hashtables...).
More soon...
:) Christoph
Sean Legassick wrote:
>
> On Thu, Nov 09, 2000 at 06:43:53PM +0100, Christoph Reck wrote:
> > Hi,
> >
> > for our application I have created several context tools that
> > would be generally reusable. This could avoid re-inventing the
> > wheel in future applications.
>
> Hi Christoph,
>
> Lots of this looks very useful indeed, it would be great if you could
> put these together as patches for the org.apache.turbine.util.template
> directory, and send them to me if you like and they're too big too post
> here.
>
> For what it's worth, I would say that some of the methods you offer are a
> bit over-powered. Core to the WebMacro/Velocity philosophy is keeping
> the programming out of the templates, and I think some of these
> facilities are moving away from that....
>
> > Please vote for each tool and let me know to whoom I should send
> > the files (as attachments) to add to the CVS. Please give me
> > suggestions to the package path where these should be placed
> > (e.g. org.apache.turbine.util.template).
> >
> > The ContextTool.java contains several methods that should have
> > been in the WebMacroFormatter (and the VelocityFormater) -
> > these run in the flavour of the isNull. I am willing to
> > send these as a patch for the WM and VL formatters.
> > ----------------------- ContextTool.java -----------------------
> > * Provides transparent access to the container of the
> > * Context hashtable (e.g. for debug dump).
> > Context getContext()
> >
> > * Removes a variable from the web context. This allows
> > * cleaning up after doing a local set in a template
> > * <code>
> > * #set $abc = "def"
> > * ## ... do something with the local variable
> > * $formatter.contextRemove("abc")
> > * </code>.
> > String contextRemove(String contextVarName)
> >
> > * Removes a set of variables from the web context.
> > String contextRemove(Object[] contextVarNames)
> >
> > * Translates a string into <code>x-www-form-urlencoded</code> format.
> > * This method is just a wrapper to java.net.URLEncoder.encode().
> > String URLEncode(String str)
> >
> > * Encode the characters <, >, " and & to
> > * &lt;, &gt;, &quot, &amp; respectively.<br>
> > * This allows safely to use
> > * <code><input type="text"
>value="$formater.encodeMarkup($anyText)"></code>
> > String encodeMarkup(String text)
> >
> > * Encode space to + and any non alphanumeric character to %XX.
> > String formEncode(String text) throws Exception
> >
> > * Decode space from + and %XX to its character from.
> > String formDecode(String s)
> >
> > * Encodes any non alphanumeric character from a string to make
> > * it usable as a form variable. Any non alphanumeric is deleted
> > * from the string and the following character is uppercased.
> > * A following second non alphanumerics is changed to a '_'.
> > * A string starting with a numeric is prefixed with a '_'. <p>
> > * Example <code>1abc.def*.ghi</code> gets converted to
> > * <code>_1abcDef_Ghi</code>.
> > String encodeToName(String text)
> >
> > * Convenience function to check for alphanumeric characters.
> > * Also used by the above methods.
> > boolean isAlphaNumeric(char c)
> >
> > * Parses the parameters to find if there is a key with the
> > * specified value (when the pp has multiple values for the key).
> > boolean hasValue(ParameterParser pp, String key, String value)
> >
> > * Convenience function to create an <code>java.lang.Vector</code>
> > * within a template.
> > Vector newVector(int size)
> >
> > * Convenience function to create an <code>java.lang.Hashtable</code>
> > * within a template.
> > Hashtable newHashtable(int size)
> >
> > * Convenience function to create an empty array within a template.<br>
> > * This can be used as a for-loop replacement:<code>
> > * #set $index = 0
> > * #foreach ($dummy in $formatter.newArray(10))
> > * index = $index
> > * #set $index = $Math.sum($index, 1)
> > * #end</code>
> > Object newArray(int size)
> >
> > * Convenience function to access an element of an array
> > Object getElement(int index, Object[] array)
> >
> >
> > The MathTool.java is there currently since VL and WM do not
> > support (simple) equations within #set directives.
> > ----------------------- MathTool.java -----------------------
> > int sum(int value1, int value2)
> > int sub(int value1, int value2)
> > int max(int value1, int value2)
> > int min(int value1, int value2)
> > boolean gt(int value1, int value2)
> > boolean lt(int value1, int value2)
> >
> > The FileTool.java provides simple access to file and directory
> > contents - since the #parse directive does not allow slurping
> > the data into a variable. It could be enahnced to only allow
> > access only via ServletContext.getRealPath (I know
> > fileRead("/etc/passwd") is uncool :) but it may be allowed
> > to the template designer.
> > ----------------------- FileTool.java -----------------------
> > String dirname(String filename)
> > String basename(String filename)
> > String basename(String filename, String suffix)
> > boolean fileExists(String fileName)
> > String fileRead(String fileName) throws Exception
> > Vector dirRead(String dirName, final String regexp)
> >
> > The ClassTool.java allows instantiating any java class
> > within a template to do more that just variable access.
> > This class is a candidate for VL texen - where there is
> > a controller that sets up the context for the output template
> > (my Trubine application also uses such a controller template).
> > ----------------------- ClassTool.java -----------------------
> > Object newInstance(String className) throws Exception
> > Object newInstance(String className, Object param)
> > Object newInstance(String className, Object[] params)
> > Constructor getConstructor(Class cls, Object[] params)
> >
> > This might be to propietary, but I was not satisfied with the
> > date formatting within WebMacroFormatter (and VelocityFormater).
> > Maybe these should be patched to allow setting a propietary
> > date format string (see http://www.w3.org/TR/NOTE-datetime).
> > I wolunteer to do the patching if others vote for it.
> > ----------------------- IsoDateTool.java -----------------------
> > String formatDate(Date date)
> > String formatDateTime(Date date)
> > String formatDateTimeShort(Date date)
> > String formatDateTimeLong(Date date)
> > Date dateFromString(String isoDateTime)
> > Date getDate()
> >
> > This is a special tool to run scripts within templates (e.g.
> > i'm using it to slurp in the environment variables into the
> > template to access files relative to these).
> > ----------------------- ScriptTool.java -----------------------
> > ProcessControl call(String command)
> > void ProcessControl.kill()
> > boolean ProcessControl.isRunning()
> > String ProcessControl.getStdout(boolean flush)
> > String ProcessControl.getStderr(boolean flush)
> > int ProcessControl.getStatus()
> >
> >
> > Please give me your votes!
> >
> > :) Christoph
--
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]