#3
authorCameron Ball <c.ball1729@gmail.com>
Sun, 22 Feb 2015 10:26:28 +0000 (18:26 +0800)
committerCameron Ball <c.ball1729@gmail.com>
Sun, 22 Feb 2015 10:26:28 +0000 (18:26 +0800)
app/components/simfiles/latest-pack.html
app/components/simfiles/latestpack-directive.js
app/components/simfiles/most-downloaded.html
app/components/simfiles/mostdownloaded-directive.js
app/components/simfiles/pack-directive.js
app/components/simfiles/simfile.html

index f47340b..4606ba7 100644 (file)
@@ -1,5 +1,7 @@
 <h2>Latest Pack</h2>
-<img class="banner" ng-src="{{rockEndpoint}}{{pack.banner}}" alt="swage" />
+<a ng-href="{{pack.mirrors[pack.mirrors.length-1].uri}}">
+    <img class="banner" ng-src="{{rockEndpoint}}{{pack.banner}}" alt="banner" />
+</a>
 <table>
     <tr>
         <th>Title:</th>
index 02ff3de..8ee80bb 100644 (file)
@@ -66,10 +66,29 @@ directive('latestPack', ['rockEndpoint', '$http', 'UserService', 'HelloService',
                         }
                     });
                 };
-                $scope.asdf = 'hello';
+
+                var slugify = function(text)
+                {
+                  return text.toString().toLowerCase()
+                    .replace(/\s+/g, '-')           // Replace spaces with -
+                    .replace(/[^\w\-]+/g, '')       // Remove all non-word chars
+                    .replace(/\-\-+/g, '-')         // Replace multiple - with single -
+                    .replace(/^-+/, '')             // Trim - from start of text
+                    .replace(/-+$/, '');            // Trim - from end of text
+                };
+
                 $scope.pack = data;
                 $scope.rockEndpoint = rockEndpoint;
                 $scope.contributors = data.contributors.join(', ');
+                
+                if($scope.pack.mirrors[$scope.pack.mirrors.length - 1].source !== 'Permalink')
+                {
+                    $scope.pack.mirrors.push({
+                        source: 'Permalink',
+                        uri: "#/pack/" + $scope.pack.hash.substr(0,8) + "/" + slugify($scope.pack.title)
+                   });
+                }
+                
                 $rootScope.$$phase || $rootScope.$apply();
             });
         }
index 18bca0f..5da49ac 100644 (file)
@@ -1,5 +1,7 @@
 <h2>Most Popular</h2>
-<img class="banner" ng-src="{{rockEndpoint}}{{banner}}" alt="swage" />
+<a ng-href="{{packOrSimfile.mirrors[packOrSimfile.mirrors.length-1].uri}}">
+    <img class="banner" ng-src="{{rockEndpoint}}{{banner}}" alt="banner" />
+</a>
 <table>
     <tr>
         <th>Title:</th>
index 3d1f40f..9ccd35c 100644 (file)
@@ -79,6 +79,25 @@ directive('mostDownloaded', ['rockEndpoint', '$http', 'UserService', 'UiSettings
                 $scope.banner = data.banner;
                 $scope.packOrSimfile = data;
                 
+                var slugify = function(text)
+                {
+                  return text.toString().toLowerCase()
+                    .replace(/\s+/g, '-')           // Replace spaces with -
+                    .replace(/[^\w\-]+/g, '')       // Remove all non-word chars
+                    .replace(/\-\-+/g, '-')         // Replace multiple - with single -
+                    .replace(/^-+/, '')             // Trim - from start of text
+                    .replace(/-+$/, '');            // Trim - from end of text
+                };
+
+                if($scope.packOrSimfile.mirrors[$scope.packOrSimfile.mirrors.length - 1].source !== 'Permalink')
+                {
+                    $scope.packOrSimfile.mirrors.push({
+                        source: 'Permalink',
+                        uri: "#/pack/" + $scope.packOrSimfile.hash.substr(0,8) + "/" + slugify($scope.packOrSimfile.title)
+                   });
+                }
+                
+                //this is here to cover the case where a simfile is the most downloaded thing
                 if(data.contributors)
                 {
                     $scope.contributors = data.contributors.join(', ');
index 64f6368..2283023 100644 (file)
@@ -25,7 +25,7 @@ directive('pack', ['$rootScope', 'UserService', 'HelloService', 'rockEndpoint',
                 .replace(/\-\-+/g, '-')         // Replace multiple - with single -
                 .replace(/^-+/, '')             // Trim - from start of text
                 .replace(/-+$/, '');            // Trim - from end of text
-            }
+            };
 
             var filesizeBytes = function(size)  
             {  
@@ -91,10 +91,10 @@ directive('pack', ['$rootScope', 'UserService', 'HelloService', 'rockEndpoint',
             
             $scope.contributors = getContributors($scope.pack.contributors);
             
-            if($scope.pack.mirrors[$scope.pack.mirrors.length - 1].source !== 'Standalone Link')
+            if($scope.pack.mirrors[$scope.pack.mirrors.length - 1].source !== 'Permalink')
             {
                 $scope.pack.mirrors.push({
-                    source: 'Standalone Link',
+                    source: 'Permalink',
                     uri: "#/pack/" + $scope.pack.hash.substr(0,8) + "/" + slugify($scope.pack.title)
                });
             }
index 8612115..e2c4a12 100644 (file)
@@ -1,4 +1,4 @@
-<img ng-src="{{rockEndpoint + simfile.banner}}" alt="swage" />
+<img ng-src="{{rockEndpoint + simfile.banner}}" alt="banner" />
 <table>
     <tr>
         <th>Title:</th>
@@ -22,7 +22,7 @@
         <th>Double:</th>
         <td>
             <ul>
-                <li ng-repeat="stepchart in steps.double">
+                <li ng-repeat="stepchart in simfile.steps.double">
                     <div class="difficulty {{stepchart.difficulty}}">{{stepchart.rating}} ({{stepchart.artist}})</div>
                 </li>
             </ul>