Beispiel #1
0
func main() {
	beego.AddFuncMap("Preview", common.Preview)
	beego.AddFuncMap("GetId", common.GetId)
	beego.AddFuncMap("LoadTimes", common.LoadTimes)
	beego.AddFuncMap("GetTagSlug", common.GetTagSlug)
	beego.Run()
}
func AddFuncMap() {
	beego.AddFuncMap("balance", ParseBalance)
	beego.AddFuncMap("checkstr", CheckStr)
	beego.AddFuncMap("lockStatusStr", LockStatusStr)
	beego.AddFuncMap("calcPrice", CalcPrice)
	beego.AddFuncMap("parseOrderDate", ParseOrderDate)
}
Beispiel #3
0
func main() {
	initialize()
	go catchExit()

	beego.Info(beego.AppName, APP_VER)

	// Register routers.
	beego.Router("/", &routers.HomeRouter{})
	beego.Router("/refresh", &routers.RefreshRouter{})
	beego.Router("/search", &routers.SearchRouter{})
	beego.Router("/index", &routers.IndexRouter{})
	// beego.Router("/label", &routers.LabelsRouter{})
	beego.Router("/function", &routers.FuncsRouter{})
	beego.Router("/example", &routers.ExamplesRouter{})
	beego.Router("/about", &routers.AboutRouter{})

	beego.Router("/api/v1/badge", &routers.ApiRouter{}, "get:Badge")

	// Register template functions.
	beego.AddFuncMap("i18n", i18n.Tr)
	beego.AddFuncMap("isHasEleS", isHasEleS)
	beego.AddFuncMap("isHasEleE", isHasEleE)
	beego.AddFuncMap("isNotEmptyS", isNotEmptyS)

	// "robot.txt"
	beego.Router("/robots.txt", &routers.RobotRouter{})

	// For all unknown pages.
	beego.Router("/:all", &routers.HomeRouter{})

	// Static path.
	beego.SetStaticPath("/public", "public")
	beego.Run()
}
Beispiel #4
0
func BeegoInit() {
	beego.RunMode = config.AppConfig.RunMode
	beego.AppName = config.AppConfig.Name
	beego.HttpPort = config.AppConfig.Port
	beego.BeegoServerName = config.AppConfig.ServerName
	beego.SessionOn = true
	beego.SessionName = "ckeyer"
	// beego.SessionDomain = "fxgcj.org"
	beego.SessionAutoSetCookie = true
	beego.AddFuncMap("showMonth", func(m int) string {
		mstr := fmt.Sprint(m)
		if len(mstr) == 6 {
			return fmt.Sprintf("%s-%s", mstr[:4], mstr[4:])
		}
		return mstr
	})
	beego.AddFuncMap("showDate", func(t time.Time) string {
		return fmt.Sprintf("%d-%02d-%02d %02d:%02d", t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute())
	})
	beego.AddFuncMap("showObjectID", func(obj bson.ObjectId) string {
		return obj.Hex()
	})
	beego.AddFuncMap("setURLMonth", func(m string) string {
		mstr := strings.Split(m, "-")
		if len(mstr) == 2 {
			return fmt.Sprintf("%s/%s", mstr[0], mstr[1])
		}
		return ""
	})
	beego.AddFuncMap("Add", func(a, b int) string {
		return fmt.Sprint(a + b)
	})

	routers.LoadRouters()
}
Beispiel #5
0
func main() {
	beego.AddFuncMap("fileConv", convertTypetoIcon)
	beego.AddFuncMap("genBackBtn", genBackBtn)
	beego.AddFuncMap("genLink", genLink)
	beego.AddFuncMap("converTime", converTime)
	beego.Run()
}
Beispiel #6
0
func init() {
	// Register template functions.
	beego.AddFuncMap("date", date)
	beego.AddFuncMap("datetime", datetime)
	beego.AddFuncMap("datetimes", datetimes)
	beego.AddFuncMap("loadtimes", loadtimes)
}
Beispiel #7
0
func init() {
	Logger.SetLogger("console", "")
	beego.AddFuncMap("asset_js", getAssetHelper(ASSET_JAVASCRIPT))
	beego.AddFuncMap("asset_css", getAssetHelper(ASSET_STYLESHEET))
	Config.extensions[ASSET_JAVASCRIPT] = []string{".js"}
	Config.extensions[ASSET_STYLESHEET] = []string{".css"}

}
Beispiel #8
0
func main() {
	beego.SessionOn = true
	beego.AddFuncMap("Index", Index)
	beego.AddFuncMap("Count", GetCount)
	beego.AddFuncMap("ResCount", GetResCount)
	beego.AddFilter("/admin/:all", "AfterStatic", FilterUser)
	beego.Run()
}
Beispiel #9
0
/*
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
    ->     IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
    ->     IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
mysql> GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost';
mysql> GRANT USAGE ON *.* TO 'dummy'@'localhost';
*/
func init() {
	//CREATE USER user1 IDENTIFIED BY [PASSWORD] 'password1'
	orm.RegisterDataBase("default", "mysql", "user1:password1@/beeapp?charset=utf8", 30)
	orm.RegisterModel(new(models.Greeting))

	beego.AddFuncMap("dateformat", dateformat)
	beego.AddFuncMap("nl2br", nl2br)

}
Beispiel #10
0
func main() {
	// 注册静态文件
	beego.SetStaticPath("/static", "static")

	// 自定义404错误页
	beego.ErrorController(&controllers.ErrorController{})

	// 首页路由
	beego.Router("/", &controllers.IndexController{}, "get:Index")
	// 文章路由
	beego.Router("/:slug", &controllers.IndexController{}, "get:View")
	// 内链跳转
	beego.Router("/go/:caption", &controllers.IndexController{}, "get:GoLink")
	// 搜索
	beego.Router("/search", &controllers.IndexController{}, "get:Search")
	// 标签页面
	beego.Router("/tag/:tag", &controllers.IndexController{}, "get:TagList")

	// 后台验证码
	beego.Router("/captcha", &controllers.LoginController{}, "get:Captcha")
	// 后台登录
	beego.Router("/admin/login", &controllers.LoginController{}, "*:Index")
	// 退出登录
	beego.Router("/admin/logout", &controllers.LoginController{}, "*:Logout")
	// 后台首页
	beego.Router("/admin", &controllers.AdminController{}, "get:Index")
	// 新建文章
	beego.Router("/admin/new", &controllers.AdminController{}, "get:New")
	// 编辑文章
	beego.Router("/admin/edit/:id", &controllers.AdminController{}, "get:Edit")
	// 提交文章
	beego.Router("/admin/edit", &controllers.AdminController{}, "post:Edit")
	// 删除文章
	beego.Router("/admin/del/:id", &controllers.AdminController{}, "get:Del")
	// 内链管理
	beego.Router("/admin/redirect", &controllers.AdminController{}, "*:External")
	// 内链修改
	beego.Router("/admin/redirect/:id", &controllers.AdminController{}, "get:External")
	// 内链删除
	beego.Router("/admin/redirect/del/:id", &controllers.AdminController{}, "get:DelExternal")
	// 系统设置
	beego.Router("/admin/setting", &controllers.AdminController{}, "*:Setting")
	// 获取汉字转拼音
	beego.Router("/admin/pinyin/:str", &controllers.AdminController{}, "get:PinYin")
	// 上传文件
	beego.Router("/admin/upload", &controllers.AdminController{}, "post:Upload")

	// 注册函数
	beego.AddFuncMap("Preview", common.Preview)
	beego.AddFuncMap("GetId", common.GetId)
	beego.AddFuncMap("Gravatar", common.Gravatar)
	beego.AddFuncMap("GetTagSlug", common.GetTagSlug)
	beego.AddFuncMap("LoadTimes", common.LoadTimes)

	beego.Run()
}
Beispiel #11
0
func main() {
	orm.Debug = true
	orm.RunSyncdb("default", false, true)
	beego.SessionOn = true

	//模板函数
	beego.AddFuncMap("time", timeformat)
	beego.AddFuncMap("time1", timeformat1)
	beego.Run()
}
Beispiel #12
0
func CtrlInit() {

	staticDir = beego.AppConfig.String("staticDir")

	CandDateFmt = beego.AppConfig.String("comments::cand_date_format")
	TrashDateFmt = beego.AppConfig.String("comments::trash_date_format")
	gitlabUrl = beego.AppConfig.String("gitlab::url")
	gitlabProject = beego.AppConfig.String("gitlab::project")

	beego.AddFuncMap("urlFor", beego.UrlFor)
	beego.AddFuncMap("js", js)
	beego.AddFuncMap("css", css)
	beego.AddFuncMap("kb", kb)
	beego.AddFuncMap("isImg", isImg)
	beego.AddFuncMap("cutStr", CutLongText)
	beego.AddFuncMap("urlContain", urlContain)
	beego.AddFuncMap("T", i18n.IdentityTfunc)
	beego.AddFuncMap("floatStr", floatToString)

	DM = M.GetDM()

	// init notify service
	initNotifyService()
	initBot()

}
Beispiel #13
0
func InitHelper() {
	beego.AddFuncMap("TimeFormat", TimeFormat)
	beego.AddFuncMap("Strcat", Strcat)
	beego.AddFuncMap("ShowMenu", ShowMenu)
	beego.AddFuncMap("AddInt", AddInt)
	beego.AddFuncMap("GetStatusDesc", GetStatusDesc)
	beego.AddFuncMap("GetStatusColor", GetStatusColor)
	beego.AddFuncMap("GetTimeDiff", GetTimeDiff)
	beego.AddFuncMap("GetRoleDesc", GetRoleDesc)
	beego.AddFuncMap("RequiredStar", RequiredStar)
	beego.AddFuncMap("TimeIsZero", TimeIsZero)
}
Beispiel #14
0
func init() {
	// Register template functions.
	beego.AddFuncMap("i18n", i18nHTML)
	beego.AddFuncMap("boolicon", boolicon)
	beego.AddFuncMap("date", date)
	beego.AddFuncMap("datetime", datetime)
	beego.AddFuncMap("datetimes", datetimes)
	beego.AddFuncMap("dict", dict)
	beego.AddFuncMap("timesince", timesince)
	beego.AddFuncMap("loadtimes", loadtimes)
	beego.AddFuncMap("sum", sum)
	beego.AddFuncMap("loginto", loginto)
}
Beispiel #15
0
func init() {
	// Register template functions.
	beego.AddFuncMap("i18n", i18nHTML)
	beego.AddFuncMap("boolicon", boolicon)
	beego.AddFuncMap("date", date)
	beego.AddFuncMap("datetime", datetime)
	beego.AddFuncMap("dict", dict)
	beego.AddFuncMap("timesince", timesince)
	beego.AddFuncMap("loadtimes", loadtimes)
	beego.AddFuncMap("sum", sum)
	beego.AddFuncMap("loginto", loginto)
	beego.AddFuncMap("initajaxurl", generateInitialAjaxUrlVariable)
}
Beispiel #16
0
func main() {
	beego.SessionOn = true
	beego.ErrorController(&controllers.ErrorController{})
	beego.AddFuncMap("i18n", i18n.Tr)

	beego.EnableAdmin = true // Port 8088

	beego.SetLogger("file", `{"filename":"logs/juna.log"}`)
	beego.SetLevel(beego.LevelInformational)
	beego.SetLogFuncCall(true)

	beego.AddFuncMap("news", news)
	beego.Run()
}
Beispiel #17
0
func main() {

	initialize()

	beego.Info(beego.AppName, APP_VER)

	beego.InsertFilter("/docs/images/:all", beego.BeforeRouter, routers.DocsStatic)

	if !routers.IsPro {
		beego.SetStaticPath("/static_source", "static_source")
		beego.DirectoryIndex = true
	}

	beego.SetStaticPath("/products/images", "products/images/")

	// Register routers.
	beego.Router("/", &routers.HomeRouter{})
	beego.Router("/community", &routers.CommunityRouter{})
	beego.Router("/quickstart", &routers.QuickStartRouter{})
	beego.Router("/video", &routers.VideoRouter{})
	beego.Router("/products", &routers.ProductsRouter{})
	beego.Router("/team", &routers.PageRouter{})
	beego.Router("/about", &routers.AboutRouter{})
	beego.Router("/donate", &routers.DonateRouter{})
	beego.Router("/docs/", &routers.DocsRouter{})
	beego.Router("/docs/:all", &routers.DocsRouter{})
	beego.Router("/blog", &routers.BlogRouter{})
	beego.Router("/blog/:all", &routers.BlogRouter{})

	// Register template functions.
	beego.AddFuncMap("i18n", i18n.Tr)

	beego.Run()
}
Beispiel #18
0
func init() {
	setting, err := compress.LoadJsonConf("conf/compress.json", true, "/")
	if err != nil {
		panic("LoadJsonConf compress.json err:" + err.Error())
	}

	setting.RunCommand()

	setting.RunCompress(true, false, true)

	beego.AddFuncMap("compress_js", setting.Js.CompressJs)
	beego.AddFuncMap("compress_css", setting.Css.CompressCss)
	beego.AddFuncMap("i18n", i18n)
	beego.AddFuncMap("config", config)
	beego.AddFuncMap("docs", docs)
}
Beispiel #19
0
func main() {

	initialize()

	beego.Info(beego.AppName, APP_VER)

	beego.AddFilter("/docs/images/:all", "BeforeRouter", routers.DocsStatic)

	// Register routers.
	beego.Router("/", &routers.HomeRouter{})
	beego.Router("/community", &routers.CommunityRouter{})
	beego.Router("/quickstart", &routers.QuickStartRouter{})
	beego.Router("/team", &routers.PageRouter{})
	beego.Router("/about", &routers.AboutRouter{})
	beego.Router("/donate", &routers.DonateRouter{})
	beego.Router("/docs/", &routers.DocsRouter{})
	beego.Router("/docs/:all", &routers.DocsRouter{})
	beego.Router("/blog", &routers.BlogRouter{})
	beego.Router("/blog/:all", &routers.BlogRouter{})
	// beego.Router("/samples", &routers.SamplesRouter{})
	// beego.Router("/samples/:all", &routers.SamplesRouter{})

	// Register template functions.
	beego.AddFuncMap("i18n", i18n.Tr)

	beego.Run()
}
Beispiel #20
0
func main() {

	//初始化
	initialize()

	beego.Info(beego.AppName, APP_VER)

	if !controllers.IsPro {
		beego.SetStaticPath("/static_source", "static_source")
		beego.DirectoryIndex = true
	}

	// 开启 ORM 调试模式
	orm.Debug = true
	// 自动建表
	orm.RunSyncdb("default", false, true)

	beego.Router("/", &controllers.MainController{})
	beego.Router("/user/reg", &controllers.UserController{}, "post:reg")

	// Register template functions.
	beego.AddFuncMap("i18n", i18n.Tr)

	beego.Run()
}
Beispiel #21
0
func main() {
	initialize()

	beego.Info(beego.AppName, APP_VER)

	// Register routers.
	beego.Router("/", &routers.HomeRouter{})
	beego.Router("/login", &routers.LoginRouter{})

	beego.Router("/register", &routers.RegisterRouter{})
	beego.Router("/register/success", &routers.RegisterRouter{}, "get:Success")
	beego.Router("/active/success", &routers.RegisterRouter{}, "get:ActiveSuccess")
	beego.Router("/active/:code([0-9a-zA-Z]+)", &routers.RegisterRouter{}, "get:Active")
	beego.Router("/active/resend", &routers.RegisterRouter{}, "post:Resend")

	beego.Router("/forgot", &routers.ForgotRouter{})
	beego.Router("/reset", &routers.ResetRouter{})

	// Register template functions.
	beego.AddFuncMap("i18n", i18n.Tr)

	// "robot.txt"
	beego.Router("/robot.txt", &routers.RobotRouter{})

	// For all unknown pages.
	beego.Run()
}
Beispiel #22
0
func main() {
	beego.Info(beego.AppName, APP_VER)

	// Register routers.
	beego.Router("/", &controllers.AppController{})
	// Indicate AppController.Join method to handle POST requests.
	beego.Router("/join", &controllers.AppController{}, "post:Join")

	// Long polling.
	beego.Router("/lp", &controllers.LongPollingController{}, "get:Join")
	beego.Router("/lp/post", &controllers.LongPollingController{})
	beego.Router("/lp/fetch", &controllers.LongPollingController{}, "get:Fetch")

	// WebSocket.
	beego.Router("/ws", &controllers.WebSocketController{})
	beego.Router("/ws/join", &controllers.WebSocketController{}, "get:Join")

	// Register template functions.
	beego.AddFuncMap("i18n", i18n.Tr)

	// serve securely if the certificates are present
	_, certErr := os.Stat(servingCertFile)
	_, keyErr := os.Stat(servingKeyFile)
	if certErr == nil && keyErr == nil && len(servingCertFile) > 0 && len(servingKeyFile) > 0 {
		beego.HttpCertFile = servingCertFile
		beego.HttpKeyFile = servingKeyFile
		beego.EnableHttpTLS = true
	}

	beego.Run()
}
Beispiel #23
0
func init() {
	// beego.Router("/", &controllers.MainController{})
	beego.Include(&controllers.MainController{})
	beego.AddFuncMap("ToString", func(b []byte) string {
		return goutils.ToString(b)
	})
}
Beispiel #24
0
func main() {
	beego.SessionOn = true
	beego.SetStaticPath("/public", "public")
	//增加模板格式化函数标签
	beego.AddFuncMap("CategoryFormat", utils.CategoryFormat)
	beego.Run()
}
Beispiel #25
0
func init() {

	//conf/app.conf -> os.Getenv("config_path")
	configPath := os.Getenv("CONFIG_PATH")
	if len(configPath) != 0 {
		log.Infof("Config path: %s", configPath)
		beego.LoadAppConfig("ini", configPath)
	}

	beego.AddFuncMap("i18n", i18n.Tr)

	langs := strings.Split(beego.AppConfig.String("lang::types"), "|")
	names := strings.Split(beego.AppConfig.String("lang::names"), "|")

	supportLanguages = make(map[string]langType)

	langTypes = make([]*langType, 0, len(langs))

	for i, lang := range langs {
		t := langType{
			Lang: lang,
			Name: names[i],
		}
		langTypes = append(langTypes, &t)
		supportLanguages[lang] = t
		if err := i18n.SetMessage(lang, "static/i18n/"+"locale_"+lang+".ini"); err != nil {
			log.Errorf("Fail to set message file: %s", err.Error())
		}
	}

}
Beispiel #26
0
func settingCompress() {
	setting, err := compress.LoadJsonConf(CompressConfPath, IsPro, "/")
	if err != nil {
		beego.Error(err)
		return
	}

	setting.RunCommand()

	if IsPro {
		setting.RunCompress(true, false, true)
	}

	beego.AddFuncMap("compress_js", setting.Js.CompressJs)
	beego.AddFuncMap("compress_css", setting.Css.CompressCss)
}
Beispiel #27
0
func main() {
	orm.Debug = true
	orm.RunSyncdb("default", false, true)

	beego.Router("/", &controllers.MainController{})
	beego.Router("/login", &controllers.LoginController{})
	beego.Router("/category", &controllers.CategoryController{})
	beego.Router("/reply", &controllers.ReplyController{})
	beego.AutoRouter(&controllers.ReplyController{})
	beego.Router("/topic", &controllers.TopicController{})
	beego.AutoRouter(&controllers.TopicController{})

	os.Mkdir("attachment", os.ModePerm)
	beego.SetStaticPath("/attachment", "attachment")

	err := i18n.SetMessage("en-US", "conf/locale_en-US.ini")
	if err != nil {
		beego.Error(err)
	}
	err = i18n.SetMessage("zh-CN", "conf/locale_zh-CN.ini")
	if err != nil {
		beego.Error(err)
	}
	err = i18n.SetMessage("zh-HK", "conf/locale_zh-HK.ini")
	if err != nil {
		beego.Error(err)
	}

	beego.AddFuncMap("i18n", i18n.Tr)

	beego.Run()
}
Beispiel #28
0
func init() {

	var datasource string
	// for heroku with cleardb
	if os.Getenv("CLEARDB_DATABASE_URL") != "" {
		datasource = convert_datasource(os.Getenv("CLEARDB_DATABASE_URL"))
	} else {
		datasource = "user:pass@/database_name?charset=utf8"
	}
	orm.RegisterDataBase("default", "mysql", datasource, 30)
	orm.RegisterModel(new(models.Greeting))

	beego.AddFuncMap("dateformat", dateformat)
	beego.AddFuncMap("nl2br", nl2br)

}
Beispiel #29
0
func settingCompress() {
	AppUrl = beego.AppConfig.DefaultString("appurl", "")
	setting, err := compress.LoadJsonConf(CompressConfPath, IsProMode, AppUrl)
	if err != nil {
		beego.Error(err)
		return
	}

	setting.RunCommand()

	if IsProMode {
		setting.RunCompress(true, false, true)
	}

	beego.AddFuncMap("compress_js", setting.Js.CompressJs)
	beego.AddFuncMap("compress_css", setting.Css.CompressCss)
}
Beispiel #30
0
func main() {
	i18n.SetMessage("en-US", "conf/locale_en-US.ini")
	i18n.SetMessage("zh-CN", "conf/locale_zh-CN.ini")

	beego.AddFuncMap("i18n", i18n.Tr)

	beego.Run()
}