Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06200775d5 | ||
|
|
8a10baa815 | ||
|
|
98c22ece8d | ||
|
|
63247f6e8c | ||
|
|
58dd812008 | ||
|
|
1575fafec8 | ||
|
|
8c935eb51d | ||
|
|
7f3a26e1c0 | ||
|
|
fe834aa244 | ||
|
|
6620a1bf41 | ||
|
|
dab08325b7 | ||
|
|
ddb4685257 | ||
|
|
39dbca3b15 | ||
|
|
a02bdfc8d5 | ||
|
|
f88721cc83 | ||
|
|
95544bfed5 | ||
|
|
999ee1c2f5 | ||
|
|
a61ade62e5 | ||
|
|
08de5efeb4 | ||
|
|
74f690a71b | ||
|
|
1d4a3005ff | ||
|
|
7447a530ee | ||
|
|
fa9396f0f4 | ||
|
|
172bbb1828 | ||
|
|
410aa5d9da | ||
|
|
736cef7127 | ||
|
|
f4ceb7163e | ||
|
|
7bd4fbc0cb | ||
|
|
2ed4658369 | ||
|
|
735312982c | ||
|
|
4ddb3f5a34 | ||
|
|
c947228ac4 | ||
|
|
505af7d9d7 | ||
|
|
2c13ac4ac1 | ||
|
|
b5fbab2072 | ||
|
|
005b184d59 | ||
|
|
372bd813d9 | ||
|
|
52599314b0 | ||
|
|
f61e71e44f | ||
|
|
e5265b6632 | ||
|
|
003f361956 | ||
|
|
cc8369d83e | ||
|
|
aeb583a0bc | ||
|
|
41f07c64eb | ||
|
|
98588a66a7 | ||
|
|
49f32f876d | ||
|
|
aeb0f37e20 | ||
|
|
59a0daa293 | ||
|
|
c716d126eb | ||
|
|
5dc210c000 | ||
|
|
3bb3fdb956 | ||
|
|
b96a4a63c0 | ||
|
|
3d54b2bd90 | ||
|
|
95d43a344c | ||
|
|
1077d5cd6b | ||
|
|
57cc174b3d | ||
|
|
cf61baa273 | ||
|
|
2d5cd2d1d3 | ||
|
|
9472aad877 | ||
|
|
dd0f3ef144 | ||
|
|
44e492160b | ||
|
|
0137b03887 | ||
|
|
92c9b134c3 | ||
|
|
1737702c7c | ||
|
|
ece52ecf7c | ||
|
|
a7d6a72718 | ||
|
|
3fa9286238 | ||
|
|
ad5ff4cfe0 | ||
|
|
9aee1ebd2a | ||
|
|
f8ed1b41d6 | ||
|
|
bb9b0dfd2b | ||
|
|
cc2ce884fc | ||
|
|
e7e7679002 | ||
|
|
9a829fd594 | ||
|
|
624d61930c | ||
|
|
ee30e7711f | ||
|
|
6e5116aa27 | ||
|
|
34acffbb7b | ||
|
|
eb6f26c191 | ||
|
|
06f3e9744a |
No files matched your search
@@ -6,3 +6,7 @@ node_modules/
|
|||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
|
.idea
|
||||||
|
.vscode
|
||||||
|
package-lock.json
|
||||||
|
yarn.lock
|
||||||
@@ -8,11 +8,17 @@ build:
|
|||||||
- freebsd
|
- freebsd
|
||||||
- netbsd
|
- netbsd
|
||||||
- openbsd
|
- openbsd
|
||||||
|
- dragonfly
|
||||||
|
- solaris
|
||||||
goarch:
|
goarch:
|
||||||
- amd64
|
- amd64
|
||||||
- 386
|
- 386
|
||||||
- arm
|
- arm
|
||||||
- arm64
|
- arm64
|
||||||
|
- mips
|
||||||
|
- mips64
|
||||||
|
- mipsle
|
||||||
|
- mips64le
|
||||||
ignore:
|
ignore:
|
||||||
- goos: openbsd
|
- goos: openbsd
|
||||||
goarch: arm
|
goarch: arm
|
||||||
@@ -20,6 +26,8 @@ build:
|
|||||||
- goos: freebsd
|
- goos: freebsd
|
||||||
goarch: arm
|
goarch: arm
|
||||||
goarm: 6
|
goarm: 6
|
||||||
|
- goos: linux
|
||||||
|
goarch: arm64
|
||||||
|
|
||||||
archive:
|
archive:
|
||||||
name_template: "{{.Os}}-{{.Arch}}-{{ .ProjectName }}"
|
name_template: "{{.Os}}-{{.Arch}}-{{ .ProjectName }}"
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
language: go
|
language: go
|
||||||
|
|
||||||
go: 1.8.3
|
go: 1.x
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- "PATH=/home/travis/gopath/bin:$PATH"
|
- "PATH=/home/travis/gopath/bin:$PATH"
|
||||||
@@ -15,7 +15,7 @@ install:
|
|||||||
- go get github.com/tsenart/deadcode
|
- go get github.com/tsenart/deadcode
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- gometalinter --disable-all -E vet -E gofmt -E misspell -E ineffassign -E goimports -E deadcode --exclude="rice-box.go" --tests ./...
|
- gometalinter --disable-all -E gofmt -E misspell -E ineffassign -E goimports -E deadcode --exclude="rice-box.go" --tests ./...
|
||||||
- go test ./... -timeout 30s
|
- go test ./... -timeout 30s
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
If you want to contribute or want to build the code from source, you will need to have the most recent version of Go and, if you want to change the static assets (JS, CSS, ...), Node.js installed on your computer. To start developing, you just need to do the following:
|
If you want to contribute or want to build the code from source, you will need to have the most recent version of Go and, if you want to change the static assets (JS, CSS, ...), Node.js installed on your computer. To start developing, you just need to do the following:
|
||||||
|
|
||||||
1. `go get github.com/hacdias/filemanager`
|
1. `go get github.com/hacdias/filemanager/cmd/filemanager`
|
||||||
2. `cd $GOPATH/src/github.com/hacdias/filemanager`
|
2. `cd $GOPATH/src/github.com/hacdias/filemanager`
|
||||||
3. `npm install`
|
3. `npm install`
|
||||||
4. `npm run dev` - regenerates the static assets automatically
|
4. `npm run dev` - regenerates the static assets automatically
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ RUN mv filemanager /go/bin/filemanager
|
|||||||
FROM scratch
|
FROM scratch
|
||||||
COPY --from=0 /go/bin/filemanager /filemanager
|
COPY --from=0 /go/bin/filemanager /filemanager
|
||||||
|
|
||||||
|
VOLUME /tmp
|
||||||
VOLUME /srv
|
VOLUME /srv
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
[](https://travis-ci.org/hacdias/filemanager)
|
[](https://travis-ci.org/hacdias/filemanager)
|
||||||
[](https://goreportcard.com/report/hacdias/filemanager)
|
[](https://goreportcard.com/report/hacdias/filemanager)
|
||||||
[](http://godoc.org/github.com/hacdias/filemanager)
|
[](http://godoc.org/github.com/hacdias/filemanager)
|
||||||
|
[](https://github.com/hacdias/filemanager/releases/latest)
|
||||||
|
|
||||||
filemanager provides a file managing interface within a specified directory and it can be used to upload, delete, preview, rename and edit your files. It allows the creation of multiple users and each user can have its own directory. It can be used as a standalone app or as a middleware.
|
filemanager provides a file managing interface within a specified directory and it can be used to upload, delete, preview, rename and edit your files. It allows the creation of multiple users and each user can have its own directory. It can be used as a standalone app or as a middleware.
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
<meta name="staticgen" content="{{ .StaticGen }}">
|
<meta name="staticgen" content="{{ .StaticGen }}">
|
||||||
<meta name="noauth" content="{{ .NoAuth }}">
|
<meta name="noauth" content="{{ .NoAuth }}">
|
||||||
<meta name="version" content="{{ .Version }}">
|
<meta name="version" content="{{ .Version }}">
|
||||||
|
<meta name="recaptcha" content="{{ .ReCaptchaKey }}">
|
||||||
<title>File Manager</title>
|
<title>File Manager</title>
|
||||||
<link rel="icon" type="image/png" sizes="32x32" href="{{ .BaseURL }}/static/img/icons/favicon-32x32.png">
|
<link rel="icon" type="image/png" sizes="32x32" href="{{ .BaseURL }}/static/img/icons/favicon-32x32.png">
|
||||||
<link rel="icon" type="image/png" sizes="16x16" href="{{ .BaseURL }}/static/img/icons/favicon-16x16.png">
|
<link rel="icon" type="image/png" sizes="16x16" href="{{ .BaseURL }}/static/img/icons/favicon-16x16.png">
|
||||||
@@ -27,6 +28,10 @@
|
|||||||
|
|
||||||
<script>CSS = "{{ .CSS }}"</script>
|
<script>CSS = "{{ .CSS }}"</script>
|
||||||
|
|
||||||
|
{{ if .ReCaptcha -}}
|
||||||
|
<script src='https://www.google.com/recaptcha/api.js?render=explicit'></script>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
<% for (var chunk of webpack.chunks) {
|
<% for (var chunk of webpack.chunks) {
|
||||||
for (var file of chunk.files) {
|
for (var file of chunk.files) {
|
||||||
if (file.match(/\.(js|css)$/)) { %>
|
if (file.match(/\.(js|css)$/)) { %>
|
||||||
|
|||||||
+34
-8
@@ -1,22 +1,48 @@
|
|||||||
<template>
|
<template>
|
||||||
<router-view @update:css="updateCSS" @clean:css="cleanCSS"></router-view>
|
<router-view :dependencies="loaded" @update:css="updateCSS" @clean:css="cleanCSS"></router-view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { mapState } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'app',
|
name: 'app',
|
||||||
|
computed: mapState(['recaptcha']),
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
loaded: false
|
||||||
|
}
|
||||||
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
// Remove loading animation.
|
if (this.recaptcha.length === 0) {
|
||||||
let loading = document.getElementById('loading')
|
this.unload()
|
||||||
loading.classList.add('done')
|
return
|
||||||
|
}
|
||||||
|
|
||||||
setTimeout(function () {
|
let check = () => {
|
||||||
loading.parentNode.removeChild(loading)
|
if (typeof window.grecaptcha === 'undefined') {
|
||||||
}, 200)
|
setTimeout(check, 100)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
this.updateCSS()
|
this.unload()
|
||||||
|
}
|
||||||
|
|
||||||
|
check()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
unload () {
|
||||||
|
this.loaded = true
|
||||||
|
// Remove loading animation.
|
||||||
|
let loading = document.getElementById('loading')
|
||||||
|
loading.classList.add('done')
|
||||||
|
|
||||||
|
setTimeout(function () {
|
||||||
|
loading.parentNode.removeChild(loading)
|
||||||
|
}, 200)
|
||||||
|
|
||||||
|
this.updateCSS()
|
||||||
|
},
|
||||||
updateCSS (global = false) {
|
updateCSS (global = false) {
|
||||||
let css = this.$store.state.css
|
let css = this.$store.state.css
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
<option value="ja">{{ $t('languages.ja') }}</option>
|
<option value="ja">{{ $t('languages.ja') }}</option>
|
||||||
<option value="zh-cn">{{ $t('languages.zhCN') }}</option>
|
<option value="zh-cn">{{ $t('languages.zhCN') }}</option>
|
||||||
<option value="zh-tw">{{ $t('languages.zhTW') }}</option>
|
<option value="zh-tw">{{ $t('languages.zhTW') }}</option>
|
||||||
|
<option value="es">{{ $t('languages.es') }}</option>
|
||||||
</select>
|
</select>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -196,6 +196,10 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
paste (event) {
|
paste (event) {
|
||||||
|
if (event.target.tagName.toLowerCase() === 'input') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
||||||
let items = []
|
let items = []
|
||||||
|
|||||||
@@ -119,9 +119,21 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event.shiftKey && this.selected.length === 1) {
|
if (event.shiftKey && this.selected.length === 1) {
|
||||||
let fi = (this.index > this.selected[0]) ? this.selected[0] : this.index
|
let fi = 0
|
||||||
let la = (this.index > this.selected[0]) ? this.index : this.selected[0]
|
let la = 0
|
||||||
for (; fi <= la; fi++) this.addSelected(fi)
|
|
||||||
|
if (this.index > this.selected[0]) {
|
||||||
|
fi = this.selected[0] + 1
|
||||||
|
la = this.index
|
||||||
|
} else {
|
||||||
|
fi = this.index
|
||||||
|
la = this.selected[0] - 1
|
||||||
|
}
|
||||||
|
|
||||||
|
for (; fi <= la; fi++) {
|
||||||
|
this.addSelected(fi)
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
:title="$t('buttons.cancel')">{{ $t('buttons.cancel') }}</button>
|
:title="$t('buttons.cancel')">{{ $t('buttons.cancel') }}</button>
|
||||||
<button class="flat"
|
<button class="flat"
|
||||||
@click="copy"
|
@click="copy"
|
||||||
|
:disabled="$route.path === dest"
|
||||||
:aria-label="$t('buttons.copy')"
|
:aria-label="$t('buttons.copy')"
|
||||||
:title="$t('buttons.copy')">{{ $t('buttons.copy') }}</button>
|
:title="$t('buttons.copy')">{{ $t('buttons.copy') }}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
:title="$t('buttons.cancel')">{{ $t('buttons.cancel') }}</button>
|
:title="$t('buttons.cancel')">{{ $t('buttons.cancel') }}</button>
|
||||||
<button class="flat"
|
<button class="flat"
|
||||||
@click="move"
|
@click="move"
|
||||||
|
:disabled="$route.path === dest"
|
||||||
:aria-label="$t('buttons.move')"
|
:aria-label="$t('buttons.move')"
|
||||||
:title="$t('buttons.move')">{{ $t('buttons.move') }}</button>
|
:title="$t('buttons.move')">{{ $t('buttons.move') }}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -48,6 +48,10 @@ export default {
|
|||||||
new (url, type) {
|
new (url, type) {
|
||||||
url = removePrefix(url)
|
url = removePrefix(url)
|
||||||
|
|
||||||
|
if (!url.endsWith('.md') && !url.endsWith('.markdown')) {
|
||||||
|
url += '.markdown'
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let request = new window.XMLHttpRequest()
|
let request = new window.XMLHttpRequest()
|
||||||
request.open('POST', `${this.$store.state.baseURL}/api/resource${url}`, true)
|
request.open('POST', `${this.$store.state.baseURL}/api/resource${url}`, true)
|
||||||
|
|||||||
@@ -112,6 +112,11 @@ button.flat.cancel {
|
|||||||
color: #ccc;
|
color: #ccc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button.flat[disabled] {
|
||||||
|
color: #ccc;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
.mobile-only {
|
.mobile-only {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,14 @@
|
|||||||
width: 90%;
|
width: 90%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#login.recaptcha form {
|
||||||
|
min-width: 304px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#login #recaptcha {
|
||||||
|
margin: .5em 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
#login input {
|
#login input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@@ -192,6 +192,7 @@ languages:
|
|||||||
ja: 日本語
|
ja: 日本語
|
||||||
zhCN: 中文 (简体)
|
zhCN: 中文 (简体)
|
||||||
zhTW: 中文 (繁體)
|
zhTW: 中文 (繁體)
|
||||||
|
es: Español
|
||||||
time:
|
time:
|
||||||
unit: Time Unit
|
unit: Time Unit
|
||||||
seconds: Seconds
|
seconds: Seconds
|
||||||
|
|||||||
@@ -0,0 +1,202 @@
|
|||||||
|
permanent: Permanente
|
||||||
|
buttons:
|
||||||
|
cancel: Cancelar
|
||||||
|
close: Cerrar
|
||||||
|
copy: Copiar
|
||||||
|
copyFile: Copiar archivo
|
||||||
|
copyToClipboard: Copiar al portapapeles
|
||||||
|
create: Crear
|
||||||
|
delete: Borrar
|
||||||
|
download: Descargar
|
||||||
|
info: Info
|
||||||
|
more: Más
|
||||||
|
move: Mover
|
||||||
|
moveFile: Mover archivo
|
||||||
|
new: Nuevo
|
||||||
|
next: Siguiente
|
||||||
|
ok: OK
|
||||||
|
replace: Reemplazar
|
||||||
|
previous: Anterior
|
||||||
|
rename: Renombrar
|
||||||
|
reportIssue: Reportar problema
|
||||||
|
save: Guardar
|
||||||
|
search: Buscar
|
||||||
|
select: Seleccionar
|
||||||
|
share: Compartir
|
||||||
|
publish: Publicar
|
||||||
|
selectMultiple: Selección múltiple
|
||||||
|
schedule: Programar
|
||||||
|
switchView: Cambiar vista
|
||||||
|
toggleSidebar: Mostrar/Ocultar menú
|
||||||
|
update: Actualizar
|
||||||
|
upload: Subir
|
||||||
|
permalink: Link permanente
|
||||||
|
success:
|
||||||
|
linkCopied: ¡Link copiado!
|
||||||
|
errors:
|
||||||
|
forbidden: No eres bienvenido aquí.
|
||||||
|
internal: La verdad es que algo ha ido mal.
|
||||||
|
notFound: No se puede acceder a este lugar.
|
||||||
|
files:
|
||||||
|
folders: Carpetas
|
||||||
|
files: Archivos
|
||||||
|
body: Cuerpo
|
||||||
|
clear: Limpiar
|
||||||
|
closePreview: Cerrar vista previa
|
||||||
|
home: Inicio
|
||||||
|
lastModified: Última modificación
|
||||||
|
loading: Cargando...
|
||||||
|
lonely: Uno se siente muy sólo aquí...
|
||||||
|
metadata: Metadatos
|
||||||
|
multipleSelectionEnabled: Selección múltiple activada
|
||||||
|
name: Nombre
|
||||||
|
size: Tamaño
|
||||||
|
sortByName: Ordenar por nombre
|
||||||
|
sortBySize: Ordenar por tamaño
|
||||||
|
sortByLastModified: Ordenar por última modificación
|
||||||
|
help:
|
||||||
|
click: seleccionar archivo o carpeta
|
||||||
|
ctrl:
|
||||||
|
click: seleccionar múltiples archivos o carpetas
|
||||||
|
f: abre la búsqueda
|
||||||
|
s: guarda un archivo o lo descarga a la carpeta en la que estás
|
||||||
|
del: elimina los items seleccionados
|
||||||
|
doubleClick: abre un archivo o carpeta
|
||||||
|
esc: limpia la selección y/o cierra la ventana
|
||||||
|
f1: esta información
|
||||||
|
f2: renombrar archivo
|
||||||
|
help: Ayuda
|
||||||
|
login:
|
||||||
|
password: Contraseña
|
||||||
|
submit: Iniciar sesión
|
||||||
|
username: Usuario
|
||||||
|
wrongCredentials: Usuario y/o contraseña incorrectos
|
||||||
|
prompts:
|
||||||
|
copy: Copiar
|
||||||
|
copyMessage: 'Elige el lugar donde quieres copiar tus archivos:'
|
||||||
|
currentlyNavigating: 'Actualmente estás en:'
|
||||||
|
deleteMessageMultiple: ¿Estás seguro que quieres eliminar {count} archivo(s)?
|
||||||
|
deleteMessageSingle: ¿Estás seguro que quieres eliminar este archivo/carpeta?
|
||||||
|
deleteTitle: Borrar archivos
|
||||||
|
displayName: 'Nombre:'
|
||||||
|
download: Descargar archivos
|
||||||
|
downloadMessage: Elige el formato de descarga.
|
||||||
|
error: Algo ha fallado
|
||||||
|
fileInfo: Información del archivo
|
||||||
|
filesSelected: "{count} archivos seleccionados."
|
||||||
|
lastModified: Última modificación
|
||||||
|
move: Mover
|
||||||
|
moveMessage: 'Elige una nueva casa para tus archivo(s)/carpeta(s):'
|
||||||
|
newDir: Nueva carpeta
|
||||||
|
newDirMessage: Escribe el nombre de la nueva carpeta.
|
||||||
|
newFile: Nuevo archivo
|
||||||
|
newFileMessage: Escribe el nombre del nuevo archivo.
|
||||||
|
numberDirs: Número de carpetas
|
||||||
|
numberFiles: Número de archivos
|
||||||
|
replace: Reemplazar
|
||||||
|
replaceMessage: >
|
||||||
|
Uno de los archivos ue intentas subir está creando conflicto por su nombre.
|
||||||
|
¿Quieres cambiar el nombre del ya existente?
|
||||||
|
rename: Renombrar
|
||||||
|
renameMessage: Escribe el nuevo nombre para
|
||||||
|
show: Mostrar
|
||||||
|
size: Tamaño
|
||||||
|
schedule: Programar
|
||||||
|
scheduleMessage: Elige una hora y fecha para programar la publicación de este post.
|
||||||
|
newArchetype: Crea un nuevo post basado en un arquetipo. Tu archivo será creado en la carpeta de contenido.
|
||||||
|
settings:
|
||||||
|
admin: Admin
|
||||||
|
administrator: Administrador
|
||||||
|
allowCommands: Ejecutar comandos
|
||||||
|
allowEdit: Editar, renombrar y borrar archivos o carpetas
|
||||||
|
allowNew: Crear nuevos archivos y carpetas
|
||||||
|
allowPublish: Publicar nuevos posts y páginas
|
||||||
|
avoidChanges: "(dejar en blanco para evitar cambios)"
|
||||||
|
changePassword: Cambiar contraseña
|
||||||
|
commands: Comandos
|
||||||
|
commandsHelp: >
|
||||||
|
Aquí puedes crear comandos que serán ejecutados en los eventos. Debes
|
||||||
|
escribir un comando por linea. Si el evento está relacionado con archivos, como
|
||||||
|
por ejemplo, antes y después de guardar, la variable de entorno "FILE" estará
|
||||||
|
disponible en la ruta del archivo.
|
||||||
|
commandsUpdated: ¡Comandos actualizados!
|
||||||
|
customStylesheet: Modificar hoja de estilos
|
||||||
|
examples: Ejemplos
|
||||||
|
globalSettings: Ajustes globales
|
||||||
|
language: Idioma
|
||||||
|
lockPassword: Evitar que el usuario cambie la contraseña
|
||||||
|
newPassword: Tu nueva contraseña
|
||||||
|
newPasswordConfirm: Confirma tu contraseña
|
||||||
|
newUser: Nuevo usuario
|
||||||
|
password: Contraseña
|
||||||
|
passwordUpdated: ¡Contraseña actualizada!
|
||||||
|
permissions: Permisos
|
||||||
|
permissionsHelp: >
|
||||||
|
Puedes nombrar al usuario como administrador o elegir los permisos
|
||||||
|
individualmente. Si seleccionas "Administrador", todas las otras opciones
|
||||||
|
serán activadas automáticamente. La administración de usuarios es un privilegio de administrador.
|
||||||
|
profileSettings: Ajustes del perfil
|
||||||
|
ruleExample1: >
|
||||||
|
previene el acceso a una extensión de archivo (Como .git) en
|
||||||
|
cada carpeta.
|
||||||
|
ruleExample2: bloquea el acceso al archivo llamado Caddyfile en la carpeta raíz.
|
||||||
|
rules: Reglas
|
||||||
|
rulesHelp1: >
|
||||||
|
Aquí puedes definir un conjunto de reglas de permisos para este usuario
|
||||||
|
específico. Los archivos bloqueados no se mostrarán en las listas y no serán accesibles
|
||||||
|
por el usuario. Puedes utilizar regex y rutas relativas a la raíz del usuario.
|
||||||
|
rulesHelp2: >
|
||||||
|
Cada regla va en una línea diferente, y debe comenzar con la palabra clave
|
||||||
|
{0} or {1}. Entonces, debes escribir {2} si estás usando una expresión regular (REGEX) y
|
||||||
|
luego la expresión o la ruta.
|
||||||
|
scope: Raíz
|
||||||
|
settingsUpdated: ¡Ajustes actualizados!
|
||||||
|
user: Usuario
|
||||||
|
userCommands: Comandos
|
||||||
|
userCommandsHelp: >
|
||||||
|
Una lista separada por espacios con los comandos permitidos para este usuario.
|
||||||
|
Ejemplo:
|
||||||
|
userCreated: ¡Usuario creado!
|
||||||
|
userDeleted: ¡Usuario eliminado!
|
||||||
|
userManagement: Administración de usuarios
|
||||||
|
username: Usuario
|
||||||
|
users: Usuarios
|
||||||
|
userUpdated: ¡Usuario actualizado!
|
||||||
|
sidebar:
|
||||||
|
help: Ayuda
|
||||||
|
logout: Cerrar sesión
|
||||||
|
myFiles: Mis archivos
|
||||||
|
newFile: Nuevo archivo
|
||||||
|
newFolder: Nueva carpeta
|
||||||
|
settings: Ajustes
|
||||||
|
siteSettings: Ajustes del sitio
|
||||||
|
hugoNew: Nuevo Hugo
|
||||||
|
preview: Vista previa
|
||||||
|
search:
|
||||||
|
images: Images
|
||||||
|
music: Música
|
||||||
|
pdf: PDF
|
||||||
|
pressToExecute: Presiona enter para ejecutar.
|
||||||
|
pressToSearch: Presiona enter para buscar.
|
||||||
|
search: Buscar...
|
||||||
|
searchOrCommand: Buscar o ejecutar un comando...
|
||||||
|
searchOrSupportedCommand: 'Buscar o ejecutar uno de los comandos soportados:'
|
||||||
|
type: Escribe y presiona enter para buscar.
|
||||||
|
types: Tipos
|
||||||
|
video: Vídeo
|
||||||
|
writeToSearch: Escribe aquí para buscar
|
||||||
|
languages:
|
||||||
|
en: English
|
||||||
|
fr: Français
|
||||||
|
pt: Português
|
||||||
|
es: Español
|
||||||
|
ja: 日本語
|
||||||
|
zhCN: 中文 (简体)
|
||||||
|
zhTW: 中文 (繁體)
|
||||||
|
|
||||||
|
time:
|
||||||
|
unit: Unidad
|
||||||
|
seconds: Segundos
|
||||||
|
minutes: Minutos
|
||||||
|
hours: Horas
|
||||||
|
days: Días
|
||||||
@@ -185,6 +185,7 @@ languages:
|
|||||||
ja: 日本語
|
ja: 日本語
|
||||||
zhCN: 中文 (简体)
|
zhCN: 中文 (简体)
|
||||||
zhTW: 中文 (繁體)
|
zhTW: 中文 (繁體)
|
||||||
|
es: Español
|
||||||
time:
|
time:
|
||||||
unit: Unité de temps
|
unit: Unité de temps
|
||||||
seconds: Secondes
|
seconds: Secondes
|
||||||
|
|||||||
@@ -6,11 +6,46 @@ import pt from './pt.yaml'
|
|||||||
import ja from './ja.yaml'
|
import ja from './ja.yaml'
|
||||||
import zhCN from './zh-cn.yaml'
|
import zhCN from './zh-cn.yaml'
|
||||||
import zhTW from './zh-tw.yaml'
|
import zhTW from './zh-tw.yaml'
|
||||||
|
import es from './es.yaml'
|
||||||
|
|
||||||
Vue.use(VueI18n)
|
Vue.use(VueI18n)
|
||||||
|
|
||||||
|
export function detectLocale () {
|
||||||
|
let locale = (navigator.language || navigator.browserLangugae).toLowerCase()
|
||||||
|
switch (true) {
|
||||||
|
case /^en.*/i.test(locale):
|
||||||
|
locale = 'en'
|
||||||
|
break
|
||||||
|
case /^fr.*/i.test(locale):
|
||||||
|
locale = 'fr'
|
||||||
|
break
|
||||||
|
case /^pt.*/i.test(locale):
|
||||||
|
locale = 'pt'
|
||||||
|
break
|
||||||
|
case /^ja.*/i.test(locale):
|
||||||
|
locale = 'ja'
|
||||||
|
break
|
||||||
|
case /^zh-CN/i.test(locale):
|
||||||
|
locale = 'zh-cn'
|
||||||
|
break
|
||||||
|
case /^zh-TW/i.test(locale):
|
||||||
|
locale = 'zh-tw'
|
||||||
|
break
|
||||||
|
case /^zh.*/i.test(locale):
|
||||||
|
locale = 'zh-cn'
|
||||||
|
break
|
||||||
|
case /^es.*/i.test(locale):
|
||||||
|
locale = 'es'
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
locale = 'en'
|
||||||
|
}
|
||||||
|
|
||||||
|
return locale
|
||||||
|
}
|
||||||
|
|
||||||
const i18n = new VueI18n({
|
const i18n = new VueI18n({
|
||||||
locale: 'en',
|
locale: detectLocale(),
|
||||||
fallbackLocale: 'en',
|
fallbackLocale: 'en',
|
||||||
messages: {
|
messages: {
|
||||||
'en': en,
|
'en': en,
|
||||||
@@ -18,7 +53,8 @@ const i18n = new VueI18n({
|
|||||||
'pt': pt,
|
'pt': pt,
|
||||||
'ja': ja,
|
'ja': ja,
|
||||||
'zh-cn': zhCN,
|
'zh-cn': zhCN,
|
||||||
'zh-tw': zhTW
|
'zh-tw': zhTW,
|
||||||
|
'es': es
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ settings:
|
|||||||
examples: 例
|
examples: 例
|
||||||
globalSettings: グローバル設定
|
globalSettings: グローバル設定
|
||||||
language: 言語
|
language: 言語
|
||||||
lockPassowrd: 新しいパスワードを変更に禁止
|
lockPassword: 新しいパスワードを変更に禁止
|
||||||
newPassword: 新しいパスワード
|
newPassword: 新しいパスワード
|
||||||
newPasswordConfirm: 新しいパスワードを確認します
|
newPasswordConfirm: 新しいパスワードを確認します
|
||||||
newUser: 新しいユーザー
|
newUser: 新しいユーザー
|
||||||
@@ -192,6 +192,7 @@ languages:
|
|||||||
ja: 日本語
|
ja: 日本語
|
||||||
zhCN: 中文 (简体)
|
zhCN: 中文 (简体)
|
||||||
zhTW: 中文 (繁體)
|
zhTW: 中文 (繁體)
|
||||||
|
es: Español
|
||||||
time:
|
time:
|
||||||
unit: 時間単位
|
unit: 時間単位
|
||||||
seconds: 秒
|
seconds: 秒
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ languages:
|
|||||||
ja: 日本語
|
ja: 日本語
|
||||||
zhCN: 中文 (简体)
|
zhCN: 中文 (简体)
|
||||||
zhTW: 中文 (繁體)
|
zhTW: 中文 (繁體)
|
||||||
|
es: Español
|
||||||
login:
|
login:
|
||||||
password: Palavra-passe
|
password: Palavra-passe
|
||||||
submit: Login
|
submit: Login
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ settings:
|
|||||||
examples: 例子
|
examples: 例子
|
||||||
globalSettings: 全局设置
|
globalSettings: 全局设置
|
||||||
language: 语言
|
language: 语言
|
||||||
lockPassowrd: 禁止用户修改密码
|
lockPassword: 禁止用户修改密码
|
||||||
newPassword: 您的新密码
|
newPassword: 您的新密码
|
||||||
newPasswordConfirm: 重输一遍新密码
|
newPasswordConfirm: 重输一遍新密码
|
||||||
newUser: 新建用户
|
newUser: 新建用户
|
||||||
@@ -190,6 +190,7 @@ languages:
|
|||||||
ja: 日本語
|
ja: 日本語
|
||||||
zhCN: 中文 (简体)
|
zhCN: 中文 (简体)
|
||||||
zhTW: 中文 (繁體)
|
zhTW: 中文 (繁體)
|
||||||
|
es: Español
|
||||||
time:
|
time:
|
||||||
unit: 时间单位
|
unit: 时间单位
|
||||||
seconds: 秒
|
seconds: 秒
|
||||||
|
|||||||
@@ -190,6 +190,7 @@ languages:
|
|||||||
ja: 日本語
|
ja: 日本語
|
||||||
zhCN: 中文 (简体)
|
zhCN: 中文 (简体)
|
||||||
zhTW: 中文 (繁體)
|
zhTW: 中文 (繁體)
|
||||||
|
es: Español
|
||||||
time:
|
time:
|
||||||
unit: 時間單位
|
unit: 時間單位
|
||||||
seconds: 秒
|
seconds: 秒
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ Vue.prototype.$showError = function (error) {
|
|||||||
type: 'error',
|
type: 'error',
|
||||||
timeout: null,
|
timeout: null,
|
||||||
buttons: [
|
buttons: [
|
||||||
Noty.button(i18n.t('buttons.reportIssue'), 'cancel', function () {
|
Noty.button(i18n.t('buttons.reportIssue'), '', function () {
|
||||||
window.open('https://github.com/hacdias/filemanager/issues/new')
|
window.open('https://github.com/hacdias/filemanager/issues/new')
|
||||||
}),
|
}),
|
||||||
Noty.button(i18n.t('buttons.close'), '', function () {
|
Noty.button(i18n.t('buttons.close'), '', function () {
|
||||||
|
|||||||
+17
-17
@@ -3,15 +3,15 @@ import Router from 'vue-router'
|
|||||||
import Login from '@/views/Login'
|
import Login from '@/views/Login'
|
||||||
import Layout from '@/views/Layout'
|
import Layout from '@/views/Layout'
|
||||||
import Files from '@/views/Files'
|
import Files from '@/views/Files'
|
||||||
import Users from '@/views/Settings/Users'
|
import Users from '@/views/settings/Users'
|
||||||
import User from '@/views/Settings/User'
|
import User from '@/views/settings/User'
|
||||||
import Settings from '@/views/Settings'
|
import Settings from '@/views/Settings'
|
||||||
import GlobalSettings from '@/views/settings/Global'
|
import GlobalSettings from '@/views/settings/Global'
|
||||||
import ProfileSettings from '@/views/settings/Profile'
|
import ProfileSettings from '@/views/settings/Profile'
|
||||||
import Error403 from '@/views/errors/403'
|
import Error403 from '@/views/errors/403'
|
||||||
import Error404 from '@/views/errors/404'
|
import Error404 from '@/views/errors/404'
|
||||||
import Error500 from '@/views/errors/500'
|
import Error500 from '@/views/errors/500'
|
||||||
import auth from '@/utils/auth.js'
|
import auth from '@/utils/auth'
|
||||||
import store from '@/store'
|
import store from '@/store'
|
||||||
|
|
||||||
Vue.use(Router)
|
Vue.use(Router)
|
||||||
@@ -51,14 +51,13 @@ const router = new Router({
|
|||||||
path: '/settings',
|
path: '/settings',
|
||||||
name: 'Settings',
|
name: 'Settings',
|
||||||
component: Settings,
|
component: Settings,
|
||||||
|
redirect: {
|
||||||
|
path: '/settings/profile'
|
||||||
|
},
|
||||||
|
meta: {
|
||||||
|
disableOnNoAuth: true
|
||||||
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
|
||||||
path: '/settings',
|
|
||||||
name: 'Settings',
|
|
||||||
redirect: {
|
|
||||||
path: '/settings/profile'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: '/settings/profile',
|
path: '/settings/profile',
|
||||||
name: 'Profile Settings',
|
name: 'Profile Settings',
|
||||||
@@ -131,16 +130,17 @@ router.beforeEach((to, from, next) => {
|
|||||||
auth.loggedIn()
|
auth.loggedIn()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (to.matched.some(record => record.meta.requiresAdmin)) {
|
if (to.matched.some(record => record.meta.requiresAdmin)) {
|
||||||
if (store.state.user.admin) {
|
if (!store.state.user.admin) {
|
||||||
next()
|
next({ path: '/403' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
next({
|
if (to.matched.some(record => record.meta.disableOnNoAuth)) {
|
||||||
path: '/403'
|
if (store.state.noAuth) {
|
||||||
})
|
next({ path: '/403' })
|
||||||
|
return
|
||||||
return
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
next()
|
next()
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ const state = {
|
|||||||
window.CSS = null
|
window.CSS = null
|
||||||
return css
|
return css
|
||||||
})(),
|
})(),
|
||||||
|
recaptcha: document.querySelector('meta[name="recaptcha"]').getAttribute('content'),
|
||||||
staticGen: document.querySelector('meta[name="staticgen"]').getAttribute('content'),
|
staticGen: document.querySelector('meta[name="staticgen"]').getAttribute('content'),
|
||||||
baseURL: document.querySelector('meta[name="base"]').getAttribute('content'),
|
baseURL: document.querySelector('meta[name="base"]').getAttribute('content'),
|
||||||
noAuth: (document.querySelector('meta[name="noauth"]').getAttribute('content') === 'true'),
|
noAuth: (document.querySelector('meta[name="noauth"]').getAttribute('content') === 'true'),
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import i18n from '@/i18n'
|
import * as i18n from '@/i18n'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
|
|
||||||
const mutations = {
|
const mutations = {
|
||||||
@@ -27,8 +27,14 @@ const mutations = {
|
|||||||
setLoading: (state, value) => { state.loading = value },
|
setLoading: (state, value) => { state.loading = value },
|
||||||
setReload: (state, value) => { state.reload = value },
|
setReload: (state, value) => { state.reload = value },
|
||||||
setUser: (state, value) => {
|
setUser: (state, value) => {
|
||||||
moment.locale(value.locale)
|
let locale = value.locale
|
||||||
i18n.locale = value.locale
|
|
||||||
|
if (locale === '') {
|
||||||
|
locale = i18n.detectLocale()
|
||||||
|
}
|
||||||
|
|
||||||
|
moment.locale(locale)
|
||||||
|
i18n.default.locale = locale
|
||||||
state.user = value
|
state.user = value
|
||||||
},
|
},
|
||||||
setCSS: (state, value) => (state.css = value),
|
setCSS: (state, value) => (state.css = value),
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
import cookie from './cookie'
|
import cookie from './cookie'
|
||||||
import store from '@/store'
|
import store from '@/store'
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
|
import { Base64 } from 'js-base64'
|
||||||
|
|
||||||
function parseToken (token) {
|
function parseToken (token) {
|
||||||
let path = store.state.baseURL
|
let path = store.state.baseURL
|
||||||
if (path === '') path = '/'
|
if (path === '') path = '/'
|
||||||
document.cookie = `auth=${token}; max-age=86400; path=${path}`
|
document.cookie = `auth=${token}; max-age=86400; path=${path}`
|
||||||
let res = token.split('.')
|
let res = token.split('.')
|
||||||
let user = JSON.parse(window.atob(res[1]))
|
let user = JSON.parse(Base64.decode(res[1]))
|
||||||
|
if (!user.commands) {
|
||||||
|
user.commands = []
|
||||||
|
}
|
||||||
|
|
||||||
store.commit('setJWT', token)
|
store.commit('setJWT', token)
|
||||||
store.commit('setUser', user)
|
store.commit('setUser', user)
|
||||||
}
|
}
|
||||||
@@ -31,8 +36,8 @@ function loggedIn () {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function login (user, password) {
|
function login (user, password, captcha) {
|
||||||
let data = {username: user, password: password}
|
let data = {username: user, password: password, recaptcha: captcha}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let request = new window.XMLHttpRequest()
|
let request = new window.XMLHttpRequest()
|
||||||
request.open('POST', `${store.state.baseURL}/api/auth/get`, true)
|
request.open('POST', `${store.state.baseURL}/api/auth/get`, true)
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
scroll (event) {
|
scroll (event) {
|
||||||
if (this.req.kind !== 'listing' || this.$store.state.req.display === 'mosaic') return
|
if (this.req.kind !== 'listing' || this.$store.state.user.viewMode === 'mosaic') return
|
||||||
|
|
||||||
let top = 112 - window.scrollY
|
let top = 112 - window.scrollY
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="login">
|
<div id="login" :class="{ recaptcha: recaptcha.length > 0 }">
|
||||||
<form @submit="submit">
|
<form @submit="submit">
|
||||||
<img src="../assets/logo.svg" alt="File Manager">
|
<img src="../assets/logo.svg" alt="File Manager">
|
||||||
<h1>File Manager</h1>
|
<h1>File Manager</h1>
|
||||||
<div v-if="wrong" class="wrong">{{ $t("login.wrongCredentials") }}</div>
|
<div v-if="wrong" class="wrong">{{ $t("login.wrongCredentials") }}</div>
|
||||||
<input type="text" v-model="username" :placeholder="$t('login.username')">
|
<input type="text" v-model="username" :placeholder="$t('login.username')">
|
||||||
<input type="password" v-model="password" :placeholder="$t('login.password')">
|
<input type="password" v-model="password" :placeholder="$t('login.password')">
|
||||||
|
<div v-if="recaptcha.length" id="recaptcha"></div>
|
||||||
<input type="submit" :value="$t('login.submit')">
|
<input type="submit" :value="$t('login.submit')">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@@ -13,9 +14,12 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import auth from '@/utils/auth'
|
import auth from '@/utils/auth'
|
||||||
|
import { mapState } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'login',
|
name: 'login',
|
||||||
|
props: ['dependencies'],
|
||||||
|
computed: mapState(['recaptcha']),
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
wrong: false,
|
wrong: false,
|
||||||
@@ -23,8 +27,23 @@ export default {
|
|||||||
password: ''
|
password: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted () {
|
||||||
|
if (this.dependencies) this.setup()
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
dependencies: function (val) {
|
||||||
|
if (val) this.setup()
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
submit: function (event) {
|
setup () {
|
||||||
|
if (this.recaptcha.length === 0) return
|
||||||
|
|
||||||
|
window.grecaptcha.render('recaptcha', {
|
||||||
|
sitekey: this.recaptcha
|
||||||
|
})
|
||||||
|
},
|
||||||
|
submit (event) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
|
|
||||||
@@ -33,7 +52,17 @@ export default {
|
|||||||
redirect = '/files/'
|
redirect = '/files/'
|
||||||
}
|
}
|
||||||
|
|
||||||
auth.login(this.username, this.password)
|
let captcha = ''
|
||||||
|
if (this.recaptcha.length > 0) {
|
||||||
|
captcha = window.grecaptcha.getResponse()
|
||||||
|
|
||||||
|
if (captcha === '') {
|
||||||
|
this.wrong = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auth.login(this.username, this.password, captcha)
|
||||||
.then(() => { this.$router.push({ path: redirect }) })
|
.then(() => { this.$router.push({ path: redirect }) })
|
||||||
.catch(() => { this.wrong = true })
|
.catch(() => { this.wrong = true })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="dashboard">
|
<div class="dashboard">
|
||||||
<form class="card" @submit.prevent="saveStaticGen">
|
<form class="card" v-if="staticGen.length" @submit.prevent="saveStaticGen">
|
||||||
<div class="card-title">
|
<div class="card-title">
|
||||||
<h2>{{ capitalize($store.state.staticGen) }}</h2>
|
<h2>{{ capitalize($store.state.staticGen) }}</h2>
|
||||||
</div>
|
</div>
|
||||||
@@ -80,7 +80,6 @@ export default {
|
|||||||
created () {
|
created () {
|
||||||
getSettings()
|
getSettings()
|
||||||
.then(settings => {
|
.then(settings => {
|
||||||
console.log(settings)
|
|
||||||
if (this.$store.state.staticGen.length > 0) {
|
if (this.$store.state.staticGen.length > 0) {
|
||||||
this.parseStaticGen(settings.staticGen)
|
this.parseStaticGen(settings.staticGen)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,21 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
|
<p>
|
||||||
|
<label for="username">{{ $t('settings.username') }}</label>
|
||||||
|
<input type="text" v-model="username" id="username">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<label for="password">{{ $t('settings.password') }}</label>
|
||||||
|
<input type="password" :placeholder="passwordPlaceholder" v-model="password" id="password">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<label for="scope">{{ $t('settings.scope') }}</label>
|
||||||
|
<input type="text" v-model="filesystem" id="scope">
|
||||||
|
</p>
|
||||||
|
|
||||||
<p><label for="username">{{ $t('settings.username') }}</label><input type="text" v-model="username" id="username"></p>
|
|
||||||
<p><label for="password">{{ $t('settings.password') }}</label><input type="password" :placeholder="passwordPlaceholder" v-model="password" id="password"></p>
|
|
||||||
<p><label for="scope">{{ $t('settings.scope') }}</label><input type="text" v-model="filesystem" id="scope"></p>
|
|
||||||
<p>
|
<p>
|
||||||
<label for="locale">{{ $t('settings.language') }}</label>
|
<label for="locale">{{ $t('settings.language') }}</label>
|
||||||
<languages id="locale" :selected.sync="locale"></languages>
|
<languages id="locale" :selected.sync="locale"></languages>
|
||||||
@@ -91,6 +102,7 @@ export default {
|
|||||||
components: { Languages },
|
components: { Languages },
|
||||||
data: () => {
|
data: () => {
|
||||||
return {
|
return {
|
||||||
|
originalUser: null,
|
||||||
id: 0,
|
id: 0,
|
||||||
admin: false,
|
admin: false,
|
||||||
allowNew: false,
|
allowNew: false,
|
||||||
@@ -141,6 +153,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getUser(user).then(user => {
|
getUser(user).then(user => {
|
||||||
|
this.originalUser = user
|
||||||
this.id = user.ID
|
this.id = user.ID
|
||||||
this.admin = user.admin
|
this.admin = user.admin
|
||||||
this.allowCommands = user.allowCommands
|
this.allowCommands = user.allowCommands
|
||||||
@@ -150,11 +163,14 @@ export default {
|
|||||||
this.lockPassword = user.lockPassword
|
this.lockPassword = user.lockPassword
|
||||||
this.filesystem = user.filesystem
|
this.filesystem = user.filesystem
|
||||||
this.username = user.username
|
this.username = user.username
|
||||||
this.commands = user.commands.join(' ')
|
|
||||||
this.css = user.css
|
this.css = user.css
|
||||||
this.permissions = user.permissions
|
this.permissions = user.permissions
|
||||||
this.locale = user.locale
|
this.locale = user.locale
|
||||||
|
|
||||||
|
if (user.commands) {
|
||||||
|
this.commands = user.commands.join(' ')
|
||||||
|
}
|
||||||
|
|
||||||
for (let rule of user.rules) {
|
for (let rule of user.rules) {
|
||||||
if (rule.allow) {
|
if (rule.allow) {
|
||||||
this.rules += 'allow '
|
this.rules += 'allow '
|
||||||
@@ -242,23 +258,21 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
parseForm () {
|
parseForm () {
|
||||||
let user = {
|
let user = this.originalUser
|
||||||
ID: this.id,
|
user.username = this.username
|
||||||
username: this.username,
|
user.password = this.password
|
||||||
password: this.password,
|
user.lockPassword = this.lockPassword
|
||||||
lockPassword: this.lockPassword,
|
user.filesystem = this.filesystem
|
||||||
filesystem: this.filesystem,
|
user.admin = this.admin
|
||||||
admin: this.admin,
|
user.allowCommands = this.allowCommands
|
||||||
allowCommands: this.allowCommands,
|
user.allowNew = this.allowNew
|
||||||
allowNew: this.allowNew,
|
user.allowEdit = this.allowEdit
|
||||||
allowEdit: this.allowEdit,
|
user.allowPublish = this.allowPublish
|
||||||
allowPublish: this.allowPublish,
|
user.permissions = this.permissions
|
||||||
permissions: this.permissions,
|
user.css = this.css
|
||||||
css: this.css,
|
user.locale = this.locale
|
||||||
locale: this.locale,
|
user.commands = this.commands.split(' ')
|
||||||
commands: this.commands.split(' '),
|
user.rules = []
|
||||||
rules: []
|
|
||||||
}
|
|
||||||
|
|
||||||
let rules = this.rules.split('\n')
|
let rules = this.rules.split('\n')
|
||||||
|
|
||||||
|
|||||||
+23
-6
@@ -37,6 +37,7 @@ func Parse(c *caddy.Controller, plugin string) ([]*filemanager.FileManager, erro
|
|||||||
AllowPublish: true,
|
AllowPublish: true,
|
||||||
Commands: []string{"git", "svn", "hg"},
|
Commands: []string{"git", "svn", "hg"},
|
||||||
CSS: "",
|
CSS: "",
|
||||||
|
ViewMode: "mosaic",
|
||||||
Rules: []*filemanager.Rule{{
|
Rules: []*filemanager.Rule{{
|
||||||
Regex: true,
|
Regex: true,
|
||||||
Allow: false,
|
Allow: false,
|
||||||
@@ -48,6 +49,8 @@ func Parse(c *caddy.Controller, plugin string) ([]*filemanager.FileManager, erro
|
|||||||
scope := "."
|
scope := "."
|
||||||
database := ""
|
database := ""
|
||||||
noAuth := false
|
noAuth := false
|
||||||
|
reCaptchaKey := ""
|
||||||
|
reCaptchaSecret := ""
|
||||||
|
|
||||||
if plugin != "" {
|
if plugin != "" {
|
||||||
baseURL = "/admin"
|
baseURL = "/admin"
|
||||||
@@ -152,9 +155,21 @@ func Parse(c *caddy.Controller, plugin string) ([]*filemanager.FileManager, erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
u.ViewMode = c.Val()
|
u.ViewMode = c.Val()
|
||||||
if u.ViewMode != "mosaic" && u.ViewMode != "list" {
|
if u.ViewMode != filemanager.MosaicViewMode && u.ViewMode != filemanager.ListViewMode {
|
||||||
return nil, c.ArgErr()
|
return nil, c.ArgErr()
|
||||||
}
|
}
|
||||||
|
case "recaptcha_key":
|
||||||
|
if !c.NextArg() {
|
||||||
|
return nil, c.ArgErr()
|
||||||
|
}
|
||||||
|
|
||||||
|
reCaptchaKey = c.Val()
|
||||||
|
case "recaptcha_secret":
|
||||||
|
if !c.NextArg() {
|
||||||
|
return nil, c.ArgErr()
|
||||||
|
}
|
||||||
|
|
||||||
|
reCaptchaSecret = c.Val()
|
||||||
case "no_auth":
|
case "no_auth":
|
||||||
if !c.NextArg() {
|
if !c.NextArg() {
|
||||||
noAuth = true
|
noAuth = true
|
||||||
@@ -193,7 +208,7 @@ func Parse(c *caddy.Controller, plugin string) ([]*filemanager.FileManager, erro
|
|||||||
sha := hex.EncodeToString(hasher.Sum(nil))
|
sha := hex.EncodeToString(hasher.Sum(nil))
|
||||||
database = filepath.Join(path, sha+".db")
|
database = filepath.Join(path, sha+".db")
|
||||||
|
|
||||||
fmt.Println("[WARNING] A database is going to be created for your File Manager instace at " + database +
|
fmt.Println("[WARNING] A database is going to be created for your File Manager instance at " + database +
|
||||||
". It is highly recommended that you set the 'database' option to '" + sha + ".db'\n")
|
". It is highly recommended that you set the 'database' option to '" + sha + ".db'\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,10 +228,12 @@ func Parse(c *caddy.Controller, plugin string) ([]*filemanager.FileManager, erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
m := &filemanager.FileManager{
|
m := &filemanager.FileManager{
|
||||||
NoAuth: noAuth,
|
NoAuth: noAuth,
|
||||||
BaseURL: "",
|
BaseURL: "",
|
||||||
PrefixURL: "",
|
PrefixURL: "",
|
||||||
DefaultUser: u,
|
ReCaptchaKey: reCaptchaKey,
|
||||||
|
ReCaptchaSecret: reCaptchaSecret,
|
||||||
|
DefaultUser: u,
|
||||||
Store: &filemanager.Store{
|
Store: &filemanager.Store{
|
||||||
Config: bolt.ConfigStore{DB: db},
|
Config: bolt.ConfigStore{DB: db},
|
||||||
Users: bolt.UsersStore{DB: db},
|
Users: bolt.UsersStore{DB: db},
|
||||||
|
|||||||
+35
-25
@@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
"github.com/asdine/storm"
|
"github.com/asdine/storm"
|
||||||
|
|
||||||
lumberjack "gopkg.in/natefinch/lumberjack.v2"
|
"gopkg.in/natefinch/lumberjack.v2"
|
||||||
|
|
||||||
"github.com/hacdias/filemanager"
|
"github.com/hacdias/filemanager"
|
||||||
"github.com/hacdias/filemanager/bolt"
|
"github.com/hacdias/filemanager/bolt"
|
||||||
@@ -24,24 +24,26 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
addr string
|
addr string
|
||||||
config string
|
config string
|
||||||
database string
|
database string
|
||||||
scope string
|
scope string
|
||||||
commands string
|
commands string
|
||||||
logfile string
|
logfile string
|
||||||
staticg string
|
staticg string
|
||||||
locale string
|
locale string
|
||||||
baseurl string
|
baseurl string
|
||||||
prefixurl string
|
prefixurl string
|
||||||
viewMode string
|
viewMode string
|
||||||
port int
|
recaptchakey string
|
||||||
noAuth bool
|
recaptchasecret string
|
||||||
allowCommands bool
|
port int
|
||||||
allowEdit bool
|
noAuth bool
|
||||||
allowNew bool
|
allowCommands bool
|
||||||
allowPublish bool
|
allowEdit bool
|
||||||
showVer bool
|
allowNew bool
|
||||||
|
allowPublish bool
|
||||||
|
showVer bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -55,12 +57,14 @@ func init() {
|
|||||||
flag.StringVar(&commands, "commands", "git svn hg", "Default commands option for new users")
|
flag.StringVar(&commands, "commands", "git svn hg", "Default commands option for new users")
|
||||||
flag.StringVar(&prefixurl, "prefixurl", "", "Prefix URL")
|
flag.StringVar(&prefixurl, "prefixurl", "", "Prefix URL")
|
||||||
flag.StringVar(&viewMode, "view-mode", "mosaic", "Default view mode for new users")
|
flag.StringVar(&viewMode, "view-mode", "mosaic", "Default view mode for new users")
|
||||||
|
flag.StringVar(&recaptchakey, "recaptcha-key", "", "ReCaptcha site key")
|
||||||
|
flag.StringVar(&recaptchasecret, "recaptcha-secret", "", "ReCaptcha secret")
|
||||||
flag.BoolVar(&allowCommands, "allow-commands", true, "Default allow commands option for new users")
|
flag.BoolVar(&allowCommands, "allow-commands", true, "Default allow commands option for new users")
|
||||||
flag.BoolVar(&allowEdit, "allow-edit", true, "Default allow edit option for new users")
|
flag.BoolVar(&allowEdit, "allow-edit", true, "Default allow edit option for new users")
|
||||||
flag.BoolVar(&allowPublish, "allow-publish", true, "Default allow publish option for new users")
|
flag.BoolVar(&allowPublish, "allow-publish", true, "Default allow publish option for new users")
|
||||||
flag.BoolVar(&allowNew, "allow-new", true, "Default allow new option for new users")
|
flag.BoolVar(&allowNew, "allow-new", true, "Default allow new option for new users")
|
||||||
flag.BoolVar(&noAuth, "no-auth", false, "Disables authentication")
|
flag.BoolVar(&noAuth, "no-auth", false, "Disables authentication")
|
||||||
flag.StringVar(&locale, "locale", "en", "Default locale for new users")
|
flag.StringVar(&locale, "locale", "", "Default locale for new users, set it empty to enable auto detect from browser")
|
||||||
flag.StringVar(&staticg, "staticgen", "", "Static Generator you want to enable")
|
flag.StringVar(&staticg, "staticgen", "", "Static Generator you want to enable")
|
||||||
flag.BoolVarP(&showVer, "version", "v", false, "Show version")
|
flag.BoolVarP(&showVer, "version", "v", false, "Show version")
|
||||||
}
|
}
|
||||||
@@ -77,11 +81,13 @@ func setupViper() {
|
|||||||
viper.SetDefault("AllowNew", true)
|
viper.SetDefault("AllowNew", true)
|
||||||
viper.SetDefault("AllowPublish", true)
|
viper.SetDefault("AllowPublish", true)
|
||||||
viper.SetDefault("StaticGen", "")
|
viper.SetDefault("StaticGen", "")
|
||||||
viper.SetDefault("Locale", "en")
|
viper.SetDefault("Locale", "")
|
||||||
viper.SetDefault("NoAuth", false)
|
viper.SetDefault("NoAuth", false)
|
||||||
viper.SetDefault("BaseURL", "")
|
viper.SetDefault("BaseURL", "")
|
||||||
viper.SetDefault("PrefixURL", "")
|
viper.SetDefault("PrefixURL", "")
|
||||||
viper.SetDefault("ViewMode", "mosaic")
|
viper.SetDefault("ViewMode", filemanager.MosaicViewMode)
|
||||||
|
viper.SetDefault("ReCaptchaKey", "")
|
||||||
|
viper.SetDefault("ReCaptchaSecret", "")
|
||||||
|
|
||||||
viper.BindPFlag("Port", flag.Lookup("port"))
|
viper.BindPFlag("Port", flag.Lookup("port"))
|
||||||
viper.BindPFlag("Address", flag.Lookup("address"))
|
viper.BindPFlag("Address", flag.Lookup("address"))
|
||||||
@@ -99,6 +105,8 @@ func setupViper() {
|
|||||||
viper.BindPFlag("BaseURL", flag.Lookup("baseurl"))
|
viper.BindPFlag("BaseURL", flag.Lookup("baseurl"))
|
||||||
viper.BindPFlag("PrefixURL", flag.Lookup("prefixurl"))
|
viper.BindPFlag("PrefixURL", flag.Lookup("prefixurl"))
|
||||||
viper.BindPFlag("ViewMode", flag.Lookup("view-mode"))
|
viper.BindPFlag("ViewMode", flag.Lookup("view-mode"))
|
||||||
|
viper.BindPFlag("ReCaptchaKey", flag.Lookup("recaptcha-key"))
|
||||||
|
viper.BindPFlag("ReCaptchaSecret", flag.Lookup("recaptcha-secret"))
|
||||||
|
|
||||||
viper.SetConfigName("filemanager")
|
viper.SetConfigName("filemanager")
|
||||||
viper.AddConfigPath(".")
|
viper.AddConfigPath(".")
|
||||||
@@ -179,9 +187,11 @@ func handler() http.Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fm := &filemanager.FileManager{
|
fm := &filemanager.FileManager{
|
||||||
NoAuth: viper.GetBool("NoAuth"),
|
NoAuth: viper.GetBool("NoAuth"),
|
||||||
BaseURL: viper.GetString("BaseURL"),
|
BaseURL: viper.GetString("BaseURL"),
|
||||||
PrefixURL: viper.GetString("PrefixURL"),
|
PrefixURL: viper.GetString("PrefixURL"),
|
||||||
|
ReCaptchaKey: viper.GetString("ReCaptchaKey"),
|
||||||
|
ReCaptchaSecret: viper.GetString("ReCaptchaSecret"),
|
||||||
DefaultUser: &filemanager.User{
|
DefaultUser: &filemanager.User{
|
||||||
AllowCommands: viper.GetBool("AllowCommands"),
|
AllowCommands: viper.GetBool("AllowCommands"),
|
||||||
AllowEdit: viper.GetBool("AllowEdit"),
|
AllowEdit: viper.GetBool("AllowEdit"),
|
||||||
|
|||||||
@@ -133,6 +133,16 @@ func (i *File) GetListing(u *User, r *http.Request) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.HasPrefix(f.Mode().String(), "L") {
|
||||||
|
// It's a symbolic link
|
||||||
|
// The FileInfo from Readdir treats symbolic link as a file only.
|
||||||
|
info, err := os.Stat(f.Name())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
f = info
|
||||||
|
}
|
||||||
|
|
||||||
if f.IsDir() {
|
if f.IsDir() {
|
||||||
name += "/"
|
name += "/"
|
||||||
dirCount++
|
dirCount++
|
||||||
@@ -187,7 +197,6 @@ func (i *File) GetEditor() error {
|
|||||||
// If there is an error, just ignore it and return nil.
|
// If there is an error, just ignore it and return nil.
|
||||||
// This way, the file can be served for editing.
|
// This way, the file can be served for editing.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,15 +260,12 @@ func (i *File) GetFileType(checkContent bool) error {
|
|||||||
|
|
||||||
// If the type isn't text (and is blob for example), it will check some
|
// If the type isn't text (and is blob for example), it will check some
|
||||||
// common types that are mistaken not to be text.
|
// common types that are mistaken not to be text.
|
||||||
for _, extension := range textExtensions {
|
if isInTextExtensions(i.Name) {
|
||||||
if strings.HasSuffix(i.Name, extension) {
|
i.Type = "text"
|
||||||
i.Type = "text"
|
} else {
|
||||||
goto End
|
i.Type = "blob"
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i.Type = "blob"
|
|
||||||
|
|
||||||
End:
|
End:
|
||||||
// If the file type is text, save its content.
|
// If the file type is text, save its content.
|
||||||
if i.Type == "text" {
|
if i.Type == "text" {
|
||||||
@@ -405,21 +411,38 @@ func (l byModified) Less(i, j int) bool {
|
|||||||
return iModified.Sub(jModified) < 0
|
return iModified.Sub(jModified) < 0
|
||||||
}
|
}
|
||||||
|
|
||||||
var textExtensions = [...]string{
|
// textExtensions is the sorted list of text extensions which
|
||||||
".md", ".markdown", ".mdown", ".mmark",
|
// can be edited.
|
||||||
".asciidoc", ".adoc", ".ad",
|
var textExtensions = []string{
|
||||||
".rst",
|
".ad", ".ada", ".adoc", ".asciidoc",
|
||||||
".json", ".toml", ".yaml", ".csv", ".xml", ".rss", ".conf", ".ini",
|
".bas", ".bash", ".bat",
|
||||||
".tex", ".sty",
|
".c", ".cc", ".cmd", ".conf", ".cpp", ".cr", ".cs", ".css", ".csv",
|
||||||
".css", ".sass", ".scss",
|
".d",
|
||||||
".js",
|
".f", ".f90",
|
||||||
".html",
|
".h", ".hh", ".hpp", ".htaccess", ".html",
|
||||||
".txt", ".rtf",
|
".ini",
|
||||||
".sh", ".bash", ".ps1", ".bat", ".cmd",
|
".java", ".js", ".json",
|
||||||
".php", ".pl", ".py",
|
".markdown", ".md", ".mdown", ".mmark",
|
||||||
|
".nim",
|
||||||
|
".php", ".pl", ".ps1", ".py",
|
||||||
|
".rss", ".rst", ".rtf",
|
||||||
|
".sass", ".scss", ".sh", ".sty",
|
||||||
|
".tex", ".tml", ".toml", ".txt",
|
||||||
|
".vala", ".vapi",
|
||||||
|
".xml",
|
||||||
|
".yaml", ".yml",
|
||||||
"Caddyfile",
|
"Caddyfile",
|
||||||
".c", ".cc", ".h", ".hh", ".cpp", ".hpp", ".f90",
|
}
|
||||||
".f", ".bas", ".d", ".ada", ".nim", ".cr", ".java", ".cs", ".vala", ".vapi",
|
|
||||||
|
// isInTextExtensions checks if a file can be edited by its extensions.
|
||||||
|
func isInTextExtensions(name string) bool {
|
||||||
|
search := filepath.Ext(name)
|
||||||
|
if search == "" {
|
||||||
|
search = name
|
||||||
|
}
|
||||||
|
|
||||||
|
i := sort.SearchStrings(textExtensions, search)
|
||||||
|
return i < len(textExtensions) && textExtensions[i] == search
|
||||||
}
|
}
|
||||||
|
|
||||||
// hasRune checks if the file has the frontmatter rune
|
// hasRune checks if the file has the frontmatter rune
|
||||||
|
|||||||
+22
-5
@@ -15,14 +15,19 @@ import (
|
|||||||
|
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
|
|
||||||
rice "github.com/GeertJohan/go.rice"
|
"github.com/GeertJohan/go.rice"
|
||||||
"github.com/hacdias/fileutils"
|
"github.com/hacdias/fileutils"
|
||||||
"github.com/mholt/caddy"
|
"github.com/mholt/caddy"
|
||||||
"github.com/robfig/cron"
|
"github.com/robfig/cron"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Version is the current File Manager version.
|
const (
|
||||||
const Version = "1.3.2"
|
// Version is the current File Manager version.
|
||||||
|
Version = "1.4.2"
|
||||||
|
|
||||||
|
ListViewMode = "list"
|
||||||
|
MosaicViewMode = "mosaic"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrExist = errors.New("the resource already exists")
|
ErrExist = errors.New("the resource already exists")
|
||||||
@@ -33,7 +38,7 @@ var (
|
|||||||
ErrEmptyScope = errors.New("scope is empty")
|
ErrEmptyScope = errors.New("scope is empty")
|
||||||
ErrWrongDataType = errors.New("wrong data type")
|
ErrWrongDataType = errors.New("wrong data type")
|
||||||
ErrInvalidUpdateField = errors.New("invalid field to update")
|
ErrInvalidUpdateField = errors.New("invalid field to update")
|
||||||
ErrInvalidOption = errors.New("Invalid option")
|
ErrInvalidOption = errors.New("invalid option")
|
||||||
)
|
)
|
||||||
|
|
||||||
// FileManager is a file manager instance. It should be creating using the
|
// FileManager is a file manager instance. It should be creating using the
|
||||||
@@ -66,6 +71,10 @@ type FileManager struct {
|
|||||||
// there will only exist one user, called "admin".
|
// there will only exist one user, called "admin".
|
||||||
NoAuth bool
|
NoAuth bool
|
||||||
|
|
||||||
|
// ReCaptcha Site key and secret.
|
||||||
|
ReCaptchaKey string
|
||||||
|
ReCaptchaSecret string
|
||||||
|
|
||||||
// StaticGen is the static websit generator handler.
|
// StaticGen is the static websit generator handler.
|
||||||
StaticGen StaticGen
|
StaticGen StaticGen
|
||||||
|
|
||||||
@@ -201,6 +210,14 @@ func (m *FileManager) Setup() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: remove this after 1.5
|
||||||
|
for _, user := range users {
|
||||||
|
if user.ViewMode != ListViewMode && user.ViewMode != MosaicViewMode {
|
||||||
|
user.ViewMode = ListViewMode
|
||||||
|
m.Store.Users.Update(user, "ViewMode")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m.DefaultUser.Username = ""
|
m.DefaultUser.Username = ""
|
||||||
m.DefaultUser.Password = ""
|
m.DefaultUser.Password = ""
|
||||||
|
|
||||||
@@ -344,7 +361,7 @@ var DefaultUser = User{
|
|||||||
Rules: []*Rule{},
|
Rules: []*Rule{},
|
||||||
CSS: "",
|
CSS: "",
|
||||||
Admin: true,
|
Admin: true,
|
||||||
Locale: "en",
|
Locale: "",
|
||||||
Scope: ".",
|
Scope: ".",
|
||||||
FileSystem: fileutils.Dir("."),
|
FileSystem: fileutils.Dir("."),
|
||||||
ViewMode: "mosaic",
|
ViewMode: "mosaic",
|
||||||
|
|||||||
+57
-3
@@ -3,15 +3,56 @@ package http
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
jwt "github.com/dgrijalva/jwt-go"
|
"github.com/dgrijalva/jwt-go"
|
||||||
"github.com/dgrijalva/jwt-go/request"
|
"github.com/dgrijalva/jwt-go/request"
|
||||||
fm "github.com/hacdias/filemanager"
|
fm "github.com/hacdias/filemanager"
|
||||||
)
|
)
|
||||||
|
|
||||||
// authHandler proccesses the authentication for the user.
|
const reCaptchaAPI = "https://www.google.com/recaptcha/api/siteverify"
|
||||||
|
|
||||||
|
type cred struct {
|
||||||
|
Password string `json:"password"`
|
||||||
|
Username string `json:"username"`
|
||||||
|
ReCaptcha string `json:"recaptcha"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// reCaptcha checks the reCaptcha code.
|
||||||
|
func reCaptcha(secret string, response string) (bool, error) {
|
||||||
|
body := url.Values{}
|
||||||
|
body.Set("secret", secret)
|
||||||
|
body.Add("response", response)
|
||||||
|
|
||||||
|
client := &http.Client{}
|
||||||
|
|
||||||
|
resp, err := client.Post(reCaptchaAPI, "application/x-www-form-urlencoded", strings.NewReader(body.Encode()))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var data struct {
|
||||||
|
Success bool `json:"success"`
|
||||||
|
ChallengeTS time.Time `json:"challenge_ts"`
|
||||||
|
Hostname string `json:"hostname"`
|
||||||
|
ErrorCodes interface{} `json:"error-codes"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.NewDecoder(resp.Body).Decode(&data)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return data.Success, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// authHandler processes the authentication for the user.
|
||||||
func authHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func authHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
// NoAuth instances shouldn't call this method.
|
// NoAuth instances shouldn't call this method.
|
||||||
if c.NoAuth {
|
if c.NoAuth {
|
||||||
@@ -19,7 +60,7 @@ func authHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, er
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Receive the credentials from the request and unmarshal them.
|
// Receive the credentials from the request and unmarshal them.
|
||||||
var cred fm.User
|
var cred cred
|
||||||
if r.Body == nil {
|
if r.Body == nil {
|
||||||
return http.StatusForbidden, nil
|
return http.StatusForbidden, nil
|
||||||
}
|
}
|
||||||
@@ -29,6 +70,18 @@ func authHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, er
|
|||||||
return http.StatusForbidden, nil
|
return http.StatusForbidden, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If ReCaptcha is enabled, check the code.
|
||||||
|
if len(c.ReCaptchaSecret) > 0 {
|
||||||
|
ok, err := reCaptcha(c.ReCaptchaSecret, cred.ReCaptcha)
|
||||||
|
if err != nil {
|
||||||
|
return http.StatusForbidden, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !ok {
|
||||||
|
return http.StatusForbidden, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Checks if the user exists.
|
// Checks if the user exists.
|
||||||
u, err := c.Store.Users.GetByUsername(cred.Username, c.NewFS)
|
u, err := c.Store.Users.GetByUsername(cred.Username, c.NewFS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -124,6 +177,7 @@ func validateAuth(c *fm.Context, r *http.Request) (bool, *fm.User) {
|
|||||||
keyFunc := func(token *jwt.Token) (interface{}, error) {
|
keyFunc := func(token *jwt.Token) (interface{}, error) {
|
||||||
return c.Key, nil
|
return c.Key, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var claims claims
|
var claims claims
|
||||||
token, err := request.ParseFromRequestWithClaims(r,
|
token, err := request.ParseFromRequestWithClaims(r,
|
||||||
extractor{},
|
extractor{},
|
||||||
|
|||||||
+24
-10
@@ -17,21 +17,13 @@ import (
|
|||||||
// downloadHandler creates an archive in one of the supported formats (zip, tar,
|
// downloadHandler creates an archive in one of the supported formats (zip, tar,
|
||||||
// tar.gz or tar.bz2) and sends it to be downloaded.
|
// tar.gz or tar.bz2) and sends it to be downloaded.
|
||||||
func downloadHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func downloadHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
query := r.URL.Query().Get("format")
|
|
||||||
|
|
||||||
// If the file isn't a directory, serve it using http.ServeFile. We display it
|
// If the file isn't a directory, serve it using http.ServeFile. We display it
|
||||||
// inline if it is requested.
|
// inline if it is requested.
|
||||||
if !c.File.IsDir {
|
if !c.File.IsDir {
|
||||||
if r.URL.Query().Get("inline") == "true" {
|
return downloadFileHandler(c, w, r)
|
||||||
w.Header().Set("Content-Disposition", "inline")
|
|
||||||
} else {
|
|
||||||
w.Header().Set("Content-Disposition", "attachment; filename=\""+c.File.Name+"\"")
|
|
||||||
}
|
|
||||||
|
|
||||||
http.ServeFile(w, r, c.File.Path)
|
|
||||||
return 0, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
query := r.URL.Query().Get("format")
|
||||||
files := []string{}
|
files := []string{}
|
||||||
names := strings.Split(r.URL.Query().Get("files"), ",")
|
names := strings.Split(r.URL.Query().Get("files"), ",")
|
||||||
|
|
||||||
@@ -111,3 +103,25 @@ func downloadHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
|||||||
_, err = io.Copy(w, file)
|
_, err = io.Copy(w, file)
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func downloadFileHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
|
if r.URL.Query().Get("inline") == "true" {
|
||||||
|
w.Header().Set("Content-Disposition", "inline")
|
||||||
|
} else {
|
||||||
|
w.Header().Set("Content-Disposition", `attachment; filename="`+c.File.Name+`"`)
|
||||||
|
}
|
||||||
|
|
||||||
|
file, err := os.Open(c.File.Path)
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return http.StatusInternalServerError, err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = io.Copy(w, file)
|
||||||
|
if err != nil {
|
||||||
|
return http.StatusInternalServerError, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
+11
-10
@@ -25,16 +25,13 @@ func Handler(m *fm.FileManager) http.Handler {
|
|||||||
if code >= 400 {
|
if code >= 400 {
|
||||||
w.WriteHeader(code)
|
w.WriteHeader(code)
|
||||||
|
|
||||||
if err == nil {
|
txt := http.StatusText(code)
|
||||||
txt := http.StatusText(code)
|
log.Printf("%v: %v %v\n", r.URL.Path, code, txt)
|
||||||
log.Printf("%v: %v %v\n", r.URL.Path, code, txt)
|
w.Write([]byte(txt + "\n"))
|
||||||
w.Write([]byte(txt))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
w.Write([]byte(err.Error()))
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -226,10 +223,13 @@ func renderFile(c *fm.Context, w http.ResponseWriter, file string) (int, error)
|
|||||||
w.Header().Set("Content-Type", contentType+"; charset=utf-8")
|
w.Header().Set("Content-Type", contentType+"; charset=utf-8")
|
||||||
|
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"BaseURL": c.RootURL(),
|
"BaseURL": c.RootURL(),
|
||||||
"NoAuth": c.NoAuth,
|
"NoAuth": c.NoAuth,
|
||||||
"Version": fm.Version,
|
"Version": fm.Version,
|
||||||
"CSS": template.CSS(c.CSS),
|
"CSS": template.CSS(c.CSS),
|
||||||
|
"ReCaptcha": c.ReCaptchaKey != "" && c.ReCaptchaSecret != "",
|
||||||
|
"ReCaptchaKey": c.ReCaptchaKey,
|
||||||
|
"ReCaptchaSecret": c.ReCaptchaSecret,
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.StaticGen != nil {
|
if c.StaticGen != nil {
|
||||||
@@ -267,6 +267,7 @@ func sharePage(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, erro
|
|||||||
|
|
||||||
info, err := os.Stat(s.Path)
|
info, err := os.Stat(s.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
c.Store.Share.Delete(s.Hash)
|
||||||
return ErrorToHTTP(err, false), err
|
return ErrorToHTTP(err, false), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -160,6 +160,11 @@ func usersPostHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (in
|
|||||||
u.Rules = []*fm.Rule{}
|
u.Rules = []*fm.Rule{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the view mode is empty, initialize with the default one.
|
||||||
|
if u.ViewMode == "" {
|
||||||
|
u.ViewMode = c.DefaultUser.ViewMode
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize commands if not initialized.
|
// Initialize commands if not initialized.
|
||||||
if u.Commands == nil {
|
if u.Commands == nil {
|
||||||
u.Commands = []string{}
|
u.Commands = []string{}
|
||||||
@@ -182,6 +187,7 @@ func usersPostHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (in
|
|||||||
}
|
}
|
||||||
|
|
||||||
u.Password = pw
|
u.Password = pw
|
||||||
|
u.ViewMode = fm.MosaicViewMode
|
||||||
|
|
||||||
// Saves the user to the database.
|
// Saves the user to the database.
|
||||||
err = c.Store.Users.Save(u)
|
err = c.Store.Users.Save(u)
|
||||||
@@ -268,6 +274,13 @@ func usersPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
|||||||
return http.StatusBadRequest, err
|
return http.StatusBadRequest, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we're updating the default user. Only for NoAuth
|
||||||
|
// implementations. Used to change the viewMode.
|
||||||
|
if id == 0 && c.NoAuth {
|
||||||
|
c.DefaultUser.ViewMode = u.ViewMode
|
||||||
|
return http.StatusOK, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Updates the CSS and locale.
|
// Updates the CSS and locale.
|
||||||
if which == "partial" {
|
if which == "partial" {
|
||||||
c.User.CSS = u.CSS
|
c.User.CSS = u.CSS
|
||||||
|
|||||||
Generated
-9161
File diff suppressed because it is too large.
Load diff
+48
-47
@@ -10,62 +10,63 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"clipboard": "^1.7.1",
|
"clipboard": "^1.7.1",
|
||||||
"codemirror": "^5.27.4",
|
"codemirror": "^5.31.0",
|
||||||
"filesize": "^3.5.10",
|
"filesize": "^3.5.11",
|
||||||
"moment": "^2.18.1",
|
"js-base64": "^2.4.0",
|
||||||
|
"moment": "^2.19.2",
|
||||||
"normalize.css": "^7.0.0",
|
"normalize.css": "^7.0.0",
|
||||||
"noty": "^3.1.2",
|
"noty": "^3.1.3",
|
||||||
"vue": "^2.3.3",
|
"vue": "^2.5.8",
|
||||||
"vue-i18n": "^7.1.0",
|
"vue-i18n": "^7.3.2",
|
||||||
"vue-router": "^2.7.0",
|
"vue-router": "^3.0.1",
|
||||||
"vuex": "^2.3.1"
|
"vuex": "^3.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"autoprefixer": "^7.1.2",
|
"autoprefixer": "^7.1.6",
|
||||||
"babel-core": "^6.22.1",
|
"babel-core": "^6.26.0",
|
||||||
"babel-eslint": "^7.1.1",
|
"babel-eslint": "^8.0.2",
|
||||||
"babel-loader": "^7.1.1",
|
"babel-loader": "^7.1.2",
|
||||||
"babel-plugin-transform-runtime": "^6.22.0",
|
"babel-plugin-transform-runtime": "^6.23.0",
|
||||||
"babel-preset-env": "^1.3.2",
|
"babel-preset-env": "^1.6.1",
|
||||||
"babel-preset-stage-2": "^6.22.0",
|
"babel-preset-stage-2": "^6.24.1",
|
||||||
"babel-register": "^6.22.0",
|
"babel-register": "^6.26.0",
|
||||||
"chalk": "^2.0.1",
|
"chalk": "^2.3.0",
|
||||||
"connect-history-api-fallback": "^1.3.0",
|
"connect-history-api-fallback": "^1.5.0",
|
||||||
"copy-webpack-plugin": "^4.0.1",
|
"copy-webpack-plugin": "^4.2.1",
|
||||||
"css-loader": "^0.28.0",
|
"css-loader": "^0.28.7",
|
||||||
"eslint": "^4.3.0",
|
"eslint": "^4.11.0",
|
||||||
"eslint-config-standard": "^10.2.1",
|
"eslint-config-standard": "^10.2.1",
|
||||||
"eslint-friendly-formatter": "^3.0.0",
|
"eslint-friendly-formatter": "^3.0.0",
|
||||||
"eslint-loader": "^1.7.1",
|
"eslint-loader": "^1.9.0",
|
||||||
"eslint-plugin-html": "^3.1.1",
|
"eslint-plugin-html": "^4.0.0",
|
||||||
"eslint-plugin-import": "^2.7.0",
|
"eslint-plugin-import": "^2.8.0",
|
||||||
"eslint-plugin-node": "^5.1.1",
|
"eslint-plugin-node": "^5.2.1",
|
||||||
"eslint-plugin-promise": "^3.4.0",
|
"eslint-plugin-promise": "^3.6.0",
|
||||||
"eslint-plugin-standard": "^3.0.1",
|
"eslint-plugin-standard": "^3.0.1",
|
||||||
"eventsource-polyfill": "^0.9.6",
|
"eventsource-polyfill": "^0.9.6",
|
||||||
"express": "^4.14.1",
|
"express": "^4.16.2",
|
||||||
"extract-text-webpack-plugin": "^3.0.0",
|
"extract-text-webpack-plugin": "^3.0.2",
|
||||||
"file-loader": "^0.11.1",
|
"file-loader": "^1.1.5",
|
||||||
"friendly-errors-webpack-plugin": "^1.1.3",
|
"friendly-errors-webpack-plugin": "^1.6.1",
|
||||||
"html-webpack-plugin": "^2.28.0",
|
"html-webpack-plugin": "^2.30.1",
|
||||||
"http-proxy-middleware": "^0.17.3",
|
"http-proxy-middleware": "^0.17.4",
|
||||||
"opn": "^5.1.0",
|
"opn": "^5.1.0",
|
||||||
"optimize-css-assets-webpack-plugin": "^3.0.0",
|
"optimize-css-assets-webpack-plugin": "^3.2.0",
|
||||||
"ora": "^1.2.0",
|
"ora": "^1.3.0",
|
||||||
"rimraf": "^2.6.0",
|
"rimraf": "^2.6.2",
|
||||||
"semver": "^5.3.0",
|
"semver": "^5.4.1",
|
||||||
"shelljs": "^0.7.6",
|
"shelljs": "^0.7.8",
|
||||||
"sw-precache-webpack-plugin": "^0.11.4",
|
"sw-precache-webpack-plugin": "^0.11.4",
|
||||||
"uglify-js": "^3.0.23",
|
"uglify-js": "^3.1.10",
|
||||||
"url-loader": "^0.5.8",
|
"url-loader": "^0.6.2",
|
||||||
"vue-loader": "^13.0.2",
|
"vue-loader": "^13.5.0",
|
||||||
"vue-style-loader": "^3.0.1",
|
"vue-style-loader": "^3.0.3",
|
||||||
"vue-template-compiler": "^2.3.3",
|
"vue-template-compiler": "^2.5.8",
|
||||||
"webpack": "^3.4.1",
|
"webpack": "^3.8.1",
|
||||||
"webpack-bundle-analyzer": "^2.2.1",
|
"webpack-bundle-analyzer": "^2.9.1",
|
||||||
"webpack-dev-middleware": "^1.10.0",
|
"webpack-dev-middleware": "^1.12.0",
|
||||||
"webpack-hot-middleware": "^2.18.0",
|
"webpack-hot-middleware": "^2.20.0",
|
||||||
"webpack-merge": "^4.1.0",
|
"webpack-merge": "^4.1.1",
|
||||||
"yml-loader": "^2.1.0"
|
"yml-loader": "^2.1.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
36b9bba06c64cd83f3994bbb77fc36948d9d2dfe
|
6e37237fbee662acdaf51c879107db450ea135ed
|
||||||
+2
-1
@@ -84,7 +84,8 @@ func (h Hugo) Hook(c *fm.Context, w http.ResponseWriter, r *http.Request) (int,
|
|||||||
return http.StatusForbidden, nil
|
return http.StatusForbidden, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
filename := filepath.Join(c.User.Scope, r.URL.Path)
|
filename := filepath.Clean(r.URL.Path)
|
||||||
|
filename = strings.TrimPrefix(filename, string(filepath.Separator))
|
||||||
archetype := r.Header.Get("archetype")
|
archetype := r.Header.Get("archetype")
|
||||||
|
|
||||||
ext := filepath.Ext(filename)
|
ext := filepath.Ext(filename)
|
||||||
|
|||||||
Reference in new issue
Block a user