Individual pages for packs.
authorCameron Ball <cameron@getapproved.com.au>
Tue, 23 Dec 2014 07:01:52 +0000 (15:01 +0800)
committerCameron Ball <cameron@getapproved.com.au>
Tue, 23 Dec 2014 07:01:52 +0000 (15:01 +0800)
app/components/simfiles/pack-directive.js
app/components/simfiles/pack.html
app/divinelegy.js
app/pages/packs/packs.html
app/pages/packs/packs.js

index b9b29d0..64f6368 100644 (file)
@@ -16,7 +16,17 @@ directive('pack', ['$rootScope', 'UserService', 'HelloService', 'rockEndpoint',
             {
                 if(contribs.length) return contribs.join(', ');
             };
-                                    
+            
+            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
+            }
+
             var filesizeBytes = function(size)  
             {  
                 //units are already bytes
@@ -80,6 +90,15 @@ directive('pack', ['$rootScope', 'UserService', 'HelloService', 'rockEndpoint',
             };
             
             $scope.contributors = getContributors($scope.pack.contributors);
+            
+            if($scope.pack.mirrors[$scope.pack.mirrors.length - 1].source !== 'Standalone Link')
+            {
+                $scope.pack.mirrors.push({
+                    source: 'Standalone Link',
+                    uri: "#/pack/" + $scope.pack.hash.substr(0,8) + "/" + slugify($scope.pack.title)
+               });
+            }
+            
             $scope.rockEndpoint = rockEndpoint;
         }
     };
index 25e9285..9515c32 100644 (file)
@@ -14,7 +14,7 @@
         <td>{{pack.size}}</td>
     </tr>
     <tr>
-        <th>Uploaded Date:</th>
+        <th>Uploaded:</th>
         <td>{{pack.uploaded}}</td>
     </tr>
     <tr ng-if="pack.mirrors">
index 2e2a99f..c928879 100644 (file)
@@ -45,7 +45,7 @@ config(['$routeProvider', '$locationProvider', function($routeProvider) {
     }).
     when('/pack/:hash/:name',
     {
-        templateUrl: 'pages/packs/pack.html',
+        templateUrl: 'pages/packs/packs.html',
         controller: 'PackController'
     }).
     when('/packs/test',
index 0182864..8ded94d 100644 (file)
@@ -1,20 +1,20 @@
-<div id="filters">\r
+<div ng-if="packList && packList.length" d="filters">\r
     <div id="text-filters">\r
-        <input type="text" ng-model="packTitleFilterKeyword" placeholder="Pack Title"/>\r
-        <input type="text" ng-model="artistFilterKeyword" placeholder="Song Artist"/>\r
-        <input type="text" ng-model="songTitleFilterKeyword" placeholder="Song Title"/>\r
-        <input type="text" ng-model="stepArtistFilterKeyword" placeholder="Step Artist"/>\r
-        <input type="text" ng-model="ratingFilterKeyword" placeholder="Block Rating"/>\r
+        <input type="text" ng-model="$parent.packTitleFilterKeyword" placeholder="Pack Title"/>\r
+        <input type="text" ng-model="$parent.artistFilterKeyword" placeholder="Song Artist"/>\r
+        <input type="text" ng-model="$parent.songTitleFilterKeyword" placeholder="Song Title"/>\r
+        <input type="text" ng-model="$parent.stepArtistFilterKeyword" placeholder="Step Artist"/>\r
+        <input type="text" ng-model="$parent.ratingFilterKeyword" placeholder="Block Rating"/>\r
     </div>\r
     <div id="select-filters">\r
-        <select ng-model="modeFilterKeyword">\r
+        <select ng-model="$parent.modeFilterKeyword">\r
             <option value="Any" disabled selected>Mode</option>\r
             <option value="Any">Any</option>\r
             <option value="single">Singles</option>\r
             <option value="double">Doubles</option>\r
         </select>\r
 \r
-        <select ng-model="difficultyFilterKeyword">\r
+        <select ng-model="$parent.difficultyFilterKeyword">\r
             <option value="Any" disabled selected>Difficulty</option>\r
             <option value="Any">Any</option>\r
             <option value="Novice">Novice</option>\r
             <option value="Expert">Expert</option>\r
         </select>\r
 \r
-        <select ng-model="fgChangesFilterKeyword">\r
+        <select ng-model="$parent.fgChangesFilterKeyword">\r
             <option value="Any" disabled selected>FG Changes</option>\r
             <option value="Any">Any</option>\r
             <option value="Yes">Yes</option>\r
             <option value="No">No</option>\r
         </select>\r
 \r
-        <select ng-model="bgChangesFilterKeyword">\r
+        <select ng-model="$parent.bgChangesFilterKeyword">\r
             <option value="Any" disabled selected>BG Changes</option>\r
             <option value="Any">Any</option>\r
             <option value="Yes">Yes</option>\r
             <option value="No">No</option>\r
         </select>\r
 \r
-        <select ng-model="bpmChangesFilterKeyword">\r
+        <select ng-model="$parent.bpmChangesFilterKeyword">\r
             <option value="Any" disabled selected>BPM Changes</option>\r
             <option value="Any">Any</option>\r
             <option value="Yes">Yes</option>\r
@@ -47,7 +47,7 @@
     </div>\r
 </div>\r
 \r
-<accordion close-others="false">\r
+<accordion ng-if="packList && packList.length" close-others="false">\r
     <accordion-group class         = "simfileListing"\r
                      is-open       = "isOpen"\r
                      ng-mouseover  = "beast = true"\r
@@ -64,3 +64,9 @@
     </div>\r
 </accordion>\r
 \r
+<h1 ng-if="pack">{{pack.title}}</h1>\r
+<div ng-if="pack" class="simfileListing">\r
+    <!-- rofl -->\r
+    <pack pack="pack" />\r
+</div>\r
+\r
index 42dc9ff..d1b48ac 100644 (file)
@@ -2,9 +2,8 @@
 
 angular.module("DivinElegy.pages.packs", ["DivinElegy.components.simfiles","DivinElegy.components.user","DivinElegy.components.config","DivinElegy.components.ui", "ui.bootstrap"])
 
-.controller("PackController", ['$scope', '$rootScope', 'rockEndpoint', 'SimfileService', 'UserService', 'UiSettingsService', 'HelloService', 'filterFilter', '$routeParams', function($scope, $rootScope, rockEndpoint, SimfileService, UserService, UiSettingsService, HelloService, filterFilter, $routeParams)
+.controller("PackController", ['$scope', 'SimfileService', 'UiSettingsService', 'filterFilter', '$routeParams', '$location', function($scope, SimfileService, UiSettingsService, filterFilter, $routeParams, $location)
 {
-    $scope.rockEndpoint = rockEndpoint;
     $scope.packTitleFilterKeyword = null;
     $scope.artistFilterKeyWord = null;
     $scope.songTitleFilterKeyword = null;
@@ -120,7 +119,19 @@ angular.module("DivinElegy.pages.packs", ["DivinElegy.components.simfiles","Divi
     {
         if($routeParams.hash)
         {
-            $scope.swageVar = 'duh herro'
+            if($routeParams.hash.length < 8) $location.path('/');
+            
+            for(var i=0; i<packs.length; i++)
+            {
+                if(packs[i].hash.substring(0, $routeParams.hash.length) == $routeParams.hash)
+                {
+                    $scope.pack = packs[i];
+                    break;
+                }
+            }
+
+//            //TODO: 404 page?
+//            if(!$scope.pack) $location.path('/');
         } else {
             $scope.pageSize = UiSettingsService.getDirective('simfilesPerPage');
             $scope.currentPage = 1;