Major changes on API

Former-commit-id: 096988e1e40835be12cdbfc685e58c3a6faf7d54 [formerly c687ad9725e93f7ee34bcef0193bafb6643feb62] [formerly cf70ea15f14f4f849a8f449438ffdb8ab5b60f6e [formerly 1f7974de38e624173d9418bddaacae53414b7db1]]
Former-commit-id: 85e35a88d9d46c2a6fe3598b902ad8ab86019c05 [formerly f38667fb170916541f62b14389b6296e8da2580e]
Former-commit-id: 5addfd36ad865a8644f659e5140453e1fdada62d
This commit is contained in:
Henrique Dias
2017-07-02 17:40:52 +01:00
parent d4a43db187
commit f6816c9a39
18 changed files with 470 additions and 638 deletions

22
file.go
View File

@@ -29,6 +29,8 @@ var (
// file contains the information about a particular file or directory.
type file struct {
// Indicates the Kind of view on the front-end (listing, editor or preview).
Kind string `json:"kind"`
// The name of the file.
Name string `json:"name"`
// The Size of the file.
@@ -79,15 +81,13 @@ type listing struct {
func getInfo(url *url.URL, c *FileManager, u *User) (*file, error) {
var err error
i := &file{URL: c.RootURL() + url.Path}
i.VirtualPath = url.Path
i.VirtualPath = strings.TrimPrefix(i.VirtualPath, "/")
i.VirtualPath = "/" + i.VirtualPath
i := &file{
URL: c.RootURL() + "/files" + url.Path,
VirtualPath: url.Path,
Path: filepath.Join(u.Scope, url.Path),
}
i.Path = u.scope + i.VirtualPath
i.Path = filepath.Clean(i.Path)
info, err := os.Stat(i.Path)
info, err := u.fileSystem.Stat(context.TODO(), i.Path)
if err != nil {
return i, err
}
@@ -103,8 +103,6 @@ func getInfo(url *url.URL, c *FileManager, u *User) (*file, error) {
// getListing gets the information about a specific directory and its files.
func (i *file) getListing(c *requestContext, r *http.Request) error {
baseURL := c.fm.RootURL() + r.URL.Path
// Gets the directory information using the Virtual File System of
// the user configuration.
f, err := c.us.fileSystem.OpenFile(context.TODO(), c.fi.VirtualPath, os.O_RDONLY, 0)
@@ -140,7 +138,7 @@ func (i *file) getListing(c *requestContext, r *http.Request) error {
}
// Absolute URL
url := url.URL{Path: baseURL + name}
url := url.URL{Path: i.URL + name}
i := file{
Name: f.Name(),
@@ -165,7 +163,7 @@ func (i *file) getListing(c *requestContext, r *http.Request) error {
}
// getEditor gets the editor based on a Info struct
func (i *file) getEditor(r *http.Request) error {
func (i *file) getEditor() error {
i.Language = editorLanguage(i.Extension)
// If the editor will hold only content, leave now.