From bcdcb038f311af25db357c4202d1ce632f943b0c Mon Sep 17 00:00:00 2001 From: Bob Pawlowski Date: Sat, 8 Feb 2014 11:09:16 -0500 Subject: [PATCH 1/2] upgrade to grails 2.3.4, Fix example --- application.properties | 4 +- src/templates/scaffolding/index.gsp | 1 + test/apps/grails-ng/application.properties | 4 +- .../grails-app/conf/BuildConfig.groovy | 54 ++- .../grails-ng/grails-app/conf/Config.groovy | 24 ++ .../grails-app/conf/UrlMappings.groovy | 11 +- .../angular/test/AlbumController.groovy | 7 +- .../views/album/{index.gsp => page.gsp} | 0 .../grails-app/views/templates/_navbar.gsp | 2 +- .../web-app/WEB-INF/applicationContext.xml | 7 +- .../grails-ng/web-app/WEB-INF/tld/spring.tld | 342 +++++++++++++----- web-app/js/grails-resource.js | 4 +- 12 files changed, 324 insertions(+), 136 deletions(-) rename test/apps/grails-ng/grails-app/views/album/{index.gsp => page.gsp} (100%) diff --git a/application.properties b/application.properties index 1145884..3597ba5 100644 --- a/application.properties +++ b/application.properties @@ -1,5 +1,5 @@ #Grails Metadata file -#Mon Oct 14 03:48:27 CDT 2013 -app.grails.version=2.3.0 +#Sat Feb 08 05:23:52 EST 2014 +app.grails.version=2.3.4 app.name=angular-scaffolding app.servlet.version=2.5 diff --git a/src/templates/scaffolding/index.gsp b/src/templates/scaffolding/index.gsp index 55ac489..ebda8e6 100644 --- a/src/templates/scaffolding/index.gsp +++ b/src/templates/scaffolding/index.gsp @@ -10,6 +10,7 @@ + diff --git a/test/apps/grails-ng/application.properties b/test/apps/grails-ng/application.properties index eac5373..24fa545 100644 --- a/test/apps/grails-ng/application.properties +++ b/test/apps/grails-ng/application.properties @@ -1,6 +1,6 @@ #Grails Metadata file -#Thu Jan 17 06:46:29 GMT 2013 -app.grails.version=2.2.1 +#Sat Feb 08 05:29:08 EST 2014 +app.grails.version=2.3.4 app.name=grails-ng app.servlet.version=2.5 app.version=1.0-SNAPSHOT diff --git a/test/apps/grails-ng/grails-app/conf/BuildConfig.groovy b/test/apps/grails-ng/grails-app/conf/BuildConfig.groovy index c6dca4f..8f03899 100644 --- a/test/apps/grails-ng/grails-app/conf/BuildConfig.groovy +++ b/test/apps/grails-ng/grails-app/conf/BuildConfig.groovy @@ -1,8 +1,27 @@ -grails.project.work.dir = 'target' -grails.project.class.dir = 'target/classes' -grails.project.test.class.dir = 'target/test-classes' -grails.project.test.reports.dir = 'target/test-reports' +grails.servlet.version = "3.0" // Change depending on target container compliance (2.5 or 3.0) +grails.project.class.dir = "target/classes" +grails.project.test.class.dir = "target/test-classes" +grails.project.test.reports.dir = "target/test-reports" +grails.project.work.dir = "target/work" grails.project.target.level = 1.6 +grails.project.source.level = 1.6 +//grails.project.war.file = "target/${appName}-${appVersion}.war" + +grails.project.fork = [ + // configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required + // compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true], + + // configure settings for the test-app JVM, uses the daemon by default + test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true], + // configure settings for the run-app JVM + run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false], + // configure settings for the run-war JVM + war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false], + // configure settings for the Console UI JVM + console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256] +] + +grails.project.dependency.resolver = "maven" // or ivy grails.project.dependency.resolution = { @@ -10,6 +29,11 @@ grails.project.dependency.resolution = { log 'warn' repositories { + inherits true // Whether to inherit repository definitions from plugins + + grailsPlugins() + grailsHome() + grailsCentral() mavenCentral() mavenLocal() @@ -17,26 +41,24 @@ grails.project.dependency.resolution = { } dependencies { - test 'org.spockframework:spock-grails-support:0.7-groovy-2.0' } plugins { - build ":tomcat:$grailsVersion" + build ":tomcat:7.0.42" compile ':cloud-foundry:1.2.3', ':cache-headers:1.1.5', ':gson:1.1.4' - runtime ":hibernate:$grailsVersion", - ':resources:1.2.RC2', - ':jquery:1.8.3', - ':cached-resources:1.0', - ':zipped-resources:1.0', - ':database-migration:1.3.2' - - test(':spock:0.7') { - exclude 'spock-grails-support' - } + // plugins needed at runtime but not for compilation + runtime ":hibernate:3.6.10.5" // or ":hibernate4:4.1.11.1" + runtime ":database-migration:1.3.5" + runtime ":jquery:1.11.0" + runtime ":resources:1.2" + // Uncomment these (or add new ones) to enable additional resources capabilities + runtime ":zipped-resources:1.0.1" + runtime ":cached-resources:1.1" + } } diff --git a/test/apps/grails-ng/grails-app/conf/Config.groovy b/test/apps/grails-ng/grails-app/conf/Config.groovy index ff4f1e7..a67665e 100644 --- a/test/apps/grails-ng/grails-app/conf/Config.groovy +++ b/test/apps/grails-ng/grails-app/conf/Config.groovy @@ -97,3 +97,27 @@ log4j = { 'org.hibernate', 'net.sf.ehcache.hibernate' } + +// Uncomment and edit the following lines to start using Grails encoding & escaping improvements + +/* remove this line +// GSP settings +grails { + views { + gsp { + encoding = 'UTF-8' + htmlcodec = 'xml' // use xml escaping instead of HTML4 escaping + codecs { + expression = 'html' // escapes values inside null + scriptlet = 'none' // escapes output from scriptlets in GSPs + taglib = 'none' // escapes output from taglibs + staticparts = 'none' // escapes output from static template parts + } + } + // escapes all not-encoded output at final stage of outputting + filteringCodecForContentType { + //'text/html' = 'html' + } + } +} +remove this line */ diff --git a/test/apps/grails-ng/grails-app/conf/UrlMappings.groovy b/test/apps/grails-ng/grails-app/conf/UrlMappings.groovy index e91a439..9403c53 100644 --- a/test/apps/grails-ng/grails-app/conf/UrlMappings.groovy +++ b/test/apps/grails-ng/grails-app/conf/UrlMappings.groovy @@ -1,15 +1,8 @@ class UrlMappings { static mappings = { - "/album/index"(controller: "album", action: "index") - "/album"(controller: "album", action: "list") - "/album/$id?"(resource: "album") - - "/$controller/$action?/$id?"{ - constraints { - // apply constraints here - } - } + "/album/page"(controller: "album", action: "page") + "/album"(resources: "album") "/"(view:"/index") "500"(view:'/error') diff --git a/test/apps/grails-ng/grails-app/controllers/grails/plugin/angular/test/AlbumController.groovy b/test/apps/grails-ng/grails-app/controllers/grails/plugin/angular/test/AlbumController.groovy index 1f57305..1965d78 100644 --- a/test/apps/grails-ng/grails-app/controllers/grails/plugin/angular/test/AlbumController.groovy +++ b/test/apps/grails-ng/grails-app/controllers/grails/plugin/angular/test/AlbumController.groovy @@ -8,14 +8,15 @@ import static grails.plugin.gson.http.HttpConstants.* class AlbumController { - def index() { } - - def list(Integer max) { + def index(Integer max) { params.max = Math.min(max ?: 10, 100) response.addIntHeader X_PAGINATION_TOTAL, Album.count() render Album.list(params) as GSON } + def page() { + } + def save() { if (!requestIsJson()) { respondNotAcceptable() diff --git a/test/apps/grails-ng/grails-app/views/album/index.gsp b/test/apps/grails-ng/grails-app/views/album/page.gsp similarity index 100% rename from test/apps/grails-ng/grails-app/views/album/index.gsp rename to test/apps/grails-ng/grails-app/views/album/page.gsp diff --git a/test/apps/grails-ng/grails-app/views/templates/_navbar.gsp b/test/apps/grails-ng/grails-app/views/templates/_navbar.gsp index e06d453..049a3ae 100644 --- a/test/apps/grails-ng/grails-app/views/templates/_navbar.gsp +++ b/test/apps/grails-ng/grails-app/views/templates/_navbar.gsp @@ -5,7 +5,7 @@ diff --git a/test/apps/grails-ng/web-app/WEB-INF/applicationContext.xml b/test/apps/grails-ng/web-app/WEB-INF/applicationContext.xml index 69fbef3..a48dec0 100644 --- a/test/apps/grails-ng/web-app/WEB-INF/applicationContext.xml +++ b/test/apps/grails-ng/web-app/WEB-INF/applicationContext.xml @@ -1,8 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> Grails application factory bean @@ -30,4 +29,6 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem utf-8 + + \ No newline at end of file diff --git a/test/apps/grails-ng/web-app/WEB-INF/tld/spring.tld b/test/apps/grails-ng/web-app/WEB-INF/tld/spring.tld index 1bc7091..a0a8c6f 100644 --- a/test/apps/grails-ng/web-app/WEB-INF/tld/spring.tld +++ b/test/apps/grails-ng/web-app/WEB-INF/tld/spring.tld @@ -1,311 +1,457 @@ - - - - - - 1.1.1 - - 1.2 - - Spring - + + + + Spring Framework JSP Tag Library + 3.0 + spring http://www.springframework.org/tags - Spring Framework JSP Tag Library. Authors: Rod Johnson, Juergen Hoeller - - - - htmlEscape - org.springframework.web.servlet.tags.HtmlEscapeTag - JSP - Sets default HTML escape value for the current page. Overrides a "defaultHtmlEscape" context-param in web.xml, if any. - + htmlEscape + org.springframework.web.servlet.tags.HtmlEscapeTag + JSP + Set the default value for HTML escaping, to be put + into the current PageContext. defaultHtmlEscape true true - - - - escapeBody - org.springframework.web.servlet.tags.EscapeBodyTag - JSP - Escapes its enclosed body content, applying HTML escaping and/or JavaScript escaping. The HTML escaping flag participates in a page-wide or application-wide setting (i.e. by HtmlEscapeTag or a "defaultHtmlEscape" context-param in web.xml). - + escapeBody + org.springframework.web.servlet.tags.EscapeBodyTag + JSP + Set HTML escaping for this tag, as boolean value. Overrides the + default HTML escaping setting for the current page. htmlEscape false true - + Set JavaScript escaping for this tag, as boolean value. + Default is false. javaScriptEscape false true - - - - message - org.springframework.web.servlet.tags.MessageTag - JSP - Retrieves the message with the given code, or text if code isn't resolvable. The HTML escaping flag participates in a page-wide or application-wide setting (i.e. by HtmlEscapeTag or a "defaultHtmlEscape" context-param in web.xml). - + message + org.springframework.web.servlet.tags.MessageTag + JSP + A MessageSourceResolvable argument (direct or through JSP EL). + Fits nicely when used in conjunction with Spring's own validation error + classes which all implement the MessageSourceResolvable interface. For + example, this allows you to iterate over all of the errors in a form, + passing each error (using a runtime expression) as the value of this + 'message' attribute, thus effecting the easy display of such error + messages. + message + false + true + + + The code (key) to use when looking up the message. + If code is not provided, the text attribute will be used. code false true - + Set optional message arguments for this tag, as a + (comma-)delimited String (each String argument can contain JSP EL), + an Object array (used as argument array), or a single Object (used + as single argument). arguments false true - + The separator character to be used for splitting the + arguments string value; defaults to a 'comma' (','). + argumentSeparator + false + true + + + Default text to output when a message for the given code + could not be found. If both text and code are not set, the tag will + output null. text false true - + The string to use when binding the result to the page, + request, session or application scope. If not specified, the result + gets outputted to the writer (i.e. typically directly to the JSP). var false true - + The scope to use when exporting the result to a variable. + This attribute is only used when var is also set. Possible values are + page, request, session and application. scope false true - + Set HTML escaping for this tag, as boolean value. + Overrides the default HTML escaping setting for the current page. htmlEscape false true - + Set JavaScript escaping for this tag, as boolean value. Default is false. javaScriptEscape false true - - - - theme - org.springframework.web.servlet.tags.ThemeTag - JSP - Retrieves the theme message with the given code, or text if code isn't resolvable. The HTML escaping flag participates in a page-wide or application-wide setting (i.e. by HtmlEscapeTag or a "defaultHtmlEscape" context-param in web.xml). - + theme + org.springframework.web.servlet.tags.ThemeTag + JSP + A MessageSourceResolvable argument (direct or through JSP EL). + message + false + true + + + The code (key) to use when looking up the message. + If code is not provided, the text attribute will be used. code false true - + Set optional message arguments for this tag, as a + (comma-)delimited String (each String argument can contain JSP EL), + an Object array (used as argument array), or a single Object (used + as single argument). arguments false true - + The separator character to be used for splitting the + arguments string value; defaults to a 'comma' (','). + argumentSeparator + false + true + + + Default text to output when a message for the given code + could not be found. If both text and code are not set, the tag will + output null. text false true - + The string to use when binding the result to the page, + request, session or application scope. If not specified, the result + gets outputted to the writer (i.e. typically directly to the JSP). var false true - + The scope to use when exporting the result to a variable. + This attribute is only used when var is also set. Possible values are + page, request, session and application. scope false true - + Set HTML escaping for this tag, as boolean value. + Overrides the default HTML escaping setting for the current page. htmlEscape false true - + Set JavaScript escaping for this tag, as boolean value. Default is false. javaScriptEscape false true - - - - hasBindErrors - org.springframework.web.servlet.tags.BindErrorsTag - JSP - Provides Errors instance in case of bind errors. The HTML escaping flag participates in a page-wide or application-wide setting (i.e. by HtmlEscapeTag or a "defaultHtmlEscape" context-param in web.xml). - + hasBindErrors + org.springframework.web.servlet.tags.BindErrorsTag + JSP errors org.springframework.validation.Errors - + The name of the bean in the request, that needs to be + inspected for errors. If errors are available for this bean, they + will be bound under the 'errors' key. name true true - + Set HTML escaping for this tag, as boolean value. + Overrides the default HTML escaping setting for the current page. htmlEscape false true - - - - nestedPath - org.springframework.web.servlet.tags.NestedPathTag - JSP - Sets a nested path to be used by the bind tag's path. - + nestedPath + org.springframework.web.servlet.tags.NestedPathTag + JSP nestedPath java.lang.String - + Set the path that this tag should apply. E.g. 'customer' + to allow bind paths like 'address.street' rather than + 'customer.address.street'. path true true - - - - bind - org.springframework.web.servlet.tags.BindTag - JSP - Provides BindStatus object for the given bind path. The HTML escaping flag participates in a page-wide or application-wide setting (i.e. by HtmlEscapeTag or a "defaultHtmlEscape" context-param in web.xml). - + bind + org.springframework.web.servlet.tags.BindTag + JSP status org.springframework.web.servlet.support.BindStatus - + The path to the bean or bean property to bind status + information for. For instance account.name, company.address.zipCode + or just employee. The status object will exported to the page scope, + specifically for this bean or bean property path true true - + Set whether to ignore a nested path, if any. Default is to not ignore. ignoreNestedPath false true - + Set HTML escaping for this tag, as boolean value. Overrides + the default HTML escaping setting for the current page. htmlEscape false true - - - - transform - org.springframework.web.servlet.tags.TransformTag - JSP - Provides transformation of variables to Strings, using an appropriate custom PropertyEditor from BindTag (can only be used inside BindTag). The HTML escaping flag participates in a page-wide or application-wide setting - (i.e. by HtmlEscapeTag or a "defaultHtmlEscape" context-param in web.xml). + (i.e. by HtmlEscapeTag or a 'defaultHtmlEscape' context-param in web.xml). - + transform + org.springframework.web.servlet.tags.TransformTag + JSP + The value to transform. This is the actual object you want + to have transformed (for instance a Date). Using the PropertyEditor that + is currently in use by the 'spring:bind' tag. value true true - + The string to use when binding the result to the page, + request, session or application scope. If not specified, the result gets + outputted to the writer (i.e. typically directly to the JSP). var false true - + The scope to use when exported the result to a variable. + This attribute is only used when var is also set. Possible values are + page, request, session and application. scope false true + + Set HTML escaping for this tag, as boolean value. Overrides + the default HTML escaping setting for the current page. + htmlEscape + false + true + + + + URL tag based on the JSTL c:url tag. This variant is fully + backwards compatible with the standard tag. Enhancements include support + for URL template parameters. + url + org.springframework.web.servlet.tags.UrlTag + JSP + + The URL to build. This value can include template place holders + that are replaced with the URL encoded value of the named parameter. Parameters + must be defined using the param tag inside the body of this tag. + value + true + true + + + Specifies a remote application context path. The default is the + current application context path. + context + false + true + + + The name of the variable to export the URL value to. + var + false + true + + The scope for the var. 'application', 'session', 'request' and + 'page' scopes are supported. Defaults to page scope. This attribute has no + effect unless the var attribute is also defined. + scope + false + true + + + Set HTML escaping for this tag, as a boolean value. Overrides the + default HTML escaping setting for the current page. htmlEscape false true + + Set JavaScript escaping for this tag, as a boolean value. + Default is false. + javaScriptEscape + false + true + + + + + Parameter tag based on the JSTL c:param tag. The sole purpose is to + support params inside the spring:url tag. + param + org.springframework.web.servlet.tags.ParamTag + JSP + + The name of the parameter. + name + true + true + + + The value of the parameter. + value + false + true + + + + Evaluates a Spring expression (SpEL) and either prints the result or assigns it to a variable. + eval + org.springframework.web.servlet.tags.EvalTag + JSP + + The expression to evaluate. + expression + true + true + + + The name of the variable to export the evaluation result to. + var + false + true + + + The scope for the var. 'application', 'session', 'request' and + 'page' scopes are supported. Defaults to page scope. This attribute has no + effect unless the var attribute is also defined. + scope + false + true + + + Set HTML escaping for this tag, as a boolean value. Overrides the + default HTML escaping setting for the current page. + htmlEscape + false + true + + + Set JavaScript escaping for this tag, as a boolean value. Default is false. + javaScriptEscape + false + true + diff --git a/web-app/js/grails-resource.js b/web-app/js/grails-resource.js index 437e3da..1ae91e7 100644 --- a/web-app/js/grails-resource.js +++ b/web-app/js/grails-resource.js @@ -10,8 +10,8 @@ angular.module('grailsService', ['ngResource']).factory('Grails', function($reso return $resource(rootUrl + ':controller/:id', {id: '@id', controller: controller}, { list: {method: 'GET', isArray: true}, get: {method: 'GET'}, - save: {method: 'PUT'}, - update: {method: 'POST'}, + save: {method: 'POST'}, + update: {method: 'PUT'}, delete: {method: 'DELETE'} }); }); From b33b5a4f381e23196cd3a240b6c216ad8e49b287 Mon Sep 17 00:00:00 2001 From: Bob Pawlowski Date: Mon, 10 Feb 2014 06:26:54 -0500 Subject: [PATCH 2/2] Fix generator --- scripts/_NgGenerate.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_NgGenerate.groovy b/scripts/_NgGenerate.groovy index 62a5bf3..9a2d0b7 100644 --- a/scripts/_NgGenerate.groovy +++ b/scripts/_NgGenerate.groovy @@ -1,7 +1,7 @@ import grails.util.GrailsNameUtils includeTargets << grailsScript("_GrailsCreateArtifacts") -includeTargets << new File("scaffoldingPluginDir/scripts/_GrailsGenerate.groovy") +includeTargets << new File("$scaffoldingPluginDir/scripts/_GrailsGenerate.groovy") includeTargets << grailsScript("_GrailsBootstrap") generateForName = null