Exemplo n.º 1
0
func revel_init(project string, template_dir string, force bool) error {
	root_dir, err := gopath_src_dir()
	if err != nil {
		return err
	}
	project_dir := path.Join(root_dir, project)

	data := map[string]interface{}{
		"project": project,
	}

	if err := symbol.CopyDir(path.Join(template_dir, "revel", "public"),
		path.Join(project_dir, "public")); err != nil {
		return err
	}
	log.Println("copy directory =>", path.Join(project_dir, "public"))

	if err := symbol.RenderTemplate(path.Join(template_dir, "revel", "models", "model.go.t"),
		path.Join(project_dir, "app", "models", "model.go"), data, force); err != nil {
		return err
	}

	if err := symbol.RenderTemplate(path.Join(template_dir, "revel", "models", "model.validator.go.t"),
		path.Join(project_dir, "app", "models", "model.validator.go"), data, force); err != nil {
		return err
	}

	if err := symbol.RenderTemplate(path.Join(template_dir, "revel", "controllers", "controller.widget.go.t"),
		path.Join(project_dir, "app", "controllers", "controller.widget.go"), data, force); err != nil {
		return err
	}

	if err := symbol.RenderTemplate(path.Join(template_dir, "revel", "controllers", "controller.db.go.t"),
		path.Join(project_dir, "app", "controllers", "controller.db.go"), data, force); err != nil {
		return err
	}

	if err := symbol.RenderTemplate(path.Join(template_dir, "revel", "controllers", "controller.fns.go.t"),
		path.Join(project_dir, "app", "controllers", "controller.fns.go"), data, force); err != nil {
		return err
	}

	return nil
}
Exemplo n.º 2
0
func revel_init(project string, template_dir string, force bool) error {
	root_dir, err := gopath_src_dir()
	if err != nil {
		return err
	}
	project_dir := path.Join(root_dir, project)
	revel.ConfPaths = append(revel.ConfPaths, path.Join(project_dir, "conf"))

	db, err := revel_db(project_dir)
	if err != nil {
		return err
	}
	defer db.Close()

	options, err := revel_options(db)
	if err != nil {
		return err
	}

	data := map[string]interface{}{
		"project": project,
		"options": options,
	}

	if err := symbol.CopyDir(path.Join(template_dir, "revel", "public"),
		path.Join(project_dir, "public")); err != nil {
		return err
	}

	if err := symbol.RenderTemplate(path.Join(template_dir, "revel", "models", "model.go.t"),
		path.Join(project_dir, "app", "models", "model.go"), data, force); err != nil {
		return err
	}

	if err := symbol.RenderTemplate(path.Join(template_dir, "revel", "models", "model.const.go.t"),
		path.Join(project_dir, "app", "models", "model.const.go"), data, force); err != nil {
		return err
	}

	if err := symbol.RenderTemplate(path.Join(template_dir, "revel", "models", "model.validator.go.t"),
		path.Join(project_dir, "app", "models", "model.validator.go"), data, force); err != nil {
		return err
	}

	if err := symbol.RenderTemplate(path.Join(template_dir, "revel", "controllers", "controller.widget.go.t"),
		path.Join(project_dir, "app", "controllers", "controller.widget.go"), data, force); err != nil {
		return err
	}

	if err := symbol.RenderTemplate(path.Join(template_dir, "revel", "controllers", "controller.db.go.t"),
		path.Join(project_dir, "app", "controllers", "controller.db.go"), data, force); err != nil {
		return err
	}

	if err := symbol.RenderTemplate(path.Join(template_dir, "revel", "controllers", "controller.fns.go.t"),
		path.Join(project_dir, "app", "controllers", "controller.fns.go"), data, force); err != nil {
		return err
	}

	return nil
}