uehaj's blog

Grな日々 - GroovyとかGrailsとかElmとかRustとかHaskellとかReactとかFregeとかJavaとか -

Kickstart with Bootstrapプラグインがかっこいいぞ

GrailsにはKickstart with Bootstrapプラグインというのがあって、サイトの雛形として使える便利ものですが、実にかっちょ良い。

  • f:id:uehaj:20121102191042p:plain
  • f:id:uehaj:20121102191719p:plain
  • f:id:uehaj:20121102191723p:plain
  • f:id:uehaj:20121102192331p:plain

スキャッフォルドも手が加わっていて、Twitter Bootstrap対応になっています。

  • f:id:uehaj:20121102191030p:plain
  • f:id:uehaj:20121102191039p:plain

こういうテンプレートがいっぱいあると良いなあ。
使うのは簡単で、最初の手間としては以下だけです。

grails install-plugin KickstartWithBootstrap
grails kickstart

create-domain-classで生成される雛形のドメインクラス定義も、コメントが豊富についていて、

package kick

/**
 * Book
 * A domain class describes the data object and it's mapping to the database
 */
class Book {

	/* Default (injected) attributes of GORM */
//	Long	id
//	Long	version
	
	/* Automatic timestamping of GORM */
//	Date	dateCreated
//	Date	lastUpdated
	
//	static belongsTo	= []	// tells GORM to cascade commands: e.g., delete this object if the "parent" is deleted.
//	static hasOne		= []	// tells GORM to associate another domain object as an owner in a 1-1 mapping
//	static hasMany		= []	// tells GORM to associate other domain objects for a 1-n or n-m mapping
//	static mappedBy		= []	// specifies which property should be used in a mapping 
	
    static mapping = {
    }
    
	static constraints = {
    }
	
	/*
	 * Methods of the Domain Class
	 */
//	@Override	// Override toString for a nicer / more descriptive UI 
//	public String toString() {
//		return "${name}";
//	}
}

ほーいいじゃないか こういうのでいいんだよこういうので。(孤独のグルメ風に)

まあ、中身を作るのは依然としてたいへんなわけですが、ガワをゼロから作らなくて良いのはまったく良いことです。