Permalink
Browse files

adding a few more technology stacks

  • Loading branch information...
1 parent 848bfda commit ad400399bfbd0023c95b37121467041be39dcdc3 @addyosmani committed Apr 29, 2012
Showing with 5,444 additions and 1 deletion.
  1. +23 −1 README.md
  2. +1 −0 option4_grails_mongo/README
  3. +7 −0 option4_grails_mongo/application.properties
  4. +5 −0 option4_grails_mongo/grails-app/conf/ApplicationResources.groovy
  5. +7 −0 option4_grails_mongo/grails-app/conf/BootStrap.groovy
  6. +46 −0 option4_grails_mongo/grails-app/conf/BuildConfig.groovy
  7. +94 −0 option4_grails_mongo/grails-app/conf/Config.groovy
  8. +14 −0 option4_grails_mongo/grails-app/conf/TodoResources.groovy
  9. +17 −0 option4_grails_mongo/grails-app/conf/UrlMappings.groovy
  10. +3 −0 option4_grails_mongo/grails-app/conf/spring/resources.groovy
  11. +27 −0 option4_grails_mongo/grails-app/controllers/todo/TodosController.groovy
  12. +12 −0 option4_grails_mongo/grails-app/domain/todo/Todo.groovy
  13. +11 −0 option4_grails_mongo/grails-app/views/error.gsp
  14. +82 −0 option4_grails_mongo/grails-app/views/index.gsp
  15. +12 −0 option4_grails_mongo/grails-app/views/layouts/main.gsp
  16. +1,231 −0 option4_grails_mongo/web-app/backbone.js
  17. BIN option4_grails_mongo/web-app/destroy.png
  18. +311 −0 option4_grails_mongo/web-app/todos.css
  19. +237 −0 option4_grails_mongo/web-app/todos.js
  20. +999 −0 option4_grails_mongo/web-app/underscore.js
  21. +10 −0 option5_php_slim/.htaccess
  22. +2 −0 option5_php_slim/README.md
  23. BIN option5_php_slim/destroy.png
  24. +77 −0 option5_php_slim/index.html
  25. +44 −0 option5_php_slim/index.php
  26. +530 −0 option5_php_slim/todos.css
  27. +253 −0 option5_php_slim/todos.js
  28. +6 −0 option5_php_slim/todos.sql
  29. +15 −0 option6_rails_coffeescript/Gemfile
  30. +119 −0 option6_rails_coffeescript/Gemfile.lock
  31. +27 −0 option6_rails_coffeescript/README.md
  32. +7 −0 option6_rails_coffeescript/Rakefile
  33. BIN option6_rails_coffeescript/app/assets/images/destroy.png
  34. +108 −0 option6_rails_coffeescript/app/assets/javascripts/application.js.coffee
  35. +18 −0 option6_rails_coffeescript/app/assets/javascripts/collections/todos.js.coffee
  36. +18 −0 option6_rails_coffeescript/app/assets/javascripts/models/todo.js.coffee
  37. +10 −0 option6_rails_coffeescript/app/assets/javascripts/templates/todos/item.jst.ejs
  38. +14 −0 option6_rails_coffeescript/app/assets/javascripts/templates/todos/stats.jst.ejs
  39. +51 −0 option6_rails_coffeescript/app/assets/javascripts/views/todos/todo.js.coffee
  40. +4 −0 option6_rails_coffeescript/app/assets/stylesheets/application.css
  41. +530 −0 option6_rails_coffeescript/app/assets/stylesheets/todos.css
  42. +3 −0 option6_rails_coffeescript/app/controllers/application_controller.rb
  43. +3 −0 option6_rails_coffeescript/app/controllers/todos_controller.rb
  44. +3 −0 option6_rails_coffeescript/app/models/todo.rb
  45. +14 −0 option6_rails_coffeescript/app/views/layouts/application.html.erb
  46. +31 −0 option6_rails_coffeescript/app/views/todos/index.html.erb
  47. +4 −0 option6_rails_coffeescript/config.ru
  48. +65 −0 option6_rails_coffeescript/config/application.rb
  49. +6 −0 option6_rails_coffeescript/config/boot.rb
  50. +3 −0 option6_rails_coffeescript/config/database.yml
  51. +5 −0 option6_rails_coffeescript/config/environment.rb
  52. +37 −0 option6_rails_coffeescript/config/environments/development.rb
  53. +67 −0 option6_rails_coffeescript/config/environments/production.rb
  54. +37 −0 option6_rails_coffeescript/config/environments/test.rb
  55. +7 −0 option6_rails_coffeescript/config/initializers/backtrace_silencers.rb
  56. +15 −0 option6_rails_coffeescript/config/initializers/inflections.rb
  57. +5 −0 option6_rails_coffeescript/config/initializers/mime_types.rb
  58. +7 −0 option6_rails_coffeescript/config/initializers/secret_token.rb
  59. +8 −0 option6_rails_coffeescript/config/initializers/session_store.rb
  60. +14 −0 option6_rails_coffeescript/config/initializers/wrap_parameters.rb
  61. +5 −0 option6_rails_coffeescript/config/locales/en.yml
  62. +4 −0 option6_rails_coffeescript/config/routes.rb
  63. +9 −0 option6_rails_coffeescript/db/migrate/20120414043745_create_todos.rb
  64. +22 −0 option6_rails_coffeescript/db/schema.rb
  65. +26 −0 option6_rails_coffeescript/public/404.html
  66. +26 −0 option6_rails_coffeescript/public/422.html
  67. +25 −0 option6_rails_coffeescript/public/500.html
  68. 0 option6_rails_coffeescript/public/favicon.ico
  69. +5 −0 option6_rails_coffeescript/public/robots.txt
  70. +6 −0 option6_rails_coffeescript/script/rails
View
@@ -1,6 +1,6 @@
#Backbone Boilerplates
-Developers have been reqesting examples of how to integrate Backbone.js with a number of different technology stacks. Two common requests have included Node.js and Sinatra/Ruby but there have been a number of others too. To help with this, you can find three of these integration examples below. There are more to come soon.
+Developers have been reqesting examples of how to integrate Backbone.js with a number of different backend technology stacks. To help with this, you can find six of these integration examples in this repository, with their stacks listed below. There are more to come soon and I'm always happy to consider other stacks not already covered.
Option 1
=========
@@ -24,6 +24,28 @@ Option 3
* Sinatra
* MongoDB
+Option 4
+==========
+* Grails
+* MongoDB
+
+(thanks to [Lauri Piispanen](https://github.com/lauripiispanen))
+
+Option 5
+==========
+* PHP
+* Slim PHP RESTful framework
+* mySQL
+
+(thanks to [Joshua Stauter](https://github.com/dthtvwls))
+
+Option 6
+==========
+* Rails / Rails Asset Pipeline
+* CoffeeScript
+* Rails JSON API
+
+(also thanks to [Joshua Stauter](https://github.com/dthtvwls))
##Instructions
@@ -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/
@@ -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
@@ -0,0 +1,5 @@
+modules = {
+ application {
+ resource url:'js/application.js'
+ }
+}
@@ -0,0 +1,7 @@
+class BootStrap {
+
+ def init = { servletContext ->
+ }
+ def destroy = {
+ }
+}
@@ -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"
+ }
+}
@@ -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'
+}
@@ -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'
+ }
+}
@@ -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')
+ }
+}
@@ -0,0 +1,3 @@
+// Place your Spring DSL code here
+beans = {
+}
@@ -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 )
+ }
+}
@@ -0,0 +1,12 @@
+package todo
+
+class Todo {
+
+ boolean done
+ int order
+ String text
+
+ static constraints = {
+ text(nullable: false, empty: false)
+ }
+}
@@ -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>
@@ -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&eacute;r&ocirc;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>
@@ -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.

0 comments on commit ad40039

Please sign in to comment.