FAQ
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.

Search Discussions

  • Nicholas Wehr at Apr 11, 2011 at 2:33 pm

    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 wrote:

    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/
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20110411/591f9db3/attachment.htm
  • Peter Edwards at Apr 11, 2011 at 3:25 pm

    On Mon, Apr 11, 2011 at 5:28 AM, John M. Dlugosz wrote:

    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 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
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20110411/1a06db62/attachment.htm
  • John M. Dlugosz at Apr 12, 2011 at 11:21 am
    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
  • John M. Dlugosz at Apr 12, 2011 at 12:26 pm

    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:
    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.
  • Octavian Rasnita at Apr 11, 2011 at 4:05 pm
    From: "John M. Dlugosz" <wxju46gefd@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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedApr 11, '11 at 12:28p
activeApr 12, '11 at 12:26p
posts6
users4
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2022 Grokbase