Re: [Catalyst] Validation of entered content

2011-04-12 Thread John M. Dlugosz

Thanks for the comprehensive reply!  That will keep my busy for a while.

On 4/11/2011 10:25 AM, Peter Edwards peter-at-dragonstaff.co.uk |Catalyst/Allow to home| 
wrote:


There are two main JS editors, the one above and TinyMCE, you have to be
careful though.

1) People paste a Word document paragraph in as HTML and it becomes invalid.
Try offering a paste-from-word button to bring up a box they paste into,
then send that to the backend to be run through
http://search.cpan.org/perldoc?Text::Demoroniser before you add it to the
content area.

2) Hitting bugs in these editors giving you invalid XHTML.
What you can do is
- validate by sending the content server-side before save and check with a
DTD schema validator like http://htmlhelp.com/tools/validator/ and on
failure disallow save with a popup warning
- then offer an option to correct invalid XHTML where you send the content
to the backend, run it through htmltidy, then bring it back to the content
area; see the HTML -  XHTML docs in
http://tidy.sourceforge.net/docs/tidy_man.html




___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Validation of entered content

2011-04-12 Thread John M. Dlugosz
On 4/11/2011 10:25 AM, Peter Edwards peter-at-dragonstaff.co.uk |Catalyst/Allow to home| 
wrote:

I've used this before - perhaps it will work for you:

http://ckeditor.com/



That looks interesting, but digging through the documentation it seems that its native 
output format is XHTML, and although it mentions that plugin providers _could_ provide 
processors for BBCode etc. it doesn't link to any page of available plugins, nor do I see 
that on their site.


I'm convinced that as a first step I should make the user-supplied content be stored in 
some other format.  Then, replacing the textarea with a fancy WYSIWYG editor would be an 
optional step, and I would like that to be invisible to the app.  So, the GUI editor 
should populate the POSTed data with the same kind of markup that I would ask the user to 
type directly.


Of course, I suppose the Catalyst way would be to allow any kind of markup as long as 
there's an adapter for it.  The abstractions I've seen already in CPAN spit out whole HTML 
files with header and body, not fragments.  And I'm not terribly interested in building 
something like that right now.  I will however keep the decision abstracted and isolated 
in the code.



___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Validation of entered content

2011-04-11 Thread Nicholas Wehr
I've used this before - perhaps it will work for you:

 http://ckeditor.com/


cheers
-nw

On Mon, Apr 11, 2011 at 5:28 AM, John M. Dlugosz wxju46g...@snkmail.comwrote:

 I have a form where an admin can change a part of the content on a page.
  The form lets someone do it without having to update the files on the
 server in a more traditional manner; BUT, it must be correct XHTML.  If the
 admin types a p or a stray '' for that matter, it will render the
 resulting page not well-formed.

 Combine that with the feature of serving XHTML to browsers that accept it,
 and the site breaks on browsers other than IE.

 What's a good way to validate something programmatically before committing
 it?  Better yet, is there a rich editor or wiki- or phpbbs-like translator
 that I might use for soliciting the input that I might use instead?

 The current content has a couple paragraphs and a bulleted list.  So it's
 not just a simple blank, but must allow an amount of rich content.




 ___
 List: Catalyst@lists.scsys.co.uk
 Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
 Searchable archive:
 http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
 Dev site: http://dev.catalyst.perl.org/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Validation of entered content

2011-04-11 Thread Peter Edwards

 On Mon, Apr 11, 2011 at 5:28 AM, John M. Dlugosz 
 wxju46g...@snkmail.comwrote:

 I have a form where an admin can change a part of the content on a page.
  The form lets someone do it without having to update the files on the
 server in a more traditional manner; BUT, it must be correct XHTML.  If the
 admin types a p or a stray '' for that matter, it will render the
 resulting page not well-formed.

 Combine that with the feature of serving XHTML to browsers that accept it,
 and the site breaks on browsers other than IE.

 On 11 April 2011 15:33, Nicholas Wehr catal...@bionikchickens.com
 wrote:

 I've used this before - perhaps it will work for you:

 http://ckeditor.com/



There are two main JS editors, the one above and TinyMCE, you have to be
careful though.

1) People paste a Word document paragraph in as HTML and it becomes invalid.
Try offering a paste-from-word button to bring up a box they paste into,
then send that to the backend to be run through
http://search.cpan.org/perldoc?Text::Demoroniser before you add it to the
content area.

2) Hitting bugs in these editors giving you invalid XHTML.
What you can do is
- validate by sending the content server-side before save and check with a
DTD schema validator like http://htmlhelp.com/tools/validator/ and on
failure disallow save with a popup warning
- then offer an option to correct invalid XHTML where you send the content
to the backend, run it through htmltidy, then bring it back to the content
area; see the HTML - XHTML docs in
http://tidy.sourceforge.net/docs/tidy_man.html


Regards, Peter
http://perl.dragonstaff.co.uk
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Validation of entered content

2011-04-11 Thread Octavian Rasnita
From: John M. Dlugosz wxju46g...@snkmail.com
I have a form where an admin can change a part of the content on a page.  The 
form lets 
 someone do it without having to update the files on the server in a more 
 traditional 
 manner; BUT, it must be correct XHTML.  If the admin types a p or a stray 
 '' for that 
 matter, it will render the resulting page not well-formed.
 
 Combine that with the feature of serving XHTML to browsers that accept it, 
 and the site 
 breaks on browsers other than IE.
 
 What's a good way to validate something programmatically before committing 
 it?  Better 
 yet, is there a rich editor or wiki- or phpbbs-like translator that I might 
 use for 
 soliciting the input that I might use instead?
 
 The current content has a couple paragraphs and a bulleted list.  So it's not 
 just a 
 simple blank, but must allow an amount of rich content.



Better than storing html, store a Textile format which is easy readable and 
similar to plain text when not rendered, but which renders as valid html.

You can use

http://search.cpan.org/~bchoate/Text-Textile-2.12/lib/Text/Textile.pm

or you can use 

http://search.cpan.org/~idoperel/DBIx-Class-InflateColumn-Markup-Unified-v0.21.1/lib/DBIx/Class/InflateColumn/Markup/Unified.pm

for beeing able to choose if you want to store the markup as Textile, Markdown 
or BBCode.

The Textile format allows the biggest flexibility and you can also use html 
elements in it, but you can create with its features headings, lists of 
different formats, tables with many settings, links, images, and many other 
things.

Octavian


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/