diff --git a/docs-web/src/main/java/com/sismics/docs/rest/resource/ThemeResource.java b/docs-web/src/main/java/com/sismics/docs/rest/resource/ThemeResource.java index abf6ee13..6e3f96a1 100644 --- a/docs-web/src/main/java/com/sismics/docs/rest/resource/ThemeResource.java +++ b/docs-web/src/main/java/com/sismics/docs/rest/resource/ThemeResource.java @@ -56,6 +56,8 @@ public class ThemeResource extends BaseResource { JsonObject themeConfig = getThemeConfig(); JsonObjectBuilder json = Json.createObjectBuilder(); json.add("name", themeConfig.getString("name", "Sismics Docs")); + json.add("color", themeConfig.getString("color", "#263238")); + json.add("css", themeConfig.getString("css", "")); return Response.ok().entity(json.build()).build(); } diff --git a/docs-web/src/main/webapp/src/app/docs/app.js b/docs-web/src/main/webapp/src/app/docs/app.js index 8c9d4fca..f68b8b72 100644 --- a/docs-web/src/main/webapp/src/app/docs/app.js +++ b/docs-web/src/main/webapp/src/app/docs/app.js @@ -13,7 +13,6 @@ angular.module('docs', * Configuring modules. */ .config(function($stateProvider, $httpProvider, RestangularProvider) { - // Configuring UI Router $stateProvider .state('main', { @@ -381,10 +380,15 @@ angular.module('docs', /** * Application initialization. */ -.run(function($rootScope, $state, $stateParams) { +.run(function($rootScope, $state, $stateParams, Restangular) { $rootScope.$state = $state; $rootScope.$stateParams = $stateParams; - $rootScope.pageTitle = 'Sismics Docs'; + + // Fetch the current theme configuration + $rootScope.appName = ''; + Restangular.one('theme').get().then(function(data) { + $rootScope.appName = data.name; + }); }) /** * Redirection support for ui-router. diff --git a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsTheme.js b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsTheme.js index 405d0066..02a06f9d 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsTheme.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsTheme.js @@ -3,19 +3,20 @@ /** * Settings theme page controller. */ -angular.module('docs').controller('SettingsTheme', function($scope, Restangular) { - // Fetch the current theme configuration - $scope.theme = { - color: $('.navbar').css('background-color') - }; +angular.module('docs').controller('SettingsTheme', function($scope, $rootScope, Restangular) { + // Fetch the current theme configuration + Restangular.one('theme').get().then(function(data) { + $scope.theme = data; + $rootScope.appName = $scope.theme.name; + }); - // Update the main color - $scope.updateColor = function(color) { - Restangular.one('theme').post('color', { - color: color - }).then(function() { - var stylesheet = $('#theme-stylesheet')[0]; - stylesheet.href = stylesheet.href.replace(/\?.*|$/, '?' + new Date().getTime()); - }); - } + // Update the theme + $scope.update = function() { + $scope.theme.name = $scope.theme.name.length == 0 ? 'Sismics Docs' : $scope.theme.name; + Restangular.one('theme').post('', $scope.theme).then(function() { + var stylesheet = $('#theme-stylesheet')[0]; + stylesheet.href = stylesheet.href.replace(/\?.*|$/, '?' + new Date().getTime()); + $rootScope.appName = $scope.theme.name; + }); + } }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/share/app.js b/docs-web/src/main/webapp/src/app/share/app.js index 9fe7cdfb..e9c69b98 100644 --- a/docs-web/src/main/webapp/src/app/share/app.js +++ b/docs-web/src/main/webapp/src/app/share/app.js @@ -95,7 +95,13 @@ angular.module('share', /** * Application initialization. */ -.run(function($rootScope, $state, $stateParams) { +.run(function($rootScope, $state, $stateParams, Restangular) { $rootScope.$state = $state; $rootScope.$stateParams = $stateParams; + + // Fetch the current theme configuration + $rootScope.appName = ''; + Restangular.one('theme').get().then(function(data) { + $rootScope.appName = data.name; + }); }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/index.html b/docs-web/src/main/webapp/src/index.html index 5b92a0b1..d4cce917 100644 --- a/docs-web/src/main/webapp/src/index.html +++ b/docs-web/src/main/webapp/src/index.html @@ -1,7 +1,7 @@
-