Commits

J. Ryan Stinnett committed be90c32

Sort directories first in list view, fixed errors with XML changes, changed styling on def type in results

Comments (0)

Files changed (4)

bazaarvoice-customizations

 # HG changeset patch
 # User J. Ryan Stinnett <jryans@gmail.com>
-# Date 1295245922 21600
+# Date 1295293584 21600
 # Node ID a0baf2a260b3a7d8c496cd32e7b323a571462f52
-# Parent 16b49499630cb910716ea53394c3304b920510e5
+# Parent 4dcd76ff7b5a03f5c7e5ceb42a0ab3e60d6e6197
 Bazaarvoice-specific customizations
 
 diff --git a/src/org/opensolaris/opengrok/search/Results.java b/src/org/opensolaris/opengrok/search/Results.java
 diff --git a/src/org/opensolaris/opengrok/search/context/Context.java b/src/org/opensolaris/opengrok/search/context/Context.java
 --- a/src/org/opensolaris/opengrok/search/context/Context.java
 +++ b/src/org/opensolaris/opengrok/search/context/Context.java
-@@ -145,7 +145,7 @@
+@@ -27,6 +27,13 @@
+  */
+ package org.opensolaris.opengrok.search.context;
+ 
++import org.apache.lucene.search.Query;
++import org.opensolaris.opengrok.OpenGrokLogger;
++import org.opensolaris.opengrok.analysis.Definitions;
++import org.opensolaris.opengrok.configuration.RuntimeEnvironment;
++import org.opensolaris.opengrok.search.Hit;
++import org.opensolaris.opengrok.web.Util;
++
+ import java.io.IOException;
+ import java.io.Reader;
+ import java.io.Writer;
+@@ -35,12 +42,6 @@
+ import java.util.Map;
+ import java.util.TreeMap;
+ import java.util.logging.Level;
+-import org.apache.lucene.search.Query;
+-import org.opensolaris.opengrok.OpenGrokLogger;
+-import org.opensolaris.opengrok.analysis.Definitions;
+-import org.opensolaris.opengrok.configuration.RuntimeEnvironment;
+-import org.opensolaris.opengrok.search.Hit;
+-import org.opensolaris.opengrok.web.Util;
+ 
+ public class Context {
+ 
+@@ -145,7 +146,7 @@
                                  if (out == null) {
                                      Hit hit = new Hit(path,
                                              Util.htmlize(desc[3]).replaceAll(
                                              desc[1], false, alt);
                                      hits.add(hit);
                                      anything = true;
-@@ -159,10 +159,10 @@
+@@ -159,10 +160,10 @@
                                      out.write(desc[1]);
                                      out.write("</span> ");
                                      out.write(Util.htmlize(desc[3]).replaceAll(
 -                                            desc[0], "<b>" + desc[0] + "</b>"));
 -                                    out.write("</a> <i> ");
 +                                            desc[0], "<strong>" + desc[0] + "</strong>"));
-+                                    out.write("</a> <em> ");
++                                    out.write("</a> <span class=\"symbolType\"> ");
                                      out.write(desc[2]);
 -                                    out.write(" </i><br/>");
-+                                    out.write(" </em><br/>");
++                                    out.write(" definition</span><br/>");
                                      anything = true;
                                  }
                              } else {
-@@ -251,7 +251,7 @@
+@@ -251,7 +252,7 @@
              anything = matchedLines > 0;
              tokens.dumpRest();
              if (lim && (truncated || matchedLines == 10) && out != null) {
              }
          } catch (IOException e) {
              OpenGrokLogger.getLogger().log(Level.WARNING, "Could not get context for " + path, e);
+diff --git a/src/org/opensolaris/opengrok/search/context/PlainLineTokenizer.lex b/src/org/opensolaris/opengrok/search/context/PlainLineTokenizer.lex
+--- a/src/org/opensolaris/opengrok/search/context/PlainLineTokenizer.lex
++++ b/src/org/opensolaris/opengrok/search/context/PlainLineTokenizer.lex
+@@ -165,10 +165,10 @@
+ 
+                         out.write("</a>");
+                         if(prevHi){
+-                                out.write(" <i> ");
++                                out.write(" <span class=\"symbolType\"> ");
+                                 String[] desc = tags.remove(prevLn);
+                                 out.write(desc[2]);
+-                                out.write(" </i>");
++                                out.write(" definition</span>");
+                         }
+                         out.write("<br/>");
+ 
+@@ -322,10 +322,10 @@
+ 
+                                 out.write("</a>");
+                                 if (prevHi) {
+-                                        out.write(" <i> ");
++                                        out.write(" <span class=\"symbolType\"> ");
+                                         String[] desc = tags.remove(prevLn);
+                                         out.write(desc[2]);
+-                                        out.write(" </i>");
++                                        out.write(" definition</span>");
+                                 }
+                                 out.write("<br/>");
+                            } else {
+@@ -352,9 +352,9 @@
+                 out.write(desc[1]);
+                 out.write("</span> ");
+                 out.write(Util.htmlize(desc[3]).replaceAll(desc[0], "<b>" + desc[0] + "</b>"));
+-                out.write("</a> <i> ");
++                out.write("</a> <span class=\"symbolType\"> ");
+                 out.write(desc[2]);
+-                out.write(" </i><br/>");
++                out.write(" definition</span><br/>");
+            }
+         } else {
+            for(Integer rem : tags.keySet()) {
+@@ -397,10 +397,10 @@
+                            printWithNum(rest, endPos, markedLine, false);
+                            out.write("</a>");
+                            if(prevHi){
+-                                out.write(" <i> ");
++                                out.write(" <span class=\"symbolType\"> ");
+                                 String[] desc = tags.remove(prevLn);
+                                 out.write(desc[2]);
+-                                out.write("</i> ");
++                                out.write(" definition</span> ");
+                            }
+                            out.write("<br/>");
+                         } else {
 diff --git a/src/org/opensolaris/opengrok/web/DirectoryListing.java b/src/org/opensolaris/opengrok/web/DirectoryListing.java
 --- a/src/org/opensolaris/opengrok/web/DirectoryListing.java
 +++ b/src/org/opensolaris/opengrok/web/DirectoryListing.java
-@@ -76,20 +76,20 @@
-         Arrays.sort(files, String.CASE_INSENSITIVE_ORDER);
+@@ -91,20 +91,20 @@
+         });
          boolean alt = true;
          Format dateFormatter = new SimpleDateFormat("dd-MMM-yyyy", Locale.getDefault());
 -        out.write("<table cellspacing=\"0\" border=\"0\" id=\"dirlist\">");
          ArrayList<String> readMes = new ArrayList<String>();
          IgnoredNames ignoredNames = RuntimeEnvironment.getInstance().getIgnoredNames();
  
-@@ -104,22 +104,22 @@
+@@ -119,22 +119,22 @@
                  out.write(alt ? " class=\"alt\"" : "");
  
-                 boolean isDir = child.isDirectory();
--                out.write("><td align=\"left\"><tt><a href=\"" + Util.URIEncodePath(file) + (isDir ? "/\" class=\"r\"" : "\" class=\"p\"") + ">");
-+                out.write("><td class=\"filename\" align=\"left\"><span class=\"code code-path\"><a href=\"" + Util.URIEncodePath(file) + (isDir ? "/\" class=\"r\"" : "\" class=\"p\"") + ">");
+                 boolean isDir = file.isDirectory();
+-                out.write("><td align=\"left\"><tt><a href=\"" + Util.URIEncodePath(fileName) + (isDir ? "/\" class=\"r\"" : "\" class=\"p\"") + ">");
++                out.write("><td class=\"filename\" align=\"left\"><span class=\"code code-path\"><a href=\"" + Util.URIEncodePath(fileName) + (isDir ? "/\" class=\"r\"" : "\" class=\"p\"") + ">");
                  if (isDir) {
--                    out.write("<b>" + file + "</b></a>/");
-+                    out.write("<span class=\"foldername\">" + file + "</span></a>/");
+-                    out.write("<b>" + fileName + "</b></a>/");
++                    out.write("<span class=\"foldername\">" + fileName + "</span></a>/");
                  } else {
-                     out.write(file + "</a>");
+                     out.write(fileName + "</a>");
                  }
-                 Date lastm = new Date(child.lastModified());
+                 Date lastm = new Date(file.lastModified());
 -                out.write("</tt></td><td>" + ((now - lastm.getTime()) < 86400000 ? "Today" : dateFormatter.format(lastm)) + "</td>");
--                out.write("<td><tt>" + (isDir ? "" : Util.redableSize(child.length())) + "</tt></td>");
+-                out.write("<td><tt>" + (isDir ? "" : Util.redableSize(file.length())) + "</tt></td>");
 +                out.write("</span></td><td class=\"date\">" + ((now - lastm.getTime()) < 86400000 ? "Today" : dateFormatter.format(lastm)) + "</td>");
-+                out.write("<td class=\"size\"><span class=\"code code-size\">" + (isDir ? "" : Util.redableSize(child.length())) + "</span></td>");
++                out.write("<td class=\"size\"><span class=\"code code-size\">" + (isDir ? "" : Util.redableSize(file.length())) + "</span></td>");
  
                  if (parentFNode != null && parentFNode.childOffset > 0) {
-                     String briefDesc = desc.getChildTag(parentFNode, file);
+                     String briefDesc = desc.getChildTag(parentFNode, fileName);
                      if (briefDesc == null) {
 -                        out.write("<td></td>");
 +                        out.write("<td class=\"description\"></td>");
 diff --git a/web/default/style.css b/web/default/style.css
 --- a/web/default/style.css
 +++ b/web/default/style.css
-@@ -1,144 +1,196 @@
+@@ -1,144 +1,197 @@
 -body {
 -background-color: #ffffff;
 -/*font-size: 100.01%; /* 12px [1] */
 +                    /*a#highlight-link {display: none;} See mast.jsp for details*/
 +                    a.highlight {background-position: 0 -680px;}
 +                        a.highlight:hover {background-position: 0 -720px;}
-+            dd.f {float: left; margin-left: 0; width: 40%;}
-+            dd.con {float: left; font-family: Consolas, 'Lucida Console', Monaco, monospace; font-size: 0.8em; margin-bottom: 1em; margin-left: 0; width: 53%;}
++            dd.f {float: left; margin-left: 0; width: 30%;}
++            dd.con {float: left; font-family: Consolas, 'Lucida Console', Monaco, monospace; font-size: 0.8em; margin-bottom: 1em; margin-left: 0; width: 63%;}
 +                a.s {color: #000000;} /* matched lines */
 +                .l {color: #999999;} /* line numbers */
 +            .link-more {font-family: Helvetica, Helvetica Neue, Arial, sans-serif; font-size: 1.2em; font-style: italic;}
 +                    .alt {background-color: #eef8fe;} /* odd rows */
 +            ul.filelist {font-family: Consolas, 'Lucida Console', Monaco, monospace; font-size: 0.8em; margin-top: 0;}
 +            p.action {margin-top: 3em;}
++            .symbolType {font-style: italic; font-weight: bold; color: #d45c55;}
 +        #src {color: #000000;}
 +    #footer {background: #101010 url(./img/backgroundFooter.jpg) no-repeat left bottom; clear: both; color: #cccccc; line-height: 1.5em; padding: 2em 50px 1.5em;}
 +        #footer a:link, #footer a:visited, #footer a:hover, #footer a:active {color: #ffffff;}
  
  .sl {color:#999;text-decoration:underline;}
  td.a{color:#000}
-@@ -146,7 +198,6 @@
+@@ -146,7 +199,6 @@
  .s  {color:green;} /* strings */
  .c  {color:#666;} /* comments */
  .b  {color:#000; font-weight:bold;} /* comments */
  .i  {color:#00008b; font-weight:bold;} /* interpolations */
  .di {color:#00008b; font-weight:bold;} /* directives */
  .bi {color:#666;} /* built-in */
-@@ -182,74 +233,6 @@
+@@ -182,74 +234,6 @@
  a.xmt {color:#00f; font-weight:bold; text-decoration:none;} /* method */
  a.xsr {color:#00f; font-weight:bold; text-decoration:none;} /* subroutine */
  
  
      var pattern = "a:contains('" + keyword + "')";
      $(pattern).css({
-@@ -344,7 +358,7 @@
+@@ -343,7 +357,7 @@
  
                          if (br != null) {
                            int len = 0;
                            while((len = br.read(buf)) > 0) {
                                out.write(buf, 0, len);
                            }
-@@ -389,7 +403,7 @@
+@@ -388,7 +402,7 @@
                          if (g == Genre.DATA || g == Genre.XREFABLE || g == null) {
  		            %><div id="src">Binary file [Click <a href="<%=context%>/raw<%=path%>?r=<%=rev%>">here</a> to download] </div><%
                          } else {
                              if (g == Genre.PLAIN) {
                                  // We don't have any way to get definitions
                                  // for old revisions currently.
-@@ -489,7 +503,7 @@
+@@ -488,7 +502,7 @@
              }
          }
      }

enhanced-xml-support

 # HG changeset patch
-# Date 1295271423 21600
+# Date 1295286196 21600
 # User J. Ryan Stinnett <jryans@gmail.com>
 # Parent 3ce12cc4378c5ea6747e9b42b2666940a40a22db
 Adds support for Spring features in XML files
      /**
       * Write a cross referenced HTML file reads the source from in
       * @param in Input source
-@@ -107,7 +128,7 @@
+@@ -106,8 +127,8 @@
+      * @param defs definitions for the file (could be null)
       * @param annotation annotation for the file (could be null)
       */
-     static void writeXref(Reader in, Writer out, Definitions defs, Annotation annotation, Project project) throws IOException {
+-    static void writeXref(Reader in, Writer out, Definitions defs, Annotation annotation, Project project) throws IOException {
 -        XMLXref xref = new XMLXref(in);
++    public static void writeXref(Reader in, Writer out, Definitions defs, Annotation annotation, Project project) throws IOException {
 +        PlainXref xref = new PlainXref(in);
          xref.annotation = annotation;
          xref.project = project;
  import org.opensolaris.opengrok.analysis.sh.ShAnalyzer;
  import org.opensolaris.opengrok.analysis.sh.ShAnalyzerFactory;
  import static org.junit.Assert.*;
+diff --git a/test/org/opensolaris/opengrok/analysis/JFlexXrefTest.java b/test/org/opensolaris/opengrok/analysis/JFlexXrefTest.java
+--- a/test/org/opensolaris/opengrok/analysis/JFlexXrefTest.java
++++ b/test/org/opensolaris/opengrok/analysis/JFlexXrefTest.java
+@@ -40,7 +40,7 @@
+ import org.opensolaris.opengrok.analysis.lisp.LispXref;
+ import org.opensolaris.opengrok.analysis.perl.PerlXref;
+ import org.opensolaris.opengrok.analysis.plain.PlainXref;
+-import org.opensolaris.opengrok.analysis.plain.XMLXref;
++import org.opensolaris.opengrok.analysis.xml.XMLXref;
+ import org.opensolaris.opengrok.analysis.sh.ShXref;
+ import org.opensolaris.opengrok.analysis.sql.SQLXref;
+ import org.opensolaris.opengrok.analysis.tcl.TclXref;
 diff --git a/test/org/opensolaris/opengrok/analysis/plain/XMLAnalyzerTest.java b/test/org/opensolaris/opengrok/analysis/plain/XMLAnalyzerTest.java
 --- a/test/org/opensolaris/opengrok/analysis/plain/XMLAnalyzerTest.java
 +++ b/test/org/opensolaris/opengrok/analysis/plain/XMLAnalyzerTest.java
 xref-line-highlight
 check-js-symbol-list
 focus-full-text
+sort-directories-first
 bazaarvoice-customizations

sort-directories-first

+# HG changeset patch
+# Parent dd509a88c89b1c5995d25e9b63b218f223e6a684
+# User J. Ryan Stinnett <jryans@gmail.com>
+# Date 1295285703 21600
+
+Sorts directories to the top of a directory listing
+
+diff --git a/src/org/opensolaris/opengrok/web/DirectoryListing.java b/src/org/opensolaris/opengrok/web/DirectoryListing.java
+--- a/src/org/opensolaris/opengrok/web/DirectoryListing.java
++++ b/src/org/opensolaris/opengrok/web/DirectoryListing.java
+@@ -23,6 +23,9 @@
+  */
+ package org.opensolaris.opengrok.web;
+ 
++import org.opensolaris.opengrok.configuration.RuntimeEnvironment;
++import org.opensolaris.opengrok.index.IgnoredNames;
++
+ import java.io.File;
+ import java.io.IOException;
+ import java.io.Writer;
+@@ -30,11 +33,10 @@
+ import java.text.SimpleDateFormat;
+ import java.util.ArrayList;
+ import java.util.Arrays;
++import java.util.Comparator;
+ import java.util.Date;
+ import java.util.List;
+ import java.util.Locale;
+-import org.opensolaris.opengrok.configuration.RuntimeEnvironment;
+-import org.opensolaris.opengrok.index.IgnoredNames;
+ 
+ /**
+  * Generates HTML listing of a Directory
+@@ -55,7 +57,7 @@
+     }
+ 
+     public void listTo(File dir, Writer out) throws IOException {
+-        String[] files = dir.list();
++        File[] files = dir.listFiles();
+         if (files != null) {
+             listTo(dir, out, dir.getPath(), files);
+         }
+@@ -72,8 +74,21 @@
+      * @throws java.io.IOException
+      *
+      */
+-    public List<String> listTo(File dir, Writer out, String path, String[] files) throws IOException {
+-        Arrays.sort(files, String.CASE_INSENSITIVE_ORDER);
++    public List<String> listTo(File dir, Writer out, String path, File[] files) throws IOException {
++        Arrays.sort(files, new Comparator<File>() {
++            @Override
++            public int compare(File f1, File f2) {
++                // First sort by type, with directories first
++                if (f1.isDirectory() && f2.isFile()) {
++                    return -1;
++                } else if (f1.isFile() && f2.isDirectory()) {
++                    return 1;
++                }
++
++                // Then sort by name
++                return f1.getName().compareToIgnoreCase(f2.getName());
++            }
++        });
+         boolean alt = true;
+         Format dateFormatter = new SimpleDateFormat("dd-MMM-yyyy", Locale.getDefault());
+         out.write("<table cellspacing=\"0\" border=\"0\" id=\"dirlist\">");
+@@ -93,29 +108,29 @@
+         ArrayList<String> readMes = new ArrayList<String>();
+         IgnoredNames ignoredNames = RuntimeEnvironment.getInstance().getIgnoredNames();
+ 
+-        for (String file : files) {
+-            if (!ignoredNames.ignore(file)) {
+-                File child = new File(dir, file);
+-                if (file.startsWith("README") || file.endsWith("README") || file.startsWith("readme")) {
+-                    readMes.add(file);
++        for (File file : files) {
++            String fileName = file.getName();
++            if (!ignoredNames.ignore(fileName)) {
++                if (fileName.startsWith("README") || fileName.endsWith("README") || fileName.startsWith("readme")) {
++                    readMes.add(fileName);
+                 }
+                 alt = !alt;
+                 out.write("<tr align=\"right\"");
+                 out.write(alt ? " class=\"alt\"" : "");
+ 
+-                boolean isDir = child.isDirectory();
+-                out.write("><td align=\"left\"><tt><a href=\"" + Util.URIEncodePath(file) + (isDir ? "/\" class=\"r\"" : "\" class=\"p\"") + ">");
++                boolean isDir = file.isDirectory();
++                out.write("><td align=\"left\"><tt><a href=\"" + Util.URIEncodePath(fileName) + (isDir ? "/\" class=\"r\"" : "\" class=\"p\"") + ">");
+                 if (isDir) {
+-                    out.write("<b>" + file + "</b></a>/");
++                    out.write("<b>" + fileName + "</b></a>/");
+                 } else {
+-                    out.write(file + "</a>");
++                    out.write(fileName + "</a>");
+                 }
+-                Date lastm = new Date(child.lastModified());
++                Date lastm = new Date(file.lastModified());
+                 out.write("</tt></td><td>" + ((now - lastm.getTime()) < 86400000 ? "Today" : dateFormatter.format(lastm)) + "</td>");
+-                out.write("<td><tt>" + (isDir ? "" : Util.redableSize(child.length())) + "</tt></td>");
++                out.write("<td><tt>" + (isDir ? "" : Util.redableSize(file.length())) + "</tt></td>");
+ 
+                 if (parentFNode != null && parentFNode.childOffset > 0) {
+-                    String briefDesc = desc.getChildTag(parentFNode, file);
++                    String briefDesc = desc.getChildTag(parentFNode, fileName);
+                     if (briefDesc == null) {
+                         out.write("<td></td>");
+                     } else {
+diff --git a/web/list.jsp b/web/list.jsp
+--- a/web/list.jsp
++++ b/web/list.jsp
+@@ -321,9 +321,8 @@
+ 
+         // If requesting a Directory listing -------------
+         DirectoryListing dl = new DirectoryListing(ef);
+-        String[] files = resourceFile.list();
++        File[] files = resourceFile.listFiles();
+         if (files != null) {
+-            Arrays.sort(files, String.CASE_INSENSITIVE_ORDER);
+             List<String> readMes = dl.listTo(resourceFile, out, path, files);
+             if(readMes != null && readMes.size() > 0) {
+                 File xdir = new File(environment.getDataRootPath() + Constants.xrefP + path);