Permalink
Browse files

cleanup

  • Loading branch information...
1 parent 9a1e492 commit 8be0f6966fb16e61d48c5fb9fd101c45917adc44 burtbeckwith committed Sep 14, 2010
@@ -14,41 +14,12 @@ class JqueryUiGrailsPlugin {
"grails-app/views/error.gsp"
]
- // TODO Fill in these fields
def author = "Marc Palmer"
def authorEmail = "marc@grailsrocks.com"
def title = "jQuery UI resources"
def description = '''\\
Simply supplies jQuery UI resources, depends on jQuery plugin. Use this plugin to avoid resource duplication and conflicts.
'''
- // URL to the plugin's documentation
def documentation = "http://grails.org/plugin/jquery-ui"
-
- 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'.
- }
}
@@ -1,33 +1,20 @@
-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.class.dir = 'target/classes'
+grails.project.test.class.dir = 'target/test-classes'
+grails.project.test.reports.dir = 'target/test-reports'
+
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()
+ inherits 'global'
+
+ log 'warn'
+
+ repositories {
+ grailsPlugins()
+ grailsHome()
+ }
- // 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.
+ dependencies {}
- // runtime 'mysql:mysql-connector-java:5.1.5'
- }
- plugins {
+ plugins {
runtime ':jquery:1.4.2.4'
- }
+ }
}
@@ -1,15 +1,16 @@
package com.grailsrocks.jqueryui
class JqueryUiTagLib {
+
static namespace = "jqui"
static writeAttrs( attrs, output) {
// Output any remaining user-specified attributes
attrs.each { k, v ->
- output << k
- output << '="'
- output << v.encodeAsHTML()
- output << '" '
+ output << k
+ output << '="'
+ output << v.encodeAsHTML()
+ output << '" '
}
}
@@ -23,9 +24,9 @@ class JqueryUiTagLib {
writeAttrs(attrs, o)
o << '></script>'
- return o
+ return o
},
-
+
link: { url, constants, attrs ->
def o = new StringBuilder()
o << "<link href=\"${url.encodeAsHTML()}\" "
@@ -38,25 +39,25 @@ class JqueryUiTagLib {
return o
}
]
-
+
static RESOURCE_MAPPINGS = [
css:[type:"text/css", rel:'stylesheet'],
- rss:[type:'application/rss+xml', rel:'alternate'],
- atom:[type:'application/atom+xml', rel:'alternate'],
+ rss:[type:'application/rss+xml', rel:'alternate'],
+ atom:[type:'application/atom+xml', rel:'alternate'],
favicon:[type:'image/x-icon', rel:'shortcut icon'],
appleicon:[type:'image/x-icon', rel:'apple-touch-icon'],
js:[writer:'js', type:'text/javascript']
]
- static CDN_URLS = [
- googlecode: [
- css:{jqver, theme, min -> "http://ajax.googleapis.com/ajax/libs/jqueryui/$jqver/themes/$theme/jquery-ui.css"},
- js:{jqver, theme, min -> "http://ajax.googleapis.com/ajax/libs/jqueryui/$jqver/jquery-ui.${min ? 'min.js' : 'js'}"}
- ]
- ]
+ static CDN_URLS = [
+ googlecode: [
+ css:{jqver, theme, min -> "http://ajax.googleapis.com/ajax/libs/jqueryui/$jqver/themes/$theme/jquery-ui.css"},
+ js:{jqver, theme, min -> "http://ajax.googleapis.com/ajax/libs/jqueryui/$jqver/jquery-ui.${min ? 'min.js' : 'js'}"}
+ ]
+ ]
def pluginManager
-
+
def resources = { attrs ->
def theme = attrs.theme ?: 'ui-lightness'
def plugin = pluginManager.getGrailsPlugin('jquery-ui')
@@ -66,56 +67,63 @@ class JqueryUiTagLib {
def plug = attrs.plugin ? attrs.plugin : 'jqueryUi'
def themedir = attrs.themeDir ? attrs.themeDir + '/' + theme : 'jquery-ui/themes/'+theme
- // if nothing is in config, serve it minified to stay compatible with older plugin versions
- def min = grailsApplication.config.jqueryUi.get('minified', true);
- // must point to a key in CDN_URLS (currently 'googlecode' is the only key there)
- def cdn = grailsApplication.config.jqueryUi.cdn
- if (cdn && !CDN_URLS[cdn])
- throwTagError "Unknown CDN name: ${cdn}"
-
- // use the theme css from cdn only if it's not provided by the app or a plugin.
- if (cdn && !attrs.plugin && !attrs.themeDir)
- out << cdnLink (cdn:cdn, type:'css', jqver:jqver, theme:theme, minified:min, id:'jquery-ui-theme')
- else
- out << resourceLink(plugin: plug, type:'css', dir: themedir,
- file:'jquery-ui-'+jqver+'.custom.css', media:'screen, projection', id:'jquery-ui-theme')
-
- // use the .js always from cdn if requested
- if (cdn)
- out << cdnLink (cdn:cdn, type:'js', jqver:jqver, theme:theme, minified:min)
- else
- out << resourceLink(plugin: 'jqueryUi', type:'js', dir:'jquery-ui/js',
- file:"jquery-ui-${jqver}.custom.${min ? 'min.js' : 'js'}")
- }
+ // if nothing is in config, serve it minified to stay compatible with older plugin versions
+ def min = grailsApplication.config.jqueryUi.get('minified', true);
+ // must point to a key in CDN_URLS (currently 'googlecode' is the only key there)
+ def cdn = grailsApplication.config.jqueryUi.cdn
+ if (cdn && !CDN_URLS[cdn]) {
+ throwTagError "Unknown CDN name: ${cdn}"
+ }
+
+ // use the theme css from cdn only if it's not provided by the app or a plugin.
+ if (cdn && !attrs.plugin && !attrs.themeDir) {
+ out << cdnLink (cdn:cdn, type:'css', jqver:jqver, theme:theme, minified:min, id:'jquery-ui-theme')
+ }
+ else {
+ out << resourceLink(plugin: plug, type:'css', dir: themedir,
+ file:'jquery-ui-'+jqver+'.custom.css', media:'screen, projection',
+ id:'jquery-ui-theme')
+ }
+ // use the .js always from cdn if requested
+ if (cdn) {
+ out << cdnLink (cdn:cdn, type:'js', jqver:jqver, theme:theme, minified:min)
+ }
+ else {
+ out << resourceLink(plugin: 'jqueryUi', type:'js', dir:'jquery-ui/js',
+ file:"jquery-ui-${jqver}.custom.${min ? 'min.js' : 'js'}")
+ }
+ }
def resourceLink = { attrs ->
def t = attrs.remove('type')
def typeInfo = [:] + RESOURCE_MAPPINGS[t]
if (!typeInfo) {
throwTagError "Unknown resourceLink type: ${t}"
}
- def url = attrs.remove('url')
- if (!url)
- url = g.resource(plugin:attrs.remove('plugin'), dir:attrs.remove('dir'), file:attrs.remove('file'))
-
+ def url = attrs.remove('url')
+ if (!url) {
+ url = g.resource(plugin:attrs.remove('plugin'), dir:attrs.remove('dir'), file:attrs.remove('file'))
+ }
+
def writerName = typeInfo.remove('writer')
def writer = LINK_WRITERS[writerName ?: 'link']
out << writer(url, typeInfo, attrs)
}
- def cdnLink = { attrs ->
- def t = attrs.type
- def cdnName = attrs.remove('cdn')
- def jqver = attrs.remove('jqver')
- def theme = attrs.remove('theme')
- def min = attrs.remove('minified')
+ def cdnLink = { attrs ->
+ def t = attrs.type
+ def cdnName = attrs.remove('cdn')
+ def jqver = attrs.remove('jqver')
+ def theme = attrs.remove('theme')
+ def min = attrs.remove('minified')
- def cdnUrlHandler = CDN_URLS[cdnName]
- if (!cdnUrlHandler)
- throwTagError "Unknown CDN name: ${cdnName}"
+ def cdnUrlHandler = CDN_URLS[cdnName]
+ if (!cdnUrlHandler) {
+ throwTagError "Unknown CDN name: ${cdnName}"
+ }
- def url = cdnUrlHandler."$t"(jqver, theme, min)
- out << resourceLink (attrs + [url:url])
- }
+ def url = cdnUrlHandler."$t"(jqver, theme, min)
+ out << resourceLink (attrs + [url:url])
+ }
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
Binary file not shown.
View
@@ -1,10 +0,0 @@
-//
-// 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")
-//
@@ -1,5 +0,0 @@
-//
-// 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!
-//
View
@@ -1,10 +0,0 @@
-//
-// 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")
-//
@@ -1,17 +0,0 @@
-package com.grailsrocks.jqueryui
-
-import grails.test.*
-
-class JQueryUITagLibTests extends TagLibUnitTestCase {
- protected void setUp() {
- super.setUp()
- }
-
- protected void tearDown() {
- super.tearDown()
- }
-
- void testSomething() {
-
- }
-}

0 comments on commit 8be0f69

Please sign in to comment.