Skip to content

Commit 257eb6f

Browse files
author
Adam Collins
committed
remove functionality to use assets in /data/spatial-hub/assets and /view at runtime
1 parent cfe81be commit 257eb6f

File tree

2 files changed

+0
-97
lines changed

2 files changed

+0
-97
lines changed

README.md

-28
Original file line numberDiff line numberDiff line change
@@ -123,34 +123,6 @@ The dependent services point to other production servers by default
123123
##### Fork [spatial-hub](https://github.com/AtlasOfLivingAustralia/spatial-hub), modify and deploy
124124
* Use when development of spatial-hub is expected. It can be used with with the other methods.
125125
126-
##### Local files
127-
* Adding files local to deployment can add new layouts and resources.
128-
129-
1. Add a new layout gsp to the ```/data/spatial-hub/views/layouts``` directory.
130-
```
131-
/data/spatial-hub/views/layouts/myLayout.gsp
132-
```
133-
134-
1. Additional assets can be added to the ```/data/spatial-hub/assets``` directory.
135-
```
136-
/data/spatial-hub/assets/css/externalCss.css
137-
/data/spatial-hub/assets/js/externalJs.js
138-
/data/spatial-hub/assets/img/externalImage.png
139-
```
140-
141-
1. Assets can be referenced within the new layout gsp.
142-
```
143-
<asset:stylesheet src="css/externalCss.css" />
144-
<asset:javascript src="js/externalJs.js" />
145-
<asset:image src="img/externalImg.png" />
146-
```
147-
148-
1. Change config to use the new layout gsp.
149-
```
150-
# edit /data/spatial-hub/config/spatial-hub-config.properties
151-
skin.layout=myLayout
152-
```
153-
154126
> **Note:**
155127
>
156128
> A forked [commonui-bs3](https://github.com/AtlasOfLivingAustralia/commonui-bs3) can be deployed to ```/data/spatial-hub/assets/``` and used with the config

grails-app/init/au/org/ala/spatial/portal/BootStrap.groovy

-69
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package au.org.ala.spatial.portal
22

3-
import asset.pipeline.AssetPipelineConfigHolder
4-
import asset.pipeline.fs.FileSystemAssetResolver
53
import au.org.ala.cas.util.AuthenticationUtils
64
import au.org.ala.web.AuthService
75
import grails.converters.JSON
8-
import org.apache.commons.io.FileUtils
96
import org.apache.commons.lang3.StringUtils
107
import org.springframework.core.io.FileSystemResource
118
import org.springframework.core.io.Resource
@@ -31,75 +28,9 @@ class BootStrap {
3128
// fix config data types when using a .properties file
3229
parseConfig()
3330

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-
5531
portalService.updateListQueries()
5632
}
5733

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-
10334
def destroy = {
10435
}
10536

0 commit comments

Comments
 (0)