Andy,

Really thank you for your reply, it will surely help me to improve the code.

I've created Issues
<https://github.com/TiuTalk/HtmlTidyComponent/issues>with your
suggestions and I will analyse and deal with each issue
separately.

I know there's a few Tidy CakePHP helpers out there, even that one of them
is mine but all of them are designed to version 1.2 or 1.3.

About the "should be a helper" advice, I created it as a Component since it
interacts with the request+respose somehow, but you have your point since
is HTML manipulation.

Maybe I shuld convert the whole idea into a plugin, and put the *
repairString* core on a Lib inside it... So as you said, I can call it from
from a Helper to clear the whole output (when specificied on helper's
configuration) or to just use a method to clean some HTML snipped inside a
view/element.

Plus, would be a good idea to create a Behavior where you do something like
this?

$actsAs = array('HtmlTidy' => array('fields' => array('body')));

And automatically cleanup the fields value inside behavior's
beforeValidate()?

Regards,
--
***Thiago Belem*
Desenvolvedor
Rio de Janeiro - RJ - Brasil

+55 (21) 8865.9250
thiagobelem.net
[email protected]

*Skype / gTalk **»* thiago.belem.web
*LinkedIn* *»* br.linkedin.com/in/thiagobelem/pt*
Assando Sites*, curso de CakePHP *»* assando-sites.com.br


2011/12/2 AD7six <[email protected]>

>
>
> On Friday, 2 December 2011 06:19:22 UTC+1, Thiago Belem wrote:
>>
>> Folks,
>>
>> I've just finished the HTML Tidy 
>> Component<https://github.com/TiuTalk/HtmlTidyComponent>,
>> it helps you to sanitize, clean and solve several HTML markup issues
>> automatically.
>>
>> Just include it in your list of components you'll get a clean and valid
>> output.
>>
>
> First point that jumps up is: What is a class that is 100% focussed on the
> V of MVC doing in the C?
>
>>
>> I would like to hear from everyone, including suggestions for improvement
>> in the component and unit tests.
>>
>
> Positive: generally it's useful
>
> Neutral: Googling you'll find that you are not the only person to have
> written something to automatically call tidy for you (there's at least one
> helper already out there on the bakery)
>
> Suggestions:
>
> Should be a helper, or a lib (so that you can, if you really want, call it
> from anywhere in your app, e.g. before save in a model,  from a helper when
> rendering) and a helper. The helper is just an after layout callback to
> auto call repairString if _configured_ to do so.
>
> Throwing exceptions (again, in the constructor) means it doesn't degrade
> gracefully. It works as designed or if flat out kills your application -
> that's not good. What happens to your application when you deploy or
> upgrade to your production server and tidy isn't/is-no-longer available?
>
> Instanciating Tidy in the constructor means you're loading a class on all
> requests which potentially you're not going to use just by including the
> component. However implemented it should lazy-load wherever possible (that
> means new Tidy() is called the first time you actually try to use the class
> - not optimistically loading it early). In practical terms that means only
> check settings in constructor/setup functions - do as little as possible.
>
> Using shutdown means if you wanted to use the class to repair some random
> string that you aren't sending to the browser - you get as a 'bonus'
> whatever html you render being corrected - with no obvious configurable way
> to turn that off (except removing the component or disabling the component
> before the request finishes)
>
> Throw exceptions when you try to use code and it won't work without
> addressing "the problem". Trigger errors when you try to use code and some
> recoverable problem occurs - That doesn't break your app but it does put
> "Tidy is configured to clean up your shitty html - but the extension isn't
> available" into the error log which devs (should) read.
>
> hth,
>
> AD
>
>>
>>  --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group
> at http://groups.google.com/group/cake-php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to