本文整理汇总了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)
}