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 }
func SetThemeCache(ctx *GoInk.Context, cache bool) { ctx.App().View().NoCache() ctx.App().View().IsCache = cache if cache { model.SetSetting("theme_cache", "true") } else { model.SetSetting("theme_cache", "false") } model.SyncSettings() }
func upgrade_20140228(_ *GoInk.App) bool { // change settings model.LoadSettings() model.SetSetting("popular_size", "4") model.SetSetting("recent_comment_size", "3") model.SetSetting("theme_cache", "false") model.SyncSettings() // overwrite zip bundle bytes cmd.ExtractBundleBytes() return true }
func CustomSetting(context *GoInk.Context) { keys := context.Strings("key") values := context.Strings("value") for i, k := range keys { if len(k) < 1 { continue } model.SetSetting("c_"+k, values[i]) } model.SyncSettings() Json(context, true).End() context.Do("setting_saved") return }
func AdminSetting(context *GoInk.Context) { if context.Method == "POST" { data := context.Input() for k, v := range data { model.SetSetting(k, v) } model.SyncSettings() Json(context, true).End() return } context.Layout("admin") context.Render("admin/setting", map[string]interface{}{ "Title": "配置", }) }
func CustomSetting(context *GoInk.Context) { if context.Method == "POST" { keys := context.Strings("key") values := context.Strings("value") for i, k := range keys { model.SetSetting("c_"+k, values[i]) } model.SyncSettings() Json(context, true).End() return } context.Layout("admin") context.Render("admin/custom_setting", map[string]interface{}{ "Title": "自定义配置", "Settings": model.GetCustomSettings(), }) }
func AdminSetting(context *GoInk.Context) { if context.Method == "POST" { data := context.Input() for k, v := range data { if v == "" { if data[k+"_def"] != "" { v = data[k+"_def"] } } model.SetSetting(k, v) } model.SyncSettings() Json(context, true).End() context.Do("setting_saved") return } context.Layout("admin/admin") context.Render("admin/setting", map[string]interface{}{ "Title": "配置", "Custom": model.GetCustomSettings(), "Navigators": model.GetNavigators(), }) }
func CmdTheme(ctx *GoInk.Context) { if ctx.Method == "POST" { change := ctx.String("cache") if change != "" { cmd.SetThemeCache(ctx, change == "true") Json(ctx, true).End() return } theme := ctx.String("theme") if theme != "" { model.SetSetting("site_theme", theme) model.SyncSettings() Json(ctx, true).End() return } return } ctx.Layout("admin/cmd") ctx.Render("admin/cmd/theme", map[string]interface{}{ "Title": "主题", "Themes": cmd.GetThemes(ctx.App().Get("view_dir")), "CurrentTheme": model.GetSetting("site_theme"), }) }