svn commit: r1100249 - in /lenya/branches/BRANCH_2_1_X/src: modules/editors/config/cocoon-xconf/ modules/editors/usecases/ modules/sitetree/java/src/org/apache/lenya/cms/cocoon/generation/ modules/sitetree/resources/javascript/ modules/sitetree/xslt/na...
[email protected] Fri, 06 May 2011 15:13:47 -0000
| Newsgroups | gmane.comp.cms.lenya.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: thorsten
Date: Fri May 6 15:13:46 2011
New Revision: 1100249
URL: http://svn.apache.org/viewvc?rev=1100249&view=rev
Log:
Refactoring the asset and image include selection of the source editor.
The former solution was causing Out-Of-Memory exceptions when pub had a lot of resources.
Now we use the "insert Link" approach to request the resources in pieces with AJAX.
Modified:
lenya/branches/BRANCH_2_1_X/src/modules/editors/config/cocoon-xconf/usecase-insertAsset.xconf
lenya/branches/BRANCH_2_1_X/src/modules/editors/config/cocoon-xconf/usecase-insertImage.xconf
lenya/branches/BRANCH_2_1_X/src/modules/editors/usecases/insertAsset.jx
lenya/branches/BRANCH_2_1_X/src/modules/sitetree/java/src/org/apache/lenya/cms/cocoon/generation/SitetreeFragmentGenerator.java
lenya/branches/BRANCH_2_1_X/src/modules/sitetree/resources/javascript/navtree.js
lenya/branches/BRANCH_2_1_X/src/modules/sitetree/xslt/navigation/sitetree2nav.xsl
lenya/branches/BRANCH_2_1_X/src/pubs/default/config/publication.xml
lenya/branches/BRANCH_2_1_X/src/pubs/default/sitemap.xmap
Modified: lenya/branches/BRANCH_2_1_X/src/modules/editors/config/cocoon-xconf/usecase-insertAsset.xconf
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_1_X/src/modules/editors/config/cocoon-xconf/usecase-insertAsset.xconf?rev=1100249&r1=1100248&r2=1100249&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_1_X/src/modules/editors/config/cocoon-xconf/usecase-insertAsset.xconf (original)
+++ lenya/branches/BRANCH_2_1_X/src/modules/editors/config/cocoon-xconf/usecase-insertAsset.xconf Fri May 6 15:13:46 2011
@@ -21,7 +21,7 @@
<component-instance
name="editors.insertAsset"
logger="lenya.publication"
- class="org.apache.lenya.cms.editors.InsertAsset"
+ class="org.apache.lenya.cms.editors.InsertLink"
>
<view
template="modules/editors/usecases/insertAsset.jx"
Modified: lenya/branches/BRANCH_2_1_X/src/modules/editors/config/cocoon-xconf/usecase-insertImage.xconf
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_1_X/src/modules/editors/config/cocoon-xconf/usecase-insertImage.xconf?rev=1100249&r1=1100248&r2=1100249&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_1_X/src/modules/editors/config/cocoon-xconf/usecase-insertImage.xconf (original)
+++ lenya/branches/BRANCH_2_1_X/src/modules/editors/config/cocoon-xconf/usecase-insertImage.xconf Fri May 6 15:13:46 2011
@@ -21,7 +21,7 @@
<component-instance
name="editors.insertImage"
logger="lenya.publication"
- class="org.apache.lenya.cms.editors.InsertAsset"
+ class="org.apache.lenya.cms.editors.InsertLink"
>
<view
template="modules/editors/usecases/insertAsset.jx"
Modified: lenya/branches/BRANCH_2_1_X/src/modules/editors/usecases/insertAsset.jx
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_1_X/src/modules/editors/usecases/insertAsset.jx?rev=1100249&r1=1100248&r2=1100249&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_1_X/src/modules/editors/usecases/insertAsset.jx (original)
+++ lenya/branches/BRANCH_2_1_X/src/modules/editors/usecases/insertAsset.jx Fri May 6 15:13:46 2011
@@ -1,4 +1,4 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -16,123 +16,78 @@
limitations under the License.
-->
-<!-- $Id: insertAsset.jx 508032 2007-02-15 17:41:53Z andreas $ -->
+<!--
+ $Id: link.xsl 555656 2007-07-12 15:17:47Z nettings $
+-->
<page:page xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0"
+ xmlns:proxy="http://apache.org/lenya/proxy/1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:i18n="http://apache.org/cocoon/i18n/2.1" >
- <page:head>
- <script type="text/javascript" src="/modules/editors/javascript/org.apache.lenya.editors.js"> </script>
- <script type="text/javascript" src="/modules/editors/javascript/insertAsset.js"> </script>
- </page:head>
-
- <!-- This view can handle both insertAsset and insertImage,
+ <!-- This view can handle both insertAsset and insertImage,
depending on the setting of the mode parameter ("Asset"|"Image") -->
<jx:set var="mode" value="${usecase.getParameterAsString('mode')}"/>
+ <jx:set var="doc" value="${usecase.getParameter('document')}"/>
<page:title>
<i18n:text>insertAsset.heading<jx:out value="${mode}"/></i18n:text>
</page:title>
- <page:body>
-
- <form method="POST" name="insertAsset">
+ <page:body style="width:auto;">
+
+ <script type="text/javascript" src="/modules/sitetree/javascript/tree.js"> </script>
+ <script type="text/javascript" src="/modules/sitetree/javascript/lenyatree.js"> </script>
+ <script type="text/javascript" src="/modules/sitetree/javascript/navtree.js"> </script>
+ <script type="text/javascript" src="/modules/editors/javascript/org.apache.lenya.editors.js"> </script>
+ <script type="text/javascript" src="/modules/jquery/jquery.js"> </script>
+ <script type="text/javascript" src="/modules/editors/javascript/insertAssetTree.js"> </script>
+ <script type="text/javascript">
+ AREA = "${doc.getArea()}";
+ DOCUMENT_ID = "${doc.getPath()}";
+ PUBLICATION_ID = "${doc.getPublication().getId()}";
+ CHOSEN_LANGUAGE = "${doc.getLanguage()}";
+ DEFAULT_LANGUAGE = "${doc.getPublication().getDefaultLanguage()}";
+ IMAGE_PATH = '<proxy:url href="/lenya/images/tree/"/>';
+ CUT_DOCUMENT_ID = '';
+ ALL_AREAS = "authoring";
+ PIPELINE_PATH = 'modules/sitetree/sitetree-fragment.xml';
+ WEBAPP_BASE_PATH = '<proxy:url href="/"/>';
+ MODE_INSERT = '${mode}';
+ </script>
+
+ <div id="lenya-info-treecanvas" style="width: 250px;">
+ <div class="lenya-tabs">
+ <jx:forEach var="language" items="${doc.getPublication().getLanguages()}">
+ <jx:choose>
+ <jx:when test="${doc.getLanguage().equals(language)}">
+ <a id="${language}" class="lenya-tablink-active"><jx:out value="${language}"/></a>
+ </jx:when>
+ <jx:otherwise>
+ <a id="${language}" class="lenya-tablink" href="lenya-document:,lang=${language}?lenya.usecase=editors.insertAsset">
+ <jx:out value="${language}"/>
+ </a>
+ </jx:otherwise>
+ </jx:choose>
+ </jx:forEach>
+ </div>
+ <div id="lenya-info-tree">
+ <div id="tree"> 
+ </div>
+ </div>
+ </div>
+ <form method="POST" name="insertAsset">
<jx:import uri="fallback://lenya/modules/usecase/templates/messages.jx"/>
<input type="hidden" name="lenya.usecase" value="${usecase.getName()}"/>
<input type="hidden" name="lenya.continuation" value="${continuation.id}"/>
- <div class="lenya-box">
+ <div class="lenya-box" style="margin-left: 260px;">
<div class="lenya-box-title">
<i18n:text>insertAsset.available<jx:out value="${mode}"/></i18n:text>
</div>
<div class="lenya-box-body">
-
- <table class="lenya-table-list" style="border: none">
-
- <tr>
- <th style="background: none;"/>
- <th style="background: none;"><i18n:text>insertAsset.file</i18n:text></th>
- <th style="background: none;"><i18n:text>insertAsset.preview</i18n:text></th>
- <th style="background: none;"><i18n:text>insertAsset.title</i18n:text></th>
- <th style="background: none;"><i18n:text>insertAsset.fileSize</i18n:text></th>
- <th style="background: none;"><i18n:text>insertAsset.imageSize</i18n:text></th>
- <th style="background: none;"><i18n:text>insertAsset.creationDate</i18n:text></th>
- </tr>
-
- <jx:set var="asset2proxyUrl" value="${usecase.getParameter('asset2proxyUrl')}"/>
- <jx:forEach var="asset" items="${usecase.getParameter('assets')}">
- <jx:set var="mimeType" value="${asset.getMimeType()}"/>
- <!-- Images are displayed in both "Asset" and "Image" mode. Other resources
- are displayed only in "Asset" mode. -->
- <jx:if test="${mode.equals('Asset') || mimeType.startsWith('image/')}">
- <!-- We must differenciate between images and assets here:
- images get a path-based URL to allow WYSIWYG editors to render them
- (they will be converted to lenya-document: UR later).
- Assets get a UUID-based lenya-document URL.
- -->
- <jx:choose>
- <jx:when test="${mode.equals('Image')}">
- <jx:set var="height" value="${asset.getMetaData('http://apache.org/lenya/metadata/media/1.0').getFirstValue('height') + ''}"/>
- <jx:set var="url" value="${asset2proxyUrl.get(asset)}"/>
- <jx:set var="width" value="${asset.getMetaData('http://apache.org/lenya/metadata/media/1.0').getFirstValue('width') + ''}"/>
- </jx:when>
- <jx:otherwise>
- <jx:set var="url" value="${('lenya-document:' + asset.getUUID() + ',lang=' + asset.getLanguage())}"/>
- </jx:otherwise>
- </jx:choose>
- <tr>
- <td>
- <!-- The "+''" construction is to avoid nulls (it forces them to be cast to the empty string).
- Undefined values would cause the form field to be disabled.
- -->
- <input type="radio" name="asset" value="${asset.getPath()}"
- onClick="updateData(
- '${url}',
- '${asset.getMetaData('http://purl.org/dc/elements/1.1/').getFirstValue('title') + ''}',
- '${height}',
- '${width}',
- '${asset.getMimeType() + ''}'
- )"
- />
- </td>
- <td>
- <jx:out value="${asset.getPath()}"/>
- </td>
- <td style="width: 50px; overflow: hidden;">
- <jx:choose>
- <jx:when test="${mimeType.startsWith('image/')}">
- <!-- Add one to avoid dividing by 0 -->
- <jx:set var="scaledWidth" value="${Packages.java.lang.Math.round(width / ( height + 1 ) * 32.0)}"/>
- <img src="${url}?lenya.module=svg&height=32&width=${scaledWidth}" style="height: 32px; vertical-align: middle; margin: 3px 0px;"/> 
- </jx:when>
- <jx:otherwise>
- <jx:out value="${mimeType}"/>
- </jx:otherwise>
- </jx:choose>
- </td>
- <td>
- <jx:out value="${asset.getMetaData('http://purl.org/dc/elements/1.1/').getFirstValue('title')}"/>
- </td>
- <td align="right" style="white-space: nowrap;">
- <jx:out value="${asset.getContentLength() / 1000}"/> kB
- </td>
- <td align="right" style="white-space: nowrap;">
- <jx:if test="${mimeType.startsWith('image/')}">
- <jx:out value="${width}"/> x <jx:out value="${height}"/></jx:if>
- </td>
- <td align="right" style="white-space: nowrap;">
- <jx:out value="${java.text.DateFormat.getDateInstance().format(asset.getLastModified())}"/>
- </td>
- </tr>
- </jx:if>
- </jx:forEach>
-
- </table>
-
- <br/>
<input type="hidden" name="url" value=""/>
<input type="hidden" name="type" value=""/>
<input type="hidden" name="ratio" value=""/>
@@ -153,7 +108,6 @@
<input class="lenya-form-element" type="text" name="title" title=""/>
</td>
</tr>
-
<jx:if test="${mode.equals('Image')}">
<tr>
<td class="lenya-entry-caption">
@@ -172,7 +126,10 @@
</td>
</tr>
</jx:if>
-
+ <tr>
+ <td colspan="2" id="preview">
+ </td>
+ </tr>
<tr>
<td colspan="2">
<input
@@ -203,6 +160,6 @@
</div>
</form>
-
</page:body>
+
</page:page>
Modified: lenya/branches/BRANCH_2_1_X/src/modules/sitetree/java/src/org/apache/lenya/cms/cocoon/generation/SitetreeFragmentGenerator.java
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_1_X/src/modules/sitetree/java/src/org/apache/lenya/cms/cocoon/generation/SitetreeFragmentGenerator.java?rev=1100249&r1=1100248&r2=1100249&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_1_X/src/modules/sitetree/java/src/org/apache/lenya/cms/cocoon/generation/SitetreeFragmentGenerator.java (original)
+++ lenya/branches/BRANCH_2_1_X/src/modules/sitetree/java/src/org/apache/lenya/cms/cocoon/generation/SitetreeFragmentGenerator.java Fri May 6 15:13:46 2011
@@ -33,10 +33,12 @@ import org.apache.cocoon.generation.Serv
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceResolver;
import org.apache.excalibur.source.SourceValidity;
+import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentFactory;
import org.apache.lenya.cms.publication.DocumentUtil;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.PublicationException;
+import org.apache.lenya.cms.publication.ResourceType;
import org.apache.lenya.cms.publication.URLInformation;
import org.apache.lenya.cms.repository.RepositoryUtil;
import org.apache.lenya.cms.repository.Session;
@@ -119,6 +121,8 @@ public class SitetreeFragmentGenerator e
public static final String ATTR_LANG = "lang";
public static final String ATTR_TYPE = "mimetype";
+ public static final String ATTR_RESOURCE_TYPE = "resourceType";
+
/**
* @see org.apache.cocoon.sitemap.SitemapModelComponent#setup(org.apache.cocoon.environment.SourceResolver,
* java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
@@ -464,9 +468,19 @@ public class SitetreeFragmentGenerator e
try {
Publication pub = this.site.getPublication();
String area = this.site.getArea();
- String type = pub.getArea(area).getDocument(node.getUuid(),
- pub.getDefaultLanguage()).getMimeType();
+ Document document = pub.getArea(area).getDocument(node.getUuid(),
+ pub.getDefaultLanguage());
+ String type = document.getMimeType();
this.attributes.addAttribute("", ATTR_TYPE, ATTR_TYPE, "CDATA", type);
+ try {
+ ResourceType resourceType = document.getResourceType();
+ if(resourceType!=null){
+ String resource = resourceType.getName();
+ this.attributes.addAttribute("", ATTR_RESOURCE_TYPE, ATTR_RESOURCE_TYPE, "CDATA", resource);
+ }
+ } catch (Exception e) {
+ getLogger().fatalError("ResourceType is null, which should not happen!", e);
+ }
} catch (PublicationException e) {
throw new SiteException(e);
}
Modified: lenya/branches/BRANCH_2_1_X/src/modules/sitetree/resources/javascript/navtree.js
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_1_X/src/modules/sitetree/resources/javascript/navtree.js?rev=1100249&r1=1100248&r2=1100249&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_1_X/src/modules/sitetree/resources/javascript/navtree.js (original)
+++ lenya/branches/BRANCH_2_1_X/src/modules/sitetree/resources/javascript/navtree.js Fri May 6 15:13:46 2011
@@ -33,7 +33,9 @@ function NavNode(id, parent) {
this.label = '';
this.area = '';
this.path = '';
+ this.isresource = false;
this.isprotected = true;
+ this.mimetype = '';
this.existsChosenLanguage = true;
this.langSuffix = '';
};
@@ -50,6 +52,8 @@ NavNode.prototype.createNewNode = functi
newItem.path = node.getAttribute('path');
newItem.uuid = node.getAttribute('uuid');
newItem.isprotected = isNodeProtected(node);
+ newItem.mimetype = getMimeType(node);
+ newItem.isresource =isResource(node);
newItem.href = node.getAttribute('href');
newItem.icon = node.getAttribute('icon');
newItem.label = getLabel(node);
@@ -71,6 +75,7 @@ NavNode.prototype.getLoadSubTreeURL = fu
+ '?pub=' + PUBLICATION_ID
+ '&area=' + area
+ '&path=' + path
+ + '&mimetype=true'
+ '&language=' + CHOSEN_LANGUAGE
+ '&defaultLanguage=' + DEFAULT_LANGUAGE
+ '&areas=' + ALL_AREAS);
@@ -116,6 +121,18 @@ function isNodeProtected(node) {
return false;
}
+function getMimeType(node) {
+ var prot = node.getAttribute('mimetype');
+ if (prot === null) return '';
+ return prot;
+}
+
+function isResource(node) {
+ var prot = node.getAttribute('resourceType');
+ if (prot === "resource") return true;
+ return false;
+}
+
function isNodeFolder(node) {
var isfolder = node.getAttribute('folder');
if (isfolder == 'true') return true;
@@ -164,7 +181,8 @@ NavTree.prototype.loadInitialTree = func
var url = encodeURI(WEBAPP_BASE_PATH + PIPELINE_PATH + '?'
+ 'pub=' + PUBLICATION_ID
+ '&area=' + area
- + '&path=' + path
+ + '&path=' + path
+ + '&mimetype=true'
+ '&defaultLanguage=' + DEFAULT_LANGUAGE
+ '&language=' + CHOSEN_LANGUAGE
+ '&initial=true'
@@ -215,10 +233,11 @@ NavTree.prototype.addLoadedSite = functi
newSite.area = siteArea;
newSite.path = '/';
newSite.isprotected = isNodeProtected(site);
+ newSite.mimetype = getMimeType(site);
+ newSite.isresource =isResource(site);
newSite.href = site.getAttribute('href') + "/" + langSuffix;
newSite.langSuffix = langSuffix;
newSite.label = site.getAttribute('label');
-
return newSite;
}
Modified: lenya/branches/BRANCH_2_1_X/src/modules/sitetree/xslt/navigation/sitetree2nav.xsl
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_1_X/src/modules/sitetree/xslt/navigation/sitetree2nav.xsl?rev=1100249&r1=1100248&r2=1100249&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_1_X/src/modules/sitetree/xslt/navigation/sitetree2nav.xsl (original)
+++ lenya/branches/BRANCH_2_1_X/src/modules/sitetree/xslt/navigation/sitetree2nav.xsl Fri May 6 15:13:46 2011
@@ -158,6 +158,13 @@ Apply nodes recursively
<xsl:value-of select="@mimetype"/>
</xsl:attribute>
</xsl:if>
+
+ <xsl:if test="@resourceType">
+ <xsl:attribute name="resourceType">
+ <xsl:value-of select="@resourceType"/>
+ </xsl:attribute>
+ </xsl:if>
+
<xsl:choose>
<xsl:when test="tree:label[lang($existinglanguage)]">
Modified: lenya/branches/BRANCH_2_1_X/src/pubs/default/config/publication.xml
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_1_X/src/pubs/default/config/publication.xml?rev=1100249&r1=1100248&r2=1100249&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_1_X/src/pubs/default/config/publication.xml (original)
+++ lenya/branches/BRANCH_2_1_X/src/pubs/default/config/publication.xml Fri May 6 15:13:46 2011
@@ -88,6 +88,7 @@
<module name="monitoring"/>
<module name="navigation"/>
<module name="tinymce"/>
+ <module name="jquery"/>
</modules>
<!-- TODO: The goal is to have a blog module ;-) -->
<!--
Modified: lenya/branches/BRANCH_2_1_X/src/pubs/default/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_1_X/src/pubs/default/sitemap.xmap?rev=1100249&r1=1100248&r2=1100249&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_1_X/src/pubs/default/sitemap.xmap (original)
+++ lenya/branches/BRANCH_2_1_X/src/pubs/default/sitemap.xmap Fri May 6 15:13:46 2011
@@ -82,7 +82,7 @@
Here we use .html.meta, bxe uses .bxe.html.
-->
<map:match pattern="*/**.html.meta">
- <map:generate type="lenyaMetaData" src="lenya-document:"/>
+ <map:generate type="lenyaMetaData" src="lenya-document:{page-envelope:document-uuid},area={1},lang={page-envelope:document-language}"/>
<map:serialize type="xml"/>
</map:match>