Forum OpenACS Q&A: Re: xowiki Folder Object

Collapse
4: Re: xowiki Folder Object (response to 3)
Posted by Richard Hamilton on
Hmmm! Not working for some reason. Put wildcard declaration in exactly as per [i] note on admin page but with

*,* at the front. Editing existing xowiki::Form pages but no change to Xinha.

When I click edit for the en:index to see if that is reflected I get an error:

can't read "edit_form_page_title": no such variable
while executing
"::xo::Page set_property doc title "[$package_id instance_name] - $edit_form_page_title""
(procedure "edit" line 69)
::959 ::xowiki::Page->edit
invoked from within

I have no idea if that is related to my widget spec or not. I somehow doubt it.

R.

Collapse
5: Re: xowiki Folder Object (response to 4)
Posted by Richard Hamilton on
Oh, yes. Can't edit anything now. It is my widget spec. Doesn't like the double wildcard for some reason - thought that was supposed to work. Never mind.

No luck so far.

R.

Collapse
6: Re: xowiki Folder Object (response to 4)
Posted by Richard Hamilton on
Have tried explicitly adding field name from xowiki::Form spec. Can anyone see why this has no effect? 
I have checked and the style-sheet referred to below is in place as per the default OpenACS installation.

*,bannerpages_pagetext_para01 {richtext(richtext),nospell,optional {label Content} 
{html {style {width: 100%}}} {options {editor xinha plugins {Stylist OacsFs} height 350px javascript 
{ xinha_config.toolbar = [ ['popupeditor', 'bold','italic','createlink','insertimage','separator'], ['killword','removeformat'] ];
 xinha_config.stylistLoadStylesheet('/resources/xowiki/examples/xinha-mc-styles.css', {'p.angabe' : 'Aufgabenstellung', 'p.loesungshinweis' : 'Lösungshinweis',
 'li.correct_choice' : 'Richtige Antwort', 'li.incorrect_choice' : 'Falsche Antwort'}); }}}}

Regards
Richard
Collapse
7: Re: xowiki Folder Object (response to 6)
Posted by Victor Guerra on
Richard

The parameter WidgetSpec is used when displaying those forms used for creating/editing xowiki objects, i.e. : Pages, PageInstances, Forms, etc. So if you take your example and change "bannerpages_pagetext_para01" for "text"; you will see that every time you create/edit a Page the "Content" field uses the Xinha configuration you provided.

But if you want to provide such customization for a form-field ( I guess your form-field in this example is called: banner_pagetext_para01) you would have to configure your formfield as follows ( on the form constraints section )

{bannerpages_pagetext_para01=richtext,editor=xinha,label=Content,plugins=Stylist OacsFs,javascript=xinha_config.stylistLoadStylesheet('/resources/xowiki/examples/xinha-mc-styles.css');}

I hope this helps you on what you are trying to achieve.

Best,

Collapse
8: Re: xowiki Folder Object (response to 7)
Posted by Richard Hamilton on
Victor,

That's fantastic, thank you for clearing that confusion.

Regards
Richard

Collapse
9: Re: xowiki Folder Object (response to 7)
Posted by Richard Hamilton on
Victor,

Thank you for this reply. The Stylist form-field configuration works fine done like this. However, when I try to specify the toolbar config, the form-field chokes on the '[' and the ']'. I presume that this is a security issue since these characters have special meaning in tcl.

Is there a way to submit a toolbar config to xinha for a form-field without using the '[' and ']' characters.

Regards
Richard

Collapse
10: Re: xowiki Folder Object (response to 9)
Posted by Gustaf Neumann on
here is an example to define the toolbar:
http://alice.wu-wien.ac.at:8000/xowiki-doc/#js

just tried it, and everthings seems ok to me...

Collapse
11: Re: xowiki Folder Object (response to 9)
Posted by Richard Hamilton on
For the record I also tried using the javascript semantic:

var xinha_config.toolbar = new Array('popupeditor','separator','textindicator');

However, this won't work because xowiki interprets the commas as delimiters even when inside curly braces.

The following works:

var xinha_config.toolbar = new Array('popupeditor');

....but clearly this is not much use! 😊

I would like to be able to put the following nested array specification into a form field specification:

{main_page_content:richtext,editor=xinha,label=Other Content,plugins=Stylist OacsFs,javascript=var xinha_config.toolbar = new Array(new Array('popupeditor'),new Array('separator','textindicator'),new Array('separator','justifyleft','justifycenter','justifyright','justifyfull'),new Array('separator','insertorderedlist','insertunorderedlist','outdent','indent'),new Array('separator','inserthorizontalrule','createlink','insertimage','inserttable'),new Array('linebreak','undo','redo','separator','selectall','print'), (Xinha.is_gecko ? [] : ['cut','copy','paste','overwrite','saveas']), new Array('separator','killword','clearfonts','removeformat','toggleborders','splitblock','lefttoright','righttoleft'), new Array('separator','htmlmode','showhelp','about'));}

Regards
Richard

Collapse
12: Re: xowiki Folder Object (response to 10)
Posted by Richard Hamilton on
Gustaf,

Yes, I know that in the instance widgetspec parameter it will work just fine (I have studied that section of your docs, and that is my fallback).

I was trying to include a spec in a specific formField specification - in the form constraints of an ::xowiki:Form

It is in that context that the issue with the '[', the ']', and the ',' crops up!

😊

Thanks for the reply.

Regards
Richard

Collapse
14: Re: xowiki Folder Object (response to 12)
Posted by Gustaf Neumann on
I see, you want to configure xinha for a certain form_field via the form constraints. Since in the form-constraints the fields are separated via comma, these have to be coded as __COMMA__. The following should work:

{_text:richtext,editor=xinha,javascript=
xinha_config.toolbar = [
    ['popupeditor'__COMMA__ 'bold'__COMMA__'italic'__COMMA__'createlink'__COMMA__'insertimage'__COMMA__'separator']__COMMA__
    ['killword'__COMMA__'removeformat']
  ];
}
I have spent ages tryting to do this and have so far failed. It must be me, but I cannot for the life of me see where the problem lies.

Here is my instance parameter spec:

*,text {richtext(richtext),nospell,optional
  {label Content}
  {html {style {width: 100%}}}
  {options {editor xinha plugins {Stylist OacsFs} height 350px javascript {

  xinha_config.toolbar = [
    ['popupeditor', 'bold','italic','createlink','insertimage','separator'],
    ['killword','removeformat']
  ];

  xinha_config.stylistLoadStylesheet('/resources/xowiki/examples/xinha-mc-styles.css',
  {'p.angabe' : 'Aufgabenstellung',
  'p.loesungshinweis' : 'Lösungshinweis',
  'li.correct_choice' : 'Richtige Antwort',
  'li.incorrect_choice' : 'Falsche Antwort'});
  }}}}

Here is my ::form::Field spec:

{main_page_content:richtext,label=Other Content}

Here is the rendered page source:

  <script type="text/javascript" src="/resources/acs-templating/xinha-nightly/XinhaCore.js"></script>

  <script type="text/javascript">
        xinha_editors = null;
        xinha_init = null;
        xinha_config = null;
        xinha_plugins = null;
        xinha_init = xinha_init ? xinha_init : function() {
            xinha_plugins = xinha_plugins ? xinha_plugins :
              ['GetHtml', 'CharacterMap', 'ContextMenu', 'ListType', 'TableOperations', 'EditTag', 'LangMarks', 'Abbreviation'];

Regards
Richard

Collapse
15: Re: xowiki Folder Object (response to 14)
Posted by Richard Hamilton on
Gustaf,

Thank you for the reply. The __COMMA__ substitution is extremely helpful thankyou.

For the sake of completeness I wanted to let you know that the above proposed notation (i.e. with square brackets) does not in fact work because the '[' and ']' fail the form validation checks in xowiki.

However, this notation works:

{main_page_content:richtext,editor=xinha,label=Content,plugins=Stylist OacsFs,javascript=xinha_config.toolbar=new Array(new Array('popupeditor')__COMMA__new Array('separator'__COMMA__'textindicator'));}

This is exactly what I wanted to achieve, however it still pains me that I cannot work out why the more general widgetspec parameter specification method doesn't work for me.

Regards
Richard

Collapse
16: Re: xowiki Folder Object (response to 15)
Posted by Gustaf Neumann on
glad, that this works. The form constraints are obviously not the best way to pass javascript. On the longer range, we should find a better way of providing these. The formfields contain already a "slim" configuration for xinha, and the way should be to extend this further.

Concerning square brackets for javascript arrays: i have tested the example above (14) before posting, and it works nicely.

Collapse
17: Re: xowiki Folder Object (response to 16)
Posted by Richard Hamilton on
Gustaf,

That is strange. I have just tried this again by creating a test form with a single field on it. I have copied your code from the forum post and I receive this error:

Error in field Form Constraints: Form constraint contains invalid characters

Could it be that the form validation on my setup is different for some reason? Is your form validation set to the default?

Content:  @test_var@

Form:  <form>@test_var@</form>

Form Constraints:  {test_var:richtext,editor=xinha,javascript=
xinha_config.toolbar = [
    ['popupeditor'__COMMA__ 'bold'__COMMA__'italic'__COMMA__'createlink'__COMMA__'insertimage'__COMMA__'separator']__COMMA__
    ['killword'__COMMA__'removeformat']
  ];
}

Regards
Richard

Collapse
18: Re: xowiki Folder Object (response to 17)
Posted by Gustaf Neumann on
you are right, it should complain, but does not on my local machine... i have always a lot of experimental code hanging around, so there must be somewhere a bad interaction...
-gustaf
Collapse
19: Re: xowiki Folder Object (response to 16)
Posted by Richard Hamilton on
I was just today re-visiting my confusion on this issue. I think I finally understand that the Xowiki instance 'Xinha WidgetSpec' parameter only configures Xinha for the forms used to create or edit xowiki objects.

I now finally understand that adding a xinha config to a formfield spec is the only way currently to configure the editor for Xowiki.Form fields.

In my current experiment, where I have several textarea fields that all need xinha activated with the same configuration, this is very verbose and repetitive.

It would be great to have the ability to set a default spec for xinha for use when filling-out/ creating instances of Xowiki.Forms.

regards
Richard

Collapse
20: Re: xowiki Folder Object (response to 19)
Posted by Richard Hamilton on