예제 #1
0
파일: index.go 프로젝트: fanliao/gorazor
func Index(users []*models.User, total int, limit int, offset int) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n\n<h2 class=\"sub-header\">用户总数:")
	_buffer.WriteString(gorazor.HTMLEscape(gorazor.Itoa(total)))
	_buffer.WriteString("</h2>\n<div class=\"table-responsive\">\n	<table class=\"table table-striped\">\n		<thead>\n			<tr>\n				<th>名字</th>\n				<th>电邮</th>\n				<th>编辑</th>\n			</tr>\n		</thead>\n		<tbody>\n			")
	for _, u := range users {

		_buffer.WriteString("<tr>\n				<td>")
		_buffer.WriteString(gorazor.HTMLEscape(u.Name))
		_buffer.WriteString("</td>\n				<td>")
		_buffer.WriteString(gorazor.HTMLEscape(u.Email))
		_buffer.WriteString("</td>\n				<td><a href=\"/admin/user/edit?id=")
		_buffer.WriteString(gorazor.HTMLEscape(u.ID.Hex()))
		_buffer.WriteString("\">编辑</a></td>\n			</tr>")

	}
	_buffer.WriteString("\n		</tbody>\n	</table>\n</div>")

	js := func() string {
		var _buffer bytes.Buffer
		return _buffer.String()
	}

	title := func() string {
		var _buffer bytes.Buffer

		_buffer.WriteString("用户管理")

		return _buffer.String()
	}

	return layout.Base(_buffer.String(), title(), js())
}
예제 #2
0
파일: Init.go 프로젝트: sunfmin/hyperboot
func Init(data ConfigData) string {
	var _buffer bytes.Buffer

	var upcaseModule = strings.ToUpper(data.Module)

	_buffer.WriteString("\npackage config\n\nimport (\n\t\"log\"\n\t\"os\"\n\t\"strings\"\n)\n\n// this is configured from env variables\nvar (\n\tEnv                 string\n\tWebDir              string\n\t")
	if data.Database == "mysql" {

		_buffer.WriteString((MysqlVars()))

	}
	_buffer.WriteString("\n)\n\nfunc init() {\n\tEnv = envOrPanic(\"")
	_buffer.WriteString(gorazor.HTMLEscape((upcaseModule)))
	_buffer.WriteString("_ENV\", false)\n\tWebDir = envOrPanic(\"")
	_buffer.WriteString(gorazor.HTMLEscape((upcaseModule)))
	_buffer.WriteString("_WEBDIR\", false)\n\t")
	if data.Database == "mysql" {

		_buffer.WriteString((MysqlAssigns(upcaseModule)))

	}
	_buffer.WriteString("\n}\n\nfunc envOrPanic(key string, allowEmpty bool) (r string) {\n\tr = os.Getenv(key)\n\tif r == \"\" && !allowEmpty {\n\t\tpanic(\"env \" + key + \" is not set\")\n\t}\n\tlogValue := r\n\tif strings.Contains(logValue, \"PASSWORD\") || strings.Contains(logValue, \"SECRET\") {\n\t\tlogValue = \"<HIDDEN>\"\n\t}\n\tlog.Printf(\"Configure: %s = %s\\n\", key, logValue)\n\treturn\n}")

	return _buffer.String()
}
예제 #3
0
파일: add.go 프로젝트: fanliao/gorazor
func Add(content string, err string) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n\n<link rel=\"stylesheet\" href=\"/css/bootstrap-datetimepicker.css\">\n\n<style>\n.row {\n	margin-top: 10px;\n}\n</style>\n\n<h2>日程登记</h2>\n\n<div class=\"container-fluid\">\n	<form method=\"POST\" action=\"\">\n	<div class=\"row\" >\n		<p class=\"bg-danger\">")
	_buffer.WriteString(gorazor.HTMLEscape(err))
	_buffer.WriteString("</p>\n	</div>\n\n	<div class=\"row\">\n	内容:\n	<input type='text' class=\"form-control\" name=\"content\" value=\"")
	_buffer.WriteString(gorazor.HTMLEscape(content))
	_buffer.WriteString("\"/>\n	</div>\n	\n	<div class=\"row\">\n	开始时间:\n	<input type='text' class=\"datetimepicker form-control\" name=\"startTime\"/>\n	</div>\n	\n	<div class=\"row\">\n	结束时间:\n	<input type='text' class=\"datetimepicker form-control\" name=\"endTime\"/>\n	</div>\n\n	<div class=\"row\">\n	日程指派:\n	<select name=\"appoint\">\n		<option>cheney</option>\n		<option>wuvist</option>\n	</select>\n	</div>\n	\n	<div class=\"row\">\n	<input style=\"float:right\" type=\"submit\" value=\"保存\" class=\"btn btn-primary\"/>\n	</div>\n	</form>\n</div>")

	title := func() string {
		var _buffer bytes.Buffer

		_buffer.WriteString("管理后台 - 添加日程")

		return _buffer.String()
	}

	js := func() string {
		var _buffer bytes.Buffer

		_buffer.WriteString("<script src=\"/js/moment.js\"></script>")

		_buffer.WriteString("<script src=\"/js/bootstrap-datetimepicker.js\"></script>")

		_buffer.WriteString("<script type=\"text/javascript\">\n	$(function () {\n		$(\".datetimepicker\").datetimepicker({\n			format: \"YYYY-MM-DD HH:mm\",\n			defaultDate: \"2014-05-01 00:00\",\n		})\n	});\n</script>")

		return _buffer.String()
	}

	return layout.Base(_buffer.String(), title(), js())
}
예제 #4
0
파일: tplImage.go 프로젝트: keysonZZZ/kmg
func tplImage(conf Image) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n<img src=\"")
	_buffer.WriteString(gorazor.HTMLEscape(conf.Src))
	_buffer.WriteString("\" style=\"")
	_buffer.WriteString(gorazor.HTMLEscape(conf.getStyle()))
	_buffer.WriteString("\"/>")

	return _buffer.String()
}
예제 #5
0
func PackageJson(data ReactData) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n{\n  \"name\": \"")
	_buffer.WriteString(gorazor.HTMLEscape((data.Module)))
	_buffer.WriteString("\",\n  \"version\": \"0.0.1\",\n  \"description\": \"")
	_buffer.WriteString(gorazor.HTMLEscape((data.Module)))
	_buffer.WriteString("\",\n  \"main\": \"app.js\",\n  \"directories\": {\n    \"test\": \"test\"\n  },\n  \"dependencies\": {\n    \"moment\": \"^2.8.4\",\n    \"react\": \"^0.12.2\",\n    \"webpack\": \"^1.4.15\",\n    \"jsx-loader\": \"^0.12.2\",\n    \"css-loader\": \"^0.9.0\",\n    \"style-loader\": \"^0.8.2\",\n    \"less\": \"^2.2.0\",\n    \"less-loader\": \"^2.0.0\",\n    \"extract-text-webpack-plugin\": \"^0.3.6\",\n    \"file-loader\": \"^0.8.1\",\n    \"bootstrap\": \"^3.3.1\",\n    \"url-loader\": \"^0.5.5\",\n    \"jquery\": \"^2.1.3\"\n  },\n  \"devDependencies\": {},\n  \"scripts\": {},\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git://yourdomain.com/yourrepository.git\"\n  },\n  \"keywords\": [\n    \"ui\",\n    \"widget\"\n  ],\n  \"author\": {\n    \"name\": \"Your Name\"\n  },\n  \"license\": \"MIT\",\n  \"bugs\": {\n    \"url\": \"https://yourdomain.com/yourrepository/issues\"\n  },\n  \"homepage\": \"https://yourdomain.com/yourrepository\"\n}")

	return _buffer.String()
}
예제 #6
0
func tplHorizontalDescription(conf HorizontalDescription) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n<dl class=\"dl-horizontal\">\n    <dt>")
	_buffer.WriteString(gorazor.HTMLEscape(conf.Key))
	_buffer.WriteString("</dt>\n    <dd>")
	_buffer.WriteString(gorazor.HTMLEscape(conf.Value))
	_buffer.WriteString("</dd>\n</dl>")

	return _buffer.String()
}
예제 #7
0
파일: header.go 프로젝트: vycb/gorazortpl
func Header(u *User) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n\t<meta charset=\"UTF-8\">\n\t<title>")
	_buffer.WriteString(gorazor.HTMLEscape(u.Name))
	_buffer.WriteString(" ")
	_buffer.WriteString(gorazor.HTMLEscape(u.Email))
	_buffer.WriteString("</title>\n</head>\n<body>\n<div>Page Header</div>")

	return _buffer.String()
}
예제 #8
0
파일: Index.go 프로젝트: sunfmin/hyperboot
func Index(data WebData) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n<!doctype html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"utf-8\">\n    <title>Main</title>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n    <link rel=\"stylesheet\" href=\"/")
	_buffer.WriteString(gorazor.HTMLEscape((data.Module)))
	_buffer.WriteString("/assets/main.css\">\n  </head>\n  <body>\n    <section id=\"react\"></section>\n    <script src=\"/")
	_buffer.WriteString(gorazor.HTMLEscape((data.Module)))
	_buffer.WriteString("/assets/main.js\"></script>\n  </body>\n</html>")

	return _buffer.String()
}
예제 #9
0
파일: Routes.go 프로젝트: sunfmin/hyperboot
func Routes(data WebData) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\npackage web\n\nimport (\n\t\"")
	_buffer.WriteString(gorazor.HTMLEscape(data.ConfigPkg))
	_buffer.WriteString("\"\n\t\"github.com/codegangsta/negroni\"\n\t\"github.com/gorilla/mux\"\n\t\"github.com/phyber/negroni-gzip/gzip\"\n\t\"net/http\"\n\t\"os\"\n\t\"path\"\n)\n\nfunc Routes() (n *negroni.Negroni) {\n\n\trouter := mux.NewRouter()\n\n\t// router.HandleFunc(\"/p/{articleId}.html\", Article)\n\n\tn = negroni.New()\n\tn.Use(gzip.Gzip(gzip.DefaultCompression))\n\n\tif config.Env != \"production\" {\n\t\tn.Use(negroni.NewRecovery())\n\t} else {\n\t\tn.Use(NewProductionRecovery())\n\t}\n\n\twebdir := path.Clean(config.WebDir)\n\tif _, err := os.Stat(webdir); err != nil {\n\t\tpanic(err)\n\t\treturn\n\t}\n\n\tstatic := &negroni.Static{\n\t\tDir:       http.Dir(webdir),\n\t\tPrefix:    \"/")
	_buffer.WriteString(gorazor.HTMLEscape((data.Module)))
	_buffer.WriteString("\",\n\t\tIndexFile: \"index.html\",\n\t}\n\n\tn.Use(static)\n\tn.Use(negroni.NewLogger())\n\tn.UseHandler(router)\n\treturn\n}")

	return _buffer.String()
}
예제 #10
0
파일: Main.go 프로젝트: sunfmin/hyperboot
func Main(data WebData) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\npackage main\n\nimport (\n\t\"")
	_buffer.WriteString(gorazor.HTMLEscape(data.WebPkg))
	_buffer.WriteString("\"\n\t\"")
	_buffer.WriteString(gorazor.HTMLEscape(data.HttpImplPkg))
	_buffer.WriteString("\"\n\t\"log\"\n\t\"net/http\"\n)\n\nfunc main() {\n\n\t")
	_buffer.WriteString(gorazor.HTMLEscape((data.Module)))
	_buffer.WriteString("apihttpimpl.AddToMux(\"/api\", http.DefaultServeMux)\n\n\thttp.Handle(\"/\", web.Routes())\n\n\tlog.Println(\"Starting Server at 9000.\")\n\terr := http.ListenAndServe(\":9000\", nil)\n\tif err != nil {\n\t\tlog.Fatal(\"ListenAndServe: \", err)\n\t}\n}")

	return _buffer.String()
}
예제 #11
0
파일: base.go 프로젝트: fanliao/gorazor
func Base(body string, title string) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n<!DOCTYPE html>\n<html>\n<head>\n	<meta charset=\"utf-8\" />\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n	<link rel=\"stylesheet\" href=\"/css/bootstrap.min.css\">\n	<link rel=\"stylesheet\" href=\"/css/dashboard.css\">\n    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->\n    <!--[if lt IE 9]>\n      <script src=\"https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js\"></script>\n      <script src=\"https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js\"></script>\n    <![endif]-->\n	<title>")
	_buffer.WriteString(gorazor.HTMLEscape(title))
	_buffer.WriteString("</title>\n</head>\n<body>\n    <div class=\"navbar navbar-inverse navbar-fixed-top\" role=\"navigation\">\n      <div class=\"container-fluid\">\n        <div class=\"navbar-header\">\n          <button type=\"button\" class=\"navbar-toggle\" data-toggle=\"collapse\" data-target=\".navbar-collapse\">\n            <span class=\"sr-only\">Toggle navigation</span>\n            <span class=\"icon-bar\"></span>\n            <span class=\"icon-bar\"></span>\n            <span class=\"icon-bar\"></span>\n          </button>\n          <a class=\"navbar-brand\" href=\"#\">广东省政法委信息化平台</a>\n        </div>\n        <div class=\"navbar-collapse collapse\">\n          <ul class=\"nav navbar-nav navbar-right\">\n            <li><a href=\"/admin/setting\">设置</a></li>\n            <li><a href=\"/admin/help\">帮助</a></li>\n            <li><a href=\"/admin/logout\">退出</a></li>\n          </ul>\n          <form class=\"navbar-form navbar-right\">\n            <input type=\"text\" class=\"form-control\" placeholder=\"搜索...\">\n          </form>\n        </div>\n      </div>\n    </div>\n\n    <div class=\"container-fluid\">\n      <div class=\"row\">\n        <div class=\"col-sm-3 col-md-2 sidebar\">\n			")
	_buffer.WriteString((helper.Menu()))
	_buffer.WriteString("\n        </div>\n        <div class=\"col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main\">\n          ")
	_buffer.WriteString(gorazor.HTMLEscape(body))
	_buffer.WriteString("\n        </div>\n      </div>\n    </div>\n	<script src=\"/js/jquery.min.js\"></script>\n	<script src=\"/js/bootstrap.min.js\"></script>\n  </body>\n</html>")

	return _buffer.String()
}
예제 #12
0
파일: layout.go 프로젝트: Zheaoli/gorazor
func Layout(body string, title string, side string) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"utf-8\" />")
	_buffer.WriteString(gorazor.HTMLEscape(title))
	_buffer.WriteString("\n</head>\n<body>\n<div>")
	_buffer.WriteString(gorazor.HTMLEscape(body))
	_buffer.WriteString("</div>\n<div>")
	_buffer.WriteString(gorazor.HTMLEscape(side))
	_buffer.WriteString("</div>\n</body>\n</html>")

	return _buffer.String()
}
예제 #13
0
func Simple(u *model.User) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n<html>\n    <body>\n        <h1>")
	_buffer.WriteString(gorazor.HTMLEscape(u.FirstName))
	_buffer.WriteString("</h1>\n\n        <p>Here's a list of your favorite colors:</p>\n        <ul>\n        ")
	for _, colorName := range u.FavoriteColors {

		_buffer.WriteString("<li>")
		_buffer.WriteString(gorazor.HTMLEscape(colorName))
		_buffer.WriteString("</li>")
	}

	_buffer.WriteString("\n        </ul>\n    </body>\n</html>")

	return _buffer.String()
}
예제 #14
0
파일: bug8.go 프로젝트: Zheaoli/gorazor
func Bug8(l *Locale) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n<span>")
	_buffer.WriteString(gorazor.HTMLEscape(l.T("for")))
	_buffer.WriteString("</span>")

	return _buffer.String()
}
예제 #15
0
파일: header.go 프로젝트: vycb/gorazortpl
func Header(p *Page) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n\t<meta charset=\"UTF-8\">\n\t<title>")
	_buffer.WriteString(gorazor.HTMLEscape(p.Title))
	_buffer.WriteString("</title>\n</head>\n<body>")

	return _buffer.String()
}
예제 #16
0
파일: Db.go 프로젝트: sunfmin/hyperboot
func Db(data DbData) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\npackage db\n\nimport (\n\t\"")
	_buffer.WriteString(gorazor.HTMLEscape(data.ConfigPkg))
	_buffer.WriteString("\"\n\t\"fmt\"\n\t_ \"github.com/go-sql-driver/mysql\"\n\t\"github.com/jinzhu/gorm\"\n)\n\nvar DB gorm.DB\nvar AllModels = []interface{}{\n\t&User{},\n}\n\nfunc init() {\n\thost := config.MySQLHost\n\tdatabase := config.MySQLDatabase\n\n\tvar err error\n\tconnect := fmt.Sprintf(\"root:%s@tcp(%s:%s)/%s?parseTime=true\", config.MySQLRootPassword, host, config.MySQLPort, database)\n\t// fmt.Println(connect)\n\tDB, err = gorm.Open(\"mysql\", connect)\n\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Error when connect database: '%v'\", err))\n\t}\n\n\tDB.LogMode(config.Env == \"development\")\n\n\tmodels := AllModels\n\n\tfor _, m := range models {\n\t\terr = DB.AutoMigrate(m).Error\n\t\tif err != nil {\n\t\t\tpanic(fmt.Sprintf(\"Error when migrate: '%v'\", err))\n\t\t}\n\t}\n\n}")

	return _buffer.String()
}
예제 #17
0
func Middleware(data WebData) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\npackage web\n\nimport (\n\t\"")
	_buffer.WriteString(gorazor.HTMLEscape(data.TemplatePkg))
	_buffer.WriteString("\"\n\t\"fmt\"\n\t\"log\"\n\t\"net/http\"\n\t\"os\"\n\t\"runtime\"\n)\n\n// Recovery is a Negroni middleware that recovers from any panics and writes a 500 if there was one.\ntype ProductionRecovery struct {\n\tLogger     *log.Logger\n\tPrintStack bool\n\tStackAll   bool\n\tStackSize  int\n}\n\n// NewRecovery returns a new instance of Recovery\nfunc NewProductionRecovery() *ProductionRecovery {\n\treturn &ProductionRecovery{\n\t\tLogger:     log.New(os.Stdout, \"[web] \", 0),\n\t\tPrintStack: true,\n\t\tStackAll:   false,\n\t\tStackSize:  1024 * 8,\n\t}\n}\n\nfunc (rec *ProductionRecovery) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {\n\tdefer func() {\n\t\tif err := recover(); err != nil {\n\t\t\trw.WriteHeader(http.StatusInternalServerError)\n\t\t\tstack := make([]byte, rec.StackSize)\n\t\t\tstack = stack[:runtime.Stack(stack, rec.StackAll)]\n\n\t\t\tf := \"PANIC: %s\\n%s\\n%s\\n%+v\\n\"\n\t\t\terrdesc := fmt.Sprintf(f, err, stack, r.URL.RawQuery, r.Header)\n\t\t\trec.Logger.Println(errdesc)\n\n\t\t\tfmt.Fprint(rw, templates.P500(errdesc))\n\n\t\t}\n\t}()\n\n\tnext(rw, r)\n}")

	return _buffer.String()
}
예제 #18
0
func Header(title string) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n<title>")
	_buffer.WriteString(gorazor.HTMLEscape(title))
	_buffer.WriteString("'s Home Page</title>\n<div class=\"header\">Page Header</div>")

	return _buffer.String()
}
예제 #19
0
파일: email.go 프로젝트: Zheaoli/gorazor
func Email() string {
	var _buffer bytes.Buffer
	_buffer.WriteString("<span>[email protected] ")
	_buffer.WriteString(gorazor.HTMLEscape(username))
	_buffer.WriteString("</span>")

	return _buffer.String()
}
예제 #20
0
파일: keyword.go 프로젝트: Zheaoli/gorazor
func Keyword() string {
	var _buffer bytes.Buffer
	_buffer.WriteString("BLK(<span>[email protected] ")
	_buffer.WriteString(gorazor.HTMLEscape(username))
	_buffer.WriteString("</span>)BLK")

	return _buffer.String()
}
예제 #21
0
파일: footer.go 프로젝트: vycb/gorazortpl
func Footer(p *Page) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n\n<div>")
	_buffer.WriteString(gorazor.HTMLEscape(p.Year))
	_buffer.WriteString(" Year</div>\n</body>\n</html>")

	return _buffer.String()
}
예제 #22
0
func Inline_var() string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n\n<body>")
	_buffer.WriteString(gorazor.HTMLEscape(Hello("Felix Sun", "h1", 30, &models.Author{"Van", 20}, 10)))
	_buffer.WriteString("\n</body>")

	return _buffer.String()
}
예제 #23
0
func RefreshSh(data ServiceData) string {
	var _buffer bytes.Buffer

	var comment = "\n# "
	if data.IsApp {
		comment = "\n"
	}

	_buffer.WriteString("\nhypermusk -pkg=")
	_buffer.WriteString(gorazor.HTMLEscape((data.ApiPkg)))
	_buffer.WriteString(" -impl=")
	_buffer.WriteString(gorazor.HTMLEscape((data.ServicesPkg)))
	_buffer.WriteString(" -lang=server -outdir=./\ngofmt -w ./")
	_buffer.WriteString(gorazor.HTMLEscape((data.Module)))
	_buffer.WriteString("apihttpimpl")
	_buffer.WriteString(gorazor.HTMLEscape((comment)))
	_buffer.WriteString("hypermusk -pkg=")
	_buffer.WriteString(gorazor.HTMLEscape((data.ApiPkg)))
	_buffer.WriteString(" -lang=javascript -outdir=./react")
	_buffer.WriteString(gorazor.HTMLEscape((comment)))
	_buffer.WriteString("gorazor ./web/templates ./web/templates")
	_buffer.WriteString(gorazor.HTMLEscape((comment)))
	_buffer.WriteString("cd react && npm install . && webpack .")

	return _buffer.String()
}
예제 #24
0
파일: badtag.go 프로젝트: fanliao/gorazor
func Badtag(w *gorazor.Widget) string {
	var _buffer bytes.Buffer
	if w.ErrorMsg != "" {

		_buffer.WriteString("<div class=\"form-group has-error\">\n	<div class=\"alert alert-danger\">")
		_buffer.WriteString(gorazor.HTMLEscape(w.ErrorMsg))
		_buffer.WriteString("</div>")
	} else {

		_buffer.WriteString("<div class=\"form-group\">")
	}
	_buffer.WriteString("\n\n	<label for=\"")
	_buffer.WriteString(gorazor.HTMLEscape(w.Name))
	_buffer.WriteString("\">")
	_buffer.WriteString(gorazor.HTMLEscape(w.Label))
	_buffer.WriteString("</label>\n	<input type=\"text\" name=\"")
	_buffer.WriteString(gorazor.HTMLEscape(w.Name))
	_buffer.WriteString("\" class=\"form-control\" id=\"")
	_buffer.WriteString(gorazor.HTMLEscape(w.Name))
	_buffer.WriteString("\" placeholder=\"")
	_buffer.WriteString(gorazor.HTMLEscape(w.PlaceHolder))
	_buffer.WriteString("\" value=\"")
	_buffer.WriteString(gorazor.HTMLEscape(w.Value))
	_buffer.WriteString("\">\n</div>")

	return _buffer.String()
}
예제 #25
0
func Navigation(nav []*model.Navigation) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n<ul class=\"navigation\">")

	for _, item := range nav {

		_buffer.WriteString("<li><a href=\"")
		_buffer.WriteString(gorazor.HTMLEscape(item.Link))
		_buffer.WriteString("\">")
		_buffer.WriteString(gorazor.HTMLEscape(item.Item))
		_buffer.WriteString("</a></li>")

	}

	_buffer.WriteString("\n</ul>")

	return _buffer.String()
}
예제 #26
0
파일: edit.go 프로젝트: Zheaoli/gorazor
func Edit(u *models.User) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n<div style=\"width: 500px\">\n<form role=\"form\">\n  <div class=\"form-group\">\n    <label for=\"exampleInputEmail1\">名字</label>\n    <input type=\"email\" class=\"form-control\" id=\"exampleInputEmail1\" placeholder=\"Enter email\" value=\"")
	_buffer.WriteString(gorazor.HTMLEscape(u.Name))
	_buffer.WriteString("\">\n  </div>\n  <div class=\"form-group\">\n    <label for=\"exampleInputPassword1\">电邮</label>\n    <input type=\"email\" class=\"form-control\" id=\"exampleInputPassword1\" placeholder=\"电邮\" value=\"")
	_buffer.WriteString(gorazor.HTMLEscape(u.Email))
	_buffer.WriteString("\">\n  </div>\n  <button type=\"submit\" class=\"btn btn-primary\">保存</button>\n  <a href=\"/admin/user\" class=\"btn btn-default pull-right\">返回</a>\n</form>\n</div>")

	title := func() string {
		var _buffer bytes.Buffer

		_buffer.WriteString("用户管理")

		return _buffer.String()
	}

	return layout.Base(_buffer.String(), title())
}
예제 #27
0
파일: bench.go 프로젝트: vycb/gorazortpl
func Bench(p *Page) string {
	var _buffer bytes.Buffer
	_buffer.WriteString(gorazor.HTMLEscape(Header(p)))
	_buffer.WriteString("\n<h1>Hello ")
	_buffer.WriteString(gorazor.HTMLEscape(strings.TrimSpace(p.Title)))
	_buffer.WriteString(" !</h1>\n\n<p>Here's a list of your favorite colors:</p>\n<ul>\n\t")
	for _, colorName := range p.FavoriteColors {

		_buffer.WriteString("<li>")
		_buffer.WriteString(gorazor.HTMLEscape(colorName))
		_buffer.WriteString("</li>")

	}
	_buffer.WriteString("\n</ul>")
	_buffer.WriteString(gorazor.HTMLEscape(Footer(p)))

	return _buffer.String()
}
예제 #28
0
파일: argsbug.go 프로젝트: fanliao/gorazor
func Argsbug(totalMessage int, u *User) string {
	var _buffer bytes.Buffer

	messages := []string{}
	_buffer.WriteString("\n\n<p>")
	_buffer.WriteString(gorazor.HTMLEscape(gorazor.Itoa(args(messages...))))
	_buffer.WriteString("</p>")

	return layout.Args(_buffer.String())
}
예제 #29
0
파일: Api.go 프로젝트: sunfmin/hyperboot
func Api(data ServiceData) string {
	var _buffer bytes.Buffer

	var lowerModule = strings.ToLower(data.Module)

	_buffer.WriteString("\npackage ")
	_buffer.WriteString(gorazor.HTMLEscape((lowerModule)))
	_buffer.WriteString("api\n\nimport (\n\t\"errors\"\n)\n\nvar (\n\tPermissionDeniedError = errors.New(\"permission denied.\")\n)\n\ntype User struct {\n\tId           string\n\tName        string\n\tUpperName   string\n}\n\n\ntype AppService interface {\n\tGetUserService(session string) (service UserService, err error)\n}\n\n\ntype UserService interface {\n\tPutUser(id int, name string) (user *User, err error)\n}")

	return _buffer.String()
}
예제 #30
0
func Index(u *model.User, nav []*model.Navigation, title string) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n\n<div class=\"content\">\n\t<div class=\"welcome\">\n\t\t<h4>Hello ")
	_buffer.WriteString(gorazor.HTMLEscape(u.FirstName))
	_buffer.WriteString("</h4>\n\t\t\n\t\t<div class=\"raw\">")
	_buffer.WriteString((u.RawContent))
	_buffer.WriteString("</div>\n\t\t<div class=\"enc\">")
	_buffer.WriteString(gorazor.HTMLEscape(u.EscapedContent))
	_buffer.WriteString("</div>\n\t</div>")

	for i := 1; i <= 5; i++ {
		if i == 1 {

			_buffer.WriteString("<p>")
			_buffer.WriteString(gorazor.HTMLEscape(u.FirstName))
			_buffer.WriteString(" has ")
			_buffer.WriteString(gorazor.HTMLEscape(i))
			_buffer.WriteString(" message</p>")

		} else {

			_buffer.WriteString("<p>")
			_buffer.WriteString(gorazor.HTMLEscape(u.FirstName))
			_buffer.WriteString(" has ")
			_buffer.WriteString(gorazor.HTMLEscape(gorazor.Itoa(i)))
			_buffer.WriteString(" messages</p>")

		}
	}

	_buffer.WriteString("\n</div>")

	header := func() string {
		var _buffer bytes.Buffer

		_buffer.WriteString((helper.Header(title)))

		return _buffer.String()
	}

	footer := func() string {
		var _buffer bytes.Buffer

		_buffer.WriteString((helper.Footer()))

		return _buffer.String()
	}

	navigation := func() string {
		var _buffer bytes.Buffer

		_buffer.WriteString((helper.Navigation(nav)))

		return _buffer.String()
	}

	return layout.Base(_buffer.String(), header(), footer(), navigation())
}