Skip to content

Commit

Permalink
Fixed install-skin for newer grails versions
Browse files Browse the repository at this point in the history
  • Loading branch information
blanke committed Sep 11, 2013
1 parent afb8b4a commit 7b5acdd
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 34 deletions.
7 changes: 6 additions & 1 deletion scaffoldtags/CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
VERSION: 0.7.3
VERSION: 0.7.4

Changes since 0.7.3:
- Fixed the install-skin to be compatible with higer grails versions script.
- load scaffold files not only for the war compiled environment.
- fix template CRUD files to support domain classes in packages.

Changes since 0.7.2:
- Fixed the install-skin script. Thanks to J. Barmash for notifying me.
Expand Down
2 changes: 1 addition & 1 deletion scaffoldtags/ScaffoldTagsGrailsPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @since March 25, 2007
*/
class ScaffoldTagsGrailsPlugin {
def version = "0.7.3"
def version = "0.7.4"
def dependsOn = [:]
def author="Daiji Takamori"
def authorEmail="[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion scaffoldtags/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<os family="windows"/>
</condition>
<property name="grails" value="grails" />
<property name="plugin.version" value="0.7.3" />
<property name="plugin.version" value="0.7.4" />
<property name="plugin.zip" value="grails-scaffold-tags-${plugin.version}.zip" />
<property name="install.dir" value="" />

Expand Down
2 changes: 1 addition & 1 deletion scaffoldtags/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h1><img alt="[grails plugin]" src="images/grails-plugin.png"/> Grails ScaffoldT
<a href="http://grails.org">Grails</a>. Please let me know what you think of it. Thanks!
&nbsp;&nbsp;&nbsp;&mdash; Daiji</p>
<p>
Current Version: 0.7.3
Current Version: 0.7.4
</p>
<h3>Links</h3>
<ul>
Expand Down
45 changes: 31 additions & 14 deletions scaffoldtags/grails-app/taglib/ScaffoldTagLib.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ import org.codehaus.groovy.grails.commons.GrailsClass
* @since 08-Mar-2007
*/
class ScaffoldTagLib {
private static final VERSION = "0.7.3"
private static final Log LOG = LogFactory.getLog(ScaffoldTagLib.class)
private static final String PATH_TO_VIEWS = "/WEB-INF/grails-app/views";
private static final String PLUGIN_PATH_TO_VIEWS = "/WEB-INF/plugins/scaffold-tags-${VERSION}/grails-app/views";

private static final VERSION = "0.7.4"
private static final Log LOG = LogFactory.getLog(ScaffoldTagLib.class)
private static String PATH_TO_VIEWS = "/WEB-INF/grails-app/views";
private static String PLUGIN_PATH_TO_VIEWS = "/WEB-INF/plugins/scaffold-tags-${VERSION}/grails-app/views";
private static boolean initPaths = false

/** Primitive class translation map */
private static final classTranslations = [(Boolean.TYPE): Boolean.class,
(Character.TYPE): Character.class,
Expand Down Expand Up @@ -711,15 +712,31 @@ class ScaffoldTagLib {
* /scaffolding/{view}
* {pluginPath}/scaffolding/{view}
*/
private findView(view) {
// There needs to be a better way to do the path lookup
String controllerUri = grailsAttributes.getControllerUri(request)
def viewpaths = ["${PATH_TO_VIEWS}${controllerUri}",
"${PATH_TO_VIEWS}/scaffolding",
"${PLUGIN_PATH_TO_VIEWS}/scaffolding"]
// println "searching for ${view} in ${viewpaths}"
def ctx = grailsAttributes.applicationContext
def resourceLoader = ctx.containsBean('groovyPageResourceLoader') ? ctx.groovyPageResourceLoader : ctx
private findView(view) {
// There needs to be a better way to do the path lookup
String controllerUri = grailsAttributes.getControllerUri(request)

def ctx = grailsAttributes.applicationContext
def resourceLoader = ctx.containsBean('groovyPageResourceLoader') ? ctx.groovyPageResourceLoader : ctx

if (!initPaths) {
if (!resourceLoader.getResource("${PATH_TO_VIEWS}/error.gsp").exists())
{
PATH_TO_VIEWS = PATH_TO_VIEWS.substring(
PATH_TO_VIEWS.indexOf('/', 1) + 1)
PLUGIN_PATH_TO_VIEWS = PLUGIN_PATH_TO_VIEWS.substring(
PLUGIN_PATH_TO_VIEWS.indexOf('/', 1) + 1)
if (!resourceLoader.getResource("${PLUGIN_PATH_TO_VIEWS}/scaffolding/editor/domain.gsp").exists()) {
PLUGIN_PATH_TO_VIEWS = org.codehaus.groovy.grails.plugins.GrailsPluginUtils.pluginInfos.find { it.name == "scaffold-tags" }?.pluginDir.toString() + "/grails-app/views"
PLUGIN_PATH_TO_VIEWS = "file:" + PLUGIN_PATH_TO_VIEWS.replace("/./", "/")
}
}
initPaths = true
}
def viewpaths = ["${PATH_TO_VIEWS}${controllerUri}",
"${PATH_TO_VIEWS}/scaffolding",
"${PLUGIN_PATH_TO_VIEWS}/scaffolding"]

for (p in viewpaths) {
if (view instanceof String || view instanceof GString) {
def uri = "${p}/${view}"
Expand Down
2 changes: 1 addition & 1 deletion scaffoldtags/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<plugin name='scaffold-tags' version='0.7.3' grailsVersion='1.1.1 &gt; *'>
<plugin name='scaffold-tags' version='0.7.4' grailsVersion='1.1.1 &gt; *'>
<author>Daiji Takamori</author>
<authorEmail>[email protected]</authorEmail>
<title>Adds tags to support fully-customizable &amp; dynamic scaffolding</title>
Expand Down
30 changes: 15 additions & 15 deletions scaffoldtags/scripts/InstallSkin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
*/

grailsHome = Ant.antProject.properties."environment.GRAILS_HOME"
includeTargets << new File ( "${grailsHome}/scripts/Init.groovy" )
includeTargets << grailsScript("_GrailsInit")

target ('default': "Installs a ScaffoldTags skin") {
version = "0.7.3"
pluginHome = "${pluginsHome}/scaffold-tags-${version}"
pluginSkins = "${pluginHome}/src/skins"
appSkins = "${basedir}/src/skins"
target ('default': "Installs a ScaffoldTags skin") {
depends(checkVersion, parseArguments)
pluginSkins = "${scaffoldTagsPluginDir}/src/skins"
appSkins = "${basedir}/src/skins"

// Obtain the skin name; make sure it exists
skin = args
skin = argsMap.params[0]
first = true
while (first || !skin) {
first = false
Expand Down Expand Up @@ -64,7 +64,7 @@ target ('default': "Installs a ScaffoldTags skin") {
layouts: "${skinDir}/layouts",
groovycode: "${skinDir}/src/groovy",
css: "${skinDir}/css" ]
targets = [ scaffolding: "${pluginHome}/grails-app/views/scaffolding",
myTargets = [ scaffolding: "${scaffoldTagsPluginDir}/grails-app/views/scaffolding",
templates: "${basedir}/src/templates/scaffolding",
layouts: "${basedir}/grails-app/views/layouts",
groovycode: "${basedir}/src/groovy",
Expand All @@ -78,7 +78,7 @@ target ('default': "Installs a ScaffoldTags skin") {
sources.each { sourceType, sourcePath ->
sourceDir = new File(sourcePath)
if (sourceDir.exists()) {
targetPath = targets[sourceType]
targetPath = myTargets[sourceType]
targetDir = new File(targetPath)

if (clearTargets.contains(sourceType)) {
Expand All @@ -92,8 +92,8 @@ target ('default': "Installs a ScaffoldTags skin") {
} else if (targetDir.exists()) {
// Prompt the user if an overwrite will occur
def sources = sourceDir.list().toList()
def targets = targetDir.list().toList()
def overlap = sources?.intersect(targets)
def myTargets = targetDir.list().toList()
def overlap = sources?.intersect(myTargets)
if (!overlap?.empty) {
println "Warning: Pre-existing files found in ${targetDir}"
def hasNewer = false
Expand Down Expand Up @@ -170,16 +170,16 @@ target ('default': "Installs a ScaffoldTags skin") {
sourceDir = new File(sourcePath)
if (sourceDir.exists() &&
(Ant.antProject.properties."skin.dir.${sourceType}.copy" != "n")) {
targetPath = targets[sourceType]
targetPath = myTargets[sourceType]
if (Ant.antProject.properties."skin.dir.${sourceType}.delete" == "y") {
println "Removing existing ${sourceType}..."
Ant.delete(dir: targetPath)
}
def overwrite = (Ant.antProject.properties."skin.dir.${sourceType}.overwrite" != "n")
if (overwrite) {
println "Installing skin '${skin}' ${sourceType}..."
println "Installing skin '${skin}' ${sourceType} into ${targetPath}..."
} else {
println "Installing only newer files in skin '${skin}' ${sourceType}..."
println "Installing only newer files in skin '${skin}' ${sourceType}into ${targetPath}..."
}

// Create any directories that don't exist
Expand Down
1 change: 1 addition & 0 deletions scaffoldtags/src/skins/dojo/templates/create.gsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%=packageName%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
Expand Down
1 change: 1 addition & 0 deletions scaffoldtags/src/skins/dojo/templates/edit.gsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%=packageName%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
Expand Down
1 change: 1 addition & 0 deletions scaffoldtags/src/skins/dojo/templates/list.gsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%=packageName%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
Expand Down
1 change: 1 addition & 0 deletions scaffoldtags/src/skins/dojo/templates/show.gsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%=packageName%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
Expand Down
1 change: 1 addition & 0 deletions scaffoldtags/src/skins/no-img-skin/templates/create.gsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%=packageName%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
Expand Down
1 change: 1 addition & 0 deletions scaffoldtags/src/skins/no-img-skin/templates/edit.gsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%=packageName%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
Expand Down
1 change: 1 addition & 0 deletions scaffoldtags/src/skins/no-img-skin/templates/list.gsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%=packageName%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
Expand Down
1 change: 1 addition & 0 deletions scaffoldtags/src/skins/no-img-skin/templates/show.gsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%=packageName%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
Expand Down

0 comments on commit 7b5acdd

Please sign in to comment.