source: branches/TaskRewrite/src/plugins/acegi-0.5.1/scripts/GenerateRegistration.groovy @ 58

Last change on this file since 58 was 58, checked in by gav, 15 years ago

Configure BootStrap? with latest concepts.
Install and setup Acegi plugin with custom views.
Test Fixture plugin in a test app but couldn't get it to work with Acegi encodePassword() so gave up.

File size: 3.1 KB
Line 
1/* Copyright 2006-2009 the original author or authors.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *      http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * Generates user registration views and controllers.
18 *
19 * @author Haotian Sun
20 * @author Tsuyoshi Yamamoto
21 * @author <a href='mailto:beckwithb@studentsonly.com'>Burt Beckwith</a>
22 */
23
24includeTargets << new File("$acegiPluginDir/scripts/_SecurityTargets.groovy")
25
26pluginTemplatePath = "$templateDir/manager"
27
28target('default': 'Generates user registration views and controllers') {
29
30        loadConfig()
31
32        if (!new File("$basedir/lib/mail-1.4.jar").exists()) {
33                println "Downloading mail-1.4 ..."
34                get(dest: "$basedir/lib/mail-1.4.jar",
35                        src: "http://repo1.maven.org/maven2/javax/mail/mail/1.4/mail-1.4.jar",
36                        verbose: true,
37                        usetimestamp: true)
38        }
39
40        if (!new File("$basedir/lib/activation-1.1.jar").exists()) {
41                println "Downloading activation-1.1.jar ..."
42                get(dest: "$basedir/lib/activation-1.1.jar",
43                        src: "http://repo1.maven.org/maven2/javax/activation/activation/1.1/activation-1.1.jar",
44                        verbose: true,
45                        usetimestamp: true)
46        }
47
48        generateRegistration 'register'
49}
50
51private void generateRegistration(String name) {
52
53        def uname = name[0].toUpperCase() + name.substring(1)
54        def outFile = new File("$basedir/grails-app/controllers/${uname}Controller.groovy")
55        if (outFile.exists()) {
56                Ant.input(addProperty: 'overwrite', message: 'Do you want to overwrite? y/n')
57                if ('y' == Ant.antProject.properties.'overwrite') {
58                        overwrite = true
59                }
60        }
61        else {
62                overwrite = true
63        }
64
65        println "generating files for $uname ......."
66
67        //copy the CaptchaController
68        String dest = "$basedir/grails-app/controllers/CaptchaController.groovy"
69        println "copying CaptchaController.groovy to - $dest"
70        copyFile "$pluginTemplatePath/controllers/_CaptchaController.groovy", dest
71
72        //copy the EmailerService
73        dest = "$basedir/grails-app/services/EmailerService.groovy"
74        println "copying EmailerService.groovy to - $dest"
75        copyFile "$pluginTemplatePath/services/_EmailerService.groovy", dest
76
77        //generate RegisterController.groovy
78        dest = "$basedir/grails-app/controllers/${uname}Controller.groovy"
79        println "generating file $dest"
80        generateFile "$pluginTemplatePath/controllers/_${uname}Controller.groovy", dest
81
82        //generate views for RegisterController
83        dest = "$basedir/grails-app/views/$name"
84        println "copying view files to - $dest/*"
85        Ant.mkdir dir: dest
86        copyFile "$pluginTemplatePath/views/$name/edit.gsp", "$dest/edit.gsp"
87        copyFile "$pluginTemplatePath/views/$name/index.gsp", "$dest/index.gsp"
88        copyFile "$pluginTemplatePath/views/$name/show.gsp", "$dest/show.gsp"
89}
Note: See TracBrowser for help on using the repository browser.