本文整理匯總了Golang中github.com/protosam/vision.New.GAssign方法的典型用法代碼示例。如果您正苦於以下問題:Golang New.GAssign方法的具體用法?Golang New.GAssign怎麽用?Golang New.GAssign使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/protosam/vision.New
的用法示例。
在下文中一共展示了New.GAssign方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: filemanager
func filemanager(ctx *macaron.Context) string {
hcuser, auth := util.Auth(ctx, "any")
if !auth {
ctx.Redirect("/", 302)
return ""
}
var tpl vision.New
tpl.TemplateFile("template/filemanager.tpl")
suser, err := user.Lookup(hcuser.System_username)
if err != nil {
return die(ctx, string(err.Error()))
}
uid, err := strconv.Atoi(suser.Uid)
if err != nil {
return die(ctx, string(err.Error()))
}
gid, err := strconv.Atoi(suser.Gid)
if err != nil {
return die(ctx, string(err.Error()))
}
selected_object := path.Clean(util.Query(ctx, "path"))
full_object := path.Clean(suser.HomeDir + "/" + selected_object)
// check ownership...
if !util.ChkPerms(full_object, uid, gid) {
return die(ctx, "You do not have access to object "+full_object)
}
delete_objectin := util.Query(ctx, "delete")
delete_object := path.Clean(util.Query(ctx, "delete"))
delete_object = path.Clean(suser.HomeDir + "/" + delete_object)
if delete_objectin != "" {
os.RemoveAll(delete_object)
}
newdirin := util.Query(ctx, "dirname")
newdir := path.Clean(util.Query(ctx, "dirname"))
newdir = path.Clean(full_object + "/" + newdir)
newfilein := util.Query(ctx, "filename")
newfile := path.Clean(util.Query(ctx, "filename"))
newfile = path.Clean(full_object + "/" + newfile)
if newdirin != "" {
os.Mkdir(newdir, 0755)
os.Chown(newdir, uid, gid)
}
if newfilein != "" {
f, _ := os.Create(newfile)
f.Close()
os.Chown(newfile, uid, gid)
os.Chmod(newfile, 0644)
}
tpl.GAssign("path_up", path.Dir(selected_object))
tpl.GAssign("current_path", full_object)
tpl.GAssign("selected_path", selected_object)
objects, err := ioutil.ReadDir(full_object)
if err != nil {
return die(ctx, string(err.Error()))
}
tpl.Parse("filemanager")
for _, file := range objects {
tpl.Assign("filename", file.Name())
mode := string(fmt.Sprintf("%s", file.Mode()))
tpl.Assign("mode", mode)
if file.IsDir() {
tpl.Parse("filemanager/directory")
} else {
tpl.Parse("filemanager/file")
}
}
return header(ctx) + tpl.Out() + footer(ctx)
}