1
1
package au.org.ala.spatial.portal
2
2
3
- import asset.pipeline.AssetPipelineConfigHolder
4
- import asset.pipeline.fs.FileSystemAssetResolver
5
3
import au.org.ala.cas.util.AuthenticationUtils
6
4
import au.org.ala.web.AuthService
7
5
import grails.converters.JSON
8
- import org.apache.commons.io.FileUtils
9
6
import org.apache.commons.lang3.StringUtils
10
7
import org.springframework.core.io.FileSystemResource
11
8
import org.springframework.core.io.Resource
@@ -31,75 +28,9 @@ class BootStrap {
31
28
// fix config data types when using a .properties file
32
29
parseConfig()
33
30
34
- // support for external layouts
35
- //
36
- // e.g. config "skin.layout=myLayout" will use the layout file /data/spatial-hub/views/layouts/myLayout.gsp
37
- //
38
- // support external files with the asset tag in the layout gsp
39
- // e.g.
40
- // files
41
- // /data/spatial-hub/assets/css/externalCss.css
42
- // /data/spatial-hub/assets/js/externalJs.js
43
- // /data/spatial-hub/assets/img/externalImage.png
44
- // asset tags
45
- // <asset:stylesheet src="css/externalCss.css" />
46
- // <asset:javascript src="js/externalJs.js" />
47
- // <asset:image src="img/externalImg.png" />
48
- //
49
- // Support the use of the default "skin.layout=generic" with a local "headerAndFooter.baseURL" by the creating files
50
- // /data/spatial-hub/assets/css/bootstrap.min.css
51
- // /data/spatial-hub/assets/css/ala-styles.css
52
- addExternalViews()
53
- addExternalAssets(servletContext)
54
-
55
31
portalService. updateListQueries()
56
32
}
57
33
58
- def addExternalViews = {
59
- groovyPageLocator. addResourceLoader(new ResourceLoader () {
60
-
61
- @Override
62
- Resource getResource (String s ) {
63
- File resource = new File (' /data/spatial-hub/views' + s)
64
- if (resource. exists()) {
65
- return new FileSystemResource (resource)
66
- }
67
- return null
68
- }
69
-
70
- @Override
71
- ClassLoader getClassLoader () {
72
- return null
73
- }
74
- })
75
- }
76
-
77
- def addExternalAssets = { servletContext ->
78
- try {
79
- File src = new File (' /data/spatial-hub/assets' )
80
-
81
- if (src. exists() && src. isDirectory()) {
82
- // asset-pipeline resolves files differently depending on the presence of a manifest
83
- if (AssetPipelineConfigHolder . manifest) {
84
- // copy external asset files into expanded war assets directory so they can be discovered
85
- File dst = new File (servletContext. getRealPath(" /assets" ))
86
-
87
- if (dst. exists() && dst. isDirectory()) {
88
- FileUtils . copyDirectory(src, dst)
89
- } else {
90
- log. error(" External assets are unavailable. Expanded WAR asset directory '${ dst.path} ' does not exist." )
91
- }
92
- } else {
93
- // a new Resolver is required to find the external assets at runtime
94
- def resolver = new FileSystemAssetResolver (" external-assets" , ' /data/spatial-hub/assets' , false )
95
- AssetPipelineConfigHolder . registerResolver(resolver)
96
- }
97
- }
98
- } catch (err) {
99
- log. error(" External assets are not available." , err)
100
- }
101
- }
102
-
103
34
def destroy = {
104
35
}
105
36
0 commit comments