[xwiki-devs] Velocity and HTML indentations (was Re: [xwiki-notifications] r25217 - platform/web/trunk/standard/src/main/webapp/templates)
On Nov 19, 2009, at 3:53 PM, tmortagne (SVN) wrote:
Author: tmortagne Date: 2009-11-19 15:53:25 +0100 (Thu, 19 Nov 2009) New Revision: 25217
Modified: platform/web/trunk/standard/src/main/webapp/templates/rightsUI.vm Log: [cleanup] Apply codestyle
Modified: platform/web/trunk/standard/src/main/webapp/templates/ rightsUI.vm =================================================================== --- platform/web/trunk/standard/src/main/webapp/templates/ rightsUI.vm 2009-11-19 14:43:57 UTC (rev 25216) +++ platform/web/trunk/standard/src/main/webapp/templates/ rightsUI.vm 2009-11-19 14:53:25 UTC (rev 25217) @@ -110,15 +110,15 @@ </tr> <tr id="usersandgroupstable-filters"> <td>$msg.get("rightsmanager.searchfilter") <input name="name" type="text" style="width:65%"/> - #if($context.database != "xwiki") #set($mainwk = false) #else #set($mainwk = true) #end - #if(!$mainwk) ## display the combobox only in a local wiki + #if(!$context.isMainWiki()) #set($mainwk = false) #else #set($mainwk = true) #end + #if(!$mainwk) ## display the combobox only in a local wiki <select name="wiki" style="margin-left:10px;">
This will create some extra spaces in the generated HTML. It would be great if we could find a way to have nice indentation and nice generated HTML output too. I tried to imagine a good solution and couldn't so far (apart from running the generated HTML to a pretty printer but this is going to cause some overhead - Maybe it's minor enough to do it though). We could also have our own pre-processor that would remove spaces at beginning of velocity lines (as we're doing in the {{velocity}} macro) WDYT? Thanks -Vincent
<option value="local" selected="selected"> $msg.get("rightsmanager.local")</option> <option value="global"> $msg.get("rightsmanager.global")</option> <option value="both"> $msg.get("rightsmanager.both")</option> </select> - #else<input type="hidden" name="wiki" value="local"/>#end - #set($colsp = $maxlevel + 1) + #else<input type="hidden" name="wiki" value="local"/>#end + #set($colsp = $maxlevel + 1) </td> <td colspan="$colsp"><input type="hidden" name="clsname" value="$clsname" /></td> </tr>
On Thu, Nov 19, 2009 at 15:57, Vincent Massol <[email protected]> wrote:
On Nov 19, 2009, at 3:53 PM, tmortagne (SVN) wrote:
Author: tmortagne Date: 2009-11-19 15:53:25 +0100 (Thu, 19 Nov 2009) New Revision: 25217
Modified: platform/web/trunk/standard/src/main/webapp/templates/rightsUI.vm Log: [cleanup] Apply codestyle
Modified: platform/web/trunk/standard/src/main/webapp/templates/ rightsUI.vm =================================================================== --- platform/web/trunk/standard/src/main/webapp/templates/ rightsUI.vm 2009-11-19 14:43:57 UTC (rev 25216) +++ platform/web/trunk/standard/src/main/webapp/templates/ rightsUI.vm 2009-11-19 14:53:25 UTC (rev 25217) @@ -110,15 +110,15 @@ </tr> <tr id="usersandgroupstable-filters"> <td>$msg.get("rightsmanager.searchfilter") <input name="name" type="text" style="width:65%"/> - #if($context.database != "xwiki") #set($mainwk = false) #else #set($mainwk = true) #end - #if(!$mainwk) ## display the combobox only in a local wiki + #if(!$context.isMainWiki()) #set($mainwk = false) #else #set($mainwk = true) #end + #if(!$mainwk) ## display the combobox only in a local wiki <select name="wiki" style="margin-left:10px;">
This will create some extra spaces in the generated HTML. It would be great if we could find a way to have nice indentation and nice generated HTML output too.
I tried to imagine a good solution and couldn't so far (apart from running the generated HTML to a pretty printer but this is going to cause some overhead - Maybe it's minor enough to do it though). We could also have our own pre-processor that would remove spaces at beginning of velocity lines (as we're doing in the {{velocity}} macro)
It's too minor to add pre-processing, it will just take more time (ok maybe not that much ;)) and not bring much value IMO.
WDYT?
Thanks -Vincent
<option value="local" selected="selected"> $msg.get("rightsmanager.local")</option> <option value="global"> $msg.get("rightsmanager.global")</option> <option value="both"> $msg.get("rightsmanager.both")</option> </select> - #else<input type="hidden" name="wiki" value="local"/>#end - #set($colsp = $maxlevel + 1) + #else<input type="hidden" name="wiki" value="local"/>#end + #set($colsp = $maxlevel + 1) </td> <td colspan="$colsp"><input type="hidden" name="clsname" value="$clsname" /></td> </tr>
devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
On Nov 19, 2009, at 5:25 PM, Thomas Mortagne wrote:
On Thu, Nov 19, 2009 at 15:57, Vincent Massol <[email protected]> wrote:
On Nov 19, 2009, at 3:53 PM, tmortagne (SVN) wrote:
Author: tmortagne Date: 2009-11-19 15:53:25 +0100 (Thu, 19 Nov 2009) New Revision: 25217
Modified: platform/web/trunk/standard/src/main/webapp/templates/rightsUI.vm Log: [cleanup] Apply codestyle
Modified: platform/web/trunk/standard/src/main/webapp/templates/ rightsUI.vm =================================================================== --- platform/web/trunk/standard/src/main/webapp/templates/ rightsUI.vm 2009-11-19 14:43:57 UTC (rev 25216) +++ platform/web/trunk/standard/src/main/webapp/templates/ rightsUI.vm 2009-11-19 14:53:25 UTC (rev 25217) @@ -110,15 +110,15 @@ </tr> <tr id="usersandgroupstable-filters"> <td>$msg.get("rightsmanager.searchfilter") <input name="name" type="text" style="width:65%"/> - #if($context.database != "xwiki") #set($mainwk = false) #else #set($mainwk = true) #end - #if(!$mainwk) ## display the combobox only in a local wiki + #if(!$context.isMainWiki()) #set($mainwk = false) #else #set($mainwk = true) #end + #if(!$mainwk) ## display the combobox only in a local wiki <select name="wiki" style="margin-left: 10px;">
This will create some extra spaces in the generated HTML. It would be great if we could find a way to have nice indentation and nice generated HTML output too.
I tried to imagine a good solution and couldn't so far (apart from running the generated HTML to a pretty printer but this is going to cause some overhead - Maybe it's minor enough to do it though). We could also have our own pre-processor that would remove spaces at beginning of velocity lines (as we're doing in the {{velocity}} macro)
It's too minor to add pre-processing, it will just take more time (ok maybe not that much ;)) and not bring much value IMO.
I'm still wondering. When you do a view source from an XE page, it's not very nice and doesn't look very professional. -Vincent
WDYT?
Thanks -Vincent
<option value="local" selected="selected"> $msg.get("rightsmanager.local")</option> <option value="global"> $msg.get("rightsmanager.global")</option> <option value="both"> $msg.get("rightsmanager.both")</option> </select> - #else<input type="hidden" name="wiki" value="local"/>#end - #set($colsp = $maxlevel + 1) + #else<input type="hidden" name="wiki" value="local"/>#end + #set($colsp = $maxlevel + 1) </td> <td colspan="$colsp"><input type="hidden" name="clsname" value="$clsname" /></td> </tr>
Hi, ----- Original Message ----- From: "Vincent Massol" >
I'm still wondering. When you do a view source from an XE page, it's not very nice and doesn't look very professional.
Just some thoughts... What about creating an optional (configured in web.xml) ResponseFormattingFilter which calls chain.doFilter(request, new PrettyResponse(response)); PrettyResponse would be a wrapper for ServletResponse which would delegate all method calls to original response but also wrap its OutputStream with PrettyOutputStream. PrettyOutputStream write() methods would have all necessary logic to properly indent html tags on-the-fly and call its underlying (wrapped) outputStream write() method whenever possible. This way we can process the document in small chunks. We could also buffer this way the whole document in the filter and pretty print it at the end - it would be easier to implement but more memory consuming. Additional possibilities: - we could use CompactResponse (the output doc would be a one-liner, all unnecessary whitespaces removed) in order to lower bandwidth - we can add the cache directives in response headers (so we won't need Apache for doing this - this can be also done in separate filter, in fact I already use such a filter) Kind regards Lukasz
On 11/19/2009 07:24 PM, Lukasz Skowronski wrote:
Hi,
----- Original Message ----- From: "Vincent Massol">
I'm still wondering. When you do a view source from an XE page, it's not very nice and doesn't look very professional.
Just some thoughts...
What about creating an optional (configured in web.xml) ResponseFormattingFilter which calls chain.doFilter(request, new PrettyResponse(response));
PrettyResponse would be a wrapper for ServletResponse which would delegate all method calls to original response but also wrap its OutputStream with PrettyOutputStream.
PrettyOutputStream write() methods would have all necessary logic to properly indent html tags on-the-fly and call its underlying (wrapped) outputStream write() method whenever possible. This way we can process the document in small chunks.
We could also buffer this way the whole document in the filter and pretty print it at the end - it would be easier to implement but more memory consuming.
Additional possibilities: - we could use CompactResponse (the output doc would be a one-liner, all unnecessary whitespaces removed) in order to lower bandwidth - we can add the cache directives in response headers (so we won't need Apache for doing this - this can be also done in separate filter, in fact I already use such a filter)
This is a pretty dangerous zone. While I would also like to have neat HTML responses, it's hard to come with a generic prettyprinter, since some elements depend on having whitespace, others must explicitly have no whitespace between similar elements to prevent broken layouts. True, this means that the style is a bit fragile, but this the style we have, and there's little we can do about it. -- Sergiu Dumitriu http://purl.org/net/sergiu/
participants (4)
-
Lukasz Skowronski -
Sergiu Dumitriu -
Thomas Mortagne -
Vincent Massol