This repository has been archived by the owner on Dec 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed view resolution for plugin views and added test for this.
- Loading branch information
Showing
18 changed files
with
1,181 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
plugins/for-plugin-view-resolution/ForPluginViewResolutionGrailsPlugin.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
class ForPluginViewResolutionGrailsPlugin { | ||
// the plugin version | ||
def version = "0.1" | ||
// the version or versions of Grails the plugin is designed for | ||
def grailsVersion = "1.3.5 > *" | ||
// the other plugins this plugin depends on | ||
def dependsOn = [:] | ||
// resources that are excluded from plugin packaging | ||
def pluginExcludes = [ | ||
"grails-app/views/error.gsp" | ||
] | ||
|
||
// TODO Fill in these fields | ||
def author = "Your name" | ||
def authorEmail = "" | ||
def title = "Plugin summary/headline" | ||
def description = '''\\ | ||
Brief description of the plugin. | ||
''' | ||
|
||
// URL to the plugin's documentation | ||
def documentation = "http://grails.org/plugin/for-plugin-view-resolution" | ||
|
||
def doWithWebDescriptor = { xml -> | ||
// TODO Implement additions to web.xml (optional), this event occurs before | ||
} | ||
|
||
def doWithSpring = { | ||
// TODO Implement runtime spring config (optional) | ||
} | ||
|
||
def doWithDynamicMethods = { ctx -> | ||
// TODO Implement registering dynamic methods to classes (optional) | ||
} | ||
|
||
def doWithApplicationContext = { applicationContext -> | ||
// TODO Implement post initialization spring config (optional) | ||
} | ||
|
||
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'. | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#Grails Metadata file | ||
#Tue Jan 04 14:44:20 EST 2011 | ||
app.grails.version=1.3.5 | ||
app.name=for-plugin-view-resolution | ||
plugins.hibernate=1.3.5 | ||
plugins.tomcat=1.3.5 |
31 changes: 31 additions & 0 deletions
31
plugins/for-plugin-view-resolution/grails-app/conf/BuildConfig.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
grails.project.class.dir = "target/classes" | ||
grails.project.test.class.dir = "target/test-classes" | ||
grails.project.test.reports.dir = "target/test-reports" | ||
//grails.project.war.file = "target/${appName}-${appVersion}.war" | ||
grails.project.dependency.resolution = { | ||
// inherit Grails' default dependencies | ||
inherits("global") { | ||
// uncomment to disable ehcache | ||
// excludes 'ehcache' | ||
} | ||
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose' | ||
repositories { | ||
grailsPlugins() | ||
grailsHome() | ||
grailsCentral() | ||
|
||
// uncomment the below to enable remote dependency resolution | ||
// from public Maven repositories | ||
//mavenLocal() | ||
//mavenCentral() | ||
//mavenRepo "http://snapshots.repository.codehaus.org" | ||
//mavenRepo "http://repository.codehaus.org" | ||
//mavenRepo "http://download.java.net/maven/2/" | ||
//mavenRepo "http://repository.jboss.com/maven2/" | ||
} | ||
dependencies { | ||
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg. | ||
|
||
// runtime 'mysql:mysql-connector-java:5.1.5' | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
plugins/for-plugin-view-resolution/grails-app/conf/Config.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// configuration for plugin testing - will not be included in the plugin zip | ||
|
||
log4j = { | ||
// Example of changing the log pattern for the default console | ||
// appender: | ||
// | ||
//appenders { | ||
// console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n') | ||
//} | ||
|
||
error 'org.codehaus.groovy.grails.web.servlet', // controllers | ||
'org.codehaus.groovy.grails.web.pages', // GSP | ||
'org.codehaus.groovy.grails.web.sitemesh', // layouts | ||
'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping | ||
'org.codehaus.groovy.grails.web.mapping', // URL mapping | ||
'org.codehaus.groovy.grails.commons', // core / classloading | ||
'org.codehaus.groovy.grails.plugins', // plugins | ||
'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration | ||
'org.springframework', | ||
'org.hibernate', | ||
'net.sf.ehcache.hibernate' | ||
|
||
warn 'org.mortbay.log' | ||
} |
32 changes: 32 additions & 0 deletions
32
plugins/for-plugin-view-resolution/grails-app/conf/DataSource.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
dataSource { | ||
pooled = true | ||
driverClassName = "org.hsqldb.jdbcDriver" | ||
username = "sa" | ||
password = "" | ||
} | ||
hibernate { | ||
cache.use_second_level_cache = true | ||
cache.use_query_cache = true | ||
cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider' | ||
} | ||
// environment specific settings | ||
environments { | ||
development { | ||
dataSource { | ||
dbCreate = "create-drop" // one of 'create', 'create-drop','update' | ||
url = "jdbc:hsqldb:mem:devDB" | ||
} | ||
} | ||
test { | ||
dataSource { | ||
dbCreate = "update" | ||
url = "jdbc:hsqldb:mem:testDb" | ||
} | ||
} | ||
production { | ||
dataSource { | ||
dbCreate = "update" | ||
url = "jdbc:hsqldb:file:prodDb;shutdown=true" | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
plugins/for-plugin-view-resolution/grails-app/conf/UrlMappings.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class UrlMappings { | ||
|
||
static mappings = { | ||
"/$controller/$action?/$id?"{ | ||
constraints { | ||
// apply constraints here | ||
} | ||
} | ||
|
||
"/"(view:"/index") | ||
"500"(view:'/error') | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
plugins/for-plugin-view-resolution/grails-app/views/email/email.gsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is from a plugin!!! |
54 changes: 54 additions & 0 deletions
54
plugins/for-plugin-view-resolution/grails-app/views/error.gsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<html> | ||
<head> | ||
<title>Grails Runtime Exception</title> | ||
<style type="text/css"> | ||
.message { | ||
border: 1px solid black; | ||
padding: 5px; | ||
background-color:#E9E9E9; | ||
} | ||
.stack { | ||
border: 1px solid black; | ||
padding: 5px; | ||
overflow:auto; | ||
height: 300px; | ||
} | ||
.snippet { | ||
padding: 5px; | ||
background-color:white; | ||
border:1px solid black; | ||
margin:3px; | ||
font-family:courier; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<h1>Grails Runtime Exception</h1> | ||
<h2>Error Details</h2> | ||
|
||
<div class="message"> | ||
<strong>Error ${request.'javax.servlet.error.status_code'}:</strong> ${request.'javax.servlet.error.message'.encodeAsHTML()}<br/> | ||
<strong>Servlet:</strong> ${request.'javax.servlet.error.servlet_name'}<br/> | ||
<strong>URI:</strong> ${request.'javax.servlet.error.request_uri'}<br/> | ||
<g:if test="${exception}"> | ||
<strong>Exception Message:</strong> ${exception.message?.encodeAsHTML()} <br /> | ||
<strong>Caused by:</strong> ${exception.cause?.message?.encodeAsHTML()} <br /> | ||
<strong>Class:</strong> ${exception.className} <br /> | ||
<strong>At Line:</strong> [${exception.lineNumber}] <br /> | ||
<strong>Code Snippet:</strong><br /> | ||
<div class="snippet"> | ||
<g:each var="cs" in="${exception.codeSnippet}"> | ||
${cs?.encodeAsHTML()}<br /> | ||
</g:each> | ||
</div> | ||
</g:if> | ||
</div> | ||
<g:if test="${exception}"> | ||
<h2>Stack Trace</h2> | ||
<div class="stack"> | ||
<pre><g:each in="${exception.stackTraceLines}">${it.encodeAsHTML()}<br/></g:each></pre> | ||
</div> | ||
</g:if> | ||
</body> | ||
</html> |
10 changes: 10 additions & 0 deletions
10
plugins/for-plugin-view-resolution/scripts/_Install.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// | ||
// This script is executed by Grails after plugin was installed to project. | ||
// This script is a Gant script so you can use all special variables provided | ||
// by Gant (such as 'baseDir' which points on project base dir). You can | ||
// use 'ant' to access a global instance of AntBuilder | ||
// | ||
// For example you can create directory under project tree: | ||
// | ||
// ant.mkdir(dir:"${basedir}/grails-app/jobs") | ||
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// | ||
// This script is executed by Grails when the plugin is uninstalled from project. | ||
// Use this script if you intend to do any additional clean-up on uninstall, but | ||
// beware of messing up SVN directories! | ||
// |
10 changes: 10 additions & 0 deletions
10
plugins/for-plugin-view-resolution/scripts/_Upgrade.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// | ||
// This script is executed by Grails during application upgrade ('grails upgrade' | ||
// command). This script is a Gant script so you can use all special variables | ||
// provided by Gant (such as 'baseDir' which points on project base dir). You can | ||
// use 'ant' to access a global instance of AntBuilder | ||
// | ||
// For example you can create directory under project tree: | ||
// | ||
// ant.mkdir(dir:"${basedir}/grails-app/jobs") | ||
// |
42 changes: 42 additions & 0 deletions
42
plugins/for-plugin-view-resolution/web-app/WEB-INF/applicationContext.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
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-2.5.xsd"> | ||
|
||
<bean id="grailsApplication" class="org.codehaus.groovy.grails.commons.GrailsApplicationFactoryBean"> | ||
<description>Grails application factory bean</description> | ||
<property name="grailsDescriptor" value="/WEB-INF/grails.xml" /> | ||
<property name="grailsResourceLoader" ref="grailsResourceLoader" /> | ||
</bean> | ||
|
||
<bean id="pluginManager" class="org.codehaus.groovy.grails.plugins.GrailsPluginManagerFactoryBean"> | ||
<description>A bean that manages Grails plugins</description> | ||
<property name="grailsDescriptor" value="/WEB-INF/grails.xml" /> | ||
<property name="application" ref="grailsApplication" /> | ||
</bean> | ||
|
||
<bean id="grailsConfigurator" class="org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator"> | ||
<constructor-arg> | ||
<ref bean="grailsApplication" /> | ||
</constructor-arg> | ||
<property name="pluginManager" ref="pluginManager" /> | ||
</bean> | ||
|
||
<bean id="grailsResourceLoader" class="org.codehaus.groovy.grails.commons.GrailsResourceLoaderFactoryBean"> | ||
<property name="grailsResourceHolder" ref="grailsResourceHolder" /> | ||
</bean> | ||
|
||
<bean id="grailsResourceHolder" scope="prototype" class="org.codehaus.groovy.grails.commons.spring.GrailsResourceHolder"> | ||
<property name="resources"> | ||
<value>classpath*:**/grails-app/**/*.groovy</value> | ||
</property> | ||
</bean> | ||
|
||
<bean id="characterEncodingFilter" | ||
class="org.springframework.web.filter.CharacterEncodingFilter"> | ||
<property name="encoding"> | ||
<value>utf-8</value> | ||
</property> | ||
</bean> | ||
</beans> |
14 changes: 14 additions & 0 deletions
14
plugins/for-plugin-view-resolution/web-app/WEB-INF/sitemesh.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<sitemesh> | ||
<page-parsers> | ||
<parser content-type="text/html" | ||
class="org.codehaus.groovy.grails.web.sitemesh.GrailsHTMLPageParser" /> | ||
<parser content-type="text/html;charset=ISO-8859-1" | ||
class="org.codehaus.groovy.grails.web.sitemesh.GrailsHTMLPageParser" /> | ||
<parser content-type="text/html;charset=UTF-8" | ||
class="org.codehaus.groovy.grails.web.sitemesh.GrailsHTMLPageParser" /> | ||
</page-parsers> | ||
|
||
<decorator-mappers> | ||
<mapper class="org.codehaus.groovy.grails.web.sitemesh.GrailsLayoutDecoratorMapper" /> | ||
</decorator-mappers> | ||
</sitemesh> |
Oops, something went wrong.