Skip to content

Commit 1590ae4

Browse files
authored
Merge pull request #48 from rande/move_skeleton_code
Move skeleton code
2 parents 0bdea6d + 65fbbe2 commit 1590ae4

File tree

252 files changed

+1016
-8042
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

252 files changed

+1016
-8042
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
explorer/node_modules
33
explorer/dist
44
dist/*
5-
assets/bindata.go
5+
app/assets/bindata.go
66
data
77
admin/build
88
admin/node_modules
99
vendor
10-
skeleton
1110
runtime
1211
.glide
12+
fork

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ script:
4343
go get golang.org/x/tools/cmd/cover;
4444
go get golang.org/x/tools/cmd/goimports;
4545
go get -u github.com/jteeuwen/go-bindata/...;
46-
./assets/bindata.sh;
46+
./app/assets/bindata.sh;
4747
mkdir -p build/coverage && rm -rf build/coverage/*.cov;
4848
export GOPKG="./core/bindata,./core/commands,./core/config,./core/guard,./core/helper,./core/logger,./core/router,./core/security,./core/squirrel,./core/vault,./modules/api,./modules/base,./modules/blog,./modules/debug,./modules/feed,./modules/guard,./modules/media,./modules/prism,./modules/raw,./modules/search,./modules/setup,./modules/user";
4949
go test -v -coverpkg ${GOPKG} -covermode count -coverprofile=build/coverage/core_bindata.cov ./core/bindata;

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2014-2015 Thomas Rabaix
1+
Copyright (c) 2014-2018 Thomas Rabaix
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal
@@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1616
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1717
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1818
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19-
THE SOFTWARE.
19+
THE SOFTWARE.

Makefile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,23 @@ shell:
2525
docker-compose run back /bin/bash
2626

2727
install:
28-
mkdir -p runtime/src
2928
$(call back,glide install)
3029
$(call back,go get github.com/wadey/gocovmerge && go get golang.org/x/tools/cmd/cover && go get golang.org/x/tools/cmd/goimports && go get -u github.com/jteeuwen/go-bindata/...)
31-
$(call back,cp -rvf /usr/local/go/src/* ./runtime/src/ )
3230

3331
test:
34-
$(call back,./assets/bindata.sh && go test -v $(GONODE_CORE) $(GONODE_MODULES) ./test/modules)
32+
$(call back,./app/assets/bindata.sh && go test -v $(GONODE_CORE) $(GONODE_MODULES) ./test/modules)
3533
$(call back,go vet $(GONODE_CORE) $(GONODE_MODULES) ./test/modules/)
3634

3735
format:
3836
$(call back,gofmt -w $(GONODE_CORE) $(GONODE_MODULES) ./test/modules)
3937
$(call back,go fix $(GONODE_CORE) $(GONODE_MODULES) ./test/modules)
4038
$(call back,go vet $(GONODE_CORE) $(GONODE_MODULES) ./test/modules)
39+
40+
run:
41+
docker-compose kill
42+
docker-compose up
43+
44+
load: ## Load fixtures
45+
curl -XPOST http://localhost:2508/setup/uninstall && exit 0
46+
curl -XPOST http://localhost:2508/setup/install
47+
curl -XPOST http://localhost:2508/setup/data/load

app/assets/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Assets
2+
======
3+
4+
This directory will only contains a gofile generated by go-bindata with all assets required by the project.
5+
6+
The ``bindata.go`` is generated only on build and should not be commited.
7+
8+
The assets can contains any template files or front files (js, css, images, ...)
9+
10+
Please note, the ``go-bindata`` must be run from ``GOPATH`` folder, so the assets references will be unique accross different projects.
11+
12+
github.com/rande/gonode/modules/setup/templates/core.setup.base.html.tpl
13+
github.com/rande/gonode/explorer/dist/css/app-0-f3673f84.css
14+
github.com/rande/gonode/explorer/dist/d317f3fe02c697f8b2d3c4c3e940ea7f.gif
15+
github.com/rande/gonode/explorer/dist/fonts/arrow-left-icon-5fc0d629.svg
16+
17+
18+
The ``Makefile`` lines to generate the file will be:
19+
20+
```Makefile
21+
22+
bin:
23+
app/assets/bindata.sh
24+
25+
run: bin
26+
go run app/main.go server -config=app/server.toml.dist
27+
28+
build: bin
29+
rm -rf dist && mkdir dist
30+
app/assets/bindata.sh
31+
go build -a -o ./dist/gonode app/main.go
32+
33+
34+
Usage
35+
-----
36+
37+
Just import the package ``assets`` and refer to the ``go-bindata`` documentation.

app/assets/assets.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright © 2014-2018 Thomas Rabaix <[email protected]>.
2+
//
3+
// Use of this source code is governed by an MIT-style
4+
// license that can be found in the LICENSE file.
5+
6+
package assets
7+
8+
var rootDir = ""
9+
10+
func UpdateRootDir(path string) {
11+
12+
if len(path) == 0 {
13+
return
14+
}
15+
16+
rootDir = path
17+
}

app/assets/bindata.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
GO_BINDATA_PATHS="${GOPATH}/src/github.com/rande/gonode/modules/..."
4+
GO_BINDATA_IGNORE="(.*)\.(go|DS_Store)"
5+
GO_BINDATA_OUTPUT="${GOPATH}/src/github.com/rande/gonode/app/assets/bindata.go"
6+
GO_BINDATA_PACKAGE="assets"
7+
8+
echo "Generating bindata file..."
9+
cd ${GOPATH}/src && go-bindata -dev -prefix ${GOPATH}/src -o ${GO_BINDATA_OUTPUT} -pkg ${GO_BINDATA_PACKAGE} -ignore ${GO_BINDATA_IGNORE} ${GO_BINDATA_PATHS}
10+
11+
echo "Done!"

app/assets/doc.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright © 2014-2018 Thomas Rabaix <[email protected]>.
2+
//
3+
// Use of this source code is governed by an MIT-style
4+
// license that can be found in the LICENSE file.
5+
6+
package assets

app/main.go

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// Copyright © 2014-2018 Thomas Rabaix <[email protected]>.
2+
//
3+
// Use of this source code is governed by an MIT-style
4+
// license that can be found in the LICENSE file.
5+
6+
package main
7+
8+
import (
9+
"os"
10+
11+
log "github.com/Sirupsen/logrus"
12+
"github.com/mitchellh/cli"
13+
"github.com/rande/goapp"
14+
"github.com/rande/gonode/app/assets"
15+
"github.com/rande/gonode/core/bindata"
16+
"github.com/rande/gonode/core/commands"
17+
"github.com/rande/gonode/core/config"
18+
"github.com/rande/gonode/core/logger"
19+
"github.com/rande/gonode/core/router"
20+
"github.com/rande/gonode/core/security"
21+
"github.com/rande/gonode/modules/api"
22+
"github.com/rande/gonode/modules/base"
23+
"github.com/rande/gonode/modules/blog"
24+
"github.com/rande/gonode/modules/debug"
25+
"github.com/rande/gonode/modules/feed"
26+
node_guard "github.com/rande/gonode/modules/guard"
27+
"github.com/rande/gonode/modules/media"
28+
"github.com/rande/gonode/modules/prism"
29+
"github.com/rande/gonode/modules/raw"
30+
"github.com/rande/gonode/modules/search"
31+
"github.com/rande/gonode/modules/setup"
32+
"github.com/rande/gonode/modules/user"
33+
)
34+
35+
func Configure(configFile string) *goapp.Lifecycle {
36+
l := goapp.NewLifecycle()
37+
38+
conf := config.NewConfig()
39+
config.LoadConfigurationFromFile(configFile, conf)
40+
41+
l.Config(func(app *goapp.App) error {
42+
assets.UpdateRootDir(conf.BinData.BasePath)
43+
44+
app.Set("gonode.asset", func(app *goapp.App) interface{} {
45+
return assets.Asset
46+
})
47+
48+
return nil
49+
})
50+
51+
base.Configure(l, conf)
52+
debug.Configure(l, conf)
53+
user.Configure(l, conf)
54+
raw.Configure(l, conf)
55+
blog.Configure(l, conf)
56+
media.Configure(l, conf)
57+
search.Configure(l, conf)
58+
feed.Configure(l, conf)
59+
60+
logger.Configure(l, conf)
61+
commands.Configure(l, conf)
62+
security.ConfigureCors(l, conf)
63+
node_guard.Configure(l, conf)
64+
security.ConfigureSecurity(l, conf)
65+
api.Configure(l, conf)
66+
setup.Configure(l, conf)
67+
bindata.Configure(l, conf)
68+
prism.Configure(l, conf)
69+
router.Configure(l, conf)
70+
71+
return l
72+
}
73+
74+
func main() {
75+
ui := &cli.BasicUi{Writer: os.Stdout}
76+
77+
c := cli.NewCLI("gonode", "0.0.2-DEV")
78+
c.Args = os.Args[1:]
79+
80+
c.Commands = map[string]cli.CommandFactory{
81+
"server": func() (cli.Command, error) {
82+
return &commands.ServerCommand{
83+
Ui: ui,
84+
Configure: Configure,
85+
}, nil
86+
},
87+
}
88+
89+
exitStatus, err := c.Run()
90+
91+
if err != nil {
92+
log.Println(err)
93+
}
94+
95+
os.Exit(exitStatus)
96+
}

app/server.toml.dist

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name= "GoNode - poc"
2+
bind= "0.0.0.0:2508"
3+
test= true
4+
5+
[databases.master]
6+
type = "master"
7+
dsn = "postgres://postgres:gonode@database/gonode?sslmode=disable"
8+
enabled = true
9+
prefix = "prod"
10+
11+
[filesystem]
12+
path = "/tmp/gnode"
13+
14+
[guard]
15+
key = "ZeSecretKey0oo"
16+
17+
[guard.jwt]
18+
[guard.jwt.login]
19+
path = "\\/api\\/v([0-9\\.]*)\\/login"
20+
21+
[guard.jwt.token]
22+
path = "^\\/api\\/v([0-9\\.]*)"
23+
24+
[guard.anonymous]
25+
roles = [
26+
"IS_AUTHENTICATED_ANONYMOUSLY",
27+
"node:prism:read"
28+
]
29+
30+
[security]
31+
voters = [
32+
"security.voter.role",
33+
"security.voter.is",
34+
"gonode.security.voter.access",
35+
"gonode.security.voter.role",
36+
]
37+
38+
[security.cors]
39+
allowed_origins = ["http://localhost:8000"]
40+
allowed_methods = ["GET", "PUT", "POST"]
41+
allowed_headers = ["Origin", "Accept", "Content-Type", "Authorization"]
42+
43+
[[security.access]]
44+
path = "^\\/admin"
45+
roles = ["ROLE_ADMIN"]
46+
47+
[[security.access]]
48+
path = "^\\/api\\/v([0-9\\.]*)\\/hello"
49+
roles = ["IS_AUTHENTICATED_ANONYMOUSLY", "ROLE_API"]
50+
51+
[[security.access]]
52+
path = "^\\/api"
53+
roles = ["ROLE_API"]
54+
55+
[[security.access]]
56+
path = "^\\/"
57+
roles = ["IS_AUTHENTICATED_ANONYMOUSLY"]
58+
59+
[bindata]
60+
templates = [
61+
"github.com/rande/gonode/modules/setup/templates",
62+
"github.com/rande/gonode/modules/blog/templates",
63+
"github.com/rande/gonode/modules/prism/templates",
64+
"github.com/rande/gonode/modules/search/templates",
65+
"github.com/rande/gonode/modules/feed/templates",
66+
]
67+
68+
[bindata.assets]
69+
[bindata.assets.explorer]
70+
index = "index.html"
71+
public = "/explorer"
72+
private = "github.com/rande/gonode/explorer/dist"
73+
74+
[media]
75+
[media.image]
76+
allowed_widths = [100, 250, 500, 1024]
77+
max_width = 1024
78+
79+
[logger]
80+
level = "debug"

0 commit comments

Comments
 (0)