Skip to content

Commit

Permalink
Implemented website UI
Browse files Browse the repository at this point in the history
  • Loading branch information
luavixen committed May 8, 2022
1 parent d8823fb commit 401706d
Show file tree
Hide file tree
Showing 25 changed files with 5,052 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@
**/.gitignore
**/.dockerignore
**/.editorconfig
**/node_modules

core/build
server/main
website/.parcel-cache
website/dist

Dockerfile
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
**/.vscode
**/node_modules

core/build
server/main
website/.parcel-cache
website/dist
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
FROM archlinux:base-devel

RUN pacman -Syu --noconfirm go meson libvips
RUN pacman -Syu --noconfirm nodejs-lts-gallium npm go meson libvips

COPY ./core /app/build/core
COPY ./server /app/build/server
COPY ./website /app/build/website

WORKDIR /app/build/core
RUN meson build && cd build && meson compile

WORKDIR /app/build/server
RUN go build -o gifspin-server main.go

WORKDIR /app/build/website
RUN npm ci && npm run build

FROM archlinux:base

RUN pacman -Syu --noconfirm libvips

COPY --from=0 /app/build/core/build/gifspin-core /app/bin/gifspin-core
COPY --from=0 /app/build/server/gifspin-server /app/bin/gifspin-server
COPY --from=0 /app/build/website/dist /app/public

RUN mkdir -p /app/public /data
RUN mkdir -p /data

CMD ["/app/bin/gifspin-server"]
26 changes: 20 additions & 6 deletions server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func nanoid() string {
return nanoidEncode.EncodeToString(b)
}

var replaceUnsafePattern = regexp.MustCompile("[a-zA-Z0-9.~_-]")
var replaceUnsafePattern = regexp.MustCompile("[^a-zA-Z0-9.~_-]")

func replaceUnsafe(s string) string {
return replaceUnsafePattern.ReplaceAllString(s, "_")
Expand Down Expand Up @@ -311,7 +311,7 @@ func sendError(res http.ResponseWriter, err error) {
}

func sendErrorMessage(res http.ResponseWriter, status int, message string) {
res.Header().Set("X-Error", message)
res.Header().Set("X-Spin-Error", message)
sendJSON(res, status, map[string]string{"err": message})
}

Expand Down Expand Up @@ -352,6 +352,8 @@ func handleUpload(res http.ResponseWriter, req *http.Request) {

token := generateTokenInput(extension)

res.Header().Set("X-Spin-Token", token)

var err error

tempPath := getPathFromToken(settings.PathTemp, token)
Expand Down Expand Up @@ -382,12 +384,24 @@ func handleSpin(res http.ResponseWriter, req *http.Request) {
}
tokenOutput = generateTokenOutput(tokenInput)

ctx := req.Context()
pathInput := getPathFromToken(settings.PathTemp, tokenInput)
pathOutput := getPathFromToken(settings.PathTemp, tokenOutput)

body := newContextReader(http.MaxBytesReader(res, req.Body, 65536), ctx)
res.Header().Set("X-Spin-Token", tokenInput)
res.Header().Set("X-Spin-TokenOutput", tokenOutput)

var err error

_, err = os.Stat(pathInput)
if errors.Is(err, os.ErrNotExist) {
sendErrorMessage(res, http.StatusNotFound, "query parameter \"file\" not found")
return
}

ctx := req.Context()

body := newContextReader(http.MaxBytesReader(res, req.Body, 65536), ctx)

var opts *CompositeOptions
var task *CompositeTask

Expand All @@ -405,8 +419,8 @@ func handleSpin(res http.ResponseWriter, req *http.Request) {

task = new(CompositeTask)
task.Options = opts
task.PathInput = getPathFromToken(settings.PathTemp, tokenInput)
task.PathOutput = getPathFromToken(settings.PathTemp, tokenOutput)
task.PathInput = pathInput
task.PathOutput = pathOutput
task.PathBinary = settings.PathBinary

err = dispatch.Execute(ctx, task)
Expand Down
15 changes: 15 additions & 0 deletions website/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf

indent_size = 4
indent_style = space

insert_final_newline = true
trim_trailing_whitespace = true

[*.html]
indent_size = 2
indent_style = space
Loading

0 comments on commit 401706d

Please sign in to comment.