Skip to content

Commit

Permalink
feat(release): release v0.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
cg33 committed Jul 29, 2020
1 parent 421f45b commit eb6ffb3
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 40 deletions.
15 changes: 6 additions & 9 deletions controller/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/GoAdminGroup/filemanager/modules/util"
"github.com/GoAdminGroup/go-admin/context"
"github.com/GoAdminGroup/go-admin/modules/config"
"github.com/GoAdminGroup/go-admin/modules/menu"
"github.com/GoAdminGroup/go-admin/plugins"
"github.com/GoAdminGroup/go-admin/plugins/admin/modules/paginator"
"github.com/GoAdminGroup/go-admin/plugins/admin/modules/parameter"
Expand All @@ -30,8 +29,7 @@ type Handler struct {
roots root.Roots
permissions permission.Permission

HTML func(ctx *context.Context, panel types.Panel, options ...plugins.HTMLOptions)
HTMLMenu func(ctx *context.Context, panel types.Panel, options ...plugins.HTMLOptions)
HTML func(ctx *context.Context, panel types.Panel, options ...plugins.HTMLOptions)
}

func NewHandler(root root.Roots, p permission.Permission) *Handler {
Expand Down Expand Up @@ -99,19 +97,18 @@ func (h *Handler) preview(ctx *context.Context, content template2.HTML, relative
GetContent(),
Title: language.GetHTML(h.roots.GetTitleFromPrefix(ctx)),
Description: fixedDescription(relativePath),
}, false, true)
}, plugins.HTMLOptions{
Animation: false,
NoCompress: true,
})
}

func fixedDescription(des string) template2.HTML {
return html.SpanEl().SetAttr("title", des).SetContent(template2.HTML(des)).Get()
}

func (h *Handler) table(ctx *context.Context, files models.Files, err error) {
h.HTML(ctx, h.tablePanel(ctx, files, err), false)
}

func (h *Handler) tableMenu(ctx *context.Context, menu *menu.Menu, files models.Files, err error) {
h.HTMLMenu(ctx, h.tablePanel(ctx, files, err), menu, false)
h.HTML(ctx, h.tablePanel(ctx, files, err))
}

func link(u string, c template2.HTML, pjax bool) template2.HTML {
Expand Down
2 changes: 1 addition & 1 deletion controller/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ func (h *Handler) ListFiles(ctx *context.Context) {
filesOfDir = append(filesOfDir, file)
}

h.tableMenu(ctx, filesOfDir, nil)
h.table(ctx, filesOfDir, nil)
return
}
38 changes: 22 additions & 16 deletions filemanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,14 @@ func (f *FileManager) IsInstalled() bool {
return len(f.roots) != 0
}

func (f *FileManager) GetIndexURL() string {
return config.Url("/fm")
}

func (f *FileManager) InitPlugin(srv service.List) {

// DO NOT DELETE
f.InitBase(srv)
f.InitBase(srv, "fm")

f.Conn = db.GetConnection(srv)

Expand Down Expand Up @@ -167,28 +171,30 @@ func (f *FileManager) InitPlugin(srv service.List) {
f.handler = controller.NewHandler(f.roots, p)
f.guard = guard.New(f.roots, f.Conn, p)
f.App = f.initRouter(srv)
f.handler.HTML = f.HTML
f.handler.HTMLMenu = f.HTMLMenu
f.handler.HTML = f.HTMLMenu

language.Lang[language.CN].Combine(language2.CN)
language.Lang[language.EN].Combine(language2.EN)

errors.Init()

f.SetInfo(info)
}

func (f *FileManager) GetInfo() plugins.Info {
return plugins.Info{
Website: "https://www.go-admin.cn",
Title: "FileManager",
Description: "A plugin help you manage files in your server",
Version: "v0.0.3",
Author: "Official",
Url: "https://github.com/GoAdminGroup/filemanager/archive/v0.0.3.zip",
Cover: "",
Agreement: "",
CreateDate: utils.ParseTime("2020-04-05"),
UpdateDate: utils.ParseTime("2020-07-29"),
}
var info = plugins.Info{
Website: "https://www.go-admin.cn",
Title: "FileManager",
Description: "A plugin help you manage files in your server",
Version: "v0.0.4",
Author: "Official",
Url: "https://github.com/GoAdminGroup/filemanager/archive/v0.0.4.zip",
Cover: "",
Agreement: "",
Uuid: "DDN7VxZDTHTeaF8HUU",
Name: "filemanager",
ModulePath: "github.com/GoAdminGroup/filemanager",
CreateDate: utils.ParseTime("2020-04-05"),
UpdateDate: utils.ParseTime("2020-07-29"),
}

type Table struct {
Expand Down
27 changes: 13 additions & 14 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,26 @@ package filemanager
import (
"github.com/GoAdminGroup/go-admin/context"
"github.com/GoAdminGroup/go-admin/modules/auth"
"github.com/GoAdminGroup/go-admin/modules/config"
"github.com/GoAdminGroup/go-admin/modules/service"
)

func (f *FileManager) initRouter(srv service.List) *context.App {

app := context.NewApp()
route := app.Group(config.GetUrlPrefix())
authRoute := route.Group("/", auth.Middleware(f.Conn))
authRoute := app.Group("/", auth.Middleware(f.Conn))

authRoute.GET("/fm", f.guard.Files, f.handler.ListFiles)
authRoute.GET("/fm/:__prefix/download", f.handler.Download)
authRoute.POST("/fm/:__prefix/upload", f.guard.Upload, f.handler.Upload)
authRoute.POST("/fm/:__prefix/create/dir/popup", f.handler.CreateDirPopUp)
authRoute.POST("/fm/:__prefix/create/dir", f.guard.CreateDir, f.handler.CreateDir)
authRoute.POST("/fm/:__prefix/delete", f.guard.Delete, f.handler.Delete)
authRoute.POST("/fm/:__prefix/move/popup", f.handler.MovePopup)
authRoute.POST("/fm/:__prefix/move", f.guard.Move, f.handler.Move)
authRoute.GET("/fm/:__prefix/preview", f.guard.Preview, f.handler.Preview)
authRoute.POST("/fm/:__prefix/rename/popup", f.handler.RenamePopUp)
authRoute.POST("/fm/:__prefix/rename", f.guard.Rename, f.handler.Rename)
authRoute.GET("/", f.guard.Files, f.handler.ListFiles)
authRoute.GET("/:__prefix/list", f.guard.Files, f.handler.ListFiles)
authRoute.GET("/:__prefix/download", f.handler.Download)
authRoute.POST("/:__prefix/upload", f.guard.Upload, f.handler.Upload)
authRoute.POST("/:__prefix/create/dir/popup", f.handler.CreateDirPopUp)
authRoute.POST("/:__prefix/create/dir", f.guard.CreateDir, f.handler.CreateDir)
authRoute.POST("/:__prefix/delete", f.guard.Delete, f.handler.Delete)
authRoute.POST("/:__prefix/move/popup", f.handler.MovePopup)
authRoute.POST("/:__prefix/move", f.guard.Move, f.handler.Move)
authRoute.GET("/:__prefix/preview", f.guard.Preview, f.handler.Preview)
authRoute.POST("/:__prefix/rename/popup", f.handler.RenamePopUp)
authRoute.POST("/:__prefix/rename", f.guard.Rename, f.handler.Rename)

return app
}

0 comments on commit eb6ffb3

Please sign in to comment.