Permalink
Browse files

Removed domain Object for demo page.

  • Loading branch information...
joergrech committed Nov 18, 2012
1 parent 9a200cf commit b4d063be325283c39df3f0d3cdcab343b837b857
@@ -1,6 +1,11 @@
+import org.codehaus.groovy.grails.commons.ApplicationHolder
+import org.codehaus.groovy.grails.plugins.GrailsPluginUtils
+import org.codehaus.groovy.grails.plugins.PluginManagerHolder
+import org.codehaus.groovy.grails.web.context.ServletContextHolder
+
class KickstartWithBootstrapGrailsPlugin {
// the plugin version
- def version = "0.8.7"
+ def version = "0.8.8"
// the version or versions of Grails the plugin is designed for
def grailsVersion = "2.0.0 > *"
// the other plugins this plugin depends on
@@ -45,18 +50,33 @@ class KickstartWithBootstrapGrailsPlugin {
// Collect all *.properties files in the I18N directory and build list of "available" locales
def locales = []
- new File("./grails-app/i18n").eachFileRecurse {
- if (it.file && it =~ /messages.*\.properties/) {
- // Extract locale from filename using RegEx
- def matcher = it.name =~ /messages(.*)\.properties/
- def result = matcher[0][1] // @see http://groovy.codehaus.org/Regular+Expressions
- if (result != null && result.size() == 3) {
- locales << result.substring(1, 3).toLowerCase() // should be empty ("") and starts with "_" (e.g., "_de")
- } else if (result != null && result.size() == 6) {
- locales << result.substring(4, 6).toLowerCase() // should be empty ("") and starts with country (e.g., "_en_US")
+
+ def i18nDir
+ if (ApplicationHolder.application.isWarDeployed()) {
+ def filePath = "grails-app/i18n"
+ i18nDir = ApplicationHolder.application.parentContext.getResource("${File.separator}WEB-INF${File.separator}${filePath}")?.getFile()
+ } else {
+ i18nDir = new File(System.properties['base.dir'] + "/grails-app/i18n")
+ }
+ if (i18nDir != null && i18nDir.exists()) {
+ i18nDir.eachFileRecurse {
+ if (it.file && it =~ /messages.*\.properties/) {
+ // Extract locale from filename using RegEx
+ def matcher = it.name =~ /messages(.*)\.properties/
+ def result = matcher[0][1] // @see http://groovy.codehaus.org/Regular+Expressions
+ if (result != null && result.size() == 3) {
+ locales << result.substring(1, 3).toLowerCase() // should be empty ("") and starts with "_" (e.g., "_de")
+ } else if (result != null && result.size() == 6) {
+ locales << result.substring(4, 6).toLowerCase() // should be empty ("") and starts with country (e.g., "_en_US")
+ }
}
}
+ } else {
+ // add a minimum of locales
+ locales << "en"
+ locales << "de"
}
+ println "> Kickstart found ${locales.size()} locales usable in the language selector."
System.setProperty('grails.i18n.locales', locales.toString())
// Note: The GrailsApplication instance is available in all of the lifecycle closures as the "application" variable.
application.config.grails.i18n.locales = locales
View
@@ -65,25 +65,25 @@ Affected files and directories (as of version 0.8.0; see script/Kickstart.groovy
** see http://joerg-rech.com and follow @JoergRech
== Changelog ==
-
-;0.8.7 Improved the date binding to use default.date.datepicker.format or default.date.format (removing non-Date items).
-;0.8.6 Changed solution for Less compilation problem (Switch is now in KickstartResources.groovy only). Fixed problem of SkinA alternative in responsive mode. In production mode only one skin is used.
-;0.8.5 Fixed a problem with CloudFoundry & Less: running in production will not compile less anymore but switch to files directly.
-;0.8.3 Introduced a demo page with all fields used by the scaffolding mechanism.
-;0.8.2 Corrected missing copy of resources.groovy.
-;0.8.1 Fixed error when copying UrlMappings.groovy, which was not packaged into the plugin.
-;0.8.0 Integrated less templates of two Bootstrap based designs. Corrected links in language selector and config menus.
-;0.7.2 Integrated a Bootstrap-based checkbox in the taglib and scaffolding templates.
-;0.7.1 Corrected datepicker problem with Java representation with month. Corrected missing ID in links to edit-actions.
-;0.7.0 Updated to Bootstrap 2.1.1 and Grails 2.1. Included FamFamFam icons for flags in language selector. Reorganized file structure for views.
-;0.6.1 Minor bug fix in _Events.gsp script.
-;0.6.0 Integration of Bootstrap DatePicker. Uses Grails 2.0 files as base for scaffolding, etc. Cleanup of code and scripts.
-;0.5.7 Added script to calculate or retrieve build numbers.
-;0.5.6 Empty commit to test Grails plugin publish mechanism
-;0.5.5 Minor bugfix (missing import) and correction of KickstartWithBootstrapGrailsPlugin.groovy
-;0.5.4 Added measurement of time to simple console logging in KickstartFilters
-;0.5.3 Improvement of error.gsp
-;0.5.2 Cleanup of code and scripts. Improvement of I18N
-;0.5.1 Minor bugfixes in Bootstrap and layout files
-;0.5.0 Initial shared version (February 11, 2012)
-;0.1.0 Initial version (September 21, 2011)
+'''0.8.8''' Fixed Bug with i18n directory when deploying. Removed domain Object for demo page.<br/>
+'''0.8.7''' Improved the date binding to use default.date.datepicker.format or default.date.format (removing non-Date items).<br/>
+'''0.8.6''' Changed solution for Less compilation problem (Switch is now in KickstartResources.groovy only). Fixed problem of SkinA alternative in responsive mode. In production mode only one skin is used.<br/>
+'''0.8.5''' Fixed a problem with CloudFoundry & Less: running in production will not compile less anymore but switch to files directly. <br/>
+'''0.8.3''' Introduced a demo page with all fields used by the scaffolding mechanism. <br/>
+'''0.8.2''' Corrected missing copy of resources.groovy. <br/>
+'''0.8.1''' Fixed error when copying UrlMappings.groovy, which was not packaged into the plugin. <br/>
+'''0.8.0''' Integrated less templates of two Bootstrap based designs. Corrected links in language selector and config menus. <br/>
+'''0.7.2''' Integrated a Bootstrap-based checkbox in the taglib and scaffolding templates. <br/>
+'''0.7.1''' Corrected datepicker problem with Java representation with month. Corrected missing ID in links to edit-actions. <br/>
+'''0.7.0''' Updated to Bootstrap 2.1.1 and Grails 2.1. Included FamFamFam icons for flags in language selector. Reorganized file structure for views. <br/>
+'''0.6.1''' Minor bug fix in _Events.gsp script. <br/>
+'''0.6.0''' Integration of Bootstrap DatePicker. Uses Grails 2.0 files as base for scaffolding, etc. Cleanup of code and scripts. <br/>
+'''0.5.7''' Added script to calculate or retrieve build numbers.<br/>
+'''0.5.6''' Empty commit to test Grails plugin publish mechanism<br/>
+'''0.5.5''' Minor bugfix (missing import) and correction of KickstartWithBootstrapGrailsPlugin.groovy<br/>
+'''0.5.4''' Added measurement of time to simple console logging in KickstartFilters<br/>
+'''0.5.3''' Improvement of error.gsp<br/>
+'''0.5.2''' Cleanup of code and scripts. Improvement of I18N <br/>
+'''0.5.1''' Minor bugfixes in Bootstrap and layout files <br/>
+'''0.5.0''' Initial shared version (February 11, 2012)<br/>
+'''0.1.0''' Initial version (September 21, 2011)<br/>
View
@@ -1,26 +1,26 @@
#Grails Metadata file
-#Fri Nov 09 18:19:11 CET 2012
+#Sun Nov 18 11:48:04 CET 2012
app.grails.version=2.1.1
app.name=kickstartWithBootstrapGrailsPlugin
app.stats.Controllers.files=2
app.stats.Controllers.loc=90
app.stats.Domain_Classes.files=1
-app.stats.Domain_Classes.loc=47
+app.stats.Domain_Classes.loc=49
app.stats.Groovy_Helpers.files=1
app.stats.Groovy_Helpers.loc=25
app.stats.Scripts.files=5
app.stats.Scripts.loc=134
app.stats.Tag_Libraries.files=1
-app.stats.Tag_Libraries.loc=295
-app.stats.Totals.files=12
-app.stats.Totals.loc=701
+app.stats.Tag_Libraries.loc=296
+app.stats.Totals.files=10
+app.stats.Totals.loc=594
app.stats.Unit_Tests.files=2
app.stats.Unit_Tests.loc=110
-app.version=0.8.7
-app.version.build=175
-app.version.build.date=Nov 09, 2012
+app.version=0.8.8
+app.version.build=186
+app.version.build.date=Nov 18, 2012
app.version.build.env=development
-app.version.revision=2657ced
+app.version.revision=9a200cf
plugins.hibernate=2.1.1
plugins.jquery=1.8.0
plugins.lesscss-resources=1.3.0.3
@@ -16,7 +16,7 @@ class _DemoPageController {
def list() {
params.max = Math.min(params.max ? params.int('max') : 10, 100)
- [_DemoPageInstanceList: _DemoPage.list(params), _DemoPageInstanceTotal: _DemoPage.count()]
+ [_DemoPageInstanceList: session.demopage ? [session.demopage] :[], _DemoPageInstanceTotal: session.demopage ? 1 : 0]
}
def create() {
@@ -25,39 +25,26 @@ class _DemoPageController {
def save() {
def _DemoPageInstance = new _DemoPage(params)
- if (!_DemoPageInstance.save(flush: true)) {
- render(view: "create", model: [_DemoPageInstance: _DemoPageInstance])
- return
- }
-
+ // store demopage in session (instead of in the database)
+ session.demopage = _DemoPageInstance
flash.message = message(code: 'default.created.message', args: [message(code: '_DemoPage.label', default: '_DemoPage'), _DemoPageInstance.id])
- redirect(action: "show", id: _DemoPageInstance.id)
+ redirect(action: "show", dp: _DemoPageInstance)
}
def show() {
- def _DemoPageInstance = _DemoPage.get(params.id)
- if (!_DemoPageInstance) {
- flash.message = message(code: 'default.not.found.message', args: [message(code: '_DemoPage.label', default: '_DemoPage'), params.id])
- redirect(action: "list")
- return
- }
-
+ def _DemoPageInstance = session.demopage
+
[_DemoPageInstance: _DemoPageInstance]
}
def edit() {
- def _DemoPageInstance = _DemoPage.get(params.id)
- if (!_DemoPageInstance) {
- flash.message = message(code: 'default.not.found.message', args: [message(code: '_DemoPage.label', default: '_DemoPage'), params.id])
- redirect(action: "list")
- return
- }
+ def _DemoPageInstance = session.demopage
[_DemoPageInstance: _DemoPageInstance]
}
def update() {
- def _DemoPageInstance = _DemoPage.get(params.id)
+ def _DemoPageInstance = session.demopage
if (!_DemoPageInstance) {
flash.message = message(code: 'default.not.found.message', args: [message(code: '_DemoPage.label', default: '_DemoPage'), params.id])
redirect(action: "list")
@@ -77,31 +64,15 @@ class _DemoPageController {
_DemoPageInstance.properties = params
- if (!_DemoPageInstance.save(flush: true)) {
- render(view: "edit", model: [_DemoPageInstance: _DemoPageInstance])
- return
- }
+ session.demopage = _DemoPageInstance
flash.message = message(code: 'default.updated.message', args: [message(code: '_DemoPage.label', default: '_DemoPage'), _DemoPageInstance.id])
redirect(action: "show", id: _DemoPageInstance.id)
}
def delete() {
- def _DemoPageInstance = _DemoPage.get(params.id)
- if (!_DemoPageInstance) {
- flash.message = message(code: 'default.not.found.message', args: [message(code: '_DemoPage.label', default: '_DemoPage'), params.id])
- redirect(action: "list")
- return
- }
-
- try {
- _DemoPageInstance.delete(flush: true)
- flash.message = message(code: 'default.deleted.message', args: [message(code: '_DemoPage.label', default: '_DemoPage'), params.id])
- redirect(action: "list")
- }
- catch (DataIntegrityViolationException e) {
- flash.message = message(code: 'default.not.deleted.message', args: [message(code: '_DemoPage.label', default: '_DemoPage'), params.id])
- redirect(action: "show", id: params.id)
- }
+ session.demopage = null
+ flash.message = message(code: 'default.deleted.message', args: [message(code: '_DemoPage.label', default: '_DemoPage'), params.id])
+ redirect(action: "list")
}
}
@@ -50,6 +50,8 @@ class _DemoPage {
static mapping = {
}
+ static mapWith = "none"
+
static constraints = {
// make all fields nullable to speed up demo usage (e.g., saves)
name nullable: true
@@ -82,4 +84,14 @@ class _DemoPage {
public String toString() {
return "${name}";
}
+
+ def list () {
+ return []
+ }
+ def count () {
+ return 0
+ }
+ def save () {
+ return true
+ }
}
@@ -8,7 +8,7 @@
<section id="overview" class="">
<div class="alert alert-error">
- ${request.'javax.servlet.error.message'.indexOf(':') == null ? request.'javax.servlet.error.message'.encodeAsHTML() : request.'javax.servlet.error.message'.substring(0, request.'javax.servlet.error.message'.indexOf(':')).encodeAsHTML()}
+ ${request.'javax.servlet.error.message'?.indexOf(':') == null ? request.'javax.servlet.error.message'?.encodeAsHTML() : request.'javax.servlet.error.message'?.substring(0, request.'javax.servlet.error.message'?.indexOf(':')).encodeAsHTML()}
<g:if test="${exception}">
${exception.className}
at line ${exception.lineNumber}
View
@@ -1,4 +1,4 @@
-<plugin name='kickstart-with-bootstrap' version='0.8.7' grailsVersion='2.0.0 &gt; *'>
+<plugin name='kickstart-with-bootstrap' version='0.8.7' grailsVersion='2.1.1 &gt; *'>
<author>Joerg Rech</author>
<authorEmail>joerg.rech@gmail.com</authorEmail>
<title>Kickstart with Bootstrap - Good looking websites!</title>
@@ -19,13 +19,23 @@
<repository name='http://repo.grails.org/grails/core' url='http://repo.grails.org/grails/core/' />
<repository name='mavenCentral' url='http://repo1.maven.org/maven2/' />
<repository name='http://grails.org/plugins' url='http://grails.org/plugins' />
+ <repository name='http://maven.springframework.org/milestone' url='http://maven.springframework.org/milestone/' />
</repositories>
<dependencies />
<plugins>
+ <compile>
+ <plugin group='org.grails.plugins' name='cache' version='1.0.0' />
+ </compile>
<runtime>
- <plugin group='org.grails.plugins' name='lesscss-resources' version='1.3.0.3' />
+ <plugin group='org.grails.plugins' name='database-migration' version='1.1' />
+ <plugin group='org.grails.plugins' name='hibernate' version='2.1.1' />
+ <plugin group='org.grails.plugins' name='cloud-foundry' version='1.2.3' />
+ <plugin group='org.grails.plugins' name='resources' version='1.1.6' />
<plugin group='org.grails.plugins' name='jquery' version='1.8.0' />
</runtime>
+ <build>
+ <plugin group='org.grails.plugins' name='tomcat' version='2.1.1' />
+ </build>
</plugins>
<runtimePluginRequirements />
<behavior />
Oops, something went wrong.

0 comments on commit b4d063b

Please sign in to comment.