First attempt to remove JSP and move to Thymeleaf and update to Spring Boot. The Thymeleaf templates can be loaded as snippets which makes it more easy to move away from ECS and create normal HTML pages for a lesson.
This commit is contained in:
@ -0,0 +1,13 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/CookieModel'],
|
||||
function($,
|
||||
_,
|
||||
Backbone,
|
||||
CookieModel) {
|
||||
return Backbone.Collection.extend({
|
||||
url:'service/cookie.mvc',
|
||||
model:CookieModel
|
||||
});
|
||||
});
|
@ -0,0 +1,9 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone'],
|
||||
function($,
|
||||
_,
|
||||
Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
});
|
||||
});
|
@ -0,0 +1,25 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone'],
|
||||
function($,_,Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
//url:'service/lessonplan.mvc',
|
||||
fetch: function (options) {
|
||||
options = options || {};
|
||||
return Backbone.Model.prototype.fetch.call(this, _.extend({ dataType: "html"}, options));
|
||||
},
|
||||
|
||||
loadData: function() {
|
||||
var self=this;
|
||||
this.fetch().then(function(data) {
|
||||
self.setContent(data);
|
||||
});
|
||||
},
|
||||
|
||||
setContent: function(content) {
|
||||
this.set('content',content);
|
||||
this.checkNullModel();
|
||||
this.trigger('loaded');
|
||||
}
|
||||
});
|
||||
});
|
@ -0,0 +1,32 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/HintModel'],
|
||||
|
||||
function($,
|
||||
_,
|
||||
Backbone,
|
||||
HintModel) {
|
||||
return Backbone.Collection.extend({
|
||||
model: HintModel,
|
||||
url:'service/hint.mvc',
|
||||
initialize: function () {
|
||||
var self = this;
|
||||
this.fetch().then(function (data) {
|
||||
this.models = data;
|
||||
self.onDataLoaded();
|
||||
});
|
||||
},
|
||||
|
||||
onDataLoaded:function() {
|
||||
this.trigger('loaded');
|
||||
},
|
||||
|
||||
checkNullModel:function() {
|
||||
if (this.models[0].indexOf('There are no hints defined.') > -1) {
|
||||
this.reset([]);
|
||||
//return this.models;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
@ -0,0 +1,10 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone'],
|
||||
function($,
|
||||
_,
|
||||
Backbone,
|
||||
HTMLContentModel) {
|
||||
return Backbone.Model.extend({
|
||||
});
|
||||
});
|
@ -0,0 +1,54 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/HTMLContentModel'],
|
||||
function($,
|
||||
_,
|
||||
Backbone,
|
||||
HTMLContentModel){
|
||||
|
||||
return HTMLContentModel.extend({
|
||||
urlRoot:null,
|
||||
defaults: {
|
||||
items:null,
|
||||
selectedItem:null
|
||||
},
|
||||
initialize: function (options) {
|
||||
this.scrParam = null;
|
||||
this.menuParam = null;
|
||||
this.stageParam = null;
|
||||
this.numParam = null;
|
||||
this.baseUrlRoot = 'attack';
|
||||
},
|
||||
loadData: function(options) {
|
||||
this.urlRoot = this.baseUrlRoot + "?Screen=" + options.scr + '&menu=' + options.menu;
|
||||
if (options.stage != null) {
|
||||
this.urlRoot += '&stage=' + options.stage;
|
||||
}
|
||||
if (options.num != null) {
|
||||
this.urlRoot += '&Num=' + options.num;
|
||||
}
|
||||
this.set('menuParam', options.menu);
|
||||
this.set('scrParam', options.scr);
|
||||
this.set('stageParam', options.stage)
|
||||
this.set('numParam', options.num)
|
||||
var self = this;
|
||||
this.fetch().done(function(data) {
|
||||
self.setContent(data);
|
||||
});
|
||||
},
|
||||
|
||||
setContent: function(content, loadHelps) {
|
||||
if (typeof loadHelps === 'undefined') {
|
||||
loadHelps = true;
|
||||
}
|
||||
this.set('content',content);
|
||||
this.trigger('content:loaded',this,loadHelps);
|
||||
},
|
||||
|
||||
fetch: function (options) {
|
||||
options = options || {};
|
||||
return Backbone.Model.prototype.fetch.call(this, _.extend({ dataType: "html"}, options));
|
||||
}
|
||||
});
|
||||
});
|
@ -0,0 +1,20 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone'],
|
||||
function($,
|
||||
_,
|
||||
Backbone){
|
||||
|
||||
return Backbone.Model.extend({
|
||||
url:'service/lessoninfo.mvc',
|
||||
|
||||
initialize: function (options) {
|
||||
this.fetch().then(this.infoLoaded.bind(this));
|
||||
},
|
||||
|
||||
infoLoaded: function(data) {
|
||||
this.trigger('info:loaded',this,data);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
@ -0,0 +1,17 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/HTMLContentModel'],
|
||||
function($,
|
||||
_,
|
||||
Backbone,
|
||||
HTMLContentModel) {
|
||||
return HTMLContentModel.extend({
|
||||
url:'service/lessonplan.mvc',
|
||||
checkNullModel: function() {
|
||||
if (this.get('content').indexOf('Could not find lesson plan for') > -1) {
|
||||
this.set('content',null);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
@ -0,0 +1,29 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/MenuModel'],
|
||||
function($,_,Backbone,MenuModel) {
|
||||
|
||||
return Backbone.Collection.extend({
|
||||
model: MenuModel,
|
||||
url:'service/lessonmenu.mvc',
|
||||
initialize: function () {
|
||||
var self = this;
|
||||
this.fetch();
|
||||
},
|
||||
|
||||
onDataLoaded: function() {
|
||||
this.trigger('menuData:loaded');
|
||||
},
|
||||
|
||||
fetch: function() {
|
||||
var self=this;
|
||||
Backbone.Collection.prototype.fetch.apply(this,arguments).then(
|
||||
function(data) {
|
||||
this.models = data;
|
||||
self.onDataLoaded();
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
@ -0,0 +1,32 @@
|
||||
//var goatApp = goatApp || {};
|
||||
|
||||
define(['jquery','underscore','backbone'], function($,_,Backbone) {
|
||||
|
||||
var menuData = Backbone.Model.extend({
|
||||
urlRoot:'/webgoat/service/lessonmenu.mvc',
|
||||
defaults: {
|
||||
items:null,
|
||||
selectedItem:null
|
||||
},
|
||||
initialize: function () {
|
||||
var self = this;
|
||||
this.fetch().then(function(menuItems){
|
||||
menuItems = goatUtils.enhanceMenuData(menuItems,this.selectedItem);
|
||||
this.setDataItems(menuItems);
|
||||
});
|
||||
},
|
||||
|
||||
update: function() {
|
||||
var self = this;
|
||||
this.fetch().then(function(menuItems) {
|
||||
menuItems = goatUtils.enhanceMenuData(menuItems,this.selectedItem);
|
||||
self.setDataItems(menuItems);
|
||||
});
|
||||
},
|
||||
|
||||
setDataItems: function (data) {
|
||||
this.items = data;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
@ -0,0 +1,10 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone'],
|
||||
function($,_,Backbone) {
|
||||
|
||||
return Backbone.Model.extend({
|
||||
|
||||
});
|
||||
|
||||
});
|
@ -0,0 +1,12 @@
|
||||
define([
|
||||
'backbone'],
|
||||
function(
|
||||
Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
initialize: function(options) {
|
||||
for (var key in options) {
|
||||
this.set(key, options.key);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
@ -0,0 +1,18 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/HTMLContentModel'],
|
||||
function($,
|
||||
_,
|
||||
Backbone,
|
||||
HTMLContentModel) {
|
||||
return HTMLContentModel.extend({
|
||||
url:'service/solution.mvc',
|
||||
checkNullModel: function() {
|
||||
if (this.get('content').indexOf('Could not find the solution file or solution file does not exist') === 0) {
|
||||
this.set('content',null);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
@ -0,0 +1,19 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'goatApp/model/HTMLContentModel'],
|
||||
function($,
|
||||
_,
|
||||
Backbone,
|
||||
HTMLContentModel) {
|
||||
return HTMLContentModel.extend({
|
||||
url:'service/source.mvc',
|
||||
checkNullModel: function () {
|
||||
//TODO: move this function into HTMLContentModel and make the string a property of this 'child' model
|
||||
if (this.get('content').indexOf("Could not find the source file or") > -1) {
|
||||
this.set('content',null);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user