Skip to content
This repository was archived by the owner on Feb 1, 2018. It is now read-only.

Commit 3f1c77f

Browse files
committed
Set page for version route
1 parent eef5762 commit 3f1c77f

4 files changed

Lines changed: 68 additions & 10 deletions

File tree

dist/js/main.js

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,8 @@
307307
resolve: resolve
308308
})
309309
.when('/:version', {
310-
templateUrl: flatdocURL,
311-
controller: 'URLCtrl',
312-
resolve: resolve
310+
templateUrl: mainURL,
311+
controller: 'VersionCtrl'
313312
})
314313
.when('/', {
315314
templateUrl: mainURL,
@@ -601,7 +600,36 @@
601600
}
602601
}
603602
};
603+
Route.VersionCtrl = function($scope, $route, $location, $filter, $timeout, $rootScope) {
604+
$scope.docbaseOptions = Docbase.options;
605+
606+
if (Docbase.options.indexType === 'markdown') {
607+
var path = Docbase.options.indexSrc;
608+
if (endsWith(path, '.md')) {
609+
path = path.substring(0, path.length - 3);
610+
}
611+
if (path.charAt(0) !== '/') {
612+
path = '/' + path;
613+
}
604614

615+
$location.path(path);
616+
} else {
617+
var onMapped = function() {
618+
$timeout(function() {
619+
$rootScope.navbarHtml = Docbase.options.navbarHtml;
620+
$rootScope.logoSrc = Docbase.options.logoSrc;
621+
$scope.map = Docbase.map;
622+
$scope.versions = Object.keys($scope.map);
623+
$scope.currentVersion = $route.current.params.version;
624+
});
625+
};
626+
if (Docbase.map) {
627+
onMapped();
628+
} else {
629+
jWindow.on('mapped', onMapped);
630+
}
631+
}
632+
};
605633
Route.updatePath = function(params) {
606634
var map = Docbase.map;
607635
var version = params.version;
@@ -787,6 +815,7 @@
787815
var angApp = angular.module('docbaseApp', ['ngRoute'], function() {})
788816
.factory('FlatdocService', ['$q', '$route', '$location', '$anchorScroll', '$http', Route.fetch])
789817
.controller('URLCtrl', ['$scope', '$location', '$filter', 'data', 'commits', '$timeout', Route.URLCtrl])
818+
.controller('VersionCtrl', ['$scope', '$route', '$location', '$filter', '$timeout', '$rootScope', Route.VersionCtrl])
790819
.controller('MainCtrl', ['$scope', '$location', '$timeout', '$rootScope', Route.mainCtrl])
791820
.config(['$routeProvider', '$locationProvider', Route.config])
792821
.run(

0 commit comments

Comments
 (0)