You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by br...@apache.org on 2019/07/16 19:25:58 UTC
[jspwiki] branch master updated: 2.11.0-M5-git-07 [JSPWIKI-1097],
Trim spaces from the rendered html.
This is an automated email from the ASF dual-hosted git repository.
brushed pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git
The following commit(s) were added to refs/heads/master by this push:
new f22b29c 2.11.0-M5-git-07 [JSPWIKI-1097], Trim spaces from the rendered html.
new b3fb157 Merge branch 'master' of https://github.com/apache/jspwiki
f22b29c is described below
commit f22b29c14309a4ed1645e9f65bd20473904af001
Author: brushed <di...@gmail.com>
AuthorDate: Tue Jul 16 21:25:41 2019 +0200
2.11.0-M5-git-07 [JSPWIKI-1097], Trim spaces from the rendered html.
---
ChangeLog | 9 ++
.../src/main/java/org/apache/wiki/Release.java | 2 +-
jspwiki-war/src/main/scripts/behaviors/Columns.js | 21 ++--
.../src/main/scripts/behaviors/TableX.Filter.js | 3 +-
.../src/main/scripts/lib/mootools-more-1.6.0.js | 111 +++++++++++++++++++++
.../src/main/scripts/util/extend-element.js | 4 +-
.../scripts/util/{hash.js => extend-function.js} | 30 ++----
jspwiki-war/src/main/scripts/util/extend-string.js | 45 +++++----
jspwiki-war/src/main/scripts/util/hash.js | 2 +-
.../main/styles/haddock/default/Collapsible.less | 1 +
.../src/main/styles/haddock/default/type.less | 2 +-
jspwiki-war/src/main/webapp/WEB-INF/web.xml | 11 ++
.../src/main/webapp/templates/default/Nav.jsp | 4 +
13 files changed, 184 insertions(+), 61 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 87e675f..a7aa495 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2019-16-07 Dirk Frederickx (brushed AT apache DOT org)
+
+ * 2.11.0-M5-git-07
+
+ * [JSPWIKI-1097] Various smaller JS refactorings, and bugfixes.
+
+ * Trim spaces from the rendered html to reduce page weight.
+
+
2019-09-07 Dirk Frederickx (brushed AT apache DOT org)
* 2.11.0-M5-git-06
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/Release.java b/jspwiki-main/src/main/java/org/apache/wiki/Release.java
index 85b658d..949db24 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/Release.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/Release.java
@@ -72,7 +72,7 @@ public final class Release {
* <p>
* If the build identifier is empty, it is not added.
*/
- public static final String BUILD = "06";
+ public static final String BUILD = "07";
/**
* This is the generic version string you should use when printing out the version. It is of
diff --git a/jspwiki-war/src/main/scripts/behaviors/Columns.js b/jspwiki-war/src/main/scripts/behaviors/Columns.js
index c51231b..3f6e8cf 100644
--- a/jspwiki-war/src/main/scripts/behaviors/Columns.js
+++ b/jspwiki-war/src/main/scripts/behaviors/Columns.js
@@ -43,22 +43,17 @@ DOM Structure
div.col[styles={width:xx%}]
(end)
*/
-function Columns(element, options){
+function Columns(element, options) {
- var divider = "hr",
- columnCount = element.getChildren(divider).length,
- width;
+ var columnCount = element.getElements(">hr").length + 1,
+ width = 100 / columnCount + "%";
- columnCount++;
+ //add one extra group-start-element at the top
+ element.insertBefore("hr".slick(), element.firstChild)
- width = 100 / columnCount + "%";
+ $.wrapChildren(element, "hr", "div.col", function (column) {
- element
- .grab(divider.slick(), "top") //add one extra group-start-element at the top
-
- .groupChildren(divider, "div.col", function(column){
- column.setStyle("width", width);
-
- });
+ column.setStyle("width", width);
+ });
}
diff --git a/jspwiki-war/src/main/scripts/behaviors/TableX.Filter.js b/jspwiki-war/src/main/scripts/behaviors/TableX.Filter.js
index b5fa5f9..6d1b658 100644
--- a/jspwiki-war/src/main/scripts/behaviors/TableX.Filter.js
+++ b/jspwiki-war/src/main/scripts/behaviors/TableX.Filter.js
@@ -70,6 +70,7 @@ TableX.Filter = new Class({
["div.form-inline.form-group.cage.filter-input", [
"input.form-control[type=search][placeholder=\"" + options.hint + "\"]", {
attach: [ self, "input" ],
+ "aria-label": "tablefilter".localize(),
events: {
keyup: filter, //"keyup:throttle": filter,
click: filter
@@ -103,7 +104,7 @@ TableX.Filter = new Class({
try {
queryRE = RegExp( query, "i"); //support regexp in filter
- //queryRE = RegExp( query.escapeRegExp(), "i");
+ //queryRE = RegExp( $.escapeRegExp(query), "i");
}
catch(e){}
diff --git a/jspwiki-war/src/main/scripts/lib/mootools-more-1.6.0.js b/jspwiki-war/src/main/scripts/lib/mootools-more-1.6.0.js
index 8341800..1f44ba5 100644
--- a/jspwiki-war/src/main/scripts/lib/mootools-more-1.6.0.js
+++ b/jspwiki-war/src/main/scripts/lib/mootools-more-1.6.0.js
@@ -933,3 +933,114 @@ Fx.Accordion = new Class({
});
+/*
+---
+
+name: Swiff
+
+description: Wrapper for embedding SWF movies. Supports External Interface Communication.
+
+license: MIT-style license.
+
+credits:
+ - Flash detection & Internet Explorer + Flash Player 9 fix inspired by SWFObject.
+
+requires: [Core/Options, Core/Object, Core/Element]
+
+provides: Swiff
+
+...
+*/
+
+(function(){
+
+var Swiff = this.Swiff = new Class({
+
+ Implements: Options,
+
+ options: {
+ id: null,
+ height: 1,
+ width: 1,
+ container: null,
+ properties: {},
+ params: {
+ quality: 'high',
+ allowScriptAccess: 'always',
+ wMode: 'window',
+ swLiveConnect: true
+ },
+ callBacks: {},
+ vars: {}
+ },
+
+ toElement: function(){
+ return this.object;
+ },
+
+ initialize: function(path, options){
+ this.instance = 'Swiff_' + String.uniqueID();
+
+ this.setOptions(options);
+ options = this.options;
+ var id = this.id = options.id || this.instance;
+ var container = document.id(options.container);
+
+ Swiff.CallBacks[this.instance] = {};
+
+ var params = options.params, vars = options.vars, callBacks = options.callBacks;
+ var properties = Object.append({height: options.height, width: options.width}, options.properties);
+
+ var self = this;
+
+ for (var callBack in callBacks){
+ Swiff.CallBacks[this.instance][callBack] = (function(option){
+ return function(){
+ return option.apply(self.object, arguments);
+ };
+ })(callBacks[callBack]);
+ vars[callBack] = 'Swiff.CallBacks.' + this.instance + '.' + callBack;
+ }
+
+ params.flashVars = Object.toQueryString(vars);
+ if ('ActiveXObject' in window){
+ properties.classid = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
+ params.movie = path;
+ } else {
+ properties.type = 'application/x-shockwave-flash';
+ }
+ properties.data = path;
+
+ var build = '<object id="' + id + '"';
+ for (var property in properties) build += ' ' + property + '="' + properties[property] + '"';
+ build += '>';
+ for (var param in params){
+ if (params[param]) build += '<param name="' + param + '" value="' + params[param] + '" />';
+ }
+ build += '</object>';
+ this.object = ((container) ? container.empty() : new Element('div')).set('html', build).firstChild;
+ },
+
+ replaces: function(element){
+ element = document.id(element, true);
+ element.parentNode.replaceChild(this.toElement(), element);
+ return this;
+ },
+
+ inject: function(element){
+ document.id(element, true).appendChild(this.toElement());
+ return this;
+ },
+
+ remote: function(){
+ return Swiff.remote.apply(Swiff, [this.toElement()].append(arguments));
+ }
+
+});
+
+Swiff.CallBacks = {};
+
+Swiff.remote = function(obj, fn){
+ var rs = obj.CallFunction('<invoke name="' + fn + '" returntype="javascript">' + __flash__argumentsToXML(arguments, 2) + '</invoke>');
+ return eval(rs);
+};
diff --git a/jspwiki-war/src/main/scripts/util/extend-element.js b/jspwiki-war/src/main/scripts/util/extend-element.js
index 2454f1a..3dd79b2 100644
--- a/jspwiki-war/src/main/scripts/util/extend-element.js
+++ b/jspwiki-war/src/main/scripts/util/extend-element.js
@@ -23,7 +23,7 @@
// ELEMENT
// convienience dom manipulation functions
-// FFS: monkey-patch on Element.prototype; or global $ namespace
+// FFS: patch on Element.prototype; or global $ namespace
$.replaces = function (newElement, existingElement) {
@@ -120,7 +120,7 @@ Arguments
DOM Structure:
(start code)
- // before
+ // before
a
delimitter1
b
diff --git a/jspwiki-war/src/main/scripts/util/hash.js b/jspwiki-war/src/main/scripts/util/extend-function.js
similarity index 63%
copy from jspwiki-war/src/main/scripts/util/hash.js
copy to jspwiki-war/src/main/scripts/util/extend-function.js
index 9aa5a24..b87940b 100644
--- a/jspwiki-war/src/main/scripts/util/hash.js
+++ b/jspwiki-war/src/main/scripts/util/extend-function.js
@@ -21,29 +21,13 @@
/*eslint-env browser */
/*global $ */
-/*
-Function: setHash
- Set URL #HASH without page jump
+// FUNCTION
-Example:
-> "here is a new hash".setHash();
+/*
+$.toFunction
+ Converts the passed argument into an executable function.
+ If the passed argument is a function, it will return that function itself.
+ Otherwise, it will return a function that returns the passed argument.
*/
-$.setHash = function(newHash) {
-
- if (history.pushState) {
-
- //history.pushState( state-object, title-ffs, "#" + hash );
- history.pushState(null, "", "#" + newHash);
-
- } else {
-
- var el = $(newHash), //fixme $("#"+newHash)
- id = el && el.id;
-
- el && el.removeAttribute(id); //prevent page jump
-
- location.hash = "#" + newHash;
+$.toFunction = function(o){ return o instanceof Function ? o : function(){ return o; }; }
- el && el.setAttribute("id", id);
- }
-}
diff --git a/jspwiki-war/src/main/scripts/util/extend-string.js b/jspwiki-war/src/main/scripts/util/extend-string.js
index 6a4306a..5d1a3e3 100644
--- a/jspwiki-war/src/main/scripts/util/extend-string.js
+++ b/jspwiki-war/src/main/scripts/util/extend-string.js
@@ -21,45 +21,52 @@
/*eslint-env browser */
/*global $ */
+/*
+Function: escapeHml()
-/*
-$.extend(String.prototype, {..
- escapeHtml: function(s){
-
- },
-});
+Example:
+> "ab<span>cd".escapeHtml() => "ab<span>cd"
*/
-
-// STRING
String.prototype.escapeHtml = function (s) {
return this.replace(/[<>'"&]/g, function (s) {
return '&#' + s.charCodeAt(0) + ';';
});
}
+/*
+Function: escapeRegExp()
+
+Example:
+> "animals.sheep[1]"".escapeRegExp() => "animals\.sheep\[1\]"
+*/
String.prototype.escapeRegExp = function () {
// Credit: XRegExp 0.6.1 (c) 2007-2008 Steven Levithan <http://stevenlevithan.com/regex/xregexp/> MIT License
return this.replace(/[-[\]{}()*+?.\\^$|,#\s]/g, '\\$&');
}
/*
-Function: xsubs (extended Substitute)
- Equal to substitute(), but also supports anonymous arguments.
+Function: xsubs (object || arguments)
+ Substitutes {keywords} in a string using an object or indexed arguments.
+ Removes undefined keywords and ignores escaped keywords.
+
+Example:
+> //Object with key - value pairs: named {keywords}
+> "Hello {text}".xsubs({text:"world"}) ==> "Hello world"
+> "Hello escaped \\{text}".xsubs({text:"world"}) ==> "Hello escaped {text}"
-Named arguments:
-> "Hello {text}".xsubs({text:"world"}) ==> "Hello world"
-Anonymous arguments:
-> "Hello {0}{1}".xsubs("world", "!") === "Hello world!"
+> //List of anonymous arguments: indexed keywords starting from 0 {0}, {1} ...
+> "Hello {0}{1}".xsubs("world", "!") === "Hello world!"
+> "Hello {0}{1}".xsubs(["world", "!"]) === "Hello world!"
*/
String.prototype.xsubs = function (object, regexp) {
if (typeOf(object) != "object") {
- object = Array.from(arguments);
+ object = Array.prototype.slice.call(arguments);
regexp = null;
}
- return String(this).replace(regexp || (/\\?\{([^{}]+)\}/g), function (match, name) {
+ return this.replace(regexp || (/\\?\{([^{}]+)\}/g), function (match, name) {
if (match.charAt(0) == '\\') return match.slice(1);
@@ -114,7 +121,7 @@ Examples:
"javascript.moreInfo": "More",
"javascript.imageInfo": "Image {0} of {1}", //indexed parms
"javascript.imageInfo2": "Image {imgCount} of {totalCount}" //named parms
- "javascript.curlyBraces": "Show \{Curly Braces}", //escaped curly braces
+ "javascript.curlyBraces": "Show \\{Curly Braces}", //escaped curly braces
}
String.I18N.PREFIX="javascript.";
@@ -129,9 +136,9 @@ String.prototype.localize = function( params ){
var I18N = String.I18N;
- return ( I18N[I18N.PREFIX + this] || this ).substitute(
+ return ( I18N[I18N.PREFIX + this] || this ).xsubs(
- ( typeOf(params) == "object" ) ? params : Array.from(arguments)
+ ( typeOf(params) == "object" ) ? params : Array.prototype.slice.call(arguments)
);
}
diff --git a/jspwiki-war/src/main/scripts/util/hash.js b/jspwiki-war/src/main/scripts/util/hash.js
index 9aa5a24..1724aa4 100644
--- a/jspwiki-war/src/main/scripts/util/hash.js
+++ b/jspwiki-war/src/main/scripts/util/hash.js
@@ -23,7 +23,7 @@
/*
Function: setHash
- Set URL #HASH without page jump
+ Set URL #HASH without page jump; fallback if pushState not supported
Example:
> "here is a new hash".setHash();
diff --git a/jspwiki-war/src/main/styles/haddock/default/Collapsible.less b/jspwiki-war/src/main/styles/haddock/default/Collapsible.less
index ad92923..ec0496a 100644
--- a/jspwiki-war/src/main/styles/haddock/default/Collapsible.less
+++ b/jspwiki-war/src/main/styles/haddock/default/Collapsible.less
@@ -63,6 +63,7 @@ Collapsible toggle button, and body scroll animation
transform: rotate(45deg) translate(@collapse-btn-base/4);
}
+ &[disabled]::before,
&[aria-expanded="false"]::before {
transform: rotate(0) translate(0);
}
diff --git a/jspwiki-war/src/main/styles/haddock/default/type.less b/jspwiki-war/src/main/styles/haddock/default/type.less
index 251bedd..6aac52a 100644
--- a/jspwiki-war/src/main/styles/haddock/default/type.less
+++ b/jspwiki-war/src/main/styles/haddock/default/type.less
@@ -397,7 +397,7 @@ span.inline-code {
}
.list-nostyle { list-style: none; }
/*Credit: https://unfetteredthoughts.net/2017/09/26/voiceover-and-list-style-type-none/ */
-.list-nostyle li:before { content: "\200B"; /* add zero-width space */ }
+.list-nostyle > * >li:before { content: "\200B"; /* add zero-width space */ }
.list-group.raised li { border:none; }
diff --git a/jspwiki-war/src/main/webapp/WEB-INF/web.xml b/jspwiki-war/src/main/webapp/WEB-INF/web.xml
index 46a57b5..3fcce8b 100644
--- a/jspwiki-war/src/main/webapp/WEB-INF/web.xml
+++ b/jspwiki-war/src/main/webapp/WEB-INF/web.xml
@@ -30,6 +30,17 @@
</description>
<display-name>JSPWiki</display-name>
+ <!--
+ Supported starting from servlet specification 2.5
+ Credit: https://raibledesigns.com/rd/entry/trim_spaces_in_your_jsp1
+ -->
+ <jsp-config>
+ <jsp-property-group>
+ <url-pattern>*.jsp</url-pattern>
+ <trim-directive-whitespaces>true</trim-directive-whitespaces>
+ </jsp-property-group>
+ </jsp-config>
+
<!-- Resource bundle default location -->
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
diff --git a/jspwiki-war/src/main/webapp/templates/default/Nav.jsp b/jspwiki-war/src/main/webapp/templates/default/Nav.jsp
index 3a7b6f2..57bdc49 100644
--- a/jspwiki-war/src/main/webapp/templates/default/Nav.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/Nav.jsp
@@ -38,6 +38,10 @@
%>
<c:set var="attachments" value="<%= c.getEngine().getAttachmentManager().listAttachments( c.getPage() ).size() %>" />
+<c:set var="wordCount" value="<%= tokens.countTokens() %>" />
+<c:set var="readingTime" value="${wordCount / 228}" />
+
+
<%-- navigation bar --%>
<div class="navigation" role="navigation">