diff --git a/_assets/_old/js/listing.js b/_assets/_old/js/listing.js
index 04e3c562..ebb7de44 100644
--- a/_assets/_old/js/listing.js
+++ b/_assets/_old/js/listing.js
@@ -17,20 +17,6 @@ listing.redefineDownloadURLs = function () {
})
}
-listing.newFileButton = function (event) {
- event.preventDefault()
-
- let clone = document.importNode(templates.question.content, true)
- clone.querySelector('h3').innerHTML = 'New file'
- clone.querySelector('p').innerHTML = 'End with a trailing slash to create a dir.'
- clone.querySelector('.ok').innerHTML = 'Create'
- clone.querySelector('form').addEventListener('submit', listing.newFilePrompt)
-
- document.querySelector('body').appendChild(clone)
- document.querySelector('.overlay').classList.add('active')
- document.querySelector('.prompt').classList.add('active')
-}
-
listing.newFilePrompt = function (event) {
event.preventDefault()
buttons.setLoading('new')
diff --git a/_assets/index.html b/_assets/index.html
index 6951984a..6b19b129 100644
--- a/_assets/index.html
+++ b/_assets/index.html
@@ -1,154 +1,127 @@
-
-
-
-
- File Manager
-
-
-
-
-
-
+
+
+
+
+ File Manager
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
- <% for (var chunk of webpack.chunks) {
+ <% for (var chunk of webpack.chunks) {
for (var file of chunk.files) {
- if (file.match(/\.(js|css)$/)) { %>
- <% }}} %>
+ if (file.match(/\.(js|css)$/)) { %>
+ <% }}} %>
-
- #loading.done {
- -webkit-animation: 1s out forwards;
- animation: 1s out forwards;
- }
-
- @-webkit-keyframes out {
- 0% {
- display: block;
- opacity: 1;
- }
- 99% {
- opacity: 0;
- display: block;
- }
- 100% {
- opacity: 0;
- display: none;
- }
- }
-
- @keyframes out {
- 0% {
- display: block;
- opacity: 1;
- }
- 99% {
- opacity: 0;
- display: block;
- }
- 100% {
- opacity: 0;
- display: none;
- }
- }
-
- .spinner {
- width: 70px;
- text-align: center;
- position: fixed;
- top: 50%;
- left: 50%;
- -webkit-transform: translate(-50%, -50%);
- transform: translate(-50%, -50%);
- }
-
- .spinner > div {
- width: 18px;
- height: 18px;
- background-color: #333;
- border-radius: 100%;
- display: inline-block;
- -webkit-animation: sk-bouncedelay 1.4s infinite ease-in-out both;
- animation: sk-bouncedelay 1.4s infinite ease-in-out both;
- }
-
- .spinner .bounce1 {
- -webkit-animation-delay: -0.32s;
- animation-delay: -0.32s;
- }
-
- .spinner .bounce2 {
- -webkit-animation-delay: -0.16s;
- animation-delay: -0.16s;
- }
-
- @-webkit-keyframes sk-bouncedelay {
- 0%, 80%, 100% { -webkit-transform: scale(0) }
- 40% { -webkit-transform: scale(1.0) }
- }
-
- @keyframes sk-bouncedelay {
- 0%, 80%, 100% {
- -webkit-transform: scale(0);
- transform: scale(0);
- } 40% {
- -webkit-transform: scale(1.0);
- transform: scale(1.0);
- }
- }
-
-
- {{- if ne .User.StyleSheet "" -}}
-
- {{- end -}}
-
+ {{- if ne .User.StyleSheet "" -}}
+
+ {{- end -}}
+
-
-
-
+
-<%= htmlWebpackPlugin.options.serviceWorkerLoader %>
+ <%= htmlWebpackPlugin.options.serviceWorkerLoader %>
diff --git a/_assets/src/App.vue b/_assets/src/App.vue
index 0a5b821a..8794ba3e 100644
--- a/_assets/src/App.vue
+++ b/_assets/src/App.vue
@@ -28,10 +28,11 @@
+
-
-
+
+
@@ -60,6 +61,8 @@ import DownloadButton from './components/DownloadButton'
import SwitchButton from './components/SwitchViewButton'
import MoveButton from './components/MoveButton'
import MovePrompt from './components/MovePrompt'
+import NewFilePrompt from './components/NewFilePrompt'
+import NewDirPrompt from './components/NewDirPrompt'
import css from './css.js'
var $ = window.info
@@ -68,6 +71,8 @@ function updateColumnSizes () {
let columns = Math.floor(document.querySelector('main').offsetWidth / 300)
let items = css(['#listing.mosaic .item', '.mosaic#listing .item'])
+ if (columns === 0) columns = 1
+
items.style.width = `calc(${100 / columns}% - 1em)`
}
@@ -77,9 +82,35 @@ function resetPrompts () {
$.showDelete = false
$.showRename = false
$.showMove = false
+ $.showNewFile = false
+ $.showNewDir = false
}
-window.addEventListener('keydown', (event) => {
+function showRenameButton () {
+ if ($.req.kind === 'listing') {
+ if ($.selected.length === 1) {
+ return $.user.allowEdit
+ }
+
+ return false
+ }
+
+ return $.user.allowEdit
+}
+
+function showDeleteButton () {
+ if ($.req.kind === 'listing') {
+ if ($.selected.length === 0) {
+ return false
+ }
+
+ return $.user.allowEdit
+ }
+
+ return $.user.allowEdit
+}
+
+function keydown (event) {
// Esc!
if (event.keyCode === 27) {
resetPrompts()
@@ -99,7 +130,9 @@ window.addEventListener('keydown', (event) => {
// Del!
if (event.keyCode === 46) {
- $.showDelete = true
+ if (showDeleteButton()) {
+ $.showDelete = true
+ }
}
// F1!
@@ -110,7 +143,9 @@ window.addEventListener('keydown', (event) => {
// F2!
if (event.keyCode === 113) {
- $.showRename = true
+ if (showRenameButton()) {
+ $.showRename = true
+ }
}
// CTRL + S
@@ -127,7 +162,25 @@ window.addEventListener('keydown', (event) => {
// TODO: save file on editor!
}
}
-})
+}
+
+function startup () {
+ updateColumnSizes()
+ window.addEventListener('resize', updateColumnSizes)
+ window.history.replaceState({
+ url: window.location.pathname,
+ name: document.title
+ }, document.title, window.location.pathname)
+
+ window.addEventListener('keydown', keydown)
+
+ let loading = document.getElementById('loading')
+ loading.classList.add('done')
+
+ setTimeout(function () {
+ loading.parentNode.removeChild(loading)
+ }, 1000)
+}
export default {
name: 'app',
@@ -146,51 +199,32 @@ export default {
UploadButton,
SwitchButton,
MoveButton,
- MovePrompt
+ MovePrompt,
+ NewFilePrompt,
+ NewDirPrompt
},
mounted: function () {
- updateColumnSizes()
- window.addEventListener('resize', updateColumnSizes)
- window.history.replaceState({
- url: window.location.pathname,
- name: document.title
- }, document.title, window.location.pathname)
-
- document.getElementById('loading').classList.add('done')
+ startup()
},
data: function () {
return window.info
},
methods: {
showOverlay: function () {
- return this.showInfo || this.showHelp || this.showDelete || this.showRename || this.showMove
+ return $.showInfo ||
+ $.showHelp ||
+ $.showDelete ||
+ $.showRename ||
+ $.showMove ||
+ $.showNewFile ||
+ $.showNewDir
},
showUpload: function () {
if (this.req.kind === 'editor') return false
return $.user.allowNew
},
- showDeleteButton: function () {
- if (this.req.kind === 'listing') {
- if (this.selected.length === 0) {
- return false
- }
-
- return $.user.allowEdit
- }
-
- return $.user.allowEdit
- },
- showRenameButton: function () {
- if (this.req.kind === 'listing') {
- if (this.selected.length === 1) {
- return $.user.allowEdit
- }
-
- return false
- }
-
- return $.user.allowEdit
- },
+ showDeleteButton: showDeleteButton,
+ showRenameButton: showRenameButton,
showMoveButton: function () {
if (this.req.kind !== 'listing') {
return false
diff --git a/_assets/src/components/NewDirPrompt.vue b/_assets/src/components/NewDirPrompt.vue
new file mode 100644
index 00000000..acf23e24
--- /dev/null
+++ b/_assets/src/components/NewDirPrompt.vue
@@ -0,0 +1,53 @@
+
+
+
New directory
+
Write the name of the new directory.
+
+
+
+
+
+
+
+
+
+
diff --git a/_assets/src/components/NewFilePrompt.vue b/_assets/src/components/NewFilePrompt.vue
new file mode 100644
index 00000000..173dd738
--- /dev/null
+++ b/_assets/src/components/NewFilePrompt.vue
@@ -0,0 +1,50 @@
+
+
+
New file
+
Write the name of the new file.
+
+
+
+
+
+
+
+
+
+
diff --git a/_assets/src/components/Search.vue b/_assets/src/components/Search.vue
index d6a0ff2f..9fd17783 100644
--- a/_assets/src/components/Search.vue
+++ b/_assets/src/components/Search.vue
@@ -123,7 +123,6 @@ export default {
conn.onclose = () => {
this.$el.classList.remove('ongoing')
- page.reload()
}
}
}
diff --git a/_assets/src/css/styles.css b/_assets/src/css/styles.css
index 3cba1d1e..efcad9a5 100644
--- a/_assets/src/css/styles.css
+++ b/_assets/src/css/styles.css
@@ -379,11 +379,10 @@ fieldset h3,
main {
width: 78%;
margin-left: 20%;
+ min-height: 1em;
}
-
-
/* * * * * * * * * * * * * * * *
* DROPDOWN *
* * * * * * * * * * * * * * * */
diff --git a/_assets/src/fonts/material/icons.woff2 b/_assets/src/fonts/material/icons.woff2
index 9fa21125..05a8ab5d 100644
Binary files a/_assets/src/fonts/material/icons.woff2 and b/_assets/src/fonts/material/icons.woff2 differ
diff --git a/filemanager.go b/filemanager.go
index 10ae06ee..18e4729f 100644
--- a/filemanager.go
+++ b/filemanager.go
@@ -106,8 +106,8 @@ func New(scope string) *FileManager {
Users: map[string]*User{},
BeforeSave: func(r *http.Request, m *FileManager, u *User) error { return nil },
AfterSave: func(r *http.Request, m *FileManager, u *User) error { return nil },
- static: http.FileServer(rice.MustFindBox("./_assets/dist_build/_").HTTPBox()),
- templates: rice.MustFindBox("./_assets/dist_build/templates"),
+ static: http.FileServer(rice.MustFindBox("./_assets/dist_dev/_").HTTPBox()),
+ templates: rice.MustFindBox("./_assets/dist_dev/templates"),
}
m.SetScope(scope, "")