mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
fix #55
This commit is contained in:
parent
6140e6ca1f
commit
aa31961892
2
assets/js/app.min.js
vendored
2
assets/js/app.min.js
vendored
File diff suppressed because one or more lines are too long
10
assets/js/plugins.min.js
vendored
10
assets/js/plugins.min.js
vendored
File diff suppressed because one or more lines are too long
@ -168,7 +168,7 @@ $(document).on('page:browse', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$.pjax({
|
$.pjax({
|
||||||
url: window.location.pathname.replace("browse", "edit") + filename,
|
url: data.Location,
|
||||||
container: '#content'
|
container: '#content'
|
||||||
})
|
})
|
||||||
}).fail(function(data) {
|
}).fail(function(data) {
|
||||||
|
@ -4,10 +4,12 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hacdias/caddy-hugo/config"
|
"github.com/hacdias/caddy-hugo/config"
|
||||||
@ -47,10 +49,9 @@ func POST(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error)
|
|||||||
filename := info["filename"].(string)
|
filename := info["filename"].(string)
|
||||||
filename = strings.TrimPrefix(filename, "/")
|
filename = strings.TrimPrefix(filename, "/")
|
||||||
filename = strings.TrimSuffix(filename, "/")
|
filename = strings.TrimSuffix(filename, "/")
|
||||||
|
url := "/admin/edit/" + r.URL.Path + filename
|
||||||
filename = c.Path + r.URL.Path + filename
|
filename = c.Path + r.URL.Path + filename
|
||||||
|
|
||||||
url := "/admin/edit/" + filename
|
|
||||||
|
|
||||||
if strings.HasPrefix(filename, c.Path+"content/") &&
|
if strings.HasPrefix(filename, c.Path+"content/") &&
|
||||||
(strings.HasSuffix(filename, ".md") || strings.HasSuffix(filename, ".markdown")) {
|
(strings.HasSuffix(filename, ".md") || strings.HasSuffix(filename, ".markdown")) {
|
||||||
|
|
||||||
@ -66,17 +67,27 @@ func POST(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error)
|
|||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wf, err := os.Create(filename)
|
var err error
|
||||||
|
|
||||||
|
if filepath.Ext(filename) == "" {
|
||||||
|
err = os.MkdirAll(filename, 0755)
|
||||||
|
url = strings.Replace(url, "edit", "browse", 1)
|
||||||
|
} else {
|
||||||
|
var wf *os.File
|
||||||
|
wf, err = os.Create(filename)
|
||||||
|
defer wf.Close()
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
|
|
||||||
defer wf.Close()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Location", url)
|
fmt.Println(url)
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.Write([]byte("{}"))
|
w.Write([]byte("{\"Location\": \"" + url + "\"}"))
|
||||||
return http.StatusOK, nil
|
return http.StatusOK, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user