Forums / Developer / Tidy output extension?

Tidy output extension?

Author Message

Andrew K

Tuesday 30 January 2007 3:02:40 pm

I was wondering if there is already or anyone would be interested in an extension that took all of the potentially messy html outputted by eZ and tidy'ed it up (probably using the tidy engine). If there is not one already out there, I thought I'd try my hand at creating it. Let me know your thoughts.

In case you're not familiar with Tidy... http://tidy.sourceforge.net/

--Andrew

Stuart Fenton

Wednesday 31 January 2007 12:48:30 am

It's a nice idea as long as it can be placed between the html generation and the cache, compile.

Regards
Fats

-- Stuart

stuart@grandmore.com
http://www.grandmore.com

Xavier Dutoit

Wednesday 31 January 2007 1:20:07 am

They aren't any reason the code generated by ez is messy.

If it it, modify the templates you don't like.

X+

http://www.sydesy.com

Xavier Dutoit

Wednesday 31 January 2007 1:22:14 am

By modify, I meant override. You can override about any template that output html and replace it with xhtml code you want.

I'm able to produce xhtml 1.1 code (or could if I modify a few template and accept not to use target for the links for instance).

X+

http://www.sydesy.com

Andrew K

Wednesday 31 January 2007 8:00:59 am

I'm not really concerned with the validity/compliance of the xhtml. Just the aesthetics of the actual outputted code.

For example, a template in eZ may output the following:

<div class='some-class'>
<div class='some-other-class'>

<ol>
<li>item 1<li>item 2<li>item 3

</ol>


</div>

</div>

Which could be cleaned up by Tidy to look like:

<div class='some-class'>
   <div class='some-other-class'>
      <ol>
         <li>item 1
         <li>item 2
         <li>item 3
      </ol>
   </div>
</div>

Which would be much easier to look at when you are debugging templates and just generally easier to look at when viewing the code.

Andrew K

Wednesday 31 January 2007 8:08:42 am

Fats,

Is it possible for a eZ extension to place something between the html generation and cache? Or would this have to be a kernel hack? This would be my first attempt a making any kind of extension. Forgive my ignorance.

--Andrew

kracker (the)

Wednesday 31 January 2007 8:23:20 am

It's sure an interesting idea!

Have you looked into where you might insert this step in the process?
I'd guess that there must be a place where this can be augmented,
but which one ...

//kracker

<i>Busdriver - Stylin' Under Pressure</i>

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

Andrew K

Wednesday 31 January 2007 8:55:05 am

That's where I'm at a loss. I could use some direction, there.

--Andrew

Paul Forsyth

Wednesday 31 January 2007 9:17:10 am

One way around this issue is to use a 'post' html solution.

This firefox extension 'pretty prints' the html:

http://jennifermadden.com/scripts/ViewRenderedSource.html

paul

Andrew K

Wednesday 31 January 2007 9:35:03 am

Paul,

I agree this is a good alternative for debugging. I guess I just want the output code of my site to look super clean to everyone.

Thanks for the recommendation.

--Andrew

Paul Forsyth

Wednesday 31 January 2007 9:55:35 am

Its a challenging task given the number of templates going into a single html page.

eZ operators often leave white space in the html output. Even template comments {* *} do that which makes output *very* hard to control. I often have to put particular statements on a single line to avoid browser incompatibilities.

paul

Paul Forsyth

Wednesday 31 January 2007 9:56:30 am

actually, thinking more about this there should be no reason for not having an operator like:

{$module_result.content|tidy}

in the main pagelayout.

hmmm...

Andrew K

Wednesday 31 January 2007 10:06:12 am

Oh yeah, I like that idea. I was thinking along a similar line. By capturing the entire output and running tidy on it before it was sent to the browser.

So that wouldn't necessarily be an extension, right or would it? I guess I just need a place to start diving in.

--Andrew

Andrew K

Wednesday 31 January 2007 10:13:44 am

Ok. I did some browsing and concluded that this would be a custom template operator. I'll start there. Thanks for all of the input, it's been very helpful!

--Andrew

Bruce Morrison

Wednesday 31 January 2007 2:36:17 pm

Howdy

Unfortinually

{$module_result.content|tidy}

may not work as tidy is treats the input as a complete HTML page and code only produces a "content" HTML fragment. I suspect that running tidy on this will cause it to insert extra html, body, head etc tags. (Though the "show-body-only" option may help here)

Whats required in eZ is thge ability to do post template generation processing ( smarty has this ability http://smarty.php.net/manual/en/api.register.postfilter.php) and it is great for this type of thing.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Andrew K

Wednesday 31 January 2007 2:53:41 pm

Bruce,

So are you saying that eZ does not have the ability to do post template generation processing, not even through an extention?

--Andrew

Andrew K

Wednesday 31 January 2007 2:59:14 pm

Looking at the Tidy Man page, it looks like Bruce is right about the 'show-body-only' option. I think that will solve tidy seeing the input as an entire page.

Thanks Bruce.

--Andrew

Bruce Morrison

Wednesday 31 January 2007 3:07:23 pm

@Andrew

<i>So are you saying that eZ does not have the ability to do post template generation processing, not even through an extention?</i>

Well I haven't checked the code but I doubt very much that the hooks are present to be able to do this in an extension. I suspect that the kernel would have to be hacked to allow for this functionallity.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Paul Forsyth

Thursday 01 February 2007 2:15:32 am

I dont think it would be too hard. Once you drop into the operator code and php you should be able to filter the html into a form tidy will accept.

Perhaps follow these steps:

1. Invoke {$module_result.content|tidy}
2. In operator php code wrap the ez html with appropriate html tags: <html><body>{$module_result.content}</body></html>
3. Allow tidy to do its job.
4. Receive formatted html and remove the added html from its output.
5. Return the formatted html.

Since eZ components has a new template engine i dont believe the current version will be improved. However, im not sure if the eZc has the necessary hooks.

Paul

Bruce Morrison

Thursday 01 February 2007 7:08:11 pm

Hi Paul

I reckon that would do the trick. Might be easier to wrap the tidy input comments .e.g.

<!-- Start pre tidy -->
{$module_result.content}
<!-- End pre tidy -->

and then remove above and below the comments in the output.

Of course an operator on {$module_result.content} will only "tidy" that portion of the HTML. The rest of pagelayout.tpl will not be effected.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

eZ debug

Timing: Jan 18 2025 11:18:45
Script start
Timing: Jan 18 2025 11:18:45
Module start 'content'
Timing: Jan 18 2025 11:18:46
Module end 'content'
Timing: Jan 18 2025 11:18:46
Script end

Main resources:

Total runtime1.2618 sec
Peak memory usage4,096.0000 KB
Database Queries271

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0080 589.0391180.8438
Module start 'content' 0.00801.0914 769.8828897.2422
Module end 'content' 1.09940.1623 1,667.1250362.5859
Script end 1.2617  2,029.7109 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00420.3292210.0002
Check MTime0.00150.1220210.0001
Mysql Total
Database connection0.00070.054010.0007
Mysqli_queries1.124889.14522710.0042
Looping result0.00290.23152690.0000
Template Total1.230497.520.6152
Template load0.00190.153820.0010
Template processing1.228497.359620.6142
Template load and register function0.00020.019010.0002
states
state_id_array0.00090.069710.0009
state_identifier_array0.00100.075520.0005
Override
Cache load0.00210.16721140.0000
Sytem overhead
Fetch class attribute can translate value0.00180.141670.0003
Fetch class attribute name0.00120.0960240.0001
XML
Image XML parsing0.00290.233270.0004
class_abstraction
Instantiating content class attribute0.00000.0036270.0000
General
dbfile0.00780.6188470.0002
String conversion0.00000.000730.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
20content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
31content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
7content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
7content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 71
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs