]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1620] add a tab to browse artifact content in artifact detail view
authorOlivier Lamy <olamy@apache.org>
Wed, 16 May 2012 22:18:05 +0000 (22:18 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 16 May 2012 22:18:05 +0000 (22:18 +0000)
start displaying content

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1339396 13f79535-47bb-0310-9956-ffa450edef68

32 files changed:
archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ArtifactContentEntry.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/application.png [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/code.png [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/css.png [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/db.png [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/directory.png [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/doc.png [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/file.png [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/film.png [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/flash.png [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/folder_open.png [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/html.png [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/java.png [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/linux.png [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/music.png [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/pdf.png [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/php.png [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/picture.png [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/ppt.png [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/psd.png [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/ruby.png [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/script.png [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/spinner.gif [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/txt.png [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/xls.png [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/zip.png [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/jqueryFileTree.css [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/jqueryFileTree-1.0.1.js [new file with mode: 0755]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html

index 7a68af9b9df0f56907927a46bae819a90c2955db..82bf58bf06c108e716a28b618cec5b38611f3d39 100644 (file)
@@ -29,32 +29,40 @@ import java.io.Serializable;
 public class ArtifactContentEntry
     implements Serializable
 {
-    private String name;
+    private String text;
 
     private boolean file;
 
     private int depth;
 
+    private boolean hasChildren;
+
     public ArtifactContentEntry()
     {
         // no op
     }
 
-    public ArtifactContentEntry( String name, boolean file, int depth )
+    public ArtifactContentEntry( String text, boolean file, int depth, boolean hasChildren )
     {
-        this.name = name;
+        this.text = text;
         this.file = file;
         this.depth = depth;
+        this.hasChildren = hasChildren;
+    }
+
+    public String getText()
+    {
+        return text;
     }
 
-    public String getName()
+    public String getId()
     {
-        return name;
+        return text;
     }
 
-    public void setName( String name )
+    public void setText( String text )
     {
-        this.name = name;
+        this.text = text;
     }
 
     public boolean isFile()
@@ -77,18 +85,18 @@ public class ArtifactContentEntry
         this.depth = depth;
     }
 
-    @Override
-    public String toString()
+    public boolean isHasChildren()
     {
-        final StringBuilder sb = new StringBuilder();
-        sb.append( "ArtifactContentEntry" );
-        sb.append( "{name='" ).append( name ).append( '\'' );
-        sb.append( ", file=" ).append( file );
-        sb.append( ", depth=" ).append( depth );
-        sb.append( '}' );
-        return sb.toString();
+        return hasChildren;
     }
 
+    public void setHasChildren( boolean hasChildren )
+    {
+        this.hasChildren = hasChildren;
+    }
+
+
+
     @Override
     public boolean equals( Object o )
     {
@@ -103,6 +111,10 @@ public class ArtifactContentEntry
 
         ArtifactContentEntry that = (ArtifactContentEntry) o;
 
+        if ( hasChildren != that.hasChildren )
+        {
+            return false;
+        }
         if ( depth != that.depth )
         {
             return false;
@@ -111,7 +123,7 @@ public class ArtifactContentEntry
         {
             return false;
         }
-        if ( !name.equals( that.name ) )
+        if ( text != null ? !text.equals( that.text ) : that.text != null )
         {
             return false;
         }
@@ -122,9 +134,23 @@ public class ArtifactContentEntry
     @Override
     public int hashCode()
     {
-        int result = name.hashCode();
+        int result = text != null ? text.hashCode() : 0;
         result = 31 * result + ( file ? 1 : 0 );
         result = 31 * result + depth;
+        result = 31 * result + ( hasChildren ? 1 : 0 );
         return result;
     }
+
+    @Override
+    public String toString()
+    {
+        final StringBuilder sb = new StringBuilder();
+        sb.append( "ArtifactContentEntry" );
+        sb.append( "{text='" ).append( text ).append( '\'' );
+        sb.append( ", file=" ).append( file );
+        sb.append( ", depth=" ).append( depth );
+        sb.append( ", children=" ).append( hasChildren );
+        sb.append( '}' );
+        return sb.toString();
+    }
 }
index 8a782ba29a0fa0915c0a3270a9727069cd1152fb..6e692202b43678cae952d4f3831a9b4016be5fe7 100644 (file)
@@ -660,10 +660,10 @@ public class DefaultBrowseService
     {
         Map<String, ArtifactContentEntry> artifactContentEntryMap = new HashMap<String, ArtifactContentEntry>();
         int filterDepth = StringUtils.countMatches( filterPath, "/" );
-        if ( filterDepth == 0 )
+        /*if ( filterDepth == 0 )
         {
             filterDepth = 1;
-        }
+        }*/
         JarFile jarFile = new JarFile( file );
         try
         {
@@ -676,7 +676,8 @@ public class DefaultBrowseService
                         currentEntry.getName(), "/" ) : currentEntry.getName();
                 String entryRootPath = getRootPath( cleanedEntryName );
                 int depth = StringUtils.countMatches( cleanedEntryName, "/" );
-                if ( StringUtils.isEmpty( filterPath ) && !artifactContentEntryMap.containsKey( entryRootPath ) )
+                if ( StringUtils.isEmpty( filterPath ) && !artifactContentEntryMap.containsKey( entryRootPath )
+                    && depth == filterDepth )
                 {
 
                     artifactContentEntryMap.put( entryRootPath,
@@ -685,7 +686,7 @@ public class DefaultBrowseService
                 }
                 else
                 {
-                    if ( StringUtils.startsWith( cleanedEntryName, filterPath ) && ( depth >= filterDepth || (
+                    if ( StringUtils.startsWith( cleanedEntryName, filterPath ) && ( depth == filterDepth || (
                         !currentEntry.isDirectory() && depth == filterDepth ) ) )
                     {
                         artifactContentEntryMap.put( cleanedEntryName, new ArtifactContentEntry( cleanedEntryName,
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/application.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/application.png
new file mode 100755 (executable)
index 0000000..1dee9e3
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/application.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/code.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/code.png
new file mode 100755 (executable)
index 0000000..0c76bd1
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/code.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/css.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/css.png
new file mode 100755 (executable)
index 0000000..f907e44
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/css.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/db.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/db.png
new file mode 100755 (executable)
index 0000000..bddba1f
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/db.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/directory.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/directory.png
new file mode 100755 (executable)
index 0000000..784e8fa
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/directory.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/doc.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/doc.png
new file mode 100755 (executable)
index 0000000..ae8ecbf
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/doc.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/file.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/file.png
new file mode 100755 (executable)
index 0000000..8b8b1ca
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/file.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/film.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/film.png
new file mode 100755 (executable)
index 0000000..b0ce7bb
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/film.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/flash.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/flash.png
new file mode 100755 (executable)
index 0000000..5769120
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/flash.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/folder_open.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/folder_open.png
new file mode 100755 (executable)
index 0000000..4e35483
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/folder_open.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/html.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/html.png
new file mode 100755 (executable)
index 0000000..6ed2490
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/html.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/java.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/java.png
new file mode 100755 (executable)
index 0000000..b7bfcd1
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/java.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/linux.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/linux.png
new file mode 100755 (executable)
index 0000000..52699bf
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/linux.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/music.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/music.png
new file mode 100755 (executable)
index 0000000..a8b3ede
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/music.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/pdf.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/pdf.png
new file mode 100755 (executable)
index 0000000..8f8095e
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/pdf.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/php.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/php.png
new file mode 100755 (executable)
index 0000000..7868a25
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/php.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/picture.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/picture.png
new file mode 100755 (executable)
index 0000000..4a158fe
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/picture.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/ppt.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/ppt.png
new file mode 100755 (executable)
index 0000000..c4eff03
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/ppt.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/psd.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/psd.png
new file mode 100755 (executable)
index 0000000..73c5b3f
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/psd.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/ruby.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/ruby.png
new file mode 100755 (executable)
index 0000000..f59b7c4
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/ruby.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/script.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/script.png
new file mode 100755 (executable)
index 0000000..63fe6ce
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/script.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/spinner.gif b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/spinner.gif
new file mode 100755 (executable)
index 0000000..85b99d4
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/spinner.gif differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/txt.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/txt.png
new file mode 100755 (executable)
index 0000000..813f712
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/txt.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/xls.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/xls.png
new file mode 100755 (executable)
index 0000000..b977d7e
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/xls.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/zip.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/zip.png
new file mode 100755 (executable)
index 0000000..fd4bbcc
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/images/zip.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/jqueryFileTree.css b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/jqueryFileTree.css
new file mode 100755 (executable)
index 0000000..01ff50e
--- /dev/null
@@ -0,0 +1,91 @@
+UL.jqueryFileTree {\r
+       font-family: Verdana, sans-serif;\r
+       font-size: 11px;\r
+       line-height: 18px;\r
+       padding: 0px;\r
+       margin: 0px;\r
+}\r
+\r
+UL.jqueryFileTree LI {\r
+       list-style: none;\r
+       padding: 0px;\r
+       padding-left: 20px;\r
+       margin: 0px;\r
+       white-space: nowrap;\r
+}\r
+\r
+UL.jqueryFileTree A {\r
+       color: #333;\r
+       text-decoration: none;\r
+       display: block;\r
+       padding: 0px 2px;\r
+}\r
+\r
+UL.jqueryFileTree A:hover {\r
+       background: #BDF;\r
+}\r
+\r
+/* Core Styles */\r
+.jqueryFileTree LI.directory { background: url(images/directory.png) left top no-repeat; }\r
+.jqueryFileTree LI.expanded { background: url(images/folder_open.png) left top no-repeat; }\r
+.jqueryFileTree LI.file { background: url(images/file.png) left top no-repeat; }\r
+.jqueryFileTree LI.wait { background: url(images/spinner.gif) left top no-repeat; }\r
+/* File Extensions*/\r
+.jqueryFileTree LI.ext_3gp { background: url(images/film.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_afp { background: url(images/code.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_afpa { background: url(images/code.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_asp { background: url(images/code.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_aspx { background: url(images/code.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_avi { background: url(images/film.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_bat { background: url(images/application.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_bmp { background: url(images/picture.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_c { background: url(images/code.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_cfm { background: url(images/code.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_cgi { background: url(images/code.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_com { background: url(images/application.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_cpp { background: url(images/code.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_css { background: url(images/css.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_doc { background: url(images/doc.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_exe { background: url(images/application.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_gif { background: url(images/picture.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_fla { background: url(images/flash.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_h { background: url(images/code.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_htm { background: url(images/html.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_html { background: url(images/html.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_jar { background: url(images/java.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_jpg { background: url(images/picture.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_jpeg { background: url(images/picture.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_js { background: url(images/script.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_lasso { background: url(images/code.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_log { background: url(images/txt.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_m4p { background: url(images/music.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_mov { background: url(images/film.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_mp3 { background: url(images/music.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_mp4 { background: url(images/film.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_mpg { background: url(images/film.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_mpeg { background: url(images/film.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_ogg { background: url(images/music.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_pcx { background: url(images/picture.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_pdf { background: url(images/pdf.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_php { background: url(images/php.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_png { background: url(images/picture.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_ppt { background: url(images/ppt.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_psd { background: url(images/psd.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_pl { background: url(images/script.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_py { background: url(images/script.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_rb { background: url(images/ruby.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_rbx { background: url(images/ruby.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_rhtml { background: url(images/ruby.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_rpm { background: url(images/linux.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_ruby { background: url(images/ruby.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_sql { background: url(images/db.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_swf { background: url(images/flash.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_tif { background: url(images/picture.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_tiff { background: url(images/picture.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_txt { background: url(images/txt.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_vb { background: url(images/code.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_wav { background: url(images/music.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_wmv { background: url(images/film.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_xls { background: url(images/xls.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_xml { background: url(images/code.png) left top no-repeat; }\r
+.jqueryFileTree LI.ext_zip { background: url(images/zip.png) left top no-repeat; }
\ No newline at end of file
index 1da65dfcb06d37e13ccb714ac7c1341bd8a363ae..1b5c4c084b0ab51fa69d9a9ce0324695b7a42057 100644 (file)
@@ -2,6 +2,7 @@
 <html>
 <head>
   <link rel="stylesheet" href="css/jquery.fileupload-ui.css"/>
+  <link rel="stylesheet" href="css/jqueryFileTree.css"/>
   <link rel="stylesheet" href="css/chosen-0.9.7.css"/>
   <link rel="stylesheet" href="css/jquery-ui-1.8.16.custom.css"/>
   <link rel="stylesheet" href="css/bootstrap.2.0.3.css">
                         "jquery.fileupload.ip":"jquery.fileupload-ip-1.0.6",
                         "jquery.fileupload.ui":"jquery.fileupload-ui-6.6.3",
                         "tmpl": "tmpl.min",
+                        "treeview": "jquery.treeview-1.5-pre",
+                        "treeview.async":"jquery.treeview.async-0.1",
+                        "jquery.treeview.edit": "jquery.treeview.edit",
+                        "jqueryFileTree": "jqueryFileTree-1.0.1",
                         "redback": "redback/redback",
                         "redback.roles": "redback/roles",
                         "redback.user": "redback/user",
index 1a80b424a90c8f0bc4574c81f5139f399216d27a..3282a8d8feb3769dc3f432a26463e70baba61f30 100644 (file)
@@ -16,7 +16,8 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knockout.simpleGrid"], function() {
+define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knockout.simpleGrid","treeview"
+  ,"treeview.async","jquery.treeview.edit","jqueryFileTree"], function() {
 
 
 
@@ -272,6 +273,20 @@ define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knock
 
                 if ($(e.target).attr("href")=="#artifact-details-file-content") {
                   $.log("file content:"+self.groupId+":"+self.artifactId+":"+self.version);
+
+                  var entriesUrl = "restServices/archivaServices/browseService/artifactContentEntries/"+encodeURIComponent(self.groupId);
+                  entriesUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(self.version);
+                  entriesUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository());
+                  //entriesUrl+="&p="+encodeURIComponent(artifactContentEntry.name);
+
+                  $("#main-content #artifact_content_tree").fileTree({
+                    script: entriesUrl,
+                    root: ""
+                       },function(file) {
+                         alert(file);
+                       });
+                  return;
+
                   var entriesUrl = "restServices/archivaServices/browseService/artifactContentEntries/"+encodeURIComponent(self.groupId);
                   entriesUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(self.version);
                   entriesUrl+="?repositoryId="+encodeURIComponent(self.repositoryId);
@@ -279,10 +294,12 @@ define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knock
                     type: "GET",
                     dataType: 'json',
                     success: function(data) {
+                      //$("#artifact-details-file-content").html($("#artifact_content_tmpl").tmpl());//{artifactContentEntries:mapArtifactContentEntries(data)}));
+                      //artifact_content_tmpl
                       var artifactContentEntryViewModel=
-                          new ArtifactContentEntryViewModel(self.groupId,self.artifactId,self.version,mapArtifactContentEntries(data));
-                      $("#artifact-details-file-content").html($("#artifact_content_main_tmpl").tmpl());
-                      ko.applyBindings(artifactContentEntryViewModel,mainContent.find("#artifact_file_content_div").get(0));
+                          new ArtifactContentEntryViewModel(self.groupId,self.artifactId,self.version,[]);
+                      artifactContentEntryViewModel.show();
+                      //ko.applyBindings(artifactContentEntryViewModel,mainContent.find("#artifact_file_content_div").get(0));
                     }
                   });
                 }
@@ -386,10 +403,11 @@ define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knock
 
   }
 
-  ArtifactContentEntry=function(name,file,depth){
-    this.name=name;
+  ArtifactContentEntry=function(text,file,depth,id){
+    this.text=text;
     this.file=file;
     this.depth=depth;
+    this.id=id;
   }
 
   mapArtifactContentEntries=function(data){
@@ -398,10 +416,10 @@ define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knock
     }
     if ( $.isArray(data)){
       return $.map(data,function(e){
-        return new ArtifactContentEntry(e.name,e.file,e.depth);
+        return new ArtifactContentEntry(e.text,e.file,e.depth,e.id);
       })
     }
-    return new ArtifactContentEntry(data.name,data.file,data.depth);
+    return new ArtifactContentEntry(data.text,data.file,data.depth,e.id);
   }
 
   ArtifactContentEntryViewModel=function(groupId,artifactId,version,artifactContentEntries){
@@ -410,7 +428,20 @@ define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knock
     this.artifactId=artifactId;
     this.version=version;
     this.artifactContentEntries=ko.observableArray(artifactContentEntries);
-    $.log("size:"+this.artifactContentEntries().length);
+    this.currentPath=ko.observable();
+
+    this.show=function(){
+      var entriesUrl = "restServices/archivaServices/browseService/artifactContentEntries/"+encodeURIComponent(self.groupId);
+      entriesUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(self.version);
+      entriesUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository());
+      //entriesUrl+="&p="+encodeURIComponent(artifactContentEntry.name);
+
+      $("#main-content #artifact_content_tree").fileTree({
+        script: entriesUrl
+               },function(file) {
+                 alert(file);
+               });
+    }
 
     entries=function(){
       return self.artifactContentEntries;
@@ -423,6 +454,7 @@ define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knock
       entriesUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(self.version);
       entriesUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository());
       entriesUrl+="&p="+encodeURIComponent(artifactContentEntry.name);
+      self.currentPath(artifactContentEntry.name);
       $.ajax(entriesUrl,{
         type: "GET",
         dataType: 'json',
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/jqueryFileTree-1.0.1.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/jqueryFileTree-1.0.1.js
new file mode 100755 (executable)
index 0000000..467eeea
--- /dev/null
@@ -0,0 +1,96 @@
+// jQuery File Tree Plugin
+//
+// Version 1.01
+//
+// Cory S.N. LaViska
+// A Beautiful Site (http://abeautifulsite.net/)
+// 24 March 2008
+//
+// Visit http://abeautifulsite.net/notebook.php?article=58 for more information
+//
+// Usage: $('.fileTreeDemo').fileTree( options, callback )
+//
+// Options:  root           - root folder to display; default = /
+//           script         - location of the serverside AJAX file to use; default = jqueryFileTree.php
+//           folderEvent    - event to trigger expand/collapse; default = click
+//           expandSpeed    - default = 500 (ms); use -1 for no animation
+//           collapseSpeed  - default = 500 (ms); use -1 for no animation
+//           expandEasing   - easing function to use on expand (optional)
+//           collapseEasing - easing function to use on collapse (optional)
+//           multiFolder    - whether or not to limit the browser to one subfolder at a time
+//           loadMessage    - Message to display while initial tree loads (can be HTML)
+//
+// History:
+//
+// 1.01 - updated to work with foreign characters in directory/file names (12 April 2008)
+// 1.00 - released (24 March 2008)
+//
+// TERMS OF USE
+// 
+// This plugin is dual-licensed under the GNU General Public License and the MIT License and
+// is copyright 2008 A Beautiful Site, LLC. 
+//
+if(jQuery) (function($){
+       
+       $.extend($.fn, {
+               fileTree: function(o, h) {
+                       // Defaults
+                       if( !o ) var o = {};
+                       if( o.root == undefined ) o.root = '/';
+                       if( o.script == undefined ) o.script = 'jqueryFileTree.php';
+                       if( o.folderEvent == undefined ) o.folderEvent = 'click';
+                       if( o.expandSpeed == undefined ) o.expandSpeed= 500;
+                       if( o.collapseSpeed == undefined ) o.collapseSpeed= 500;
+                       if( o.expandEasing == undefined ) o.expandEasing = null;
+                       if( o.collapseEasing == undefined ) o.collapseEasing = null;
+                       if( o.multiFolder == undefined ) o.multiFolder = true;
+                       if( o.loadMessage == undefined ) o.loadMessage = 'Loading...';
+                       
+                       $(this).each( function() {
+                               
+                               function showTree(c, t) {
+                                       $(c).addClass('wait');
+                                       $(".jqueryFileTree.start").remove();
+                                       $.get(o.script, { p: t }, function(data) {
+            $(c).find('.start').html('');
+            var htmlContent = $("#artifact_content_tree_partial" ).tmpl({artifactContentEntries:mapArtifactContentEntries(data)});
+                                               $(c).removeClass('wait').append(htmlContent);
+                                               if( o.root == t ) $(c).find('UL:hidden').show(); else $(c).find('UL:hidden').slideDown({ duration: o.expandSpeed, easing: o.expandEasing });
+                                               bindTree(c);
+                                       });
+                               }
+                               
+                               function bindTree(t) {
+                                       $(t).find('LI A').bind(o.folderEvent, function() {
+                                               if( $(this).parent().hasClass('directory') ) {
+                                                       if( $(this).parent().hasClass('collapsed') ) {
+                                                               // Expand
+                                                               if( !o.multiFolder ) {
+                                                                       $(this).parent().parent().find('UL').slideUp({ duration: o.collapseSpeed, easing: o.collapseEasing });
+                                                                       $(this).parent().parent().find('LI.directory').removeClass('expanded').addClass('collapsed');
+                                                               }
+                                                               $(this).parent().find('UL').remove(); // cleanup
+                                                               showTree( $(this).parent(), escape($(this).attr('rel')) );//.match( /.*\// )
+                                                               $(this).parent().removeClass('collapsed').addClass('expanded');
+                                                       } else {
+                                                               // Collapse
+                                                               $(this).parent().find('UL').slideUp({ duration: o.collapseSpeed, easing: o.collapseEasing });
+                                                               $(this).parent().removeClass('expanded').addClass('collapsed');
+                                                       }
+                                               } else {
+                                                       h($(this).attr('rel'));
+                                               }
+                                               return false;
+                                       });
+                                       // Prevent A from triggering the # on non-click events
+                                       if( o.folderEvent.toLowerCase != 'click' ) $(t).find('LI A').bind('click', function() { return false; });
+                               }
+                               // Loading message
+                               $(this).html('<ul class="jqueryFileTree start"><li class="wait">' + o.loadMessage + '<li></ul>');
+                               // Get the initial file list
+                               showTree( $(this), escape(o.root) );
+                       });
+               }
+       });
+       
+})(jQuery);
\ No newline at end of file
index 2c7c1d57d6162555e0250cbdf7850d79d5e210c4..5edbbb8b955238cb2bb3714e35008e70da3e6c80 100644 (file)
       </div>
 
       <div id="artifact-details-file-content" class="tab-pane">
+          <div id="artifact_content_tree">
+          </div>
       </div>
 
       <div id="artifact-details-used-by-content" class="tab-pane"></div>
 </script>
 
 <script id="artifact_content_tmpl" type="text/html">
-    <ul>
-      {{each(i, artifactContentEntry) artifactContentEntries()}}
-        <li data-bind="css: { 'browse-list': artifactContentEntry.file==false }">
-          <a href="#" data-bind="click: function(){displayPath(artifactContentEntry)}">${artifactContentEntry.name}</a>
-        </li>
-      {{/each}}
-    </ul>
+    <div id="artifact_content_tree">
+    </div>
+</script>
+
+<script id="artifact_content_tree_partial" type="text/html">
+  <ul class="jqueryFileTree" style="display: none;">
+    {{each artifactContentEntries}}
+    <li class="directory collapsed">
+      <a href="#" rel="${$value.text}/">${$value.text}</a>
+    </li>
+    {{/each}}
+  </ul>
 </script>
\ No newline at end of file