Forum OpenACS Development: ad_form widget for textareas

Collapse
Posted by Malte Sussdorff on
What I'd like to see is a form widget, that offers you a choice how a textarea should be treated. If you look at the forum posting for example, the format should read:

- HTML.
- Enhanced text.
- WYSIWYG (if the browser is capable of doing this). Look at http://www.kevinroth.com/rte/demo.htm to know what I mean.

This should be an option in general for textareas, so all packages can make use of it without the need for further development. Furthermore, switching from WYSIWYG would take away the controls, but keep the generated HTML still in the textarea. Don't ask me how this is going to work, but this is my idea (I have a dream.... :)).

Does this make sense to you? Would you go and try to make one widget for all packages or would you split it up like it is done at the moment with Forums?

We are most likely willing to put some effort into it for Forums/Blogger/ETP, but I'd like to generate a solution that is appealing to the community at large. Well, and for sure get some feedback from people that have already done something like this.

Collapse
Posted by Dave Bauer on
Malte, have you seen "enhancedtext" widget?

It works nicely with ad_form. It is a multiple property widget that has the HTML content, mime-type and escaped html content.

This does most of what you want. I am not sure if it includes buttons to add bold, etc. Doesn't seem to work on Mozilla anyway :) Maybe on IE.

Collapse
Posted by Malte Sussdorff on
I have seen the enhancedtext widget. Is there a documentation about the capabilities somewhere. I only read that you can use HTML without the need to bother about page breaks.
Collapse
Posted by Lars Pind on
Malte,

It's called 'richtext', and is very simple. Take a look at /acs-templating/tcl/richtext-procs.tcl.

It offers buttons for B, I, and links on IE. That's it.

Would be awesome to make it do WYSIWYG on IE and Mozilla, but that's going to be significantly harder.

And yes, all it really does is add the buttons, and do the line break, paragraph break, link, and email translation which the regular text-to-html conversion already does.

So it's like the normal text-formatting, but also allowing you to use HTML tags.

/Lars

Collapse
Posted by David Cotter on
I was recently reviewing different WYSIWYG controls. Here's a list of some:

http://www.hotscripts.com/JavaScript/Scripts_and_Programs/Content_Management/

Most require IE 5.5 or greater but some like

http://www.interactivetools.com/products/htmlarea/

are starting to support Mozilla on all platforms. I was planning on adding one of these to ETP for a project I might have to do soon and it seems straightforward to me but that's just from a cursory glance at the code.

Collapse
Posted by Lars Pind on
David,

If that could be added as a easy-to-use formbuilder widget, that would be absolutely awesome. Go! :)

/Lars

Collapse
Posted by Andrei Popov on
Wouldn't the original Malte's link then be the most adequate solution based on (a) license and (b) browser support?
Collapse
Posted by Jerry Asher on
The original Malte? Has something happened?
Collapse
Posted by Malte Sussdorff on
Not to my knowledge. I pretty much feel unchanged, though I got a new haircut today :).
Collapse
Posted by Lars Pind on
Take a look at TYPO 3 as well, it has pretty good integration with desktop office applications as well. You can copy-paste from Word, and it integrates with StarOffice/OpenOffice. Or so I've been told. I haven't looked closely ... :)

/Lars

Collapse
Posted by Barry Books on
I would look at flash for this. I've been using a flash charting package and it works nicely. Flash seems to be more portable than javascript and can present a better user interface.
Collapse
Posted by David Cotter on
To prove the concept I put one of the above controls into edit-this-page in about 20 minutes.

The one I picked, htmlArea, uses a BSD licence and is for IE5.5 only but has an alpha version for Mozilla 1.3 which I didn't look at. I'm sure all the others including Malte's suggestion are similar.

To put this into ETP I did the following:

  • Get the htmlArea zip file and unzip into /web/yourserver/www/htmlarea
  • In etp-master.tcl add the following
    
    set header_stuff "<script language=\"Javascript1.2\"><!-- // load htmlarea
    _editor_url = \"/htmlarea/\";                     // URL to htmlarea files
    var win_ie_ver = parseFloat(navigator.appVersion.split(\"MSIE\")\[1\]);
    if (navigator.userAgent.indexOf('Mac')        >= 0) { win_ie_ver = 0; }
    if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
    if (navigator.userAgent.indexOf('Opera')      >= 0) { win_ie_ver = 0; }
    if (win_ie_ver >= 5.5) {
     document.write('<scr' + 'ipt src=\"' +_editor_url+ 'editor.js\"');
     document.write(' language=\"Javascript1.2\"></scr' + 'ipt>');
    } else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
    // --></script>
    "
    
  • In etp-master.adp add the following line (I added it just after <master>)
    
    <property name="header_stuff">@header_stuff@</property>
    
  • In etp-edit.tcl change the line:
    
        set widget "<textarea name=\"$attribute\" $html>[ad_quotehtml $value]</textarea>\n"
    
    to look like this:
    
        set widget "<textarea name=\"$attribute\" $html>[ad_quotehtml $value]</textarea>\n
        <script language=\"JavaScript1.2\" defer>
          editor_generate('$attribute');
          </script>"
    

    I'm not 100% about some of the templating stuff so it may not be the best way to modify pages

    That's it. To see it working with IE5.5 or greater go to: http://lin.alatto.com:8086/news-test and login as test@test.com with a password of test

    I think some of the other controls are better and some worse (e.g. in how they handle tables or images) but I think they're all pretty easy to integrate so it's a case of deciding on what one is the best.

  • Collapse
    Posted by Yves Goldberg on
    I can't locate the following in etp-edit.tcl:

    set widget "<textarea name=\"$attribute\" $html>[ad_quotehtml $value]</textarea>\n"

    anyone could update the modification to etp-edit.tcl in order to call htmlArea?

    TIA

    Collapse
    Posted by Mark Aufflick on
    note that the htmlArea team jsut released version 3.0 RC1 whcih is the release tree that includes mozilla support.

    I have it running on a test server you can check out:

    With everything:
    http://home.pumptheory.com/ha/examples/fully-loaded.html

    My favourite, with tables and context menu, but no spelling or full page supprt:
    http://goo:8001/ha/examples/context-menu.html

    Two caveats:

    1/ it has crashed my mozilla once so far - but then my mozilla does crash from time to time...

    2/ the spell checker uses a perl cgi. since it's not in a /cgi-bin/ or similar segregated directory, i couldn't figure out how to get aolserver to run it. wouldn't be hard to make the it link in from there though.

    Collapse
    Posted by Mark Aufflick on
    NB: you have to add these lines to your user.js to allow copy & paste to work in current mozilla versions (they disable script access to copy/paste for security):

    user_pref("capability.policy.policynames", "allowclipboard");
    user_pref("capability.policy.allowclipboard.sites", "http://www.mozilla.org");
    user_pref("capability.policy.allowclipboard.Clipboard.cutcopy", "allAccess");
    user_pref("capability.policy.allowclipboard.Clipboard.paste", "allAccess");