]> source.dussan.org Git - archiva.git/commitdiff
start using sammy for navigation while browsing tru the ui
authorOlivier Lamy <olamy@apache.org>
Wed, 11 Jul 2012 10:32:34 +0000 (10:32 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 11 Jul 2012 10:32:34 +0000 (10:32 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1360109 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js

index 639edc1e216ad4fa9d4a4a5d666d64fafa75c965..d4edb8141ff6e33c9703b5a741d7b6644e29b962 100644 (file)
@@ -64,29 +64,8 @@ function() {
       resetPasswordForm(resetPassword);
       return;
     }
-
-    var artifact= $.urlParam("artifact");
-    var repositoryId = $.urlParam("repositoryId");
-    // format groupId:artifactId org.apache.maven.plugins:maven-jar-plugin
-    // or  groupId:artifactId:version org.apache.maven.plugins:maven-jar-plugin:2.3.1
-    // repository in param repositoryId
-    if (artifact){
-      if ( artifact.indexOf(':')>=0){
-        var splitted = artifact.split(':');
-        $.log("splitted.length:"+splitted.length);
-        if(splitted.length==2){
-          displayBrowseArtifactDetail(splitted[0],splitted[1],null,null);
-          return;
-        } else if (splitted.length==3) {
-          generalDisplayArtifactDetailsVersionView(splitted[0],splitted[1],splitted[2],repositoryId);
-          return;
-        } else {
-          displayWarningMessage( $.i18n.prop("shortcut.artifact.illegal"));
-        }
-      }
-    }
     // by default display search screen
-    displaySearch();
+    window.sammyArchivaApplication.setLocation("#search");
   }
 
   hasKarma=function(karmaName){
@@ -256,6 +235,30 @@ function() {
       this.activeMenuId = ko.observable();
           
       window.sammyArchivaApplication = Sammy(function () {
+                // #artifact-(optionnal repositoryId)
+                // format groupId:artifactId org.apache.maven.plugins:maven-jar-plugin
+                // or  groupId:artifactId:version org.apache.maven.plugins:maven-jar-plugin:2.3.1
+                this.get('#artifact/:groupId/:artifactId',function(context){
+                  var groupId= this.params['groupId'];
+                  var artifactId= this.params['artifactId'];
+                  $.log("get #artifact:"+groupId+":"+artifactId);
+                  goToBrowseArtifactDetail(groupId,artifactId);//,null,null);
+                  return;
+
+                });
+                this.get('#artifact:repositoryId/:groupId/:artifactId/:version',function(context){
+
+                  var repositoryId = this.params['repositoryId'];
+                  var groupId= this.params['groupId'];
+                  var artifactId= this.params['artifactId'];
+                  var version= this.params['version'];
+
+                  if(!version){
+                    displayBrowseArtifactDetail(splitted[0],splitted[1]);//,null,null);
+                  } else {
+                    generalDisplayArtifactDetailsVersionView(groupId,artifactId,version,repositoryId);
+                  }
+                });
                 this.get('#browse/:groupId',function(context){
                   var groupId = this.params['groupId'];
                   if (groupId){
@@ -274,7 +277,7 @@ function() {
                     });
                     
                 });
-                this.get('', function () { this.app.runRoute('get', '#Search') });
+                this.get('', function () { this.app.runRoute('get', '#search') });
           } );
       sammyArchivaApplication.run();
   }
index 98299440ac6ddb13c2ee09f9374d7723013de244..54d4ad6a4cb9239f28335b7f2e94e878a0a57a2b 100644 (file)
@@ -59,6 +59,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
       $.log("displayProjectEntry:"+id+",groupId:"+self.groupId+",values:"+values);
 
       displayArtifactDetail(self.groupId,values,self);
+      //window.sammyArchivaApplication.setLocation("#artifact/"+self.groupId+"/"+values);
 
     }
 
@@ -829,6 +830,12 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
   }
 
   displayBrowseArtifactDetail=function(groupId, artifactId){
+    window.sammyArchivaApplication.setLocation("#artifact/"+groupId+"/"+artifactId);
+    //displayArtifactDetail(groupId,artifactId,null,null);
+  }
+
+  goToBrowseArtifactDetail=function(groupId, artifactId){
+    $.log("displayBrowseArtifactDetail");
     displayBrowseGroupId(groupId);
     displayArtifactDetail(groupId,artifactId,null,null);
   }