Permalink
Browse files

More HTML cleanup. Html5 doctype declaration, get rid of <br> and

xml-style "/>" tag endings, other cleanup to make it validate.
  • Loading branch information...
1 parent 52703c6 commit f7505e6673d0ccfc7a530dd469beded3d701c11f @nlevitt nlevitt committed Mar 16, 2012
@@ -208,10 +208,7 @@ public void writeHtmlTo(PrintWriter pw) {
writeHtmlTo(pw,"./");
}
public void writeHtmlTo(PrintWriter pw, String uriPrefix) {
-// pw.println("<span class='job'>");
-// if(isRunning()) {
-// pw.println("ACTIVE; "+getCrawlController().getState()+":");
-// }
+ pw.println("<div>");
pw.println("<a href='"+uriPrefix+TextUtils.urlEscape(getShortName())+"'>"+getShortName()+"</a>");
if(isProfile()) {
pw.println("(profile)");
@@ -220,18 +217,18 @@ public void writeHtmlTo(PrintWriter pw, String uriPrefix) {
pw.println("&laquo;"+getJobStatusDescription()+"&raquo;");
}
if (true == isLaunchInfoPartial) {
- pw.print(" at least ");
+ pw.print(" at least ");
} else {
- pw.print(" ");
+ pw.print(" ");
}
- pw.println(getLaunchCount() + " launches");
- pw.println("<br><span style='color:#666'>");
+ pw.println(getLaunchCount() + " launches");
+ pw.println("</div>");
+ pw.println("<div style='color:#666'>");
pw.println(getPrimaryConfig());
- pw.println("</span><br>");
+ pw.println("</div>");
if(lastLaunch!=null) {
- pw.println("(last at "+lastLaunch+")");
+ pw.println("<div>(last at "+lastLaunch+")</div>");
}
-// pw.println("</span>");
}
/**
@@ -195,8 +195,11 @@ public void write(Writer writer) throws IOException {
protected void writeHtml(Writer writer) {
String baseRef = getRequest().getResourceRef().getBaseRef().toString();
- if (!baseRef.endsWith("/")) baseRef += "/";
+ if (!baseRef.endsWith("/")) {
+ baseRef += "/";
+ }
PrintWriter pw = new PrintWriter(writer);
+ pw.println("<!DOCTYPE html>");
pw.println("<html>");
pw.println("<head>");
pw.println("<title>Crawl beans in "+cj.getShortName()+"</title>");
@@ -229,14 +232,16 @@ protected void writeHtml(Writer writer) {
if(bwrap.isWritableProperty(propPath)
&& (bwrap.getDefaultEditor(type)!=null|| type == String.class)
&& !Collection.class.isAssignableFrom(type)) {
+ pw.println("<div>");
pw.println(beanPath+" = ");
writeObject(pw, null, target);
- pw.println("<a href=\"javascript:document.getElementById('editform').style.display='inline';void(0);\">edit</a>");
- pw.println("<span id='editform' style=\'display:none\'>Note: it may not be appropriate/effective to change this value in an already-built crawl context.<br/>");
- pw.println("<form id='editform' method='POST'>");
- pw.println("<input type='hidden' name='beanPath' value='"+beanPath+"'>");
+ pw.println(" <a href=\"javascript:document.getElementById('editform').style.display='block';void(0);\">edit</a>");
+ pw.println("</div>");
+ pw.println("<form id='editform' style=\'display:none\' method='POST'>");
+ pw.println("<div>Note: it may not be appropriate/effective to change this value in an already-built crawl context.</div>");
+ pw.println("<div><input type='hidden' name='beanPath' value='"+beanPath+"'>");
pw.println(beanPath + " = <input type='text' name='newVal' style='width:400px' value='"+target+"'>");
- pw.println("<input type='submit' value='update'></form></span>");
+ pw.println("<input type='submit' value='update'></div></form>");
} else {
writeObject(pw, null, target, beanPath);
}
@@ -61,20 +61,25 @@ public Reader getReader() throws IOException {
@Override
public void write(Writer writer) throws IOException {
PrintWriter pw = new PrintWriter(writer);
+ pw.println("<!DOCTYPE html>");
+ pw.println("<html>");
pw.println("<head><title>"+fileRepresentation.getFile().getName()+"</title></head>");
-
+ pw.println("<body>");
Flash.renderFlashesHTML(pw, dirResource.getRequest());
pw.println("<form method='POST'>");
// TODO: enable button on after changes made
- pw.println("<input type='submit' value='save changes'/>");
+ pw.println("<div>");
+ pw.println("<input type='submit' value='save changes'>");
pw.println(fileRepresentation.getFile());
Reference viewRef = dirResource.getRequest().getOriginalRef().clone();
viewRef.setQuery(null);
pw.println("<a href='"+viewRef+"'>view</a>");
- pw.println("<br/>");
+ pw.println("</div>");
pw.println("<textarea style='width:100%;height:94%;' name='contents'>");
StringEscapeUtils.escapeHtml(pw,fileRepresentation.getText());
pw.println("</textarea></form>");
+ pw.println("</body>");
+ pw.println("</html>");
pw.close();
}
@@ -251,6 +251,7 @@ protected void writeHtml(Writer writer) {
baseRef += "/";
}
PrintWriter pw = new PrintWriter(writer);
+ pw.println("<!DOCTYPE html>");
pw.println("<html>");
pw.println("<head><title>"+engineTitle+"</title>");
pw.println("<base href='"+baseRef+"'/>");
@@ -260,10 +261,9 @@ protected void writeHtml(Writer writer) {
Flash.renderFlashesHTML(pw, getRequest());
- pw.println("<b>Memory:</b>");
- pw.println(engine.heapReport());
- pw.println("<br><br>");
- pw.println("<b>Jobs Directory</b>: <a href='jobsdir'>"+jobsDir.getAbsolutePath()+"</a>");
+ pw.println("<p><b>Memory:</b> " + engine.heapReport() + "</p>");
+ pw.println("<p><b>Jobs Directory</b>: <a href='jobsdir'>"
+ + jobsDir.getAbsolutePath() + "</a></p>");
ArrayList<CrawlJob> jobs = new ArrayList<CrawlJob>();
@@ -285,24 +285,24 @@ protected void writeHtml(Writer writer) {
// create new job with defaults
pw.println("<form method='POST'>\n"
- + "Create new job directory with recommended starting configuration<br>\n"
- + "<b>Path:</b> " + jobsDir.getAbsolutePath() + File.separator
- + "<input name='createpath'/>\n"
+ + "<div>Create new job directory with recommended starting configuration</div>\n"
+ + "<div><b>Path:</b> " + jobsDir.getAbsolutePath()
+ + File.separator + "<input name='createpath'>\n"
+ "<input type='submit' name='action' value='create'>\n"
- + "</form>\n");
+ + "</div></form>\n");
pw.println("<form method='POST'>");
- pw.println("Specify a path to a pre-existing job directory<br>");
- pw.println("<b>Path:</b> <input size='53' name='addpath'>");
+ pw.println("<div>Specify a path to a pre-existing job directory</div>");
+ pw.println("<div><b>Path:</b> <input size='53' name='addpath'>");
pw.println("<input type='submit' name='action' value='add'>");
- pw.println("</form>");
+ pw.println("</div></form>");
pw.println(
- "You may also compose or copy a valid job directory into " +
+ "<p>You may also compose or copy a valid job directory into " +
"the main jobs directory via outside means, then use the " +
"'rescan' button above to make it appear in this interface. Or, " +
"use the 'copy' functionality at the botton of any existing " +
- "job's detail page.");
+ "job's detail page.</p>");
pw.println("<h2>Exit Java</h2>");
@@ -320,8 +320,10 @@ protected void writeHtml(Writer writer) {
+checkName+"'><label for='"+checkName+"'> Ignore job '"
+entry.getKey()+"' and exit anyway</label><br>");
}
+ pw.println("<div>");
pw.println("<input type='submit' name='action' value='Exit Java Process'>");
- pw.println("<input type='checkbox' name=\"I'm sure\" id=\"I'm sure\"><label for=\"I'm sure\"> I'm sure</label>");
+ pw.println("<input type='checkbox' name='im_sure' id='im_sure'><label for='im_sure'> I'm sure</label>");
+ pw.println("</div>");
pw.println("</form>");
pw.println("</body>");
pw.println("</html>");
@@ -23,6 +23,7 @@
import java.beans.PropertyDescriptor;
import java.io.File;
import java.io.PrintWriter;
+import java.net.URLEncoder;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
@@ -36,6 +37,7 @@
import org.apache.commons.lang.StringUtils;
import org.archive.crawler.framework.CrawlJob;
import org.archive.crawler.framework.Engine;
+import org.archive.util.TextUtils;
import org.restlet.Context;
import org.restlet.data.Reference;
import org.restlet.data.Request;
@@ -415,48 +417,49 @@ protected void writeObject(PrintWriter pw, String field, Object object, HashSet<
String close = "";
String beanPath = beanPathPrefix;
if(StringUtils.isNotBlank(field)) {
- pw.write("<tr><td align='right' valign='top'><b>");
+ pw.write("<tr>\n<td style='text-align:right;vertical-align:top'><b>");
String closeAnchor ="";
if(StringUtils.isNotBlank(beanPathPrefix)) {
if(beanPathPrefix.endsWith(".")) {
beanPath += field;
} else if (beanPathPrefix.endsWith("[")) {
beanPath += field + "]";
}
- pw.println("<a href='../beans/"+beanPath+"'>");
+ // url-encode because brackets are not allowed here according to validator.w3.org
+ pw.print("<a href='../beans/" + TextUtils.urlEscape(beanPath) + "'>");
closeAnchor = "</a>";
}
pw.write(field);
pw.write(closeAnchor);
- pw.write(":</b></td><td>");
- close="</td></tr>";
+ pw.write(":</b></td>\n<td>");
+ close="</td>\n</tr>\n";
}
if(object == null) {
- pw.write("<i>null</i><br/>");
+ pw.write("<i>null</i>");
pw.write(close);
return;
}
if(object instanceof String) {
- pw.write("\""+object+"\"<br/>");
+ pw.write("\""+object+"\"");
pw.write(close);
return;
}
if(BeanUtils.isSimpleValueType(object.getClass())
|| object instanceof File
//|| BeanUtils.findEditorByConvention(object.getClass())!=null
) {
- pw.write(object+"<br/>");
+ pw.write(object.toString());
pw.write(close);
return;
}
if(alreadyWritten.contains(object)) {
- pw.println("&uarr;<br/>");
+ pw.println("&uarr;");
pw.write(close);
return;
}
alreadyWritten.add(object); // guard against repeats and cycles
if(StringUtils.isNotBlank(key) && StringUtils.isNotBlank(field)) {
- pw.println("<a href='../beans/"+key+"'>"+key+"</a><br/>");
+ pw.println("<a href='../beans/"+key+"'>"+key+"</a>");
pw.write(close);
return;
}
@@ -509,7 +512,7 @@ protected void writeObject(PrintWriter pw, String field, Object object, HashSet<
}
}
pw.println("</table>");
- pw.print("</fieldset><br/>");
+ pw.print("</fieldset>");
pw.write(close);
}
Oops, something went wrong.

0 comments on commit f7505e6

Please sign in to comment.