mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-10-29 09:07:30 +08:00
maintenance (cleanup): remove dead code
This commit is contained in:
@ -13,27 +13,8 @@ import (
|
|||||||
var (
|
var (
|
||||||
logpath = filepath.Join(GetCurrentDir(), LOG_PATH, "access.log")
|
logpath = filepath.Join(GetCurrentDir(), LOG_PATH, "access.log")
|
||||||
configpath = filepath.Join(GetCurrentDir(), CONFIG_PATH, "config.json")
|
configpath = filepath.Join(GetCurrentDir(), CONFIG_PATH, "config.json")
|
||||||
pluginpath = filepath.Join(GetCurrentDir(), PLUGIN_PATH)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func FetchPluginsHandler(ctx App, res http.ResponseWriter, req *http.Request) {
|
|
||||||
f, err := os.OpenFile(pluginpath, os.O_RDONLY, os.ModePerm)
|
|
||||||
if err != nil {
|
|
||||||
SendErrorResult(res, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
files, err := f.Readdir(0)
|
|
||||||
if err != nil {
|
|
||||||
SendErrorResult(res, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
plugins := make([]string, 0)
|
|
||||||
for i := 0; i < len(files); i++ {
|
|
||||||
plugins = append(plugins, files[i].Name())
|
|
||||||
}
|
|
||||||
SendSuccessResults(res, plugins)
|
|
||||||
}
|
|
||||||
|
|
||||||
func FetchLogHandler(ctx App, res http.ResponseWriter, req *http.Request) {
|
func FetchLogHandler(ctx App, res http.ResponseWriter, req *http.Request) {
|
||||||
file, err := os.OpenFile(logpath, os.O_RDONLY, os.ModePerm)
|
file, err := os.OpenFile(logpath, os.O_RDONLY, os.ModePerm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -75,42 +75,17 @@ func AboutHandler(ctx App, res http.ResponseWriter, req *http.Request) {
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1> {{index .App 0}} <br><span>({{index .App 1}})</span> </h1>
|
<h1> {{index .App 0}} <br><span>({{index .App 1}} - {{index .App 2}})</span> </h1>
|
||||||
<p>{{range .Plugins}}
|
|
||||||
{{ index . 0 }} <span>({{ index . 1 }})</span> <br>{{end}}
|
|
||||||
</p>
|
|
||||||
</body>
|
</body>
|
||||||
</html>`
|
</html>`
|
||||||
t, _ := template.New("about").Parse(page)
|
t, _ := template.New("about").Parse(page)
|
||||||
t.Execute(res, struct {
|
t.Execute(res, struct {
|
||||||
App []string
|
App []string
|
||||||
Plugins [][]string
|
}{ []string{
|
||||||
}{
|
"Filestash " + APP_VERSION + "." + BUILD_NUMBER,
|
||||||
App: []string{"Filestash " + APP_VERSION + "." + BUILD_NUMBER, hashFile(filepath.Join(GetCurrentDir(), "/filestash"), 6)},
|
hashFile(filepath.Join(GetCurrentDir(), "/filestash"), 6),
|
||||||
Plugins: func () [][]string {
|
hashFile(filepath.Join(GetCurrentDir(), CONFIG_PATH, "config.json"), 6),
|
||||||
plugins := make([][]string, 1)
|
}})
|
||||||
plugins[0] = []string {
|
|
||||||
"config.json",
|
|
||||||
hashFile(filepath.Join(GetCurrentDir(), CONFIG_PATH, "config.json"), 6),
|
|
||||||
}
|
|
||||||
pPath := filepath.Join(GetCurrentDir(), PLUGIN_PATH)
|
|
||||||
file, err := os.Open(pPath);
|
|
||||||
if err != nil {
|
|
||||||
return plugins
|
|
||||||
}
|
|
||||||
files, err := file.Readdir(0);
|
|
||||||
if err != nil {
|
|
||||||
return plugins
|
|
||||||
}
|
|
||||||
for i:=0; i < len(files); i++ {
|
|
||||||
plugins = append(plugins, []string{
|
|
||||||
files[i].Name(),
|
|
||||||
hashFile(pPath + "/" + files[i].Name(), 6),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return plugins
|
|
||||||
}(),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func hashFile (path string, n int) string {
|
func hashFile (path string, n int) string {
|
||||||
|
|||||||
@ -46,7 +46,6 @@ func Init(a *App) {
|
|||||||
admin.HandleFunc("/session", NewMiddlewareChain(AdminSessionGet, middlewares, *a)).Methods("GET")
|
admin.HandleFunc("/session", NewMiddlewareChain(AdminSessionGet, middlewares, *a)).Methods("GET")
|
||||||
admin.HandleFunc("/session", NewMiddlewareChain(AdminSessionAuthenticate, middlewares, *a)).Methods("POST")
|
admin.HandleFunc("/session", NewMiddlewareChain(AdminSessionAuthenticate, middlewares, *a)).Methods("POST")
|
||||||
middlewares = []Middleware{ ApiHeaders, AdminOnly, SecureAjax }
|
middlewares = []Middleware{ ApiHeaders, AdminOnly, SecureAjax }
|
||||||
admin.HandleFunc("/plugin", NewMiddlewareChain(FetchPluginsHandler, middlewares, *a)).Methods("GET")
|
|
||||||
admin.HandleFunc("/config", NewMiddlewareChain(PrivateConfigHandler, middlewares, *a)).Methods("GET")
|
admin.HandleFunc("/config", NewMiddlewareChain(PrivateConfigHandler, middlewares, *a)).Methods("GET")
|
||||||
admin.HandleFunc("/config", NewMiddlewareChain(PrivateConfigUpdateHandler, middlewares, *a)).Methods("POST")
|
admin.HandleFunc("/config", NewMiddlewareChain(PrivateConfigUpdateHandler, middlewares, *a)).Methods("POST")
|
||||||
middlewares = []Middleware{ IndexHeaders }
|
middlewares = []Middleware{ IndexHeaders }
|
||||||
|
|||||||
Reference in New Issue
Block a user