本文整理匯總了Golang中github.com/fuxiaohei/GoInk.App.Get方法的典型用法代碼示例。如果您正苦於以下問題:Golang App.Get方法的具體用法?Golang App.Get怎麽用?Golang App.Get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/fuxiaohei/GoInk.App
的用法示例。
在下文中一共展示了App.Get方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetLogs
func GetLogs(app *GoInk.App) []*logItem {
dir := app.Get("log_dir")
logs := make([]*logItem, 0)
filepath.Walk(dir, func(_ string, info os.FileInfo, err error) error {
if err == nil {
if info.IsDir() {
return nil
}
ext := filepath.Ext(info.Name())
if ext != ".log" {
return nil
}
bytes, e := ioutil.ReadFile(filepath.Join(dir, info.Name()))
if e != nil {
return nil
}
l := new(logItem)
l.Name = info.Name()
l.CreateTime = info.ModTime().Unix()
l.Text = string(bytes)
logs = append([]*logItem{l}, logs...)
}
return nil
})
return logs
}
示例2: upgrade_20140130
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
}
示例3: upgrade_20140209
func upgrade_20140209(app *GoInk.App) bool {
// clean template
vDir := app.Get("view_dir")
os.Remove(path.Join(vDir, "admin.layout"))
os.Remove(path.Join(vDir, "cmd.layout"))
// write default menu setting
model.DefaultNavigators()
// write message storage
model.Storage.Set("messages", []*model.Message{})
cmd.ExtractBundleBytes()
return true
}
示例4: upgrade_20140131
func upgrade_20140131(app *GoInk.App) bool {
// re-write all data to non-indent json
/*model.All()
model.SyncContents()
model.SyncFiles()
model.SyncReaders()
model.SyncSettings()
model.SyncTokens()
model.SyncUsers()
model.SyncVersion()*/
// update ling template
os.RemoveAll(path.Join(app.Get("view_dir"), "ling"))
cmd.ExtractBundleBytes()
return true
}
示例5: RemoveLogFile
func RemoveLogFile(app *GoInk.App, file string) {
f := filepath.Join(app.Get("log_dir"), file)
os.Remove(f)
}