Skip to content

Commit

Permalink
Compatible with Grails 2.4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
goeh committed Feb 28, 2015
1 parent e6e384d commit 66372c0
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 32 deletions.
12 changes: 2 additions & 10 deletions ContentBufferGrailsPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,14 @@
* limitations under the License.
*/
class ContentBufferGrailsPlugin {
// the plugin version
def version = "1.0.1"
def version = "1.0.2"
def license = "APACHE"
// the version or versions of Grails the plugin is designed for
def grailsVersion = "1.2.0 > *"
// the other plugins this plugin depends on
def grailsVersion = "2.0.0 > *"
def dependsOn = [:]
// resources that are excluded from plugin packaging
def pluginExcludes = [
"grails-app/controllers/**/*",
"grails-app/views/**/*"
]

def author = "Goran Ehrsson"
def authorEmail = "goran@technipelago.se"
def title = "GSP Content Buffer"
Expand All @@ -36,10 +31,7 @@ It is used to insert page fragments anywhere in a GSP before it is rendered.
The standard sitemesh content tag does not support appending content, this plugin does.
Templates included with the render tag can also append content to sections in the layout.
'''

// URL to the plugin's documentation
def documentation = "http://grails.org/plugin/content-buffer"

def organization = [name: "Technipelago AB", url: "http://www.technipelago.se/"]
def issueManagement = [system: "github", url: "https://github.com/goeh/grails-content-buffer/issues"]
def scm = [url: "https://github.com/goeh/grails-content-buffer"]
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Content Buffer Plugin

This plugin provide a taglib method called 'content'. It is used to insert page fragments anywhere in a GSP before it is rendered.
This Grails plugin provide a taglib method called 'content'. It is used to insert page fragments anywhere in a GSP before it is rendered.
The standard sitemesh content tag does not support appending content, this plugin does.
Templates included with the render tag can also append content to sections in the layout.

Expand Down Expand Up @@ -51,3 +51,11 @@ The content-buffer plugin makes it possible to append as much content as you lik
Then you let the layout render it to the final page.

---------------------------------------

## Version history

*1.0.2* Compatible with Grails 2.4.4

*1.0.1* Compatible with Grails 2.2.4

*1.0.0* Initial revision
4 changes: 1 addition & 3 deletions application.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#Grails Metadata file
#Wed Jan 25 19:50:07 CET 2012
app.grails.version=2.0.4
app.grails.version=2.4.4
app.name=content-buffer
plugins.rest-client-builder=1.0.2
plugins.svn=1.0.2
6 changes: 6 additions & 0 deletions grails-app/conf/BootStrap.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class BootStrap {
def init = { servletContext ->
}
def destroy() {
}
}
22 changes: 16 additions & 6 deletions grails-app/conf/BuildConfig.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,32 @@ grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.target.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"

grails.project.fork = [
// compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256]
]

grails.project.dependency.resolver = "maven"
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
}
inherits "global"
log "warn"
repositories {
grailsCentral()
mavenLocal()
mavenCentral()
}
dependencies {
}

plugins {
build(":tomcat:$grailsVersion",
":release:2.0.4") {
build(":release:3.0.1",
":rest-client-builder:1.0.3") {
export = false
}
//build(":tomcat:7.0.55")
}
}
2 changes: 2 additions & 0 deletions grails-app/conf/Config.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ log4j = {

warn 'org.mortbay.log'
}

grails.views.gsp.sitemesh.preprocess = true
8 changes: 6 additions & 2 deletions grails-app/conf/DataSource.groovy
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
dataSource {
pooled = true
jmxExport = true
driverClassName = "org.h2.Driver"
username = "sa"
password = ""
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
cache.use_query_cache = false
// cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
singleSession = true // configure OSIV singleSession mode
flush.mode = 'manual' // OSIV session flush mode outside of transactional context
}
// environment specific settings
environments {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@
*/
package grails.plugins.contentbuffer

import com.opensymphony.module.sitemesh.RequestConstants
import groovy.transform.CompileStatic
import org.codehaus.groovy.grails.web.pages.FastStringWriter
import org.codehaus.groovy.grails.web.sitemesh.GSPSitemeshPage
import org.codehaus.groovy.grails.web.util.GrailsPrintWriter
import org.codehaus.groovy.grails.web.util.StreamCharBuffer

class ContentBufferTagLib {
class ContentBufferTagLib implements RequestConstants {

static final String GSP_SITEMESH_PAGE = 'org.codehaus.groovy.grails.web.sitemesh.GrailsLayoutView.GSP_SITEMESH_PAGE'

def content = {attrs, body->
if(! attrs.tag) {
Expand Down Expand Up @@ -51,20 +55,22 @@ class ContentBufferTagLib {
return null
}

protected getPage() {
return request[org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.GSP_SITEMESH_PAGE]
@CompileStatic
protected Object getPage() {
request.getAttribute(GSP_SITEMESH_PAGE)
}

protected wrapContentInBuffer(content) {
@CompileStatic
protected StreamCharBuffer wrapContentInBuffer(content) {
if(content instanceof Closure) {
content = content()
}
if(!(content instanceof StreamCharBuffer)) {
// the body closure might be a string constant, so wrap it in a StreamCharBuffer in that case
def newbuffer = new FastStringWriter()
newbuffer.print(content)
content = newbuffer.buffer
if(content instanceof StreamCharBuffer) {
return (StreamCharBuffer)content
}
return content
// the body closure might be a string constant, so wrap it in a StreamCharBuffer in that case
final FastStringWriter newbuffer = new FastStringWriter()
newbuffer.print(content)
return newbuffer.buffer
}
}

0 comments on commit 66372c0

Please sign in to comment.