Commit 83ae2bc2 authored by Antek's avatar Antek

Merge branch 'grunt' into 'auth'

Grunt



See merge request !1
parents 391cae85 692018c9
...@@ -2,3 +2,5 @@ ...@@ -2,3 +2,5 @@
.idea .idea
service/target service/target
service/ctf-archifact.iml service/ctf-archifact.iml
service/src/main/resources/assets_build
node_modules
\ No newline at end of file
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: ["./service/src/main/resources/assets_build/"],
cssmin: {
task: {
src: [
'./service/src/main/resources/assets/statics/css/*',
'./service/src/main/resources/assets/statics/libs/*.css'
],
dest: './service/src/main/resources/assets_build/statics/css/main.min.css'
},
options: {
'banner': null,
'keepSpecialComments': '*',
'report': 'min'
}
},
copy: {
main: {
files: [
{expand: true, flatten: true, src: ['service/src/main/resources/assets/statics/img/**'], dest: 'service/src/main/resources/assets_build/statics/img/', filter: 'isFile'}
]
}
},
htmlmin: {
target: {
options: {
removeComments: true,
collapseWhitespace: true
},
files: {
'./service/src/main/resources/assets_build/index.html': './service/src/main/resources/assets/index.html',
'./service/src/main/resources/assets_build/about.html': './service/src/main/resources/assets/about.html',
'./service/src/main/resources/assets_build/home.html': './service/src/main/resources/assets/home.html',
'./service/src/main/resources/assets_build/login.html': './service/src/main/resources/assets/login.html',
'./service/src/main/resources/assets_build/scoresheet.html': './service/src/main/resources/assets/scoresheet.html',
'./service/src/main/resources/assets_build/submitflag.html': './service/src/main/resources/assets/submitflag.html',
'./service/src/main/resources/assets_build/task.html': './service/src/main/resources/assets/task.html',
'./service/src/main/resources/assets_build/tasks.html': './service/src/main/resources/assets/tasks.html'
}
}
},
jshint: {
files: ['./service/src/main/resources/assets/statics/js/main.js',
'./service/src/main/resources/assets/statics/js/services/*.js',
'./service/src/main/resources/assets/statics/js/providers/*.js',
'./service/src/main/resources/assets/statics/js/utils/*.js',
'./service/src/main/resources/assets/statics/js/controllers/*.js'
],
options: {
globals: {
jQuery: true
}
}
},
uglify: {
task: {
src: [
'./service/src/main/resources/assets/statics/js/main.js',
'./service/src/main/resources/assets/statics/js/services/*.js',
'./service/src/main/resources/assets/statics/js/providers/*.js',
'./service/src/main/resources/assets/statics/js/utils/*.js',
'./service/src/main/resources/assets/statics/js/controllers/*.js',
'./service/src/main/resources/assets/statics/libs/*.js'
],
dest: './service/src/main/resources/assets_build/statics/js/app.min.js'
},
options: {
'mangle': false,
'compress': {},
'beautify': false,
'expression': false,
'report': 'min',
'sourceMap': false,
'sourceMapName': undefined,
'sourceMapIn': undefined,
'sourceMapIncludeSources': false,
'enclose': undefined,
'wrap': undefined,
'exportAll': false,
'preserveComments': undefined,
'banner': '',
'footer': ''
}
}
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-htmlmin');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.registerTask('default', ['clean', 'jshint', 'copy', 'htmlmin', 'cssmin', 'uglify']);
};
\ No newline at end of file
{
"name": "MyApp",
"title": "My App",
"version": "0.0.1",
"devDependencies": {
"grunt": "0.4.5",
"grunt-contrib-clean": "^1.0.0",
"grunt-contrib-concat": "^1.0.0",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-cssmin": "*",
"grunt-contrib-htmlmin": "^1.0.0",
"grunt-contrib-jshint": "*",
"grunt-contrib-uglify": "^1.0.1",
"grunt-ng-annotate": "^2.0.1",
"grunt-ngmin": "0.0.3"
}
}
import auth.ExampleAuthenticator; import auth.ExampleAuthenticator;
import com.bazaarvoice.dropwizard.webjars.WebJarBundle; import com.bazaarvoice.dropwizard.webjars.WebJarBundle;
import com.google.inject.AbstractModule;
import com.google.inject.Guice; import com.google.inject.Guice;
import com.google.inject.Injector; import com.google.inject.Injector;
import com.mongodb.MongoClient;
import commands.PurgeDatabaseCommand; import commands.PurgeDatabaseCommand;
import commands.RegisterTasksCommand; import commands.RegisterTasksCommand;
import commands.RegisterTeamsCommand; import commands.RegisterTeamsCommand;
...@@ -25,9 +23,6 @@ import resources.*; ...@@ -25,9 +23,6 @@ import resources.*;
import java.util.stream.Stream; import java.util.stream.Stream;
/**
* Created by gpietrus on 16.02.16.
*/
public class CTFApplication extends Application<ApplicationConfiguration> public class CTFApplication extends Application<ApplicationConfiguration>
{ {
private Injector injector; private Injector injector;
...@@ -35,7 +30,8 @@ public class CTFApplication extends Application<ApplicationConfiguration> ...@@ -35,7 +30,8 @@ public class CTFApplication extends Application<ApplicationConfiguration>
@Override @Override
public void initialize(final Bootstrap<ApplicationConfiguration> bootstrap) public void initialize(final Bootstrap<ApplicationConfiguration> bootstrap)
{ {
bootstrap.addBundle(new AssetsBundle("/assets", "/page", "index.html")); //todo: refactor, will not work on artifact?
bootstrap.addBundle(new AssetsBundle("/assets_build", "/page", "index.html"));
bootstrap.addCommand(new PurgeDatabaseCommand()); bootstrap.addCommand(new PurgeDatabaseCommand());
bootstrap.addCommand(new RegisterTasksCommand()); bootstrap.addCommand(new RegisterTasksCommand());
bootstrap.addCommand(new RegisterTeamsCommand()); bootstrap.addCommand(new RegisterTeamsCommand());
......
...@@ -4,9 +4,8 @@ ...@@ -4,9 +4,8 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>CTF</title> <title>CTF</title>
<link rel="stylesheet" href="/webjars/materializecss/css/materialize.min.css"> <link rel="stylesheet" href="/webjars/materializecss/css/materialize.min.css">
<link rel="stylesheet" href="/page/statics/libs/angular-materialize.css">
<link rel="stylesheet" href="/webjars/font-awesome/css/font-awesome.min.css"> <link rel="stylesheet" href="/webjars/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="/page/statics/css/main.css"> <link rel="stylesheet" href="/page/statics/css/main.min.css">
</head> </head>
<nav ng-controller="NavigationController"> <nav ng-controller="NavigationController">
...@@ -34,28 +33,6 @@ ...@@ -34,28 +33,6 @@
<script type="text/javascript" src="/webjars/angularjs/angular.min.js"></script> <script type="text/javascript" src="/webjars/angularjs/angular.min.js"></script>
<script type="text/javascript" src="/webjars/angular-ui-router/angular-ui-router.min.js"></script> <script type="text/javascript" src="/webjars/angular-ui-router/angular-ui-router.min.js"></script>
<script type="text/javascript" src="/webjars/angular-cookies/angular-cookies.min.js"></script> <script type="text/javascript" src="/webjars/angular-cookies/angular-cookies.min.js"></script>
<script type="text/javascript" src="/page/statics/libs/angular-materialize.js"></script> <script type="text/javascript" src="/page/statics/js/app.min.js"></script>
<script type="text/javascript" src="/page/statics/libs/angular-breadcrumb.min.js"></script>
<script type="text/javascript" src="/page/statics/libs/typed.js"></script>
<script type="text/javascript" src="/page/statics/js/main.js"></script>
<script type="text/javascript" src="/page/statics/js/base64.js"></script>
<script type="text/javascript" src="/page/statics/js/apiProvider.js"></script>
<script type="text/javascript" src="/page/statics/js/authenticationService.js"></script>
<script type="text/javascript" src="/page/statics/js/controllers/navigationController.js"></script>
<script type="text/javascript" src="/page/statics/js/controllers/loginController.js"></script>
<script type="text/javascript" src="/page/statics/js/controllers/taskController.js"></script>
<script type="text/javascript" src="/page/statics/js/controllers/tasksController.js"></script>
<script type="text/javascript" src="/page/statics/js/controllers/scoreboardController.js"></script>
<script>
</script>
</html> </html>
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
} }
$scope.teamsScores = calculatePerTeam(data); $scope.teamsScores = calculatePerTeam(data);
console.log($scope.teamsScores); console.log($scope.teamsScores);
viewGraph() viewGraph();
}); });
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
var app = angular.module('ctfApp', ['ui.router', 'ncy-angular-breadcrumb', 'ngCookies']); var app = angular.module('ctfApp', ['ui.router', 'ncy-angular-breadcrumb', 'ngCookies']);
app.config(function($stateProvider, $urlRouterProvider, $breadcrumbProvider) { app.config(['$stateProvider', '$urlRouterProvider', '$breadcrumbProvider', function($stateProvider, $urlRouterProvider, $breadcrumbProvider) {
$urlRouterProvider.otherwise('/home'); $urlRouterProvider.otherwise('/home');
...@@ -35,17 +35,17 @@ ...@@ -35,17 +35,17 @@
templateUrl: '/page/scoresheet.html' templateUrl: '/page/scoresheet.html'
}); });
}); }]);
app.factory('AppSettings', function() { app.factory('AppSettings', function() {
return { return {
apiAddress: "localhost:8080/api/v1" apiAddress: "localhost:8080/api/v1"
} };
}); });
app.config(function ($httpProvider) { app.config(['$httpProvider', function ($httpProvider) {
$httpProvider.interceptors.push(function ($q) { $httpProvider.interceptors.push(['$q', function ($q) {
return { return {
'response': function (response) { 'response': function (response) {
if (response.status === 401) { if (response.status === 401) {
...@@ -60,8 +60,8 @@ ...@@ -60,8 +60,8 @@
return $q.reject(rejection); return $q.reject(rejection);
} }
}; };
}); }]);
}); }]);
app.run(['$rootScope', '$location', '$cookieStore', '$http', app.run(['$rootScope', '$location', '$cookieStore', '$http',
function ($rootScope, $location, $cookieStore, $http) { function ($rootScope, $location, $cookieStore, $http) {
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
var result; var result;
if (!tasks) { if (!tasks) {
this.getTasks(function(data){ this.getTasks(function(data){
result = this.getTaskById(id, callback) result = this.getTaskById(id, callback);
}.bind(this)); }.bind(this));
} }
else { else {
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
callback(response); callback(response);
}, function(response) { }, function(response) {
callback(response); callback(response);
}) });
}, },
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
}.bind(this), function(response){ }.bind(this), function(response){
this.clearCredentials(); this.clearCredentials();
callback(response); callback(response);
}.bind(this)) }.bind(this));
}, },
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
} }
}; };
$http.defaults.headers.common['Authorization'] = 'Basic ' + authdata; $http.defaults.headers.common.Authorization = 'Basic ' + authdata;
$cookieStore.put('globals', $rootScope.globals); $cookieStore.put('globals', $rootScope.globals);
}, },
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
$rootScope.globals = {}; $rootScope.globals = {};
$cookieStore.remove('globals'); $cookieStore.remove('globals');
$http.defaults.headers.common.Authorization = 'Basic ' $http.defaults.headers.common.Authorization = 'Basic ';
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment