Last active
October 23, 2015 04:09
-
-
Save yamkazu/08e5daed0092a24e205e to your computer and use it in GitHub Desktop.
jggug-grails-bootcampの資材
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
/* | |
*= require webjars/bootstrap/3.3.5/dist/css/bootstrap | |
*= require_self | |
*/ |
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
package sample | |
class Book { | |
String title | |
Integer price | |
static constraints = { | |
} | |
} |
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
import todo.Todo | |
class BootStrap { | |
def init = { servletContext -> | |
environments { | |
development { | |
new Todo(content: "山田さんに電話").save() | |
new Todo(content: "ゴミ袋を買う").save() | |
new Todo(content: "ネコに餌をやる").save() | |
} | |
} | |
} | |
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
buildscript { | |
ext { | |
grailsVersion = project.grailsVersion | |
} | |
repositories { | |
mavenLocal() | |
maven { url "https://repo.grails.org/grails/core" } | |
} | |
dependencies { | |
classpath "org.grails:grails-gradle-plugin:$grailsVersion" | |
classpath 'com.bertramlabs.plugins:asset-pipeline-gradle:2.5.0' | |
classpath "org.grails.plugins:hibernate:4.3.10.5" | |
} | |
} | |
plugins { | |
id "io.spring.dependency-management" version "0.5.2.RELEASE" | |
} | |
version "0.1" | |
group "todo" | |
apply plugin: "spring-boot" | |
apply plugin: "war" | |
apply plugin: "asset-pipeline" | |
apply plugin: 'eclipse' | |
apply plugin: 'idea' | |
apply plugin: "org.grails.grails-web" | |
apply plugin: "org.grails.grails-gsp" | |
ext { | |
grailsVersion = project.grailsVersion | |
gradleWrapperVersion = project.gradleWrapperVersion | |
} | |
assets { | |
minifyJs = true | |
minifyCss = true | |
} | |
repositories { | |
mavenLocal() | |
maven { url "https://repo.grails.org/grails/core" } | |
} | |
dependencyManagement { | |
imports { | |
mavenBom "org.grails:grails-bom:$grailsVersion" | |
} | |
applyMavenExclusions false | |
} | |
dependencies { | |
compile "org.springframework.boot:spring-boot-starter-logging" | |
compile "org.springframework.boot:spring-boot-starter-actuator" | |
compile "org.springframework.boot:spring-boot-autoconfigure" | |
compile "org.springframework.boot:spring-boot-starter-tomcat" | |
compile "org.grails:grails-dependencies" | |
compile "org.grails:grails-web-boot" | |
compile "org.grails.plugins:hibernate" | |
compile "org.grails.plugins:cache" | |
compile "org.hibernate:hibernate-ehcache" | |
compile "org.grails.plugins:scaffolding" | |
runtime "org.grails.plugins:asset-pipeline" | |
testCompile "org.grails:grails-plugin-testing" | |
testCompile "org.grails.plugins:geb" | |
// Note: It is recommended to update to a more robust driver (Chrome, Firefox etc.) | |
testRuntime 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.44.0' | |
console "org.grails:grails-console" | |
provided "org.webjars.bower:bootstrap:3.3.5" | |
} | |
task wrapper(type: Wrapper) { | |
gradleVersion = gradleWrapperVersion | |
} |
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
package sample | |
class HelloController { | |
def index() { | |
render 'Hello Grails!' | |
} | |
} |
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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>MYTODO</title> | |
</head> | |
<body> | |
<h2>TODOリスト</h2> | |
<ul> | |
<g:each in="${todos}" var="todo"> | |
<li>${todo.content}</li> | |
</g:each> | |
</ul> | |
</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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>MYTODO</title> | |
</head> | |
<body> | |
<g:form action="save"> | |
<g:textField name="content" /> | |
<g:submitButton name="create" value="追加" /> | |
</g:form> | |
<h2>TODOリスト</h2> | |
<ul> | |
<g:each in="${todos}" var="todo"> | |
<li> | |
${todo.content} | |
<g:form action="delete" id="${todo.id}"> | |
<g:submitButton name="delete" value="削除" /> | |
</g:form> | |
</li> | |
</g:each> | |
</ul> | |
</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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>MYTODO</title> | |
</head> | |
<body> | |
<g:hasErrors bean="${todo}"> | |
<g:renderErrors bean="${todo}" /> | |
</g:hasErrors> | |
<g:form action="save"> | |
<g:textField name="content" value="${task?.content}" /> | |
<g:submitButton name="create" value="追加" /> | |
</g:form> | |
<h2>TODOリスト</h2> | |
<ul> | |
<g:each in="${todos}" var="todo"> | |
<li> | |
${todo.content} | |
<g:form action="delete" id="${todo.id}"> | |
<g:submitButton name="delete" value="削除" /> | |
</g:form> | |
</li> | |
</g:each> | |
</ul> | |
</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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title><g:message code="app.name" /></title> | |
</head> | |
<body> | |
<g:hasErrors bean="${todo}"> | |
<g:renderErrors bean="${todo}" /> | |
</g:hasErrors> | |
<g:form action="save"> | |
<g:textField name="content" value="${task?.content}" /> | |
<g:submitButton name="create" value="${message(code: 'default.button.create.label')}" /> | |
</g:form> | |
<h2><g:message code="default.list.label" args="${[message(code: 'todo.label')]}"/></h2> | |
<ul> | |
<g:each in="${todos}" var="todo"> | |
<li> | |
${todo.content} | |
<g:form action="delete" id="${todo.id}"> | |
<g:submitButton name="delete" value="${message(code: 'default.button.delete.label')}" /> | |
</g:form> | |
</li> | |
</g:each> | |
</ul> | |
</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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title><g:message code="app.name" /></title> | |
</head> | |
<body> | |
<g:hasErrors bean="${todo}"> | |
<g:renderErrors bean="${todo}" /> | |
</g:hasErrors> | |
<g:form action="save"> | |
<g:textField name="content" value="${task?.content}" /> | |
<g:submitButton name="create" value="${message(code: 'default.button.create.label')}" /> | |
</g:form> | |
<h2><g:message code="default.list.label" args="${[message(code: 'todo.label')]}"/></h2> | |
<g:form action="index"> | |
<g:textField name="keyword" value="${params.keyword}"/> | |
<g:submitButton name="filter" value="絞り込み"/> | |
</g:form> | |
<ul> | |
<g:each in="${todos}" var="todo"> | |
<li> | |
${todo.content} | |
<g:form action="delete" id="${todo.id}"> | |
<g:submitButton name="delete" value="${message(code: 'default.button.delete.label')}" /> | |
</g:form> | |
</li> | |
</g:each> | |
</ul> | |
</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
<!doctype html> | |
<html> | |
<head> | |
<meta name="layout" content="main"/> | |
<title><g:message code="app.name" /></title> | |
</head> | |
<body> | |
<g:hasErrors bean="${todo}"> | |
<g:renderErrors bean="${todo}" /> | |
</g:hasErrors> | |
<g:form action="save"> | |
<g:textField name="content" value="${task?.content}" /> | |
<g:submitButton name="create" value="${message(code: 'default.button.create.label')}" /> | |
</g:form> | |
<h2><g:message code="default.list.label" args="${[message(code: 'todo.label')]}"/></h2> | |
<g:form action="index"> | |
<g:textField name="keyword" value="${params.keyword}"/> | |
<g:submitButton name="filter" value="絞り込み"/> | |
</g:form> | |
<ul> | |
<g:each in="${todos}" var="todo"> | |
<li> | |
${todo.content} | |
<g:form action="delete" id="${todo.id}"> | |
<g:submitButton name="delete" value="${message(code: 'default.button.delete.label')}" /> | |
</g:form> | |
</li> | |
</g:each> | |
</ul> | |
</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
<!doctype html> | |
<html> | |
<head> | |
<meta name="layout" content="main"/> | |
<title><g:message code="app.name" /></title> | |
</head> | |
<body> | |
<g:hasErrors bean="${todo}"> | |
<div class="alert alert-danger" role="alert"> | |
<g:renderErrors bean="${todo}" /> | |
</div> | |
</g:hasErrors> | |
<g:form action="save"> | |
<div class="input-group"> | |
<g:textField name="content" value="${task?.content}" class="form-control" placeholder="なにするの?" /> | |
<span class="input-group-btn"> | |
<g:submitButton name="create" value="${message(code: 'default.button.create.label')}" class="btn btn-success"/> | |
</span> | |
</div> | |
</g:form> | |
<h2><g:message code="default.list.label" args="${[message(code: 'todo.label')]}"/></h2> | |
<div class="well"> | |
<g:form action="index"> | |
<div class="input-group"> | |
<g:textField name="keyword" value="${params.keyword}" class="form-control"/> | |
<span class="input-group-btn"> | |
<g:submitButton name="search" value="絞り込み" class="btn btn-default"/> | |
</span> | |
</div> | |
</g:form> | |
</div> | |
<ul class="list-group"> | |
<g:each in="${todos}" var="todo"> | |
<li class="list-group-item"> | |
${todo.content} | |
<g:form action="delete" id="${todo.id}" class="pull-right"> | |
<g:submitButton name="delete" value="${message(code: 'default.button.delete.label')}" class="btn btn-danger btn-xs" /> | |
</g:form> | |
</li> | |
</g:each> | |
</ul> | |
</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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<title><g:layoutTitle default="${message(code: 'app.name')}" /></title> | |
<g:layoutHead/> | |
</head> | |
<body> | |
<h1><g:message code="app.name" /></h1> | |
<g:layoutBody/> | |
</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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<title><g:layoutTitle default="${message(code: 'app.name')}" /></title> | |
<asset:stylesheet src="application.css"/> | |
<asset:javascript src="application.js"/> | |
<g:layoutHead/> | |
</head> | |
<body> | |
<h1><g:message code="app.name" /></h1> | |
<g:layoutBody/> | |
</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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<title><g:layoutTitle default="${message(code: 'app.name')}" /></title> | |
<asset:stylesheet src="application.css"/> | |
<asset:javascript src="application.js"/> | |
<g:layoutHead/> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="page-header"> | |
<h1><g:message code="app.name" /></h1> | |
</div> | |
<g:layoutBody/> | |
</div> | |
</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
default.invalid.max.size.message={1}の{0}は{3}文字以内で入力してください。 | |
default.null.message={1}の{0}が入力されていません。 | |
todo.label=TODO | |
todo.content.label=内容 |
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
app.name=MYTODO |
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
package todo | |
class Todo { | |
String content | |
static constraints = { | |
content blank: false, maxSize: 20 | |
} | |
} |
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
package todo | |
class TodoController { | |
def index() { | |
[todos: Todo.list()] | |
} | |
} |
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
package todo | |
class TodoController { | |
def index() { | |
[todos: Todo.list()] | |
} | |
def save(Todo todo) { | |
todo.save(flush: true) | |
redirect action: 'index' | |
} | |
def delete(Todo todo) { | |
todo.delete(flush: true) | |
redirect action: 'index' | |
} | |
} |
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
package todo | |
class TodoController { | |
def index() { | |
[todos: Todo.list()] | |
} | |
def save(Todo todo) { | |
if (todo.hasErrors()) { | |
render view: 'index', model: [todo: todo, todos: Todo.list()] | |
return | |
} | |
todo.save(flush: true) | |
redirect action: 'index' | |
} | |
def delete(Todo todo) { | |
todo.delete(flush: true) | |
redirect action: 'index' | |
} | |
} |
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
package todo | |
class TodoController { | |
def index(String keyword) { | |
if (keyword) { | |
return [todos: Todo.where { content ==~ /%$keyword%/ }.list()] | |
} | |
[todos: Todo.list()] | |
} | |
def save(Todo todo) { | |
if (todo.hasErrors()) { | |
render view: 'index', model: [todo: todo, todos: Todo.list()] | |
return | |
} | |
todo.save(flush: true) | |
redirect action: 'index' | |
} | |
def delete(Todo todo) { | |
todo.delete(flush: true) | |
redirect action: 'index' | |
} | |
} |
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
class UrlMappings { | |
static mappings = { | |
"/$controller/$action?/$id?(.$format)?"{ | |
constraints { | |
// apply constraints here | |
} | |
} | |
"/"(controller: 'todo') | |
"500"(view:'/error') | |
"404"(view:'/notFound') | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment