• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang GoInk.App类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/fuxiaohei/GoInk.App的典型用法代码示例。如果您正苦于以下问题:Golang App类的具体用法?Golang App怎么用?Golang App使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了App类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
开发者ID:carriercomm,项目名称:GoBlog,代码行数:26,代码来源:log.go


示例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
}
开发者ID:carriercomm,项目名称:GoBlog,代码行数:35,代码来源:v20140130.go


示例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
}
开发者ID:carriercomm,项目名称:GoBlog,代码行数:15,代码来源:v20140209.go


示例4: Update

func Update(app *GoInk.App) {
	pluginHandlers, routeHandlers := Handlers()

	if len(routeHandlers) > 0 {
		for n, h := range routeHandlers {
			if usedHandler["route"][n] {
				continue
			}
			app.Route(h.Method, h.Pattern, h.Handler)
			usedHandler["route"][n] = true
		}
	}

	if len(pluginHandlers["middle"]) > 0 {
		for n, h := range pluginHandlers["middle"] {
			if usedHandler["middle"][n] {
				continue
			}
			app.Use(h)
			usedHandler["middle"][n] = true
			//println("use plugin middle handler",n)
		}
		//fmt.Println(usedHandler)
	}

	if len(pluginHandlers["inter"]) > 0 {
		for name, h := range pluginHandlers["inter"] {
			if usedHandler["inter"][name] {
				continue
			}
			if name == "static" {
				app.Static(h)
				usedHandler["inter"][name] = true
				continue
			}
			if name == "recover" {
				app.Recover(h)
				usedHandler["inter"][name] = true
				continue
			}
			if name == "notfound" {
				app.NotFound(h)
				usedHandler["inter"][name] = true
				continue
			}
		}
	}
}
开发者ID:flying99999,项目名称:GoBlog,代码行数:48,代码来源:plugin.go


示例5: 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
}
开发者ID:flying99999,项目名称:GoBlog,代码行数:18,代码来源:v20140131.go


示例6: DoBackup

// DoBackup backups whole files to zip archive.
// If withData is false, it compresses static files to zip archive without data files, config files and install lock file.
func DoBackup(app *GoInk.App, withData bool) (string, error) {
	os.Mkdir(backupDir, os.ModePerm)
	// create zip file name from time unix
	filename := path.Join(backupDir, utils.DateTime(time.Now(), "YYYYMMDDHHmmss"))
	if withData {
		filename += ".zip"
	} else {
		filename += "_static.zip"
	}
	z, e := zip.Create(filename)
	if e != nil {
		return "", e
	}
	root, _ := os.Getwd()
	if withData {
		// if with data, add install lock file and config file
		lockFile := path.Join(root, "install.lock")
		if utils.IsFile(lockFile) {
			z.AddFile("install.lock", lockFile)
		}
		configFile := path.Join(root, "config.json")
		if utils.IsFile(configFile) {
			z.AddFile("config.json", configFile)
		}
	}
	z.AddDir("static/css", path.Join(root, "static", "css"))
	z.AddDir("static/img", path.Join(root, "static", "img"))
	z.AddDir("static/js", path.Join(root, "static", "js"))
	z.AddDir("static/lib", path.Join(root, "static", "lib"))
	z.AddFile("static/favicon.ico", path.Join(root, "static", "favicon.ico"))
	if withData {
		// if with data, backup data files and uploaded files
		z.AddDir("data", path.Join(root, "data"))
		z.AddDir("static/upload", path.Join(root, "static", "upload"))
	}
	z.AddDir(app.View().Dir, path.Join(root, app.View().Dir))
	e = z.Flush()
	if e != nil {
		return "", e
	}
	println("backup success in " + filename)
	return filename, nil
}
开发者ID:flying99999,项目名称:GoBlog,代码行数:45,代码来源:backup.go


示例7: RemoveLogFile

func RemoveLogFile(app *GoInk.App, file string) {
	f := filepath.Join(app.Get("log_dir"), file)
	os.Remove(f)
}
开发者ID:carriercomm,项目名称:GoBlog,代码行数:4,代码来源:log.go



注:本文中的github.com/fuxiaohei/GoInk.App类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang GoInk.Context类代码示例发布时间:2022-05-23
下一篇:
Golang GoInk.Context类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap