-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKickstartWithBootstrapGrailsPlugin.groovy
More file actions
118 lines (98 loc) · 4.46 KB
/
KickstartWithBootstrapGrailsPlugin.groovy
File metadata and controls
118 lines (98 loc) · 4.46 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
import kickstart.CustomDateEditorRegistrar
class KickstartWithBootstrapGrailsPlugin {
def title = "Kickstart with Bootstrap - Good looking websites!"
def version = "1.3.0"
def license = "APACHE"
def description = """\
Kickstart is a plugin for Grails to start your project with a good looking frontend. \
It provides adapted scaffolding templates for standard CRUD pages using the Bootstrap \
frontend framework initiated by Twitter."""
def grailsVersion = "2.4 > *"
// resources that are excluded from plugin packaging
def pluginExcludes = [
// "grails-app/views/error.gsp"
'web-app/WEB-INF/**'
]
def developers = [
[ name: "Ibrahim H.", email: "bitsnaps@yahoo.fr" ]
]
def documentation = "http://grails.org/plugin/kickstart-with-bootstrap"
def scm = [ url: "https://github.com/bitsnaps/KickstartWithBootstrap" ]
def issueManagement = [ url: "https://github.com/bitsnaps/KickstartWithBootstrap/issues", system: "GitHub" ]
// Extra (optional) plugin metadata
// License: one of 'APACHE', 'GPL2', 'GPL3'
// def license = "APACHE"
// Details of company behind the plugin (if there is one)
// def organization = [ name: "My Company", url: "http://www.my-company.com/" ]
// Any additional developers beyond the author specified above.
// def developers = [ [ name: "Joe Bloggs", email: "joe@bloggs.net" ]]
// Location of the plugin's issue tracker.
// def issueManagement = [ system: "JIRA", url: "http://jira.grails.org/browse/GPMYPLUGIN" ]
// Online location of the plugin's browseable source code.
// def scm = [ url: "http://svn.codehaus.org/grails-plugins/" ]
def doWithWebDescriptor = { xml ->
// TODO Implement additions to web.xml (optional), this event occurs before
}
def doWithSpring = {
customPropertyEditorRegistrar(CustomDateEditorRegistrar) {
grailsApplication = ref("grailsApplication")
}
}
def doWithDynamicMethods = { ctx ->
// TODO Implement registering dynamic methods to classes (optional)
}
def doWithApplicationContext = { ctx ->
// Collect all *.properties files in the I18N directory and build list of "available" locales
def locales = []
def i18nDir
try {
if (application.isWarDeployed()) {
def filePath = "grails-app/i18n"
i18nDir = application.parentContext.getResource("${File.separator}WEB-INF${File.separator}${filePath}")?.getFile()
} else {
i18nDir = new File(System.properties['base.dir'] + "/grails-app/i18n")
}
if (i18nDir != null && i18nDir.exists()) {
i18nDir.eachFileRecurse {
if (it.file && it =~ /messages.*\.properties/) {
// Extract locale from filename using RegEx
def matcher = it.name =~ /messages(.*)\.properties/
def result = matcher[0][1] // @see http://groovy.codehaus.org/Regular+Expressions
if (result != null && result.size() == 3) {
locales << result.substring(1, 3).toLowerCase() // should be empty ("") and starts with "_" (e.g., "_de")
} else if (result != null && result.size() == 6) {
locales << result.substring(4, 6).toLowerCase() // should be empty ("") and starts with country (e.g., "_en_US")
} else {
// executed if the default "locale" - messages.properties is found
}
}
}
} else {
// add a minimum of locales
locales << "en"
locales << "de"
}
log.info "| Kickstart found ${locales.size()} locales usable in the language selector (excluding the default \"locale\" messages.properties)."
} catch (Exception e) {
log.warn "WARNING: could not find the directory to the project's I18N files! The Language Switcher might not work correctly!"
log.warn e.getMessage()
// add a minimum of locales
locales << "en"
locales << "de"
}
application.config.grails.i18n.locales = locales
System.setProperty('grails.i18n.locales', locales.toString())
}
def onChange = { event ->
// TODO Implement code that is executed when any artefact that this plugin is
// watching is modified and reloaded. The event contains: event.source,
// event.application, event.manager, event.ctx, and event.plugin.
}
def onConfigChange = { event ->
// TODO Implement code that is executed when the project configuration changes.
// The event is the same as for 'onChange'.
}
def onShutdown = { event ->
// TODO Implement code that is executed when the application shuts down (optional)
}
}