forked from timcunningham/learncfinaweek
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApplication.cfc
105 lines (93 loc) · 3.42 KB
/
Application.cfc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
component extends="org.corfield.framework" {
this.name='learncfinaweek';
this.sessionManagement = true;
// ORM Settings
this.datasource = "learncfinaweek";
this.ormenabled = true;
this.mappings["/com"] = "#getDirectoryFromPath(getCurrentTemplatePath())#/com";
this.mappings["/coldspring"] = "#getDirectoryFromPath(getCurrentTemplatePath())#/org/coldspring";
this.ormsettings = {
dbcreate="update",
cfclocation="com/entity"
};
variables.framework = {
usingSubsystems = true,
defaultSubsystem = 'frontend',
defaultSection = 'main',
defaultItem = 'default',
subsystemDelimiter = ':',
siteWideLayoutSubsystem = 'common',
home = "frontend:main.default",
error = "admin:main.error",
preserveKeyURLKey = 'fw1pk',
applicationKey = 'org.corfield.framework',
unhandledPaths='/flex2gateway,/404.cfm,/sorry.cfm,/api',
reloadApplicationOnEveryRequest=false,
reload = 'doit'/*,
password = 'fuckyea'*/
};
function setupSession() {
controller( 'security.session' );
if(structKeyExists(url,'campaign')){
session.campaign=url.campaign;
}
session.HTTP_REFERER=cgi.HTTP_REFERER;
session.HTTP_USER_AGENT = cgi.HTTP_USER_AGENT;
session.showNavigation = true;
}
function setupRequest() {
verifyApplicationSetup();
controller( 'security.authorize' );
}
public void function verifyApplicationSetup() {
if(structKeyExists(url, variables.framework.reload)) {
application.app.initialized = false;
}
if(!structKeyExists(application, "app") || !structKeyExists(application.app, "initialized") || !application.app.initialized) {
lock scope="Application" timeout="120" {
if(!structKeyExists(application, "app") || !structKeyExists(application.app, "initialized") || !application.app.initialized) {
application.app = structNew();
application.app.initialized = false;
application.cachedContent = {};
application.cachedContributors = [];
application.cachedResources = {};
application.fw = this;
application.cssVersion = 1;
application.jsVersion = 1;
application.seoKeywords = 'ColdFusion, opensource, training, course';
application.seoDescription = 'Learn CF in a Week is a OpenSource ColdFusion training course that teaches people everything they need to know to be a ColdFusion developer';
application.pageService = createObject('component','com.service.pageService').init();
createObject('component','com.service.tagUtilityService').cache(action='flush');
//createObject('component','com.service.cacheService').prepopulate();
ormReload();
application.app.initialized = true;
setupSession();
}
}
}
}
function onMissingTemplate(string template){
include "/404.cfm";
abort;
}
function onError( any Exception, string EventName ) {
if(structKeyExists(arguments.exception,'cause') && arguments.exception.cause.ErrorCode eq '404'){
include "/404.cfm";
abort;
}else{
include "/sorry.cfm";
var errorEmail = new mail();
errorEmail.setTo('[email protected]');
errorEmail.setFrom('[email protected]');
if(structKeyExists(arguments.exception,'cause')){
errorEmail.setSubject('An Error has Occured- ' & arguments.exception.cause.message);
}else{
errorEmail.setSubject('An Error has Occured');
}
errorEmail.setBody(createObject('com.service.tagUtilityService').content(arguments.exception,cgi));
errorEmail.setType('html');
errorEmail.send();
abort;
}
}
}