Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
3pia
VISPA
VISPA web
Commits
e2c76244
Commit
e2c76244
authored
Mar 20, 2013
by
murban
Browse files
Updates in filesystem: get_file_list now returns an object and removal of some expandvars / ..user
parent
ae7c93da
Changes
11
Hide whitespace changes
Inline
Side-by-side
vispa/controller/filesystem.py
View file @
e2c76244
...
...
@@ -86,6 +86,7 @@ class FSAjaxController(AbstractController):
# get the files with the filter
files
=
fs
.
get_file_list
(
path
,
deep
=
deep
,
filter
=
filter
,
reverse
=
reverse
)
rjson
=
vispa
.
rpc
.
get
(
cherrypy
.
request
.
user
,
cherrypy
.
request
.
workspace
).
getmodule
(
"json"
)
cherrypy
.
response
.
headers
[
'Content-Type'
]
=
"application/json"
return
rjson
.
dumps
(
files
)
...
...
vispa/extensions/filebrowser/extension.py
View file @
e2c76244
...
...
@@ -22,7 +22,6 @@ class FileBrowserExtension(AbstractExtension):
self
.
js
(
platform
,
'js/extension.js'
)
self
.
js
(
platform
,
'js/browser.js'
)
self
.
js
(
platform
,
'js/view.js'
)
self
.
js
(
platform
,
'js/ajax.js'
)
self
.
js
(
platform
,
'js/actions.js'
)
self
.
css
(
platform
,
'css/styles.css'
)
self
.
remote
()
\ No newline at end of file
vispa/extensions/filebrowser/static/js/actions.js
View file @
e2c76244
...
...
@@ -29,4 +29,5 @@ var FileBrowserActions = FileBaseActions.extend({
url
=
encodeURI
(
url
.
slice
(
0
,
url
.
lastIndexOf
(
"
=
"
))
+
"
=
"
+
data
.
path
);
$
.
Helpers
.
changeUrl
(
url
);
}
});
\ No newline at end of file
});
vispa/extensions/filebrowser/static/js/ajax.js
deleted
100644 → 0
View file @
ae7c93da
var
FileBrowserAjaxHandler
=
FileBaseAjaxHandler
.
extend
({
init
:
function
(
owner
)
{
this
.
_super
(
owner
);
}
});
\ No newline at end of file
vispa/extensions/filebrowser/static/js/browser.js
View file @
e2c76244
...
...
@@ -9,7 +9,6 @@ var FileBrowser = FileBase.extend({
this
.
instance
=
instance
;
this
.
view
=
new
FileBrowserView
(
this
);
this
.
ajax
=
new
FileBrowserAjaxHandler
(
this
);
this
.
actions
=
new
FileBrowserActions
(
this
);
// variables that may change in this workflow
...
...
vispa/remote/filesystem.py
View file @
e2c76244
...
...
@@ -70,7 +70,8 @@ class FileSystem(object):
def
get_file_list
(
self
,
path
,
deep
=
False
,
filter
=
[],
reverse
=
False
,
hide_hidden
=
True
):
filelist
=
[]
for
elem
in
os
.
listdir
(
os
.
path
.
expanduser
(
os
.
path
.
expandvars
(
path
))):
path_expand
=
os
.
path
.
expanduser
(
os
.
path
.
expandvars
(
path
))
for
elem
in
os
.
listdir
(
path_expand
):
# hide hidden files?
if
elem
.
startswith
(
'.'
)
and
hide_hidden
:
continue
...
...
@@ -83,22 +84,26 @@ class FileSystem(object):
if
match
!=
reverse
:
continue
fullpath
=
os
.
path
.
join
(
path
,
elem
)
fullpath
=
os
.
path
.
join
(
path
_expand
,
elem
)
# get locales, mtime, etc
locale
.
setlocale
(
locale
.
LC_ALL
,
''
)
stats
=
os
.
stat
(
os
.
path
.
expand
user
(
os
.
path
.
expandvars
(
fullpath
))
)
stats
=
os
.
stat
(
path
_
expand
)
size
=
locale
.
format
(
'%d'
,
stats
.
st_size
,
grouping
=
True
)
mtime
=
datetime
.
fromtimestamp
(
stats
.
st_mtime
).
strftime
(
'%Y-%m-%d %H:%M:%S'
)
if
os
.
path
.
isdir
(
os
.
path
.
expanduser
(
os
.
path
.
expandvars
(
fullpath
)
))
:
if
os
.
path
.
isdir
(
fullpath
):
filelist
.
append
({
'name'
:
elem
,
'type'
:
'd'
,
'parent'
:
path
,
'extension'
:
''
,
'mtime'
:
mtime
,
'size'
:
size
,
'path'
:
fullpath
})
if
deep
:
filelist
.
extend
(
self
.
get_file_list
(
fullpath
,
deep
,
filter
,
reverse
))
else
:
extension
=
elem
.
split
(
'.'
)[
-
1
]
filelist
.
append
({
'name'
:
elem
,
'type'
:
'f'
,
'parent'
:
path
,
'extension'
:
extension
,
'mtime'
:
mtime
,
'size'
:
size
,
'path'
:
fullpath
})
return
filelist
# Determine the parent
parentpath
=
path_expand
[:
-
1
]
if
path_expand
.
endswith
(
os
.
sep
)
and
path_expand
!=
os
.
sep
else
path_expand
parentpath
=
os
.
path
.
dirname
(
path_expand
)
return
{
'filelist'
:
filelist
,
'parentpath'
:
parentpath
}
def
get_suggestions
(
self
,
path
,
length
=
1
,
append_hidden
=
True
):
suggestions
=
[]
...
...
vispa/static/js/base/file/filebase/ajax.js
deleted
100644 → 0
View file @
ae7c93da
var
FileBaseAjaxHandler
=
Class
.
extend
({
init
:
function
(
owner
)
{
this
.
owner
=
owner
;
},
exists
:
function
(
path
)
{
var
exists
=
false
;
var
promise
=
$
.
ajax
({
type
:
'
POST
'
,
async
:
false
,
url
:
this
.
owner
.
urlFormatter
(
'
ajax/fs/exists
'
),
data
:
{
path
:
path
}
});
$
.
when
(
promise
).
then
(
function
(
response
)
{
if
(
response
.
success
)
{
exists
=
true
;
}
else
{
// TODO
}
});
return
exists
;
},
fileList
:
function
(
path
)
{
var
list
=
[];
var
promise
=
$
.
ajax
({
type
:
'
POST
'
,
async
:
false
,
url
:
this
.
owner
.
urlFormatter
(
'
ajax/fs/filelist
'
),
data
:
{
path
:
path
}
});
$
.
when
(
promise
).
then
(
function
(
response
)
{
if
(
response
.
success
)
{
list
=
response
.
files
;
}
else
{
// TODO
}
});
return
list
;
},
folderup
:
function
(
path
)
{
var
folderup_path
=
""
;
var
promise
=
$
.
ajax
({
type
:
'
POST
'
,
async
:
false
,
url
:
this
.
owner
.
urlFormatter
(
'
ajax/fs/folderup
'
),
data
:
{
path
:
path
}
});
$
.
when
(
promise
).
then
(
function
(
response
)
{
if
(
response
.
success
)
{
folderup_path
=
response
.
folderuppath
;
}
else
{
console
.
log
(
"
Error in AJAX
"
);
}
});
return
folderup_path
;
}
});
\ No newline at end of file
vispa/static/js/base/file/filebase/base.js
View file @
e2c76244
...
...
@@ -3,7 +3,7 @@ var FileBase = Class.extend({
init
:
function
(
path
,
urlFormatter
)
{
// components
this
.
view
=
new
FileBaseView
(
this
);
this
.
ajax
=
new
FileBaseAjaxHandler
(
this
);
//
this.ajax = new FileBaseAjaxHandler(this);
this
.
events
=
new
FileBaseEvents
(
this
);
this
.
actions
=
new
FileBaseActions
(
this
);
...
...
vispa/static/js/base/file/filebase/views/symbol/view.js
View file @
e2c76244
...
...
@@ -34,7 +34,7 @@ var Symbolview = Class.extend({
//empty the existing container
_this
.
owner
.
view
.
mainContainer
.
html
(
""
);
var
folderupPath
=
_this
.
owner
.
ajax
.
folderup
(
_this
.
owner
.
workflow
.
path
)
;
var
folderupPath
=
data
.
parent
path
;
var
folderupData
=
{
"
extension
"
:
""
,
"
mtime
"
:
""
,
...
...
@@ -47,8 +47,7 @@ var Symbolview = Class.extend({
var
folderup
=
_this
.
makeIcon
(
folderupData
);
_this
.
owner
.
view
.
mainContainer
.
append
(
folderup
);
$
.
each
(
data
,
function
(
i
,
file
)
{
// console.log(file)
$
.
each
(
data
.
filelist
,
function
(
i
,
file
)
{
var
contentdiv
=
_this
.
makeIcon
(
file
);
// owner.view.mainContainer.isotope('insert', contentdiv);
...
...
vispa/static/js/base/file/fileselector/fileselector.js
0 → 100644
View file @
e2c76244
var
FileSelector
=
FileBase
.
extend
({
init
:
function
(
instance
,
path
)
{
// use urlHandler.dynamic as urlFormatter
var
formatter
=
function
(
path
)
{
return
instance
.
_vispa
.
urlHandler
.
dynamic
(
path
);
}
this
.
_super
(
path
,
formatter
);
}
})
\ No newline at end of file
vispa/templates/html/sites/index.html
View file @
e2c76244
...
...
@@ -73,7 +73,6 @@
"
helpers.js
",
"
file
/
filebase
/
base.js
",
"
file
/
filebase
/
view.js
",
"
file
/
filebase
/
ajax.js
",
"
file
/
filebase
/
events.js
",
"
file
/
filebase
/
actions.js
",
"
file
/
filebase
/
views
/
symbol
/
view.js
",
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment