Hi Alex,
All commits that fix something or make some changes (except refactoring, ie same behavior, just internal way the code is written) must reference a jira issue.
If this problem was caused by some changes in the trunk that wasn't released yet, you should use the same jira issue. If it's a fix over some previously released version then it needs a new jira issue. The idea is that a user who looks at the release notes must be able to see what was modified vs the version he has.
Thanks
-Vincent
On Sep 11, 2010, at 7:15 PM, abusenius (SVN) wrote:
> Author: abusenius
> Date: 2010-09-11 19:15:10 +0200 (Sat, 11 Sep 2010)
> New Revision: 31048
>
> Modified:
> platform/web/trunk/standard/src/main/webapp/templates/editobject.vm
> Log:
> [misc] Fixed broken URL
>
> Modified: platform/web/trunk/standard/src/main/webapp/templates/editobject.vm
> ===================================================================
> --- platform/web/trunk/standard/src/main/webapp/templates/editobject.vm 2010-09-11 02:32:40 UTC (rev 31047)
> +++ platform/web/trunk/standard/src/main/webapp/templates/editobject.vm 2010-09-11 17:15:10 UTC (rev 31048)
> @@ -16,7 +16,7 @@
> #macro(displayObject $obj $class $props $firstfield)
> <div id="xobject_${escapetool.xml($class.name)}_${obj.number}" class="xobject">
> <div id="xobject_${escapetool.xml($class.name)}_${obj.number}_title" class="xobject-title"><h3>#cleanClassname(${class.name}) ${obj.number}: $!{escapetool.xml($doc.display($firstfield, $obj))}
> - <a href="$doc.getURL('objectremove', "classname=${escapetool.url($class.name)}&classid=${obj.number}&xredirect=${doc.getURL('edit', 'editor=object')}")" class="xobject-action delete" title="$msg.get('core.editors.object.removeObject.tooltip')">$msg.get('core.editors.object.removeObject')</a>
> + <a href="$doc.getURL('objectremove', "classname=${escapetool.url($class.name)}&classid=${obj.number}&xredirect=${escapetool.url($doc.getURL('edit', 'editor=object'))}")" class="xobject-action delete" title="$msg.get('core.editors.object.removeObject.tooltip')">$msg.get('core.editors.object.removeObject')</a>
> #if(!$hasCustomObject) <a href="$doc.getURL("edit", "editor=object&classname=${escapetool.url($class.name)}&object=${obj.number}")" class="xobject-action edit" title="$msg.get('core.editors.object.editSingleObject.tooltip')">$msg.get('core.editors.object.editSingleObject')</a> #end
> </h3></div>
> <div id="xobject_${escapetool.xml($class.name)}_${obj.number}_content" class="xobject-content"><div>
Hi Marius,
I think there are some changes we need to discuss in this commit:
- new config api methods
- new wiki model api methods
- new deps introduced in the rendering module (makes it harder to use without maven)
These 2 are important as they are important public apis. The WikiModel one is the most important and we need to be 100% sure we want to add a new methods. There must absolutely be the minimal number of methods in this class. Also we're going to break people using the rendering module outside of xwiki (guys from eXo for example, so we need to be careful).
I haven't thought too much about it yet but my first feeling is that the methods added look quite specific. I'd like to have Thomas's opinion on this since he's the one who's the most knowledgeable about the rendering module.
Thanks
-Vincent
On Sep 12, 2010, at 1:30 PM, mflorea (SVN) wrote:
> Author: mflorea
> Date: 2010-09-12 13:30:15 +0200 (Sun, 12 Sep 2010)
> New Revision: 31053
>
> Modified:
> platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/configuration/RenderingConfiguration.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/configuration/DefaultRenderingConfiguration.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/xhtml/DefaultXHTMLImageRenderer.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/wiki/WikiModel.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/pom.xml
> platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/configuration/XWikiRenderingConfiguration.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/wiki/XWikiWikiModel.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/test/java/org/xwiki/rendering/internal/configuration/XWikiRenderingConfigurationTest.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/test/java/org/xwiki/rendering/internal/wiki/XWikiWikiModelTest.java
> Log:
> XWIKI-5479: Include image dimensions in the image URL for server side image resizing
>
> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/configuration/RenderingConfiguration.java
> ===================================================================
> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/configuration/RenderingConfiguration.java 2010-09-11 17:15:46 UTC (rev 31052)
> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/configuration/RenderingConfiguration.java 2010-09-12 11:30:15 UTC (rev 31053)
> @@ -50,7 +50,7 @@
> * </ul>
> * Note that if the page title is empty or not defined then it defaults to %p. This is also the case
> * if the title cannot be retrieved for the document.
> - *
> + *
> * The default is "%p". Some examples: "%s.%p", "%w:%s.%p".
> *
> * @return the format to use to display link labels when the user hasn't specified a label
> @@ -63,4 +63,42 @@
> * descriptor (ie defined by the macro author) will be used
> */
> Properties getMacroCategories();
> +
> + /**
> + * @return {@code true} to include the image dimensions extracted from the image parameters in the image URL,
> + * {@code false} otherwise; when image dimensions are included in the image URL the image can be resized
> + * on the server side before being downloaded.
> + * @since 2.5M2
> + */
> + boolean isIncludeImageDimensionsInImageURL();
> +
> + /**
> + * One way to improve page load speed is to resize images on the server side just before rendering the page. The
> + * rendering module can use the image width provided by the user to scale the image. When the user doesn't specify
> + * the image width the rendering module can limit the width of the image based on this configuration parameter.
> + * <p>
> + * The default value is {@code -1} which means image width is not limited by default. Use a value greater than 0 to
> + * limit the image width (pixels). Note that the aspect ratio is kept even when both the width and the height of the
> + * image are limited.
> + *
> + * @return the maximum image width when there's no user supplied width
> + * @see #isIncludeImageDimensionsInImageURL()
> + * @since 2.5M2
> + */
> + int getImageWidthLimit();
> +
> + /**
> + * One way to improve page load speed is to resize images on the server side just before rendering the page. The
> + * rendering module can use the image height provided by the user to scale the image. When the user doesn't specify
> + * the image height the rendering module can limit the height of the image based on this configuration parameter.
> + * <p>
> + * The default value is {@code -1} which means image height is not limited by default. Use a value greater than 0 to
> + * limit the image height (pixels). Note that the aspect ratio is kept even when both the width and the height of
> + * the image are limited.
> + *
> + * @return the maximum image height when there's no user supplied height
> + * @see #isIncludeImageDimensionsInImageURL()
> + * @since 2.5M2
> + */
> + int getImageHeightLimit();
> }
>
> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/configuration/DefaultRenderingConfiguration.java
> ===================================================================
> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/configuration/DefaultRenderingConfiguration.java 2010-09-11 17:15:46 UTC (rev 31052)
> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/configuration/DefaultRenderingConfiguration.java 2010-09-12 11:30:15 UTC (rev 31053)
> @@ -45,6 +45,21 @@
> private Properties macroCategories = new Properties();
>
> /**
> + * @see #getImageWidthLimit()
> + */
> + private int imageWidthLimit = -1;
> +
> + /**
> + * @see #getImageHeightLimit()
> + */
> + private int imageHeightLimit = -1;
> +
> + /**
> + * @see #isIncludeImageDimensionsInImageURL()
> + */
> + private boolean includeImageDimensionsInImageURL = true;
> +
> + /**
> * {@inheritDoc}
> *
> * @see org.xwiki.rendering.configuration.RenderingConfiguration#getLinkLabelFormat()
> @@ -84,4 +99,66 @@
> // to work even without a configuration store.
> this.macroCategories.setProperty(macroId.toString(), category);
> }
> +
> + /**
> + * {@inheritDoc}
> + *
> + * @see org.xwiki.rendering.configuration.RenderingConfiguration#getImageWidthLimit()
> + */
> + public int getImageWidthLimit()
> + {
> + return this.imageWidthLimit;
> + }
> +
> + /**
> + * @param imageWidthLimit the maximum image width when there's no user supplied width
> + */
> + public void setImageWidthLimit(int imageWidthLimit)
> + {
> + // This method is useful for those using the XWiki Rendering in standalone mode since it allows the rendering
> + // to work even without a configuration store.
> + this.imageWidthLimit = imageWidthLimit;
> + }
> +
> + /**
> + * {@inheritDoc}
> + *
> + * @see org.xwiki.rendering.configuration.RenderingConfiguration#getImageHeightLimit()
> + */
> + public int getImageHeightLimit()
> + {
> + return this.imageHeightLimit;
> + }
> +
> + /**
> + * @param imageHeightLimit the maximum image height when there's no user supplied height
> + */
> + public void setImageHeightLimit(int imageHeightLimit)
> + {
> + // This method is useful for those using the XWiki Rendering in standalone mode since it allows the rendering
> + // to work even without a configuration store.
> + this.imageHeightLimit = imageHeightLimit;
> + }
> +
> + /**
> + * {@inheritDoc}
> + *
> + * @see org.xwiki.rendering.configuration.RenderingConfiguration#isIncludeImageDimensionsInImageURL()
> + */
> + public boolean isIncludeImageDimensionsInImageURL()
> + {
> + return this.includeImageDimensionsInImageURL;
> + }
> +
> + /**
> + * @param includeImageDimensionsInImageURL {@code true} to include image dimensions extracted from the image
> + * parameters in the image URL so that the image can be resized on the server side before being
> + * downloaded, {@code false} otherwise
> + */
> + public void setIncludeImageDimensionsInImageURL(boolean includeImageDimensionsInImageURL)
> + {
> + // This method is useful for those using the XWiki Rendering in standalone mode since it allows the rendering
> + // to work even without a configuration store.
> + this.includeImageDimensionsInImageURL = includeImageDimensionsInImageURL;
> + }
> }
>
> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/xhtml/DefaultXHTMLImageRenderer.java
> ===================================================================
> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/xhtml/DefaultXHTMLImageRenderer.java 2010-09-11 17:15:46 UTC (rev 31052)
> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/xhtml/DefaultXHTMLImageRenderer.java 2010-09-12 11:30:15 UTC (rev 31053)
> @@ -42,10 +42,9 @@
> * Default implementation for rendering images as XHTML. We handle both cases:
> * <ul>
> * <li>when inside a wiki (ie when an implementation of {@link WikiModel} is provided.</li>
> - * <li>when outside of a wiki. In this case we only handle external images and document images don't
> - * display anything.</li>
> + * <li>when outside of a wiki. In this case we only handle external images and document images don't display anything.</li>
> * </ul>
> - *
> + *
> * @version $Id$
> * @since 2.0M3
> */
> @@ -68,6 +67,7 @@
>
> /**
> * {@inheritDoc}
> + *
> * @see Initializable#initialize()
> */
> public void initialize() throws InitializationException
> @@ -83,7 +83,7 @@
>
> /**
> * {@inheritDoc}
> - *
> + *
> * @see XHTMLImageRenderer#setXHTMLWikiPrinter(XHTMLWikiPrinter)
> */
> public void setXHTMLWikiPrinter(XHTMLWikiPrinter printer)
> @@ -103,7 +103,7 @@
>
> /**
> * {@inheritDoc}
> - *
> + *
> * @see XHTMLImageRenderer#onImage(Image, boolean, Map)
> */
> public void onImage(Image image, boolean isFreeStandingURI, Map<String, String> parameters)
> @@ -118,8 +118,9 @@
> // that would not honor this contract.
> if (this.wikiModel != null) {
> DocumentImage documentImage = DocumentImage.class.cast(image);
> - imageURL = this.wikiModel.getAttachmentURL(documentImage.getDocumentName(),
> - documentImage.getAttachmentName());
> + imageURL =
> + this.wikiModel.getImageURL(documentImage.getDocumentName(), documentImage.getAttachmentName(),
> + parameters);
> } else {
> throw new RuntimeException("Invalid Image type. In non wiki mode, all image types must be URL images.");
> }
>
> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/wiki/WikiModel.java
> ===================================================================
> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/wiki/WikiModel.java 2010-09-11 17:15:46 UTC (rev 31052)
> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/wiki/WikiModel.java 2010-09-12 11:30:15 UTC (rev 31053)
> @@ -19,13 +19,15 @@
> */
> package org.xwiki.rendering.wiki;
>
> +import java.util.Map;
> +
> import org.xwiki.component.annotation.ComponentRole;
>
> /**
> * Bridge between the Rendering module and a Wiki Model. Contains wiki APIs required by Rendering classes such as
> - * Renderers. For example the XHTML Link Renderer needs to know if a wiki document exists in order to know how to
> - * generate the HTML (in order to display a question mark for non existing documents) and it also needs to get the
> - * URL pointing the wiki document.
> + * Renderers. For example the XHTML Link Renderer needs to know if a wiki document exists in order to know how to
> + * generate the HTML (in order to display a question mark for non existing documents) and it also needs to get the URL
> + * pointing the wiki document.
> *
> * @version $Id$
> * @since 2.0M1
> @@ -34,36 +36,48 @@
> public interface WikiModel
> {
> /**
> - * @param documentName the document name of the document containing the attachment. The syntax used depends on
> - * the underlying wiki system used. For example for XWiki a valid documentName would be
> - * {@code wiki:Space.Page}
> + * @param documentName the document name of the document containing the attachment. The syntax used depends on the
> + * underlying wiki system used. For example for XWiki a valid documentName would be
> + * {@code wiki:Space.Page}
> * @param attachmentName the name of the attachment in the passed document wikip page
> * @return the URL to the attachment
> */
> String getAttachmentURL(String documentName, String attachmentName);
>
> /**
> - * @param documentName the document name as a String. The syntax used depends on
> - * the underlying wiki system used. For example for XWiki a valid documentName would be
> - * {@code wiki:Space.Page}
> + * Generate image specific URL. The difference with {@link #getAttachmentURL(String, String)} is that in some
> + * implementation we want to make a distinction between displayed image and a simple link targeting an attachment
> + * file.
> + *
> + * @param documentName the document name of the document containing the attachment. The syntax used depends on the
> + * underlying wiki system used. For example for XWiki a valid documentName would be
> + * {@code wiki:Space.Page}
> + * @param attachmentName the name of the attachment in the passed document wiki page
> + * @param parameters custom parameters
> + * @return the URL to the image
> + * @since 2.5M2
> + */
> + String getImageURL(String documentName, String attachmentName, Map<String, String> parameters);
> +
> + /**
> + * @param documentName the document name as a String. The syntax used depends on the underlying wiki system used.
> + * For example for XWiki a valid documentName would be {@code wiki:Space.Page}
> * @return true if the document exists and can be viewed or false otherwise
> */
> boolean isDocumentAvailable(String documentName);
>
> /**
> - * @param documentName the document name as a String. The syntax used depends on
> - * the underlying wiki system used. For example for XWiki a valid documentName would be
> - * {@code wiki:Space.Page}
> + * @param documentName the document name as a String. The syntax used depends on the underlying wiki system used.
> + * For example for XWiki a valid documentName would be {@code wiki:Space.Page}
> * @param anchor an anchor pointing to some place inside the document or null
> * @param queryString a query string specifying some parameters or null
> * @return the URL to view the specified wiki document
> */
> String getDocumentViewURL(String documentName, String anchor, String queryString);
> -
> +
> /**
> - * @param documentName the document name as a String. The syntax used depends on
> - * the underlying wiki system used. For example for XWiki a valid documentName would be
> - * {@code wiki:Space.Page}
> + * @param documentName the document name as a String. The syntax used depends on the underlying wiki system used.
> + * For example for XWiki a valid documentName would be {@code wiki:Space.Page}
> * @param anchor an anchor pointing to some place inside the document or null
> * @param queryString a query string specifying some parameters or null
> * @return the URL to edit the specified wiki document
>
> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/pom.xml
> ===================================================================
> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/pom.xml 2010-09-11 17:15:46 UTC (rev 31052)
> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/pom.xml 2010-09-12 11:30:15 UTC (rev 31053)
> @@ -54,6 +54,12 @@
> <artifactId>xwiki-core-script</artifactId>
> <version>${pom.version}</version>
> </dependency>
> + <dependency>
> + <!-- For parsing the CSS from the style attribute. -->
> + <groupId>net.sourceforge.cssparser</groupId>
> + <artifactId>cssparser</artifactId>
> + <version>0.9.5</version>
> + </dependency>
> <!-- Testing dependencies -->
> <dependency>
> <groupId>org.xwiki.platform</groupId>
>
> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/configuration/XWikiRenderingConfiguration.java
> ===================================================================
> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/configuration/XWikiRenderingConfiguration.java 2010-09-11 17:15:46 UTC (rev 31052)
> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/configuration/XWikiRenderingConfiguration.java 2010-09-12 11:30:15 UTC (rev 31053)
> @@ -19,13 +19,13 @@
> */
> package org.xwiki.rendering.internal.configuration;
>
> +import java.util.Properties;
> +
> import org.xwiki.component.annotation.Component;
> import org.xwiki.component.annotation.Requirement;
> import org.xwiki.configuration.ConfigurationSource;
> import org.xwiki.rendering.configuration.RenderingConfiguration;
>
> -import java.util.Properties;
> -
> /**
> * All configuration options for the rendering subsystem.
> *
> @@ -46,7 +46,7 @@
> private static final String DEFAULT_LINK_LABEL_FORMAT = "%p";
>
> /**
> - * Defines from where to read the rendering configuration data.
> + * Defines from where to read the rendering configuration data.
> */
> @Requirement
> private ConfigurationSource configuration;
> @@ -58,16 +58,46 @@
> */
> public String getLinkLabelFormat()
> {
> - return this.configuration.getProperty(PREFIX + "linkLabelFormat", DEFAULT_LINK_LABEL_FORMAT);
> + return this.configuration.getProperty(PREFIX + "linkLabelFormat", DEFAULT_LINK_LABEL_FORMAT);
> }
>
> /**
> * {@inheritDoc}
> - *
> + *
> * @see org.xwiki.rendering.configuration.RenderingConfiguration#getMacroCategories()
> */
> public Properties getMacroCategories()
> {
> return this.configuration.getProperty(PREFIX + "macroCategories", Properties.class);
> }
> +
> + /**
> + * {@inheritDoc}
> + *
> + * @see org.xwiki.rendering.configuration.RenderingConfiguration#getImageWidthLimit()
> + */
> + public int getImageWidthLimit()
> + {
> + return this.configuration.getProperty(PREFIX + "imageWidthLimit", -1);
> + }
> +
> + /**
> + * {@inheritDoc}
> + *
> + * @see org.xwiki.rendering.configuration.RenderingConfiguration#getImageHeightLimit()
> + */
> + public int getImageHeightLimit()
> + {
> + return this.configuration.getProperty(PREFIX + "imageHeightLimit", -1);
> + }
> +
> + /**
> + * {@inheritDoc}
> + *
> + * @see org.xwiki.rendering.configuration.RenderingConfiguration#isIncludeImageDimensionsInImageURL()
> + */
> + public boolean isIncludeImageDimensionsInImageURL()
> + {
> + return this.configuration.getProperty(PREFIX + "includeImageDimensionsInImageURL", true);
> + }
> }
>
> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/wiki/XWikiWikiModel.java
> ===================================================================
> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/wiki/XWikiWikiModel.java 2010-09-11 17:15:46 UTC (rev 31052)
> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/wiki/XWikiWikiModel.java 2010-09-12 11:30:15 UTC (rev 31053)
> @@ -19,17 +19,25 @@
> */
> package org.xwiki.rendering.internal.wiki;
>
> +import java.io.IOException;
> +import java.io.StringReader;
> import java.io.UnsupportedEncodingException;
> import java.net.URLEncoder;
> +import java.util.Map;
>
> import org.apache.commons.lang.StringUtils;
> +import org.w3c.css.sac.InputSource;
> +import org.w3c.dom.css.CSSStyleDeclaration;
> import org.xwiki.bridge.DocumentAccessBridge;
> -import org.xwiki.model.reference.DocumentReference;
> import org.xwiki.component.annotation.Component;
> import org.xwiki.component.annotation.Requirement;
> +import org.xwiki.model.reference.DocumentReference;
> import org.xwiki.model.reference.EntityReferenceSerializer;
> +import org.xwiki.rendering.configuration.RenderingConfiguration;
> import org.xwiki.rendering.wiki.WikiModel;
>
> +import com.steadystate.css.parser.CSSOMParser;
> +
> /**
> * Implementation using the Document Access Bridge ({@link DocumentAccessBridge}).
> *
> @@ -39,14 +47,47 @@
> @Component
> public class XWikiWikiModel implements WikiModel
> {
> + /**
> + * The suffix used to mark an amount of pixels.
> + */
> + private static final String PIXELS = "px";
> +
> + /**
> + * The name of the {@code width} image parameter.
> + */
> + private static final String WIDTH = "width";
> +
> + /**
> + * The name of the {@code height} image parameter.
> + */
> + private static final String HEIGHT = "height";
> +
> + /**
> + * The component used to access configuration parameters.
> + */
> @Requirement
> + private RenderingConfiguration renderingConfiguration;
> +
> + /**
> + * The component used to access the underlying XWiki model.
> + */
> + @Requirement
> private DocumentAccessBridge documentAccessBridge;
>
> + /**
> + * The component used to serialize entity references to strings.
> + */
> @Requirement
> private EntityReferenceSerializer<String> entityReferenceSerializer;
>
> /**
> + * The object used to parse the CSS from the image style parameter.
> + */
> + private final CSSOMParser cssParser = new CSSOMParser();
> +
> + /**
> * {@inheritDoc}
> + *
> * @see WikiModel#getAttachmentURL(String, String)
> */
> public String getAttachmentURL(String documentName, String attachmentName)
> @@ -55,7 +96,112 @@
> }
>
> /**
> + * Extracts the specified image dimension from the image parameters.
> + *
> + * @param dimension either {@code width} or {@code height}
> + * @param imageParameters the image parameters; may include the {@code width}, {@code height} and {@code style}
> + * parameters
> + * @return the value of the passed dimension if it is specified in the image parameters, {@code null} otherwise
> + */
> + private String getImageDimension(String dimension, Map<String, String> imageParameters)
> + {
> + // Check first if the style parameter contains information about the given dimension. In-line style has priority
> + // over the dimension parameters.
> + String value = null;
> + String style = imageParameters.get("style");
> + if (StringUtils.isNotBlank(style)) {
> + try {
> + CSSStyleDeclaration sd = cssParser.parseStyleDeclaration(new InputSource(new StringReader(style)));
> + value = sd.getPropertyValue(dimension);
> + } catch (IOException e) {
> + // Ignore the style parameter.
> + }
> + }
> + if (StringUtils.isBlank(value)) {
> + // Fall back on the value of the dimension parameter.
> + value = imageParameters.get(dimension);
> + }
> + return value;
> + }
> +
> + /**
> + * Creates the query string that can be added to an image URL to resize the image on the server side.
> + *
> + * @param imageParameters image parameters, including width and height then they are specified
> + * @return the query string to be added to an image URL in order to resize the image on the server side
> + */
> + private StringBuilder getImageURLQueryString(Map<String, String> imageParameters)
> + {
> + String width = StringUtils.chomp(getImageDimension(WIDTH, imageParameters), PIXELS);
> + String height = StringUtils.chomp(getImageDimension(HEIGHT, imageParameters), PIXELS);
> + boolean useHeight = StringUtils.isNotEmpty(height) && StringUtils.isNumeric(height);
> + StringBuilder queryString = new StringBuilder();
> + if (StringUtils.isEmpty(width) || !StringUtils.isNumeric(width)) {
> + // Width is unspecified or is not measured in pixels.
> + if (useHeight) {
> + // Height is specified in pixels.
> + queryString.append('&').append(HEIGHT).append('=').append(height);
> + } else {
> + // If image width and height are unspecified or if they are not expressed in pixels then limit the image
> + // size to best fit the rectangle specified in the configuration (keeping aspect ratio).
> + int widthLimit = renderingConfiguration.getImageWidthLimit();
> + if (widthLimit > 0) {
> + queryString.append('&').append(WIDTH).append('=').append(widthLimit);
> + }
> + int heightLimit = renderingConfiguration.getImageHeightLimit();
> + if (heightLimit > 0) {
> + queryString.append('&').append(HEIGHT).append('=').append(heightLimit);
> + }
> + if (widthLimit > 0 && heightLimit > 0) {
> + queryString.append("&keepAspectRatio=").append(true);
> + }
> + }
> + } else {
> + // Width is specified in pixels.
> + queryString.append('&').append(WIDTH).append('=').append(width);
> + if (useHeight) {
> + // Height is specified in pixels.
> + queryString.append('&').append(HEIGHT).append('=').append(height);
> + }
> + }
> + return queryString;
> + }
> +
> + /**
> * {@inheritDoc}
> + *
> + * @see org.xwiki.rendering.wiki.WikiModel#getImageURL(java.lang.String, java.lang.String, java.util.Map)
> + */
> + public String getImageURL(String documentName, String attachmentName, Map<String, String> parameters)
> + {
> + String url = getAttachmentURL(documentName, attachmentName);
> + if (!renderingConfiguration.isIncludeImageDimensionsInImageURL()) {
> + return url;
> + }
> +
> + StringBuilder queryString = getImageURLQueryString(parameters);
> + if (queryString.length() == 0) {
> + return url;
> + }
> +
> + // Determine the insertion point.
> + int insertionPoint = url.lastIndexOf('#');
> + if (insertionPoint < 0) {
> + // No fragment identifier.
> + insertionPoint = url.length();
> + }
> + if (url.lastIndexOf('?', insertionPoint) < 0) {
> + // No query string.
> + queryString.setCharAt(0, '?');
> + }
> +
> + // Insert the query string.
> + return new StringBuilder(url).insert(insertionPoint, queryString).toString();
> + }
> +
> + /**
> + * {@inheritDoc}
> + *
> * @see WikiModel#isDocumentAvailable(String)
> */
> public boolean isDocumentAvailable(String documentName)
> @@ -65,6 +211,7 @@
>
> /**
> * {@inheritDoc}
> + *
> * @see WikiModel#getDocumentViewURL(String, String, String)
> */
> public String getDocumentViewURL(String documentName, String anchor, String queryString)
> @@ -74,6 +221,7 @@
>
> /**
> * {@inheritDoc}
> + *
> * @see WikiModel#getDocumentEditURL(String, String, String)
> */
> public String getDocumentEditURL(String documentName, String anchor, String queryString)
> @@ -89,17 +237,17 @@
> // See http://www.w3.org/TR/html40/appendix/notes.html#non-ascii-chars
> // TODO: Once the xwiki-url module is usable, refactor this code to use it and remove the need to
> // perform explicit encoding here.
> - modifiedQueryString =
> + modifiedQueryString =
> "parent=" + URLEncoder.encode(this.entityReferenceSerializer.serialize(reference), "UTF-8");
> } catch (UnsupportedEncodingException e) {
> // Not supporting UTF-8 as a valid encoding for some reasons. We consider XWiki cannot work
> // without that encoding.
> - throw new RuntimeException("Failed to URL encode [" + this.entityReferenceSerializer.serialize(
> - reference) + "] using UTF-8.", e);
> + throw new RuntimeException("Failed to URL encode ["
> + + this.entityReferenceSerializer.serialize(reference) + "] using UTF-8.", e);
> }
> }
> }
> -
> +
> return this.documentAccessBridge.getURL(documentName, "create", modifiedQueryString, anchor);
> }
> }
>
> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/test/java/org/xwiki/rendering/internal/configuration/XWikiRenderingConfigurationTest.java
> ===================================================================
> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/test/java/org/xwiki/rendering/internal/configuration/XWikiRenderingConfigurationTest.java 2010-09-11 17:15:46 UTC (rev 31052)
> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/test/java/org/xwiki/rendering/internal/configuration/XWikiRenderingConfigurationTest.java 2010-09-12 11:30:15 UTC (rev 31053)
> @@ -22,9 +22,9 @@
> import java.util.Properties;
>
> import org.jmock.Expectations;
> -import org.xwiki.configuration.ConfigurationSource;
> import org.junit.Assert;
> import org.junit.Test;
> +import org.xwiki.configuration.ConfigurationSource;
> import org.xwiki.test.AbstractMockingComponentTestCase;
> import org.xwiki.test.annotation.MockingRequirement;
>
> @@ -43,10 +43,13 @@
> public void testGetLinkLabelFormat() throws Exception
> {
> final ConfigurationSource source = getComponentManager().lookup(ConfigurationSource.class);
> - getMockery().checking(new Expectations() {{
> - allowing(source).getProperty("rendering.linkLabelFormat", "%p");
> + getMockery().checking(new Expectations()
> + {
> + {
> + allowing(source).getProperty("rendering.linkLabelFormat", "%p");
> will(returnValue("%p"));
> - }});
> + }
> + });
>
> Assert.assertEquals("%p", this.configuration.getLinkLabelFormat());
> }
> @@ -55,12 +58,60 @@
> public void testGetMacroCategories() throws Exception
> {
> final ConfigurationSource source = getComponentManager().lookup(ConfigurationSource.class);
> - getMockery().checking(new Expectations() {{
> - allowing(source).getProperty("rendering.macroCategories", Properties.class);
> + getMockery().checking(new Expectations()
> + {
> + {
> + allowing(source).getProperty("rendering.macroCategories", Properties.class);
> will(returnValue(new Properties()));
> - }});
> + }
> + });
>
> Assert.assertNotNull(this.configuration.getMacroCategories());
> Assert.assertEquals(0, this.configuration.getMacroCategories().size());
> }
> +
> + @Test
> + public void testGetImageWidthLimit() throws Exception
> + {
> + final ConfigurationSource source = getComponentManager().lookup(ConfigurationSource.class);
> + getMockery().checking(new Expectations()
> + {
> + {
> + allowing(source).getProperty("rendering.imageWidthLimit", -1);
> + will(returnValue(100));
> + }
> + });
> +
> + Assert.assertEquals(100, this.configuration.getImageWidthLimit());
> + }
> +
> + @Test
> + public void testGetImageHeightLimit() throws Exception
> + {
> + final ConfigurationSource source = getComponentManager().lookup(ConfigurationSource.class);
> + getMockery().checking(new Expectations()
> + {
> + {
> + allowing(source).getProperty("rendering.imageHeightLimit", -1);
> + will(returnValue(150));
> + }
> + });
> +
> + Assert.assertEquals(150, this.configuration.getImageHeightLimit());
> + }
> +
> + @Test
> + public void testIsIncludeImageDimensionsInImageURL() throws Exception
> + {
> + final ConfigurationSource source = getComponentManager().lookup(ConfigurationSource.class);
> + getMockery().checking(new Expectations()
> + {
> + {
> + allowing(source).getProperty("rendering.includeImageDimensionsInImageURL", true);
> + will(returnValue(false));
> + }
> + });
> +
> + Assert.assertFalse(this.configuration.isIncludeImageDimensionsInImageURL());
> + }
> }
>
> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/test/java/org/xwiki/rendering/internal/wiki/XWikiWikiModelTest.java
> ===================================================================
> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/test/java/org/xwiki/rendering/internal/wiki/XWikiWikiModelTest.java 2010-09-11 17:15:46 UTC (rev 31052)
> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/test/java/org/xwiki/rendering/internal/wiki/XWikiWikiModelTest.java 2010-09-12 11:30:15 UTC (rev 31053)
> @@ -19,12 +19,20 @@
> */
> package org.xwiki.rendering.internal.wiki;
>
> +import java.util.Collections;
> +import java.util.HashMap;
> +import java.util.Map;
> +
> +import junit.framework.Assert;
> +
> import org.jmock.Expectations;
> -import org.jmock.Mockery;
> +import org.junit.Test;
> import org.xwiki.bridge.DocumentAccessBridge;
> import org.xwiki.model.reference.DocumentReference;
> -import org.xwiki.component.util.ReflectionUtils;
> import org.xwiki.model.reference.EntityReferenceSerializer;
> +import org.xwiki.rendering.configuration.RenderingConfiguration;
> +import org.xwiki.test.AbstractMockingComponentTestCase;
> +import org.xwiki.test.annotation.MockingRequirement;
>
> /**
> * Unit tests for {@link XWikiWikiModel}.
> @@ -32,31 +40,321 @@
> * @version $Id$
> * @since 2.0M1
> */
> -public class XWikiWikiModelTest
> +public class XWikiWikiModelTest extends AbstractMockingComponentTestCase
> {
> - @org.junit.Test
> + @MockingRequirement
> + private XWikiWikiModel wikiModel;
> +
> + @Test
> public void testGetDocumentEditURLWhenNoQueryStringSpecified() throws Exception
> {
> - Mockery mockery = new Mockery();
> - XWikiWikiModel wikiModel = new XWikiWikiModel();
> + final EntityReferenceSerializer< ? > entityReferenceSerializer =
> + getComponentManager().lookup(EntityReferenceSerializer.class);
> + final DocumentAccessBridge documentAccessBridge = getComponentManager().lookup(DocumentAccessBridge.class);
> + final DocumentReference documentReference = new DocumentReference("wiki", "Space", "Page");
> + getMockery().checking(new Expectations()
> + {
> + {
> + oneOf(documentAccessBridge).getCurrentDocumentReference();
> + will(returnValue(documentReference));
> + oneOf(entityReferenceSerializer).serialize(documentReference);
> + will(returnValue("wiki:Space.Page\u20AC"));
>
> - final EntityReferenceSerializer mockEntityReferenceSerializer = mockery.mock(EntityReferenceSerializer.class);
> - ReflectionUtils.setFieldValue(wikiModel, "entityReferenceSerializer", mockEntityReferenceSerializer);
> + // The test is here: we verify that getURL is called with the query string already encoded since
> + // getURL() doesn't encode it.
> + oneOf(documentAccessBridge).getURL("Space.Page\u20AC", "create", "parent=wiki%3ASpace.Page%E2%82%AC",
> + "anchor");
> + }
> + });
>
> - final DocumentAccessBridge mockDocumentAccessBridge = mockery.mock(DocumentAccessBridge.class);
> - ReflectionUtils.setFieldValue(wikiModel, "documentAccessBridge", mockDocumentAccessBridge);
> + wikiModel.getDocumentEditURL("Space.Page\u20AC", "anchor", null);
> + }
>
> - final DocumentReference docReference = new DocumentReference("wiki", "Space", "Page");
> - mockery.checking(new Expectations() {{
> - oneOf(mockDocumentAccessBridge).getCurrentDocumentReference(); will(returnValue(docReference));
> - oneOf(mockEntityReferenceSerializer).serialize(docReference); will(returnValue("wiki:Space.Page\u20AC"));
> + /**
> + * Tests that the proper image URL is generated when both the width and the height image parameters are specified.
> + *
> + * @throws Exception if an exception occurs while running the test
> + */
> + @Test
> + public void testGetImageURLWhenBothWidthAndHeightAttributesAreSpecified() throws Exception
> + {
> + final DocumentAccessBridge documentAccessBridge = getComponentManager().lookup(DocumentAccessBridge.class);
> + final RenderingConfiguration configuration = getComponentManager().lookup(RenderingConfiguration.class);
> + getMockery().checking(new Expectations()
> + {
> + {
> + oneOf(documentAccessBridge).getAttachmentURL("", "");
> + will(returnValue(""));
> + oneOf(configuration).isIncludeImageDimensionsInImageURL();
> + will(returnValue(true));
> + }
> + });
> + Map<String, String> parameters = new HashMap<String, String>();
> + parameters.put("width", "100px");
> + parameters.put("height", "50");
> + Assert.assertEquals("?width=100&height=50", wikiModel.getImageURL("", "", parameters));
> + }
>
> - // The test is here: we verify that getURL is called with the query string already encoded since getURL()
> - // doesn't encode it.
> - oneOf(mockDocumentAccessBridge).getURL("Space.Page\u20AC", "create", "parent=wiki%3ASpace.Page%E2%82%AC",
> - "anchor");
> - }});
> + /**
> + * Tests that the proper image URL is generated when both the width and the height image parameters are specified
> + * but including them in the image URL is forbidden from the rendering configuration.
> + *
> + * @throws Exception if an exception occurs while running the test
> + */
> + @Test
> + public void testGetImageURLWhenIncludingImageDimensionsIsForbidden() throws Exception
> + {
> + final DocumentAccessBridge documentAccessBridge = getComponentManager().lookup(DocumentAccessBridge.class);
> + final RenderingConfiguration configuration = getComponentManager().lookup(RenderingConfiguration.class);
> + getMockery().checking(new Expectations()
> + {
> + {
> + oneOf(documentAccessBridge).getAttachmentURL("", "");
> + will(returnValue(""));
> + oneOf(configuration).isIncludeImageDimensionsInImageURL();
> + will(returnValue(false));
> + }
> + });
> + Map<String, String> parameters = new HashMap<String, String>();
> + parameters.put("width", "101px");
> + parameters.put("height", "55px");
> + Assert.assertEquals("", wikiModel.getImageURL("", "", parameters));
> + }
>
> - wikiModel.getDocumentEditURL("Space.Page\u20AC", "anchor", null);
> + /**
> + * Tests that the proper image URL is generated when both the width and the height CSS properties are specified.
> + *
> + * @throws Exception if an exception occurs while running the test
> + */
> + @Test
> + public void testGetImageURLWhenBothWidthAndHeightCSSPropertiesAreSpecified() throws Exception
> + {
> + final DocumentAccessBridge documentAccessBridge = getComponentManager().lookup(DocumentAccessBridge.class);
> + final RenderingConfiguration configuration = getComponentManager().lookup(RenderingConfiguration.class);
> + getMockery().checking(new Expectations()
> + {
> + {
> + oneOf(documentAccessBridge).getAttachmentURL("", "");
> + will(returnValue(""));
> + oneOf(configuration).isIncludeImageDimensionsInImageURL();
> + will(returnValue(true));
> + }
> + });
> + Map<String, String> parameters = new HashMap<String, String>();
> + parameters.put("style", "border: 1px; height: 30px; margin-top: 2em; width: 70px");
> + Assert.assertEquals("?width=70&height=30", wikiModel.getImageURL("", "", parameters));
> }
> +
> + /**
> + * Tests that the proper image URL is generated when only the width image parameter is specified.
> + *
> + * @throws Exception if an exception occurs while running the test
> + */
> + @Test
> + public void testGetImageURLWhenOnlyWidthAttributeIsSpecified() throws Exception
> + {
> + final DocumentAccessBridge documentAccessBridge = getComponentManager().lookup(DocumentAccessBridge.class);
> + final RenderingConfiguration configuration = getComponentManager().lookup(RenderingConfiguration.class);
> + getMockery().checking(new Expectations()
> + {
> + {
> + oneOf(documentAccessBridge).getAttachmentURL("", "");
> + will(returnValue(""));
> + oneOf(configuration).isIncludeImageDimensionsInImageURL();
> + will(returnValue(true));
> + }
> + });
> + Map<String, String> parameters = new HashMap<String, String>();
> + parameters.put("width", "150");
> + parameters.put("height", "30%");
> + Assert.assertEquals("?width=150", wikiModel.getImageURL("", "", parameters));
> + }
> +
> + /**
> + * Tests that the proper image URL is generated when only the height CSS property is specified.
> + *
> + * @throws Exception if an exception occurs while running the test
> + */
> + @Test
> + public void testGetImageURLWhenOnlyHeightCSSPropertyIsSpecified() throws Exception
> + {
> + final DocumentAccessBridge documentAccessBridge = getComponentManager().lookup(DocumentAccessBridge.class);
> + final RenderingConfiguration configuration = getComponentManager().lookup(RenderingConfiguration.class);
> + getMockery().checking(new Expectations()
> + {
> + {
> + oneOf(documentAccessBridge).getAttachmentURL("", "");
> + will(returnValue(""));
> + oneOf(configuration).isIncludeImageDimensionsInImageURL();
> + will(returnValue(true));
> + }
> + });
> + Map<String, String> parameters = new HashMap<String, String>();
> + parameters.put("style", "width: 5cm; height: 80px");
> + Assert.assertEquals("?height=80", wikiModel.getImageURL("", "", parameters));
> + }
> +
> + /**
> + * Tests that the proper image URL is generated when both the width and the height are unspecified and image size is
> + * limited in the configuration.
> + *
> + * @throws Exception if an exception occurs while running the test
> + */
> + @Test
> + public void testGetImageURLWhenBothWidthAndHeightAreUnspecifiedAndImageSizeIsLimited() throws Exception
> + {
> + final DocumentAccessBridge documentAccessBridge = getComponentManager().lookup(DocumentAccessBridge.class);
> + final RenderingConfiguration configuration = getComponentManager().lookup(RenderingConfiguration.class);
> + getMockery().checking(new Expectations()
> + {
> + {
> + oneOf(documentAccessBridge).getAttachmentURL("", "");
> + will(returnValue(""));
> + oneOf(configuration).isIncludeImageDimensionsInImageURL();
> + will(returnValue(true));
> + oneOf(configuration).getImageWidthLimit();
> + will(returnValue(200));
> + oneOf(configuration).getImageHeightLimit();
> + will(returnValue(170));
> + }
> + });
> + Map<String, String> parameters = Collections.emptyMap();
> + Assert.assertEquals("?width=200&height=170&keepAspectRatio=true", wikiModel.getImageURL("", "", parameters));
> + }
> +
> + /**
> + * Tests that the proper image URL is generated when both the width and the height are unspecified and only the
> + * image width is limited in the configuration.
> + *
> + * @throws Exception if an exception occurs while running the test
> + */
> + @Test
> + public void testGetImageURLWhenBothWidthAndHeightAreUnspecifiedAndOnlyImageWidthIsLimited() throws Exception
> + {
> + final DocumentAccessBridge documentAccessBridge = getComponentManager().lookup(DocumentAccessBridge.class);
> + final RenderingConfiguration configuration = getComponentManager().lookup(RenderingConfiguration.class);
> + getMockery().checking(new Expectations()
> + {
> + {
> + oneOf(documentAccessBridge).getAttachmentURL("", "");
> + will(returnValue(""));
> + oneOf(configuration).isIncludeImageDimensionsInImageURL();
> + will(returnValue(true));
> + oneOf(configuration).getImageWidthLimit();
> + will(returnValue(25));
> + oneOf(configuration).getImageHeightLimit();
> + will(returnValue(-1));
> + }
> + });
> + Map<String, String> parameters = new HashMap<String, String>();
> + parameters.put("width", "45%");
> + parameters.put("style", "height:10em");
> + Assert.assertEquals("?width=25", wikiModel.getImageURL("", "", parameters));
> + }
> +
> + /**
> + * Tests that the proper image URL is generated when both the width and the height are unspecified and the image
> + * size is not limited in the configuration.
> + *
> + * @throws Exception if an exception occurs while running the test
> + */
> + @Test
> + public void testGetImageURLWhenBothWidthAndHeightAreUnspecifiedAndImageSizeIsNotLimited() throws Exception
> + {
> + final DocumentAccessBridge documentAccessBridge = getComponentManager().lookup(DocumentAccessBridge.class);
> + final RenderingConfiguration configuration = getComponentManager().lookup(RenderingConfiguration.class);
> + getMockery().checking(new Expectations()
> + {
> + {
> + oneOf(documentAccessBridge).getAttachmentURL("", "");
> + will(returnValue(""));
> + oneOf(configuration).isIncludeImageDimensionsInImageURL();
> + will(returnValue(true));
> + oneOf(configuration).getImageWidthLimit();
> + will(returnValue(-1));
> + oneOf(configuration).getImageHeightLimit();
> + will(returnValue(-1));
> + }
> + });
> + Map<String, String> parameters = new HashMap<String, String>();
> + parameters.put("style", "bad CSS declaration");
> + Assert.assertEquals("", wikiModel.getImageURL("", "", parameters));
> + }
> +
> + /**
> + * Tests that the proper image URL is generated when the attachment URL has a fragment identifier.
> + *
> + * @throws Exception if an exception occurs while running the test
> + */
> + @Test
> + public void testGetImageURLWhenAttachmentURLHasFragmentIdentifier() throws Exception
> + {
> + final DocumentAccessBridge documentAccessBridge = getComponentManager().lookup(DocumentAccessBridge.class);
> + final RenderingConfiguration configuration = getComponentManager().lookup(RenderingConfiguration.class);
> + getMockery().checking(new Expectations()
> + {
> + {
> + oneOf(documentAccessBridge).getAttachmentURL("", "");
> + will(returnValue("test#fragment"));
> + oneOf(configuration).isIncludeImageDimensionsInImageURL();
> + will(returnValue(true));
> + }
> + });
> + Map<String, String> parameters = new HashMap<String, String>();
> + parameters.put("width", "23");
> + Assert.assertEquals("test?width=23#fragment", wikiModel.getImageURL("", "", parameters));
> + }
> +
> + /**
> + * Tests that the proper image URL is generated when the attachment URL has a query string and a fragment
> + * identifier.
> + *
> + * @throws Exception if an exception occurs while running the test
> + */
> + @Test
> + public void testGetImageURLWhenAttachmentURLHasQueryStringAndFragmentIdentifier() throws Exception
> + {
> + final DocumentAccessBridge documentAccessBridge = getComponentManager().lookup(DocumentAccessBridge.class);
> + final RenderingConfiguration configuration = getComponentManager().lookup(RenderingConfiguration.class);
> + getMockery().checking(new Expectations()
> + {
> + {
> + oneOf(documentAccessBridge).getAttachmentURL("", "");
> + will(returnValue("test?param=value#fragment"));
> + oneOf(configuration).isIncludeImageDimensionsInImageURL();
> + will(returnValue(true));
> + }
> + });
> + Map<String, String> parameters = new HashMap<String, String>();
> + parameters.put("height", "17");
> + Assert.assertEquals("test?param=value&height=17#fragment", wikiModel.getImageURL("", "", parameters));
> + }
> +
> + /**
> + * Tests that the proper image URL is generated when both the style and the dimension parameters are specified.
> + *
> + * @throws Exception if an exception occurs while running the test
> + */
> + @Test
> + public void testGetImageURLWhenBothStyleAndDimensionParametersAreSpecified() throws Exception
> + {
> + final DocumentAccessBridge documentAccessBridge = getComponentManager().lookup(DocumentAccessBridge.class);
> + final RenderingConfiguration configuration = getComponentManager().lookup(RenderingConfiguration.class);
> + getMockery().checking(new Expectations()
> + {
> + {
> + oneOf(documentAccessBridge).getAttachmentURL("", "");
> + will(returnValue(""));
> + oneOf(configuration).isIncludeImageDimensionsInImageURL();
> + will(returnValue(true));
> + }
> + });
> + Map<String, String> parameters = new HashMap<String, String>();
> + parameters.put("height", "46");
> + parameters.put("width", "101px");
> + parameters.put("style", "width: 20%; height:75px");
> + // Note that the style parameter take precedence over the dimension parameters and the width is actually 20% but
> + // we can't use it for resizing the image on the server side so it's omitted from the query string.
> + Assert.assertEquals("?height=75", wikiModel.getImageURL("", "", parameters));
> + }
> }
On 09/09/2010 01:59 PM, cjdelisle (SVN) wrote:
> Author: cjdelisle
> Date: 2010-09-09 13:59:55 +0200 (Thu, 09 Sep 2010)
> New Revision: 31022
>
> Modified:
> platform/web/trunk/standard/src/main/webapp/templates/commentsinline.vm
> Log:
> XWIKI-2110: Made comments be rendered in the context of the document "XWiki.XWikiComments"
>
> Modified: platform/web/trunk/standard/src/main/webapp/templates/commentsinline.vm
> ===================================================================
> --- platform/web/trunk/standard/src/main/webapp/templates/commentsinline.vm 2010-09-09 08:37:05 UTC (rev 31021)
> +++ platform/web/trunk/standard/src/main/webapp/templates/commentsinline.vm 2010-09-09 11:59:55 UTC (rev 31022)
> @@ -110,7 +110,7 @@
> ##
> ##
> ##
> -#macro(displayThread $key $commentThreads)
> +#macro(displayThread $key $commentThreads, $commentDoc)
> ## If request parameter replyto is specified then we show the form under that comment.
> #if($replyTo == "$key")
> #displayCommentForm()
> @@ -134,7 +134,7 @@
> ##
> ##
> ##
> -#macro(displayComment $comment)
> +#macro(displayComment $comment, $commentDoc)
> <div id="xwikicomment_${comment.number}" class="xwikicomment#if($comment.getProperty('author').value == $doc.creator) commentByCreator#end">
> ##<div class="commentavatar">#useravatar($comment.author)</div>
> <div class="commentheader">
> @@ -156,7 +156,7 @@
> #end
> </span>## commenttools
> </div>## commentheader
> -<div class="commentcontent">$doc.display('comment', 'view', $comment)</div>
> +<div class="commentcontent">$commentDoc.getRenderedContent($comment.getProperty('comment').getValue(), $doc.getSyntax().toIdString())</div>
> </div>## xwikicomment
> #end
> ##
> @@ -302,7 +302,11 @@
> #foreach($comment in $comments)
> #addCommentToThreads($comment, $commentThreads, $rootKey)
> #end
> - #displayThread($rootKey, $commentThreads)
> + ##
> + ## Comments will be rendered in the context of this document.
> + #set($commentDoc = $xwiki.getDocument('XWiki.XWikiComments'))
What if the user does not have the right to view XWiki.XWikiComments?
$commentDoc will be null, and the display will fail. You should fall
back to $doc in this case. Note that this is not so absurd, since it's a
good practice to forbid access to the XWiki space.
One incompatible use case is that all code using $doc will show
different results now, but I don't think this is a very valid use case.
> + ##
> + #displayThread($rootKey, $commentThreads, $commentDoc)
> #else
> <p class="noitems">$msg.get('core.viewers.comments.noComments')</p>
> #end
--
Sergiu Dumitriu
http://purl.org/net/sergiu/
On Mon, Sep 13, 2010 at 09:08, Vincent Massol <vincent(a)massol.net> wrote:
> Hi Marius,
>
> I think there are some changes we need to discuss in this commit:
> - new config api methods
> - new wiki model api methods
> - new deps introduced in the rendering module (makes it harder to use without maven)
>
> These 2 are important as they are important public apis. The WikiModel one is the most important and we need to be 100% sure we want to add a new methods. There must absolutely be the minimal number of methods in this class. Also we're going to break people using the rendering module outside of xwiki (guys from eXo for example, so we need to be careful).
>
> I haven't thought too much about it yet but my first feeling is that the methods added look quite specific. I'd like to have Thomas's opinion on this since he's the one who's the most knowledgeable about the rendering module.
>
> Thanks
> -Vincent
>
> On Sep 12, 2010, at 1:30 PM, mflorea (SVN) wrote:
>
>> Author: mflorea
>> Date: 2010-09-12 13:30:15 +0200 (Sun, 12 Sep 2010)
>> New Revision: 31053
>>
>> Modified:
>> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/configuration/RenderingConfiguration.java
>> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/configuration/DefaultRenderingConfiguration.java
>> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/xhtml/DefaultXHTMLImageRenderer.java
>> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/wiki/WikiModel.java
>> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/pom.xml
>> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/configuration/XWikiRenderingConfiguration.java
>> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/wiki/XWikiWikiModel.java
>> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/test/java/org/xwiki/rendering/internal/configuration/XWikiRenderingConfigurationTest.java
>> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/test/java/org/xwiki/rendering/internal/wiki/XWikiWikiModelTest.java
>> Log:
>> XWIKI-5479: Include image dimensions in the image URL for server side image resizing
>>
>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/configuration/RenderingConfiguration.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/configuration/RenderingConfiguration.java    2010-09-11 17:15:46 UTC (rev 31052)
>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/configuration/RenderingConfiguration.java    2010-09-12 11:30:15 UTC (rev 31053)
>> @@ -50,7 +50,7 @@
>> Â Â Â * </ul>
>> Â Â Â * Note that if the page title is empty or not defined then it defaults to %p. This is also the case
>> Â Â Â * if the title cannot be retrieved for the document.
>> - Â Â *
>> + Â Â *
>> Â Â Â * The default is "%p". Some examples: "%s.%p", "%w:%s.%p".
>> Â Â Â *
>> Â Â Â * @return the format to use to display link labels when the user hasn't specified a label
>> @@ -63,4 +63,42 @@
>> Â Â Â * Â Â Â Â descriptor (ie defined by the macro author) will be used
>> Â Â Â */
>> Â Â Properties getMacroCategories();
>> +
>> + Â Â /**
>> + Â Â * @return {@code true} to include the image dimensions extracted from the image parameters in the image URL,
>> + Â Â * Â Â Â Â Â Â {@code false} otherwise; when image dimensions are included in the image URL the image can be resized
>> + Â Â * Â Â Â Â Â Â on the server side before being downloaded.
>> + Â Â * @since 2.5M2
>> + Â Â */
>> + Â Â boolean isIncludeImageDimensionsInImageURL();
>> +
>> + Â Â /**
>> + Â Â * One way to improve page load speed is to resize images on the server side just before rendering the page. The
>> + Â Â * rendering module can use the image width provided by the user to scale the image. When the user doesn't specify
>> + Â Â * the image width the rendering module can limit the width of the image based on this configuration parameter.
>> + Â Â * <p>
>> + Â Â * The default value is {@code -1} which means image width is not limited by default. Use a value greater than 0 to
>> + Â Â * limit the image width (pixels). Note that the aspect ratio is kept even when both the width and the height of the
>> + Â Â * image are limited.
>> + Â Â *
>> + Â Â * @return the maximum image width when there's no user supplied width
>> + Â Â * @see #isIncludeImageDimensionsInImageURL()
>> + Â Â * @since 2.5M2
>> + Â Â */
>> + Â Â int getImageWidthLimit();
>> +
>> + Â Â /**
>> + Â Â * One way to improve page load speed is to resize images on the server side just before rendering the page. The
>> + Â Â * rendering module can use the image height provided by the user to scale the image. When the user doesn't specify
>> + Â Â * the image height the rendering module can limit the height of the image based on this configuration parameter.
>> + Â Â * <p>
>> + Â Â * The default value is {@code -1} which means image height is not limited by default. Use a value greater than 0 to
>> + Â Â * limit the image height (pixels). Note that the aspect ratio is kept even when both the width and the height of
>> + Â Â * the image are limited.
>> + Â Â *
>> + Â Â * @return the maximum image height when there's no user supplied height
>> + Â Â * @see #isIncludeImageDimensionsInImageURL()
>> + Â Â * @since 2.5M2
>> + Â Â */
>> + Â Â int getImageHeightLimit();
>> }
This is very wrong. Theses configuration is supposed to be a
rendering-xwiki specific thing so it has nothing to do in the standard
rendering configuration.
>>
>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/configuration/DefaultRenderingConfiguration.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/configuration/DefaultRenderingConfiguration.java    2010-09-11 17:15:46 UTC (rev 31052)
>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/configuration/DefaultRenderingConfiguration.java    2010-09-12 11:30:15 UTC (rev 31053)
>> @@ -45,6 +45,21 @@
>> Â Â private Properties macroCategories = new Properties();
>>
>> Â Â /**
>> + Â Â * @see #getImageWidthLimit()
>> + Â Â */
>> + Â Â private int imageWidthLimit = -1;
>> +
>> + Â Â /**
>> + Â Â * @see #getImageHeightLimit()
>> + Â Â */
>> + Â Â private int imageHeightLimit = -1;
>> +
>> + Â Â /**
>> + Â Â * @see #isIncludeImageDimensionsInImageURL()
>> + Â Â */
>> + Â Â private boolean includeImageDimensionsInImageURL = true;
>> +
>> + Â Â /**
>> Â Â Â * {@inheritDoc}
>> Â Â Â *
>> Â Â Â * @see org.xwiki.rendering.configuration.RenderingConfiguration#getLinkLabelFormat()
>> @@ -84,4 +99,66 @@
>> Â Â Â Â // to work even without a configuration store.
>> Â Â Â Â this.macroCategories.setProperty(macroId.toString(), category);
>> Â Â }
>> +
>> + Â Â /**
>> + Â Â * {@inheritDoc}
>> + Â Â *
>> + Â Â * @see org.xwiki.rendering.configuration.RenderingConfiguration#getImageWidthLimit()
>> + Â Â */
>> + Â Â public int getImageWidthLimit()
>> + Â Â {
>> + Â Â Â Â return this.imageWidthLimit;
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * @param imageWidthLimit the maximum image width when there's no user supplied width
>> + Â Â */
>> + Â Â public void setImageWidthLimit(int imageWidthLimit)
>> + Â Â {
>> + Â Â Â Â // This method is useful for those using the XWiki Rendering in standalone mode since it allows the rendering
>> + Â Â Â Â // to work even without a configuration store.
>> + Â Â Â Â this.imageWidthLimit = imageWidthLimit;
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * {@inheritDoc}
>> + Â Â *
>> + Â Â * @see org.xwiki.rendering.configuration.RenderingConfiguration#getImageHeightLimit()
>> + Â Â */
>> + Â Â public int getImageHeightLimit()
>> + Â Â {
>> + Â Â Â Â return this.imageHeightLimit;
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * @param imageHeightLimit the maximum image height when there's no user supplied height
>> + Â Â */
>> + Â Â public void setImageHeightLimit(int imageHeightLimit)
>> + Â Â {
>> + Â Â Â Â // This method is useful for those using the XWiki Rendering in standalone mode since it allows the rendering
>> + Â Â Â Â // to work even without a configuration store.
>> + Â Â Â Â this.imageHeightLimit = imageHeightLimit;
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * {@inheritDoc}
>> + Â Â *
>> + Â Â * @see org.xwiki.rendering.configuration.RenderingConfiguration#isIncludeImageDimensionsInImageURL()
>> + Â Â */
>> + Â Â public boolean isIncludeImageDimensionsInImageURL()
>> + Â Â {
>> + Â Â Â Â return this.includeImageDimensionsInImageURL;
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * @param includeImageDimensionsInImageURL {@code true} to include image dimensions extracted from the image
>> + Â Â * Â Â Â Â Â Â parameters in the image URL so that the image can be resized on the server side before being
>> + Â Â * Â Â Â Â Â Â downloaded, {@code false} otherwise
>> + Â Â */
>> + Â Â public void setIncludeImageDimensionsInImageURL(boolean includeImageDimensionsInImageURL)
>> + Â Â {
>> + Â Â Â Â // This method is useful for those using the XWiki Rendering in standalone mode since it allows the rendering
>> + Â Â Â Â // to work even without a configuration store.
>> + Â Â Â Â this.includeImageDimensionsInImageURL = includeImageDimensionsInImageURL;
>> + Â Â }
>> }
>>
>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/xhtml/DefaultXHTMLImageRenderer.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/xhtml/DefaultXHTMLImageRenderer.java  2010-09-11 17:15:46 UTC (rev 31052)
>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/xhtml/DefaultXHTMLImageRenderer.java  2010-09-12 11:30:15 UTC (rev 31053)
>> @@ -42,10 +42,9 @@
>> Â * Default implementation for rendering images as XHTML. We handle both cases:
>> Â * <ul>
>> Â * <li>when inside a wiki (ie when an implementation of {@link WikiModel} is provided.</li>
>> - * <li>when outside of a wiki. In this case we only handle external images and document images don't
>> - * Â Â display anything.</li>
>> + * <li>when outside of a wiki. In this case we only handle external images and document images don't display anything.</li>
>> Â * </ul>
>> - *
>> + *
>> Â * @version $Id$
>> Â * @since 2.0M3
>> Â */
>> @@ -68,6 +67,7 @@
>>
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> + Â Â *
>> Â Â Â * @see Initializable#initialize()
>> Â Â Â */
>> Â Â public void initialize() throws InitializationException
>> @@ -83,7 +83,7 @@
>>
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> - Â Â *
>> + Â Â *
>> Â Â Â * @see XHTMLImageRenderer#setXHTMLWikiPrinter(XHTMLWikiPrinter)
>> Â Â Â */
>> Â Â public void setXHTMLWikiPrinter(XHTMLWikiPrinter printer)
>> @@ -103,7 +103,7 @@
>>
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> - Â Â *
>> + Â Â *
>> Â Â Â * @see XHTMLImageRenderer#onImage(Image, boolean, Map)
>> Â Â Â */
>> Â Â public void onImage(Image image, boolean isFreeStandingURI, Map<String, String> parameters)
>> @@ -118,8 +118,9 @@
>> Â Â Â Â Â Â // that would not honor this contract.
>> Â Â Â Â Â Â if (this.wikiModel != null) {
>> Â Â Â Â Â Â Â Â DocumentImage documentImage = DocumentImage.class.cast(image);
>> - Â Â Â Â Â Â Â Â imageURL = this.wikiModel.getAttachmentURL(documentImage.getDocumentName(),
>> - Â Â Â Â Â Â Â Â Â Â documentImage.getAttachmentName());
>> + Â Â Â Â Â Â Â Â imageURL =
>> + Â Â Â Â Â Â Â Â Â Â this.wikiModel.getImageURL(documentImage.getDocumentName(), documentImage.getAttachmentName(),
>> + Â Â Â Â Â Â Â Â Â Â Â Â parameters);
>> Â Â Â Â Â Â } else {
>> Â Â Â Â Â Â Â Â throw new RuntimeException("Invalid Image type. In non wiki mode, all image types must be URL images.");
>> Â Â Â Â Â Â }
>>
>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/wiki/WikiModel.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/wiki/WikiModel.java   2010-09-11 17:15:46 UTC (rev 31052)
>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/wiki/WikiModel.java   2010-09-12 11:30:15 UTC (rev 31053)
>> @@ -19,13 +19,15 @@
>> Â */
>> package org.xwiki.rendering.wiki;
>>
>> +import java.util.Map;
>> +
>> import org.xwiki.component.annotation.ComponentRole;
>>
>> /**
>> Â * Bridge between the Rendering module and a Wiki Model. Contains wiki APIs required by Rendering classes such as
>> - * Renderers. For example the XHTML Link Renderer needs to know if a wiki document exists in order to know how to
>> - * generate the HTML (in order to display a question mark for non existing documents) and it also needs to get the
>> - * URL pointing the wiki document.
>> + * Renderers. For example the XHTML Link Renderer needs to know if a wiki document exists in order to know how to
>> + * generate the HTML (in order to display a question mark for non existing documents) and it also needs to get the URL
>> + * pointing the wiki document.
>> Â *
>> Â * @version $Id$
>> Â * @since 2.0M1
>> @@ -34,36 +36,48 @@
>> public interface WikiModel
>> {
>> Â Â /**
>> - Â Â * @param documentName the document name of the document containing the attachment. The syntax used depends on
>> - Â Â * Â Â Â Â the underlying wiki system used. For example for XWiki a valid documentName would be
>> - Â Â * Â Â Â Â {@code wiki:Space.Page}
>> + Â Â * @param documentName the document name of the document containing the attachment. The syntax used depends on the
>> + Â Â * Â Â Â Â Â Â underlying wiki system used. For example for XWiki a valid documentName would be
>> + Â Â * Â Â Â Â Â Â {@code wiki:Space.Page}
>> Â Â Â * @param attachmentName the name of the attachment in the passed document wikip page
>> Â Â Â * @return the URL to the attachment
>> Â Â Â */
>> Â Â String getAttachmentURL(String documentName, String attachmentName);
>>
>> Â Â /**
>> - Â Â * @param documentName the document name as a String. The syntax used depends on
>> - Â Â * Â Â Â Â the underlying wiki system used. For example for XWiki a valid documentName would be
>> - Â Â * Â Â Â Â {@code wiki:Space.Page}
>> + Â Â * Generate image specific URL. The difference with {@link #getAttachmentURL(String, String)} is that in some
>> + Â Â * implementation we want to make a distinction between displayed image and a simple link targeting an attachment
>> + Â Â * file.
>> + Â Â *
>> + Â Â * @param documentName the document name of the document containing the attachment. The syntax used depends on the
>> + Â Â * Â Â Â Â Â Â underlying wiki system used. For example for XWiki a valid documentName would be
>> + Â Â * Â Â Â Â Â Â {@code wiki:Space.Page}
>> + Â Â * @param attachmentName the name of the attachment in the passed document wiki page
>> + Â Â * @param parameters custom parameters
>> + Â Â * @return the URL to the image
>> + Â Â * @since 2.5M2
>> + Â Â */
>> + Â Â String getImageURL(String documentName, String attachmentName, Map<String, String> parameters);
>> +
>> + Â Â /**
>> + Â Â * @param documentName the document name as a String. The syntax used depends on the underlying wiki system used.
>> + Â Â * Â Â Â Â Â Â For example for XWiki a valid documentName would be {@code wiki:Space.Page}
>> Â Â Â * @return true if the document exists and can be viewed or false otherwise
>> Â Â Â */
>> Â Â boolean isDocumentAvailable(String documentName);
>>
>> Â Â /**
>> - Â Â * @param documentName the document name as a String. The syntax used depends on
>> - Â Â * Â Â Â Â the underlying wiki system used. For example for XWiki a valid documentName would be
>> - Â Â * Â Â Â Â {@code wiki:Space.Page}
>> + Â Â * @param documentName the document name as a String. The syntax used depends on the underlying wiki system used.
>> + Â Â * Â Â Â Â Â Â For example for XWiki a valid documentName would be {@code wiki:Space.Page}
>> Â Â Â * @param anchor an anchor pointing to some place inside the document or null
>> Â Â Â * @param queryString a query string specifying some parameters or null
>> Â Â Â * @return the URL to view the specified wiki document
>> Â Â Â */
>> Â Â String getDocumentViewURL(String documentName, String anchor, String queryString);
>> -
>> +
>> Â Â /**
>> - Â Â * @param documentName the document name as a String. The syntax used depends on
>> - Â Â * Â Â Â Â the underlying wiki system used. For example for XWiki a valid documentName would be
>> - Â Â * Â Â Â Â {@code wiki:Space.Page}
>> + Â Â * @param documentName the document name as a String. The syntax used depends on the underlying wiki system used.
>> + Â Â * Â Â Â Â Â Â For example for XWiki a valid documentName would be {@code wiki:Space.Page}
>> Â Â Â * @param anchor an anchor pointing to some place inside the document or null
>> Â Â Â * @param queryString a query string specifying some parameters or null
>> Â Â Â * @return the URL to edit the specified wiki document
>>
>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/pom.xml
>> ===================================================================
>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/pom.xml 2010-09-11 17:15:46 UTC (rev 31052)
>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/pom.xml 2010-09-12 11:30:15 UTC (rev 31053)
>> @@ -54,6 +54,12 @@
>> Â Â Â <artifactId>xwiki-core-script</artifactId>
>> Â Â Â <version>${pom.version}</version>
>> Â Â </dependency>
>> + Â Â <dependency>
>> + Â Â Â <!-- For parsing the CSS from the style attribute. -->
>> + Â Â Â <groupId>net.sourceforge.cssparser</groupId>
>> + Â Â Â <artifactId>cssparser</artifactId>
>> + Â Â Â <version>0.9.5</version>
>> + Â Â </dependency>
>> Â Â <!-- Testing dependencies -->
>> Â Â <dependency>
>> Â Â Â <groupId>org.xwiki.platform</groupId>
>>
>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/configuration/XWikiRenderingConfiguration.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/configuration/XWikiRenderingConfiguration.java    2010-09-11 17:15:46 UTC (rev 31052)
>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/configuration/XWikiRenderingConfiguration.java    2010-09-12 11:30:15 UTC (rev 31053)
>> @@ -19,13 +19,13 @@
>> Â */
>> package org.xwiki.rendering.internal.configuration;
>>
>> +import java.util.Properties;
>> +
>> import org.xwiki.component.annotation.Component;
>> import org.xwiki.component.annotation.Requirement;
>> import org.xwiki.configuration.ConfigurationSource;
>> import org.xwiki.rendering.configuration.RenderingConfiguration;
>>
>> -import java.util.Properties;
>> -
>> /**
>> Â * All configuration options for the rendering subsystem.
>> Â *
>> @@ -46,7 +46,7 @@
>> Â Â private static final String DEFAULT_LINK_LABEL_FORMAT = "%p";
>>
>> Â Â /**
>> - Â Â * Defines from where to read the rendering configuration data.
>> + Â Â * Defines from where to read the rendering configuration data.
>> Â Â Â */
>> Â Â @Requirement
>> Â Â private ConfigurationSource configuration;
>> @@ -58,16 +58,46 @@
>> Â Â Â */
>> Â Â public String getLinkLabelFormat()
>> Â Â {
>> - Â Â Â return this.configuration.getProperty(PREFIX + "linkLabelFormat", DEFAULT_LINK_LABEL_FORMAT);
>> + Â Â Â Â return this.configuration.getProperty(PREFIX + "linkLabelFormat", DEFAULT_LINK_LABEL_FORMAT);
>> Â Â }
>>
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> - Â Â *
>> + Â Â *
>> Â Â Â * @see org.xwiki.rendering.configuration.RenderingConfiguration#getMacroCategories()
>> Â Â Â */
>> Â Â public Properties getMacroCategories()
>> Â Â {
>> Â Â Â Â return this.configuration.getProperty(PREFIX + "macroCategories", Properties.class);
>> Â Â }
>> +
>> + Â Â /**
>> + Â Â * {@inheritDoc}
>> + Â Â *
>> + Â Â * @see org.xwiki.rendering.configuration.RenderingConfiguration#getImageWidthLimit()
>> + Â Â */
>> + Â Â public int getImageWidthLimit()
>> + Â Â {
>> + Â Â Â Â return this.configuration.getProperty(PREFIX + "imageWidthLimit", -1);
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * {@inheritDoc}
>> + Â Â *
>> + Â Â * @see org.xwiki.rendering.configuration.RenderingConfiguration#getImageHeightLimit()
>> + Â Â */
>> + Â Â public int getImageHeightLimit()
>> + Â Â {
>> + Â Â Â Â return this.configuration.getProperty(PREFIX + "imageHeightLimit", -1);
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * {@inheritDoc}
>> + Â Â *
>> + Â Â * @see org.xwiki.rendering.configuration.RenderingConfiguration#isIncludeImageDimensionsInImageURL()
>> + Â Â */
>> + Â Â public boolean isIncludeImageDimensionsInImageURL()
>> + Â Â {
>> + Â Â Â Â return this.configuration.getProperty(PREFIX + "includeImageDimensionsInImageURL", true);
>> + Â Â }
>> }
>>
>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/wiki/XWikiWikiModel.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/wiki/XWikiWikiModel.java   2010-09-11 17:15:46 UTC (rev 31052)
>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/wiki/XWikiWikiModel.java   2010-09-12 11:30:15 UTC (rev 31053)
>> @@ -19,17 +19,25 @@
>> Â */
>> package org.xwiki.rendering.internal.wiki;
>>
>> +import java.io.IOException;
>> +import java.io.StringReader;
>> import java.io.UnsupportedEncodingException;
>> import java.net.URLEncoder;
>> +import java.util.Map;
>>
>> import org.apache.commons.lang.StringUtils;
>> +import org.w3c.css.sac.InputSource;
>> +import org.w3c.dom.css.CSSStyleDeclaration;
>> import org.xwiki.bridge.DocumentAccessBridge;
>> -import org.xwiki.model.reference.DocumentReference;
>> import org.xwiki.component.annotation.Component;
>> import org.xwiki.component.annotation.Requirement;
>> +import org.xwiki.model.reference.DocumentReference;
>> import org.xwiki.model.reference.EntityReferenceSerializer;
>> +import org.xwiki.rendering.configuration.RenderingConfiguration;
>> import org.xwiki.rendering.wiki.WikiModel;
>>
>> +import com.steadystate.css.parser.CSSOMParser;
>> +
>> /**
>> Â * Implementation using the Document Access Bridge ({@link DocumentAccessBridge}).
>> Â *
>> @@ -39,14 +47,47 @@
>> @Component
>> public class XWikiWikiModel implements WikiModel
>> {
>> + Â Â /**
>> + Â Â * The suffix used to mark an amount of pixels.
>> + Â Â */
>> + Â Â private static final String PIXELS = "px";
>> +
>> + Â Â /**
>> + Â Â * The name of the {@code width} image parameter.
>> + Â Â */
>> + Â Â private static final String WIDTH = "width";
>> +
>> + Â Â /**
>> + Â Â * The name of the {@code height} image parameter.
>> + Â Â */
>> + Â Â private static final String HEIGHT = "height";
>> +
>> + Â Â /**
>> + Â Â * The component used to access configuration parameters.
>> + Â Â */
>> Â Â @Requirement
>> + Â Â private RenderingConfiguration renderingConfiguration;
>> +
>> + Â Â /**
>> + Â Â * The component used to access the underlying XWiki model.
>> + Â Â */
>> + Â Â @Requirement
>> Â Â private DocumentAccessBridge documentAccessBridge;
>>
>> + Â Â /**
>> + Â Â * The component used to serialize entity references to strings.
>> + Â Â */
>> Â Â @Requirement
>> Â Â private EntityReferenceSerializer<String> entityReferenceSerializer;
>>
>> Â Â /**
>> + Â Â * The object used to parse the CSS from the image style parameter.
>> + Â Â */
>> + Â Â private final CSSOMParser cssParser = new CSSOMParser();
>> +
>> + Â Â /**
>> Â Â Â * {@inheritDoc}
>> + Â Â *
>> Â Â Â * @see WikiModel#getAttachmentURL(String, String)
>> Â Â Â */
>> Â Â public String getAttachmentURL(String documentName, String attachmentName)
>> @@ -55,7 +96,112 @@
>> Â Â }
>>
>> Â Â /**
>> + Â Â * Extracts the specified image dimension from the image parameters.
>> + Â Â *
>> + Â Â * @param dimension either {@code width} or {@code height}
>> + Â Â * @param imageParameters the image parameters; may include the {@code width}, {@code height} and {@code style}
>> + Â Â * Â Â Â Â Â Â parameters
>> + Â Â * @return the value of the passed dimension if it is specified in the image parameters, {@code null} otherwise
>> + Â Â */
>> + Â Â private String getImageDimension(String dimension, Map<String, String> imageParameters)
>> + Â Â {
>> + Â Â Â Â // Check first if the style parameter contains information about the given dimension. In-line style has priority
>> + Â Â Â Â // over the dimension parameters.
>> + Â Â Â Â String value = null;
>> + Â Â Â Â String style = imageParameters.get("style");
>> + Â Â Â Â if (StringUtils.isNotBlank(style)) {
>> + Â Â Â Â Â Â try {
>> + Â Â Â Â Â Â Â Â CSSStyleDeclaration sd = cssParser.parseStyleDeclaration(new InputSource(new StringReader(style)));
>> + Â Â Â Â Â Â Â Â value = sd.getPropertyValue(dimension);
>> + Â Â Â Â Â Â } catch (IOException e) {
>> + Â Â Â Â Â Â Â Â // Ignore the style parameter.
>> + Â Â Â Â Â Â }
>> + Â Â Â Â }
>> + Â Â Â Â if (StringUtils.isBlank(value)) {
>> + Â Â Â Â Â Â // Fall back on the value of the dimension parameter.
>> + Â Â Â Â Â Â value = imageParameters.get(dimension);
>> + Â Â Â Â }
>> + Â Â Â Â return value;
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * Creates the query string that can be added to an image URL to resize the image on the server side.
>> + Â Â *
>> + Â Â * @param imageParameters image parameters, including width and height then they are specified
>> + Â Â * @return the query string to be added to an image URL in order to resize the image on the server side
>> + Â Â */
>> + Â Â private StringBuilder getImageURLQueryString(Map<String, String> imageParameters)
>> + Â Â {
>> + Â Â Â Â String width = StringUtils.chomp(getImageDimension(WIDTH, imageParameters), PIXELS);
>> + Â Â Â Â String height = StringUtils.chomp(getImageDimension(HEIGHT, imageParameters), PIXELS);
>> + Â Â Â Â boolean useHeight = StringUtils.isNotEmpty(height) && StringUtils.isNumeric(height);
>> + Â Â Â Â StringBuilder queryString = new StringBuilder();
>> + Â Â Â Â if (StringUtils.isEmpty(width) || !StringUtils.isNumeric(width)) {
>> + Â Â Â Â Â Â // Width is unspecified or is not measured in pixels.
>> + Â Â Â Â Â Â if (useHeight) {
>> + Â Â Â Â Â Â Â Â // Height is specified in pixels.
>> + Â Â Â Â Â Â Â Â queryString.append('&').append(HEIGHT).append('=').append(height);
>> + Â Â Â Â Â Â } else {
>> + Â Â Â Â Â Â Â Â // If image width and height are unspecified or if they are not expressed in pixels then limit the image
>> + Â Â Â Â Â Â Â Â // size to best fit the rectangle specified in the configuration (keeping aspect ratio).
>> + Â Â Â Â Â Â Â Â int widthLimit = renderingConfiguration.getImageWidthLimit();
>> + Â Â Â Â Â Â Â Â if (widthLimit > 0) {
>> + Â Â Â Â Â Â Â Â Â Â queryString.append('&').append(WIDTH).append('=').append(widthLimit);
>> + Â Â Â Â Â Â Â Â }
>> + Â Â Â Â Â Â Â Â int heightLimit = renderingConfiguration.getImageHeightLimit();
>> + Â Â Â Â Â Â Â Â if (heightLimit > 0) {
>> + Â Â Â Â Â Â Â Â Â Â queryString.append('&').append(HEIGHT).append('=').append(heightLimit);
>> + Â Â Â Â Â Â Â Â }
>> + Â Â Â Â Â Â Â Â if (widthLimit > 0 && heightLimit > 0) {
>> + Â Â Â Â Â Â Â Â Â Â queryString.append("&keepAspectRatio=").append(true);
>> + Â Â Â Â Â Â Â Â }
>> + Â Â Â Â Â Â }
>> + Â Â Â Â } else {
>> + Â Â Â Â Â Â // Width is specified in pixels.
>> + Â Â Â Â Â Â queryString.append('&').append(WIDTH).append('=').append(width);
>> + Â Â Â Â Â Â if (useHeight) {
>> + Â Â Â Â Â Â Â Â // Height is specified in pixels.
>> + Â Â Â Â Â Â Â Â queryString.append('&').append(HEIGHT).append('=').append(height);
>> + Â Â Â Â Â Â }
>> + Â Â Â Â }
>> + Â Â Â Â return queryString;
>> + Â Â }
>> +
>> + Â Â /**
>> Â Â Â * {@inheritDoc}
>> + Â Â *
>> + Â Â * @see org.xwiki.rendering.wiki.WikiModel#getImageURL(java.lang.String, java.lang.String, java.util.Map)
>> + Â Â */
>> + Â Â public String getImageURL(String documentName, String attachmentName, Map<String, String> parameters)
>> + Â Â {
>> + Â Â Â Â String url = getAttachmentURL(documentName, attachmentName);
>> + Â Â Â Â if (!renderingConfiguration.isIncludeImageDimensionsInImageURL()) {
>> + Â Â Â Â Â Â return url;
>> + Â Â Â Â }
>> +
>> + Â Â Â Â StringBuilder queryString = getImageURLQueryString(parameters);
>> + Â Â Â Â if (queryString.length() == 0) {
>> + Â Â Â Â Â Â return url;
>> + Â Â Â Â }
>> +
>> + Â Â Â Â // Determine the insertion point.
>> + Â Â Â Â int insertionPoint = url.lastIndexOf('#');
>> + Â Â Â Â if (insertionPoint < 0) {
>> + Â Â Â Â Â Â // No fragment identifier.
>> + Â Â Â Â Â Â insertionPoint = url.length();
>> + Â Â Â Â }
>> + Â Â Â Â if (url.lastIndexOf('?', insertionPoint) < 0) {
>> + Â Â Â Â Â Â // No query string.
>> + Â Â Â Â Â Â queryString.setCharAt(0, '?');
>> + Â Â Â Â }
>> +
>> + Â Â Â Â // Insert the query string.
>> + Â Â Â Â return new StringBuilder(url).insert(insertionPoint, queryString).toString();
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * {@inheritDoc}
>> + Â Â *
>> Â Â Â * @see WikiModel#isDocumentAvailable(String)
>> Â Â Â */
>> Â Â public boolean isDocumentAvailable(String documentName)
>> @@ -65,6 +211,7 @@
>>
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> + Â Â *
>> Â Â Â * @see WikiModel#getDocumentViewURL(String, String, String)
>> Â Â Â */
>> Â Â public String getDocumentViewURL(String documentName, String anchor, String queryString)
>> @@ -74,6 +221,7 @@
>>
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> + Â Â *
>> Â Â Â * @see WikiModel#getDocumentEditURL(String, String, String)
>> Â Â Â */
>> Â Â public String getDocumentEditURL(String documentName, String anchor, String queryString)
>> @@ -89,17 +237,17 @@
>> Â Â Â Â Â Â Â Â Â Â // See http://www.w3.org/TR/html40/appendix/notes.html#non-ascii-chars
>> Â Â Â Â Â Â Â Â Â Â // TODO: Once the xwiki-url module is usable, refactor this code to use it and remove the need to
>> Â Â Â Â Â Â Â Â Â Â // perform explicit encoding here.
>> - Â Â Â Â Â Â Â Â Â Â modifiedQueryString =
>> + Â Â Â Â Â Â Â Â Â Â modifiedQueryString =
>> Â Â Â Â Â Â Â Â Â Â Â Â "parent=" + URLEncoder.encode(this.entityReferenceSerializer.serialize(reference), "UTF-8");
>> Â Â Â Â Â Â Â Â } catch (UnsupportedEncodingException e) {
>> Â Â Â Â Â Â Â Â Â Â // Not supporting UTF-8 as a valid encoding for some reasons. We consider XWiki cannot work
>> Â Â Â Â Â Â Â Â Â Â // without that encoding.
>> - Â Â Â Â Â Â Â Â Â Â throw new RuntimeException("Failed to URL encode [" + this.entityReferenceSerializer.serialize(
>> - Â Â Â Â Â Â Â Â Â Â Â Â reference) + "] using UTF-8.", e);
>> + Â Â Â Â Â Â Â Â Â Â throw new RuntimeException("Failed to URL encode ["
>> + Â Â Â Â Â Â Â Â Â Â Â Â + this.entityReferenceSerializer.serialize(reference) + "] using UTF-8.", e);
>> Â Â Â Â Â Â Â Â }
>> Â Â Â Â Â Â }
>> Â Â Â Â }
>> -
>> +
>> Â Â Â Â return this.documentAccessBridge.getURL(documentName, "create", modifiedQueryString, anchor);
>> Â Â }
>> }
>>
>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/test/java/org/xwiki/rendering/internal/configuration/XWikiRenderingConfigurationTest.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/test/java/org/xwiki/rendering/internal/configuration/XWikiRenderingConfigurationTest.java  2010-09-11 17:15:46 UTC (rev 31052)
>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/test/java/org/xwiki/rendering/internal/configuration/XWikiRenderingConfigurationTest.java  2010-09-12 11:30:15 UTC (rev 31053)
>> @@ -22,9 +22,9 @@
>> import java.util.Properties;
>>
>> import org.jmock.Expectations;
>> -import org.xwiki.configuration.ConfigurationSource;
>> import org.junit.Assert;
>> import org.junit.Test;
>> +import org.xwiki.configuration.ConfigurationSource;
>> import org.xwiki.test.AbstractMockingComponentTestCase;
>> import org.xwiki.test.annotation.MockingRequirement;
>>
>> @@ -43,10 +43,13 @@
>> Â Â public void testGetLinkLabelFormat() throws Exception
>> Â Â {
>> Â Â Â Â final ConfigurationSource source = getComponentManager().lookup(ConfigurationSource.class);
>> - Â Â Â Â getMockery().checking(new Expectations() {{
>> - Â Â Â Â Â Â allowing(source).getProperty("rendering.linkLabelFormat", "%p");
>> + Â Â Â Â getMockery().checking(new Expectations()
>> + Â Â Â Â {
>> + Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â allowing(source).getProperty("rendering.linkLabelFormat", "%p");
>> Â Â Â Â Â Â Â Â will(returnValue("%p"));
>> - Â Â Â Â }});
>> + Â Â Â Â Â Â }
>> + Â Â Â Â });
>>
>> Â Â Â Â Assert.assertEquals("%p", this.configuration.getLinkLabelFormat());
>> Â Â }
>> @@ -55,12 +58,60 @@
>> Â Â public void testGetMacroCategories() throws Exception
>> Â Â {
>> Â Â Â Â final ConfigurationSource source = getComponentManager().lookup(ConfigurationSource.class);
>> - Â Â Â Â getMockery().checking(new Expectations() {{
>> - Â Â Â Â Â Â allowing(source).getProperty("rendering.macroCategories", Properties.class);
>> + Â Â Â Â getMockery().checking(new Expectations()
>> + Â Â Â Â {
>> + Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â allowing(source).getProperty("rendering.macroCategories", Properties.class);
>> Â Â Â Â Â Â Â Â will(returnValue(new Properties()));
>> - Â Â Â Â }});
>> + Â Â Â Â Â Â }
>> + Â Â Â Â });
>>
>> Â Â Â Â Assert.assertNotNull(this.configuration.getMacroCategories());
>> Â Â Â Â Assert.assertEquals(0, this.configuration.getMacroCategories().size());
>> Â Â }
>> +
>> + Â Â @Test
>> + Â Â public void testGetImageWidthLimit() throws Exception
>> + Â Â {
>> + Â Â Â Â final ConfigurationSource source = getComponentManager().lookup(ConfigurationSource.class);
>> + Â Â Â Â getMockery().checking(new Expectations()
>> + Â Â Â Â {
>> + Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â allowing(source).getProperty("rendering.imageWidthLimit", -1);
>> + Â Â Â Â Â Â Â Â will(returnValue(100));
>> + Â Â Â Â Â Â }
>> + Â Â Â Â });
>> +
>> + Â Â Â Â Assert.assertEquals(100, this.configuration.getImageWidthLimit());
>> + Â Â }
>> +
>> + Â Â @Test
>> + Â Â public void testGetImageHeightLimit() throws Exception
>> + Â Â {
>> + Â Â Â Â final ConfigurationSource source = getComponentManager().lookup(ConfigurationSource.class);
>> + Â Â Â Â getMockery().checking(new Expectations()
>> + Â Â Â Â {
>> + Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â allowing(source).getProperty("rendering.imageHeightLimit", -1);
>> + Â Â Â Â Â Â Â Â will(returnValue(150));
>> + Â Â Â Â Â Â }
>> + Â Â Â Â });
>> +
>> + Â Â Â Â Assert.assertEquals(150, this.configuration.getImageHeightLimit());
>> + Â Â }
>> +
>> + Â Â @Test
>> + Â Â public void testIsIncludeImageDimensionsInImageURL() throws Exception
>> + Â Â {
>> + Â Â Â Â final ConfigurationSource source = getComponentManager().lookup(ConfigurationSource.class);
>> + Â Â Â Â getMockery().checking(new Expectations()
>> + Â Â Â Â {
>> + Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â allowing(source).getProperty("rendering.includeImageDimensionsInImageURL", true);
>> + Â Â Â Â Â Â Â Â will(returnValue(false));
>> + Â Â Â Â Â Â }
>> + Â Â Â Â });
>> +
>> + Â Â Â Â Assert.assertFalse(this.configuration.isIncludeImageDimensionsInImageURL());
>> + Â Â }
>> }
>>
>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/test/java/org/xwiki/rendering/internal/wiki/XWikiWikiModelTest.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/test/java/org/xwiki/rendering/internal/wiki/XWikiWikiModelTest.java 2010-09-11 17:15:46 UTC (rev 31052)
>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-xwiki/src/test/java/org/xwiki/rendering/internal/wiki/XWikiWikiModelTest.java 2010-09-12 11:30:15 UTC (rev 31053)
>> @@ -19,12 +19,20 @@
>> Â */
>> package org.xwiki.rendering.internal.wiki;
>>
>> +import java.util.Collections;
>> +import java.util.HashMap;
>> +import java.util.Map;
>> +
>> +import junit.framework.Assert;
>> +
>> import org.jmock.Expectations;
>> -import org.jmock.Mockery;
>> +import org.junit.Test;
>> import org.xwiki.bridge.DocumentAccessBridge;
>> import org.xwiki.model.reference.DocumentReference;
>> -import org.xwiki.component.util.ReflectionUtils;
>> import org.xwiki.model.reference.EntityReferenceSerializer;
>> +import org.xwiki.rendering.configuration.RenderingConfiguration;
>> +import org.xwiki.test.AbstractMockingComponentTestCase;
>> +import org.xwiki.test.annotation.MockingRequirement;
>>
>> /**
>> Â * Unit tests for {@link XWikiWikiModel}.
>> @@ -32,31 +40,321 @@
>> Â * @version $Id$
>> Â * @since 2.0M1
>> Â */
>> -public class XWikiWikiModelTest
>> +public class XWikiWikiModelTest extends AbstractMockingComponentTestCase
>> {
>> - Â Â @org.junit.Test
>> + Â Â @MockingRequirement
>> + Â Â private XWikiWikiModel wikiModel;
>> +
>> + Â Â @Test
>> Â Â public void testGetDocumentEditURLWhenNoQueryStringSpecified() throws Exception
>> Â Â {
>> - Â Â Â Â Mockery mockery = new Mockery();
>> - Â Â Â Â XWikiWikiModel wikiModel = new XWikiWikiModel();
>> + Â Â Â Â final EntityReferenceSerializer< ? > entityReferenceSerializer =
>> + Â Â Â Â Â Â getComponentManager().lookup(EntityReferenceSerializer.class);
>> + Â Â Â Â final DocumentAccessBridge documentAccessBridge = getComponentManager().lookup(DocumentAccessBridge.class);
>> + Â Â Â Â final DocumentReference documentReference = new DocumentReference("wiki", "Space", "Page");
>> + Â Â Â Â getMockery().checking(new Expectations()
>> + Â Â Â Â {
>> + Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â oneOf(documentAccessBridge).getCurrentDocumentReference();
>> + Â Â Â Â Â Â Â Â will(returnValue(documentReference));
>> + Â Â Â Â Â Â Â Â oneOf(entityReferenceSerializer).serialize(documentReference);
>> + Â Â Â Â Â Â Â Â will(returnValue("wiki:Space.Page\u20AC"));
>>
>> - Â Â Â Â final EntityReferenceSerializer mockEntityReferenceSerializer = mockery.mock(EntityReferenceSerializer.class);
>> - Â Â Â Â ReflectionUtils.setFieldValue(wikiModel, "entityReferenceSerializer", mockEntityReferenceSerializer);
>> + Â Â Â Â Â Â Â Â // The test is here: we verify that getURL is called with the query string already encoded since
>> + Â Â Â Â Â Â Â Â // getURL() doesn't encode it.
>> + Â Â Â Â Â Â Â Â oneOf(documentAccessBridge).getURL("Space.Page\u20AC", "create", "parent=wiki%3ASpace.Page%E2%82%AC",
>> + Â Â Â Â Â Â Â Â Â Â "anchor");
>> + Â Â Â Â Â Â }
>> + Â Â Â Â });
>>
>> - Â Â Â Â final DocumentAccessBridge mockDocumentAccessBridge = mockery.mock(DocumentAccessBridge.class);
>> - Â Â Â Â ReflectionUtils.setFieldValue(wikiModel, "documentAccessBridge", mockDocumentAccessBridge);
>> + Â Â Â Â wikiModel.getDocumentEditURL("Space.Page\u20AC", "anchor", null);
>> + Â Â }
>>
>> - Â Â Â Â final DocumentReference docReference = new DocumentReference("wiki", "Space", "Page");
>> - Â Â Â Â mockery.checking(new Expectations() {{
>> - Â Â Â Â Â Â oneOf(mockDocumentAccessBridge).getCurrentDocumentReference(); will(returnValue(docReference));
>> - Â Â Â Â Â Â oneOf(mockEntityReferenceSerializer).serialize(docReference); will(returnValue("wiki:Space.Page\u20AC"));
>> + Â Â /**
>> + Â Â * Tests that the proper image URL is generated when both the width and the height image parameters are specified.
>> + Â Â *
>> + Â Â * @throws Exception if an exception occurs while running the test
>> + Â Â */
>> + Â Â @Test
>> + Â Â public void testGetImageURLWhenBothWidthAndHeightAttributesAreSpecified() throws Exception
>> + Â Â {
>> + Â Â Â Â final DocumentAccessBridge documentAccessBridge = getComponentManager().lookup(DocumentAccessBridge.class);
>> + Â Â Â Â final RenderingConfiguration configuration = getComponentManager().lookup(RenderingConfiguration.class);
>> + Â Â Â Â getMockery().checking(new Expectations()
>> + Â Â Â Â {
>> + Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â oneOf(documentAccessBridge).getAttachmentURL("", "");
>> + Â Â Â Â Â Â Â Â will(returnValue(""));
>> + Â Â Â Â Â Â Â Â oneOf(configuration).isIncludeImageDimensionsInImageURL();
>> + Â Â Â Â Â Â Â Â will(returnValue(true));
>> + Â Â Â Â Â Â }
>> + Â Â Â Â });
>> + Â Â Â Â Map<String, String> parameters = new HashMap<String, String>();
>> + Â Â Â Â parameters.put("width", "100px");
>> + Â Â Â Â parameters.put("height", "50");
>> + Â Â Â Â Assert.assertEquals("?width=100&height=50", wikiModel.getImageURL("", "", parameters));
>> + Â Â }
>>
>> - Â Â Â Â Â Â // The test is here: we verify that getURL is called with the query string already encoded since getURL()
>> - Â Â Â Â Â Â // doesn't encode it.
>> - Â Â Â Â Â Â oneOf(mockDocumentAccessBridge).getURL("Space.Page\u20AC", "create", "parent=wiki%3ASpace.Page%E2%82%AC",
>> - Â Â Â Â Â Â Â Â "anchor");
>> - Â Â Â Â }});
>> + Â Â /**
>> + Â Â * Tests that the proper image URL is generated when both the width and the height image parameters are specified
>> + Â Â * but including them in the image URL is forbidden from the rendering configuration.
>> + Â Â *
>> + Â Â * @throws Exception if an exception occurs while running the test
>> + Â Â */
>> + Â Â @Test
>> + Â Â public void testGetImageURLWhenIncludingImageDimensionsIsForbidden() throws Exception
>> + Â Â {
>> + Â Â Â Â final DocumentAccessBridge documentAccessBridge = getComponentManager().lookup(DocumentAccessBridge.class);
>> + Â Â Â Â final RenderingConfiguration configuration = getComponentManager().lookup(RenderingConfiguration.class);
>> + Â Â Â Â getMockery().checking(new Expectations()
>> + Â Â Â Â {
>> + Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â oneOf(documentAccessBridge).getAttachmentURL("", "");
>> + Â Â Â Â Â Â Â Â will(returnValue(""));
>> + Â Â Â Â Â Â Â Â oneOf(configuration).isIncludeImageDimensionsInImageURL();
>> + Â Â Â Â Â Â Â Â will(returnValue(false));
>> + Â Â Â Â Â Â }
>> + Â Â Â Â });
>> + Â Â Â Â Map<String, String> parameters = new HashMap<String, String>();
>> + Â Â Â Â parameters.put("width", "101px");
>> + Â Â Â Â parameters.put("height", "55px");
>> + Â Â Â Â Assert.assertEquals("", wikiModel.getImageURL("", "", parameters));
>> + Â Â }
>>
>> - Â Â Â Â wikiModel.getDocumentEditURL("Space.Page\u20AC", "anchor", null);
>> + Â Â /**
>> + Â Â * Tests that the proper image URL is generated when both the width and the height CSS properties are specified.
>> + Â Â *
>> + Â Â * @throws Exception if an exception occurs while running the test
>> + Â Â */
>> + Â Â @Test
>> + Â Â public void testGetImageURLWhenBothWidthAndHeightCSSPropertiesAreSpecified() throws Exception
>> + Â Â {
>> + Â Â Â Â final DocumentAccessBridge documentAccessBridge = getComponentManager().lookup(DocumentAccessBridge.class);
>> + Â Â Â Â final RenderingConfiguration configuration = getComponentManager().lookup(RenderingConfiguration.class);
>> + Â Â Â Â getMockery().checking(new Expectations()
>> + Â Â Â Â {
>> + Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â oneOf(documentAccessBridge).getAttachmentURL("", "");
>> + Â Â Â Â Â Â Â Â will(returnValue(""));
>> + Â Â Â Â Â Â Â Â oneOf(configuration).isIncludeImageDimensionsInImageURL();
>> + Â Â Â Â Â Â Â Â will(returnValue(true));
>> + Â Â Â Â Â Â }
>> + Â Â Â Â });
>> + Â Â Â Â Map<String, String> parameters = new HashMap<String, String>();
>> + Â Â Â Â parameters.put("style", "border: 1px; height: 30px; margin-top: 2em; width: 70px");
>> + Â Â Â Â Assert.assertEquals("?width=70&height=30", wikiModel.getImageURL("", "", parameters));
>> Â Â }
>> +
>> + Â Â /**
>> + Â Â * Tests that the proper image URL is generated when only the width image parameter is specified.
>> + Â Â *
>> + Â Â * @throws Exception if an exception occurs while running the test
>> + Â Â */
>> + Â Â @Test
>> + Â Â public void testGetImageURLWhenOnlyWidthAttributeIsSpecified() throws Exception
>> + Â Â {
>> + Â Â Â Â final DocumentAccessBridge documentAccessBridge = getComponentManager().lookup(DocumentAccessBridge.class);
>> + Â Â Â Â final RenderingConfiguration configuration = getComponentManager().lookup(RenderingConfiguration.class);
>> + Â Â Â Â getMockery().checking(new Expectations()
>> + Â Â Â Â {
>> + Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â oneOf(documentAccessBridge).getAttachmentURL("", "");
>> + Â Â Â Â Â Â Â Â will(returnValue(""));
>> + Â Â Â Â Â Â Â Â oneOf(configuration).isIncludeImageDimensionsInImageURL();
>> + Â Â Â Â Â Â Â Â will(returnValue(true));
>> + Â Â Â Â Â Â }
>> + Â Â Â Â });
>> + Â Â Â Â Map<String, String> parameters = new HashMap<String, String>();
>> + Â Â Â Â parameters.put("width", "150");
>> + Â Â Â Â parameters.put("height", "30%");
>> + Â Â Â Â Assert.assertEquals("?width=150", wikiModel.getImageURL("", "", parameters));
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * Tests that the proper image URL is generated when only the height CSS property is specified.
>> + Â Â *
>> + Â Â * @throws Exception if an exception occurs while running the test
>> + Â Â */
>> + Â Â @Test
>> + Â Â public void testGetImageURLWhenOnlyHeightCSSPropertyIsSpecified() throws Exception
>> + Â Â {
>> + Â Â Â Â final DocumentAccessBridge documentAccessBridge = getComponentManager().lookup(DocumentAccessBridge.class);
>> + Â Â Â Â final RenderingConfiguration configuration = getComponentManager().lookup(RenderingConfiguration.class);
>> + Â Â Â Â getMockery().checking(new Expectations()
>> + Â Â Â Â {
>> + Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â oneOf(documentAccessBridge).getAttachmentURL("", "");
>> + Â Â Â Â Â Â Â Â will(returnValue(""));
>> + Â Â Â Â Â Â Â Â oneOf(configuration).isIncludeImageDimensionsInImageURL();
>> + Â Â Â Â Â Â Â Â will(returnValue(true));
>> + Â Â Â Â Â Â }
>> + Â Â Â Â });
>> + Â Â Â Â Map<String, String> parameters = new HashMap<String, String>();
>> + Â Â Â Â parameters.put("style", "width: 5cm; height: 80px");
>> + Â Â Â Â Assert.assertEquals("?height=80", wikiModel.getImageURL("", "", parameters));
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * Tests that the proper image URL is generated when both the width and the height are unspecified and image size is
>> + Â Â * limited in the configuration.
>> + Â Â *
>> + Â Â * @throws Exception if an exception occurs while running the test
>> + Â Â */
>> + Â Â @Test
>> + Â Â public void testGetImageURLWhenBothWidthAndHeightAreUnspecifiedAndImageSizeIsLimited() throws Exception
>> + Â Â {
>> + Â Â Â Â final DocumentAccessBridge documentAccessBridge = getComponentManager().lookup(DocumentAccessBridge.class);
>> + Â Â Â Â final RenderingConfiguration configuration = getComponentManager().lookup(RenderingConfiguration.class);
>> + Â Â Â Â getMockery().checking(new Expectations()
>> + Â Â Â Â {
>> + Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â oneOf(documentAccessBridge).getAttachmentURL("", "");
>> + Â Â Â Â Â Â Â Â will(returnValue(""));
>> + Â Â Â Â Â Â Â Â oneOf(configuration).isIncludeImageDimensionsInImageURL();
>> + Â Â Â Â Â Â Â Â will(returnValue(true));
>> + Â Â Â Â Â Â Â Â oneOf(configuration).getImageWidthLimit();
>> + Â Â Â Â Â Â Â Â will(returnValue(200));
>> + Â Â Â Â Â Â Â Â oneOf(configuration).getImageHeightLimit();
>> + Â Â Â Â Â Â Â Â will(returnValue(170));
>> + Â Â Â Â Â Â }
>> + Â Â Â Â });
>> + Â Â Â Â Map<String, String> parameters = Collections.emptyMap();
>> + Â Â Â Â Assert.assertEquals("?width=200&height=170&keepAspectRatio=true", wikiModel.getImageURL("", "", parameters));
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * Tests that the proper image URL is generated when both the width and the height are unspecified and only the
>> + Â Â * image width is limited in the configuration.
>> + Â Â *
>> + Â Â * @throws Exception if an exception occurs while running the test
>> + Â Â */
>> + Â Â @Test
>> + Â Â public void testGetImageURLWhenBothWidthAndHeightAreUnspecifiedAndOnlyImageWidthIsLimited() throws Exception
>> + Â Â {
>> + Â Â Â Â final DocumentAccessBridge documentAccessBridge = getComponentManager().lookup(DocumentAccessBridge.class);
>> + Â Â Â Â final RenderingConfiguration configuration = getComponentManager().lookup(RenderingConfiguration.class);
>> + Â Â Â Â getMockery().checking(new Expectations()
>> + Â Â Â Â {
>> + Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â oneOf(documentAccessBridge).getAttachmentURL("", "");
>> + Â Â Â Â Â Â Â Â will(returnValue(""));
>> + Â Â Â Â Â Â Â Â oneOf(configuration).isIncludeImageDimensionsInImageURL();
>> + Â Â Â Â Â Â Â Â will(returnValue(true));
>> + Â Â Â Â Â Â Â Â oneOf(configuration).getImageWidthLimit();
>> + Â Â Â Â Â Â Â Â will(returnValue(25));
>> + Â Â Â Â Â Â Â Â oneOf(configuration).getImageHeightLimit();
>> + Â Â Â Â Â Â Â Â will(returnValue(-1));
>> + Â Â Â Â Â Â }
>> + Â Â Â Â });
>> + Â Â Â Â Map<String, String> parameters = new HashMap<String, String>();
>> + Â Â Â Â parameters.put("width", "45%");
>> + Â Â Â Â parameters.put("style", "height:10em");
>> + Â Â Â Â Assert.assertEquals("?width=25", wikiModel.getImageURL("", "", parameters));
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * Tests that the proper image URL is generated when both the width and the height are unspecified and the image
>> + Â Â * size is not limited in the configuration.
>> + Â Â *
>> + Â Â * @throws Exception if an exception occurs while running the test
>> + Â Â */
>> + Â Â @Test
>> + Â Â public void testGetImageURLWhenBothWidthAndHeightAreUnspecifiedAndImageSizeIsNotLimited() throws Exception
>> + Â Â {
>> + Â Â Â Â final DocumentAccessBridge documentAccessBridge = getComponentManager().lookup(DocumentAccessBridge.class);
>> + Â Â Â Â final RenderingConfiguration configuration = getComponentManager().lookup(RenderingConfiguration.class);
>> + Â Â Â Â getMockery().checking(new Expectations()
>> + Â Â Â Â {
>> + Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â oneOf(documentAccessBridge).getAttachmentURL("", "");
>> + Â Â Â Â Â Â Â Â will(returnValue(""));
>> + Â Â Â Â Â Â Â Â oneOf(configuration).isIncludeImageDimensionsInImageURL();
>> + Â Â Â Â Â Â Â Â will(returnValue(true));
>> + Â Â Â Â Â Â Â Â oneOf(configuration).getImageWidthLimit();
>> + Â Â Â Â Â Â Â Â will(returnValue(-1));
>> + Â Â Â Â Â Â Â Â oneOf(configuration).getImageHeightLimit();
>> + Â Â Â Â Â Â Â Â will(returnValue(-1));
>> + Â Â Â Â Â Â }
>> + Â Â Â Â });
>> + Â Â Â Â Map<String, String> parameters = new HashMap<String, String>();
>> + Â Â Â Â parameters.put("style", "bad CSS declaration");
>> + Â Â Â Â Assert.assertEquals("", wikiModel.getImageURL("", "", parameters));
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * Tests that the proper image URL is generated when the attachment URL has a fragment identifier.
>> + Â Â *
>> + Â Â * @throws Exception if an exception occurs while running the test
>> + Â Â */
>> + Â Â @Test
>> + Â Â public void testGetImageURLWhenAttachmentURLHasFragmentIdentifier() throws Exception
>> + Â Â {
>> + Â Â Â Â final DocumentAccessBridge documentAccessBridge = getComponentManager().lookup(DocumentAccessBridge.class);
>> + Â Â Â Â final RenderingConfiguration configuration = getComponentManager().lookup(RenderingConfiguration.class);
>> + Â Â Â Â getMockery().checking(new Expectations()
>> + Â Â Â Â {
>> + Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â oneOf(documentAccessBridge).getAttachmentURL("", "");
>> + Â Â Â Â Â Â Â Â will(returnValue("test#fragment"));
>> + Â Â Â Â Â Â Â Â oneOf(configuration).isIncludeImageDimensionsInImageURL();
>> + Â Â Â Â Â Â Â Â will(returnValue(true));
>> + Â Â Â Â Â Â }
>> + Â Â Â Â });
>> + Â Â Â Â Map<String, String> parameters = new HashMap<String, String>();
>> + Â Â Â Â parameters.put("width", "23");
>> + Â Â Â Â Assert.assertEquals("test?width=23#fragment", wikiModel.getImageURL("", "", parameters));
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * Tests that the proper image URL is generated when the attachment URL has a query string and a fragment
>> + Â Â * identifier.
>> + Â Â *
>> + Â Â * @throws Exception if an exception occurs while running the test
>> + Â Â */
>> + Â Â @Test
>> + Â Â public void testGetImageURLWhenAttachmentURLHasQueryStringAndFragmentIdentifier() throws Exception
>> + Â Â {
>> + Â Â Â Â final DocumentAccessBridge documentAccessBridge = getComponentManager().lookup(DocumentAccessBridge.class);
>> + Â Â Â Â final RenderingConfiguration configuration = getComponentManager().lookup(RenderingConfiguration.class);
>> + Â Â Â Â getMockery().checking(new Expectations()
>> + Â Â Â Â {
>> + Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â oneOf(documentAccessBridge).getAttachmentURL("", "");
>> + Â Â Â Â Â Â Â Â will(returnValue("test?param=value#fragment"));
>> + Â Â Â Â Â Â Â Â oneOf(configuration).isIncludeImageDimensionsInImageURL();
>> + Â Â Â Â Â Â Â Â will(returnValue(true));
>> + Â Â Â Â Â Â }
>> + Â Â Â Â });
>> + Â Â Â Â Map<String, String> parameters = new HashMap<String, String>();
>> + Â Â Â Â parameters.put("height", "17");
>> + Â Â Â Â Assert.assertEquals("test?param=value&height=17#fragment", wikiModel.getImageURL("", "", parameters));
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * Tests that the proper image URL is generated when both the style and the dimension parameters are specified.
>> + Â Â *
>> + Â Â * @throws Exception if an exception occurs while running the test
>> + Â Â */
>> + Â Â @Test
>> + Â Â public void testGetImageURLWhenBothStyleAndDimensionParametersAreSpecified() throws Exception
>> + Â Â {
>> + Â Â Â Â final DocumentAccessBridge documentAccessBridge = getComponentManager().lookup(DocumentAccessBridge.class);
>> + Â Â Â Â final RenderingConfiguration configuration = getComponentManager().lookup(RenderingConfiguration.class);
>> + Â Â Â Â getMockery().checking(new Expectations()
>> + Â Â Â Â {
>> + Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â oneOf(documentAccessBridge).getAttachmentURL("", "");
>> + Â Â Â Â Â Â Â Â will(returnValue(""));
>> + Â Â Â Â Â Â Â Â oneOf(configuration).isIncludeImageDimensionsInImageURL();
>> + Â Â Â Â Â Â Â Â will(returnValue(true));
>> + Â Â Â Â Â Â }
>> + Â Â Â Â });
>> + Â Â Â Â Map<String, String> parameters = new HashMap<String, String>();
>> + Â Â Â Â parameters.put("height", "46");
>> + Â Â Â Â parameters.put("width", "101px");
>> + Â Â Â Â parameters.put("style", "width: 20%; height:75px");
>> + Â Â Â Â // Note that the style parameter take precedence over the dimension parameters and the width is actually 20% but
>> + Â Â Â Â // we can't use it for resizing the image on the server side so it's omitted from the query string.
>> + Â Â Â Â Assert.assertEquals("?height=75", wikiModel.getImageURL("", "", parameters));
>> + Â Â }
>> }
>
> _______________________________________________
> devs mailing list
> devs(a)xwiki.org
> http://lists.xwiki.org/mailman/listinfo/devs
>
--
Thomas Mortagne
Hi All,
I am trying to convert JSPwiki pages to Xwiki pages.For that i used the code
which is in the link
http://code.xwiki.org/xwiki/bin/view/Extensions/JSPWikiToXWikiExtension .All
the needed jar files had been added to the classpath and try to build this
java class.Then it showed the following error
Starting up background thread: JSPWiki Lucene Indexer.
Starting up background thread: WatchDog for 'Wiki'.
com.ecyrd.jspwiki.InternalWikiException: java.io.IOException: Unable to find
web.xml for processing.
at
com.ecyrd.jspwiki.auth.authorize.WebContainerAuthorizer.initialize(WebContainerAuthorizer.java:127)
at
com.ecyrd.jspwiki.auth.AuthorizationManager.initialize(AuthorizationManager.java:404)
at com.ecyrd.jspwiki.WikiEngine.initialize(WikiEngine.java:559)
at com.ecyrd.jspwiki.WikiEngine.<init>(WikiEngine.java:369)
at JspWikiImporter.export(JspWikiImporter.java:76)
at JspWikiImporter.main(JspWikiImporter.java:50)
com.ecyrd.jspwiki.WikiException: Failed to start managers:
java.io.IOException: Unable to find web.xml for processing.
at com.ecyrd.jspwiki.WikiEngine.initialize(WikiEngine.java:610)
at com.ecyrd.jspwiki.WikiEngine.<init>(WikiEngine.java:369)
at JspWikiImporter.export(JspWikiImporter.java:76)
at JspWikiImporter.main(JspWikiImporter.java:50)
Caused by: com.ecyrd.jspwiki.InternalWikiException: java.io.IOException:
Unable to find web.xml for processing.
at
com.ecyrd.jspwiki.auth.authorize.WebContainerAuthorizer.initialize(WebContainerAuthorizer.java:127)
at
com.ecyrd.jspwiki.auth.AuthorizationManager.initialize(AuthorizationManager.java:404)
at com.ecyrd.jspwiki.WikiEngine.initialize(WikiEngine.java:559)
... 3 more
I added a dummy web.xml in WEB-INF directory.But the same issue occurs.What
is to be done to rectify this issue and what are the essential components
that are needed in the said web.xml? Please help me.
If anybody have any idea please let me know.
Thanks,
Jins Jacob
Hi, I would like to propose a change in direction.
I think the practice of marrying form fields to class properties
should be discontinued.
Including form information in the class property makes certain jobs
easier but XObjects do not always represent forms and marrying
something as high level as forms with something as low level as
objects makes code maintenance exceedingly difficult, not to mention
the general ugliness of code in xwiki-core which generates HTML.
I would like to start development of 3 new XWikiDocuments:
XWiki.FormClass,
XWiki.FormFieldClass and
XWiki.FormFieldConstraintClass.
Much of the code in XWiki.Registration will be ported to these
classes. The fields will be validated twice, once at the client side
with LiveValidation, and once at the server side.
I would then like to deprecate the use of the display related
settings in the class editor and eventually remove them from the
class editor entirely.
I envision a form being made and fields added similar to the way we
add objects to a document. Likewise, each field will be defined by
selecting a display type from a predefined list then adding
validation constraint objects to the field.
I have not started development on this and I am sure there will be
plenty more to discuss later. What I want to know is whether people
think this is the right direction.
WDYT?
Caleb
Hi All,
I am trying to convert JSPwiki pages to Xwiki pages.For that i used the code
which is in the link
http://code.xwiki.org/xwiki/bin/view/Extensions/JSPWikiToXWikiExtension.All
the needed jar files had been added to the classpath and try to build
this java class.Then it showed the following error
* *
* Starting up background thread: JSPWiki Lucene Indexer.
Starting up background thread: WatchDog for 'Wiki'.
com.ecyrd.jspwiki.InternalWikiException: java.io.IOException: Unable to find
web.xml for processing.
at
com.ecyrd.jspwiki.auth.authorize.WebContainerAuthorizer.initialize(WebContainerAuthorizer.java:127)
at
com.ecyrd.jspwiki.auth.AuthorizationManager.initialize(AuthorizationManager.java:404)
at com.ecyrd.jspwiki.WikiEngine.initialize(WikiEngine.java:559)
at com.ecyrd.jspwiki.WikiEngine.<init>(WikiEngine.java:369)
at JspWikiImporter.export(JspWikiImporter.java:76)
at JspWikiImporter.main(JspWikiImporter.java:50)
com.ecyrd.jspwiki.WikiException: Failed to start managers:
java.io.IOException: Unable to find web.xml for processing.
at com.ecyrd.jspwiki.WikiEngine.initialize(WikiEngine.java:610)
at com.ecyrd.jspwiki.WikiEngine.<init>(WikiEngine.java:369)
at JspWikiImporter.export(JspWikiImporter.java:76)
at JspWikiImporter.main(JspWikiImporter.java:50)
Caused by: com.ecyrd.jspwiki.InternalWikiException: java.io.IOException:
Unable to find web.xml for processing.
at
com.ecyrd.jspwiki.auth.authorize.WebContainerAuthorizer.initialize(WebContainerAuthorizer.java:127)
at
com.ecyrd.jspwiki.auth.AuthorizationManager.initialize(AuthorizationManager.java:404)
at com.ecyrd.jspwiki.WikiEngine.initialize(WikiEngine.java:559)
... 3 more*
**
I added a dummy web.xml in WEB-INF directory.But the same issue occurs.What
is to be done to rectify this issue and what are the essential components
that are needed in the said web.xml? Please help me.
Thanks,
Jins Jacob
----- "Fabio Mancinelli" <fabio.mancinelli(a)xwiki.com> wrote:
> On 08/30/2010 05:46 PM, Ecaterina Valica wrote:
> > Hi Fabio,
> >
> > This means I am iterating and I gather feedback and depending on
> that
> > feedback we must agree on a version.
> >
> Ok. I thought that "old" meant "superseded by" :)
>
> > On a wiki platform, what do you think is more relevant: the user or
> page
> > centric approach?
> > What are the things that make this version (the page centric one)
> not to fit
> > the Wiki 3.0 specification?
> >
> What is missing basically boils down to the "Share your thoughts" box
Yes, user updates should be mixed in the stream ultimately, I think.
>
> and the type of information we can convey with it.
>
> The "user centric" view, imho, is also useful because a "user" could
> also be an application that sends events (e.g., meeting or deadlines
> reminders, etc.) that can be shown in a more natural way in a user
> centric view. Basically even applications might share their thoughts
> through the activity stream ;)
I completely agree with the last sentence. BUT I think it's not incompatible with a document/user mixed-approched (I don't think either full document-centric or full user-centric can embrace the versatility of XWiki)
I see two types of entries :
* Document updates. Basically what is currently in latest proposal (though I would add little user pictures here as well, even before the click). This is KM, collaboration, etc.
* Users/applications updates. Those are less structured, more a-la facebook.
I see something like http://incubator.myxwiki.org/xwiki/bin/view/Improvements/ActivityStreamMixed (raw picture, would have to be refined)
(Note I also have right-padded a bit more the comment/annotation/pencil/etc icons that are on top of user photos, I think they were a bit too masked by them)
Jerome.
>
> > Jerome missed the avatars, so if you did too, please try to expand
> the items
> > in the prototype (when you hover the items an arrow appears in the
> right
> > part suggesting that the item can be expanded ).
> >
> Yes I missed them too, but then I saw it.
> Still the previously mentioned types of information are not available
>
> anymore.
>
> Thanks,
> Fabio
> _______________________________________________
> devs mailing list
> devs(a)xwiki.org
> http://lists.xwiki.org/mailman/listinfo/devs