Compare commits
114 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c7c507830 | ||
|
|
bc8d19feff | ||
|
|
f77009365f | ||
|
|
74e93b8df0 | ||
|
|
901dc2c160 | ||
|
|
b5ee82c943 | ||
|
|
8e4805ba69 | ||
|
|
694c750561 | ||
|
|
efa3b3f198 | ||
|
|
998dd9430d | ||
|
|
c8b5728743 | ||
|
|
fab33e3ed1 | ||
|
|
5079f405fc | ||
|
|
b85a07536d | ||
|
|
7e3a15e073 | ||
|
|
aeb4e2aab3 | ||
|
|
bd65bc9e44 | ||
|
|
59468830bb | ||
|
|
d7c3665e2b | ||
|
|
679b0f0f4e | ||
|
|
7d912dd257 | ||
|
|
a92d7aab8e | ||
|
|
0536d8342c | ||
|
|
93acf4a6f7 | ||
|
|
dd8f47fade | ||
|
|
3f4db6b81e | ||
|
|
e471e79d50 | ||
|
|
6b4bce5daf | ||
|
|
b66adcb582 | ||
|
|
5ec06fa0cd | ||
|
|
c163318ce5 | ||
|
|
98dabff1e7 | ||
|
|
50dcf35eda | ||
|
|
769e634bdd | ||
|
|
dead024e53 | ||
|
|
f4982cff5e | ||
|
|
bfbb7b5ee1 | ||
|
|
7c09473312 | ||
|
|
b6a8472722 | ||
|
|
db01cfa2f0 | ||
|
|
4267ebf0b4 | ||
|
|
d4e9f5ba53 | ||
|
|
4ace991b8a | ||
|
|
e0c91bb747 | ||
|
|
557e5922d2 | ||
|
|
cea4d2aae9 | ||
|
|
bb5c041d5c | ||
|
|
bf1ef5b0f8 | ||
|
|
08ebe0fbb0 | ||
|
|
bdd7c269ed | ||
|
|
292ef7ea8a | ||
|
|
03ab2199d4 | ||
|
|
41489f9e89 | ||
|
|
3bc5f6e0df | ||
|
|
42d33cf595 | ||
|
|
0fbde826bf | ||
|
|
578f3e9bdd | ||
|
|
f1e5cd490e | ||
|
|
40b0cd4b66 | ||
|
|
f9e3923ae7 | ||
|
|
32f7efbde5 | ||
|
|
56e5005484 | ||
|
|
6bf0e8c063 | ||
|
|
7445d73cf6 | ||
|
|
af095a71e7 | ||
|
|
ab87f76dcb | ||
|
|
2cbe941202 | ||
|
|
5e58c25aa4 | ||
|
|
bdfca1be33 | ||
|
|
281b8dca23 | ||
|
|
2761302ddf | ||
|
|
06f0d36dd8 | ||
|
|
a8863ec90b | ||
|
|
3ed5a64cef | ||
|
|
013c24733e | ||
|
|
d9d6fb656a | ||
|
|
eb72c5d959 | ||
|
|
03bdc57334 | ||
|
|
00e80365da | ||
|
|
aeba656a3b | ||
|
|
dd40590ee6 | ||
|
|
3ffb64abcd | ||
|
|
2dbb080fa2 | ||
|
|
f014828ee6 | ||
|
|
bab6b7760b | ||
|
|
e278dbba65 | ||
|
|
5a8c28fa6d | ||
|
|
e7e2edf76c | ||
|
|
dd2d02e492 | ||
|
|
735e74a858 | ||
|
|
7fc2414476 | ||
|
|
822b8f8e05 | ||
|
|
2d63c288e4 | ||
|
|
218a96eebd | ||
|
|
4fbef557ee | ||
|
|
0a4c803650 | ||
|
|
68c5b8cd52 | ||
|
|
0cff87be24 | ||
|
|
a2fcb8b3b0 | ||
|
|
5eb9e95720 | ||
|
|
967d4e28de | ||
|
|
ee53803fc2 | ||
|
|
fa2ab280aa | ||
|
|
395801016b | ||
|
|
30ed82a70f | ||
|
|
ab643cd0c4 | ||
|
|
85e5beaa4a | ||
|
|
3cab34c68b | ||
|
|
8299f8ed06 | ||
|
|
da05c5048e | ||
|
|
071e1ec19b | ||
|
|
8884e68806 | ||
|
|
68bfbe5103 | ||
|
|
4a7bdfc59b |
@@ -1,79 +0,0 @@
|
||||
version: 2
|
||||
jobs:
|
||||
linting:
|
||||
docker:
|
||||
- image: circleci/golang:1.9
|
||||
working_directory: /go/src/github.com/filebrowser/filebrowser
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Install Dependencies
|
||||
command: |
|
||||
cd cmd/filebrowser && go get ./... && cd ../..
|
||||
go get github.com/alecthomas/gometalinter
|
||||
gometalinter --install
|
||||
- run:
|
||||
name: Run linting
|
||||
command: |
|
||||
gometalinter --exclude="rice-box.go" \
|
||||
-D goconst \
|
||||
-D gocyclo \
|
||||
-D vetshadow \
|
||||
-D errcheck \
|
||||
-D golint \
|
||||
-D gas
|
||||
build:
|
||||
docker:
|
||||
- image: circleci/golang:1.9
|
||||
working_directory: /go/src/github.com/filebrowser/filebrowser
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Install Dependencies
|
||||
command: |
|
||||
cd cmd/filebrowser
|
||||
go get ./...
|
||||
- run:
|
||||
name: Building
|
||||
command: go build
|
||||
deploy:
|
||||
docker:
|
||||
- image: circleci/golang:1.9
|
||||
working_directory: /go/src/github.com/filebrowser/filebrowser
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Install Dependencies
|
||||
command: |
|
||||
cd cmd/filebrowser
|
||||
go get ./...
|
||||
cd ../..
|
||||
- run:
|
||||
name: Deploy
|
||||
command: curl -sL https://git.io/goreleaser | bash
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
lint-build-deploy:
|
||||
jobs:
|
||||
- linting:
|
||||
filters:
|
||||
tags:
|
||||
only: /.*/
|
||||
branches:
|
||||
only: /.*/
|
||||
- build:
|
||||
filters:
|
||||
tags:
|
||||
only: /.*/
|
||||
branches:
|
||||
only: /.*/
|
||||
- deploy:
|
||||
requires:
|
||||
- linting
|
||||
- build
|
||||
filters:
|
||||
tags:
|
||||
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
|
||||
branches:
|
||||
ignore: /.*/
|
||||
@@ -1,2 +1,3 @@
|
||||
testdata/
|
||||
.github/
|
||||
testdata/
|
||||
.github/
|
||||
**.git
|
||||
|
||||
24
.github/ISSUE_TEMPLATE.md
vendored
24
.github/ISSUE_TEMPLATE.md
vendored
@@ -1,24 +0,0 @@
|
||||
### Instructions (remove before submitting):
|
||||
|
||||
1. Are you asking for help with using Caddy or File Manager? Please use our forum instead: https://forum.caddyserver.com.
|
||||
2. If you are filing a bug report, please answer the following questions.
|
||||
3. If your issue is not a bug report, you do not need to use this template.
|
||||
4. If not using with Caddy, ignore questions 1 and 2.
|
||||
|
||||
### 1. Have you downloaded File Manager from caddyserver.com? If yes, when have you done that? If no, and you are running a custom build, which is the revision of File Manager's repository?
|
||||
|
||||
### 2. What is your entire Caddyfile?
|
||||
```text
|
||||
(Put Caddyfile here)
|
||||
```
|
||||
|
||||
### 3. What are you trying to do?
|
||||
|
||||
|
||||
### 4. What did you expect to see?
|
||||
|
||||
|
||||
### 5. What did you see instead (give full error messages and/or log)?
|
||||
|
||||
|
||||
### 6. How can someone who is starting from scratch reproduce this behaviour as minimally as possible?
|
||||
22
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
22
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
---
|
||||
|
||||
**Description**
|
||||
A clear and concise description of what the issue is about. What are you trying to do?
|
||||
|
||||
**Expected behaviour**
|
||||
What did you expect to happen?
|
||||
|
||||
**What is happening instead?**
|
||||
Please, give full error messages and/or log.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here. If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**How to reproduce?**
|
||||
Tell us how to reproduce this issue. How can someone who is starting from scratch reproduce this behaviour as minimally as possible?
|
||||
|
||||
**Files**
|
||||
A list of relevant files for this issue. Large files can be uploaded one-by-one or in a tarball/zipfile.
|
||||
33
.github/ISSUE_TEMPLATE/caddy_bug_report.md
vendored
Normal file
33
.github/ISSUE_TEMPLATE/caddy_bug_report.md
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
---
|
||||
name: Caddy related bug report
|
||||
about: Create a report to help us improve
|
||||
---
|
||||
|
||||
**Are you asking for help with using Caddy or File Browser?**
|
||||
Please use our forum instead: https://forum.caddyserver.com.
|
||||
|
||||
**When did you download File Browser from caddyserver.com?**
|
||||
|
||||
**What is your entire Caddyfile?**
|
||||
|
||||
```text
|
||||
(Put Caddyfile here)
|
||||
```
|
||||
|
||||
**Description**
|
||||
A clear and concise description of what the issue is about. What are you trying to do?
|
||||
|
||||
**Expected behaviour**
|
||||
What did you expect to happen?
|
||||
|
||||
**What is happening instead?**
|
||||
Please, give full error messages and/or log.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here. If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**How to reproduce?**
|
||||
Tell us how to reproduce this issue. How can someone who is starting from scratch reproduce this behaviour as minimally as possible?
|
||||
|
||||
**Files**
|
||||
A list of relevant files for this issue. Large files can be uploaded one-by-one or in a tarball/zipfile.
|
||||
16
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
16
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
Add a clear and concise description of what the problem is. E.g. *I'm always frustrated when [...]*
|
||||
|
||||
**Describe the solution you'd like**
|
||||
Add a clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
Add a clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
16
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
16
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
**Description**
|
||||
Please explain the changes you made here.
|
||||
If the feature changes current behaviour, explain why your solution is better.
|
||||
|
||||
:rotating_light: Before submitting your PR, please read [community](https://github.com/filebrowser/community), and indicate which issues (in any of the repos) are either fixed or closed by this PR. See [GitHub Help: Closing issues using keywords](https://help.github.com/articles/closing-issues-via-commit-messages/).
|
||||
|
||||
- [ ] DO make sure you are requesting to **pull a topic/feature/bugfix branch** (right side). Don't request your master!
|
||||
- [ ] DO make sure you are making a pull request against the **master branch** (left side). Also you should start *your branch* off *our master*.
|
||||
- [ ] DO make sure that File Browser can be successfully built. See [builds](https://github.com/filebrowser/community/blob/master/builds.md) and [development](https://github.com/filebrowser/community/blob/master/development.md).
|
||||
- [ ] DO make sure that related issues are opened in other repositories. I.e., the frontend, caddy plugins or the web page need to be updated accordingly.
|
||||
- [ ] AVOID breaking the continuous integration build.
|
||||
|
||||
**Further comments**
|
||||
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did, what alternatives you considered, etc.
|
||||
|
||||
:heart: Thank you!
|
||||
13
.gitignore
vendored
13
.gitignore
vendored
@@ -1,12 +1,15 @@
|
||||
.DS_Store
|
||||
node_modules/
|
||||
*/dist/*
|
||||
*.db
|
||||
*.db.lock
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
.idea
|
||||
.vscode
|
||||
Dockerfile
|
||||
filebrowser
|
||||
rice-box.go
|
||||
vendor
|
||||
npm-debug.log*
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
yarn.lock
|
||||
|
||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "frontend"]
|
||||
path = frontend
|
||||
url = https://github.com/filebrowser/frontend
|
||||
20
.golangci.yml
Normal file
20
.golangci.yml
Normal file
@@ -0,0 +1,20 @@
|
||||
run:
|
||||
deadline: 5m
|
||||
|
||||
linters:
|
||||
enable:
|
||||
- deadcode
|
||||
- govet
|
||||
- ineffassign
|
||||
- interfacer
|
||||
- maligned
|
||||
- megacheck
|
||||
- structcheck
|
||||
- unconvert
|
||||
- varcheck
|
||||
enable-all: false
|
||||
disable-all: true
|
||||
# presets:
|
||||
# - bugs
|
||||
# - unused
|
||||
fast: false
|
||||
@@ -1,37 +1,59 @@
|
||||
build:
|
||||
main: cmd/filebrowser/main.go
|
||||
binary: filebrowser
|
||||
goos:
|
||||
- darwin
|
||||
- linux
|
||||
- windows
|
||||
- freebsd
|
||||
- netbsd
|
||||
- openbsd
|
||||
- dragonfly
|
||||
- solaris
|
||||
goarch:
|
||||
- amd64
|
||||
- 386
|
||||
- arm
|
||||
- arm64
|
||||
- mips
|
||||
- mips64
|
||||
- mipsle
|
||||
- mips64le
|
||||
ignore:
|
||||
- goos: openbsd
|
||||
goarch: arm
|
||||
goarm: 6
|
||||
- goos: freebsd
|
||||
goarch: arm
|
||||
goarm: 6
|
||||
- goos: linux
|
||||
goarch: arm64
|
||||
|
||||
archive:
|
||||
name_template: "{{.Os}}-{{.Arch}}-{{ .ProjectName }}"
|
||||
format: tar.gz
|
||||
format_overrides:
|
||||
- goos: windows
|
||||
format: zip
|
||||
project_name: filebrowser
|
||||
|
||||
build:
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
main: cli/main.go
|
||||
binary: filebrowser
|
||||
goos:
|
||||
- darwin
|
||||
- linux
|
||||
- windows
|
||||
- freebsd
|
||||
- netbsd
|
||||
- openbsd
|
||||
- dragonfly
|
||||
- solaris
|
||||
goarch:
|
||||
- amd64
|
||||
- 386
|
||||
- arm
|
||||
- arm64
|
||||
goarm:
|
||||
- 5
|
||||
- 6
|
||||
- 7
|
||||
ignore:
|
||||
- goos: darwin
|
||||
goarch: 386
|
||||
- goos: openbsd
|
||||
goarch: arm
|
||||
- goos: freebsd
|
||||
goarch: arm
|
||||
- goos: netbsd
|
||||
goarch: arm
|
||||
- goos: solaris
|
||||
goarch: arm
|
||||
|
||||
archive:
|
||||
name_template: "{{.Os}}-{{.Arch}}{{if .Arm}}v{{.Arm}}{{end}}-{{ .ProjectName }}"
|
||||
format: tar.gz
|
||||
format_overrides:
|
||||
- goos: windows
|
||||
format: zip
|
||||
|
||||
release:
|
||||
disable: true
|
||||
|
||||
dockers:
|
||||
-
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
goarm: ''
|
||||
image: filebrowser/filebrowser
|
||||
skip_push: true
|
||||
tag_templates:
|
||||
- "{{ .Tag }}"
|
||||
- latest
|
||||
extra_files:
|
||||
- Docker.json
|
||||
|
||||
50
.travis.yml
Normal file
50
.travis.yml
Normal file
@@ -0,0 +1,50 @@
|
||||
os: linux
|
||||
services: docker
|
||||
language: minimal
|
||||
install: skip
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- docker-ce
|
||||
- pass
|
||||
env:
|
||||
global:
|
||||
- USE_DOCKER="true"
|
||||
stages:
|
||||
- lint
|
||||
- test
|
||||
- release
|
||||
cache:
|
||||
directories:
|
||||
- lib/rice-box.go
|
||||
jobs:
|
||||
include:
|
||||
- stage: lint
|
||||
script: "./build/run_linters.sh"
|
||||
- stage: test
|
||||
script: "./build/build_all.sh"
|
||||
deploy:
|
||||
provider: script
|
||||
skip_cleanup: true
|
||||
script: docker build -t filebrowser/filebrowser . && ./build/docker_login.sh && docker push filebrowser/filebrowser && docker logout
|
||||
on:
|
||||
tags: false
|
||||
repo: filebrowser/filebrowser
|
||||
branch: master
|
||||
- stage: release
|
||||
script:
|
||||
- docker run --rm -itv $(pwd):/src -w /src -v /var/run/docker.sock:/var/run/docker.sock filebrowser/dev sh -c "go get ./... && goreleaser"
|
||||
- ./build/push_images.sh
|
||||
- ./build/push_ricebox.sh
|
||||
if: tag IS present
|
||||
deploy:
|
||||
provider: releases
|
||||
skip_cleanup: true
|
||||
api_key:
|
||||
secure: GCURbl9xmjOmeNc7cYSvfSwbEp46cacWmJRczcsU6rQa0aWqzjELYdyIsl6HWW+o0dzuZvbWRD6muxYqIud92oPLYDuXSnra9tM3mCjswrjiPCJ57bksWkSPBfFQcxIyB6c3o+A/FMnX3nnSE/2r5HYZnPNFbEcBbC7WSgwx9ejXUuyWn1PUFK9YQWANdl6J7b7EKsk+9MxS9Pmw6M2ycBwX8ScUQdofkUPvR/nqlXISm+3hs30VubqQi9Ha6DM9Bw3aFK3/Ts/ujCOxP1ZoMCBZ6tfnaQOElIG96WTwnt77eDYlZezBOLym3Z18iif+Qny+XndFKDbexaiUT06VlWFXCKtt3iLs6HJwRcjmiHmB0Z3v+W4cKPl3cEyxxrU2aal54k1PBhU+5L0Xc8ileKbDMYg5tps88zWHNefeZVfaxYSVrmUHkuygMe481oaBLacDXTxs4t6XEpStREuLmvx9NLTwTFAbWjMNM0PqlueDMxO4bdwNvzXg/TcKLWV9FezqAlre8lFNZK5wX6lKFVSZ3hFjxCfwrJL2cPwg5A8Yd5EOC4Nh81WdgYuFGOxZzMAoSJlaVRvQS1trCUP/++ONnDep3ExSxvw4B7vijGZWeXUhrOMiPQHXu+t6BnrlnDjQ4gi44QTW0y/iM2WC2DBKfgYjAKwyHx13hFrmOCg=
|
||||
file: "dist/*.*"
|
||||
file_glob: true
|
||||
on:
|
||||
repo: filebrowser/filebrowser
|
||||
all_branches: true
|
||||
tags: true
|
||||
12
Docker.json
12
Docker.json
@@ -2,9 +2,11 @@
|
||||
"port": 80,
|
||||
"address": "",
|
||||
"database": "/database.db",
|
||||
"scope": "/srv",
|
||||
"allowCommands": true,
|
||||
"allowEdit": true,
|
||||
"allowNew": true,
|
||||
"commands": []
|
||||
"defaults": {
|
||||
"scope": "/srv",
|
||||
"allowCommands": true,
|
||||
"allowEdit": true,
|
||||
"allowNew": true,
|
||||
"commands": []
|
||||
}
|
||||
}
|
||||
|
||||
36
Dockerfile
36
Dockerfile
@@ -1,24 +1,12 @@
|
||||
|
||||
FROM golang:alpine
|
||||
|
||||
COPY . /go/src/github.com/filebrowser/filebrowser
|
||||
|
||||
WORKDIR /go/src/github.com/filebrowser/filebrowser
|
||||
RUN apk add --no-cache git
|
||||
RUN go get ./...
|
||||
|
||||
WORKDIR /go/src/github.com/filebrowser/filebrowser/cmd/filebrowser
|
||||
RUN CGO_ENABLED=0 go build -a
|
||||
RUN mv filebrowser /go/bin/filebrowser
|
||||
|
||||
FROM scratch
|
||||
COPY --from=0 /go/bin/filebrowser /filebrowser
|
||||
|
||||
VOLUME /tmp
|
||||
VOLUME /srv
|
||||
EXPOSE 80
|
||||
|
||||
COPY Docker.json /config.json
|
||||
|
||||
ENTRYPOINT ["/filebrowser"]
|
||||
CMD ["--config", "/config.json"]
|
||||
FROM scratch
|
||||
|
||||
COPY --from=filebrowser/dev /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||
|
||||
VOLUME /tmp
|
||||
VOLUME /srv
|
||||
EXPOSE 80
|
||||
|
||||
COPY filebrowser /filebrowser
|
||||
COPY Docker.json /.filebrowser.json
|
||||
|
||||
ENTRYPOINT ["/filebrowser"]
|
||||
|
||||
161
README.md
161
README.md
@@ -1,75 +1,86 @@
|
||||

|
||||
|
||||
# filebrowser
|
||||
|
||||
[](https://circleci.com/gh/filebrowser/filebrowser)
|
||||
[](https://goreportcard.com/report/github.com/filebrowser/filebrowser)
|
||||
[](http://godoc.org/github.com/filebrowser/filebrowser)
|
||||
[](https://github.com/filebrowser/filebrowser/releases/latest)
|
||||
|
||||
filebrowser 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.
|
||||
|
||||
# Table of contents
|
||||
|
||||
+ [Getting started](#getting-started)
|
||||
+ [Features](#features)
|
||||
- [Users](#users)
|
||||
- [Search](#search)
|
||||
+ [Contributing](#contributing)
|
||||
+ [Donate](#donate)
|
||||
|
||||
# Getting started
|
||||
|
||||
You can find the Getting Started guide on the [documentation](https://filebrowser.github.io/quick-start/).
|
||||
|
||||
# Features
|
||||
|
||||
Easy login system.
|
||||
|
||||

|
||||
|
||||
Listings of your files, available in two styles: mosaic and list. You can delete, move, rename, upload and create new files, as well as directories. Single files can be downloaded directly, and multiple files as *.zip*, *.tar*, *.tar.gz*, *.tar.bz2* or *.tar.xz*.
|
||||
|
||||

|
||||
|
||||
File Manager editor is powered by [Codemirror](https://codemirror.net/) and if you're working with markdown files with metadata, both parts will be separated from each other so you can focus on the content.
|
||||
|
||||

|
||||
|
||||
On the settings page, a regular user can set its own custom CSS to personalize the experience and change its password. For admins, they can manage the permissions of each user, set commands which can be executed when certain events are triggered (such as before saving and after saving) and change plugin's settings.
|
||||
|
||||

|
||||
|
||||
We also allow the users to search in the directories and execute commands if allowed.
|
||||
|
||||
## Users
|
||||
|
||||
We support multiple users and each user can have its own scope and custom stylesheet. The administrator is able to choose which permissions should be given to the users, as well as the commands they can execute. Each user also have a set of rules, in which he can be prevented or allowed to access some directories (regular expressions included!).
|
||||
|
||||

|
||||
|
||||
## Search
|
||||
|
||||
File Browser allows you to search through your files and it has some options. By default, your search will be something like this:
|
||||
|
||||
```
|
||||
this are keywords
|
||||
```
|
||||
|
||||
If you search for that it will look at every file that contains "this", "are" or "keywords" on their name. If you want to search for an exact term, you should surround your search by double quotes:
|
||||
|
||||
```
|
||||
"this is the name"
|
||||
```
|
||||
|
||||
That will search for any file that contains "this is the name" on its name. It won't search for each separated term this time.
|
||||
|
||||
By default, every search will be case sensitive. Although, you can make a case insensitive search by adding `case:insensitive` to the search terms, like this:
|
||||
|
||||
```
|
||||
this are keywords case:insensitive
|
||||
```
|
||||
|
||||
# Contributing
|
||||
|
||||
The contributing guidelines can be found [here](https://github.com/filebrowser/community).
|
||||
ℹ INFO: **This project is not under active development ATM. A small group of developers keeps the project alive, but due to lack of time, we can't continue adding new features or doing deep changes. Please read [#532](https://github.com/filebrowser/filebrowser/issues/532) for more info!**
|
||||
|
||||
ℹ INFO: in Q2 2018, this project was renamed from `filemanager` to `filebrowser`, and the main repo was moved from [hacdias/filemanager](https://github.com/hacdias/filemanager) to [filebrowser/filebrowser](https://github.com/filebrowser/filebrowser). At the same time, the official docker image was changed to [`filebrowser/filebrowser`](https://hub.docker.com/r/filebrowser/filebrowser/). Users are encouraged to check their sources and update them accordingly.
|
||||
|
||||
---
|
||||
|
||||
<p align="center">
|
||||
<img src="https://raw.githubusercontent.com/filebrowser/logo/master/banner.png" width="550"/>
|
||||
</p>
|
||||
|
||||

|
||||
|
||||
# filebrowser
|
||||
|
||||
[](https://travis-ci.com/filebrowser/filebrowser)
|
||||
[](https://goreportcard.com/report/github.com/filebrowser/filebrowser)
|
||||
[](http://godoc.org/github.com/filebrowser/filebrowser)
|
||||
[](https://github.com/filebrowser/filebrowser/releases/latest)
|
||||
[](http://webchat.freenode.net/?channels=%23filebrowser)
|
||||
|
||||
filebrowser 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.
|
||||
|
||||
# Table of contents
|
||||
|
||||
+ [Getting started](#getting-started)
|
||||
+ [Features](#features)
|
||||
- [Users](#users)
|
||||
- [Search](#search)
|
||||
+ [Contributing](#contributing)
|
||||
+ [Donate](#donate)
|
||||
|
||||
# Getting started
|
||||
|
||||
You can find the Getting Started guide on the [documentation](https://filebrowser.github.io/quick-start/).
|
||||
|
||||
# Features
|
||||
|
||||
Easy login system.
|
||||
|
||||

|
||||
|
||||
Listings of your files, available in two styles: mosaic and list. You can delete, move, rename, upload and create new files, as well as directories. Single files can be downloaded directly, and multiple files as *.zip*, *.tar*, *.tar.gz*, *.tar.bz2* or *.tar.xz*.
|
||||
|
||||

|
||||
|
||||
File Browser editor is powered by [Codemirror](https://codemirror.net/) and if you're working with markdown files with metadata, both parts will be separated from each other so you can focus on the content.
|
||||
|
||||

|
||||
|
||||
On the settings page, a regular user can set its own custom CSS to personalize the experience and change its password. For admins, they can manage the permissions of each user, set commands which can be executed when certain events are triggered (such as before saving and after saving) and change plugin's settings.
|
||||
|
||||

|
||||
|
||||
We also allow the users to search in the directories and execute commands if allowed.
|
||||
|
||||
## Users
|
||||
|
||||
We support multiple users and each user can have its own scope and custom stylesheet. The administrator is able to choose which permissions should be given to the users, as well as the commands they can execute. Each user also have a set of rules, in which he can be prevented or allowed to access some directories (regular expressions included!).
|
||||
|
||||

|
||||
|
||||
## Search
|
||||
|
||||
File Browser allows you to search through your files and it has some options. By default, your search will be something like this:
|
||||
|
||||
```
|
||||
this are keywords
|
||||
```
|
||||
|
||||
If you search for that it will look at every file that contains "this", "are" or "keywords" on their name. If you want to search for an exact term, you should surround your search by double quotes:
|
||||
|
||||
```
|
||||
"this is the name"
|
||||
```
|
||||
|
||||
That will search for any file that contains "this is the name" on its name. It won't search for each separated term this time.
|
||||
|
||||
By default, every search will be case insensitive. Although, you can make a case sensitive search by adding `case:sensitive` to the search terms, like this:
|
||||
|
||||
```
|
||||
this are keywords case:sensitive
|
||||
```
|
||||
|
||||
# Contributing
|
||||
|
||||
The contributing guidelines can be found [here](https://github.com/filebrowser/community).
|
||||
|
||||
20
build/build.sh
Executable file
20
build/build.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)/../cli
|
||||
|
||||
go get -v ./...
|
||||
|
||||
if [ "$COMMIT_SHA" != "" ]; then
|
||||
echo "Set version to ($COMMIT_SHA)"
|
||||
sed -i.bak "s|(untracked)|($COMMIT_SHA)|g" ../lib/filebrowser.go
|
||||
fi
|
||||
|
||||
echo "Build CLI"
|
||||
go build -a -o filebrowser
|
||||
|
||||
if [ "$COMMIT_SHA" != "" ]; then
|
||||
echo "Reset version to (untracked)"
|
||||
sed -i "s|($COMMIT_SHA)|(untracked)|g" ../lib/filebrowser.go
|
||||
fi
|
||||
37
build/build_all.sh
Executable file
37
build/build_all.sh
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
|
||||
cd $(dirname $0)/..
|
||||
|
||||
if [ -d lib/"rice-box.go" ]; then
|
||||
rm -rf lib/rice-box.go
|
||||
fi
|
||||
|
||||
if [ "$USE_DOCKER" != "" ]; then
|
||||
if [ -d "frontend/dist" ]; then
|
||||
rm -rf frontend/dist
|
||||
fi;
|
||||
|
||||
if [ "$(command -v git)" != "" ]; then
|
||||
COMMIT_SHA="$(git rev-parse HEAD | cut -c1-8)"
|
||||
else
|
||||
COMMIT_SHA="untracked"
|
||||
fi
|
||||
|
||||
$(command -v winpty) docker run --rm -it \
|
||||
-v /$(pwd):/src:z \
|
||||
-w //src \
|
||||
-e COMMIT_SHA=$COMMIT_SHA \
|
||||
filebrowser/dev \
|
||||
sh -c "\
|
||||
cd build && \
|
||||
dos2unix build_assets.sh && \
|
||||
dos2unix build.sh && \
|
||||
./build_assets.sh && \
|
||||
./build.sh &&
|
||||
mv ../cli/filebrowser ../ \
|
||||
"
|
||||
else
|
||||
set -e
|
||||
./build/build_assets.sh
|
||||
./build/build.sh
|
||||
fi
|
||||
19
build.sh → build/build_assets.sh
Normal file → Executable file
19
build.sh → build/build_assets.sh
Normal file → Executable file
@@ -1,14 +1,23 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)/..
|
||||
|
||||
# Clean the dist folder and build the assets
|
||||
cd frontend
|
||||
if [ -d "dist" ]; then
|
||||
rm -rf dist/*
|
||||
fi;
|
||||
yarn install
|
||||
yarn build
|
||||
cd ..
|
||||
|
||||
# Install rice tool if not present
|
||||
if ! [ -x "$(command -v rice)" ]; then
|
||||
go get github.com/GeertJohan/go.rice/rice
|
||||
fi
|
||||
|
||||
# Clean the dist folder and build the assets
|
||||
rm -rf node_modules
|
||||
npm install
|
||||
|
||||
# Embed the assets using rice
|
||||
cd lib
|
||||
rice embed-go
|
||||
BIN
build/deploy_key.enc
Normal file
BIN
build/deploy_key.enc
Normal file
Binary file not shown.
27
build/docker_login.sh
Executable file
27
build/docker_login.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
# init key for pass
|
||||
gpg --batch --gen-key <<-EOF
|
||||
%echo Generating a standard key
|
||||
Key-Type: DSA
|
||||
Key-Length: 1024
|
||||
Subkey-Type: ELG-E
|
||||
Subkey-Length: 1024
|
||||
Name-Real: Meshuggah Rocks
|
||||
Name-Email: meshuggah@example.com
|
||||
Expire-Date: 0
|
||||
# Do a commit here, so that we can later print "done" :-)
|
||||
%commit
|
||||
%echo done
|
||||
EOF
|
||||
|
||||
key=$(gpg --no-auto-check-trustdb --list-secret-keys | grep ^sec | cut -d/ -f2 | cut -d" " -f1)
|
||||
pass init $key
|
||||
|
||||
if [ "$(command -v docker-credential-pass)" = "" ]; then
|
||||
docker run --rm -itv /usr/local/bin:/src filebrowser/dev sh -c "cp /go/bin/docker-credential-pass /src"
|
||||
fi
|
||||
|
||||
echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin
|
||||
14
build/push_images.sh
Executable file
14
build/push_images.sh
Executable file
@@ -0,0 +1,14 @@
|
||||
#! /bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
./docker_login.sh
|
||||
|
||||
for tag in `echo $(docker images filebrowser/filebrowser* | awk -F ' ' '{print $1 ":" $2}') | cut -d ' ' -f2-`; do
|
||||
if [ "$tag" = "REPOSITORY:TAG" ]; then break; fi
|
||||
docker push $tag
|
||||
done
|
||||
|
||||
docker logout
|
||||
39
build/push_ricebox.sh
Executable file
39
build/push_ricebox.sh
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
COMMIT_SHA="$(git rev-parse --verify HEAD | cut -c1-8)"
|
||||
|
||||
eval `ssh-agent -s`
|
||||
openssl aes-256-cbc -K $encrypted_9ca81b5594f5_key -iv $encrypted_9ca81b5594f5_iv -in ./deploy_key.enc -d | ssh-add -
|
||||
|
||||
git clone git@github.com:filebrowser/caddy caddy
|
||||
cd caddy
|
||||
cp ../../lib/rice-box.go assets/
|
||||
sed -i 's/package lib/package assets/g' assets/rice-box.go
|
||||
git checkout -b update-rice-box origin/master
|
||||
git config --local user.name "Filebrowser Bot"
|
||||
git config --local user.email "FilebrowserBot@users.noreply.github.com"
|
||||
git commit -am "update rice-box $COMMIT_SHA"
|
||||
|
||||
if [ $(git tag | grep "$TRAVIS_TAG" | wc -l) -ne 0 ]; then
|
||||
git tag -d "$TRAVIS_TAG"
|
||||
fi
|
||||
|
||||
git tag "$TRAVIS_TAG"
|
||||
|
||||
if [ "$(git ls-remote --heads origin update-rice-box)" != "" ]; then
|
||||
git push -u origin update-rice-box
|
||||
else
|
||||
git push origin +update-rice-box
|
||||
fi
|
||||
|
||||
if [ "$(git ls-remote --heads origin update-rice-box)" != "" ]; then
|
||||
git push origin "$TRAVIS_TAG"
|
||||
else
|
||||
git push origin :"$TRAVIS_TAG"
|
||||
git push origin "$TRAVIS_TAG"
|
||||
fi
|
||||
|
||||
55
build/release.sh
Executable file
55
build/release.sh
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)/..
|
||||
|
||||
echo "> Checking semver format"
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "This release script requires a single argument corresponding to the semver to be released. See semver.org"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
semver=$(grep -P '^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)' <<< "$1")
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Not valid semver format. See semver.org"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "> Checking matching $semver in frontend submodule"
|
||||
|
||||
cd frontend
|
||||
git fetch --all
|
||||
|
||||
if [ $(git tag | grep "$semver" | wc -l) -eq 0 ]; then
|
||||
echo "Tag $semver does not exist in submodule 'frontend'. Tag it and run this script again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git rev-parse --verify --quiet release
|
||||
if [ $? -ne 0 ]; then
|
||||
git checkout -b release "$semver"
|
||||
else
|
||||
git checkout release
|
||||
git reset --hard "$semver"
|
||||
fi
|
||||
|
||||
cd ..
|
||||
|
||||
echo "> Updating submodule ref to $semver"
|
||||
|
||||
sed -i "s|(untracked)|$1|g" filebrowser.go
|
||||
git commit -am "chore: version $semver"
|
||||
git tag "$1"
|
||||
git push
|
||||
git push --tags
|
||||
|
||||
echo "> Commiting untracked version notice..."
|
||||
|
||||
sed -i "s|$1|(untracked)|g" filebrowser.go
|
||||
git commit -am "chore: setting untracked version [ci skip]"
|
||||
git push
|
||||
|
||||
echo "> Done!"
|
||||
13
build/run_linters.sh
Executable file
13
build/run_linters.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)/..
|
||||
|
||||
if [ "$USE_DOCKER" != "" ]; then
|
||||
$(command -v winpty) docker run --rm -itv "/$(pwd)://src" -w "//src" filebrowser/dev sh -c "\
|
||||
go get -v ./... && \
|
||||
golangci-lint run -v"
|
||||
else
|
||||
golangci-lint run -v
|
||||
fi
|
||||
24
cli/cmd/db.go
Normal file
24
cli/cmd/db.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// dbCmd represents the db command
|
||||
var dbCmd = &cobra.Command{
|
||||
Use: "db",
|
||||
Version: rootCmd.Version,
|
||||
Aliases: []string{"database"},
|
||||
Short: "Manage a filebrowser database",
|
||||
Long: `This is a CLI tool to ease the management of
|
||||
filebrowser database files.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("db called. Command not implemented, yet.")
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(dbCmd)
|
||||
}
|
||||
76
cli/cmd/root.go
Normal file
76
cli/cmd/root.go
Normal file
@@ -0,0 +1,76 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
fb "github.com/filebrowser/filebrowser/lib"
|
||||
homedir "github.com/mitchellh/go-homedir"
|
||||
"github.com/spf13/cobra"
|
||||
v "github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var cfgFile string
|
||||
|
||||
// rootCmd represents the base command when called without any subcommands
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "filebrowser",
|
||||
Version: fb.Version,
|
||||
Aliases: []string{"serve"},
|
||||
Short: "A stylish web-based file manager",
|
||||
Long: `Command 'serve' is the default. Filebrowser is started
|
||||
with the provided envvars, flags and/or config file. For example:
|
||||
|
||||
filebrowser -c config.json -p 80 -s ./srv
|
||||
|
||||
File Browser is a static binary composed of a golang backend and
|
||||
a Vue.js frontend to create, edit, copy, move, download your files
|
||||
easily, everywhere, every time.`,
|
||||
// Run: func(cmd *cobra.Command, args []string) {},
|
||||
}
|
||||
|
||||
// Execute adds all child commands to the root command and sets flags appropriately.
|
||||
// This is called by main.main(). It only needs to happen once to the rootCmd.
|
||||
func Execute() {
|
||||
checkRootAlias()
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
cobra.OnInitialize(initConfig)
|
||||
rootCmd.SetVersionTemplate("File Browser {{printf \"version %s\" .Version}}\n")
|
||||
|
||||
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file (defaults are './.filebrowser[ext]', '$HOME/.filebrowser[ext]' or '/etc/filebrowser/.filebrowser[ext]')")
|
||||
}
|
||||
|
||||
// initConfig reads in config file and ENV variables if set.
|
||||
func initConfig() {
|
||||
if cfgFile == "" {
|
||||
// Find home directory.
|
||||
home, err := homedir.Dir()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
v.AddConfigPath(".")
|
||||
v.AddConfigPath(home)
|
||||
v.AddConfigPath("/etc/filebrowser/")
|
||||
v.SetConfigName(".filebrowser")
|
||||
} else {
|
||||
// Use config file from the flag.
|
||||
v.SetConfigFile(cfgFile)
|
||||
}
|
||||
|
||||
v.SetEnvPrefix("FB")
|
||||
v.AutomaticEnv()
|
||||
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
|
||||
|
||||
if err := v.ReadInConfig(); err != nil {
|
||||
if _, ok := err.(v.ConfigParseError); ok {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
log.Println("Using config file:", v.ConfigFileUsed())
|
||||
}
|
||||
}
|
||||
46
cli/cmd/rootalias.go
Normal file
46
cli/cmd/rootalias.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
// checkRootAlias compares the first argument provided in the CLI with a list of
|
||||
// subcmds and aliases. If no match is found, the first alias of rootCmd is added.
|
||||
func checkRootAlias() {
|
||||
l := len(rootCmd.Aliases)
|
||||
if l == 0 {
|
||||
return
|
||||
}
|
||||
if l > 1 {
|
||||
log.Printf("rootCmd.Aliases should contain a single string. '%s' is used.\n", rootCmd.Aliases[0])
|
||||
}
|
||||
if len(os.Args) > 1 {
|
||||
for _, v := range append(nonRootSubCmds(), []string{"--help", "--version"}...) {
|
||||
if os.Args[1] == v {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
os.Args = append([]string{os.Args[0], rootCmd.Aliases[0]}, os.Args[1:]...)
|
||||
}
|
||||
|
||||
// nonRootSubCmds traverses the list of subcommands of rootCmd and returns a string
|
||||
// slice containing the names and aliases of all the subcmds, except the one defined
|
||||
// in the Aliases field of rootCmd.
|
||||
func nonRootSubCmds() (l []string) {
|
||||
for _, c := range rootCmd.Commands() {
|
||||
isAlias := false
|
||||
for _, a := range append(c.Aliases, c.Name()) {
|
||||
if a == rootCmd.Aliases[0] {
|
||||
isAlias = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !isAlias {
|
||||
l = append(l, c.Name())
|
||||
l = append(l, c.Aliases...)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
111
cli/cmd/serve.go
Normal file
111
cli/cmd/serve.go
Normal file
@@ -0,0 +1,111 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
filebrowser "github.com/filebrowser/filebrowser/lib"
|
||||
"github.com/spf13/cobra"
|
||||
v "github.com/spf13/viper"
|
||||
)
|
||||
|
||||
// serveCmd represents the serve command
|
||||
var serveCmd = &cobra.Command{
|
||||
Use: "serve",
|
||||
Version: rootCmd.Version,
|
||||
Aliases: []string{"server"},
|
||||
Short: "Start filebrowser service",
|
||||
Long: rootCmd.Long,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
Serve()
|
||||
},
|
||||
Args: cobra.NoArgs,
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(serveCmd)
|
||||
|
||||
f := serveCmd.PersistentFlags()
|
||||
|
||||
flag := func(k string, i interface{}, u string) {
|
||||
switch y := i.(type) {
|
||||
case bool:
|
||||
f.Bool(k, y, u)
|
||||
case int:
|
||||
f.Int(k, y, u)
|
||||
case string:
|
||||
f.String(k, y, u)
|
||||
}
|
||||
v.SetDefault(k, i)
|
||||
}
|
||||
|
||||
flagP := func(k, p string, i interface{}, u string) {
|
||||
switch y := i.(type) {
|
||||
case bool:
|
||||
f.BoolP(k, p, y, u)
|
||||
case int:
|
||||
f.IntP(k, p, y, u)
|
||||
case string:
|
||||
f.StringP(k, p, y, u)
|
||||
}
|
||||
v.SetDefault(k, i)
|
||||
}
|
||||
|
||||
deprecated := func(k string, i interface{}, u, m string) {
|
||||
switch y := i.(type) {
|
||||
case bool:
|
||||
f.Bool(k, y, u)
|
||||
case int:
|
||||
f.Int(k, y, u)
|
||||
case string:
|
||||
f.String(k, y, u)
|
||||
}
|
||||
f.MarkDeprecated(k, m)
|
||||
}
|
||||
|
||||
// Global settings
|
||||
flagP("port", "p", 0, "HTTP Port (default is random)")
|
||||
flagP("address", "a", "", "Address to listen to (default is all of them)")
|
||||
flagP("database", "d", "./filebrowser.db", "Database file")
|
||||
flagP("log", "l", "stdout", "Errors logger; can use 'stdout', 'stderr' or file")
|
||||
flagP("baseurl", "b", "", "Base URL")
|
||||
flag("prefixurl", "", "Prefix URL")
|
||||
flag("staticgen", "", "Static Generator you want to enable")
|
||||
|
||||
// User default settings
|
||||
f.String("defaults.commands", "git svn hg", "Default commands option for new users")
|
||||
v.SetDefault("defaults.commands", []string{"git", "svn", "hg"})
|
||||
|
||||
flagP("defaults.scope", "s", ".", "Default scope option for new users")
|
||||
flag("defaults.viewMode", filebrowser.MosaicViewMode, "Default view mode for new users")
|
||||
flag("defaults.allowCommands", true, "Default allow commands option for new users")
|
||||
flag("defaults.allowEdit", true, "Default allow edit option for new users")
|
||||
flag("defaults.allowNew", true, "Default allow new option for new users")
|
||||
flag("defaults.allowPublish", true, "Default allow publish option for new users")
|
||||
flag("defaults.locale", "", "Default locale for new users, set it empty to enable auto detect from browser")
|
||||
|
||||
// Recaptcha settings
|
||||
flag("recaptcha.host", "https://www.google.com", "Use another host for ReCAPTCHA. recaptcha.net might be useful in China")
|
||||
flag("recaptcha.key", "", "ReCaptcha site key")
|
||||
flag("recaptcha.secret", "", "ReCaptcha secret")
|
||||
|
||||
// Auth settings
|
||||
flag("auth.method", "default", "Switch between 'none', 'default' and 'proxy' authentication")
|
||||
flag("auth.header", "X-Forwarded-User", "The header name used for proxy authentication")
|
||||
|
||||
// Bind the full flag set to the configuration
|
||||
if err := v.BindPFlags(f); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Deprecated flags
|
||||
deprecated("no-auth", false, "Disables authentication", "use --auth.method='none' instead")
|
||||
deprecated("alternative-recaptcha", false, "Use recaptcha.net for serving and handling, useful in China", "use --recaptcha.host instead")
|
||||
deprecated("recaptcha-key", "", "ReCaptcha site key", "use --recaptcha.key instead")
|
||||
deprecated("recaptcha-secret", "", "ReCaptcha secret", "use --recaptcha.secret instead")
|
||||
deprecated("scope", ".", "Default scope option for new users", "use --defaults.scope instead")
|
||||
deprecated("commands", "git svn hg", "Default commands option for new users", "use --defaults.commands instead")
|
||||
deprecated("view-mode", "mosaic", "Default view mode for new users", "use --defaults.viewMode instead")
|
||||
deprecated("locale", "", "Default locale for new users, set it empty to enable auto detect from browser", "use --defaults.locale instead")
|
||||
deprecated("allow-commands", true, "Default allow commands option for new users", "use --defaults.allowCommands instead")
|
||||
deprecated("allow-edit", true, "Default allow edit option for new users", "use --defaults.allowEdit instead")
|
||||
deprecated("allow-publish", true, "Default allow publish option for new users", "use --defaults.allowPublish instead")
|
||||
deprecated("allow-new", true, "Default allow new option for new users", "use --defaults.allowNew instead")
|
||||
}
|
||||
150
cli/cmd/server.go
Normal file
150
cli/cmd/server.go
Normal file
@@ -0,0 +1,150 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/asdine/storm"
|
||||
filebrowser "github.com/filebrowser/filebrowser/lib"
|
||||
"github.com/filebrowser/filebrowser/lib/bolt"
|
||||
h "github.com/filebrowser/filebrowser/lib/http"
|
||||
"github.com/filebrowser/filebrowser/lib/staticgen"
|
||||
"github.com/hacdias/fileutils"
|
||||
"github.com/spf13/viper"
|
||||
lumberjack "gopkg.in/natefinch/lumberjack.v2"
|
||||
)
|
||||
|
||||
func Serve() {
|
||||
// Set up process log before anything bad happens.
|
||||
switch l := viper.GetString("log"); l {
|
||||
case "stdout":
|
||||
log.SetOutput(os.Stdout)
|
||||
case "stderr":
|
||||
log.SetOutput(os.Stderr)
|
||||
case "":
|
||||
log.SetOutput(ioutil.Discard)
|
||||
default:
|
||||
log.SetOutput(&lumberjack.Logger{
|
||||
Filename: l,
|
||||
MaxSize: 100,
|
||||
MaxAge: 14,
|
||||
MaxBackups: 10,
|
||||
})
|
||||
}
|
||||
|
||||
// Validate the provided config before moving forward
|
||||
{
|
||||
// Map of valid authentication methods, containing a boolean value to indicate the need of Auth.Header
|
||||
validMethods := make(map[string]bool)
|
||||
validMethods["none"] = false
|
||||
validMethods["default"] = false
|
||||
validMethods["proxy"] = true
|
||||
|
||||
m := viper.GetString("auth.method")
|
||||
b, ok := validMethods[m]
|
||||
if !ok {
|
||||
log.Fatal("The property 'auth.method' needs to be set to 'none', 'default' or 'proxy'.")
|
||||
}
|
||||
|
||||
if b {
|
||||
if viper.GetString("auth.header") == "" {
|
||||
log.Fatal("The 'auth.header' needs to be specified when '", m, "' authentication is used.")
|
||||
}
|
||||
log.Println("[WARN] Filebrowser authentication is configured to '", m, "' authentication. This can cause a huge security issue if the infrastructure is not configured correctly.")
|
||||
}
|
||||
}
|
||||
|
||||
// Builds the address and a listener.
|
||||
laddr := viper.GetString("address") + ":" + viper.GetString("port")
|
||||
listener, err := net.Listen("tcp", laddr)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Tell the user the port in which is listening.
|
||||
log.Println("Listening on", listener.Addr().String())
|
||||
|
||||
// Starts the server.
|
||||
if err := http.Serve(listener, handler()); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func handler() http.Handler {
|
||||
db, err := storm.Open(viper.GetString("database"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fb := &filebrowser.FileBrowser{
|
||||
Auth: &filebrowser.Auth{
|
||||
Method: viper.GetString("auth.method"),
|
||||
Header: viper.GetString("auth.header"),
|
||||
},
|
||||
ReCaptcha: &filebrowser.ReCaptcha{
|
||||
Host: viper.GetString("recaptcha.host"),
|
||||
Key: viper.GetString("recaptcha.key"),
|
||||
Secret: viper.GetString("recaptcha.secret"),
|
||||
},
|
||||
DefaultUser: &filebrowser.User{
|
||||
AllowCommands: viper.GetBool("defaults.allowCommands"),
|
||||
AllowEdit: viper.GetBool("defaults.allowEdit"),
|
||||
AllowNew: viper.GetBool("defaults.allowNew"),
|
||||
AllowPublish: viper.GetBool("defaults.allowPublish"),
|
||||
Commands: viper.GetStringSlice("defaults.commands"),
|
||||
Rules: []*filebrowser.Rule{},
|
||||
Locale: viper.GetString("defaults.locale"),
|
||||
CSS: "",
|
||||
Scope: viper.GetString("defaults.scope"),
|
||||
FileSystem: fileutils.Dir(viper.GetString("defaults.scope")),
|
||||
ViewMode: viper.GetString("defaults.viewMode"),
|
||||
},
|
||||
Store: &filebrowser.Store{
|
||||
Config: bolt.ConfigStore{DB: db},
|
||||
Users: bolt.UsersStore{DB: db},
|
||||
Share: bolt.ShareStore{DB: db},
|
||||
},
|
||||
NewFS: func(scope string) filebrowser.FileSystem {
|
||||
return fileutils.Dir(scope)
|
||||
},
|
||||
}
|
||||
|
||||
fb.SetBaseURL(viper.GetString("baseurl"))
|
||||
fb.SetPrefixURL(viper.GetString("prefixurl"))
|
||||
|
||||
err = fb.Setup()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
switch viper.GetString("staticgen") {
|
||||
case "hugo":
|
||||
hugo := &staticgen.Hugo{
|
||||
Root: viper.GetString("Scope"),
|
||||
Public: filepath.Join(viper.GetString("Scope"), "public"),
|
||||
Args: []string{},
|
||||
CleanPublic: true,
|
||||
}
|
||||
|
||||
if err = fb.Attach(hugo); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
case "jekyll":
|
||||
jekyll := &staticgen.Jekyll{
|
||||
Root: viper.GetString("Scope"),
|
||||
Public: filepath.Join(viper.GetString("Scope"), "_site"),
|
||||
Args: []string{"build"},
|
||||
CleanPublic: true,
|
||||
}
|
||||
|
||||
if err = fb.Attach(jekyll); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
return h.Handler(fb)
|
||||
}
|
||||
28
cli/cmd/version.go
Normal file
28
cli/cmd/version.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"text/template"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var versionCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Print the version number of File Browser",
|
||||
Long: `All software has versions. This is File Browser's`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
// https://github.com/spf13/cobra/issues/724
|
||||
t := template.New("version")
|
||||
template.Must(t.Parse(rootCmd.VersionTemplate()))
|
||||
err := t.Execute(rootCmd.OutOrStdout(), rootCmd)
|
||||
if err != nil {
|
||||
rootCmd.Println(err)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(versionCmd)
|
||||
serveCmd.AddCommand(versionCmd)
|
||||
dbCmd.AddCommand(versionCmd)
|
||||
}
|
||||
7
cli/main.go
Normal file
7
cli/main.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package main
|
||||
|
||||
import "github.com/filebrowser/filebrowser/cli/cmd"
|
||||
|
||||
func main() {
|
||||
cmd.Execute()
|
||||
}
|
||||
@@ -1,249 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/asdine/storm"
|
||||
|
||||
"gopkg.in/natefinch/lumberjack.v2"
|
||||
|
||||
"github.com/filebrowser/filebrowser"
|
||||
"github.com/filebrowser/filebrowser/bolt"
|
||||
h "github.com/filebrowser/filebrowser/http"
|
||||
"github.com/filebrowser/filebrowser/staticgen"
|
||||
"github.com/hacdias/fileutils"
|
||||
flag "github.com/spf13/pflag"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var (
|
||||
addr string
|
||||
config string
|
||||
database string
|
||||
scope string
|
||||
commands string
|
||||
logfile string
|
||||
staticg string
|
||||
locale string
|
||||
baseurl string
|
||||
prefixurl string
|
||||
viewMode string
|
||||
recaptchakey string
|
||||
recaptchasecret string
|
||||
port int
|
||||
noAuth bool
|
||||
allowCommands bool
|
||||
allowEdit bool
|
||||
allowNew bool
|
||||
allowPublish bool
|
||||
showVer bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.StringVarP(&config, "config", "c", "", "Configuration file")
|
||||
flag.IntVarP(&port, "port", "p", 0, "HTTP Port (default is random)")
|
||||
flag.StringVarP(&addr, "address", "a", "", "Address to listen to (default is all of them)")
|
||||
flag.StringVarP(&database, "database", "d", "./filebrowser.db", "Database file")
|
||||
flag.StringVarP(&logfile, "log", "l", "stdout", "Errors logger; can use 'stdout', 'stderr' or file")
|
||||
flag.StringVarP(&scope, "scope", "s", ".", "Default scope option for new users")
|
||||
flag.StringVarP(&baseurl, "baseurl", "b", "", "Base URL")
|
||||
flag.StringVar(&commands, "commands", "git svn hg", "Default commands option for new users")
|
||||
flag.StringVar(&prefixurl, "prefixurl", "", "Prefix URL")
|
||||
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(&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(&allowNew, "allow-new", true, "Default allow new option for new users")
|
||||
flag.BoolVar(&noAuth, "no-auth", false, "Disables authentication")
|
||||
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.BoolVarP(&showVer, "version", "v", false, "Show version")
|
||||
}
|
||||
|
||||
func setupViper() {
|
||||
viper.SetDefault("Address", "")
|
||||
viper.SetDefault("Port", "0")
|
||||
viper.SetDefault("Database", "./filebrowser.db")
|
||||
viper.SetDefault("Scope", ".")
|
||||
viper.SetDefault("Logger", "stdout")
|
||||
viper.SetDefault("Commands", []string{"git", "svn", "hg"})
|
||||
viper.SetDefault("AllowCommmands", true)
|
||||
viper.SetDefault("AllowEdit", true)
|
||||
viper.SetDefault("AllowNew", true)
|
||||
viper.SetDefault("AllowPublish", true)
|
||||
viper.SetDefault("StaticGen", "")
|
||||
viper.SetDefault("Locale", "")
|
||||
viper.SetDefault("NoAuth", false)
|
||||
viper.SetDefault("BaseURL", "")
|
||||
viper.SetDefault("PrefixURL", "")
|
||||
viper.SetDefault("ViewMode", filebrowser.MosaicViewMode)
|
||||
viper.SetDefault("ReCaptchaKey", "")
|
||||
viper.SetDefault("ReCaptchaSecret", "")
|
||||
|
||||
viper.BindPFlag("Port", flag.Lookup("port"))
|
||||
viper.BindPFlag("Address", flag.Lookup("address"))
|
||||
viper.BindPFlag("Database", flag.Lookup("database"))
|
||||
viper.BindPFlag("Scope", flag.Lookup("scope"))
|
||||
viper.BindPFlag("Logger", flag.Lookup("log"))
|
||||
viper.BindPFlag("Commands", flag.Lookup("commands"))
|
||||
viper.BindPFlag("AllowCommands", flag.Lookup("allow-commands"))
|
||||
viper.BindPFlag("AllowEdit", flag.Lookup("allow-edit"))
|
||||
viper.BindPFlag("AlowNew", flag.Lookup("allow-new"))
|
||||
viper.BindPFlag("AllowPublish", flag.Lookup("allow-publish"))
|
||||
viper.BindPFlag("Locale", flag.Lookup("locale"))
|
||||
viper.BindPFlag("StaticGen", flag.Lookup("staticgen"))
|
||||
viper.BindPFlag("NoAuth", flag.Lookup("no-auth"))
|
||||
viper.BindPFlag("BaseURL", flag.Lookup("baseurl"))
|
||||
viper.BindPFlag("PrefixURL", flag.Lookup("prefixurl"))
|
||||
viper.BindPFlag("ViewMode", flag.Lookup("view-mode"))
|
||||
viper.BindPFlag("ReCaptchaKey", flag.Lookup("recaptcha-key"))
|
||||
viper.BindPFlag("ReCaptchaSecret", flag.Lookup("recaptcha-secret"))
|
||||
|
||||
viper.SetConfigName("filebrowser")
|
||||
viper.AddConfigPath(".")
|
||||
}
|
||||
|
||||
func printVersion() {
|
||||
fmt.Println("filebrowser version", filebrowser.Version)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func main() {
|
||||
setupViper()
|
||||
flag.Parse()
|
||||
|
||||
if showVer {
|
||||
printVersion()
|
||||
}
|
||||
|
||||
// Add a configuration file if set.
|
||||
if config != "" {
|
||||
ext := filepath.Ext(config)
|
||||
dir := filepath.Dir(config)
|
||||
config = strings.TrimSuffix(config, ext)
|
||||
|
||||
if dir != "" {
|
||||
viper.AddConfigPath(dir)
|
||||
config = strings.TrimPrefix(config, dir)
|
||||
}
|
||||
|
||||
viper.SetConfigName(config)
|
||||
}
|
||||
|
||||
// Read configuration from a file if exists.
|
||||
err := viper.ReadInConfig()
|
||||
if err != nil {
|
||||
if _, ok := err.(viper.ConfigParseError); ok {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Set up process log before anything bad happens.
|
||||
switch viper.GetString("Logger") {
|
||||
case "stdout":
|
||||
log.SetOutput(os.Stdout)
|
||||
case "stderr":
|
||||
log.SetOutput(os.Stderr)
|
||||
case "":
|
||||
log.SetOutput(ioutil.Discard)
|
||||
default:
|
||||
log.SetOutput(&lumberjack.Logger{
|
||||
Filename: logfile,
|
||||
MaxSize: 100,
|
||||
MaxAge: 14,
|
||||
MaxBackups: 10,
|
||||
})
|
||||
}
|
||||
|
||||
// Builds the address and a listener.
|
||||
laddr := viper.GetString("Address") + ":" + viper.GetString("Port")
|
||||
listener, err := net.Listen("tcp", laddr)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Tell the user the port in which is listening.
|
||||
fmt.Println("Listening on", listener.Addr().String())
|
||||
|
||||
// Starts the server.
|
||||
if err := http.Serve(listener, handler()); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func handler() http.Handler {
|
||||
db, err := storm.Open(viper.GetString("Database"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fm := &filebrowser.FileBrowser{
|
||||
NoAuth: viper.GetBool("NoAuth"),
|
||||
BaseURL: viper.GetString("BaseURL"),
|
||||
PrefixURL: viper.GetString("PrefixURL"),
|
||||
ReCaptchaKey: viper.GetString("ReCaptchaKey"),
|
||||
ReCaptchaSecret: viper.GetString("ReCaptchaSecret"),
|
||||
DefaultUser: &filebrowser.User{
|
||||
AllowCommands: viper.GetBool("AllowCommands"),
|
||||
AllowEdit: viper.GetBool("AllowEdit"),
|
||||
AllowNew: viper.GetBool("AllowNew"),
|
||||
AllowPublish: viper.GetBool("AllowPublish"),
|
||||
Commands: viper.GetStringSlice("Commands"),
|
||||
Rules: []*filebrowser.Rule{},
|
||||
Locale: viper.GetString("Locale"),
|
||||
CSS: "",
|
||||
Scope: viper.GetString("Scope"),
|
||||
FileSystem: fileutils.Dir(viper.GetString("Scope")),
|
||||
ViewMode: viper.GetString("ViewMode"),
|
||||
},
|
||||
Store: &filebrowser.Store{
|
||||
Config: bolt.ConfigStore{DB: db},
|
||||
Users: bolt.UsersStore{DB: db},
|
||||
Share: bolt.ShareStore{DB: db},
|
||||
},
|
||||
NewFS: func(scope string) filebrowser.FileSystem {
|
||||
return fileutils.Dir(scope)
|
||||
},
|
||||
}
|
||||
|
||||
err = fm.Setup()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
switch viper.GetString("StaticGen") {
|
||||
case "hugo":
|
||||
hugo := &staticgen.Hugo{
|
||||
Root: viper.GetString("Scope"),
|
||||
Public: filepath.Join(viper.GetString("Scope"), "public"),
|
||||
Args: []string{},
|
||||
CleanPublic: true,
|
||||
}
|
||||
|
||||
if err = fm.Attach(hugo); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
case "jekyll":
|
||||
jekyll := &staticgen.Jekyll{
|
||||
Root: viper.GetString("Scope"),
|
||||
Public: filepath.Join(viper.GetString("Scope"), "_site"),
|
||||
Args: []string{"build"},
|
||||
CleanPublic: true,
|
||||
}
|
||||
|
||||
if err = fm.Attach(jekyll); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
return h.Handler(fm)
|
||||
}
|
||||
1
frontend
Submodule
1
frontend
Submodule
Submodule frontend added at 2642333928
36
go.mod
Normal file
36
go.mod
Normal file
@@ -0,0 +1,36 @@
|
||||
module github.com/filebrowser/filebrowser
|
||||
|
||||
require (
|
||||
github.com/GeertJohan/go.rice v0.0.0-20170420135705-c02ca9a983da
|
||||
github.com/Sereal/Sereal v0.0.0-20181211220259-509a78ddbda3 // indirect
|
||||
github.com/asdine/storm v2.1.2+incompatible
|
||||
github.com/boltdb/bolt v1.3.1 // indirect
|
||||
github.com/daaku/go.zipexe v0.0.0-20150329023125-a5fe2436ffcb // indirect
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
||||
github.com/dsnet/compress v0.0.0-20171208185109-cc9eb1d7ad76 // indirect
|
||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 // indirect
|
||||
github.com/gohugoio/hugo v0.49.2
|
||||
github.com/golang/protobuf v1.2.0 // indirect
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
|
||||
github.com/google/uuid v1.1.0 // indirect
|
||||
github.com/gorilla/websocket v1.4.0
|
||||
github.com/hacdias/fileutils v0.0.0-20181202104838-227b317161a1
|
||||
github.com/hacdias/varutils v0.0.0-20171121224303-82d3b57f667a
|
||||
github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 // indirect
|
||||
github.com/maruel/natural v0.0.0-20180416170133-dbcb3e2e8cf1
|
||||
github.com/mholt/archiver v2.1.0+incompatible
|
||||
github.com/mholt/caddy v0.11.1
|
||||
github.com/mitchellh/go-homedir v1.0.0
|
||||
github.com/mitchellh/mapstructure v1.1.2
|
||||
github.com/nwaples/rardecode v1.0.0 // indirect
|
||||
github.com/pierrec/lz4 v2.0.5+incompatible // indirect
|
||||
github.com/robfig/cron v0.0.0-20180505203441-b41be1df6967
|
||||
github.com/spf13/cobra v0.0.3
|
||||
github.com/spf13/viper v1.3.1
|
||||
github.com/ulikunitz/xz v0.5.5 // indirect
|
||||
github.com/vmihailenco/msgpack v4.0.1+incompatible // indirect
|
||||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
|
||||
go.etcd.io/bbolt v1.3.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0
|
||||
)
|
||||
167
go.sum
Normal file
167
go.sum
Normal file
@@ -0,0 +1,167 @@
|
||||
github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69/go.mod h1:L1AbZdiDllfyYH5l5OkAaZtk7VkWe89bPJFmnDBNHxg=
|
||||
github.com/BurntSushi/toml v0.0.0-20170626110600-a368813c5e64 h1:BuYewlQyh/jroxY8qx41SrzD8Go17GkyCyAeVmprvQI=
|
||||
github.com/BurntSushi/toml v0.0.0-20170626110600-a368813c5e64/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/GeertJohan/go.rice v0.0.0-20170420135705-c02ca9a983da h1:UVU3a9pRUyLdnBtn60WjRl0s4SEyJc2ChCY56OAR6wI=
|
||||
github.com/GeertJohan/go.rice v0.0.0-20170420135705-c02ca9a983da/go.mod h1:DgrzXonpdQbfN3uYaGz1EG4Sbhyum/MMIn6Cphlh2bw=
|
||||
github.com/PuerkitoBio/purell v1.1.0 h1:rmGxhojJlM0tuKtfdvliR84CFHljx9ag64t2xmVkjK4=
|
||||
github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||
github.com/Sereal/Sereal v0.0.0-20181211220259-509a78ddbda3/go.mod h1:D0JMgToj/WdxCgd30Kc1UcA9E+WdZoJqeVOuYW7iTBM=
|
||||
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI=
|
||||
github.com/alecthomas/chroma v0.5.0 h1:PI0RlRSWL+8GSMuIMMA5KIND4CeJ5KXUQA60LLp/SjA=
|
||||
github.com/alecthomas/chroma v0.5.0/go.mod h1:MmozekIi2rfQSzDcdEZ2BoJ9Pxs/7uc2Y4Boh+hIeZo=
|
||||
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
|
||||
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
|
||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||
github.com/asdine/storm v2.1.2+incompatible h1:dczuIkyqwY2LrtXPz8ixMrU/OFgZp71kbKTHGrXYt/Q=
|
||||
github.com/asdine/storm v2.1.2+incompatible/go.mod h1:RarYDc9hq1UPLImuiXK3BIWPJLdIygvV3PsInK0FbVQ=
|
||||
github.com/bep/debounce v1.1.0/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0=
|
||||
github.com/bep/gitmap v1.0.0/go.mod h1:g9VRETxFUXNWzMiuxOwcudo6DfZkW9jOsOW0Ft4kYaY=
|
||||
github.com/bep/go-tocss v0.5.0/go.mod h1:c/+hEVoVvkufrV9Is/CPRHWGGdpcTwNuB48hfxzyYBI=
|
||||
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
|
||||
github.com/chaseadamsio/goorgeous v1.1.0 h1:J9UrYDhzucUMHXsCKG+kICvpR5dT1cqZdVFTYvSlUBk=
|
||||
github.com/chaseadamsio/goorgeous v1.1.0/go.mod h1:6QaC0vFoKWYDth94dHFNgRT2YkT5FHdQp/Yx15aAAi0=
|
||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/cpuguy83/go-md2man v1.0.8/go.mod h1:N6JayAiVKtlHSnuTCeuLSQVs75hb8q+dYQLjr7cDsKY=
|
||||
github.com/daaku/go.zipexe v0.0.0-20150329023125-a5fe2436ffcb h1:tUf55Po0vzOendQ7NWytcdK0VuzQmfAgvGBUOQvN0WA=
|
||||
github.com/daaku/go.zipexe v0.0.0-20150329023125-a5fe2436ffcb/go.mod h1:U0vRfAucUOohvdCxt5MWLF+TePIL0xbCkbKIiV8TQCE=
|
||||
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=
|
||||
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/disintegration/imaging v1.5.0/go.mod h1:9B/deIUIrliYkyMTuXJd6OUFLcrZ2tf+3Qlwnaf/CjU=
|
||||
github.com/dlclark/regexp2 v1.1.6 h1:CqB4MjHw0MFCDj+PHHjiESmHX+N7t0tJzKvC6M97BRg=
|
||||
github.com/dlclark/regexp2 v1.1.6/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
|
||||
github.com/dsnet/compress v0.0.0-20171208185109-cc9eb1d7ad76 h1:eX+pdPPlD279OWgdx7f6KqIRSONuK7egk+jDx7OM3Ac=
|
||||
github.com/dsnet/compress v0.0.0-20171208185109-cc9eb1d7ad76/go.mod h1:KjxHHirfLaw19iGT70HvVjHQsL1vq1SRQB4yOsAfy2s=
|
||||
github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM=
|
||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=
|
||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
||||
github.com/fortytw2/leaktest v1.2.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
|
||||
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
|
||||
github.com/gohugoio/hugo v0.49.2 h1:cj62OqvM3tV12G06J9QQkN2GrO0hOq5m0xtREC7Z9NQ=
|
||||
github.com/gohugoio/hugo v0.49.2/go.mod h1:Mh0VDogJpLC4OWpv/wIE4+tJZ1wFPUfMJDNaoJ1yuFA=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/uuid v1.1.0 h1:Jf4mxPC/ziBnoPIdpQdPJ9OeiomAUHLvxmPRSPH9m4s=
|
||||
github.com/google/uuid v1.1.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
|
||||
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
github.com/hacdias/fileutils v0.0.0-20181202104838-227b317161a1 h1:2MkEawJQTmAr6YI7T7j7SKxdTmYJOcaJZfzeVPr56PM=
|
||||
github.com/hacdias/fileutils v0.0.0-20181202104838-227b317161a1/go.mod h1:lwnswzFVSy7B/k81M5rOLUU0fOBKHrDRIkPIBZd7PBo=
|
||||
github.com/hacdias/varutils v0.0.0-20171121224303-82d3b57f667a h1:BAjqcm8I/EO0WVwhNcZ/Zcv0Gd/7BrhCp2zi8oqXZh4=
|
||||
github.com/hacdias/varutils v0.0.0-20171121224303-82d3b57f667a/go.mod h1:VfbRoVIe7I1Hz8CEW4K80fCz+lQ6Budq0WiI0MrqEdM=
|
||||
github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0=
|
||||
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
|
||||
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/jdkato/prose v1.1.0 h1:LpvmDGwbKGTgdCH3a8VJL56sr7p/wOFPw/R4lM4PfFg=
|
||||
github.com/jdkato/prose v1.1.0/go.mod h1:jkF0lkxaX5PFSlk9l4Gh9Y+T57TqUZziWT7uZbW5ADg=
|
||||
github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 h1:PJPDf8OUfOK1bb/NeTKd4f1QXZItOX389VN3B6qC8ro=
|
||||
github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kyokomi/emoji v1.5.1 h1:qp9dub1mW7C4MlvoRENH6EAENb9skEFOvIEbp1Waj38=
|
||||
github.com/kyokomi/emoji v1.5.1/go.mod h1:mZ6aGCD7yk8j6QY6KICwnZ2pxoszVseX1DNoGtU2tBA=
|
||||
github.com/magefile/mage v1.4.0/go.mod h1:IUDi13rsHje59lecXokTfGX0QIzO45uVPlXnJYsXepA=
|
||||
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
|
||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/markbates/inflect v1.0.0/go.mod h1:oTeZL2KHA7CUX6X+fovmK9OvIOFuqu0TwdQrZjLTh88=
|
||||
github.com/maruel/natural v0.0.0-20180416170133-dbcb3e2e8cf1 h1:PEhRT94KBTY4E0KdCYmhvDGWjSFBxc68j2M6PMRix8U=
|
||||
github.com/maruel/natural v0.0.0-20180416170133-dbcb3e2e8cf1/go.mod h1:wI697HNhDFM/vBruYM3ckbszQ2+DOIeH9qdBKMdf288=
|
||||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-runewidth v0.0.3 h1:a+kO+98RDGEfo6asOGMmpodZq4FNtnGP54yps8BzLR4=
|
||||
github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||
github.com/mholt/archiver v2.1.0+incompatible h1:1ivm7KAHPtPere1YDOdrY6xGdbMNGRWThZbYh5lWZT0=
|
||||
github.com/mholt/archiver v2.1.0+incompatible/go.mod h1:Dh2dOXnSdiLxRiPoVfIr/fI1TwETms9B8CTWfeh7ROU=
|
||||
github.com/mholt/caddy v0.11.1 h1:oNfejqftVesLoFxw53Gh17aBPNbTxQ9xJw1pn4IiAPk=
|
||||
github.com/mholt/caddy v0.11.1/go.mod h1:Wb1PlT4DAYSqOEd03MsqkdkXnTxA8v9pKjdpxbqM1kY=
|
||||
github.com/miekg/mmark v1.3.6 h1:t47x5vThdwgLJzofNsbsAl7gmIiJ7kbDQN5BxwBmwvY=
|
||||
github.com/miekg/mmark v1.3.6/go.mod h1:w7r9mkTvpS55jlfyn22qJ618itLryxXBhA7Jp3FIlkw=
|
||||
github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0=
|
||||
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/hashstructure v1.0.0/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ=
|
||||
github.com/mitchellh/mapstructure v1.0.0/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/muesli/smartcrop v0.0.0-20180228075044-f6ebaa786a12/go.mod h1:i2fCI/UorTfgEpPPLWiFBv4pye+YAG78RwcQLUkocpI=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
||||
github.com/nicksnyder/go-i18n v1.10.0/go.mod h1:HrK7VCrbOvQoUAQ7Vpy7i87N7JZZZ7R2xBGjv0j365Q=
|
||||
github.com/nwaples/rardecode v1.0.0 h1:r7vGuS5akxOnR4JQSkko62RJ1ReCMXxQRPtxsiFMBOs=
|
||||
github.com/nwaples/rardecode v1.0.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0=
|
||||
github.com/olekukonko/tablewriter v0.0.0-20180506121414-d4647c9c7a84 h1:fiKJgB4JDUd43CApkmCeTSQlWjtTtABrU2qsgbuP0BI=
|
||||
github.com/olekukonko/tablewriter v0.0.0-20180506121414-d4647c9c7a84/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
|
||||
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I=
|
||||
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/robfig/cron v0.0.0-20180505203441-b41be1df6967 h1:x7xEyJDP7Hv3LVgvWhzioQqbC/KtuUhTigKlH/8ehhE=
|
||||
github.com/robfig/cron v0.0.0-20180505203441-b41be1df6967/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
|
||||
github.com/russross/blackfriday v0.0.0-20180804101149-46c73eb196ba h1:8Vzt8HxRjy7hp1eqPKVoAEPK9npQFW2510qlobGzvi0=
|
||||
github.com/russross/blackfriday v0.0.0-20180804101149-46c73eb196ba/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||
github.com/sanity-io/litter v1.1.0/go.mod h1:CJ0VCw2q4qKU7LaQr3n7UOSHzgEMgcGco7N/SkZQPjw=
|
||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||
github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95 h1:/vdW8Cb7EXrkqWGufVMES1OH2sU9gKVb2n9/1y5NMBY=
|
||||
github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/cast v1.2.0/go.mod h1:r2rcYCSwa1IExKTDiTfzaxqT2FNHs8hODu4LnUfgKEg=
|
||||
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
|
||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cobra v0.0.3 h1:ZlrZ4XsMRm04Fr5pSFxBgfND2EBVa1nLpiy1stUsX/8=
|
||||
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
|
||||
github.com/spf13/fsync v0.0.0-20170320142552-12a01e648f05/go.mod h1:jdsEoy1w+v0NpuwXZEaRAH6ADTDmzfRnE2eVwshwFrM=
|
||||
github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
|
||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||
github.com/spf13/nitro v0.0.0-20131003134307-24d7ef30a12d/go.mod h1:jU8A+8xL+6n1OX4XaZtCj4B3mIa64tULUsD6YegdpFo=
|
||||
github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/viper v1.2.0/go.mod h1:P4AexN0a+C9tGAnUFNwDMYYZv3pjFuvmeiMyKRaNVlI=
|
||||
github.com/spf13/viper v1.3.1 h1:5+8j8FTpnFV4nEImW/ofkzEt8VoOiLXxdYIDsB73T38=
|
||||
github.com/spf13/viper v1.3.1/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/tdewolff/minify v2.3.5+incompatible/go.mod h1:9Ov578KJUmAWpS6NeZwRZyT56Uf6o3Mcz9CEsg8USYs=
|
||||
github.com/tdewolff/parse v2.3.3+incompatible/go.mod h1:8oBwCsVmUkgHO8M5iCzSIDtpzXOT0WXX9cWhz+bIzJQ=
|
||||
github.com/tdewolff/test v0.0.0-20171106182207-265427085153/go.mod h1:DiQUlutnqlEvdvhSn2LPGy4TFwRauAaYDsL+683RNX4=
|
||||
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||
github.com/ulikunitz/xz v0.5.5 h1:pFrO0lVpTBXLpYw+pnLj6TbvHuyjXMfjGeCwSqCVwok=
|
||||
github.com/ulikunitz/xz v0.5.5/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
|
||||
github.com/vmihailenco/msgpack v4.0.1+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
|
||||
github.com/wellington/go-libsass v0.0.0-20180624165032-615eaa47ef79/go.mod h1:mxgxgam0N0E+NAUMHLcu20Ccfc3mVpDkyrLDayqfiTs=
|
||||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
|
||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||
github.com/yosssi/ace v0.0.5/go.mod h1:ALfIzm2vT7t5ZE7uoIZqF3TQ7SAOyupFZnkrF5id+K0=
|
||||
go.etcd.io/bbolt v1.3.0 h1:oY10fI923Q5pVCVt1GBTZMn8LHo5M+RCInFpeMnV4QI=
|
||||
go.etcd.io/bbolt v1.3.0/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 h1:mKdxBk7AujPs8kU4m80U72y/zjbZ3UcXC7dClwKbUI0=
|
||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180906133057-8cf3aee42992/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a h1:1n5lsVfiQW3yfsRGu98756EH1YthsFqr/5mxHduZW2A=
|
||||
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
@@ -2,7 +2,7 @@ package bolt
|
||||
|
||||
import (
|
||||
"github.com/asdine/storm"
|
||||
fm "github.com/filebrowser/filebrowser"
|
||||
fb "github.com/filebrowser/filebrowser/lib"
|
||||
)
|
||||
|
||||
// ConfigStore is a configuration store.
|
||||
@@ -14,7 +14,7 @@ type ConfigStore struct {
|
||||
func (c ConfigStore) Get(name string, to interface{}) error {
|
||||
err := c.DB.Get("config", name, to)
|
||||
if err == storm.ErrNotFound {
|
||||
return fm.ErrNotExist
|
||||
return fb.ErrNotExist
|
||||
}
|
||||
|
||||
return err
|
||||
@@ -3,7 +3,7 @@ package bolt
|
||||
import (
|
||||
"github.com/asdine/storm"
|
||||
"github.com/asdine/storm/q"
|
||||
fm "github.com/filebrowser/filebrowser"
|
||||
fb "github.com/filebrowser/filebrowser/lib"
|
||||
)
|
||||
|
||||
// ShareStore is a shareable links store.
|
||||
@@ -12,55 +12,55 @@ type ShareStore struct {
|
||||
}
|
||||
|
||||
// Get gets a Share Link from an hash.
|
||||
func (s ShareStore) Get(hash string) (*fm.ShareLink, error) {
|
||||
var v fm.ShareLink
|
||||
func (s ShareStore) Get(hash string) (*fb.ShareLink, error) {
|
||||
var v fb.ShareLink
|
||||
err := s.DB.One("Hash", hash, &v)
|
||||
if err == storm.ErrNotFound {
|
||||
return nil, fm.ErrNotExist
|
||||
return nil, fb.ErrNotExist
|
||||
}
|
||||
|
||||
return &v, err
|
||||
}
|
||||
|
||||
// GetPermanent gets the permanent link from a path.
|
||||
func (s ShareStore) GetPermanent(path string) (*fm.ShareLink, error) {
|
||||
var v fm.ShareLink
|
||||
func (s ShareStore) GetPermanent(path string) (*fb.ShareLink, error) {
|
||||
var v fb.ShareLink
|
||||
err := s.DB.Select(q.Eq("Path", path), q.Eq("Expires", false)).First(&v)
|
||||
if err == storm.ErrNotFound {
|
||||
return nil, fm.ErrNotExist
|
||||
return nil, fb.ErrNotExist
|
||||
}
|
||||
|
||||
return &v, err
|
||||
}
|
||||
|
||||
// GetByPath gets all the links for a specific path.
|
||||
func (s ShareStore) GetByPath(hash string) ([]*fm.ShareLink, error) {
|
||||
var v []*fm.ShareLink
|
||||
func (s ShareStore) GetByPath(hash string) ([]*fb.ShareLink, error) {
|
||||
var v []*fb.ShareLink
|
||||
err := s.DB.Find("Path", hash, &v)
|
||||
if err == storm.ErrNotFound {
|
||||
return v, fm.ErrNotExist
|
||||
return v, fb.ErrNotExist
|
||||
}
|
||||
|
||||
return v, err
|
||||
}
|
||||
|
||||
// Gets retrieves all the shareable links.
|
||||
func (s ShareStore) Gets() ([]*fm.ShareLink, error) {
|
||||
var v []*fm.ShareLink
|
||||
func (s ShareStore) Gets() ([]*fb.ShareLink, error) {
|
||||
var v []*fb.ShareLink
|
||||
err := s.DB.All(&v)
|
||||
if err == storm.ErrNotFound {
|
||||
return v, fm.ErrNotExist
|
||||
return v, fb.ErrNotExist
|
||||
}
|
||||
|
||||
return v, err
|
||||
}
|
||||
|
||||
// Save stores a Share Link on the database.
|
||||
func (s ShareStore) Save(l *fm.ShareLink) error {
|
||||
func (s ShareStore) Save(l *fb.ShareLink) error {
|
||||
return s.DB.Save(l)
|
||||
}
|
||||
|
||||
// Delete deletes a Share Link from the database.
|
||||
func (s ShareStore) Delete(hash string) error {
|
||||
return s.DB.DeleteStruct(&fm.ShareLink{Hash: hash})
|
||||
return s.DB.DeleteStruct(&fb.ShareLink{Hash: hash})
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"reflect"
|
||||
|
||||
"github.com/asdine/storm"
|
||||
fm "github.com/filebrowser/filebrowser"
|
||||
fb "github.com/filebrowser/filebrowser/lib"
|
||||
)
|
||||
|
||||
// UsersStore is a users store.
|
||||
@@ -13,11 +13,11 @@ type UsersStore struct {
|
||||
}
|
||||
|
||||
// Get gets a user with a certain id from the database.
|
||||
func (u UsersStore) Get(id int, builder fm.FSBuilder) (*fm.User, error) {
|
||||
var us fm.User
|
||||
func (u UsersStore) Get(id int, builder fb.FSBuilder) (*fb.User, error) {
|
||||
var us fb.User
|
||||
err := u.DB.One("ID", id, &us)
|
||||
if err == storm.ErrNotFound {
|
||||
return nil, fm.ErrNotExist
|
||||
return nil, fb.ErrNotExist
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@@ -29,11 +29,11 @@ func (u UsersStore) Get(id int, builder fm.FSBuilder) (*fm.User, error) {
|
||||
}
|
||||
|
||||
// GetByUsername gets a user with a certain username from the database.
|
||||
func (u UsersStore) GetByUsername(username string, builder fm.FSBuilder) (*fm.User, error) {
|
||||
var us fm.User
|
||||
func (u UsersStore) GetByUsername(username string, builder fb.FSBuilder) (*fb.User, error) {
|
||||
var us fb.User
|
||||
err := u.DB.One("Username", username, &us)
|
||||
if err == storm.ErrNotFound {
|
||||
return nil, fm.ErrNotExist
|
||||
return nil, fb.ErrNotExist
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@@ -45,11 +45,11 @@ func (u UsersStore) GetByUsername(username string, builder fm.FSBuilder) (*fm.Us
|
||||
}
|
||||
|
||||
// Gets gets all the users from the database.
|
||||
func (u UsersStore) Gets(builder fm.FSBuilder) ([]*fm.User, error) {
|
||||
var us []*fm.User
|
||||
func (u UsersStore) Gets(builder fb.FSBuilder) ([]*fb.User, error) {
|
||||
var us []*fb.User
|
||||
err := u.DB.All(&us)
|
||||
if err == storm.ErrNotFound {
|
||||
return nil, fm.ErrNotExist
|
||||
return nil, fb.ErrNotExist
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@@ -64,7 +64,7 @@ func (u UsersStore) Gets(builder fm.FSBuilder) ([]*fm.User, error) {
|
||||
}
|
||||
|
||||
// Update updates the whole user object or only certain fields.
|
||||
func (u UsersStore) Update(us *fm.User, fields ...string) error {
|
||||
func (u UsersStore) Update(us *fb.User, fields ...string) error {
|
||||
if len(fields) == 0 {
|
||||
return u.Save(us)
|
||||
}
|
||||
@@ -80,11 +80,11 @@ func (u UsersStore) Update(us *fm.User, fields ...string) error {
|
||||
}
|
||||
|
||||
// Save saves a user to the database.
|
||||
func (u UsersStore) Save(us *fm.User) error {
|
||||
func (u UsersStore) Save(us *fb.User) error {
|
||||
return u.DB.Save(us)
|
||||
}
|
||||
|
||||
// Delete deletes a user from the database.
|
||||
func (u UsersStore) Delete(id int) error {
|
||||
return u.DB.DeleteStruct(&fm.User{ID: id})
|
||||
return u.DB.DeleteStruct(&fb.User{ID: id})
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Package filebrowser provides a web interface to access your files
|
||||
wherever you are. To use this package as a middleware for your app,
|
||||
you'll need to import both File Manager and File Manager HTTP packages.
|
||||
you'll need to import both File Browser and File Browser HTTP packages.
|
||||
|
||||
import (
|
||||
fm "github.com/filebrowser/filebrowser"
|
||||
@@ -16,6 +16,10 @@ to import "github.com/filebrowser/filebrowser/bolt".
|
||||
|
||||
m := &fm.FileBrowser{
|
||||
NoAuth: false,
|
||||
Auth: {
|
||||
Method: "default",
|
||||
LoginHeader: "X-Fowarded-User"
|
||||
},
|
||||
DefaultUser: &fm.User{
|
||||
AllowCommands: true,
|
||||
AllowEdit: true,
|
||||
@@ -49,11 +53,11 @@ functions:
|
||||
m.SetPrefixURL("/")
|
||||
|
||||
The Prefix URL is a part of the path that is already stripped from the
|
||||
r.URL.Path variable before the request arrives to File Manager's handler.
|
||||
r.URL.Path variable before the request arrives to File Browser's handler.
|
||||
This is a function that will rarely be used. You can see one example on Caddy
|
||||
filemanager plugin.
|
||||
|
||||
The Base URL is the URL path where you want File Manager to be available in. If
|
||||
The Base URL is the URL path where you want File Browser to be available in. If
|
||||
you want to be available at the root path, you should call:
|
||||
|
||||
m.SetBaseURL("/")
|
||||
@@ -62,7 +66,7 @@ But if you want to access it at '/admin', you would call:
|
||||
|
||||
m.SetBaseURL("/admin")
|
||||
|
||||
Now, that you already have a File Manager instance created, you just need to
|
||||
Now, that you already have a File Browser instance created, you just need to
|
||||
add it to your handlers using m.ServeHTTP which is compatible to http.Handler.
|
||||
We also have a m.ServeWithErrorsHTTP that returns the status code and an error.
|
||||
|
||||
@@ -70,4 +74,4 @@ One simple implementation for this, at port 80, in the root of the domain, would
|
||||
|
||||
http.ListenAndServe(":80", h.Handler(m))
|
||||
*/
|
||||
package filebrowser
|
||||
package lib
|
||||
@@ -1,4 +1,4 @@
|
||||
package filebrowser
|
||||
package lib
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -20,8 +20,13 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gohugoio/hugo/parser"
|
||||
"github.com/maruel/natural"
|
||||
)
|
||||
|
||||
// The size of the loaded text can be rendered in the browser. Avoiding files that are too large causes browsers to crash.
|
||||
// Currently set to 10MB, 10 * 1024 * 1024 = 10485760 byte
|
||||
const textExtensionsRenderMaxSize int64 = 10485760
|
||||
|
||||
// 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).
|
||||
@@ -134,13 +139,12 @@ func (i *File) GetListing(u *User, r *http.Request) error {
|
||||
}
|
||||
|
||||
if strings.HasPrefix(f.Mode().String(), "L") {
|
||||
// It's a symbolic link
|
||||
// The FileInfo from Readdir treats symbolic link as a file only.
|
||||
// It's a symbolic link. We try to follow it. If it doesn't work,
|
||||
// we stay with the link information instead if the target's.
|
||||
info, err := os.Stat(f.Name())
|
||||
if err != nil {
|
||||
return err
|
||||
if err == nil {
|
||||
f = info
|
||||
}
|
||||
f = info
|
||||
}
|
||||
|
||||
if f.IsDir() {
|
||||
@@ -223,14 +227,14 @@ func (i *File) GetFileType(checkContent bool) error {
|
||||
|
||||
// Only the first 512 bytes are used to sniff the content type.
|
||||
buffer := make([]byte, 512)
|
||||
_, err = file.Read(buffer)
|
||||
n, err := file.Read(buffer)
|
||||
if err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
// Tries to get the file mimetype using its first
|
||||
// 512 bytes.
|
||||
mimetype = http.DetectContentType(buffer)
|
||||
mimetype = http.DetectContentType(buffer[:n])
|
||||
}
|
||||
|
||||
if strings.HasPrefix(mimetype, "video") {
|
||||
@@ -268,7 +272,7 @@ func (i *File) GetFileType(checkContent bool) error {
|
||||
|
||||
End:
|
||||
// If the file type is text, save its content.
|
||||
if i.Type == "text" {
|
||||
if i.Type == "text" && i.Size <= textExtensionsRenderMaxSize { // Avoiding files that are too large causes browsers to crash
|
||||
if len(content) == 0 {
|
||||
content, err = ioutil.ReadFile(i.Path)
|
||||
if err != nil {
|
||||
@@ -373,7 +377,7 @@ func (l byName) Less(i, j int) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
return strings.ToLower(l.Items[i].Name) < strings.ToLower(l.Items[j].Name)
|
||||
return natural.Less(l.Items[i].Name, l.Items[j].Name)
|
||||
}
|
||||
|
||||
// By Size
|
||||
64
filebrowser.go → lib/filebrowser.go
Normal file → Executable file
64
filebrowser.go → lib/filebrowser.go
Normal file → Executable file
@@ -1,4 +1,4 @@
|
||||
package filebrowser
|
||||
package lib
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
@@ -15,15 +15,16 @@ import (
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
|
||||
"github.com/GeertJohan/go.rice"
|
||||
rice "github.com/GeertJohan/go.rice"
|
||||
"github.com/hacdias/fileutils"
|
||||
"github.com/mholt/caddy"
|
||||
"github.com/robfig/cron"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
const (
|
||||
// Version is the current File Manager version.
|
||||
Version = "1.5.1"
|
||||
// Version is the current File Browser version.
|
||||
Version = "v1.11.0"
|
||||
|
||||
ListViewMode = "list"
|
||||
MosaicViewMode = "mosaic"
|
||||
@@ -41,6 +42,25 @@ var (
|
||||
ErrInvalidOption = errors.New("invalid option")
|
||||
)
|
||||
|
||||
// ReCaptcha settings.
|
||||
type ReCaptcha struct {
|
||||
Host string
|
||||
Key string
|
||||
Secret string
|
||||
}
|
||||
|
||||
// Auth settings.
|
||||
type Auth struct {
|
||||
// Define if which of the following authentication mechansims should be used:
|
||||
// - 'default', which requires a user and a password.
|
||||
// - 'proxy', which requires a valid user and the user name has to be provided through an
|
||||
// http header.
|
||||
// - 'none', which allows anyone to access the filebrowser instance.
|
||||
Method string
|
||||
// If 'Method' is set to 'proxy' the header configured below is used to identify the user.
|
||||
Header string
|
||||
}
|
||||
|
||||
// FileBrowser is a file manager instance. It should be creating using the
|
||||
// 'New' function and not directly.
|
||||
type FileBrowser struct {
|
||||
@@ -58,7 +78,7 @@ type FileBrowser struct {
|
||||
Store *Store
|
||||
|
||||
// PrefixURL is a part of the URL that is already trimmed from the request URL before it
|
||||
// arrives to our handlers. It may be useful when using File Manager as a middleware
|
||||
// arrives to our handlers. It may be useful when using File Browser as a middleware
|
||||
// such as in caddy-filemanager plugin. It is only useful in certain situations.
|
||||
PrefixURL string
|
||||
|
||||
@@ -67,13 +87,11 @@ type FileBrowser struct {
|
||||
// edited directly. Use SetBaseURL.
|
||||
BaseURL string
|
||||
|
||||
// NoAuth disables the authentication. When the authentication is disabled,
|
||||
// there will only exist one user, called "admin".
|
||||
NoAuth bool
|
||||
// Authentication configuration.
|
||||
Auth *Auth
|
||||
|
||||
// ReCaptcha Site key and secret.
|
||||
ReCaptchaKey string
|
||||
ReCaptchaSecret string
|
||||
// ReCaptcha host, key and secret.
|
||||
ReCaptcha *ReCaptcha
|
||||
|
||||
// StaticGen is the static websit generator handler.
|
||||
StaticGen StaticGen
|
||||
@@ -114,11 +132,11 @@ type FSBuilder func(scope string) FileSystem
|
||||
|
||||
// Setup loads the configuration from the database and configures
|
||||
// the Assets and the Cron job. It must always be run after
|
||||
// creating a File Manager object.
|
||||
// creating a File Browser object.
|
||||
func (m *FileBrowser) Setup() error {
|
||||
// Creates a new File Manager instance with the Users
|
||||
// Creates a new File Browser instance with the Users
|
||||
// map and Assets box.
|
||||
m.Assets = rice.MustFindBox("./node_modules/filebrowser-frontend/dist")
|
||||
m.Assets = rice.MustFindBox("../frontend/dist")
|
||||
m.Cron = cron.New()
|
||||
|
||||
// Tries to get the encryption key from the database.
|
||||
@@ -188,14 +206,18 @@ func (m *FileBrowser) Setup() error {
|
||||
// If there are no users in the database, it creates a new one
|
||||
// based on 'base' User that must be provided by the function caller.
|
||||
if len(users) == 0 {
|
||||
u := *m.DefaultUser
|
||||
u.Username = "admin"
|
||||
viper.SetDefault("DEFAULT_USERNAME", "admin")
|
||||
|
||||
// Hashes the password.
|
||||
u.Password, err = HashPassword("admin")
|
||||
defaultPassword, err := HashPassword("admin")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
viper.SetDefault("DEFAULT_PASSWORD_HASH", defaultPassword)
|
||||
|
||||
u := *m.DefaultUser
|
||||
u.Username = viper.GetString("DEFAULT_USERNAME")
|
||||
u.Password = viper.GetString("DEFAULT_PASSWORD_HASH")
|
||||
|
||||
// The first user must be an administrator.
|
||||
u.Admin = true
|
||||
@@ -220,7 +242,7 @@ func (m *FileBrowser) Setup() error {
|
||||
}
|
||||
|
||||
// RootURL returns the actual URL where
|
||||
// File Manager interface can be accessed.
|
||||
// File Browser interface can be accessed.
|
||||
func (m FileBrowser) RootURL() string {
|
||||
return m.PrefixURL + m.BaseURL
|
||||
}
|
||||
@@ -234,7 +256,7 @@ func (m *FileBrowser) SetPrefixURL(url string) {
|
||||
m.PrefixURL = strings.TrimSuffix(url, "/")
|
||||
}
|
||||
|
||||
// SetBaseURL updates the baseURL of a File Manager
|
||||
// SetBaseURL updates the baseURL of a File Browser
|
||||
// object.
|
||||
func (m *FileBrowser) SetBaseURL(url string) {
|
||||
url = strings.TrimPrefix(url, "/")
|
||||
@@ -243,7 +265,7 @@ func (m *FileBrowser) SetBaseURL(url string) {
|
||||
m.BaseURL = strings.TrimSuffix(url, "/")
|
||||
}
|
||||
|
||||
// Attach attaches a static generator to the current File Manager.
|
||||
// Attach attaches a static generator to the current File Browser.
|
||||
func (m *FileBrowser) Attach(s StaticGen) error {
|
||||
if reflect.TypeOf(s).Kind() != reflect.Ptr {
|
||||
return errors.New("data should be a pointer to interface, not interface")
|
||||
@@ -289,7 +311,7 @@ func (m FileBrowser) ShareCleaner() {
|
||||
func (m FileBrowser) Runner(event string, path string, destination string, user *User) error {
|
||||
commands := []string{}
|
||||
|
||||
// Get the commands from the File Manager instance itself.
|
||||
// Get the commands from the File Browser instance itself.
|
||||
if val, ok := m.Commands[event]; ok {
|
||||
commands = append(commands, val...)
|
||||
}
|
||||
@@ -9,10 +9,10 @@ import (
|
||||
|
||||
"github.com/dgrijalva/jwt-go"
|
||||
"github.com/dgrijalva/jwt-go/request"
|
||||
fm "github.com/filebrowser/filebrowser"
|
||||
fb "github.com/filebrowser/filebrowser/lib"
|
||||
)
|
||||
|
||||
const reCaptchaAPI = "https://www.google.com/recaptcha/api/siteverify"
|
||||
const reCaptchaAPI = "/recaptcha/api/siteverify"
|
||||
|
||||
type cred struct {
|
||||
Password string `json:"password"`
|
||||
@@ -21,14 +21,14 @@ type cred struct {
|
||||
}
|
||||
|
||||
// reCaptcha checks the reCaptcha code.
|
||||
func reCaptcha(secret string, response string) (bool, error) {
|
||||
func reCaptcha(host, secret, 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()))
|
||||
resp, err := client.Post(host+reCaptchaAPI, "application/x-www-form-urlencoded", strings.NewReader(body.Encode()))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -50,26 +50,38 @@ func reCaptcha(secret string, response string) (bool, error) {
|
||||
}
|
||||
|
||||
// authHandler processes the authentication for the user.
|
||||
func authHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
// NoAuth instances shouldn't call this method.
|
||||
if c.NoAuth {
|
||||
func authHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
if c.Auth.Method == "none" {
|
||||
// NoAuth instances shouldn't call this method.
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
if c.Auth.Method == "proxy" {
|
||||
// Receive the Username from the Header and check if it exists.
|
||||
u, err := c.Store.Users.GetByUsername(r.Header.Get(c.Auth.Header), c.NewFS)
|
||||
if err != nil {
|
||||
return http.StatusForbidden, nil
|
||||
}
|
||||
|
||||
c.User = u
|
||||
return printToken(c, w)
|
||||
}
|
||||
|
||||
// Receive the credentials from the request and unmarshal them.
|
||||
var cred cred
|
||||
|
||||
if r.Body == nil {
|
||||
return http.StatusForbidden, nil
|
||||
}
|
||||
|
||||
err := json.NewDecoder(r.Body).Decode(&cred)
|
||||
if err != nil {
|
||||
return http.StatusForbidden, nil
|
||||
return http.StatusForbidden, err
|
||||
}
|
||||
|
||||
// If ReCaptcha is enabled, check the code.
|
||||
if len(c.ReCaptchaSecret) > 0 {
|
||||
ok, err := reCaptcha(c.ReCaptchaSecret, cred.ReCaptcha)
|
||||
if len(c.ReCaptcha.Secret) > 0 {
|
||||
ok, err := reCaptcha(c.ReCaptcha.Host, c.ReCaptcha.Secret, cred.ReCaptcha)
|
||||
if err != nil {
|
||||
return http.StatusForbidden, err
|
||||
}
|
||||
@@ -86,7 +98,7 @@ func authHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, er
|
||||
}
|
||||
|
||||
// Checks if the password is correct.
|
||||
if !fm.CheckPasswordHash(cred.Password, u.Password) {
|
||||
if !fb.CheckPasswordHash(cred.Password, u.Password) {
|
||||
return http.StatusForbidden, nil
|
||||
}
|
||||
|
||||
@@ -96,7 +108,7 @@ func authHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, er
|
||||
|
||||
// renewAuthHandler is used when the front-end already has a JWT token
|
||||
// and is checking if it is up to date. If so, updates its info.
|
||||
func renewAuthHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func renewAuthHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
ok, u := validateAuth(c, r)
|
||||
if !ok {
|
||||
return http.StatusForbidden, nil
|
||||
@@ -108,15 +120,15 @@ func renewAuthHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (in
|
||||
|
||||
// claims is the JWT claims.
|
||||
type claims struct {
|
||||
fm.User
|
||||
fb.User
|
||||
jwt.StandardClaims
|
||||
}
|
||||
|
||||
// printToken prints the final JWT token to the user.
|
||||
func printToken(c *fm.Context, w http.ResponseWriter) (int, error) {
|
||||
func printToken(c *fb.Context, w http.ResponseWriter) (int, error) {
|
||||
// Creates a copy of the user and removes it password
|
||||
// hash so it never arrives to the user.
|
||||
u := fm.User{}
|
||||
u := fb.User{}
|
||||
u = *c.User
|
||||
u.Password = ""
|
||||
|
||||
@@ -125,7 +137,7 @@ func printToken(c *fm.Context, w http.ResponseWriter) (int, error) {
|
||||
u,
|
||||
jwt.StandardClaims{
|
||||
ExpiresAt: time.Now().Add(time.Hour * 24).Unix(),
|
||||
Issuer: "File Manager",
|
||||
Issuer: "File Browser",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -165,12 +177,22 @@ func (e extractor) ExtractToken(r *http.Request) (string, error) {
|
||||
|
||||
// validateAuth is used to validate the authentication and returns the
|
||||
// User if it is valid.
|
||||
func validateAuth(c *fm.Context, r *http.Request) (bool, *fm.User) {
|
||||
if c.NoAuth {
|
||||
func validateAuth(c *fb.Context, r *http.Request) (bool, *fb.User) {
|
||||
if c.Auth.Method == "none" {
|
||||
c.User = c.DefaultUser
|
||||
return true, c.User
|
||||
}
|
||||
|
||||
// If proxy auth is used do not verify the JWT token if the header is provided.
|
||||
if c.Auth.Method == "proxy" {
|
||||
u, err := c.Store.Users.GetByUsername(r.Header.Get(c.Auth.Header), c.NewFS)
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
c.User = u
|
||||
return true, c.User
|
||||
}
|
||||
|
||||
keyFunc := func(token *jwt.Token) (interface{}, error) {
|
||||
return c.Key, nil
|
||||
}
|
||||
@@ -7,14 +7,14 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
fm "github.com/filebrowser/filebrowser"
|
||||
fb "github.com/filebrowser/filebrowser/lib"
|
||||
"github.com/hacdias/fileutils"
|
||||
"github.com/mholt/archiver"
|
||||
)
|
||||
|
||||
// downloadHandler creates an archive in one of the supported formats (zip, tar,
|
||||
// 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 *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
// If the file isn't a directory, serve it using http.ServeFile. We display it
|
||||
// inline if it is requested.
|
||||
if !c.File.IsDir {
|
||||
@@ -30,7 +30,7 @@ func downloadHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
||||
if len(names) != 0 {
|
||||
for _, name := range names {
|
||||
// Unescape the name.
|
||||
name, err := url.QueryUnescape(name)
|
||||
name, err := url.QueryUnescape(strings.Replace(name, "+", "%2B", -1))
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
@@ -77,13 +77,12 @@ func downloadHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
||||
return 0, err
|
||||
}
|
||||
|
||||
func downloadFileHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func downloadFileHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
file, err := os.Open(c.File.Path)
|
||||
defer file.Close()
|
||||
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
stat, err := file.Stat()
|
||||
if err != nil {
|
||||
@@ -10,13 +10,13 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
fm "github.com/filebrowser/filebrowser"
|
||||
fb "github.com/filebrowser/filebrowser/lib"
|
||||
)
|
||||
|
||||
// Handler returns a function compatible with http.HandleFunc.
|
||||
func Handler(m *fm.FileBrowser) http.Handler {
|
||||
func Handler(m *fb.FileBrowser) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
code, err := serve(&fm.Context{
|
||||
code, err := serve(&fb.Context{
|
||||
FileBrowser: m,
|
||||
User: nil,
|
||||
File: nil,
|
||||
@@ -37,9 +37,9 @@ func Handler(m *fm.FileBrowser) http.Handler {
|
||||
}
|
||||
|
||||
// serve is the main entry point of this HTML application.
|
||||
func serve(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func serve(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
// Checks if the URL contains the baseURL and strips it. Otherwise, it just
|
||||
// returns a 404 fm.Error because we're not supposed to be here!
|
||||
// returns a 404 fb.Error because we're not supposed to be here!
|
||||
p := strings.TrimPrefix(r.URL.Path, c.BaseURL)
|
||||
|
||||
if len(p) >= len(r.URL.Path) && c.BaseURL != "" {
|
||||
@@ -93,7 +93,7 @@ func serve(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
}
|
||||
|
||||
// staticHandler handles the static assets path.
|
||||
func staticHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func staticHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
if r.URL.Path != "/static/manifest.json" {
|
||||
http.FileServer(c.Assets.HTTPBox()).ServeHTTP(w, r)
|
||||
return 0, nil
|
||||
@@ -103,7 +103,7 @@ func staticHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int,
|
||||
}
|
||||
|
||||
// apiHandler is the main entry point for the /api endpoint.
|
||||
func apiHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func apiHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
if r.URL.Path == "/auth/get" {
|
||||
return authHandler(c, w, r)
|
||||
}
|
||||
@@ -137,9 +137,9 @@ func apiHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, err
|
||||
}
|
||||
}
|
||||
|
||||
if c.Router == "checksum" || c.Router == "download" {
|
||||
if c.Router == "checksum" || c.Router == "download" || c.Router == "subtitle" || c.Router == "subtitles" {
|
||||
var err error
|
||||
c.File, err = fm.GetInfo(r.URL, c.FileBrowser, c.User)
|
||||
c.File, err = fb.GetInfo(r.URL, c.FileBrowser, c.User)
|
||||
if err != nil {
|
||||
return ErrorToHTTP(err, false), err
|
||||
}
|
||||
@@ -165,6 +165,10 @@ func apiHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, err
|
||||
code, err = settingsHandler(c, w, r)
|
||||
case "share":
|
||||
code, err = shareHandler(c, w, r)
|
||||
case "subtitles":
|
||||
code, err = subtitlesHandler(c, w, r)
|
||||
case "subtitle":
|
||||
code, err = subtitleHandler(c, w, r)
|
||||
default:
|
||||
code = http.StatusNotFound
|
||||
}
|
||||
@@ -173,11 +177,11 @@ func apiHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, err
|
||||
}
|
||||
|
||||
// serveChecksum calculates the hash of a file. Supports MD5, SHA1, SHA256 and SHA512.
|
||||
func checksumHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func checksumHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
query := r.URL.Query().Get("algo")
|
||||
|
||||
val, err := c.File.Checksum(query)
|
||||
if err == fm.ErrInvalidOption {
|
||||
if err == fb.ErrInvalidOption {
|
||||
return http.StatusBadRequest, err
|
||||
} else if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
@@ -205,7 +209,7 @@ func splitURL(path string) (string, string) {
|
||||
}
|
||||
|
||||
// renderFile renders a file using a template with some needed variables.
|
||||
func renderFile(c *fm.Context, w http.ResponseWriter, file string) (int, error) {
|
||||
func renderFile(c *fb.Context, w http.ResponseWriter, file string) (int, error) {
|
||||
tpl := template.Must(template.New("file").Parse(c.Assets.MustString(file)))
|
||||
|
||||
var contentType string
|
||||
@@ -223,16 +227,17 @@ func renderFile(c *fm.Context, w http.ResponseWriter, file string) (int, error)
|
||||
w.Header().Set("Content-Type", contentType+"; charset=utf-8")
|
||||
|
||||
data := map[string]interface{}{
|
||||
"BaseURL": c.RootURL(),
|
||||
"NoAuth": c.NoAuth,
|
||||
"Version": fm.Version,
|
||||
"CSS": template.CSS(c.CSS),
|
||||
"ReCaptcha": c.ReCaptchaKey != "" && c.ReCaptchaSecret != "",
|
||||
"ReCaptchaKey": c.ReCaptchaKey,
|
||||
"baseurl": c.RootURL(),
|
||||
"NoAuth": c.Auth.Method == "none",
|
||||
"Version": fb.Version,
|
||||
"CSS": template.CSS(c.CSS),
|
||||
"ReCaptcha": c.ReCaptcha.Key != "" && c.ReCaptcha.Secret != "",
|
||||
"ReCaptchaHost": c.ReCaptcha.Host,
|
||||
"ReCaptchaKey": c.ReCaptcha.Key,
|
||||
}
|
||||
|
||||
if c.StaticGen != nil {
|
||||
data["StaticGen"] = c.StaticGen.Name()
|
||||
data["staticgen"] = c.StaticGen.Name()
|
||||
}
|
||||
|
||||
err := tpl.Execute(w, data)
|
||||
@@ -245,9 +250,9 @@ func renderFile(c *fm.Context, w http.ResponseWriter, file string) (int, error)
|
||||
}
|
||||
|
||||
// sharePage build the share page.
|
||||
func sharePage(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func sharePage(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
s, err := c.Store.Share.Get(r.URL.Path)
|
||||
if err == fm.ErrNotExist {
|
||||
if err == fb.ErrNotExist {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
return renderFile(c, w, "static/share/404.html")
|
||||
}
|
||||
@@ -270,7 +275,7 @@ func sharePage(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, erro
|
||||
return ErrorToHTTP(err, false), err
|
||||
}
|
||||
|
||||
c.File = &fm.File{
|
||||
c.File = &fb.File{
|
||||
Path: s.Path,
|
||||
Name: info.Name(),
|
||||
ModTime: info.ModTime(),
|
||||
@@ -286,7 +291,7 @@ func sharePage(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, erro
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
|
||||
err := tpl.Execute(w, map[string]interface{}{
|
||||
"BaseURL": c.RootURL(),
|
||||
"baseurl": c.RootURL(),
|
||||
"File": c.File,
|
||||
})
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
fm "github.com/filebrowser/filebrowser"
|
||||
fb "github.com/filebrowser/filebrowser/lib"
|
||||
"github.com/hacdias/fileutils"
|
||||
)
|
||||
|
||||
@@ -27,7 +27,7 @@ func sanitizeURL(url string) string {
|
||||
return path
|
||||
}
|
||||
|
||||
func resourceHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func resourceHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
r.URL.Path = sanitizeURL(r.URL.Path)
|
||||
|
||||
switch r.Method {
|
||||
@@ -62,9 +62,9 @@ func resourceHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
||||
return http.StatusNotImplemented, nil
|
||||
}
|
||||
|
||||
func resourceGetHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func resourceGetHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
// Gets the information of the directory/file.
|
||||
f, err := fm.GetInfo(r.URL, c.FileBrowser, c.User)
|
||||
f, err := fb.GetInfo(r.URL, c.FileBrowser, c.User)
|
||||
if err != nil {
|
||||
return ErrorToHTTP(err, false), err
|
||||
}
|
||||
@@ -104,7 +104,7 @@ func resourceGetHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (
|
||||
return renderJSON(w, f)
|
||||
}
|
||||
|
||||
func listingHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func listingHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
f := c.File
|
||||
f.Kind = "listing"
|
||||
|
||||
@@ -133,7 +133,7 @@ func listingHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int,
|
||||
return renderJSON(w, f)
|
||||
}
|
||||
|
||||
func resourceDeleteHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func resourceDeleteHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
// Prevent the removal of the root directory.
|
||||
if r.URL.Path == "/" || !c.User.AllowEdit {
|
||||
return http.StatusForbidden, nil
|
||||
@@ -158,7 +158,7 @@ func resourceDeleteHandler(c *fm.Context, w http.ResponseWriter, r *http.Request
|
||||
return http.StatusOK, nil
|
||||
}
|
||||
|
||||
func resourcePostPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func resourcePostPutHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
if !c.User.AllowNew && r.Method == http.MethodPost {
|
||||
return http.StatusForbidden, nil
|
||||
}
|
||||
@@ -182,7 +182,7 @@ func resourcePostPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Reques
|
||||
}
|
||||
|
||||
// Otherwise we try to create the directory.
|
||||
err := c.User.FileSystem.Mkdir(r.URL.Path, 0776)
|
||||
err := c.User.FileSystem.Mkdir(r.URL.Path, 0775)
|
||||
return ErrorToHTTP(err, false), err
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ func resourcePostPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Reques
|
||||
}
|
||||
|
||||
// Create/Open the file.
|
||||
f, err := c.User.FileSystem.OpenFile(r.URL.Path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0776)
|
||||
f, err := c.User.FileSystem.OpenFile(r.URL.Path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0775)
|
||||
if err != nil {
|
||||
return ErrorToHTTP(err, false), err
|
||||
}
|
||||
@@ -240,7 +240,7 @@ func resourcePostPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Reques
|
||||
return http.StatusOK, nil
|
||||
}
|
||||
|
||||
func resourcePublishSchedule(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func resourcePublishSchedule(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
publish := r.Header.Get("Publish")
|
||||
schedule := r.Header.Get("Schedule")
|
||||
|
||||
@@ -271,7 +271,7 @@ func resourcePublishSchedule(c *fm.Context, w http.ResponseWriter, r *http.Reque
|
||||
return http.StatusOK, nil
|
||||
}
|
||||
|
||||
func resourcePublish(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func resourcePublish(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
path := filepath.Join(c.User.Scope, r.URL.Path)
|
||||
|
||||
// Before save command handler.
|
||||
@@ -293,7 +293,7 @@ func resourcePublish(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
||||
}
|
||||
|
||||
// resourcePatchHandler is the entry point for resource handler.
|
||||
func resourcePatchHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func resourcePatchHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
if !c.User.AllowEdit {
|
||||
return http.StatusForbidden, nil
|
||||
}
|
||||
@@ -6,12 +6,12 @@ import (
|
||||
"net/http"
|
||||
"reflect"
|
||||
|
||||
fm "github.com/filebrowser/filebrowser"
|
||||
fb "github.com/filebrowser/filebrowser/lib"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
)
|
||||
|
||||
type modifySettingsRequest struct {
|
||||
*modifyRequest
|
||||
modifyRequest
|
||||
Data struct {
|
||||
CSS string `json:"css"`
|
||||
Commands map[string][]string `json:"commands"`
|
||||
@@ -28,7 +28,7 @@ type option struct {
|
||||
func parsePutSettingsRequest(r *http.Request) (*modifySettingsRequest, error) {
|
||||
// Checks if the request body is empty.
|
||||
if r.Body == nil {
|
||||
return nil, fm.ErrEmptyRequest
|
||||
return nil, fb.ErrEmptyRequest
|
||||
}
|
||||
|
||||
// Parses the request body and checks if it's well formed.
|
||||
@@ -40,13 +40,13 @@ func parsePutSettingsRequest(r *http.Request) (*modifySettingsRequest, error) {
|
||||
|
||||
// Checks if the request type is right.
|
||||
if mod.What != "settings" {
|
||||
return nil, fm.ErrWrongDataType
|
||||
return nil, fb.ErrWrongDataType
|
||||
}
|
||||
|
||||
return mod, nil
|
||||
}
|
||||
|
||||
func settingsHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func settingsHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
if r.URL.Path != "" && r.URL.Path != "/" {
|
||||
return http.StatusNotFound, nil
|
||||
}
|
||||
@@ -67,7 +67,7 @@ type settingsGetRequest struct {
|
||||
StaticGen []option `json:"staticGen"`
|
||||
}
|
||||
|
||||
func settingsGetHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func settingsGetHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
if !c.User.Admin {
|
||||
return http.StatusForbidden, nil
|
||||
}
|
||||
@@ -97,7 +97,7 @@ func settingsGetHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (
|
||||
return renderJSON(w, result)
|
||||
}
|
||||
|
||||
func settingsPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func settingsPutHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
if !c.User.Admin {
|
||||
return http.StatusForbidden, nil
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"encoding/base64"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
fm "github.com/filebrowser/filebrowser"
|
||||
fb "github.com/filebrowser/filebrowser/lib"
|
||||
)
|
||||
|
||||
func shareHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func shareHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
r.URL.Path = sanitizeURL(r.URL.Path)
|
||||
|
||||
switch r.Method {
|
||||
@@ -26,10 +26,10 @@ func shareHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, e
|
||||
return http.StatusNotImplemented, nil
|
||||
}
|
||||
|
||||
func shareGetHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func shareGetHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
path := filepath.Join(c.User.Scope, r.URL.Path)
|
||||
s, err := c.Store.Share.GetByPath(path)
|
||||
if err == fm.ErrNotExist {
|
||||
if err == fb.ErrNotExist {
|
||||
return http.StatusNotFound, nil
|
||||
}
|
||||
|
||||
@@ -51,10 +51,10 @@ func shareGetHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
||||
return renderJSON(w, s)
|
||||
}
|
||||
|
||||
func sharePostHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func sharePostHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
path := filepath.Join(c.User.Scope, r.URL.Path)
|
||||
|
||||
var s *fm.ShareLink
|
||||
var s *fb.ShareLink
|
||||
expire := r.URL.Query().Get("expires")
|
||||
unit := r.URL.Query().Get("unit")
|
||||
|
||||
@@ -67,14 +67,14 @@ func sharePostHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (in
|
||||
}
|
||||
}
|
||||
|
||||
bytes, err := fm.GenerateRandomBytes(32)
|
||||
bytes, err := fb.GenerateRandomBytes(6)
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
str := hex.EncodeToString(bytes)
|
||||
str := base64.URLEncoding.EncodeToString(bytes)
|
||||
|
||||
s = &fm.ShareLink{
|
||||
s = &fb.ShareLink{
|
||||
Path: path,
|
||||
Hash: str,
|
||||
Expires: expire != "",
|
||||
@@ -108,9 +108,9 @@ func sharePostHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (in
|
||||
return renderJSON(w, s)
|
||||
}
|
||||
|
||||
func shareDeleteHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func shareDeleteHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
s, err := c.Store.Share.Get(strings.TrimPrefix(r.URL.Path, "/"))
|
||||
if err == fm.ErrNotExist {
|
||||
if err == fb.ErrNotExist {
|
||||
return http.StatusNotFound, nil
|
||||
}
|
||||
|
||||
83
lib/http/subtitle.go
Normal file
83
lib/http/subtitle.go
Normal file
@@ -0,0 +1,83 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
|
||||
fb "github.com/filebrowser/filebrowser/lib"
|
||||
)
|
||||
|
||||
func subtitlesHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
files, err := readDir(filepath.Dir(c.File.Path))
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
subtitles := make([]map[string]string, 0)
|
||||
for _, file := range files {
|
||||
ext := filepath.Ext(file.Name())
|
||||
if ext == ".vtt" || ext == ".srt" {
|
||||
sub := make(map[string]string)
|
||||
sub["src"] = filepath.Dir(c.File.Path) + "/" + file.Name()
|
||||
sub["kind"] = "subtitles"
|
||||
sub["label"] = file.Name()
|
||||
subtitles = append(subtitles, sub)
|
||||
}
|
||||
}
|
||||
return renderJSON(w, subtitles)
|
||||
}
|
||||
|
||||
func subtitleHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
str, err := cleanSubtitle(c.File.Path)
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
file, err := os.Open(c.File.Path)
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
stat, err := file.Stat()
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Disposition", "inline")
|
||||
w.Header().Set("Content-Type", "text/vtt")
|
||||
http.ServeContent(w, r, stat.Name(), stat.ModTime(), bytes.NewReader([]byte(str)))
|
||||
|
||||
return 0, nil
|
||||
|
||||
}
|
||||
|
||||
func cleanSubtitle(filename string) (string, error) {
|
||||
b, err := ioutil.ReadFile(filename)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
str := string(b) // convert content to a 'string'
|
||||
ext := filepath.Ext(filename)
|
||||
if ext == ".srt" {
|
||||
re := regexp.MustCompile("([0-9]{2}:[0-9]{2}:[0-9]{2}),([0-9]{3})")
|
||||
str = "WEBVTT\n\n" + re.ReplaceAllString(str, "$1.$2")
|
||||
}
|
||||
return str, err
|
||||
}
|
||||
|
||||
func readDir(dirname string) ([]os.FileInfo, error) {
|
||||
f, err := os.Open(dirname)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list, err := f.Readdir(-1)
|
||||
f.Close()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
fm "github.com/filebrowser/filebrowser"
|
||||
fb "github.com/filebrowser/filebrowser/lib"
|
||||
)
|
||||
|
||||
type modifyRequest struct {
|
||||
@@ -18,13 +18,13 @@ type modifyRequest struct {
|
||||
}
|
||||
|
||||
type modifyUserRequest struct {
|
||||
*modifyRequest
|
||||
Data *fm.User `json:"data"`
|
||||
modifyRequest
|
||||
Data *fb.User `json:"data"`
|
||||
}
|
||||
|
||||
// usersHandler is the entry point of the users API. It's just a router
|
||||
// to send the request to its
|
||||
func usersHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func usersHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
// If the user isn't admin and isn't making a PUT
|
||||
// request, then return forbidden.
|
||||
if !c.User.Admin && r.Method != http.MethodPut {
|
||||
@@ -47,7 +47,7 @@ func usersHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, e
|
||||
|
||||
// getUserID returns the id from the user which is present
|
||||
// in the request url. If the url is invalid and doesn't
|
||||
// contain a valid ID, it returns an fm.Error.
|
||||
// contain a valid ID, it returns an fb.Error.
|
||||
func getUserID(r *http.Request) (int, error) {
|
||||
// Obtains the ID in string from the URL and converts
|
||||
// it into an integer.
|
||||
@@ -63,11 +63,11 @@ func getUserID(r *http.Request) (int, error) {
|
||||
|
||||
// getUser returns the user which is present in the request
|
||||
// body. If the body is empty or the JSON is invalid, it
|
||||
// returns an fm.Error.
|
||||
func getUser(c *fm.Context, r *http.Request) (*fm.User, string, error) {
|
||||
// returns an fb.Error.
|
||||
func getUser(c *fb.Context, r *http.Request) (*fb.User, string, error) {
|
||||
// Checks if the request body is empty.
|
||||
if r.Body == nil {
|
||||
return nil, "", fm.ErrEmptyRequest
|
||||
return nil, "", fb.ErrEmptyRequest
|
||||
}
|
||||
|
||||
// Parses the request body and checks if it's well formed.
|
||||
@@ -79,14 +79,14 @@ func getUser(c *fm.Context, r *http.Request) (*fm.User, string, error) {
|
||||
|
||||
// Checks if the request type is right.
|
||||
if mod.What != "user" {
|
||||
return nil, "", fm.ErrWrongDataType
|
||||
return nil, "", fb.ErrWrongDataType
|
||||
}
|
||||
|
||||
mod.Data.FileSystem = c.NewFS(mod.Data.Scope)
|
||||
return mod.Data, mod.Which, nil
|
||||
}
|
||||
|
||||
func usersGetHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func usersGetHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
// Request for the default user data.
|
||||
if r.URL.Path == "/base" {
|
||||
return renderJSON(w, c.DefaultUser)
|
||||
@@ -118,7 +118,7 @@ func usersGetHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
||||
}
|
||||
|
||||
u, err := c.Store.Users.Get(id, c.NewFS)
|
||||
if err == fm.ErrExist {
|
||||
if err == fb.ErrExist {
|
||||
return http.StatusNotFound, err
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ func usersGetHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
||||
return renderJSON(w, u)
|
||||
}
|
||||
|
||||
func usersPostHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func usersPostHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
if r.URL.Path != "/" {
|
||||
return http.StatusMethodNotAllowed, nil
|
||||
}
|
||||
@@ -142,22 +142,22 @@ func usersPostHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (in
|
||||
|
||||
// Checks if username isn't empty.
|
||||
if u.Username == "" {
|
||||
return http.StatusBadRequest, fm.ErrEmptyUsername
|
||||
return http.StatusBadRequest, fb.ErrEmptyUsername
|
||||
}
|
||||
|
||||
// Checks if scope isn't empty.
|
||||
if u.Scope == "" {
|
||||
return http.StatusBadRequest, fm.ErrEmptyScope
|
||||
return http.StatusBadRequest, fb.ErrEmptyScope
|
||||
}
|
||||
|
||||
// Checks if password isn't empty.
|
||||
if u.Password == "" {
|
||||
return http.StatusBadRequest, fm.ErrEmptyPassword
|
||||
return http.StatusBadRequest, fb.ErrEmptyPassword
|
||||
}
|
||||
|
||||
// Initialize rules if they're not initialized.
|
||||
if u.Rules == nil {
|
||||
u.Rules = []*fm.Rule{}
|
||||
u.Rules = []*fb.Rule{}
|
||||
}
|
||||
|
||||
// If the view mode is empty, initialize with the default one.
|
||||
@@ -181,17 +181,17 @@ func usersPostHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (in
|
||||
}
|
||||
|
||||
// Hashes the password.
|
||||
pw, err := fm.HashPassword(u.Password)
|
||||
pw, err := fb.HashPassword(u.Password)
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
u.Password = pw
|
||||
u.ViewMode = fm.MosaicViewMode
|
||||
u.ViewMode = fb.MosaicViewMode
|
||||
|
||||
// Saves the user to the database.
|
||||
err = c.Store.Users.Save(u)
|
||||
if err == fm.ErrExist {
|
||||
if err == fb.ErrExist {
|
||||
return http.StatusConflict, err
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ func checkFS(path string) (int, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
func usersDeleteHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func usersDeleteHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
if r.URL.Path == "/" {
|
||||
return http.StatusMethodNotAllowed, nil
|
||||
}
|
||||
@@ -240,8 +240,8 @@ func usersDeleteHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (
|
||||
|
||||
// Deletes the user from the database.
|
||||
err = c.Store.Users.Delete(id)
|
||||
if err == fm.ErrNotExist {
|
||||
return http.StatusNotFound, fm.ErrNotExist
|
||||
if err == fb.ErrNotExist {
|
||||
return http.StatusNotFound, fb.ErrNotExist
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@@ -251,7 +251,7 @@ func usersDeleteHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (
|
||||
return http.StatusOK, nil
|
||||
}
|
||||
|
||||
func usersPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func usersPutHandler(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
// New users should be created on /api/users.
|
||||
if r.URL.Path == "/" {
|
||||
return http.StatusMethodNotAllowed, nil
|
||||
@@ -276,7 +276,7 @@ func usersPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
||||
|
||||
// If we're updating the default user. Only for NoAuth
|
||||
// implementations. Used to change the viewMode.
|
||||
if id == 0 && c.NoAuth {
|
||||
if id == 0 && c.Auth.Method == "none" {
|
||||
c.DefaultUser.ViewMode = u.ViewMode
|
||||
return http.StatusOK, nil
|
||||
}
|
||||
@@ -298,14 +298,14 @@ func usersPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
||||
// Updates the Password.
|
||||
if which == "password" {
|
||||
if u.Password == "" {
|
||||
return http.StatusBadRequest, fm.ErrEmptyPassword
|
||||
return http.StatusBadRequest, fb.ErrEmptyPassword
|
||||
}
|
||||
|
||||
if id == c.User.ID && c.User.LockPassword {
|
||||
return http.StatusForbidden, nil
|
||||
}
|
||||
|
||||
c.User.Password, err = fm.HashPassword(u.Password)
|
||||
c.User.Password, err = fb.HashPassword(u.Password)
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
@@ -320,17 +320,17 @@ func usersPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
||||
|
||||
// If can only be all.
|
||||
if which != "all" {
|
||||
return http.StatusBadRequest, fm.ErrInvalidUpdateField
|
||||
return http.StatusBadRequest, fb.ErrInvalidUpdateField
|
||||
}
|
||||
|
||||
// Checks if username isn't empty.
|
||||
if u.Username == "" {
|
||||
return http.StatusBadRequest, fm.ErrEmptyUsername
|
||||
return http.StatusBadRequest, fb.ErrEmptyUsername
|
||||
}
|
||||
|
||||
// Checks if filesystem isn't empty.
|
||||
if u.Scope == "" {
|
||||
return http.StatusBadRequest, fm.ErrEmptyScope
|
||||
return http.StatusBadRequest, fb.ErrEmptyScope
|
||||
}
|
||||
|
||||
// Checks if the scope exists.
|
||||
@@ -340,7 +340,7 @@ func usersPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
||||
|
||||
// Initialize rules if they're not initialized.
|
||||
if u.Rules == nil {
|
||||
u.Rules = []*fm.Rule{}
|
||||
u.Rules = []*fb.Rule{}
|
||||
}
|
||||
|
||||
// Initialize commands if not initialized.
|
||||
@@ -350,7 +350,7 @@ func usersPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
||||
|
||||
// Gets the current saved user from the in-memory map.
|
||||
suser, err := c.Store.Users.Get(id, c.NewFS)
|
||||
if err == fm.ErrNotExist {
|
||||
if err == fb.ErrNotExist {
|
||||
return http.StatusNotFound, nil
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ func usersPutHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
||||
|
||||
// Changes the password if the request wants it.
|
||||
if u.Password != "" {
|
||||
pw, err := fm.HashPassword(u.Password)
|
||||
pw, err := fb.HashPassword(u.Password)
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
fm "github.com/filebrowser/filebrowser"
|
||||
fb "github.com/filebrowser/filebrowser/lib"
|
||||
"github.com/gorilla/websocket"
|
||||
)
|
||||
|
||||
@@ -27,8 +27,8 @@ var (
|
||||
)
|
||||
|
||||
// command handles the requests for VCS related commands: git, svn and mercurial
|
||||
func command(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
// Upgrades the connection to a websocket and checks for fm.Errors.
|
||||
func command(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
// Upgrades the connection to a websocket and checks for fb.Errors.
|
||||
conn, err := upgrader.Upgrade(w, r, nil)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -57,13 +57,14 @@ func command(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error)
|
||||
allowed := false
|
||||
|
||||
for _, cmd := range c.User.Commands {
|
||||
if cmd == command[0] {
|
||||
if regexp.MustCompile(cmd).MatchString(command[0]) {
|
||||
allowed = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !allowed {
|
||||
err = conn.WriteMessage(websocket.BinaryMessage, cmdNotAllowed)
|
||||
err = conn.WriteMessage(websocket.TextMessage, cmdNotAllowed)
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
@@ -71,9 +72,9 @@ func command(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error)
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// Check if the program is talled is installed on the computer.
|
||||
// Check if the program is installed on the computer.
|
||||
if _, err = exec.LookPath(command[0]); err != nil {
|
||||
err = conn.WriteMessage(websocket.BinaryMessage, cmdNotImplemented)
|
||||
err = conn.WriteMessage(websocket.TextMessage, cmdNotImplemented)
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
@@ -92,7 +93,7 @@ func command(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error)
|
||||
cmd.Stderr = buff
|
||||
cmd.Stdout = buff
|
||||
|
||||
// Starts the command and checks for fm.Errors.
|
||||
// Starts the command and checks for fb.Errors.
|
||||
err = cmd.Start()
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
@@ -146,9 +147,9 @@ var (
|
||||
type condition func(path string) bool
|
||||
|
||||
type searchOptions struct {
|
||||
CaseInsensitive bool
|
||||
Conditions []condition
|
||||
Terms []string
|
||||
CaseSensitive bool
|
||||
Conditions []condition
|
||||
Terms []string
|
||||
}
|
||||
|
||||
func extensionCondition(extension string) condition {
|
||||
@@ -180,9 +181,9 @@ func videoCondition(path string) bool {
|
||||
|
||||
func parseSearch(value string) *searchOptions {
|
||||
opts := &searchOptions{
|
||||
CaseInsensitive: strings.Contains(value, "case:insensitive"),
|
||||
Conditions: []condition{},
|
||||
Terms: []string{},
|
||||
CaseSensitive: strings.Contains(value, "case:sensitive"),
|
||||
Conditions: []condition{},
|
||||
Terms: []string{},
|
||||
}
|
||||
|
||||
// removes the options from the value
|
||||
@@ -214,7 +215,7 @@ func parseSearch(value string) *searchOptions {
|
||||
}
|
||||
|
||||
// If it's canse insensitive, put everything in lowercase.
|
||||
if opts.CaseInsensitive {
|
||||
if !opts.CaseSensitive {
|
||||
value = strings.ToLower(value)
|
||||
}
|
||||
|
||||
@@ -240,8 +241,8 @@ func parseSearch(value string) *searchOptions {
|
||||
}
|
||||
|
||||
// search searches for a file or directory.
|
||||
func search(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
// Upgrades the connection to a websocket and checks for fm.Errors.
|
||||
func search(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
// Upgrades the connection to a websocket and checks for fb.Errors.
|
||||
conn, err := upgrader.Upgrade(w, r, nil)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -275,14 +276,20 @@ func search(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error)
|
||||
scope = filepath.Clean(scope)
|
||||
|
||||
err = filepath.Walk(scope, func(path string, f os.FileInfo, err error) error {
|
||||
if search.CaseInsensitive {
|
||||
path = strings.ToLower(path)
|
||||
}
|
||||
var (
|
||||
originalPath string
|
||||
)
|
||||
|
||||
path = strings.TrimPrefix(path, scope)
|
||||
path = strings.TrimPrefix(path, "/")
|
||||
path = strings.Replace(path, "\\", "/", -1)
|
||||
|
||||
originalPath = path
|
||||
|
||||
if !search.CaseSensitive {
|
||||
path = strings.ToLower(path)
|
||||
}
|
||||
|
||||
// Only execute if there are conditions to meet.
|
||||
if len(search.Conditions) > 0 {
|
||||
match := false
|
||||
@@ -322,10 +329,13 @@ func search(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
if f.IsDir() {
|
||||
originalPath = originalPath + "/"
|
||||
}
|
||||
|
||||
response, _ := json.Marshal(map[string]interface{}{
|
||||
"dir": f.IsDir(),
|
||||
"path": path,
|
||||
"path": originalPath,
|
||||
})
|
||||
|
||||
return conn.WriteMessage(websocket.TextMessage, response)
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
fm "github.com/filebrowser/filebrowser"
|
||||
fb "github.com/filebrowser/filebrowser/lib"
|
||||
"github.com/hacdias/varutils"
|
||||
)
|
||||
|
||||
@@ -64,7 +64,7 @@ func (h Hugo) Name() string {
|
||||
}
|
||||
|
||||
// Hook is the pre-api handler.
|
||||
func (h Hugo) Hook(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func (h Hugo) Hook(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
// If we are not using HTTP Post, we shall return Method Not Allowed
|
||||
// since we are only working with this method.
|
||||
if r.Method != http.MethodPost {
|
||||
@@ -108,7 +108,7 @@ func (h Hugo) Hook(c *fm.Context, w http.ResponseWriter, r *http.Request) (int,
|
||||
}
|
||||
|
||||
// Publish publishes a post.
|
||||
func (h Hugo) Publish(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func (h Hugo) Publish(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
filename := filepath.Join(c.User.Scope, r.URL.Path)
|
||||
|
||||
// We only run undraft command if it is a file.
|
||||
@@ -125,7 +125,7 @@ func (h Hugo) Publish(c *fm.Context, w http.ResponseWriter, r *http.Request) (in
|
||||
}
|
||||
|
||||
// Preview handles the preview path.
|
||||
func (h *Hugo) Preview(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func (h *Hugo) Preview(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
// Get a new temporary path if there is none.
|
||||
if h.previewPath == "" {
|
||||
path, err := ioutil.TempDir("", "")
|
||||
@@ -187,9 +187,6 @@ func (h Hugo) undraft(file string) error {
|
||||
// Setup sets up the plugin.
|
||||
func (h *Hugo) Setup() error {
|
||||
var err error
|
||||
if h.Exe, err = exec.LookPath("hugo"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
h.Exe, err = exec.LookPath("hugo")
|
||||
return err
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
fm "github.com/filebrowser/filebrowser"
|
||||
fb "github.com/filebrowser/filebrowser/lib"
|
||||
)
|
||||
|
||||
// Jekyll is the Jekyll static website generator.
|
||||
@@ -39,12 +39,12 @@ func (j Jekyll) SettingsPath() string {
|
||||
}
|
||||
|
||||
// Hook is the pre-api handler.
|
||||
func (j Jekyll) Hook(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func (j Jekyll) Hook(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// Publish publishes a post.
|
||||
func (j Jekyll) Publish(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func (j Jekyll) Publish(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
filename := filepath.Join(c.User.Scope, r.URL.Path)
|
||||
|
||||
// We only run undraft command if it is a file.
|
||||
@@ -59,7 +59,7 @@ func (j Jekyll) Publish(c *fm.Context, w http.ResponseWriter, r *http.Request) (
|
||||
}
|
||||
|
||||
// Preview handles the preview path.
|
||||
func (j *Jekyll) Preview(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func (j *Jekyll) Preview(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
// Get a new temporary path if there is none.
|
||||
if j.previewPath == "" {
|
||||
path, err := ioutil.TempDir("", "")
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"name": "filebrowser",
|
||||
"author": "File Browser contributors",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"filebrowser-frontend": "^1.0.3"
|
||||
}
|
||||
}
|
||||
21
publish.sh
21
publish.sh
@@ -1,21 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "Building assets"
|
||||
./build.sh
|
||||
|
||||
echo "Updating version number to $1..."
|
||||
sed -i "s|(untracked)|$1|g" filebrowser.go
|
||||
git add -A
|
||||
git commit -m "chore: version $1"
|
||||
git tag "v$1"
|
||||
git push
|
||||
git push --tags
|
||||
|
||||
echo "Commiting untracked version notice..."
|
||||
sed -i "s|$1|(untracked)|g" filebrowser.go
|
||||
git add -A
|
||||
git commit -m "chore: setting untracked version [ci skip]"
|
||||
git push
|
||||
|
||||
echo "Done!"
|
||||
@@ -1 +0,0 @@
|
||||
48f80ccfd160585c4a9e60e1f90399ec17c185ea
|
||||
Reference in New Issue
Block a user