Skip to content

Instantly share code, notes, and snippets.

View marcpalmer's full-sized avatar
💭
Busy working on Concepts app, and Captionista

Marc Palmer marcpalmer

💭
Busy working on Concepts app, and Captionista
View GitHub Profile
@marcpalmer
marcpalmer / gist:1871003
Created February 20, 2012 19:50
Functional Test Plugin Example
import com.grailsrocks.functionaltest.*
class GrailsSiteTests extends BrowserTestCase {
void testSearch() {
get('http://grails.org')
assertStatus 200
assertContentContains "download"
}
}
@marcpalmer
marcpalmer / gist:1871026
Created February 20, 2012 19:56
Invitation Only Plugin Example
class MyController {
def doSignup = {
// Don't allow signup/use of service unless their invite
// has been approved
if (!invitationService.isUserApproved(params.email, '1.0-beta')) {
redirect( action: 'sorryBetaUsersOnly' )
}
}
@marcpalmer
marcpalmer / gist:1871038
Created February 20, 2012 19:58
Navigation Plugin Example
class DashboardController {
static navigation = [
group:'tabs',
order:10,
title:'Your Inbox',
action:'inbox'
]
def index = { }
@marcpalmer
marcpalmer / gist:1871056
Created February 20, 2012 20:02
One Time Data Plugin Example
class BookController {
def updateBook = {
// set up the one time data for a future request, using a manual "conversation" key
def otID = book.isbn
oneTimeData(otID) {
customerName = customer.name
statusMessage = "Update to book saved!"
}
@marcpalmer
marcpalmer / gist:1871079
Created February 20, 2012 20:06
Resources Plugin Example
<html>
<head>
<meta name="layout" content="main"/>
<r:require modules="jquery-ui, blueprint"/>
<r:script>
$(function() {
$('#form').dialog('open');
});
</r:script>
</head>
@marcpalmer
marcpalmer / gist:1871100
Created February 20, 2012 20:08
Taxonomy Plugin Example
def book1 = Book.get(1)
def book2 = Book.get(2)
book1.addToTaxonomy(['Non-fiction', 'Autobiography'])
book1.addToTaxonomy(['Discounted', '10%'], 'pricing') // Pricing taxonomy, separate tree
book2.addToTaxonomy(['Non-fiction', 'Popular science'])
book2.addToTaxonomy(['Discounted', '20%'], 'pricing') // Pricing taxonomy, separate tree
// Find all books under Non-fiction
def nonFictionBooks = Book.findAllByTaxonomyFamily('Non-fiction')
@marcpalmer
marcpalmer / gist:2225545
Created March 28, 2012 11:32
Hooking up Platform Core Security API to your Security Provider
package com.mycompany.security
import org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils
import org.grails.plugin.platform.security.SecurityBridge
import org.apache.commons.logging.LogFactory
class MySecurityProvider implements SecurityBridge {
def log = LogFactory.getLog(MySecurityProvider)
def springSecurityService
@marcpalmer
marcpalmer / gist:2225569
Created March 28, 2012 11:43
SecurityBridge declaration example
grailsSecurityBridge(com.mycompany.security.MySecurityProvider) {
springSecurityService = ref('springSecurityService')
grailsApplication = ref('grailsApplication')
}
@marcpalmer
marcpalmer / gist:2225631
Created March 28, 2012 11:56
Example of Config API to declare config options
def doWithConfigOptions = {
'guest.roles'(defaultValue:['ROLE_GUEST'], validator: { v ->
(v == null || !(v instanceof List)) ? 'A role list is required' : null
})
'signup.allowed'(defaultValue:true)
'post.login.url'(defaultValue:[uri:'/'])
}
<img src="clear-placeholder.png" width="100" height="50" data-2x-src="[email protected]"/>