Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #88 from qor5/vue3
Browse files Browse the repository at this point in the history
Vue3
  • Loading branch information
sunfmin authored Jun 6, 2024
2 parents 398accf + dfd4507 commit f10d631
Show file tree
Hide file tree
Showing 242 changed files with 20,721 additions and 7,809 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@ jobs:
run: go build -v ./...

- name: Test
run: go test -v ./...
run: go test -v -cover -coverpkg=github.com/qor5/... -coverprofile=coverage.txt ./...

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
.idea
.DS_Store
_tmp
__debug_*
_backup
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM golang:1.21.5-alpine as builder
FROM golang:1.22.2-alpine as builder
RUN apk update && apk add git gcc libc-dev sqlite sqlite-dev && rm -rf /var/cache/apk/*
ARG GITHUB_TOKEN
WORKDIR /go/src/github.com/qor5/docs
COPY . .
RUN set -x && go get -d -v ./docsrc/server/...
RUN GOOS=linux GOARCH=amd64 go build -o /app/entry ./docsrc/server/
RUN set -x && go get -d -v ./docsrc/examples/server/...
RUN GOOS=linux GOARCH=amd64 go build -o /app/entry ./docsrc/examples/server/

FROM alpine
RUN apk update && apk add sqlite sqlite-dev && rm -rf /var/cache/apk/*
Expand Down
24 changes: 12 additions & 12 deletions cmd/qor5/admin-template/admin/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ package admin
import (
"net/http"

"github.com/qor5/admin/presets"
"github.com/qor5/admin/presets/gorm2op"
"github.com/qor5/docs/cmd/qor5/admin-template/models"
"github.com/qor5/ui/vuetify"
"github.com/qor5/web"
h "github.com/theplant/htmlgo"
"github.com/qor5/admin/v3/presets"

Check failure on line 6 in cmd/qor5/admin-template/admin/config.go

View workflow job for this annotation

GitHub Actions / build

github.com/qor5/admin/[email protected]: replacement directory ../admin does not exist
"github.com/qor5/admin/v3/presets/gorm2op"

Check failure on line 7 in cmd/qor5/admin-template/admin/config.go

View workflow job for this annotation

GitHub Actions / build

github.com/qor5/admin/[email protected]: replacement directory ../admin does not exist
"github.com/qor5/docs/v3/cmd/qor5/admin-template/models"
. "github.com/qor5/ui/v3/vuetify"
"github.com/qor5/web/v3"
. "github.com/theplant/htmlgo"
)

func Initialize() *http.ServeMux {
b := initializeProject()
mux := SetupRouter(b)
b := setupAdmin()
mux := setupRouter(b)

return mux
}

func initializeProject() (b *presets.Builder) {
func setupAdmin() (b *presets.Builder) {
db := ConnectDB()

// Initialize the builder of QOR5
Expand All @@ -29,9 +29,9 @@ func initializeProject() (b *presets.Builder) {
BrandTitle("Admin").
DataOperator(gorm2op.DataOperator(db)).
HomePageFunc(func(ctx *web.EventContext) (r web.PageResponse, err error) {
r.Body = vuetify.VContainer(
h.H1("Home"),
h.P().Text("Change your home page here"))
r.Body = VContainer(
H1("Home"),
P().Text("Change your home page here"))
return
})

Expand Down
9 changes: 5 additions & 4 deletions cmd/qor5/admin-template/admin/db.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package admin

import (
"os"

"github.com/qor5/docs/cmd/qor5/admin-template/models"
"github.com/qor5/docs/v3/cmd/qor5/admin-template/models"
"github.com/theplant/osenv"
"gorm.io/driver/postgres"
"gorm.io/gorm"
"gorm.io/gorm/logger"
)

var dbParamsString = osenv.Get("DB_PARAMS", "database connection string", "")

func ConnectDB() (db *gorm.DB) {
var err error
// Create database connection
db, err = gorm.Open(postgres.Open(os.Getenv("DB_PARAMS")))
db, err = gorm.Open(postgres.Open(dbParamsString))
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/qor5/admin-template/admin/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package admin
import (
"net/http"

"github.com/qor5/admin/presets"
"github.com/qor5/admin/v3/presets"
)

func SetupRouter(b *presets.Builder) (mux *http.ServeMux) {
func setupRouter(b *presets.Builder) (mux *http.ServeMux) {
mux = http.NewServeMux()
mux.Handle("/", b)
return
Expand Down
9 changes: 3 additions & 6 deletions cmd/qor5/admin-template/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@ package main
import (
"fmt"
"net/http"
"os"

"github.com/qor5/docs/cmd/qor5/admin-template/admin"
"github.com/qor5/docs/v3/cmd/qor5/admin-template/admin"
"github.com/theplant/osenv"
)

func main() {
// Setup project
mux := admin.Initialize()

port := os.Getenv("PORT")
if port == "" {
port = "9000"
}
port := osenv.Get("PORT", "The port to serve the admin on", "9000")

fmt.Println("Served at http://localhost:" + port + "/admin")

Expand Down
11 changes: 4 additions & 7 deletions cmd/qor5/bare-template/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ package main
import (
"log"
"net/http"
"os"
"time"

"github.com/qor5/web"
"github.com/qor5/web/v3"
. "github.com/theplant/htmlgo"
"github.com/theplant/osenv"
)

const doAction1 = "doAction1"

var port = osenv.Get("PORT", "The port to serve on", "9010")

func Home(ctx *web.EventContext) (r web.PageResponse, err error) {
r.Body = Div(
H1(time.Now().String()),
Expand All @@ -28,7 +30,6 @@ func DoAction1(ctx *web.EventContext) (r web.EventResponse, err error) {

func layout(in web.PageFunc) (out web.PageFunc) {
return func(ctx *web.EventContext) (pr web.PageResponse, err error) {

ctx.Injector.TailHTML(`
<script src='/main.js'></script>
`)
Expand Down Expand Up @@ -65,10 +66,6 @@ func main() {
mux.Handle("/", w.Page(layout(Home)).
EventFuncs(doAction1, DoAction1))

port := os.Getenv("PORT")
if port == "" {
port = "9010"
}
log.Printf("Listen on %s", port)
log.Fatal(http.ListenAndServe(":"+port, mux))
}
8 changes: 4 additions & 4 deletions cmd/qor5/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func main() {

dir := filepath.Base(pkg)

err = os.MkdirAll(dir, 0755)
err = os.MkdirAll(dir, 0o755)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -105,7 +105,7 @@ func copyAndReplaceFiles(box embed.FS, dir string, template string, pkg string)
}
newPath := strings.ReplaceAll(path, template+"/", "")
fp := filepath.Join(dir, newPath)
err := os.MkdirAll(filepath.Dir(fp), 0755)
err := os.MkdirAll(filepath.Dir(fp), 0o755)
if err != nil {
panic(err)
}
Expand All @@ -121,7 +121,7 @@ func copyAndReplaceFiles(box embed.FS, dir string, template string, pkg string)
panic(err)
}

err = os.WriteFile(fp, []byte(content), 0644)
err = os.WriteFile(fp, []byte(content), 0o644)
if err != nil {
panic(err)
}
Expand All @@ -131,7 +131,7 @@ func copyAndReplaceFiles(box embed.FS, dir string, template string, pkg string)

fmt.Println("Done")

replaceInFiles(dir, "github.com/qor5/docs/cmd/qor5/"+template, pkg)
replaceInFiles(dir, "github.com/qor5/docs/v3/cmd/qor5/"+template, pkg)
replaceInFiles(dir, "QOR5PackageName", dir)

if _, err = os.Stat(filepath.Join(dir, "go.mod")); err != nil {
Expand Down
1 change: 1 addition & 0 deletions cmd/qor5/website-template/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
publish
Loading

0 comments on commit f10d631

Please sign in to comment.