You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by ne...@apache.org on 2007/07/24 16:44:14 UTC

svn commit: r559065 - in /lenya/trunk/src/modules/tinymce: resources/javascript/tiny_config.js resources/javascript/tiny_config.xml sitemap.xmap xslt/page2edit.xsl

Author: nettings
Date: Tue Jul 24 07:44:13 2007
New Revision: 559065

URL: http://svn.apache.org/viewvc?view=rev&rev=559065
Log:
simplified tinymce localisation code (folded into page2edit.xsl
transform, gets rid of extra javascript transform).

Added:
    lenya/trunk/src/modules/tinymce/resources/javascript/tiny_config.js
Removed:
    lenya/trunk/src/modules/tinymce/resources/javascript/tiny_config.xml
Modified:
    lenya/trunk/src/modules/tinymce/sitemap.xmap
    lenya/trunk/src/modules/tinymce/xslt/page2edit.xsl

Added: lenya/trunk/src/modules/tinymce/resources/javascript/tiny_config.js
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/tinymce/resources/javascript/tiny_config.js?view=auto&rev=559065
==============================================================================
--- lenya/trunk/src/modules/tinymce/resources/javascript/tiny_config.js (added)
+++ lenya/trunk/src/modules/tinymce/resources/javascript/tiny_config.js Tue Jul 24 07:44:13 2007
@@ -0,0 +1,123 @@
+  /*
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+*/
+
+/* 
+these are the configuration settings for TinyMCE. a complete list 
+of options can be found in the excellent manual at
+http://tinymce.moxiecode.com/tinymce/docs/reference_configuration.html
+*/
+
+
+    currentURL = location.href.replace(/\?.*$/,"");
+
+    config = {
+
+    /* enable customizable theme */
+    theme    : "advanced",
+
+    /* only the element whose ID is listed under "elements" will be editable */
+    mode     : "exact",
+    elements : "tinymce.content",
+
+    /* enable plugins for custom save function, fullscreen editing
+      and search-and-replace. */
+    plugins  : "save,fullscreen,searchreplace,table,contextmenu,simplebrowser",
+    
+       plugin_simplebrowser_browselinkurl : currentURL + '?lenya.usecase=editors.insertLink',
+       plugin_simplebrowser_browseimageurl : currentURL + '?lenya.usecase=tinymce.insertImage',
+       plugin_simplebrowser_browseflashurl : '',
+     
+
+    /* grey out the "save" button unless there are unsaved changes: */
+    save_enablewhendirty : false,
+
+    /* some special settings for fullscreen mode (they override the 
+      settings further down) */
+    fullscreen_settings : {
+            auto_resize : false,
+            theme_advanced_toolbar_location : "top",
+            theme_advanced_statusbar_location : "bottom"
+    },
+
+    /* auto-resize the editing area. docs say this is "experimental"! */
+    auto_resize : false,
+
+    /* characters that should be replaced by named XHTML entities.
+       cocoon does not define entities by default, so we use none. */
+    entities        : "",
+
+    /* do not make unicode references, output all special characters unchanged. */
+    entity_encoding : "raw",
+
+    /* keep linebreaks, don't put everything on one line. this is 
+       important for advanced users who want to use the source editor. */
+    remove_linebreaks       : false,
+
+    /* prettyprint sourcecode on saving FIXME: test. does this do anything? */
+    apply_source_formatting : true,
+
+    /* if the user inserts a table into a p, split p to create correct code.
+       for nested lists, the inner list is correctly placed in a <li/>
+    fix_list_elements: true;
+    fix_table_elements: true;
+
+    /* let tinymce do the layout by itself */
+    theme_advanced_layout_manager     : "SimpleLayout",
+
+    /* the toolbar is placed at the top of the editable area. */
+    theme_advanced_toolbar_location   : "top",
+
+    /* the statusbar is placed at the bottom. it displays the element path. */
+    theme_advanced_statusbar_location : "bottom",
+
+    /* the following items define the function buttons your users get to see.
+      for a complete list, see
+      http://tinymce.moxiecode.com/tinymce/docs/reference_buttons.html */
+
+    theme_advanced_buttons1 :
+            "save,undo,redo,search,replace,separator," + 
+            "cleanup,code,charmap,visualaid,fullscreen,separator," + 
+            "formatselect,styleselect",
+
+    theme_advanced_buttons2 : 
+            "bold,italic,underline,strikethrough,sub,sup,removeformat,separator," +
+            "bullist,numlist,table,separator," + 
+            "indent,outdent,separator," + 
+            "anchor,link,unlink,image,separator," +
+            "help",
+
+    /* three button rows are active by default. override. */
+    theme_advanced_buttons3 : "",
+
+    /* the following items define the allowed elements and attributes on your site. 
+      the default setting is very restrictive to enforce a corporate design and clean
+      code at the expense of flexibility. */
+    theme_advanced_blockformats       : "p,h1,h2,h3,h4",
+
+
+/*
+Lenya/TinyMCE glue code
+*/
+
+    /* this callback can override arbitrary tinymce commands. neato!
+       currently used hooks are "insert image", "insert link" and "save". 
+       the handler sits in tiny_lenya_glue.js. */
+    execcommand_callback : "LenyaExecCommandHandler",
+
+    /* insert custom save handler to do some extra clean-up. */
+    save_callback : "LenyaSaveContent"
+    };

Modified: lenya/trunk/src/modules/tinymce/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/tinymce/sitemap.xmap?view=diff&rev=559065&r1=559064&r2=559065
==============================================================================
--- lenya/trunk/src/modules/tinymce/sitemap.xmap (original)
+++ lenya/trunk/src/modules/tinymce/sitemap.xmap Tue Jul 24 07:44:13 2007
@@ -57,11 +57,12 @@
         <map:transform src="context://lenya/xslt/util/strip_namespaces.xsl"/>
         <map:serialize type="xml"/>
       </map:match>
+
     </map:pipeline>
 
     <map:pipeline>
 
-      <!-- this is the view of the usecase (see config/cocoon-xconf/usecases.xconf) -->
+      <!-- this is the view of the usecase (see config/cocoon-xconf/usecase-tinymce-edit.xconf) -->
 
       <map:match pattern="tinymce.edit">
         <!-- check if TinyMCE is installed -->
@@ -72,12 +73,28 @@
               <map:part src="cocoon:/tinymce.delegateToPubSitemap/authoring{page-envelope:document-url}"/>
               <map:part src="cocoon:/tinymce.getUsecaseMessages"/>
             </map:aggregate>
-            <map:transform src="fallback://lenya/modules/tinymce/xslt/page2edit.xsl">
-              <map:parameter name="contextPath" value=""/>
-              <map:parameter name="continuationId" value="{flow-continuation:id}"/>
-              <map:parameter name="usecaseName" value="{request-param:lenya.usecase}"/>
-              <map:parameter name="publicationid" value="{page-envelope:publication-id}"/>
-            </map:transform>
+            <!-- Check for language pack to render TinyMCE according to the 
+                 requested locale. If it does not exist, fall back to English. --> 
+            <map:select type="resource-exists">
+              <map:when test="fallback://lenya/modules/tinymce/resources/tinymce/jscripts/tiny_mce/langs/{request:locale}.js">
+                <map:transform src="fallback://lenya/modules/tinymce/xslt/page2edit.xsl">
+                  <map:parameter name="contextPath" value=""/>
+                  <map:parameter name="continuationId" value="{flow-continuation:id}"/>
+                  <map:parameter name="usecaseName" value="{request-param:lenya.usecase}"/>
+                  <map:parameter name="publicationid" value="{page-envelope:publication-id}"/>
+                  <map:parameter name="locale" value="{request:locale}"/>
+                </map:transform>
+              </map:when>
+              <map:otherwise>
+                <map:transform src="fallback://lenya/modules/tinymce/xslt/page2edit.xsl">
+                  <map:parameter name="contextPath" value=""/>
+                  <map:parameter name="continuationId" value="{flow-continuation:id}"/>
+                  <map:parameter name="usecaseName" value="{request-param:lenya.usecase}"/>
+                  <map:parameter name="publicationid" value="{page-envelope:publication-id}"/>
+                  <map:parameter name="locale" value="en"/>
+                </map:transform>
+              </map:otherwise>
+            </map:select>
           </map:when>
           <!-- TinyMCE is not installed - generate info page for the user -->
           <map:otherwise>
@@ -86,25 +103,6 @@
         </map:select>
         <map:call resource="style-cms-page"/>
         <map:serialize type="xhtml"/>
-      </map:match>
-
-      <!-- check requested locale and set appropriate tinymce language, if available. if not, fall back to english -->
-      <map:match pattern="tiny_config.xml">
-        <map:generate src="fallback://lenya/modules/tinymce/resources/javascript/tiny_config.xml"/>
-        <map:select type="resource-exists">
-          <!-- fixme: is this an appropriate test for language packs? -->
-          <map:when test="fallback://lenya/modules/tinymce/resources/tinymce/jscripts/tiny_mce/langs/{request:locale}.js">
-            <map:transform src="fallback://lenya/modules/tinymce/xslt/tiny_config.xsl">  
-              <map:parameter name="locale" value="{request:locale}"/>
-            </map:transform>
-          </map:when>
-          <map:otherwise>
-            <map:transform src="fallback://lenya/modules/tinymce/xslt/tiny_config.xsl">  
-              <map:parameter name="locale" value="en"/>
-            </map:transform>
-          </map:otherwise>
-        </map:select>
-        <map:serialize type="text"/>
       </map:match>
 
     </map:pipeline>

Modified: lenya/trunk/src/modules/tinymce/xslt/page2edit.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/tinymce/xslt/page2edit.xsl?view=diff&rev=559065&r1=559064&r2=559065
==============================================================================
--- lenya/trunk/src/modules/tinymce/xslt/page2edit.xsl (original)
+++ lenya/trunk/src/modules/tinymce/xslt/page2edit.xsl Tue Jul 24 07:44:13 2007
@@ -16,6 +16,7 @@
 <xsl:param name="continuationId" select="'tinymce.ERROR'"/>
 <xsl:param name="usecaseName" select="'tinymce.ERROR'"/>
 <xsl:param name="publicationid" />
+<xsl:param name="locale" select="'tinymce.ERROR'"/>
 
 
 <!--
@@ -24,14 +25,30 @@
 -->
 <xsl:template match="tinymceWrapper">
   <xsl:if test="$contextPath='tinymce.ERROR'">
-    <xsl:message terminate="yes"><i18n:text>Missing contextPath parameter! Check your tinymce sitemap.</i18n:text></xsl:message>
+    <xsl:message terminate="yes">
+      <i18n:text>Missing contextPath parameter!</i18n:text>
+      <i18n:text>Check your tinymce sitemap.</i18n:text>
+    </xsl:message>
   </xsl:if>
   <xsl:if test="$continuationId='tinymce.ERROR'">
-    <xsl:message terminate="yes"><i18n:text>Missing continuationId parameter! Check your tinymce sitemap.</i18n:text></xsl:message>
+    <xsl:message terminate="yes">
+      <i18n:text>Missing continuationId parameter!</i18n:text>
+      <i18n:text>Check your tinymce sitemap.</i18n:text>
+    </xsl:message>
   </xsl:if>
   <xsl:if test="$usecaseName='tinymce.ERROR'">
-    <xsl:message terminate="yes"><i18n:text>Missing usecaseName parameter! Check your tinymce sitemap.</i18n:text></xsl:message>
+    <xsl:message terminate="yes">
+      <i18n:text>Missing usecaseName parameter!</i18n:text>
+      <i18n:text>Check your tinymce sitemap.</i18n:text>
+    </xsl:message>
   </xsl:if>
+  <xsl:if test="$locale='tinymce.ERROR'">
+    <xsl:message terminate="yes">
+      <i18n:text>Missing locale parameter!</i18n:text>
+      <i18n:text>Check your tinymce sitemap.</i18n:text>
+    </xsl:message>
+  </xsl:if>
+
   <xsl:apply-templates select="xhtml:html"/>
 </xsl:template>
 
@@ -49,7 +66,7 @@
   <xsl:comment>special code for tinymce.edit usecase view</xsl:comment>
   <xsl:text>
   </xsl:text>
-  <xsl:comment>without the &#160; weirdness, firefox tends to interpret the whole page as a comment or something.</xsl:comment>
+  <xsl:comment>without the space between opening and closing script tag, Firefox tends to interpret the whole page as a comment or something :(</xsl:comment>
   <xsl:text>
   </xsl:text>
   <xsl:comment>the tinymce code:</xsl:comment>
@@ -75,7 +92,7 @@
   </xsl:text>
   <script language="javascript" 
           type="text/javascript"
-          src="/{$publicationid}/modules/tinymce/tiny_config.xml"
+          src="/{$publicationid}/modules/tinymce/javascript/tiny_config.js"
   >&#160;</script>
   <xsl:text>
   </xsl:text>
@@ -104,18 +121,25 @@
 
     /* pass all the stylesheets of the current page (except for those specific
        to the Lenya authoring GUI) to TinyMCE for true WYSIWYG editing */
+
+    config['language'] = "</xsl:text>
+    <xsl:value-of select="$locale"/>
+    <xsl:text>";
     config['content_css'] = "</xsl:text>
+
     <xsl:value-of select="$contextPath"/>
     <xsl:text>/modules/tinymce/css/editor_content.css</xsl:text>
     <xsl:for-each select="../xhtml:link[@rel='stylesheet' and not(contains(@href, '/lenya/css/'))]">
         <xsl:text>,</xsl:text>
         <xsl:value-of select="@href"/>
     </xsl:for-each>
+
     <xsl:text>";
 
     tinyMCE.init(config);
 
     </xsl:text>
+
     </script>
 </xsl:template>
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org