Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
PUBLIC
/
surfer-okd
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit f66b47bd
authored
Apr 07, 2017
by
Johannes Zellner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add file download button
1 parent
789485e5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
1 deletions
frontend/index.html
frontend/js/app.js
src/files.js
frontend/index.html
View file @
f66b47b
...
...
@@ -183,6 +183,7 @@
<th><span
v-my-tooltip=
"foobar"
data-toggle=
"tooltip"
title=
"{{ entry.mtime }}"
>
{{ entry.mtime | prettyDate }}
</span></th>
<th
style=
"text-align: right;"
>
<span
class=
"entry-toolbar"
>
<button
class=
"btn btn-sm btn-default"
v-on:click
.
stop=
"download(entry)"
title=
"Download"
v-show=
"entry.isFile"
><i
class=
"fa fa-download"
></i></button>
<button
class=
"btn btn-sm btn-default"
v-on:click
.
stop=
"renameAsk(entry)"
title=
"Rename"
><i
class=
"fa fa-pencil"
></i></button>
<button
class=
"btn btn-sm btn-danger"
v-on:click
.
stop=
"delAsk(entry)"
title=
"Delete"
><i
class=
"fa fa-trash"
></i></button>
</span>
...
...
frontend/js/app.js
View file @
f66b47b
...
...
@@ -135,6 +135,12 @@ function open(entry) {
window
.
open
(
encode
(
path
));
}
function
download
(
entry
)
{
if
(
entry
.
isDirectory
)
return
;
window
.
open
(
encode
(
'/api/files/'
+
sanitize
(
app
.
path
+
'/'
+
entry
.
filePath
))
+
'?access_token='
+
localStorage
.
accessToken
);
}
function
up
()
{
window
.
location
.
hash
=
sanitize
(
app
.
path
.
split
(
'/'
).
slice
(
0
,
-
1
).
filter
(
function
(
p
)
{
return
!!
p
;
}).
join
(
'/'
));
}
...
...
@@ -329,6 +335,7 @@ var app = new Vue({
logout
:
logout
,
loadDirectory
:
loadDirectory
,
open
:
open
,
download
:
download
,
up
:
up
,
upload
:
upload
,
delAsk
:
delAsk
,
...
...
src/files.js
View file @
f66b47b
...
...
@@ -88,7 +88,7 @@ function get(req, res, next) {
debug
(
'get'
,
absoluteFilePath
);
if
(
!
result
.
isDirectory
()
&&
!
result
.
isFile
())
return
next
(
new
HttpError
(
500
,
'unsupported type'
));
if
(
result
.
isFile
())
return
res
.
sendFile
(
absoluteFilePath
);
if
(
result
.
isFile
())
return
res
.
download
(
absoluteFilePath
);
async
.
map
(
fs
.
readdirSync
(
absoluteFilePath
),
function
(
filePath
,
callback
)
{
fs
.
stat
(
path
.
join
(
absoluteFilePath
,
filePath
),
function
(
error
,
result
)
{
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment