Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
XWiki
xwiki-rendering
Commits
22eac2b1
Commit
22eac2b1
authored
Mar 28, 2022
by
Thomas Mortagne
Browse files
XRENDERING-654: Add rendering entry points for the PAGE_ATTACHMENT entity type
parent
2ccc5406
Changes
11
Hide whitespace changes
Inline
Side-by-side
xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/reference/DefaultResourceReferenceParser.java
View file @
22eac2b1
...
...
@@ -64,6 +64,7 @@ public class DefaultResourceReferenceParser extends AbstractResourceReferencePar
ResourceType
.
SPACE
,
ResourceType
.
PAGE
,
ResourceType
.
ATTACHMENT
,
ResourceType
.
PAGE_ATTACHMENT
,
ResourceType
.
ICON
);
// @formatter:on
...
...
xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/reference/type/PageAttachmentResourceReferenceTypeParser.java
0 → 100644
View file @
22eac2b1
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package
org.xwiki.rendering.internal.parser.reference.type
;
import
javax.inject.Named
;
import
javax.inject.Singleton
;
import
org.xwiki.component.annotation.Component
;
import
org.xwiki.rendering.listener.reference.ResourceType
;
/**
* Parses a resource reference to an attachment.
*
* @version $Id$
* @since 13.10.5
* @since 14.3RC1
*/
@Component
@Named
(
"pageAttach"
)
@Singleton
public
class
PageAttachmentResourceReferenceTypeParser
extends
AbstractURIResourceReferenceTypeParser
{
@Override
public
ResourceType
getType
()
{
return
ResourceType
.
PAGE_ATTACHMENT
;
}
}
xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/renderer/DefaultPageAttachmentURILabelGenerator.java
0 → 100644
View file @
22eac2b1
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package
org.xwiki.rendering.internal.renderer
;
import
javax.inject.Named
;
import
javax.inject.Singleton
;
import
org.xwiki.component.annotation.Component
;
import
org.xwiki.rendering.listener.reference.ResourceReference
;
import
org.xwiki.rendering.renderer.reference.link.URILabelGenerator
;
/**
* Generate link labels for ATTACH URIs.
*
* @version $Id$
* @since 13.10.5
* @since 14.3RC1
*/
@Component
@Named
(
"pageAttach"
)
@Singleton
public
class
DefaultPageAttachmentURILabelGenerator
implements
URILabelGenerator
{
@Override
public
String
generateLabel
(
ResourceReference
reference
)
{
return
reference
.
getReference
();
}
}
xwiki-rendering-api/src/main/java/org/xwiki/rendering/listener/reference/PageAttachmentResourceReference.java
0 → 100644
View file @
22eac2b1
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package
org.xwiki.rendering.listener.reference
;
import
org.apache.commons.lang3.StringUtils
;
/**
* Represents a reference to an Attachment of a Page.
*
* @version $Id$
* @since 13.10.5
* @since 14.3RC1
*/
public
class
PageAttachmentResourceReference
extends
ResourceReference
{
/**
* The name of the parameter representing the Query String.
*/
public
static
final
String
QUERY_STRING
=
"queryString"
;
/**
* The name of the parameter representing the Anchor.
*/
public
static
final
String
ANCHOR
=
"anchor"
;
/**
* @param reference see {@link #getReference()}
*/
public
PageAttachmentResourceReference
(
String
reference
)
{
super
(
reference
,
ResourceType
.
PAGE_ATTACHMENT
);
}
/**
* @return the query string for specifying parameters that will be used in the rendered URL or null if no query
* string has been specified. Example: {@code mydata1=5&mydata2=Hello}
*/
public
String
getQueryString
()
{
return
getParameter
(
QUERY_STRING
);
}
/**
* @param queryString see {@link #getQueryString()}
*/
public
void
setQueryString
(
String
queryString
)
{
if
(!
StringUtils
.
isEmpty
(
queryString
))
{
setParameter
(
QUERY_STRING
,
queryString
);
}
}
/**
* @return the anchor name pointing to an anchor defined in the referenced attachment or null if no anchor has been
* specified (in which case the reference points to the top of the attachment).
*/
public
String
getAnchor
()
{
return
getParameter
(
ANCHOR
);
}
/**
* @param anchor see {@link #getAnchor()}
*/
public
void
setAnchor
(
String
anchor
)
{
if
(!
StringUtils
.
isEmpty
(
anchor
))
{
setParameter
(
ANCHOR
,
anchor
);
}
}
}
xwiki-rendering-api/src/main/java/org/xwiki/rendering/listener/reference/ResourceType.java
View file @
22eac2b1
...
...
@@ -82,10 +82,18 @@
public
static
final
ResourceType
MAILTO
=
new
ResourceType
(
"mailto"
);
/**
* Represents an attachment.
* Represents an attachment
of a document
.
*/
public
static
final
ResourceType
ATTACHMENT
=
new
ResourceType
(
"attach"
);
/**
* Represents an attachment of a page.
*
* @since 13.10.5
* @since 14.3RC1
*/
public
static
final
ResourceType
PAGE_ATTACHMENT
=
new
ResourceType
(
"pageAttach"
);
/**
* Represents an icon.
*/
...
...
xwiki-rendering-api/src/main/resources/META-INF/components.txt
View file @
22eac2b1
...
...
@@ -17,6 +17,7 @@ org.xwiki.rendering.internal.parser.reference.type.DocumentResourceReferenceType
org.xwiki.rendering.internal.parser.reference.type.IconResourceReferenceTypeParser
org.xwiki.rendering.internal.parser.reference.type.InterWikiResourceReferenceTypeParser
org.xwiki.rendering.internal.parser.reference.type.MailtoResourceReferenceTypeParser
org.xwiki.rendering.internal.parser.reference.type.PageAttachmentResourceReferenceTypeParser
org.xwiki.rendering.internal.parser.reference.type.PageResourceReferenceTypeParser
org.xwiki.rendering.internal.parser.reference.type.PathResourceReferenceTypeParser
org.xwiki.rendering.internal.parser.reference.type.SpaceResourceReferenceTypeParser
...
...
@@ -26,6 +27,7 @@ org.xwiki.rendering.internal.renderer.DefaultLinkLabelGenerator
org.xwiki.rendering.internal.renderer.DefaultAttachmentURILabelGenerator
org.xwiki.rendering.internal.renderer.MailtoURILabelGenerator
org.xwiki.rendering.internal.renderer.DataURILabelGenerator
org.xwiki.rendering.internal.renderer.DefaultPageAttachmentURILabelGenerator
org.xwiki.rendering.internal.renderer.reference.DefaultResourceReferenceTypeSerializer
org.xwiki.rendering.internal.syntax.SyntaxConverter
org.xwiki.rendering.internal.syntax.DefaultSyntaxRegistry
...
...
xwiki-rendering-syntaxes/xwiki-rendering-syntax-xhtml/src/main/java/org/xwiki/rendering/internal/renderer/xhtml/image/PageAttachmentXHTMLImageTypeRenderer.java
0 → 100644
View file @
22eac2b1
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package
org.xwiki.rendering.internal.renderer.xhtml.image
;
import
javax.inject.Named
;
import
org.xwiki.component.annotation.Component
;
import
org.xwiki.component.annotation.InstantiationStrategy
;
import
org.xwiki.component.descriptor.ComponentInstantiationStrategy
;
/**
* Handle XHTML rendering for images located in page attachments.
*
* @version $Id$
* @since 13.10.5
* @since 14.3RC1
*/
@Component
@Named
(
"pageAttach"
)
@InstantiationStrategy
(
ComponentInstantiationStrategy
.
PER_LOOKUP
)
public
class
PageAttachmentXHTMLImageTypeRenderer
extends
AttachmentXHTMLImageTypeRenderer
{
}
xwiki-rendering-syntaxes/xwiki-rendering-syntax-xhtml/src/main/java/org/xwiki/rendering/internal/renderer/xhtml/link/PageAttachmentXHTMLLinkTypeRenderer.java
0 → 100644
View file @
22eac2b1
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package
org.xwiki.rendering.internal.renderer.xhtml.link
;
import
javax.inject.Named
;
import
org.xwiki.component.annotation.Component
;
import
org.xwiki.component.annotation.InstantiationStrategy
;
import
org.xwiki.component.descriptor.ComponentInstantiationStrategy
;
/**
* Handle XHTML rendering for links to attachments.
*
* @version $Id$
* @since 13.10.5
* @since 14.3RC1
*/
@Component
@Named
(
"pageAttach"
)
@InstantiationStrategy
(
ComponentInstantiationStrategy
.
PER_LOOKUP
)
public
class
PageAttachmentXHTMLLinkTypeRenderer
extends
AttachmentXHTMLLinkTypeRenderer
{
}
xwiki-rendering-syntaxes/xwiki-rendering-syntax-xhtml/src/main/resources/META-INF/components.txt
View file @
22eac2b1
...
...
@@ -10,12 +10,14 @@ org.xwiki.rendering.internal.renderer.xhtml.image.DefaultXHTMLImageTypeRenderer
org.xwiki.rendering.internal.renderer.xhtml.image.AttachmentXHTMLImageTypeRenderer
org.xwiki.rendering.internal.renderer.xhtml.image.IconXHTMLImageTypeRenderer
org.xwiki.rendering.internal.renderer.xhtml.image.DataURIXHTMLImageTypeRenderer
org.xwiki.rendering.internal.renderer.xhtml.image.PageAttachmentXHTMLImageTypeRenderer
org.xwiki.rendering.internal.renderer.xhtml.link.AttachmentXHTMLLinkTypeRenderer
org.xwiki.rendering.internal.renderer.xhtml.link.DefaultXHTMLLinkRenderer
org.xwiki.rendering.internal.renderer.xhtml.link.DefaultXHTMLLinkTypeRenderer
org.xwiki.rendering.internal.renderer.xhtml.link.DocumentXHTMLLinkTypeRenderer
org.xwiki.rendering.internal.renderer.xhtml.link.InterWikiXHTMLLinkTypeRenderer
org.xwiki.rendering.internal.renderer.xhtml.link.MailtoXHTMLLinkTypeRenderer
org.xwiki.rendering.internal.renderer.xhtml.link.PageAttachmentXHTMLLinkTypeRenderer
org.xwiki.rendering.internal.renderer.xhtml.link.PathXHTMLLinkTypeRenderer
org.xwiki.rendering.internal.renderer.xhtml.link.SpaceXHTMLLinkTypeRenderer
org.xwiki.rendering.internal.renderer.xhtml.link.UNCXHTMLLinkTypeRenderer
...
...
xwiki-rendering-syntaxes/xwiki-rendering-syntax-xwiki21/src/main/java/org/xwiki/rendering/internal/parser/xwiki21/XWiki21XWikiGeneratorListener.java
View file @
22eac2b1
...
...
@@ -86,7 +86,7 @@ protected void onReference(ResourceReference reference, String label, boolean fr
if
(
anchor
!=
null
)
{
reference
.
setParameter
(
DocumentResourceReference
.
ANCHOR
,
anchor
);
}
}
else
if
(
ResourceType
.
ATTACHMENT
.
equals
(
resourceType
))
{
}
else
if
(
ResourceType
.
ATTACHMENT
.
equals
(
resourceType
)
||
ResourceType
.
PAGE_ATTACHMENT
.
equals
(
resourceType
)
)
{
String
queryString
=
parameters
.
remove
(
QUERY_STRING
);
if
(
queryString
!=
null
)
{
reference
.
setParameter
(
AttachmentResourceReference
.
QUERY_STRING
,
queryString
);
...
...
@@ -100,7 +100,8 @@ protected void onReference(ResourceReference reference, String label, boolean fr
protected
void
onImage
(
ResourceReference
reference
,
boolean
freestanding
,
Map
<
String
,
String
>
parameters
)
{
// Since 2.5M2, handle the special case when the image syntax used for an image has a query string specified.
if
(
ResourceType
.
ATTACHMENT
.
equals
(
reference
.
getType
()))
{
if
(
ResourceType
.
ATTACHMENT
.
equals
(
reference
.
getType
())
||
ResourceType
.
PAGE_ATTACHMENT
.
equals
(
reference
.
getType
()))
{
String
queryString
=
parameters
.
remove
(
QUERY_STRING
);
if
(
queryString
!=
null
)
{
reference
.
setParameter
(
DocumentResourceReference
.
QUERY_STRING
,
queryString
);
...
...
xwiki-rendering-syntaxes/xwiki-rendering-syntax-xwiki21/src/main/java/org/xwiki/rendering/internal/renderer/xwiki21/reference/XWikiSyntaxResourceRenderer.java
View file @
22eac2b1
...
...
@@ -66,6 +66,11 @@ private boolean isDocument(ResourceType resourceType)
||
ResourceType
.
PAGE
.
equals
(
resourceType
);
}
private
boolean
isAttachment
(
ResourceType
resourceType
)
{
return
ResourceType
.
ATTACHMENT
.
equals
(
resourceType
)
||
ResourceType
.
PAGE_ATTACHMENT
.
equals
(
resourceType
);
}
@Override
protected
void
printParameters
(
XWikiSyntaxEscapeWikiPrinter
printer
,
ResourceReference
reference
,
Map
<
String
,
String
>
parameters
)
...
...
@@ -97,7 +102,7 @@ protected void printParameters(XWikiSyntaxEscapeWikiPrinter printer, ResourceRef
printer
.
print
(
this
.
PARAMETERS_PRINTER
.
print
(
ANCHOR
,
anchor
,
'~'
));
shouldPrintSeparator
=
false
;
}
}
else
if
(
ResourceType
.
ATTACHMENT
.
equals
(
resourceType
))
{
}
else
if
(
isAttachment
(
resourceType
))
{
String
queryString
=
reference
.
getParameter
(
AttachmentResourceReference
.
QUERY_STRING
);
if
(!
StringUtils
.
isEmpty
(
queryString
))
{
printer
.
print
(
PARAMETER_SEPARATOR
);
...
...
Git Mirror User
@gitmirror
mentioned in commit
d6d2623b
·
Apr 01, 2022
mentioned in commit
d6d2623b
mentioned in commit d6d2623b77c378a3975380070dd337196d09d12b
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment