コード例 #1
0
ファイル: app.go プロジェクト: HYQMartin/go_learning
// Init starts Fxh.Go application preparation.
// Load models and plugins, update views.
func Init() {

	// init storage
	model.Init(VERSION)

	// load all data
	model.All()

	// init plugin
	plugin.Init()

	// update plugin handlers
	plugin.Update(App)

	App.View().FuncMap["DateInt64"] = utils.DateInt64
	App.View().FuncMap["DateString"] = utils.DateString
	App.View().FuncMap["DateTime"] = utils.DateTime
	App.View().FuncMap["Now"] = utils.Now
	App.View().FuncMap["Html2str"] = utils.Html2str
	App.View().FuncMap["FileSize"] = utils.FileSize
	App.View().FuncMap["Setting"] = model.GetSetting
	App.View().FuncMap["Navigator"] = model.GetNavigators
	App.View().FuncMap["Md2html"] = utils.Markdown2HtmlTemplate
	App.View().IsCache = (model.GetSetting("theme_cache") == "true")

	println("app version @ " + strconv.Itoa(model.GetVersion().Version))
}
コード例 #2
0
ファイル: v20140130.go プロジェクト: carriercomm/GoBlog
func upgrade_20140130(app *GoInk.App) bool {

	// change settings
	model.LoadSettings()
	model.SetSetting("c_footer_ga", "<!-- google analytics or other -->")
	model.SetSetting("enable_go_markdown", "false")
	model.SetSetting("enable_go_markdown_def", "false")
	model.SetSetting("site_theme", "default")
	model.SetSetting("site_theme_def", "default")
	model.SetSetting("c_home_avatar", "/static/img/site.png")
	model.SyncSettings()

	// init plugin
	plugin.Init()
	model.Storage.Dir("plugin")

	// remove static files
	os.RemoveAll(app.Get("view_dir"))
	os.RemoveAll(path.Join(app.Get("static_dir"), "less"))
	os.RemoveAll(path.Join(app.Get("static_dir"), "css"))
	os.RemoveAll(path.Join(app.Get("static_dir"), "img"))
	os.RemoveAll(path.Join(app.Get("static_dir"), "js"))
	os.RemoveAll(path.Join(app.Get("static_dir"), "lib"))
	os.Remove(path.Join(app.Get("static_dir"), "favicon.ico"))

	// extract current static files
	cmd.ExtractBundleBytes()

	// "c_footer_ga":        "<!-- google analytics or other -->",
	// "enable_go_markdown": "true",
	// "enable_go_markdown_def": "false",
	// "site_theme": "ling",
	// "site_theme_def": "default",
	return true
}