Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Openfire
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Openfire
Commits
f7010088
Commit
f7010088
authored
Jun 21, 2017
by
Guus der Kinderen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding custom JSTL functions.
parent
93f81848
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
105 additions
and
1 deletion
+105
-1
JSTLFunctions.java
src/java/org/jivesoftware/admin/JSTLFunctions.java
+68
-0
admin.tld
webadmintld/src/main/resources/META-INF/admin.tld
+37
-1
No files found.
src/java/org/jivesoftware/admin/JSTLFunctions.java
View file @
f7010088
package
org
.
jivesoftware
.
admin
;
import
org.jivesoftware.util.ByteFormat
;
import
org.jivesoftware.util.StringUtils
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLDecoder
;
import
java.net.URLEncoder
;
/**
* Utility functions that are exposed through a taglib.
*
...
...
@@ -28,4 +35,65 @@ public class JSTLFunctions
{
return
string
.
split
(
regex
);
}
/**
* A formatter for formatting byte sizes. For example, formatting 12345 byes results in
* "12.1 K" and 1234567 results in "1.18 MB".
*
* @see ByteFormat
*/
public
static
String
byteFormat
(
long
bytes
)
{
return
new
ByteFormat
().
format
(
bytes
);
}
/**
* Translates a string into {@code application/x-www-form-urlencoded} format using a specific encoding scheme. This
* method uses the UTF-8 encoding scheme to obtain the bytes for unsafe characters.
*
* @see URLEncoder
*/
public
static
String
urlEncode
(
String
string
)
{
try
{
return
URLEncoder
.
encode
(
string
,
"UTF-8"
);
}
catch
(
UnsupportedEncodingException
e
)
{
// Should never occur, as UTF-8 encoding is mantdatory to implement for any JRE.
throw
new
IllegalStateException
(
"Unable to URL-encode string: "
+
string
,
e
);
}
}
/**
* Decodes a {@code application/x-www-form-urlencoded} string using the UTF-8 encoding scheme. The encoding is used
* to determine what characters are represented by any consecutive sequences of the form "<i>{@code %xy}</i>".
*
* @see URLDecoder
*/
public
static
String
urlDecode
(
String
string
)
{
try
{
return
URLDecoder
.
decode
(
string
,
"UTF-8"
);
}
catch
(
UnsupportedEncodingException
e
)
{
// Should never occur, as UTF-8 encoding is mantdatory to implement for any JRE.
throw
new
IllegalStateException
(
"Unable to URL-decode string: "
+
string
,
e
);
}
}
/**
* This method takes a string which may contain HTML tags (ie, <7;b>,
* <table>, etc) and converts the '<' and '>' characters to
* their HTML escape sequences. It will also replace LF with <br>.
*
* @see StringUtils#escapeHTMLTags(String);
*/
public
static
String
escapeHTMLTags
(
String
string
)
{
return
StringUtils
.
escapeHTMLTags
(
string
);
}
}
webadmintld/src/main/resources/META-INF/admin.tld
View file @
f7010088
...
...
@@ -4,7 +4,7 @@
xsi:schemaLocation=
"http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
version=
"2.1"
>
<tlib-version>
1.
2
</tlib-version>
<tlib-version>
1.
3
</tlib-version>
<short-name>
Tag Library for Openfire
</short-name>
<description>
Tab Library for Openfire Admin Console
</description>
<short-name>
admin
</short-name>
...
...
@@ -151,6 +151,26 @@
<function-class>
org.jivesoftware.admin.JSTLFunctions
</function-class>
<function-signature>
java.lang.String[] split(java.lang.String, java.lang.String)
</function-signature>
</function>
<function>
<name>
byteFormat
</name>
<function-class>
org.jivesoftware.admin.JSTLFunctions
</function-class>
<function-signature>
java.lang.String byteFormat(long)
</function-signature>
</function>
<function>
<name>
urlEncode
</name>
<function-class>
org.jivesoftware.admin.JSTLFunctions
</function-class>
<function-signature>
java.lang.String urlEncode(java.lang.String)
</function-signature>
</function>
<function>
<name>
urlDecode
</name>
<function-class>
org.jivesoftware.admin.JSTLFunctions
</function-class>
<function-signature>
java.lang.String urlDecode(java.lang.String)
</function-signature>
</function>
<function>
<name>
escapeHTMLTags
</name>
<function-class>
org.jivesoftware.admin.JSTLFunctions
</function-class>
<function-signature>
java.lang.String escapeHTMLTags(java.lang.String)
</function-signature>
</function>
<function>
<name>
serverIdentities
</name>
<function-class>
org.jivesoftware.util.CertificateManager
</function-class>
...
...
@@ -186,4 +206,20 @@
<function-class>
org.jivesoftware.util.JiveGlobals
</function-class>
<function-signature>
java.util.List getListProperty(java.lang.String,java.util.List)
</function-signature>
</function>
<function>
<name>
formatDate
</name>
<function-class>
org.jivesoftware.util.JiveGlobals
</function-class>
<function-signature>
java.lang.String formatDate(java.util.Date)
</function-signature>
</function>
<function>
<name>
formatDateTime
</name>
<function-class>
org.jivesoftware.util.JiveGlobals
</function-class>
<function-signature>
java.lang.String formatDateTime(java.util.Date)
</function-signature>
</function>
<function>
<name>
formatTime
</name>
<function-class>
org.jivesoftware.util.JiveGlobals
</function-class>
<function-signature>
java.lang.String formatTime(java.util.Date)
</function-signature>
</function>
</taglib>
Write
Preview
Markdown
is supported
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