mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-20 07:53:38 +02:00
Added Auto-route language support for documentation.
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
module.exports = function DocsCtrl($rootScope, $scope, $window, $location) {
|
||||
module.exports =
|
||||
function DocsCtrl($rootScope, $scope, $window, $location) {
|
||||
|
||||
$scope.goBack = function () {
|
||||
$window.history.back()
|
||||
$scope.goBack = function () {
|
||||
$window.history.back()
|
||||
}
|
||||
|
||||
$scope.goHome = function () {
|
||||
$location.path('/docs/index')
|
||||
}
|
||||
|
||||
$rootScope.$on("$routeChangeError",
|
||||
function (event, current, previous, rejection) {
|
||||
console.log("ROUTE CHANGE ERROR: " + rejection)
|
||||
console.log('event', event)
|
||||
console.log('current', current)
|
||||
console.log('previous', previous)
|
||||
})
|
||||
}
|
||||
|
||||
$scope.goHome = function () {
|
||||
$location.path('/docs/en/index')
|
||||
}
|
||||
|
||||
$rootScope.$on("$routeChangeError",
|
||||
function (event, current, previous, rejection) {
|
||||
console.log("ROUTE CHANGE ERROR: " + rejection)
|
||||
console.log('event', event)
|
||||
console.log('current', current)
|
||||
console.log('previous', previous)
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,14 +1,34 @@
|
||||
require('./docs.css')
|
||||
|
||||
module.exports = angular.module('stf.help.docs', [])
|
||||
.config(['$routeProvider', function ($routeProvider) {
|
||||
module.exports = angular.module('stf.help.docs', [
|
||||
require('stf/language').name
|
||||
])
|
||||
.config(function ($routeProvider, languageProvider) {
|
||||
// TODO: Solutions to the lang problem
|
||||
//
|
||||
// 1) Use $route inside a controller instead of $routeProvider
|
||||
// 2) Use $routeProvider along with languageProvider
|
||||
// In this case languageProvider depends on Settings and gettext
|
||||
// which are not providers
|
||||
// 3) Easiest way is to use AppState
|
||||
// 4) It needs a fallback if the language doesn't exists, it can be made
|
||||
// in Express side.
|
||||
|
||||
$routeProvider.when('/docs/:lang/:document*', {
|
||||
templateUrl: function (params) {
|
||||
var document = params.document.replace('.md', '')
|
||||
return '/static/docs/' + params.lang + '/' + document
|
||||
}
|
||||
})
|
||||
$routeProvider
|
||||
.when('/docs/:document*', {
|
||||
templateUrl: function (params) {
|
||||
var lang = languageProvider.$get().selectedLanguage
|
||||
var document = params.document.replace('.md', '')
|
||||
return '/static/docs/' + lang + '/' + document
|
||||
}
|
||||
})
|
||||
//.when('/docs/:lang/:document*', {
|
||||
// templateUrl: function (params) {
|
||||
// var lang = params.lang
|
||||
// var document = params.document.replace('.md', '')
|
||||
// return '/static/docs/' + lang + '/' + document
|
||||
// }
|
||||
//})
|
||||
|
||||
}])
|
||||
})
|
||||
.controller('DocsCtrl', require('./docs-controller'))
|
||||
|
||||
Reference in New Issue
Block a user