Bug 43990 - TinyMCE editor doesn't convert images to lenya-document:{uuid} syntax
TinyMCE editor doesn't convert images to lenya-document:{uuid} syntax
Status: REOPENED
Product: Lenya
Classification: Unclassified
Component: TinyMCE Integration
Trunk
Other other
: P2 critical
: 2.0.1
Assigned To: Lenya Developers
:
Depends on: 47190
Blocks:
  Show dependency tree
 
Reported: 2007-11-29 02:49 UTC by Andreas Hartmann
Modified: 2009-07-15 13:56 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Hartmann 2007-11-29 02:49:25 UTC
The OneForm editor inserts images with absolute URLs instead of
lenya-document:{uuid} URLs:

<img src="/default/authoring/doctypes/logo.png" title="Logo" alt="Logo"
width="199" height="63"/>

Non-proxy environment, standard Jetty.
Comment 1 J 2007-11-29 02:54:55 UTC
hmm, yes. i figured that when we're in edit mode, we need real URLs so that
editors can display images (does not strictly apply to oneform, but i'm still
dreaming of the Grand Unified Editor Usecase In The Sky). i thought that
url2uuid conversion was handled in the post-processing, but it seems it isn't...
Comment 2 Andreas Hartmann 2007-11-29 03:05:47 UTC
(In reply to comment #1)
> hmm, yes. i figured that when we're in edit mode, we need real URLs so that
> editors can display images (does not strictly apply to oneform, but i'm still
> dreaming of the Grand Unified Editor Usecase In The Sky).

Yes, that's OK from my POV.

> i thought that
> url2uuid conversion was handled in the post-processing, but it seems it isn't...

I guess the OneForm editor doesn't have such a post-processing yet. Do you have
the time to take a look at it?
Comment 3 Juergen Ragaller 2007-12-11 12:46:11 UTC
Same problem in tinyMCE.

The bad aspect of this bug is, that if it's fixed later (after 2.0), a content migration from <img src... links to uuid-links would be necessary....
Comment 4 Richard Frovarp 2007-12-11 12:56:25 UTC
I really hate to say this, but isn't this a blocker? Insert an image using one
form, publish, view under live. You'll end up with this as the URL in the live page:

http://localhost:8888/default/authoring/tutorial/test.png?lenya.module=svg&height=120&width=160

If you aren't proxying the authoring URLs through from live, the image won't be
visible from live. I've seen FCK do this. For some reason with FCK, just going
back to the page and hitting save fixes the problem. Not sure why it doesn't
always do the translation from path to uuid.
Comment 5 Richard Frovarp 2007-12-11 12:57:08 UTC
(In reply to comment #3)
> Same problem in tinyMCE.
> 
> The bad aspect of this bug is, that if it's fixed later (after 2.0), a content
migration from <img src... links to uuid-links would be necessary....

Saving the page would do the content migration. That's how it works with BXE,
and usually FCK. That's how I fix the issue when FCK doesn't cooperate.
Comment 6 Andreas Hartmann 2007-12-11 14:12:23 UTC
Should be fixed for the OneForm editor, at least for non-proxy, root-context
environments. Please test. TIA!
Comment 7 Andreas Hartmann 2007-12-11 14:14:15 UTC
(In reply to comment #1)
> hmm, yes. i figured that when we're in edit mode, we need real URLs so that
> editors can display images [...]

Does the image insertion code generate proxy-based URLs? If yes, we have to add
another processing step when saving the file (IncomingLinkRewriter).
Comment 8 Andreas Hartmann 2007-12-11 14:39:06 UTC
(In reply to comment #6)
> Should be fixed for the OneForm editor, at least for non-proxy, root-context
> environments. Please test. TIA!

Should now also work for proxy environments.

TinyMCE isn't updated yet. Any volunteers? :)
Comment 9 Andreas Hartmann 2007-12-11 14:44:37 UTC
Should be fixed for TinyMCE too, needs to be tested.
Comment 10 Juergen Ragaller 2007-12-12 00:20:18 UTC
 (In reply to comment #9)
> Should be fixed for TinyMCE too, needs to be tested.

In TinyMCE the image url I see is still the non-uuid one (after a switch to the trunk and a build clean-all)
Comment 11 Juergen Ragaller 2007-12-12 00:26:05 UTC
 (In reply to comment #8)
> (In reply to comment #6)
> > Should be fixed for the OneForm editor, at least for non-proxy, root-context
> > environments. Please test. TIA!
> 
> Should now also work for proxy environments.

confirmed here
Comment 12 Andreas Hartmann 2007-12-12 01:07:02 UTC
(In reply to comment #10)
>  (In reply to comment #9)
> > Should be fixed for TinyMCE too, needs to be tested.
> 
> In TinyMCE the image url I see is still the non-uuid one (after a switch to
> the trunk and a build clean-all)

IIUC TinyMCE should indeed show the non-UUID URL, but after saving it should be
replaced with the UUID-based one. Can you confirm this, or is it saved with
non-UUID URLs? BTW, you can just use the .xml extension in the browser URL box
to get the document source.
Comment 13 Juergen Ragaller 2007-12-12 01:14:05 UTC
No, I can't confirm this - in the page source, the non-uuid reference is still used.
Comment 14 Andreas Hartmann 2007-12-12 01:15:43 UTC
Unfortunately I can't test it at the moment, I always get "onclick attribute not
supported" errors when I save.
Comment 15 Richard Frovarp 2007-12-12 07:02:12 UTC
I just tested and see the problem. TinyMCE keeps rewriting the image url to
something like this: 

index/test.jpg?lenya.module=svg&height=120&width=160

When what is needed for the matcher is this:
/default/authoring/index/test.jpg?lenya.module=svg&height=120&width=160

So the transform may be running, but it doesn't match and you can't force
TinyMCE to have the proper URL as it keeps changing it to the first one.
Comment 16 Juergen Ragaller 2007-12-12 08:09:24 UTC
ui - think I found the option that is needed for this purpose:

TinyMCE can be configured to use absolute image urls:

http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/relative_urls

I just gave it a try by inserting 

relative_urls : false, 

into tiny_config.js;

It seems to work (link gets rewritten @ save) - but I'll have to do more testing before committing this.
Comment 17 Juergen Ragaller 2007-12-12 08:18:40 UTC
Mmmmh - setting relative_urls to false seems to work for image links but breaks internal links to other lenya pages (the end up having links in the page source like: /default/authoring/lenya-document:5d353320-a8ca-11dc-96fc-db94b5998549,lang=en).

There is also:
http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/document_base_url

Comment 18 Richard Frovarp 2008-03-13 13:35:42 UTC
This looks to be cleared up with the possible exception of TinyMCE. Could a user of that editor comment?
Comment 19 Juergen Ragaller 2008-03-15 03:37:24 UTC
(In reply to comment #18)
> This looks to be cleared up with the possible exception of TinyMCE. Could a
> user of that editor comment?
> 

TinyMCE seems to be currently broken - I tried to get it running by removing the (deprecated) menu.xsp and create a menu entry in xhtml/config/menu.xml like this:

<item uc:usecase="tinymce.edit"><i18n:text>With Tinymce</i18n:text></item>

results in a (usecase) error.


Reading the svn-history of the tinyMCE module, I think, that the current state still is: links have lenya-document:{UUID} syntax, image src attributes don't.

Comment 20 Juergen Ragaller 2008-03-15 08:44:48 UTC
(In reply to comment #18)
> This looks to be cleared up with the possible exception of TinyMCE. Could a
> user of that editor comment?
> 

... got tinymce running again

Image references are still non-uuid:
<img src="name.jpg" />

Comment 21 Richard Frovarp 2008-03-15 11:30:14 UTC
What about the resulting saved source? When they're inserted they go in as non-uuid, but they should be converted to uuids when saved. If you change the extension of a file from html in your browser to xml you'll see the saved source. Or you can always look on the filesystem as well.
Comment 22 Juergen Ragaller 2008-03-15 14:23:08 UTC
(In reply to comment #21)
> What about the resulting saved source? When they're inserted they go in as
> non-uuid, but they should be converted to uuids when saved. If you change the
> extension of a file from html in your browser to xml you'll see the saved
> source. Or you can always look on the filesystem as well.
> 

the source is non-uuid
Comment 23 Andreas Hartmann 2009-05-05 06:04:38 UTC
We could add a transformation step to transform the relative to absolute URIs:

http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_0_X/src/modules-core/linking/java/src/org/apache/lenya/cms/linking/RelativeToAbsoluteLinkRewriter.java?view=markup
Comment 24 Andreas Hartmann 2009-05-05 06:21:12 UTC
Fixed in 0. It would be great if someone could find the time to verify the fix. Thanks!
Comment 25 Juergen Ragaller 2009-05-10 09:05:21 UTC
I just tested the uuid image link behaviour inserting an image as child of features. Here are the result in the xml of the edited page. IIUC the behaviour is still broken.


The first time a freshly uploaded (from within timymce) image is inserted, non uuid style:
<img alt="test-image" height="133" src="/default/authoring/features/test-image.jpg" width="250"/>


The second time the same image is inserted, things look correct:
<img alt="test-image" height="133" src="lenya-document:a86b2740-3d7b-11de-a5c8-868a4fd960e2" width="250"/> 


When a page is reopened in tinymce svn parameters are added:
<img alt="test-image" height="133" src="lenya-document:a86b2740-3d7b-11de-a5c8-868a4fd960e2?lenya.module=svg&amp;height=133&amp;width=250" width="250"/>
Comment 26 Andreas Hartmann 2009-05-27 13:50:18 UTC
Does any of the TinyMCE users have the time to take a look at this issue?
Comment 27 Andreas Hartmann 2009-07-15 13:33:04 UTC
(In reply to comment #25)

> When a page is reopened in tinymce svn parameters are added:
> <img alt="test-image" height="133"
> src="lenya-document:a86b2740-3d7b-11de-a5c8-868a4fd960e2?lenya.module=svg&amp;height=133&amp;width=250"
> width="250"/>

The problem is that when the textarea for TinyMCE is filled, not the document source but the actual rendered page from the publication is used. This has several downsides:

* <object> is converted to <img>
* the svg module params are added
* …

IMO the whole integration is a hack, but I don't see an immediate remedy :(
Comment 28 Andreas Hartmann 2009-07-15 13:53:11 UTC
I just did some prototyping: Include the source instead of the assembled page. Seems to work fine if the source contains <img> as opposed to <object> elements.



Index: sitemap.xmap
===================================================================
--- sitemap.xmap	(4)
+++ sitemap.xmap	(working copy)
@@ -36,6 +36,13 @@
   <map:pipelines>
 
     <map:pipeline internal-only="yes">
+      
+      <map:match pattern="content.xml">
+        <map:generate src="lenya-document:"/>
+        <map:transform type="uuid2url"/>
+        <map:transform src="xslt/extractContent.xsl"/>
+        <map:serialize type="xml"/>
+      </map:match>
 
       <!-- when editing, the page should look exactly like the original, and since
            we cannot know anything about the pipelines used for rendering, we must
@@ -104,6 +111,7 @@
             <map:call resource="style-cms-page"/>
           </map:otherwise>
         </map:select>
+        <map:transform type="include"/>
         <map:transform type="i18n">      
           <map:parameter name="locale" value="{request:locale}"/>
         </map:transform>
Index: xslt/page2edit.xsl
===================================================================
--- xslt/page2edit.xsl	(5)
+++ xslt/page2edit.xsl	(working copy)
@@ -3,6 +3,7 @@
   xmlns="http://www.w3.org/1999/xhtml"
   xmlns:xhtml="http://www.w3.org/1999/xhtml"
   xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+  xmlns:i="http://apache.org/cocoon/include/1.0"
   exclude-result-prefixes="#default i18n"
 >
 
@@ -212,7 +213,10 @@
             <xsl:choose>
               <!-- firefox bug workaround: prevent <textarea/> from collapsing if empty -->
               <xsl:when test=".//*">
+                <i:include src="cocoon:/content.xml"/>
+                <!--
                 <xsl:apply-templates/>
+                -->
               </xsl:when>
               <xsl:otherwise>
                 <xsl:text>&#160;</xsl:text>
Comment 29 Andreas Hartmann 2009-07-15 13:56:15 UTC
Rainer Schoepf: you could use the cleanup function in tiny_config.js to convert between <object> and <img>