diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index cdb19d5bae..be9c3b526e 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -1716,4 +1716,20 @@ public class Functions { DecimalFormat format = new DecimalFormat("#0.00"); return format.format(number) + " " + measure; } + + /** + * Get a string that can be safely broken to several lines when necessary. + * + * This implementation inserts <wbr> tags into string. It allows browsers + * to wrap line before any sequence of punctuation characters or anywhere + * in the middle of prolonged sequences of word characters. + * + * @since 1.516 + */ + public static String breakableString(final String plain) { + + return plain.replaceAll("(\\p{Punct}+\\w)", "$1") + .replaceAll("(\\w{10})(?=\\w{3})", "$1") + ; + } } diff --git a/core/src/main/resources/hudson/matrix/MatrixProject/index.jelly b/core/src/main/resources/hudson/matrix/MatrixProject/index.jelly index 7dbf81516f..de39e50e3a 100644 --- a/core/src/main/resources/hudson/matrix/MatrixProject/index.jelly +++ b/core/src/main/resources/hudson/matrix/MatrixProject/index.jelly @@ -27,7 +27,7 @@ THE SOFTWARE. -

${%Project} ${it.displayName}

+

${%Project}

${%Project name}: ${it.fullName} diff --git a/core/src/main/resources/hudson/model/Job/index.jelly b/core/src/main/resources/hudson/model/Job/index.jelly index 651b2dd732..9e3c5becd4 100644 --- a/core/src/main/resources/hudson/model/Job/index.jelly +++ b/core/src/main/resources/hudson/model/Job/index.jelly @@ -27,7 +27,7 @@ THE SOFTWARE. -

${it.pronoun} ${it.displayName}

+

${it.pronoun}

${%Project name}: ${it.fullName} diff --git a/core/src/main/resources/hudson/views/JobColumn/column.jelly b/core/src/main/resources/hudson/views/JobColumn/column.jelly index 116ca8d108..347d4260d2 100644 --- a/core/src/main/resources/hudson/views/JobColumn/column.jelly +++ b/core/src/main/resources/hudson/views/JobColumn/column.jelly @@ -25,6 +25,6 @@ THE SOFTWARE. - ${h.getRelativeDisplayNameFrom(job,currentView.owner.itemGroup)} + - \ No newline at end of file + diff --git a/core/src/main/resources/lib/hudson/buildListTable.jelly b/core/src/main/resources/lib/hudson/buildListTable.jelly index 36d859fa6c..cf2b131db2 100644 --- a/core/src/main/resources/lib/hudson/buildListTable.jelly +++ b/core/src/main/resources/lib/hudson/buildListTable.jelly @@ -53,7 +53,7 @@ THE SOFTWARE. - ${b.parent.fullDisplayName} + ${b.displayName} diff --git a/core/src/main/resources/lib/hudson/executors.jelly b/core/src/main/resources/lib/hudson/executors.jelly index 9ad0e67fab..8bab2b1bd9 100644 --- a/core/src/main/resources/lib/hudson/executors.jelly +++ b/core/src/main/resources/lib/hudson/executors.jelly @@ -79,7 +79,7 @@ THE SOFTWARE. - ${exeparent.fullDisplayName} #${exe.number} +  #${exe.number} diff --git a/core/src/main/resources/lib/hudson/jobLink.jelly b/core/src/main/resources/lib/hudson/jobLink.jelly index dc5d6677dd..fcd234154a 100644 --- a/core/src/main/resources/lib/hudson/jobLink.jelly +++ b/core/src/main/resources/lib/hudson/jobLink.jelly @@ -32,5 +32,5 @@ THE SOFTWARE. ${job.iconColor.description} -${job.fullDisplayName} + diff --git a/core/src/main/resources/lib/hudson/queue.jelly b/core/src/main/resources/lib/hudson/queue.jelly index 7f5488444d..846fccb59a 100644 --- a/core/src/main/resources/lib/hudson/queue.jelly +++ b/core/src/main/resources/lib/hudson/queue.jelly @@ -63,7 +63,7 @@ THE SOFTWARE. - ${item.task.fullDisplayName} + diff --git a/core/src/main/resources/lib/layout/breakable.jelly b/core/src/main/resources/lib/layout/breakable.jelly new file mode 100644 index 0000000000..984b4485d6 --- /dev/null +++ b/core/src/main/resources/lib/layout/breakable.jelly @@ -0,0 +1,33 @@ + + + + + Send escaped value to output decorated to be safely broken into lines when necessary + + Unescaped value to output + + + ${h.breakableString(h.escape(value))} + diff --git a/core/src/test/java/hudson/FunctionsTest.java b/core/src/test/java/hudson/FunctionsTest.java index 8b703dce22..3ef3014d64 100644 --- a/core/src/test/java/hudson/FunctionsTest.java +++ b/core/src/test/java/hudson/FunctionsTest.java @@ -264,4 +264,11 @@ public class FunctionsTest { } } + @Test + public void testBreakableString() { + + assertEquals("Hello world!", Functions.breakableString("Hello world!")); + assertEquals("H,e.l/l:o-w_o=+|d", Functions.breakableString("H,e.l/l:o-w_o=+|d")); + assertEquals("ALongStringThatCanNotBeBrokenByDefault", Functions.breakableString("ALongStringThatCanNotBeBrokenByDefault")); + } }