當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Context.String方法代碼示例

本文整理匯總了Golang中github.com/fuxiaohei/GoInk.Context.String方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.String方法的具體用法?Golang Context.String怎麽用?Golang Context.String使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/fuxiaohei/GoInk.Context的用法示例。


在下文中一共展示了Context.String方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: CmdBackup

func CmdBackup(context *GoInk.Context) {
	if context.Method == "POST" {
		file, e := cmd.DoBackup(context.App(), true)
		if e != nil {
			Json(context, false).Set("msg", e.Error()).End()
			return
		}
		Json(context, true).Set("file", file).End()
		context.Do("bakcup_success", file)
		model.CreateMessage("backup", "[1]"+file)
		return
	}
	if context.Method == "DELETE" {
		file := context.String("file")
		if file == "" {
			Json(context, false).End()
			return
		}
		cmd.RemoveBackupFile(file)
		Json(context, true).End()
		context.Do("backup_delete", file)
		return
	}
	files, _ := cmd.GetBackupFiles()
	context.Layout("admin/cmd")
	context.Render("admin/cmd/backup", map[string]interface{}{
		"Files": files,
		"Title": "備份",
	})
}
開發者ID:carriercomm,項目名稱:GoBlog,代碼行數:30,代碼來源:cmd.go

示例2: AdminPlugin

func AdminPlugin(context *GoInk.Context) {
	if context.Method == "POST" {
		action := context.String("action")
		if action == "" {
			Json(context, false).End()
			return
		}
		pln := context.String("plugin")
		if action == "activate" {
			plugin.Activate(pln)
			plugin.Update(context.App())
			Json(context, true).End()
			context.Do("plugin_activated", pln)
			return
		}
		if action == "deactivate" {
			plugin.Deactivate(pln)
			Json(context, true).End()
			context.Do("plugin_deactivated", pln)
			return
		}
		context.Status = 405
		Json(context, false).End()
		return
	}
	context.Layout("admin/admin")
	context.Render("admin/plugin", map[string]interface{}{
		"Title":   "插件",
		"Plugins": plugin.GetPlugins(),
	})
}
開發者ID:carriercomm,項目名稱:GoBlog,代碼行數:31,代碼來源:admin.go

示例3: CmdLogs

func CmdLogs(context *GoInk.Context) {
	if context.Method == "DELETE" {
		cmd.RemoveLogFile(context.App(), context.String("file"))
		Json(context, true).End()
		return
	}
	context.Layout("admin/cmd")
	context.Render("admin/cmd/log", map[string]interface{}{
		"Title": "日誌",
		"Logs":  cmd.GetLogs(context.App()),
	})
}
開發者ID:carriercomm,項目名稱:GoBlog,代碼行數:12,代碼來源:cmd.go

示例4: CmdReader

func CmdReader(ctx *GoInk.Context) {
	if ctx.Method == "POST" {
		email := ctx.String("email")
		model.RemoveReader(email)
		Json(ctx, true).End()
		return
	}
	ctx.Layout("admin/cmd")
	ctx.Render("admin/cmd/reader", map[string]interface{}{
		"Title":   "讀者",
		"Readers": model.GetReaders(),
	})
}
開發者ID:carriercomm,項目名稱:GoBlog,代碼行數:13,代碼來源:cmd.go

示例5: AdminComments

func AdminComments(context *GoInk.Context) {
	if context.Method == "DELETE" {
		id := context.Int("id")
		cmt := model.GetCommentById(id)
		model.RemoveComment(cmt.Cid, id)
		Json(context, true).End()
		context.Do("comment_delete", id)
		return
	}
	if context.Method == "PUT" {
		id := context.Int("id")
		cmt2 := model.GetCommentById(id)
		cmt2.Status = "approved"
		cmt2.GetReader().Active = true
		model.SaveComment(cmt2)
		Json(context, true).End()
		context.Do("comment_change_status", cmt2)
		return
	}
	if context.Method == "POST" {
		// get required data
		pid := context.Int("pid")
		cid := model.GetCommentById(pid).Cid
		uid, _ := strconv.Atoi(context.Cookie("token-user"))
		user := model.GetUserById(uid)

		co := new(model.Comment)
		co.Author = user.Nick
		co.Email = user.Email
		co.Url = user.Url
		co.Content = context.String("content")
		co.Avatar = utils.Gravatar(co.Email, "50")
		co.Pid = pid
		co.Ip = context.Ip
		co.UserAgent = context.UserAgent
		co.IsAdmin = true
		model.CreateComment(cid, co)
		Json(context, true).Set("comment", co.ToJson()).End()
		model.CreateMessage("comment", co)
		context.Do("comment_reply", co)
		return
	}
	page := context.IntOr("page", 1)
	comments, pager := model.GetCommentList(page, 10)
	context.Layout("admin/admin")
	context.Render("admin/comments", map[string]interface{}{
		"Title":    "評論",
		"Comments": comments,
		"Pager":    pager,
	})
}
開發者ID:carriercomm,項目名稱:GoBlog,代碼行數:51,代碼來源:admin.go

示例6: AdminPassword

func AdminPassword(context *GoInk.Context) {
	if context.Method == "POST" {
		uid, _ := strconv.Atoi(context.Cookie("token-user"))
		user := model.GetUserById(uid)
		if !user.CheckPassword(context.String("old")) {
			Json(context, false).Set("msg", "舊密碼錯誤").End()
			return
		}
		user.ChangePassword(context.String("new"))
		go model.SyncUsers()
		Json(context, true).End()
		context.Do("password_update", user)
		return
	}
	context.Layout("admin/admin")
	context.Render("admin/password", map[string]interface{}{
		"Title": "修改密碼",
		//"User":user,
	})
}
開發者ID:carriercomm,項目名稱:GoBlog,代碼行數:20,代碼來源:admin.go

示例7: CmdTheme

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"),
	})
}
開發者ID:carriercomm,項目名稱:GoBlog,代碼行數:24,代碼來源:cmd.go

示例8: CmdBackupFile

func CmdBackupFile(context *GoInk.Context) {
	file := context.String("file")
	context.Download(cmd.GetBackupFileAbsPath(file))
	context.Do("backup_download", file)
}
開發者ID:carriercomm,項目名稱:GoBlog,代碼行數:5,代碼來源:cmd.go


注:本文中的github.com/fuxiaohei/GoInk.Context.String方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。