Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
848bfda
commit ad40039
Showing
70 changed files
with
5,444 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Example to accompany blog post: http://lauripiispanen.github.com/blog/2012/01/31/building-a-backend-for-backbone-dot-js-todos-example-with-grails-and-mongodb/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#Grails Metadata file | ||
#Wed Jan 25 16:27:14 EET 2012 | ||
app.grails.version=2.0.0 | ||
app.name=todo | ||
app.servlet.version=2.5 | ||
app.version=0.1 | ||
plugins.mongodb=1.0.0.RC3 |
5 changes: 5 additions & 0 deletions
5
option4_grails_mongo/grails-app/conf/ApplicationResources.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
modules = { | ||
application { | ||
resource url:'js/application.js' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class BootStrap { | ||
|
||
def init = { servletContext -> | ||
} | ||
def destroy = { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
grails.servlet.version = "2.5" // Change depending on target container compliance (2.5 or 3.0) | ||
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.source.level = 1.6 | ||
//grails.project.war.file = "target/${appName}-${appVersion}.war" | ||
|
||
grails.project.dependency.resolution = { | ||
// inherit Grails' default dependencies | ||
inherits("global") { | ||
// uncomment to disable ehcache | ||
// excludes 'ehcache' | ||
} | ||
log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose' | ||
checksums true // Whether to verify checksums on resolve | ||
|
||
repositories { | ||
inherits true // Whether to inherit repository definitions from plugins | ||
grailsPlugins() | ||
grailsHome() | ||
grailsCentral() | ||
mavenCentral() | ||
|
||
// uncomment these to enable remote dependency resolution from public Maven repositories | ||
//mavenCentral() | ||
//mavenLocal() | ||
//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. | ||
|
||
// runtime 'mysql:mysql-connector-java:5.1.16' | ||
} | ||
|
||
plugins { | ||
runtime ":mongodb:latest.integration" | ||
runtime ":jquery:1.7.1" | ||
runtime ":resources:1.1.5" | ||
|
||
build ":tomcat:$grailsVersion" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// locations to search for config files that get merged into the main config | ||
// config files can either be Java properties files or ConfigSlurper scripts | ||
|
||
// grails.config.locations = [ "classpath:${appName}-config.properties", | ||
// "classpath:${appName}-config.groovy", | ||
// "file:${userHome}/.grails/${appName}-config.properties", | ||
// "file:${userHome}/.grails/${appName}-config.groovy"] | ||
|
||
// if (System.properties["${appName}.config.location"]) { | ||
// grails.config.locations << "file:" + System.properties["${appName}.config.location"] | ||
// } | ||
|
||
|
||
grails.project.groupId = appName // change this to alter the default package name and Maven publishing destination | ||
grails.mime.file.extensions = true // enables the parsing of file extensions from URLs into the request format | ||
grails.mime.use.accept.header = false | ||
grails.mime.types = [ html: ['text/html','application/xhtml+xml'], | ||
xml: ['text/xml', 'application/xml'], | ||
text: 'text/plain', | ||
js: 'text/javascript', | ||
rss: 'application/rss+xml', | ||
atom: 'application/atom+xml', | ||
css: 'text/css', | ||
csv: 'text/csv', | ||
all: '*/*', | ||
json: ['application/json','text/json'], | ||
form: 'application/x-www-form-urlencoded', | ||
multipartForm: 'multipart/form-data' | ||
] | ||
|
||
// URL Mapping Cache Max Size, defaults to 5000 | ||
//grails.urlmapping.cache.maxsize = 1000 | ||
|
||
// What URL patterns should be processed by the resources plugin | ||
grails.resources.adhoc.patterns = ['/images/*', '/css/*', '/js/*', '/plugins/*'] | ||
|
||
grails.app.context="/" | ||
|
||
// The default codec used to encode data with ${} | ||
grails.views.default.codec = "none" // none, html, base64 | ||
grails.views.gsp.encoding = "UTF-8" | ||
grails.converters.encoding = "UTF-8" | ||
// enable Sitemesh preprocessing of GSP pages | ||
grails.views.gsp.sitemesh.preprocess = true | ||
// scaffolding templates configuration | ||
grails.scaffolding.templates.domainSuffix = 'Instance' | ||
|
||
// Set to false to use the new Grails 1.2 JSONBuilder in the render method | ||
grails.json.legacy.builder = false | ||
// enabled native2ascii conversion of i18n properties files | ||
grails.enable.native2ascii = true | ||
// packages to include in Spring bean scanning | ||
grails.spring.bean.packages = [] | ||
// whether to disable processing of multi part requests | ||
grails.web.disable.multipart=false | ||
|
||
// request parameters to mask when logging exceptions | ||
grails.exceptionresolver.params.exclude = ['password'] | ||
|
||
// enable query caching by default | ||
grails.hibernate.cache.queries = true | ||
|
||
// set per-environment serverURL stem for creating absolute links | ||
environments { | ||
development { | ||
grails.logging.jul.usebridge = true | ||
} | ||
production { | ||
grails.logging.jul.usebridge = false | ||
// TODO: grails.serverURL = "http://www.changeme.com" | ||
} | ||
} | ||
|
||
// log4j configuration | ||
log4j = { | ||
// Example of changing the log pattern for the default console | ||
// appender: | ||
// | ||
//appenders { | ||
// console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n') | ||
//} | ||
|
||
error 'org.codehaus.groovy.grails.web.servlet', // controllers | ||
'org.codehaus.groovy.grails.web.pages', // GSP | ||
'org.codehaus.groovy.grails.web.sitemesh', // layouts | ||
'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping | ||
'org.codehaus.groovy.grails.web.mapping', // URL mapping | ||
'org.codehaus.groovy.grails.commons', // core / classloading | ||
'org.codehaus.groovy.grails.plugins', // plugins | ||
'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration | ||
'org.springframework', | ||
'org.hibernate', | ||
'net.sf.ehcache.hibernate' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
modules = { | ||
todo { | ||
dependsOn 'jquery, underscore, backbone' | ||
|
||
resource url: '/todos.css' | ||
resource url: '/todos.js' | ||
} | ||
backbone { | ||
resource url: '/backbone.js' | ||
} | ||
underscore { | ||
resource url: '/underscore.js' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class UrlMappings { | ||
|
||
static mappings = { | ||
"/$controller/$action?/$id?"{ | ||
constraints { | ||
// apply constraints here | ||
} | ||
} | ||
|
||
"/todos/$id?"(controller: "todos") { | ||
action = [GET:"list", POST: "save", DELETE: "delete", PUT: "edit"] | ||
} | ||
|
||
"/"(view:"/index") | ||
"500"(view:'/error') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place your Spring DSL code here | ||
beans = { | ||
} |
27 changes: 27 additions & 0 deletions
27
option4_grails_mongo/grails-app/controllers/todo/TodosController.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package todo | ||
|
||
import grails.converters.JSON | ||
|
||
class TodosController { | ||
|
||
def index() { | ||
render( Todo.findAll() as JSON ) | ||
} | ||
|
||
def save() { | ||
def todo = new Todo(request.JSON); | ||
render( todo.save() as JSON ) | ||
} | ||
|
||
def delete() { | ||
def todo = Todo.findById(params.id) | ||
todo?.delete() | ||
render(todo as JSON ); | ||
} | ||
|
||
def edit() { | ||
def todo = Todo.findById(params.id) | ||
bindData(todo, request.JSON) | ||
render(todo.save() as JSON ) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package todo | ||
|
||
class Todo { | ||
|
||
boolean done | ||
int order | ||
String text | ||
|
||
static constraints = { | ||
text(nullable: false, empty: false) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Grails Runtime Exception</title> | ||
<meta name="layout" content="main"> | ||
<link rel="stylesheet" href="${resource(dir: 'css', file: 'errors.css')}" type="text/css"> | ||
</head> | ||
<body> | ||
<g:renderException exception="${exception}" /> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<title>Backbone Demo: Todos</title> | ||
<r:require module="todo" /> | ||
<meta name="layout" content="main"> | ||
</head> | ||
|
||
<body> | ||
|
||
<!-- Todo App Interface --> | ||
|
||
<div id="todoapp"> | ||
|
||
<div class="title"> | ||
<h1>Todos</h1> | ||
</div> | ||
|
||
<div class="content"> | ||
|
||
<div id="create-todo"> | ||
<input id="new-todo" placeholder="What needs to be done?" type="text" /> | ||
<span class="ui-tooltip-top" style="display:none;">Press Enter to save this task</span> | ||
</div> | ||
|
||
<div id="todos"> | ||
<ul id="todo-list"></ul> | ||
</div> | ||
|
||
<div id="todo-stats"></div> | ||
|
||
</div> | ||
|
||
</div> | ||
|
||
<ul id="instructions"> | ||
<li>Double-click to edit a todo.</li> | ||
<li><a href="../../docs/todos.html">View the annotated source.</a></li> | ||
</ul> | ||
|
||
<div id="credits"> | ||
Created by | ||
<br /> | ||
<a href="http://jgn.me/">Jérôme Gravel-Niquet</a> | ||
</div> | ||
|
||
<!-- Templates --> | ||
|
||
<script type="text/template" id="item-template"> | ||
<div class="todo {{ done ? 'done' : '' }}"> | ||
<div class="display"> | ||
<input class="check" type="checkbox" {{ done ? 'checked="checked"' : '' }} /> | ||
<div class="todo-text"></div> | ||
<span class="todo-destroy"></span> | ||
</div> | ||
<div class="edit"> | ||
<input class="todo-input" type="text" value="" /> | ||
</div> | ||
</div> | ||
</script> | ||
|
||
<script type="text/template" id="stats-template"> | ||
{! if (total) { !} | ||
<span class="todo-count"> | ||
<span class="number">{{ remaining }}</span> | ||
<span class="word">{{ remaining == 1 ? 'item' : 'items' }}</span> left. | ||
</span> | ||
{! } !} | ||
{! if (done) { !} | ||
<span class="todo-clear"> | ||
<a href="#"> | ||
Clear <span class="number-done">{{ done }}</span> | ||
completed <span class="word-done">{{ done == 1 ? 'item' : 'items' }}</span> | ||
</a> | ||
</span> | ||
{! } !} | ||
</script> | ||
|
||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title><g:layoutTitle default="Grails"/></title> | ||
<g:layoutHead/> | ||
<r:layoutResources /> | ||
</head> | ||
<body> | ||
<g:layoutBody/> | ||
<r:layoutResources /> | ||
</body> | ||
</html> |
Oops, something went wrong.