diff --git a/README.md b/README.md index a6d1e56..9d28f7e 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,12 @@ compile org.grails.plugins:view-tools:1.2.0 compile :view-tools:0.3-grails2 ``` +## Configuration +To make plugin look into grails3 folders add next line as a first line for you `BuildConfig.groovy` +``` +grails.useGrails3FolderLayout = true +``` + ### ViewResourceLocator **Example Bean** ```groovy diff --git a/plugin/src/main/groovy/grails/plugin/viewtools/AppResourceLoader.groovy b/plugin/src/main/groovy/grails/plugin/viewtools/AppResourceLoader.groovy index 66eec50..51c269c 100644 --- a/plugin/src/main/groovy/grails/plugin/viewtools/AppResourceLoader.groovy +++ b/plugin/src/main/groovy/grails/plugin/viewtools/AppResourceLoader.groovy @@ -127,8 +127,9 @@ class AppResourceLoader implements ResourceLoader, GrailsConfigurationAware { * file: the File instace that we put in that directory */ @SuppressWarnings("ReturnsNullInsteadOfEmptyCollection") - Map createAttachmentFile(Long attachmentId, String name, String extension, Object data) { + Map createAttachmentFile(Long attachmentId, String name, String extension, Object data, String location = null) { if (!data) return null + if(!location) location = ATTACHMENT_LOCATION_KEY String prefix = "" if (name) { prefix = "${name}_" @@ -139,7 +140,7 @@ class AppResourceLoader implements ResourceLoader, GrailsConfigurationAware { String destFileName = extension ? "${prefix}${attachmentId}.${extension}" : "${prefix}${attachmentId}" //setup the monthly dir for attachments - File monthDir = getMonthDirectory(ATTACHMENT_LOCATION_KEY) + File monthDir = getMonthDirectory(location) File file = new File(monthDir, destFileName) if (data) { if (data instanceof File) FileUtils.moveFile(data, file)