Hello all,

It's been a while since this subject crossed the mailing list. I figured it would be good to write down what I found out so far, so you need not go through the same process. So these are my (preliminary) conclusions:

1. There is no easy way to add or replace Xinha plugins (see mail exchange below). The only solution seems to create a local copy of the editor tree and modify that. This means that you have to forget about editor updates or do the merging yourself.

2. The Xinha is rather old (and somewhat buggy), but unfortunately it cannot 
simply be replaced by the latest version of
Xinha. At first is seems there is no problem, but when there are multiple 
htmlareas in one document sh.. hits the fan.
The code that manages activation of the different areas is in the CMS not part 
of Xinha and can be found in:
   editor/src/site/editing/cf2/resources/js/htmlarea-functions.js
The latest Xinha has functionality to that effect builtin, but it is 
incompatible. That means, in my estimate,
htmlarea-functions.js need to be (almost) completely rewritten to get it to work. This shouldn't really be hard, I played with it a bit, but just didn't have time to get it right.

3. So I turned back to the old Xinha. Problem was that of one of the plugins I needed (definition lists) I could only find one for the latest Xinha and that such newer plugins, not surprisingly, don't work in an old Xinha. Good news is that only a couple small changes are needed (at least for the plugins I wanted: abbrev, langmarks and definitionlist. Old versions of the first two are available, by the way, but the newer ones have advantages).

The following changes were needed (I can provide the plugin source code if 
anyone is interested):
  a. Plugin javascript CamelCase filenames should be replaced by lowercase 
names with dashes.
     All but the first <Uppercase> => -<lowercase>. Example: DefinitionList.js 
becomes definition-list.js.
     The plugin loader actually converts the plugin directory name in that way 
to find the .js file.

  b. In the plugin code Xinha needs to be replaced by HTMLArea.

  c. The onGenerate() function needs to be replaced. Simply look at one of the 
old plugins for an example.

  d. Autoloading of plugins in the toolbar in the old Xinha is broken.
     If manually loaded, it should not autoload but it does so anyway and you 
cannot control where it goes.
     I don't see really why this autoloading would be useful, so I disabled it 
in the plugins.

  e. Definition lists always load themselves, but the buttons may appear twice.
     This required a small fix. I also modified this plugin to move the cursor 
into the newly created element.

4. A final, somewhat related problem I had was that I needed to clean the HTML. There is HTMLCleaner of course, but that doesn't treat <span> elements properly: it assumes that span is only used for styling, either through a class or a style attribute. So it doesn't look at the attributes given in the allowed-elements config and thus removes for instance the lang attribute that the LangMarks plugin inserts. I also looked at the SuperClean/Filter plugin for Xinha, but that needs a button to be pushed by the content editor and I want things to be automatic. Postprocessing could have been an option, if it hadn't been for the fact that without HMTLcleaner the content of an htmlarea element is not XML but a string, where XML syntax related characters have been translated to entities (&lt;, &amp;, etc).
So in the end I returned to HtmlCleaner and modified it.

If anyone is interested in any of the modifications I made, I'll gladly 
upload/mail them somewhere.

Thanks for all the help I received.
Regards,


Reinier



Reinier van den Born wrote:
The story continues:
I have overridden /editing/cf2/perspective.html but that doesn't do the trick either.
What I did is:
- got /editing/cf2/perspective.html in my browser
- saved in extensions/editing/perspective.html and made my changes.
- configured the override
To verify I refreshed the page in my browser and ensured I got my version.

So it seems that the @frameUrl is not used in the way you think it is?

Looking at the source of a CMS edit frame I noticed the following. It looks like this:
      _editor_url = "/cforms/resources/xinha/";
      _editor_lang = "en_US";
      _editor_skin = "blue-look";

But the last line is not in the perspective.html, perspective.xsl, nor could I find how it could be inserted from there.
So I decided to search in the opposite direction.
I scanned all code for occurrences of _editor_skin and found only one:
...\cms-customized\editor\src\site\editing\cf2\transformers\cforms-hippocms-styling.xsl

Haven't had time to look into this further myself, but maybe this brings new insights?

Looking at the whole thing from another point of view, I think it would make sense to restore or create the override possibility for cforms files. That requires only a small change in the site/sitemap, is the proper way and would have saved us a lot of time. Because frankly, if I wouldn't have had some spare time, I would never have taken the search this far.

Reinier



Jasha Joachimsthal wrote:
/editing/cf2/prerspective.html is a URL matched in the src/editing/cf2/sitemap.xmap. It uses transformers/perspective.xsl for its rendering.
      <map:match pattern="perspective.html">
        <map:generate src="sitemap.xmap"/>
        <map:transform src="transformers/perspective.xsl">
        </map:transform>
        <map:serialize type="html"/>
      </map:match>

You can see which standard URL is used for the perspective in xpath /perspective/@frameUrl in file src/workbench/standard-configuration/perspectives/<perspective-name>/component.xml

Jasha



-----Original Message-----
From: [email protected] on behalf of Reinier van den Born
Sent: Wed 29-10-2008 13:06
To: Hippo CMS development public mailinglist
Subject: Re: [HippoCMS-dev] Xinha questions
Hoi Jasha,

The file is in a slightly different location for me (/explorer/resources/html/perspective.html) but anyway...

I created a folder "explorer" in my extensions and gave it the following override.xmap:
   <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0";>

     <map:pipelines>
       <map:pipeline type="noncaching">

         <map:match pattern="resources/html/perspective.html">
<map:read src="perspective.html"/> <!-- don't need the directory structure -->
         </map:match>

         <map:match pattern="**">
           <map:mount uri-prefix="" src="site://explorer/sitemap.xmap"/>
         </map:match>

       </map:pipeline>
     </map:pipelines>

   </map:sitemap>

Then I copied the original perspective.html to extensions/explorer/perspective.html and modified _editor_url and the script element that loads htmlarea right below it. Look like this:

   <script type="text/javascript">
           _editor_url = "/extensions/cforms/resources/xinha/";
           _editor_lang = "en";
         </script>
<script type="text/javascript" src="/extensions/cforms/resources/xinha/htmlarea.js">&nbsp;</script>

When I browse to http://localhost:50000/explorer/resources/html/perspective.html I actually get to see my version, so that works.

However when I reload the editor and look at the source HTML of the frame it doesn't show the change. _editor_url and src for loading htmlarea.js are the same as before.

Also plugins are simply loaded from the original location.

So I started scanning the project and found 4 sitemaps where a perspective.html is generated using a transformers/perspective.xsl. One location is site/editing/cf2, maybe that is the one you meant? Unfortunately there is no XSL at location.

There are two locations (site/slide and site/slide/explorer) where the sitemap may actually produce a perspective.html. Lo and behold the script elements that I want to change are present in the transformer/perspective.xsl files there.
But the location of these files makes little sense to me: slide?

All this raises the question: Is there a solution other than overriding half of the editor? If no, I might as well make my local copy and get rid of a whole lot of complications.

Btw, I wouldn't mind a solution where the editor is updated to the latest Xinha. Haven't tried this, but is sports a method to load a plugin from another, specific location.
Which may very well solve the problem that I started with :-)


Reinier



Jasha Joachimsthal wrote:
Hi Reinier,

is overriding /explorer/cf2/perspective.html an option? This page contains the scripts used in the editing perspective, including:
</script>
        <script type="text/javascript">
          _editor_url = "/cforms/resources/xinha/";
          _editor_lang = "en";
        </script>

Jasha


-----Original Message-----
From: [email protected] on behalf of Reinier van den Born
Sent: Tue 28-10-2008 17:23
To: Hippo CMS development public mailinglist
Subject: Re: [HippoCMS-dev] Xinha questions
Hi Jeroen,

Like I mentioned before overriding doesn't work.
Problem is that the site/sitemap contains an explicit pipeline for cform/resources/** before it starts looking voor overrides. The override pipeline is the last one in the sitemap, which maybe isn't the best place?

Xinha versions. I asked about that before and didn't get an answer.
Probably because I tend to ask to many Qs in one mail :-)

Anyway, for now, I took the latest and greatest, stable Xinha version (0.95)
and copied it into the editor tree. No other modifications.
Seems to work fine... no Xinha/HTMLArea object naming problems in sight.

Are there any other, specific problems you expect (and that I should check)
or, since the basics work, do you think I am OK?


Reinier



Jeroen Reijn wrote:
Hi Reinier,

http://wiki.hippo.nl/display/CMS/Overriding+core+CMS+code should be the way to go in this case. But you are probably trying to use the Xinha trunk. Beware that the current Xinha trunk/release has refactored it's core and the current JavaScript API( which is used inside the CMS) probably won't work anymore if you change it to Xinha trunk. The current Xinha is now located in called XinhaCore.js or something similar and the HTMLArea object, which previously existed, does not exist anymore in the new Xinha code and is replaced with the Xinha object.

Hi,

I have a couple of questions about Xinha:

Q1:
I would like to add some plugins to Xinha that don't come standard with the Hippo editor (eg. definition lists). And fiddle with/replace some that are standard (because they don't place themselves correctly on the toolbar).

I was hoping to be able to add the plugins somewhere down my extensions folder and tell Xinha to look there, but haven't found a way to do this.
Any suggestions?
Sure you can create your own Xinha plugins. I've done it in multiple occasions.

Try adding this function to your extended htmlarea.js (which is referenced in the <lib> tag in your BE templates.

HTMLArea.loadExternalPlugin = function(pluginPath, pluginName, callback) {
  // Might already be loaded
  if(eval('typeof ' + pluginName) != 'undefined')
  {
    if(callback)
    {
      callback(pluginName);
    }
    return true;
  }

  var plugin = pluginName.replace(/([a-z])([A-Z])([a-z])/g,
          function (str, l1, l2, l3) {
            return l1 + "-" + l2.toLowerCase() + l3;
          }).toLowerCase() + ".js";
  var plugin_file = pluginPath + "/" + pluginName + "/" + plugin;

  if(callback)
  {
HTMLArea._loadback(plugin_file, function() { callback(pluginName); });
  }
  else
  {
document.write("<script type='text/javascript' src='" + plugin_file + "'></script>");
  }
  return false;
};

Now you should be able to say something like (where Expander is the name of your plugin):

HTMLArea.loadExternalPlugin("/extensions/xinha/plugins", "Expander");


Q2.
Looking through the Xinha docs I don't see any reference to the type of HTML it generates:
XHTML, HTML 4.01, or some older version.
It looks like it is XHTML. If so, is there a way to tell it to generate HTML 4.01?
Xinha itself creates some HTML, which is not always very well formatted. Therefor we have use the HTMLCleaner. In the new version of the CMS, you can choose between XHTML strict and transitional. It will allways generate valid XHTML if you use the HTMLCleaner.

Q3.
I noticed some keyboard shortcuts are defined for Xinha (<ctrl-1> for H1, etc). They have apparently nothing to do with the plugin that allows changes like that from the toolbar.
So is there a way to disable these boys?
(I don't want to allow content editor anything but entering plain text, lists, emphasis etc.)
Yes, you should be able to create your own Xinha plugin for this. You can then catch the key events.

Any help is greatly appreciated.

Thanks,

Reinier van den Born

--

Reinier van den Born

HintTech B.V.
Rotterdamseweg 183c, 2629 HD Delft
T: +31(0)15 268 2573
F: +31(0)15 268 2567
M: +31(0)6 494 171 36
--
HintTech levert specialisten op het gebied van softwareontwikkeling (.NET en Java), projectmanagement, informatiebeveiliging en business consulting.
KvK Den Haag nr. 27242282 | BTW nr. NL8062.16.396.B01
********************************************
Hippocms-dev: Hippo CMS development public mailinglist

Searchable archives can be found at:
MarkMail: http://hippocms-dev.markmail.org
Nabble: http://www.nabble.com/Hippo-CMS-f26633.html


********************************************
Hippocms-dev: Hippo CMS development public mailinglist

Searchable archives can be found at:
MarkMail: http://hippocms-dev.markmail.org
Nabble: http://www.nabble.com/Hippo-CMS-f26633.html


********************************************
Hippocms-dev: Hippo CMS development public mailinglist

Searchable archives can be found at:
MarkMail: http://hippocms-dev.markmail.org
Nabble: http://www.nabble.com/Hippo-CMS-f26633.html

********************************************
Hippocms-dev: Hippo CMS development public mailinglist

Searchable archives can be found at:
MarkMail: http://hippocms-dev.markmail.org
Nabble: http://www.nabble.com/Hippo-CMS-f26633.html


------------------------------------------------------------------------

********************************************
Hippocms-dev: Hippo CMS development public mailinglist

Searchable archives can be found at:
MarkMail: http://hippocms-dev.markmail.org
Nabble: http://www.nabble.com/Hippo-CMS-f26633.html



------------------------------------------------------------------------

********************************************
Hippocms-dev: Hippo CMS development public mailinglist

Searchable archives can be found at:
MarkMail: http://hippocms-dev.markmail.org
Nabble: http://www.nabble.com/Hippo-CMS-f26633.html


********************************************
Hippocms-dev: Hippo CMS development public mailinglist

Searchable archives can be found at:
MarkMail: http://hippocms-dev.markmail.org
Nabble: http://www.nabble.com/Hippo-CMS-f26633.html


--

Reinier van den Born

HintTech B.V.
Rotterdamseweg 183c, 2629 HD Delft
T: +31(0)15 268 2573
F: +31(0)15 268 2567
M: +31(0)6 494 171 36
--
HintTech levert specialisten op het gebied van softwareontwikkeling (.NET en 
Java),
projectmanagement, informatiebeveiliging en business consulting.
KvK Den Haag nr. 27242282 | BTW nr. NL8062.16.396.B01
begin:vcard
fn:Reinier van den Born
n:van den Born;Reinier
org:HintTech B.V.
adr:;;Rotterdamseweg 183c;Delft;;2629HD;Netherlands
email;internet:[email protected]
tel;work:+31-15-268 2573
tel;fax:+31-15-268 2567
tel;cell:+31-6 494 171 36
note;quoted-printable:KvK Den Haag nr. 27242282 | BTW nr. NL8062.16.396.B01=0D=0A=
	=0D=0A=
	HintTech levert specialisten op het gebied van softwareontwikkeling (.NET=
	en Java), projectmanagement, informatiebeveiliging en business consulting=
	.=0D=0A=
	=0D=0A=
	
url:www.hinttech.com
version:2.1
end:vcard

********************************************
Hippocms-dev: Hippo CMS development public mailinglist

Searchable archives can be found at:
MarkMail: http://hippocms-dev.markmail.org
Nabble: http://www.nabble.com/Hippo-CMS-f26633.html

Reply via email to