Author: radu
Date: Mon Feb 29 23:03:20 2016
New Revision: 1732966
URL: http://svn.apache.org/viewvc?rev=1732966&view=rev
Log:
SLING-5573 - The File System Classloader Console Plugin should wrap long lines
of code
* added white-space: pre-wrap CSS3 property to the pre tag where the code is
outputted
(verified on Chrome 48, Firefox 44, IE 11, Safari 9.1)
* minor code cleaning
Modified:
sling/trunk/bundles/commons/fsclassloader/src/main/java/org/apache/sling/commons/fsclassloader/impl/FSClassLoaderWebConsole.java
Modified:
sling/trunk/bundles/commons/fsclassloader/src/main/java/org/apache/sling/commons/fsclassloader/impl/FSClassLoaderWebConsole.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/commons/fsclassloader/src/main/java/org/apache/sling/commons/fsclassloader/impl/FSClassLoaderWebConsole.java?rev=1732966&r1=1732965&r2=1732966&view=diff
==============================================================================
---
sling/trunk/bundles/commons/fsclassloader/src/main/java/org/apache/sling/commons/fsclassloader/impl/FSClassLoaderWebConsole.java
(original)
+++
sling/trunk/bundles/commons/fsclassloader/src/main/java/org/apache/sling/commons/fsclassloader/impl/FSClassLoaderWebConsole.java
Mon Feb 29 23:03:20 2016
@@ -50,7 +50,7 @@ import org.osgi.service.component.Compon
@Component
@Service
@Properties({
- @Property(name = "service.description", value = "JSP Script
Handler"),
+ @Property(name = "service.description", value = "Web Console
for the FileSystem Class Loader"),
@Property(name = "service.vendor", value = "The Apache Software
Foundation"),
@Property(name = "felix.webconsole.label", value =
FSClassLoaderWebConsole.APP_ROOT),
@Property(name = "felix.webconsole.title", value = "File System
Class Loader"),
@@ -150,10 +150,11 @@ public class FSClassLoaderWebConsole ext
/**
* Activate this component. Create the root directory.
*
- * @param componentContext
+ * @param componentContext the component context
* @throws MalformedURLException
*/
@Activate
+ @SuppressWarnings("unused")
protected void activate(final ComponentContext componentContext)
throws MalformedURLException {
// get the file root
@@ -293,8 +294,11 @@ public class FSClassLoaderWebConsole ext
private void readFiles(File file, Map<String, ScriptFiles> scripts)
throws IOException {
if (file.isDirectory()) {
- for (File f : file.listFiles()) {
- readFiles(f, scripts);
+ File[] children = file.listFiles();
+ if (children != null) {
+ for (File f : children) {
+ readFiles(f, scripts);
+ }
}
} else {
String script = ScriptFiles.getScript(file);
@@ -325,7 +329,7 @@ public class FSClassLoaderWebConsole ext
w.write("<script type=\"text/javascript\" src=\"" + RES_LOC
+ "/prettify.js\"></script>");
w.write("<script>$(document).ready(prettyPrint);</script>");
- w.write("<style>.prettyprint ol.linenums > li {
list-style-type: decimal; }</style>");
+ w.write("<style>.prettyprint ol.linenums > li {
list-style-type: decimal; } pre.prettyprint { white-space: pre-wrap;
}</style>");
String file = request.getParameter("view");
File toView = new File(root + file);
if (!StringUtils.isEmpty(file)) {
@@ -360,9 +364,9 @@ public class FSClassLoaderWebConsole ext
try {
is = new FileInputStream(toView);
String contents = IOUtils.toString(is);
- w.write("<pre class=\"prettyprint
linenums\"><code>");
+ w.write("<pre class=\"prettyprint
linenums\">");
StringEscapeUtils.escapeHtml(w,
contents);
- w.write("</pre></code>");
+ w.write("</pre>");
} finally {
IOUtils.closeQuietly(is);
}