Skip to content

Commit

Permalink
Develop (#11)
Browse files Browse the repository at this point in the history
* fix error page
* upgrade dependencies
  • Loading branch information
markus621 authored Dec 20, 2023
1 parent f85d065 commit 0f5d1e8
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .deb.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package: jasta
source: jasta
version: 1:0.3.0
version: 1:0.3.2
architecture:
- amd64
- arm64
Expand Down
2 changes: 1 addition & 1 deletion cmd/jasta/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/osspkg/jasta/internal/command"
"github.com/osspkg/jasta/internal/jasta"
"go.osspkg.com/goppy"
"go.osspkg.com/goppy/plugins/web"
"go.osspkg.com/goppy/web"
)

func main() {
Expand Down
20 changes: 15 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,27 @@ module github.com/osspkg/jasta
go 1.20

require (
go.osspkg.com/goppy v0.14.0
go.osspkg.com/goppy v0.15.8
go.osspkg.com/goppy/app v0.1.4
go.osspkg.com/goppy/console v0.1.0
go.osspkg.com/goppy/errors v0.1.0
go.osspkg.com/goppy/iofile v0.1.3
go.osspkg.com/goppy/plugins v0.1.1
go.osspkg.com/goppy/shell v0.1.0
go.osspkg.com/goppy/syscall v0.1.0
go.osspkg.com/goppy/web v0.1.4
go.osspkg.com/goppy/xlog v0.1.4
go.osspkg.com/static v1.4.0
golang.org/x/image v0.13.0
golang.org/x/image v0.14.0
)

require (
github.com/gorilla/websocket v1.5.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
go.osspkg.com/algorithms v1.3.0 // indirect
go.osspkg.com/goppy/iosync v0.1.2 // indirect
go.osspkg.com/goppy/ioutil v0.1.0 // indirect
go.osspkg.com/goppy/xc v0.1.0 // indirect
go.osspkg.com/goppy/xnet v0.1.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
40 changes: 31 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,26 +1,48 @@
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
go.osspkg.com/algorithms v1.3.0 h1:rrKO440aNTofYJwGnOVsW00w0VRtZtu+BQrgXMXw7j4=
go.osspkg.com/algorithms v1.3.0/go.mod h1:J2SXxHdqBK9ALGYJomA9XGvTOhIwMK0fvVw+KusYyoo=
go.osspkg.com/goppy v0.14.0 h1:7YoNaSA+XIAy+lbIMEdmMIXH9Em+keNRMVvqP4+4jiE=
go.osspkg.com/goppy v0.14.0/go.mod h1:NAWYk3WylEMTTcEgFiFEQsL69T/ox614gpuzlWyxlzg=
go.osspkg.com/goppy v0.15.8 h1:VNxG/pJLRNuo7cvab1UF5kC2Tr7KguwyBpQau32lqzA=
go.osspkg.com/goppy v0.15.8/go.mod h1:0dUVSEiLjrWD0IuGKTHKWA6vV3VUrz4u4CGBwCKffS4=
go.osspkg.com/goppy/app v0.1.4 h1:Los8E/6/PNiD4pLy22RDJUc98h69MCDQv/Mn0q2idc8=
go.osspkg.com/goppy/app v0.1.4/go.mod h1:3pBd9xeqxcAlWScY6A9uoK87XGx5+9hVP9U9KQRoF/o=
go.osspkg.com/goppy/console v0.1.0 h1:ksQzyPFJlp9EY48tyAU6fOzKLfKkGa0KIB+fPkhTnJE=
go.osspkg.com/goppy/console v0.1.0/go.mod h1:x4MxAqsjTygGXyu1QkDLTvRaeQVU3/0euCxSQjtXzic=
go.osspkg.com/goppy/errors v0.1.0 h1:2q8gdRZMEEDk7y/sneblQxpHhsi3pqF1BbFFHS7+FnE=
go.osspkg.com/goppy/errors v0.1.0/go.mod h1:SvA8dgErO9e2i3TR8hgJV4uMAzs4TkL4FxXBSnw2UG4=
go.osspkg.com/goppy/iofile v0.1.3 h1:JxKOeysFUCB9JDvqgwQTBrQz4mISdSE2ouRxX8RJrKA=
go.osspkg.com/goppy/iofile v0.1.3/go.mod h1:bJTlDCHoZ3rENuu7ZE4KzzJJNv1CVq1TRZmj9phhXC8=
go.osspkg.com/goppy/iosync v0.1.2 h1:w0BxqBa7PAdxFM2P8pZn3ToHK6ilX5IG+1nwIXJEoGg=
go.osspkg.com/goppy/iosync v0.1.2/go.mod h1:huJpHhpIQ2DgzY3wVt72RUsJaje0uqYiUvMRovb1/Dg=
go.osspkg.com/goppy/ioutil v0.1.0 h1:Z9CF1nzrjbcHJV1EIcLqOPAotePScuCjmTSyU7BoLzk=
go.osspkg.com/goppy/ioutil v0.1.0/go.mod h1:WpZGj1HpuBlDDH5k8mn+2QwPssMP83jKj59U8qLsBoU=
go.osspkg.com/goppy/plugins v0.1.1 h1:ly/g8LyGQNhT9BLKLbhHejUuPho5atd4uJmitorQyvM=
go.osspkg.com/goppy/plugins v0.1.1/go.mod h1:oolaNTq9VCWBAApLUFCHvWZ/7tMUhzLaqQEIxmLviNQ=
go.osspkg.com/goppy/shell v0.1.0 h1:L/28FTiO+Mo+YxjKj1dwYI+1oJWgMq4RAfgS6aDSA1Q=
go.osspkg.com/goppy/shell v0.1.0/go.mod h1:K6EnrxB2vD2Hpg1mJIkeQKcZ9VEAnX5pBWhMgUBBds0=
go.osspkg.com/goppy/syscall v0.1.0 h1:qOkgnjRo4RlSyYDQiYzZqfmGUIO9tuIZZ/OKsvfC3+s=
go.osspkg.com/goppy/syscall v0.1.0/go.mod h1:8MsNFOYAzNzGI6FE+0hmqLINQ5cxVkhqHUyirzENG9A=
go.osspkg.com/goppy/web v0.1.4 h1:rvAU2nVLn5m37A8LgWvJcSC1xTkVgPruVm7BLAiyCE0=
go.osspkg.com/goppy/web v0.1.4/go.mod h1:fHCxV/5F6ulR5FmCr3csDXI9D1tGVC0CZr5K7DGvsmQ=
go.osspkg.com/goppy/xc v0.1.0 h1:e2231FumnLEf1OjqEtbRaUxz3FT9M8pZVKg0C0aTf7g=
go.osspkg.com/goppy/xc v0.1.0/go.mod h1:ocKrJbO+EADhuClTbOqzDfCqnUO9+ikEW0M7pqLl1Y4=
go.osspkg.com/goppy/xlog v0.1.4 h1:3+o71O3Jb8UgfSA6nfpfQHfhHLIploHhlQ4p+Yfj5So=
go.osspkg.com/goppy/xlog v0.1.4/go.mod h1:AtYBxgKaxQxFWmb/SbmLvYp7ysuE2i1YYSE3Pu29nNQ=
go.osspkg.com/goppy/xnet v0.1.1 h1:nysNyS5O7nHXIN/IjP9HGfa6Qh5BTTSYLULijk+Sv9M=
go.osspkg.com/goppy/xnet v0.1.1/go.mod h1:eB5pFfZTCrcaIOHzt4RlTgBVF5dRUV/u52qz/2hY3qk=
go.osspkg.com/goppy/xtest v0.1.2 h1:rbUzEnWZW9vkGa24owydA9icQcfOaROJWSym1l0mCtU=
go.osspkg.com/static v1.4.0 h1:2uy4/11c0QP+QLMucKQZbAU+e6lhVHKw5dWJPTk/DBg=
go.osspkg.com/static v1.4.0/go.mod h1:94YydVU3qUtb1J534486lpm+qg6CviQjqtxKlkpSppM=
golang.org/x/image v0.13.0 h1:3cge/F/QTkNLauhf2QoE9zp+7sr+ZcL4HnoZmdwg9sg=
golang.org/x/image v0.13.0/go.mod h1:6mmbMOeV28HuMTgA6OSRkdXKYw/t5W9Uwn2Yv1r3Yxk=
golang.org/x/image v0.14.0 h1:tNgSxAFe3jC4uYqvZdTr84SZoM1KfwdC9SKIFrLjFn4=
golang.org/x/image v0.14.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
2 changes: 1 addition & 1 deletion internal/command/prerender.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package command

import (
"github.com/osspkg/jasta/internal/spiderweb"
"go.osspkg.com/goppy/sdk/console"
"go.osspkg.com/goppy/console"
)

func PreRenderStaticWebsites() {
Expand Down
2 changes: 1 addition & 1 deletion internal/jasta/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package jasta
import (
"fmt"

"go.osspkg.com/goppy/sdk/iofile"
"go.osspkg.com/goppy/iofile"
)

type Config struct {
Expand Down
15 changes: 9 additions & 6 deletions internal/jasta/jasta.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import (
"path/filepath"
"strings"

"go.osspkg.com/goppy/plugins/web"
"go.osspkg.com/goppy/sdk/app"
"go.osspkg.com/goppy/sdk/log"
"go.osspkg.com/goppy/web"
"go.osspkg.com/goppy/xlog"
"go.osspkg.com/static"
)

Expand Down Expand Up @@ -43,7 +42,7 @@ func New(c WebsiteConfigs, r web.RouterPool) *Jasta {
}
}

func (v *Jasta) Up(_ app.Context) error {
func (v *Jasta) Up() error {
v.router.Get("/", v.handler)
v.router.Get("#", v.handler)
return nil
Expand All @@ -65,7 +64,7 @@ func (v *Jasta) handler(ctx web.Context) {
conf, ok := v.settings[host]
if !ok {
ctx.Response().WriteHeader(403)
log.WithFields(log.Fields{
xlog.WithFields(xlog.Fields{
"host": host,
}).Warnf("Host not found")
return
Expand Down Expand Up @@ -94,6 +93,10 @@ func prepareSettings(c []*WebsiteConfig) map[string]Setting {
result := make(map[string]Setting, 10)
for _, item := range c {
for _, domain := range item.Domains {
xlog.WithFields(xlog.Fields{
"domain": domain,
"root": item.Root,
}).Infof("Load config")
result[domain] = Setting{
Root: item.Root,
Assets: item.AssetsFolder,
Expand All @@ -119,7 +122,7 @@ func doResponse(w http.ResponseWriter, root string, page string, page404 string,
return
}
if b, err = os.ReadFile(root + "/" + page404); err != nil {
w.WriteHeader(500)
w.WriteHeader(404)
return
}
code = 404
Expand Down
4 changes: 2 additions & 2 deletions internal/jasta/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"fmt"

"github.com/osspkg/jasta/internal/utils"
"go.osspkg.com/goppy/app"
"go.osspkg.com/goppy/plugins"
"go.osspkg.com/goppy/sdk/app"
)

var Plugins = plugins.Plugins{}.Inject(
var Plugins = plugins.Inject(
plugins.Plugin{
Config: &Config{},
Inject: WebsiteConfigDecode,
Expand Down
6 changes: 3 additions & 3 deletions internal/spiderweb/spider.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
"time"

"github.com/osspkg/jasta/internal/utils"
"go.osspkg.com/goppy/sdk/iofile"
"go.osspkg.com/goppy/sdk/shell"
"go.osspkg.com/goppy/sdk/syscall"
"go.osspkg.com/goppy/iofile"
"go.osspkg.com/goppy/shell"
"go.osspkg.com/goppy/syscall"
)

type Spider struct {
Expand Down
10 changes: 5 additions & 5 deletions internal/utils/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"strings"
"sync"

"go.osspkg.com/goppy/sdk/errors"
"go.osspkg.com/goppy/sdk/log"
"go.osspkg.com/goppy/errors"
"go.osspkg.com/goppy/xlog"
"golang.org/x/image/bmp"
"golang.org/x/image/draw"
"golang.org/x/image/tiff"
Expand Down Expand Up @@ -129,7 +129,7 @@ func (v *Images) writeFile(filename string, img image.Image) error {
}
defer func() {
if err0 := file.Close(); err0 != nil {
log.WithFields(log.Fields{
xlog.WithFields(xlog.Fields{
"err": err0.Error(),
"file": filename,
}).Errorf("Close image file")
Expand All @@ -154,7 +154,7 @@ func (v *Images) readFile(filename string) (image.Image, string, error) {
}
defer func() {
if err0 := file.Close(); err0 != nil {
log.WithFields(log.Fields{
xlog.WithFields(xlog.Fields{
"err": err0.Error(),
"file": filename,
}).Errorf("Close image file")
Expand All @@ -179,7 +179,7 @@ func (v *Images) getHash(filename string) (string, error) {
}
defer func() {
if err0 := file.Close(); err0 != nil {
log.WithFields(log.Fields{
xlog.WithFields(xlog.Fields{
"err": err0.Error(),
"file": filename,
}).Errorf("Close image file")
Expand Down
3 changes: 1 addition & 2 deletions test_data/localhost.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
domains:
- localhost
root: test_data
index_file: index.html
page404: 404.html
route404: /404.html
assets_folder: /assets/
single: false

0 comments on commit 0f5d1e8

Please sign in to comment.