main.go 832 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package main
  2. import (
  3. "log"
  4. "net/http"
  5. "github.com/qor5/admin/pagebuilder/example"
  6. "github.com/qor5/admin/presets"
  7. "github.com/qor5/admin/presets/gorm2op"
  8. "github.com/qor5/web"
  9. )
  10. func main() {
  11. db := example.ConnectDB()
  12. p := presets.New().
  13. URIPrefix("/admin").
  14. DataOperator(gorm2op.DataOperator(db))
  15. pb := example.ConfigPageBuilder(db, "/page_builder", `<link rel="stylesheet" href="/frontstyle.css">`, p.I18n())
  16. pb.Configure(p, db, nil, nil, nil, nil)
  17. mux := http.NewServeMux()
  18. mux.Handle("/frontstyle.css", p.GetWebBuilder().PacksHandler("text/css", web.ComponentsPack(`
  19. :host {
  20. all: initial;
  21. display: block;
  22. }
  23. div {
  24. background-color:orange;
  25. }
  26. `)))
  27. mux.Handle("/admin/", p)
  28. mux.Handle("/page_builder/", pb)
  29. log.Println("Listen on http://localhost:9600")
  30. log.Fatal(http.ListenAndServe(":9600", mux))
  31. }