From ae566018d655b874c2c9a8a5646f1f6486ddc67d Mon Sep 17 00:00:00 2001 From: jendib Date: Sun, 23 Feb 2014 02:28:44 +0100 Subject: [PATCH] Gruntification --- docs-web/pom.xml | 38 +++++- docs-web/src/main/webapp/.gitignore | 6 +- docs-web/src/main/webapp/Gruntfile.js | 122 ++++++++++++++++++ .../webapp/app/docs/controller/FileView.js | 98 -------------- .../app/docs/controller/SettingsDefault.js | 7 - .../webapp/app/share/controller/FileView.js | 98 -------------- .../main/webapp/app/share/controller/Main.js | 7 - docs-web/src/main/webapp/package.json | 24 ++++ .../src/main/webapp/{ => src}/app/docs/app.js | 4 +- .../{ => src}/app/docs/controller/Document.js | 2 +- .../app/docs/controller/DocumentDefault.js | 2 +- .../app/docs/controller/DocumentEdit.js | 4 +- .../app/docs/controller/DocumentView.js | 2 +- .../src/app/docs/controller/FileModalView.js | 83 ++++++++++++ .../src/app/docs/controller/FileView.js | 21 +++ .../{ => src}/app/docs/controller/Login.js | 2 +- .../{ => src}/app/docs/controller/Main.js | 2 +- .../app/docs/controller/Navigation.js | 2 +- .../{ => src}/app/docs/controller/Settings.js | 2 +- .../app/docs/controller/SettingsAccount.js | 2 +- .../app/docs/controller/SettingsDefault.js | 7 + .../app/docs/controller/SettingsLog.js | 2 +- .../app/docs/controller/SettingsSession.js | 2 +- .../app/docs/controller/SettingsUser.js | 2 +- .../app/docs/controller/SettingsUserEdit.js | 2 +- .../{ => src}/app/docs/controller/Tag.js | 2 +- .../{ => src}/app/docs/directive/File.js | 2 +- .../app/docs/directive/InlineEdit.js | 2 +- .../{ => src}/app/docs/directive/SelectTag.js | 2 +- .../{ => src}/app/docs/filter/Newline.js | 2 +- .../{ => src}/app/docs/filter/Shorten.js | 2 +- .../webapp/{ => src}/app/docs/service/Tag.js | 2 +- .../webapp/{ => src}/app/docs/service/User.js | 2 +- .../main/webapp/{ => src}/app/share/app.js | 4 +- .../src/app/share/controller/FileModalView.js | 83 ++++++++++++ .../src/app/share/controller/FileView.js | 21 +++ .../webapp/src/app/share/controller/Main.js | 7 + .../{ => src}/app/share/controller/Share.js | 2 +- .../webapp/src/app/share/filter/Newline.js | 13 ++ .../src/main/webapp/{ => src}/favicon.png | Bin .../fonts/glyphicons-halflings-regular.eot | Bin .../fonts/glyphicons-halflings-regular.svg | 0 .../fonts/glyphicons-halflings-regular.ttf | Bin .../fonts/glyphicons-halflings-regular.woff | Bin .../src/main/webapp/{ => src}/img/alpha.png | Bin .../main/webapp/{ => src}/img/flag/eng.png | Bin .../main/webapp/{ => src}/img/flag/fra.png | Bin .../main/webapp/{ => src}/img/flag/jpn.png | Bin .../img/glyphicons-halflings-white.png | Bin .../{ => src}/img/glyphicons-halflings.png | Bin .../src/main/webapp/{ => src}/img/hue.png | Bin .../src/main/webapp/{ => src}/img/loader.gif | Bin .../main/webapp/{ => src}/img/saturation.png | Bin docs-web/src/main/webapp/{ => src}/index.html | 11 +- .../{ => src}/lib/angular.colorpicker.js | 0 .../src/main/webapp/{ => src}/lib/angular.js | 38 +++--- .../{ => src}/lib/angular.restangular.js | 0 .../lib/angular.sanitize.js} | 0 .../lib/angular.touch.js} | 0 .../{ => src}/lib/angular.ui-bootstrap.js | 0 .../webapp/{ => src}/lib/angular.ui-router.js | 0 .../{ => src}/lib/angular.ui-sortable.js | 0 .../webapp/{ => src}/lib/angular.ui-utils.js | 0 .../main/webapp/{ => src}/lib/colorpicker.js | 0 .../src/main/webapp/{ => src}/lib/jquery.js | 0 .../main/webapp/{ => src}/lib/jquery.ui.js | 0 .../src/main/webapp/{ => src}/lib/less.js | 0 .../main/webapp/{ => src}/lib/underscore.js | 0 .../webapp/{ => src}/locale/messages.en.js | 0 .../partial/docs/directive.selecttag.html | 0 .../partial/docs/document.default.html | 0 .../{ => src}/partial/docs/document.edit.html | 0 .../{ => src}/partial/docs/document.html | 0 .../partial/docs/document.share.html | 0 .../{ => src}/partial/docs/document.view.html | 2 +- .../{ => src}/partial/docs/file.view.html | 2 +- .../webapp/{ => src}/partial/docs/login.html | 0 .../webapp/{ => src}/partial/docs/main.html | 0 .../partial/docs/settings.account.html | 0 .../partial/docs/settings.default.html | 0 .../{ => src}/partial/docs/settings.html | 0 .../{ => src}/partial/docs/settings.log.html | 0 .../partial/docs/settings.session.html | 0 .../partial/docs/settings.user.edit.html | 0 .../{ => src}/partial/docs/settings.user.html | 0 .../webapp/{ => src}/partial/docs/tag.html | 0 .../webapp/{ => src}/partial/share/403.html | 0 .../{ => src}/partial/share/file.view.html | 2 +- .../webapp/{ => src}/partial/share/main.html | 0 .../webapp/{ => src}/partial/share/share.html | 2 +- docs-web/src/main/webapp/{ => src}/share.html | 13 +- .../main/webapp/{ => src}/style/bootstrap.css | 0 .../webapp/{ => src}/style/colorpicker.css | 0 .../src/main/webapp/{ => src}/style/main.less | 0 94 files changed, 488 insertions(+), 271 deletions(-) create mode 100644 docs-web/src/main/webapp/Gruntfile.js delete mode 100644 docs-web/src/main/webapp/app/docs/controller/FileView.js delete mode 100644 docs-web/src/main/webapp/app/docs/controller/SettingsDefault.js delete mode 100644 docs-web/src/main/webapp/app/share/controller/FileView.js delete mode 100644 docs-web/src/main/webapp/app/share/controller/Main.js create mode 100644 docs-web/src/main/webapp/package.json rename docs-web/src/main/webapp/{ => src}/app/docs/app.js (98%) rename docs-web/src/main/webapp/{ => src}/app/docs/controller/Document.js (95%) rename docs-web/src/main/webapp/{ => src}/app/docs/controller/DocumentDefault.js (61%) rename docs-web/src/main/webapp/{ => src}/app/docs/controller/DocumentEdit.js (96%) rename docs-web/src/main/webapp/{ => src}/app/docs/controller/DocumentView.js (96%) create mode 100644 docs-web/src/main/webapp/src/app/docs/controller/FileModalView.js create mode 100644 docs-web/src/main/webapp/src/app/docs/controller/FileView.js rename docs-web/src/main/webapp/{ => src}/app/docs/controller/Login.js (81%) rename docs-web/src/main/webapp/{ => src}/app/docs/controller/Main.js (70%) rename docs-web/src/main/webapp/{ => src}/app/docs/controller/Navigation.js (93%) rename docs-web/src/main/webapp/{ => src}/app/docs/controller/Settings.js (65%) rename docs-web/src/main/webapp/{ => src}/app/docs/controller/SettingsAccount.js (84%) create mode 100644 docs-web/src/main/webapp/src/app/docs/controller/SettingsDefault.js rename docs-web/src/main/webapp/{ => src}/app/docs/controller/SettingsLog.js (66%) rename docs-web/src/main/webapp/{ => src}/app/docs/controller/SettingsSession.js (83%) rename docs-web/src/main/webapp/{ => src}/app/docs/controller/SettingsUser.js (82%) rename docs-web/src/main/webapp/{ => src}/app/docs/controller/SettingsUserEdit.js (92%) rename docs-web/src/main/webapp/{ => src}/app/docs/controller/Tag.js (95%) rename docs-web/src/main/webapp/{ => src}/app/docs/directive/File.js (88%) rename docs-web/src/main/webapp/{ => src}/app/docs/directive/InlineEdit.js (96%) rename docs-web/src/main/webapp/{ => src}/app/docs/directive/SelectTag.js (95%) rename docs-web/src/main/webapp/{ => src}/app/docs/filter/Newline.js (75%) rename docs-web/src/main/webapp/{ => src}/app/docs/filter/Shorten.js (77%) rename docs-web/src/main/webapp/{ => src}/app/docs/service/Tag.js (79%) rename docs-web/src/main/webapp/{ => src}/app/docs/service/User.js (90%) rename docs-web/src/main/webapp/{ => src}/app/share/app.js (97%) create mode 100644 docs-web/src/main/webapp/src/app/share/controller/FileModalView.js create mode 100644 docs-web/src/main/webapp/src/app/share/controller/FileView.js create mode 100644 docs-web/src/main/webapp/src/app/share/controller/Main.js rename docs-web/src/main/webapp/{ => src}/app/share/controller/Share.js (88%) create mode 100644 docs-web/src/main/webapp/src/app/share/filter/Newline.js rename docs-web/src/main/webapp/{ => src}/favicon.png (100%) rename docs-web/src/main/webapp/{ => src}/fonts/glyphicons-halflings-regular.eot (100%) rename docs-web/src/main/webapp/{ => src}/fonts/glyphicons-halflings-regular.svg (100%) rename docs-web/src/main/webapp/{ => src}/fonts/glyphicons-halflings-regular.ttf (100%) rename docs-web/src/main/webapp/{ => src}/fonts/glyphicons-halflings-regular.woff (100%) rename docs-web/src/main/webapp/{ => src}/img/alpha.png (100%) rename docs-web/src/main/webapp/{ => src}/img/flag/eng.png (100%) rename docs-web/src/main/webapp/{ => src}/img/flag/fra.png (100%) rename docs-web/src/main/webapp/{ => src}/img/flag/jpn.png (100%) rename docs-web/src/main/webapp/{ => src}/img/glyphicons-halflings-white.png (100%) rename docs-web/src/main/webapp/{ => src}/img/glyphicons-halflings.png (100%) rename docs-web/src/main/webapp/{ => src}/img/hue.png (100%) rename docs-web/src/main/webapp/{ => src}/img/loader.gif (100%) rename docs-web/src/main/webapp/{ => src}/img/saturation.png (100%) rename docs-web/src/main/webapp/{ => src}/index.html (93%) rename docs-web/src/main/webapp/{ => src}/lib/angular.colorpicker.js (100%) rename docs-web/src/main/webapp/{ => src}/lib/angular.js (99%) rename docs-web/src/main/webapp/{ => src}/lib/angular.restangular.js (100%) rename docs-web/src/main/webapp/{lib/angular-sanitize.js => src/lib/angular.sanitize.js} (100%) rename docs-web/src/main/webapp/{lib/angular-touch.js => src/lib/angular.touch.js} (100%) rename docs-web/src/main/webapp/{ => src}/lib/angular.ui-bootstrap.js (100%) rename docs-web/src/main/webapp/{ => src}/lib/angular.ui-router.js (100%) rename docs-web/src/main/webapp/{ => src}/lib/angular.ui-sortable.js (100%) rename docs-web/src/main/webapp/{ => src}/lib/angular.ui-utils.js (100%) rename docs-web/src/main/webapp/{ => src}/lib/colorpicker.js (100%) rename docs-web/src/main/webapp/{ => src}/lib/jquery.js (100%) rename docs-web/src/main/webapp/{ => src}/lib/jquery.ui.js (100%) rename docs-web/src/main/webapp/{ => src}/lib/less.js (100%) rename docs-web/src/main/webapp/{ => src}/lib/underscore.js (100%) rename docs-web/src/main/webapp/{ => src}/locale/messages.en.js (100%) rename docs-web/src/main/webapp/{ => src}/partial/docs/directive.selecttag.html (100%) rename docs-web/src/main/webapp/{ => src}/partial/docs/document.default.html (100%) rename docs-web/src/main/webapp/{ => src}/partial/docs/document.edit.html (100%) rename docs-web/src/main/webapp/{ => src}/partial/docs/document.html (100%) rename docs-web/src/main/webapp/{ => src}/partial/docs/document.share.html (100%) rename docs-web/src/main/webapp/{ => src}/partial/docs/document.view.html (93%) rename docs-web/src/main/webapp/{ => src}/partial/docs/file.view.html (92%) rename docs-web/src/main/webapp/{ => src}/partial/docs/login.html (100%) rename docs-web/src/main/webapp/{ => src}/partial/docs/main.html (100%) rename docs-web/src/main/webapp/{ => src}/partial/docs/settings.account.html (100%) rename docs-web/src/main/webapp/{ => src}/partial/docs/settings.default.html (100%) rename docs-web/src/main/webapp/{ => src}/partial/docs/settings.html (100%) rename docs-web/src/main/webapp/{ => src}/partial/docs/settings.log.html (100%) rename docs-web/src/main/webapp/{ => src}/partial/docs/settings.session.html (100%) rename docs-web/src/main/webapp/{ => src}/partial/docs/settings.user.edit.html (100%) rename docs-web/src/main/webapp/{ => src}/partial/docs/settings.user.html (100%) rename docs-web/src/main/webapp/{ => src}/partial/docs/tag.html (100%) rename docs-web/src/main/webapp/{ => src}/partial/share/403.html (100%) rename docs-web/src/main/webapp/{ => src}/partial/share/file.view.html (88%) rename docs-web/src/main/webapp/{ => src}/partial/share/main.html (100%) rename docs-web/src/main/webapp/{ => src}/partial/share/share.html (80%) rename docs-web/src/main/webapp/{ => src}/share.html (81%) rename docs-web/src/main/webapp/{ => src}/style/bootstrap.css (100%) rename docs-web/src/main/webapp/{ => src}/style/colorpicker.css (100%) rename docs-web/src/main/webapp/{ => src}/style/main.less (100%) diff --git a/docs-web/pom.xml b/docs-web/pom.xml index 86514de4..6177bacc 100644 --- a/docs-web/pom.xml +++ b/docs-web/pom.xml @@ -264,14 +264,44 @@ - + + + maven-antrun-plugin + 1.7 + + + generate-sources + + + + + + + + + + + + + + + + + + + + run + + + + + + org.apache.maven.plugins maven-war-plugin - - sismicsdocs/**, - + ${basedir}/src/main/webapp/dist src\main\webapp\WEB-INF\web.xml diff --git a/docs-web/src/main/webapp/.gitignore b/docs-web/src/main/webapp/.gitignore index f86f20a7..209feadd 100644 --- a/docs-web/src/main/webapp/.gitignore +++ b/docs-web/src/main/webapp/.gitignore @@ -1,2 +1,4 @@ -/sismicsdocs -/.idea \ No newline at end of file +sismicsdocs +node_modules +dist +.idea \ No newline at end of file diff --git a/docs-web/src/main/webapp/Gruntfile.js b/docs-web/src/main/webapp/Gruntfile.js new file mode 100644 index 00000000..44adc424 --- /dev/null +++ b/docs-web/src/main/webapp/Gruntfile.js @@ -0,0 +1,122 @@ +module.exports = function(grunt) { + + // Project configuration. + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + clean: { + dist: { + src: ['dist'] + } + }, + ngmin: { + dist: { + expand: true, + cwd: 'src', + src: ['app/**/*.js'], + dest: 'dist' + } + }, + concat: { + docs: { + options: { + separator: ';' + }, + src: ['src/lib/jquery.js','src/lib/jquery.ui.js','src/lib/underscore.js','src/lib/colorpicker.js', 'src/lib/angular.js', 'src/lib/angular.*.js', + 'dist/app/docs/app.js', 'dist/app/docs/controller/*.js', 'dist/app/docs/directive/*.js', 'dist/app/docs/filter/*.js', 'dist/app/docs/service/*.js'], + dest: 'dist/docs.js' + }, + share: { + options: { + separator: ';' + }, + src: ['src/lib/jquery.js','src/lib/jquery.ui.js','src/lib/underscore.js','src/lib/colorpicker.js', 'src/lib/angular.js', 'src/lib/angular.*.js', + 'dist/app/share/app.js', 'dist/app/share/controller/*.js', 'dist/app/share/directive/*.js', 'dist/app/share/filter/*.js', 'dist/app/share/service/*.js'], + dest: 'dist/share.js' + }, + css: { + src: ['src/style/*.css', 'dist/less.css'], + dest: 'dist/style.css' + } + }, + less: { + dist: { + src: ['src/style/*.less'], + dest: 'dist/less.css' + } + }, + cssmin: { + dist: { + src: 'dist/style.css', + dest: 'dist/style/style.min.css' + } + }, + uglify: { + docs: { + src: 'dist/docs.js', + dest: 'dist/docs.min.js' + }, + share: { + src: 'dist/share.js', + dest: 'dist/share.min.js' + } + }, + copy: { + dist: { + expand: true, + cwd: 'src/', + src: ['**', '!**/*.js', '!*.html', '!**/*.less', '!**/*.css'], + dest: 'dist/' + } + }, + htmlrefs: { + index: { + src: 'src/index.html', + dest: 'dist/index.html' + }, + share: { + src: 'src/share.html', + dest: 'dist/share.html' + } + }, + remove: { + dist: { + fileList: ['dist/style.css', 'dist/docs.js', 'dist/share.js', 'dist/less.css'], + dirList: ['dist/app'] + } + }, + cleanempty: { + options: { + files: false, + folders: true + }, + src: ['dist/**'] + }, + replace: { + dist: { + src: ['dist/docs.min.js', 'dist/share.min.js', 'dist/**/*.html'], + overwrite: true, + replacements: [{ + from: '../api', + to: grunt.option('apiurl') || '../api' + }] + } + } + }); + + grunt.loadNpmTasks('grunt-contrib-clean'); + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-copy'); + grunt.loadNpmTasks('grunt-cleanempty'); + grunt.loadNpmTasks('grunt-htmlrefs'); + grunt.loadNpmTasks('grunt-css'); + grunt.loadNpmTasks('grunt-contrib-less'); + grunt.loadNpmTasks('grunt-remove'); + grunt.loadNpmTasks('grunt-ngmin'); + grunt.loadNpmTasks('grunt-text-replace'); + + // Default tasks. + grunt.registerTask('default', ['clean', 'ngmin', 'concat:docs', 'concat:share', 'less', 'concat:css', 'cssmin', + 'uglify:docs', 'uglify:share', 'copy', 'remove', 'cleanempty', 'htmlrefs:index', 'htmlrefs:share', 'replace']); + +}; \ No newline at end of file diff --git a/docs-web/src/main/webapp/app/docs/controller/FileView.js b/docs-web/src/main/webapp/app/docs/controller/FileView.js deleted file mode 100644 index 8829c1d7..00000000 --- a/docs-web/src/main/webapp/app/docs/controller/FileView.js +++ /dev/null @@ -1,98 +0,0 @@ -'use strict'; - -/** - * File view controller. - */ -App.controller('FileView', function($modal, $state, $stateParams) { - var modal = $modal.open({ - windowClass: 'modal modal-fileview', - templateUrl: 'partial/docs/file.view.html', - controller: function($rootScope, $scope, $state, $stateParams, Restangular) { - // Load files - Restangular.one('file').getList('list', { id: $stateParams.id }).then(function(data) { - $scope.files = data.files; - - // Search current file - _.each($scope.files, function(value) { - if (value.id == $stateParams.fileId) { - $scope.file = value; - } - }); - }); - - /** - * Navigate to the next file. - */ - $scope.nextFile = function() { - _.each($scope.files, function(value, key) { - if (value.id == $stateParams.fileId) { - var next = $scope.files[key + 1]; - if (next) { - $state.transitionTo('document.view.file', { id: $stateParams.id, fileId: next.id }); - } - } - }); - }; - - /** - * Navigate to the previous file. - */ - $scope.previousFile = function() { - _.each($scope.files, function(value, key) { - if (value.id == $stateParams.fileId) { - var previous = $scope.files[key - 1]; - if (previous) { - $state.transitionTo('document.view.file', { id: $stateParams.id, fileId: previous.id }); - } - } - }); - }; - - /** - * Open the file in a new window. - */ - $scope.openFile = function() { - window.open('api/file/' + $stateParams.fileId + '/data'); - }; - - /** - * Print the file. - */ - $scope.printFile = function() { - var popup = window.open('api/file/' + $stateParams.fileId + '/data', '_blank'); - popup.onload = function () { - popup.print(); - popup.close(); - } - }; - - /** - * Close the file preview. - */ - $scope.closeFile = function () { - modal.dismiss(); - }; - - // Close the modal when the user exits this state - var off = $rootScope.$on('$stateChangeStart', function(event, toState) { - if (!modal.closed) { - if (toState.name == 'document.view.file') { - modal.close(); - } else { - modal.dismiss(); - } - } - off(); - }); - } - }); - - // Returns to document view on file close - modal.closed = false; - modal.result.then(function() { - modal.closed = true; - }, function() { - modal.closed = true; - $state.transitionTo('document.view', { id: $stateParams.id }); - }); -}); \ No newline at end of file diff --git a/docs-web/src/main/webapp/app/docs/controller/SettingsDefault.js b/docs-web/src/main/webapp/app/docs/controller/SettingsDefault.js deleted file mode 100644 index 0e37dbc0..00000000 --- a/docs-web/src/main/webapp/app/docs/controller/SettingsDefault.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -/** - * Settings default page controller. - */ -App.controller('SettingsDefault', function($scope, Restangular) { -}); \ No newline at end of file diff --git a/docs-web/src/main/webapp/app/share/controller/FileView.js b/docs-web/src/main/webapp/app/share/controller/FileView.js deleted file mode 100644 index 834e8d60..00000000 --- a/docs-web/src/main/webapp/app/share/controller/FileView.js +++ /dev/null @@ -1,98 +0,0 @@ -'use strict'; - -/** - * File view controller. - */ -App.controller('FileView', function($modal, $state, $stateParams) { - var modal = $modal.open({ - windowClass: 'modal modal-fileview', - templateUrl: 'partial/share/file.view.html', - controller: function($rootScope, $scope, $state, $stateParams, Restangular) { - // Load files - Restangular.one('file').getList('list', { id: $stateParams.documentId, share: $stateParams.shareId }).then(function(data) { - $scope.files = data.files; - - // Search current file - _.each($scope.files, function(value) { - if (value.id == $stateParams.fileId) { - $scope.file = value; - } - }); - }); - - /** - * Navigate to the next file. - */ - $scope.nextFile = function() { - _.each($scope.files, function(value, key) { - if (value.id == $stateParams.fileId) { - var next = $scope.files[key + 1]; - if (next) { - $state.transitionTo('share.file', { documentId: $stateParams.documentId, shareId: $stateParams.shareId, fileId: next.id }); - } - } - }); - }; - - /** - * Navigate to the previous file. - */ - $scope.previousFile = function() { - _.each($scope.files, function(value, key) { - if (value.id == $stateParams.fileId) { - var previous = $scope.files[key - 1]; - if (previous) { - $state.transitionTo('share.file', { documentId: $stateParams.documentId, shareId: $stateParams.shareId, fileId: previous.id }); - } - } - }); - }; - - /** - * Open the file in a new window. - */ - $scope.openFile = function() { - window.open('api/file/' + $stateParams.fileId + '/data?share=' + $stateParams.shareId); - }; - - /** - * Print the file. - */ - $scope.printFile = function() { - var popup = window.open('api/file/' + $stateParams.fileId + '/data', '_blank'); - popup.onload = function () { - popup.print(); - popup.close(); - } - }; - - /** - * Close the file preview. - */ - $scope.closeFile = function () { - modal.dismiss(); - }; - - // Close the modal when the user exits this state - var off = $rootScope.$on('$stateChangeStart', function(event, toState){ - if (!modal.closed) { - if (toState.name == 'share.file') { - modal.close(); - } else { - modal.dismiss(); - } - } - off(); - }); - } - }); - - // Returns to share view on file close - modal.closed = false; - modal.result.then(function() { - modal.closed = true; - },function(result) { - modal.closed = true; - $state.transitionTo('share', { documentId: $stateParams.documentId, shareId: $stateParams.shareId }); - }); -}); \ No newline at end of file diff --git a/docs-web/src/main/webapp/app/share/controller/Main.js b/docs-web/src/main/webapp/app/share/controller/Main.js deleted file mode 100644 index 69dbe8a4..00000000 --- a/docs-web/src/main/webapp/app/share/controller/Main.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -/** - * Main controller. - */ -App.controller('Main', function() { -}); \ No newline at end of file diff --git a/docs-web/src/main/webapp/package.json b/docs-web/src/main/webapp/package.json new file mode 100644 index 00000000..c8187b94 --- /dev/null +++ b/docs-web/src/main/webapp/package.json @@ -0,0 +1,24 @@ +{ + "name": "sismics-docs", + "description": "Lightweight document management system", + "readme": "See http://github.com/simics/docs for more informations.", + "version": "0.0.1", + "repository": { + "type": "git", + "url": "git://github.com/sismics/docs.git" + }, + "devDependencies": { + "grunt": "~0.4.2", + "grunt-contrib-uglify": "~0.3.2", + "grunt-contrib-concat": "~0.3.0", + "grunt-contrib-copy": "~0.5.0", + "grunt-contrib-clean": "~0.5.0", + "grunt-cleanempty": "~0.2.0", + "grunt-htmlrefs": "~0.5.0", + "grunt-css": "~0.5.4", + "grunt-contrib-less": "~0.9.0", + "grunt-remove": "~0.1.0", + "grunt-ngmin": "0.0.3", + "grunt-text-replace": "~0.3.11" + } +} diff --git a/docs-web/src/main/webapp/app/docs/app.js b/docs-web/src/main/webapp/src/app/docs/app.js similarity index 98% rename from docs-web/src/main/webapp/app/docs/app.js rename to docs-web/src/main/webapp/src/app/docs/app.js index 8b19a178..5cf5fc47 100644 --- a/docs-web/src/main/webapp/app/docs/app.js +++ b/docs-web/src/main/webapp/src/app/docs/app.js @@ -3,7 +3,7 @@ /** * Sismics Docs application. */ -var App = angular.module('docs', +angular.module('docs', // Dependencies ['ui.router', 'ui.route', 'ui.bootstrap', 'ui.keypress', 'ui.validate', 'dialog', 'ui.sortable', 'restangular', 'ngSanitize', 'ngTouch', 'colorpicker.module'] @@ -171,7 +171,7 @@ var App = angular.module('docs', }); // Configuring Restangular - RestangularProvider.setBaseUrl('api'); + RestangularProvider.setBaseUrl('../api'); // Configuring $http to act like jQuery.ajax $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8'; diff --git a/docs-web/src/main/webapp/app/docs/controller/Document.js b/docs-web/src/main/webapp/src/app/docs/controller/Document.js similarity index 95% rename from docs-web/src/main/webapp/app/docs/controller/Document.js rename to docs-web/src/main/webapp/src/app/docs/controller/Document.js index a527e01c..7a127547 100644 --- a/docs-web/src/main/webapp/app/docs/controller/Document.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/Document.js @@ -3,7 +3,7 @@ /** * Document controller. */ -App.controller('Document', function($scope, $timeout, $state, Restangular) { +angular.module('docs').controller('Document', function($scope, $timeout, $state, Restangular) { /** * Documents table sort status. */ diff --git a/docs-web/src/main/webapp/app/docs/controller/DocumentDefault.js b/docs-web/src/main/webapp/src/app/docs/controller/DocumentDefault.js similarity index 61% rename from docs-web/src/main/webapp/app/docs/controller/DocumentDefault.js rename to docs-web/src/main/webapp/src/app/docs/controller/DocumentDefault.js index a4b857db..463073ff 100644 --- a/docs-web/src/main/webapp/app/docs/controller/DocumentDefault.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/DocumentDefault.js @@ -3,7 +3,7 @@ /** * Document default controller. */ -App.controller('DocumentDefault', function($scope, $state, Restangular) { +angular.module('docs').controller('DocumentDefault', function($scope, $state, Restangular) { // Load app data Restangular.one('app').get().then(function(data) { $scope.app = data; diff --git a/docs-web/src/main/webapp/app/docs/controller/DocumentEdit.js b/docs-web/src/main/webapp/src/app/docs/controller/DocumentEdit.js similarity index 96% rename from docs-web/src/main/webapp/app/docs/controller/DocumentEdit.js rename to docs-web/src/main/webapp/src/app/docs/controller/DocumentEdit.js index 58366651..42ac85e1 100644 --- a/docs-web/src/main/webapp/app/docs/controller/DocumentEdit.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/DocumentEdit.js @@ -3,7 +3,7 @@ /** * Document edition controller. */ -App.controller('DocumentEdit', function($rootScope, $scope, $q, $http, $state, $stateParams, Restangular, Tag) { +angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $q, $http, $state, $stateParams, Restangular, Tag) { // Alerts $scope.alerts = []; @@ -120,7 +120,7 @@ App.controller('DocumentEdit', function($rootScope, $scope, $q, $http, $state, $ // Send the file $.ajax({ type: 'PUT', - url: 'api/file', + url: '../api/file', data: formData, cache: false, contentType: false, diff --git a/docs-web/src/main/webapp/app/docs/controller/DocumentView.js b/docs-web/src/main/webapp/src/app/docs/controller/DocumentView.js similarity index 96% rename from docs-web/src/main/webapp/app/docs/controller/DocumentView.js rename to docs-web/src/main/webapp/src/app/docs/controller/DocumentView.js index cf7e801e..2a16a47f 100644 --- a/docs-web/src/main/webapp/app/docs/controller/DocumentView.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/DocumentView.js @@ -3,7 +3,7 @@ /** * Document view controller. */ -App.controller('DocumentView', function ($scope, $state, $stateParams, $location, $dialog, $modal, Restangular) { +angular.module('docs').controller('DocumentView', function ($scope, $state, $stateParams, $location, $dialog, $modal, Restangular) { // Load data from server Restangular.one('document', $stateParams.id).get().then(function(data) { $scope.document = data; diff --git a/docs-web/src/main/webapp/src/app/docs/controller/FileModalView.js b/docs-web/src/main/webapp/src/app/docs/controller/FileModalView.js new file mode 100644 index 00000000..fd457072 --- /dev/null +++ b/docs-web/src/main/webapp/src/app/docs/controller/FileModalView.js @@ -0,0 +1,83 @@ +'use strict'; + +/** + * File modal view controller. + */ +angular.module('docs').controller('FileModalView', function($rootScope, $modalInstance, $scope, $state, $stateParams, Restangular) { + // Load files + Restangular.one('file').getList('list', { id: $stateParams.id }).then(function(data) { + $scope.files = data.files; + + // Search current file + _.each($scope.files, function(value) { + if (value.id == $stateParams.fileId) { + $scope.file = value; + } + }); + }); + + /** + * Navigate to the next file. + */ + $scope.nextFile = function() { + _.each($scope.files, function(value, key) { + if (value.id == $stateParams.fileId) { + var next = $scope.files[key + 1]; + if (next) { + $state.transitionTo('document.view.file', { id: $stateParams.id, fileId: next.id }); + } + } + }); + }; + + /** + * Navigate to the previous file. + */ + $scope.previousFile = function() { + _.each($scope.files, function(value, key) { + if (value.id == $stateParams.fileId) { + var previous = $scope.files[key - 1]; + if (previous) { + $state.transitionTo('document.view.file', { id: $stateParams.id, fileId: previous.id }); + } + } + }); + }; + + /** + * Open the file in a new window. + */ + $scope.openFile = function() { + window.open('../api/file/' + $stateParams.fileId + '/data'); + }; + + /** + * Print the file. + */ + $scope.printFile = function() { + var popup = window.open('../api/file/' + $stateParams.fileId + '/data', '_blank'); + popup.onload = function () { + popup.print(); + popup.close(); + } + }; + + /** + * Close the file preview. + */ + $scope.closeFile = function () { + $modalInstance.dismiss(); + }; + + // Close the modal when the user exits this state + var off = $rootScope.$on('$stateChangeStart', function(event, toState) { + if (!$modalInstance.closed) { + if (toState.name == 'document.view.file') { + $modalInstance.close(); + } else { + $modalInstance.dismiss(); + } + } + off(); + }); +}); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/docs/controller/FileView.js b/docs-web/src/main/webapp/src/app/docs/controller/FileView.js new file mode 100644 index 00000000..8f99710a --- /dev/null +++ b/docs-web/src/main/webapp/src/app/docs/controller/FileView.js @@ -0,0 +1,21 @@ +'use strict'; + +/** + * File view controller. + */ +angular.module('docs').controller('FileView', function($modal, $state, $stateParams) { + var modal = $modal.open({ + windowClass: 'modal modal-fileview', + templateUrl: 'partial/docs/file.view.html', + controller: 'FileModalView' + }); + + // Returns to document view on file close + modal.closed = false; + modal.result.then(function() { + modal.closed = true; + }, function() { + modal.closed = true; + $state.transitionTo('document.view', { id: $stateParams.id }); + }); +}); \ No newline at end of file diff --git a/docs-web/src/main/webapp/app/docs/controller/Login.js b/docs-web/src/main/webapp/src/app/docs/controller/Login.js similarity index 81% rename from docs-web/src/main/webapp/app/docs/controller/Login.js rename to docs-web/src/main/webapp/src/app/docs/controller/Login.js index d8320248..c6d7a947 100644 --- a/docs-web/src/main/webapp/app/docs/controller/Login.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/Login.js @@ -3,7 +3,7 @@ /** * Login controller. */ -App.controller('Login', function($scope, $rootScope, $state, $dialog, User) { +angular.module('docs').controller('Login', function($scope, $rootScope, $state, $dialog, User) { $scope.login = function() { User.login($scope.user).then(function() { $rootScope.userInfo = User.userInfo(true); diff --git a/docs-web/src/main/webapp/app/docs/controller/Main.js b/docs-web/src/main/webapp/src/app/docs/controller/Main.js similarity index 70% rename from docs-web/src/main/webapp/app/docs/controller/Main.js rename to docs-web/src/main/webapp/src/app/docs/controller/Main.js index 5cc3b957..bb56d24e 100644 --- a/docs-web/src/main/webapp/app/docs/controller/Main.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/Main.js @@ -3,7 +3,7 @@ /** * Main controller. */ -App.controller('Main', function($scope, $rootScope, $state, User) { +angular.module('docs').controller('Main', function($scope, $rootScope, $state, User) { User.userInfo().then(function(data) { if (data.anonymous) { $state.transitionTo('login'); diff --git a/docs-web/src/main/webapp/app/docs/controller/Navigation.js b/docs-web/src/main/webapp/src/app/docs/controller/Navigation.js similarity index 93% rename from docs-web/src/main/webapp/app/docs/controller/Navigation.js rename to docs-web/src/main/webapp/src/app/docs/controller/Navigation.js index 3579050e..64417aa9 100644 --- a/docs-web/src/main/webapp/app/docs/controller/Navigation.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/Navigation.js @@ -3,7 +3,7 @@ /** * Navigation controller. */ -App.controller('Navigation', function($scope, $http, $state, $rootScope, User, Restangular) { +angular.module('docs').controller('Navigation', function($scope, $http, $state, $rootScope, User, Restangular) { User.userInfo().then(function(data) { $rootScope.userInfo = data; }); diff --git a/docs-web/src/main/webapp/app/docs/controller/Settings.js b/docs-web/src/main/webapp/src/app/docs/controller/Settings.js similarity index 65% rename from docs-web/src/main/webapp/app/docs/controller/Settings.js rename to docs-web/src/main/webapp/src/app/docs/controller/Settings.js index 269f11e6..47823487 100644 --- a/docs-web/src/main/webapp/app/docs/controller/Settings.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/Settings.js @@ -3,7 +3,7 @@ /** * Settings controller. */ -App.controller('Settings', function($scope, Restangular) { +angular.module('docs').controller('Settings', function($scope, Restangular) { // Flag if the user is admin $scope.isAdmin = $scope.userInfo.base_functions.indexOf('ADMIN') != -1; }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/app/docs/controller/SettingsAccount.js b/docs-web/src/main/webapp/src/app/docs/controller/SettingsAccount.js similarity index 84% rename from docs-web/src/main/webapp/app/docs/controller/SettingsAccount.js rename to docs-web/src/main/webapp/src/app/docs/controller/SettingsAccount.js index 55c90452..d318c0e1 100644 --- a/docs-web/src/main/webapp/app/docs/controller/SettingsAccount.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/SettingsAccount.js @@ -3,7 +3,7 @@ /** * Settings account controller. */ -App.controller('SettingsAccount', function($scope, Restangular) { +angular.module('docs').controller('SettingsAccount', function($scope, Restangular) { $scope.editUserAlert = false; // Alerts diff --git a/docs-web/src/main/webapp/src/app/docs/controller/SettingsDefault.js b/docs-web/src/main/webapp/src/app/docs/controller/SettingsDefault.js new file mode 100644 index 00000000..05d9cb7e --- /dev/null +++ b/docs-web/src/main/webapp/src/app/docs/controller/SettingsDefault.js @@ -0,0 +1,7 @@ +'use strict'; + +/** + * Settings default page controller. + */ +angular.module('docs').controller('SettingsDefault', function($scope, Restangular) { +}); \ No newline at end of file diff --git a/docs-web/src/main/webapp/app/docs/controller/SettingsLog.js b/docs-web/src/main/webapp/src/app/docs/controller/SettingsLog.js similarity index 66% rename from docs-web/src/main/webapp/app/docs/controller/SettingsLog.js rename to docs-web/src/main/webapp/src/app/docs/controller/SettingsLog.js index 0745675c..41c72e8a 100644 --- a/docs-web/src/main/webapp/app/docs/controller/SettingsLog.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/SettingsLog.js @@ -3,7 +3,7 @@ /** * Settings logs controller. */ -App.controller('SettingsLog', function($scope, Restangular) { +angular.module('docs').controller('SettingsLog', function($scope, Restangular) { Restangular.one('app/log').get({ limit: 100 }).then(function(data) { diff --git a/docs-web/src/main/webapp/app/docs/controller/SettingsSession.js b/docs-web/src/main/webapp/src/app/docs/controller/SettingsSession.js similarity index 83% rename from docs-web/src/main/webapp/app/docs/controller/SettingsSession.js rename to docs-web/src/main/webapp/src/app/docs/controller/SettingsSession.js index 72f7f267..26f2957c 100644 --- a/docs-web/src/main/webapp/app/docs/controller/SettingsSession.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/SettingsSession.js @@ -3,7 +3,7 @@ /** * Settings session controller. */ -App.controller('SettingsSession', function($scope, Restangular) { +angular.module('docs').controller('SettingsSession', function($scope, Restangular) { /** * Load sessions. */ diff --git a/docs-web/src/main/webapp/app/docs/controller/SettingsUser.js b/docs-web/src/main/webapp/src/app/docs/controller/SettingsUser.js similarity index 82% rename from docs-web/src/main/webapp/app/docs/controller/SettingsUser.js rename to docs-web/src/main/webapp/src/app/docs/controller/SettingsUser.js index 831952ab..f65160aa 100644 --- a/docs-web/src/main/webapp/app/docs/controller/SettingsUser.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/SettingsUser.js @@ -3,7 +3,7 @@ /** * Settings user page controller. */ -App.controller('SettingsUser', function($scope, $state, Restangular) { +angular.module('docs').controller('SettingsUser', function($scope, $state, Restangular) { /** * Load users from server. */ diff --git a/docs-web/src/main/webapp/app/docs/controller/SettingsUserEdit.js b/docs-web/src/main/webapp/src/app/docs/controller/SettingsUserEdit.js similarity index 92% rename from docs-web/src/main/webapp/app/docs/controller/SettingsUserEdit.js rename to docs-web/src/main/webapp/src/app/docs/controller/SettingsUserEdit.js index 44652ff0..ecd4d027 100644 --- a/docs-web/src/main/webapp/app/docs/controller/SettingsUserEdit.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/SettingsUserEdit.js @@ -3,7 +3,7 @@ /** * Settings user edition page controller. */ -App.controller('SettingsUserEdit', function($scope, $dialog, $state, $stateParams, Restangular) { +angular.module('docs').controller('SettingsUserEdit', function($scope, $dialog, $state, $stateParams, Restangular) { /** * Returns true if in edit mode (false in add mode). */ diff --git a/docs-web/src/main/webapp/app/docs/controller/Tag.js b/docs-web/src/main/webapp/src/app/docs/controller/Tag.js similarity index 95% rename from docs-web/src/main/webapp/app/docs/controller/Tag.js rename to docs-web/src/main/webapp/src/app/docs/controller/Tag.js index 45609631..d38c0ced 100644 --- a/docs-web/src/main/webapp/app/docs/controller/Tag.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/Tag.js @@ -3,7 +3,7 @@ /** * Tag controller. */ -App.controller('Tag', function($scope, $dialog, $state, Tag, Restangular) { +angular.module('docs').controller('Tag', function($scope, $dialog, $state, Tag, Restangular) { $scope.tag = { name: '', color: '#3a87ad' }; // Retrieve tags diff --git a/docs-web/src/main/webapp/app/docs/directive/File.js b/docs-web/src/main/webapp/src/app/docs/directive/File.js similarity index 88% rename from docs-web/src/main/webapp/app/docs/directive/File.js rename to docs-web/src/main/webapp/src/app/docs/directive/File.js index 01b315e0..f1fe09ed 100644 --- a/docs-web/src/main/webapp/app/docs/directive/File.js +++ b/docs-web/src/main/webapp/src/app/docs/directive/File.js @@ -3,7 +3,7 @@ /** * File upload directive. */ -App.directive('file', function() { +angular.module('docs').directive('file', function() { return { restrict: 'E', template: '', diff --git a/docs-web/src/main/webapp/app/docs/directive/InlineEdit.js b/docs-web/src/main/webapp/src/app/docs/directive/InlineEdit.js similarity index 96% rename from docs-web/src/main/webapp/app/docs/directive/InlineEdit.js rename to docs-web/src/main/webapp/src/app/docs/directive/InlineEdit.js index 649074ab..02ea72c8 100644 --- a/docs-web/src/main/webapp/app/docs/directive/InlineEdit.js +++ b/docs-web/src/main/webapp/src/app/docs/directive/InlineEdit.js @@ -4,7 +4,7 @@ * Inline edition directive. * Thanks to http://jsfiddle.net/joshdmiller/NDFHg/ */ -App.directive('inlineEdit', function() { +angular.module('docs').directive('inlineEdit', function() { return { restrict: 'E', scope: { diff --git a/docs-web/src/main/webapp/app/docs/directive/SelectTag.js b/docs-web/src/main/webapp/src/app/docs/directive/SelectTag.js similarity index 95% rename from docs-web/src/main/webapp/app/docs/directive/SelectTag.js rename to docs-web/src/main/webapp/src/app/docs/directive/SelectTag.js index 38a0cf41..c0753325 100644 --- a/docs-web/src/main/webapp/app/docs/directive/SelectTag.js +++ b/docs-web/src/main/webapp/src/app/docs/directive/SelectTag.js @@ -3,7 +3,7 @@ /** * Tag selection directive. */ -App.directive('selectTag', function() { +angular.module('docs').directive('selectTag', function() { return { restrict: 'E', templateUrl: 'partial/docs/directive.selecttag.html', diff --git a/docs-web/src/main/webapp/app/docs/filter/Newline.js b/docs-web/src/main/webapp/src/app/docs/filter/Newline.js similarity index 75% rename from docs-web/src/main/webapp/app/docs/filter/Newline.js rename to docs-web/src/main/webapp/src/app/docs/filter/Newline.js index ed0bb238..c7cce4b7 100644 --- a/docs-web/src/main/webapp/app/docs/filter/Newline.js +++ b/docs-web/src/main/webapp/src/app/docs/filter/Newline.js @@ -3,7 +3,7 @@ /** * Filter converting new lines in
*/ -App.filter('newline', function() { +angular.module('docs').filter('newline', function() { return function(text) { if (!text) { return ''; diff --git a/docs-web/src/main/webapp/app/docs/filter/Shorten.js b/docs-web/src/main/webapp/src/app/docs/filter/Shorten.js similarity index 77% rename from docs-web/src/main/webapp/app/docs/filter/Shorten.js rename to docs-web/src/main/webapp/src/app/docs/filter/Shorten.js index 57963f49..d2b055e1 100644 --- a/docs-web/src/main/webapp/app/docs/filter/Shorten.js +++ b/docs-web/src/main/webapp/src/app/docs/filter/Shorten.js @@ -3,7 +3,7 @@ /** * Filter shortening text in one letter uppercase. */ -App.filter('shorten', function() { +angular.module('docs').filter('shorten', function() { return function(text) { if (!text) { return ''; diff --git a/docs-web/src/main/webapp/app/docs/service/Tag.js b/docs-web/src/main/webapp/src/app/docs/service/Tag.js similarity index 79% rename from docs-web/src/main/webapp/app/docs/service/Tag.js rename to docs-web/src/main/webapp/src/app/docs/service/Tag.js index 31dc780a..04a94687 100644 --- a/docs-web/src/main/webapp/app/docs/service/Tag.js +++ b/docs-web/src/main/webapp/src/app/docs/service/Tag.js @@ -3,7 +3,7 @@ /** * Tag service. */ -App.factory('Tag', function(Restangular) { +angular.module('docs').factory('Tag', function(Restangular) { var tags = null; return { diff --git a/docs-web/src/main/webapp/app/docs/service/User.js b/docs-web/src/main/webapp/src/app/docs/service/User.js similarity index 90% rename from docs-web/src/main/webapp/app/docs/service/User.js rename to docs-web/src/main/webapp/src/app/docs/service/User.js index eb0e9171..31c411f6 100644 --- a/docs-web/src/main/webapp/app/docs/service/User.js +++ b/docs-web/src/main/webapp/src/app/docs/service/User.js @@ -3,7 +3,7 @@ /** * User service. */ -App.factory('User', function(Restangular) { +angular.module('docs').factory('User', function(Restangular) { var userInfo = null; return { diff --git a/docs-web/src/main/webapp/app/share/app.js b/docs-web/src/main/webapp/src/app/share/app.js similarity index 97% rename from docs-web/src/main/webapp/app/share/app.js rename to docs-web/src/main/webapp/src/app/share/app.js index 19bc7d57..9fe7cdfb 100644 --- a/docs-web/src/main/webapp/app/share/app.js +++ b/docs-web/src/main/webapp/src/app/share/app.js @@ -3,7 +3,7 @@ /** * Share application. */ -var App = angular.module('share', +angular.module('share', // Dependencies ['ui.router', 'ui.bootstrap', 'restangular', 'ngSanitize', 'ngTouch'] ) @@ -50,7 +50,7 @@ var App = angular.module('share', }); // Configuring Restangular - RestangularProvider.setBaseUrl('api'); + RestangularProvider.setBaseUrl('../api'); // Configuring $http to act like jQuery.ajax $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8'; diff --git a/docs-web/src/main/webapp/src/app/share/controller/FileModalView.js b/docs-web/src/main/webapp/src/app/share/controller/FileModalView.js new file mode 100644 index 00000000..8426022d --- /dev/null +++ b/docs-web/src/main/webapp/src/app/share/controller/FileModalView.js @@ -0,0 +1,83 @@ +'use strict'; + +/** + * File modal view controller. + */ +angular.module('share').controller('FileModalView', function($rootScope, $modalInstance, $scope, $state, $stateParams, Restangular) { + // Load files + Restangular.one('file').getList('list', { id: $stateParams.documentId, share: $stateParams.shareId }).then(function(data) { + $scope.files = data.files; + + // Search current file + _.each($scope.files, function(value) { + if (value.id == $stateParams.fileId) { + $scope.file = value; + } + }); + }); + + /** + * Navigate to the next file. + */ + $scope.nextFile = function() { + _.each($scope.files, function(value, key) { + if (value.id == $stateParams.fileId) { + var next = $scope.files[key + 1]; + if (next) { + $state.transitionTo('share.file', { documentId: $stateParams.documentId, shareId: $stateParams.shareId, fileId: next.id }); + } + } + }); + }; + + /** + * Navigate to the previous file. + */ + $scope.previousFile = function() { + _.each($scope.files, function(value, key) { + if (value.id == $stateParams.fileId) { + var previous = $scope.files[key - 1]; + if (previous) { + $state.transitionTo('share.file', { documentId: $stateParams.documentId, shareId: $stateParams.shareId, fileId: previous.id }); + } + } + }); + }; + + /** + * Open the file in a new window. + */ + $scope.openFile = function() { + window.open('../api/file/' + $stateParams.fileId + '/data?share=' + $stateParams.shareId); + }; + + /** + * Print the file. + */ + $scope.printFile = function() { + var popup = window.open('../api/file/' + $stateParams.fileId + '/data', '_blank'); + popup.onload = function () { + popup.print(); + popup.close(); + } + }; + + /** + * Close the file preview. + */ + $scope.closeFile = function () { + $modalInstance.dismiss(); + }; + + // Close the modal when the user exits this state + var off = $rootScope.$on('$stateChangeStart', function(event, toState){ + if (!$modalInstance.closed) { + if (toState.name == 'share.file') { + $modalInstance.close(); + } else { + $modalInstance.dismiss(); + } + } + off(); + }); +}); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/share/controller/FileView.js b/docs-web/src/main/webapp/src/app/share/controller/FileView.js new file mode 100644 index 00000000..3ea83514 --- /dev/null +++ b/docs-web/src/main/webapp/src/app/share/controller/FileView.js @@ -0,0 +1,21 @@ +'use strict'; + +/** + * File view controller. + */ +angular.module('share').controller('FileView', function($modal, $state, $stateParams) { + var modal = $modal.open({ + windowClass: 'modal modal-fileview', + templateUrl: 'partial/share/file.view.html', + controller: 'FileModalView' + }); + + // Returns to share view on file close + modal.closed = false; + modal.result.then(function() { + modal.closed = true; + },function(result) { + modal.closed = true; + $state.transitionTo('share', { documentId: $stateParams.documentId, shareId: $stateParams.shareId }); + }); +}); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/share/controller/Main.js b/docs-web/src/main/webapp/src/app/share/controller/Main.js new file mode 100644 index 00000000..44fa21af --- /dev/null +++ b/docs-web/src/main/webapp/src/app/share/controller/Main.js @@ -0,0 +1,7 @@ +'use strict'; + +/** + * Main controller. + */ +angular.module('share').controller('Main', function() { +}); \ No newline at end of file diff --git a/docs-web/src/main/webapp/app/share/controller/Share.js b/docs-web/src/main/webapp/src/app/share/controller/Share.js similarity index 88% rename from docs-web/src/main/webapp/app/share/controller/Share.js rename to docs-web/src/main/webapp/src/app/share/controller/Share.js index 9ecbcdee..f3ddda15 100644 --- a/docs-web/src/main/webapp/app/share/controller/Share.js +++ b/docs-web/src/main/webapp/src/app/share/controller/Share.js @@ -3,7 +3,7 @@ /** * Share controller. */ -App.controller('Share', function($scope, $state, $stateParams, Restangular) { +angular.module('share').controller('Share', function($scope, $state, $stateParams, Restangular) { // Load document Restangular.one('document', $stateParams.documentId).get({ share: $stateParams.shareId }) .then(function (data) { diff --git a/docs-web/src/main/webapp/src/app/share/filter/Newline.js b/docs-web/src/main/webapp/src/app/share/filter/Newline.js new file mode 100644 index 00000000..571fa4d5 --- /dev/null +++ b/docs-web/src/main/webapp/src/app/share/filter/Newline.js @@ -0,0 +1,13 @@ +'use strict'; + +/** + * Filter converting new lines in
+ */ +angular.module('share').filter('newline', function() { + return function(text) { + if (!text) { + return ''; + } + return text.replace(/\n/g, '
'); + } +}) \ No newline at end of file diff --git a/docs-web/src/main/webapp/favicon.png b/docs-web/src/main/webapp/src/favicon.png similarity index 100% rename from docs-web/src/main/webapp/favicon.png rename to docs-web/src/main/webapp/src/favicon.png diff --git a/docs-web/src/main/webapp/fonts/glyphicons-halflings-regular.eot b/docs-web/src/main/webapp/src/fonts/glyphicons-halflings-regular.eot similarity index 100% rename from docs-web/src/main/webapp/fonts/glyphicons-halflings-regular.eot rename to docs-web/src/main/webapp/src/fonts/glyphicons-halflings-regular.eot diff --git a/docs-web/src/main/webapp/fonts/glyphicons-halflings-regular.svg b/docs-web/src/main/webapp/src/fonts/glyphicons-halflings-regular.svg similarity index 100% rename from docs-web/src/main/webapp/fonts/glyphicons-halflings-regular.svg rename to docs-web/src/main/webapp/src/fonts/glyphicons-halflings-regular.svg diff --git a/docs-web/src/main/webapp/fonts/glyphicons-halflings-regular.ttf b/docs-web/src/main/webapp/src/fonts/glyphicons-halflings-regular.ttf similarity index 100% rename from docs-web/src/main/webapp/fonts/glyphicons-halflings-regular.ttf rename to docs-web/src/main/webapp/src/fonts/glyphicons-halflings-regular.ttf diff --git a/docs-web/src/main/webapp/fonts/glyphicons-halflings-regular.woff b/docs-web/src/main/webapp/src/fonts/glyphicons-halflings-regular.woff similarity index 100% rename from docs-web/src/main/webapp/fonts/glyphicons-halflings-regular.woff rename to docs-web/src/main/webapp/src/fonts/glyphicons-halflings-regular.woff diff --git a/docs-web/src/main/webapp/img/alpha.png b/docs-web/src/main/webapp/src/img/alpha.png similarity index 100% rename from docs-web/src/main/webapp/img/alpha.png rename to docs-web/src/main/webapp/src/img/alpha.png diff --git a/docs-web/src/main/webapp/img/flag/eng.png b/docs-web/src/main/webapp/src/img/flag/eng.png similarity index 100% rename from docs-web/src/main/webapp/img/flag/eng.png rename to docs-web/src/main/webapp/src/img/flag/eng.png diff --git a/docs-web/src/main/webapp/img/flag/fra.png b/docs-web/src/main/webapp/src/img/flag/fra.png similarity index 100% rename from docs-web/src/main/webapp/img/flag/fra.png rename to docs-web/src/main/webapp/src/img/flag/fra.png diff --git a/docs-web/src/main/webapp/img/flag/jpn.png b/docs-web/src/main/webapp/src/img/flag/jpn.png similarity index 100% rename from docs-web/src/main/webapp/img/flag/jpn.png rename to docs-web/src/main/webapp/src/img/flag/jpn.png diff --git a/docs-web/src/main/webapp/img/glyphicons-halflings-white.png b/docs-web/src/main/webapp/src/img/glyphicons-halflings-white.png similarity index 100% rename from docs-web/src/main/webapp/img/glyphicons-halflings-white.png rename to docs-web/src/main/webapp/src/img/glyphicons-halflings-white.png diff --git a/docs-web/src/main/webapp/img/glyphicons-halflings.png b/docs-web/src/main/webapp/src/img/glyphicons-halflings.png similarity index 100% rename from docs-web/src/main/webapp/img/glyphicons-halflings.png rename to docs-web/src/main/webapp/src/img/glyphicons-halflings.png diff --git a/docs-web/src/main/webapp/img/hue.png b/docs-web/src/main/webapp/src/img/hue.png similarity index 100% rename from docs-web/src/main/webapp/img/hue.png rename to docs-web/src/main/webapp/src/img/hue.png diff --git a/docs-web/src/main/webapp/img/loader.gif b/docs-web/src/main/webapp/src/img/loader.gif similarity index 100% rename from docs-web/src/main/webapp/img/loader.gif rename to docs-web/src/main/webapp/src/img/loader.gif diff --git a/docs-web/src/main/webapp/img/saturation.png b/docs-web/src/main/webapp/src/img/saturation.png similarity index 100% rename from docs-web/src/main/webapp/img/saturation.png rename to docs-web/src/main/webapp/src/img/saturation.png diff --git a/docs-web/src/main/webapp/index.html b/docs-web/src/main/webapp/src/index.html similarity index 93% rename from docs-web/src/main/webapp/index.html rename to docs-web/src/main/webapp/src/index.html index 074716c9..c72f0eaa 100644 --- a/docs-web/src/main/webapp/index.html +++ b/docs-web/src/main/webapp/src/index.html @@ -5,9 +5,12 @@ + + + + + - - + + @@ -38,6 +43,7 @@ + @@ -55,6 +61,7 @@ +