Skip to content

Commit

Permalink
remove external filebrowser
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay committed Dec 17, 2024
1 parent 8e11ee8 commit b2d294a
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 71 deletions.
14 changes: 0 additions & 14 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ services:
SERVER_NAME: "dev-server"
DEFAULT_THEME: "darkly"
ENABLE_FEATURES: "shell,luashell,minetest_config,docker,modmanagement,signup,chat,minetest_web"
FILEBROWSER_URL: "http://filebrowser/"
INSTALL_MTUI_MOD: "true"
MINETEST_CONFIG: "/world/minetest.conf"
GEOIP_API: "https://hosting.minetest.ch/api/geoip"
Expand All @@ -40,21 +39,8 @@ services:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
working_dir: /app
command: ["go", "run", "."]

filebrowser:
image: filebrowser/filebrowser:v2.31.2
ports:
- 8081:80
environment:
FB_DATABASE: /database/filebrowser.db
FB_BASEURL: /filebrowser
FB_NOAUTH: "true"
volumes:
- world_dir:/srv
- filebrowser_db:/database

volumes:
go_cache: {}
go_dir: {}
world_dir: {}
filebrowser_db: {}
30 changes: 5 additions & 25 deletions public/js/components/pages/filebrowser/Filebrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import format_size from "../../../util/format_size.js";
import format_time from "../../../util/format_time.js";
import { START, FILEBROWSER } from "../../Breadcrumb.js";
import { can_edit } from "./common.js";
import { get_filebrowser_enabled } from "../../../service/stats.js";

export default {
props: ["pathMatch"],
Expand All @@ -26,7 +25,7 @@ export default {
data: function() {
return {
result: null,
mkfile_name: "",
mkdir_name: "",
move_name: "",
move_target: "",
upload_archive_busy: false,
Expand All @@ -41,14 +40,9 @@ export default {
get_targz_url,
get_download_url,
mkdir: function() {
mkdir(this.result.dir + "/" + this.mkfile_name)
mkdir(this.result.dir + "/" + this.mkdir_name)
.then(() => this.browse_dir())
.then(() => this.mkfile_name = "");
},
mkfile: function() {
upload(this.result.dir + "/" + this.mkfile_name, "")
.then(() => this.browse_dir())
.then(() => this.mkfile_name = "");
.then(() => this.mkdir_name = "");
},
upload: function() {
const files = Array.from(this.$refs.input_upload.files);
Expand Down Expand Up @@ -115,7 +109,6 @@ export default {
});
},
can_edit: can_edit,
filebrowser_enabled: get_filebrowser_enabled,
is_json_profile: function(filename) {
return filename.match(/^profile-.*.json$/);
},
Expand Down Expand Up @@ -168,28 +161,15 @@ export default {
},
template: /*html*/`
<default-layout icon="folder" title="Filebrowser" :breadcrumb="breadcrumb">
<div class="row" v-if="filebrowser_enabled">
<div class="col-md-12">
<div class="alert alert-info">
<i class="fa fa-info"></i>
<b>Note: </b> To upload larger files use the dedicated <a href="filebrowser/">filebrowser</a> interface and enable the maintenance mode for database files
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="input-group">
<input type="text" v-model="mkfile_name" class="form-control" placeholder="Directory name"/>
<button class="btn btn-secondary" v-on:click="mkdir" :disabled="!mkfile_name">
<input type="text" v-model="mkdir_name" class="form-control" placeholder="Directory name"/>
<button class="btn btn-secondary" v-on:click="mkdir" :disabled="!mkdir_name">
<i class="fa fa-folder"></i>
<i class="fa fa-plus"></i>
Create directory
</button>
<button class="btn btn-secondary" v-on:click="mkfile" :disabled="!mkfile_name">
<i class="fa fa-file"></i>
<i class="fa fa-plus"></i>
Create file
</button>
</div>
</div>
<div class="col-md-3">
Expand Down
1 change: 0 additions & 1 deletion public/js/service/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ export const stop_polling = () => clearInterval(handle);
export const get_player_count = () => store.player_count;
export const get_players = () => store.players;
export const get_maintenance = () => store.maintenance;
export const get_filebrowser_enabled = () => store.filebrowser_enabled;
4 changes: 0 additions & 4 deletions types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ type Config struct {
Webdev bool
Servername string
EnabledFeatures []string
FilebrowserURL string
FilebrowserProxyPath string
InstallMtuiMod bool
AutoReconfigureMods bool
LogStreamURL string
Expand Down Expand Up @@ -50,8 +48,6 @@ func NewConfig(world_dir string) *Config {
Webdev: os.Getenv("WEBDEV") == "true",
Servername: os.Getenv("SERVER_NAME"),
EnabledFeatures: strings.Split(os.Getenv("ENABLE_FEATURES"), ","),
FilebrowserURL: os.Getenv("FILEBROWSER_URL"),
FilebrowserProxyPath: os.Getenv("FILEBROWSER_PROXY_PATH"),
InstallMtuiMod: os.Getenv("INSTALL_MTUI_MOD") == "true",
AutoReconfigureMods: os.Getenv("AUTORECONFIGURE_MODS") == "true",
LogStreamURL: os.Getenv("LOG_STREAM_URL"),
Expand Down
23 changes: 0 additions & 23 deletions web/setup.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package web

import (
"fmt"
"mtui/app"
"mtui/public"
"mtui/types"
"net/http"
"net/http/httputil"
"net/url"
"os"
"time"

Expand All @@ -31,26 +28,6 @@ func Setup(a *app.App) error {
return err
}

if a.Config.FilebrowserURL != "" {
// enable filebrowser access with "server" priv
remote, err := url.Parse(a.Config.FilebrowserURL)
if err != nil {
return err
}

handler := func(p *httputil.ReverseProxy) func(http.ResponseWriter, *http.Request) {
return api.SecurePriv("server", func(w http.ResponseWriter, r *http.Request, c *types.Claims) {
r.Host = remote.Host
// prepend proxy path
r.URL.Path = fmt.Sprintf("%s%s", a.Config.FilebrowserProxyPath, r.URL.Path)
p.ServeHTTP(w, r)
})
}

proxy := httputil.NewSingleHostReverseProxy(remote)
r.PathPrefix("/filebrowser/").HandlerFunc(handler(proxy))
}

// always on api
r.HandleFunc("/api/maintenance", api.SecurePriv(types.PRIV_SERVER, api.GetMaintenanceMode)).Methods(http.MethodGet)
r.HandleFunc("/api/maintenance", api.SecurePriv(types.PRIV_SERVER, api.EnableMaintenanceMode)).Methods(http.MethodPut)
Expand Down
6 changes: 2 additions & 4 deletions web/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@ func (a *Api) StatsEventListener(c chan *bridge.CommandResponse) {

type StatResponse struct {
*command.StatsCommand
Maintenance bool `json:"maintenance"`
FilebrowserEnabled bool `json:"filebrowser_enabled"`
Maintenance bool `json:"maintenance"`
}

func (a *Api) GetStats(w http.ResponseWriter, r *http.Request, claims *types.Claims) {

sc := &StatResponse{
StatsCommand: &command.StatsCommand{},
FilebrowserEnabled: a.app.Config.FilebrowserURL != "",
StatsCommand: &command.StatsCommand{},
}
sc.Maintenance = a.app.MaintenanceMode.Load()

Expand Down

0 comments on commit b2d294a

Please sign in to comment.