mirror of
https://github.com/mickael-kerjean/filestash
synced 2026-01-06 07:50:40 +01:00
improve (config): common issue on install problems
This commit is contained in:
parent
46b0858f69
commit
bdf8d9a931
7 changed files with 92 additions and 19 deletions
|
|
@ -14,10 +14,10 @@ steps:
|
|||
image: alpine:latest
|
||||
depends_on: [ clone ]
|
||||
commands:
|
||||
- mkdir -p ./dist/data/state/
|
||||
- cp -R config ./dist/data/state/
|
||||
- mkdir -p ./filestash/data/state/
|
||||
- cp -R config ./filestash/data/state/
|
||||
- mkdir -p ./dist/data/state/config
|
||||
- cp config/config.josn ./dist/data/state/config/
|
||||
- mkdir -p ./filestash/data/state/config
|
||||
- cp config/config.json ./filestash/data/state/config/
|
||||
|
||||
- name: build_frontend
|
||||
image: node:12-alpine
|
||||
|
|
|
|||
1
Makefile
1
Makefile
|
|
@ -3,6 +3,7 @@ all:
|
|||
|
||||
build_init:
|
||||
find server/plugin/plg_* -type f -name "install.sh" -exec {} \;
|
||||
go generate -x ./server/...
|
||||
|
||||
build_frontend:
|
||||
NODE_ENV=production npm run build
|
||||
|
|
|
|||
|
|
@ -45,5 +45,7 @@
|
|||
|
||||
;; markdown export
|
||||
(add-to-list 'load-path (file-name-directory load-file-name))
|
||||
(require 'ox-gfm)
|
||||
(defalias 'org-md-export-to-markdown 'org-gfm-export-to-markdown)
|
||||
|
||||
(when (require 'ox-gfm nil 'noerror)
|
||||
(defalias 'org-md-export-to-markdown 'org-gfm-export-to-markdown))
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +1,12 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var MimeTypes map[string]string = map[string]string{ "txt": "text/plain" }
|
||||
|
||||
func init() {
|
||||
path := filepath.Join(GetCurrentDir(), CONFIG_PATH + "mime.json")
|
||||
if f, err := os.OpenFile(path, os.O_RDONLY, os.ModePerm); err == nil {
|
||||
j, _ := ioutil.ReadAll(f)
|
||||
json.Unmarshal(j, &MimeTypes)
|
||||
f.Close()
|
||||
}
|
||||
}
|
||||
//go:generate sh -c "go run ../generator/mime.go > mime_generated.go && go fmt mime_generated.go"
|
||||
var MimeTypes map[string]string = make(map[string]string, 0)
|
||||
|
||||
func GetMimeType(p string) string {
|
||||
ext := filepath.Ext(p)
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
//go:generate sh -c "go run ../generator/emacs-el.go > export_generated.go && go fmt export_generated.go"
|
||||
var EmacsElConfig string = ""
|
||||
|
||||
|
||||
func FileExport(ctx App, res http.ResponseWriter, req *http.Request) {
|
||||
http.SetCookie(res, &http.Cookie{
|
||||
Name: "download",
|
||||
|
|
@ -55,6 +59,18 @@ func FileExport(ctx App, res http.ResponseWriter, req *http.Request) {
|
|||
}
|
||||
}
|
||||
|
||||
// initialise the default emacs.el
|
||||
if f, err := os.OpenFile(GetAbsolutePath(CONFIG_PATH + "emacs.el"), os.O_WRONLY | os.O_CREATE | os.O_EXCL, os.ModePerm); err == nil {
|
||||
if _, err = f.Write([]byte(EmacsElConfig)); err != nil {
|
||||
SendErrorResult(res, ErrFilesystemError)
|
||||
return
|
||||
}
|
||||
if err = f.Close(); err != nil {
|
||||
SendErrorResult(res, ErrFilesystemError)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if mimeType == "text/html" {
|
||||
cmd = exec.Command(
|
||||
emacsPath, "--no-init-file", "--batch",
|
||||
|
|
|
|||
31
server/generator/emacs-el.go
Normal file
31
server/generator/emacs-el.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
f, err := os.OpenFile("../../config/emacs.el", os.O_RDONLY, os.ModePerm)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||
os.Exit(1)
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
j, err := ioutil.ReadAll(f)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf(`package ctrl
|
||||
func init() {
|
||||
EmacsElConfig = `+"`"+`
|
||||
%s
|
||||
`+"`"+`
|
||||
}
|
||||
`, j)
|
||||
}
|
||||
34
server/generator/mime.go
Normal file
34
server/generator/mime.go
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
f, err := os.OpenFile("../../config/mime.json", os.O_RDONLY, os.ModePerm)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||
os.Exit(1)
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
j, err := ioutil.ReadAll(f)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
mTypes := make(map[string]string, 0)
|
||||
json.Unmarshal(j, &mTypes)
|
||||
|
||||
fmt.Printf("package common\n")
|
||||
fmt.Printf("func init() {\n")
|
||||
for key, value := range mTypes {
|
||||
fmt.Printf("MimeTypes[\"%s\"] = \"%s\"\n", key, value)
|
||||
}
|
||||
fmt.Printf("}\n")
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue