aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.example.scfg1
-rw-r--r--go.mod3
-rw-r--r--go.sum31
-rw-r--r--main.go2
-rw-r--r--pkg/config/config.go14
-rw-r--r--pkg/handler/about.go51
-rw-r--r--pkg/handler/status.go2
-rw-r--r--pkg/u/util.go5
-rw-r--r--templates/base.qtpl11
-rw-r--r--templates/base.qtpl.go135
-rw-r--r--templates/helloworld.qtpl4
-rw-r--r--templates/helloworld.qtpl.go4
12 files changed, 184 insertions, 79 deletions
diff --git a/config.example.scfg b/config.example.scfg
index eda4f38..1e3180f 100644
--- a/config.example.scfg
+++ b/config.example.scfg
@@ -1,3 +1,4 @@
+root-readme /srv/git/README.md
scan /srv/git/ {
public true
}
diff --git a/go.mod b/go.mod
index 2122f6b..5bd4d76 100644
--- a/go.mod
+++ b/go.mod
@@ -5,6 +5,8 @@ go 1.22.2
require (
git.sr.ht/~emersion/go-scfg v0.0.0-20240128091534-2ae16e782082
github.com/alecthomas/chroma/v2 v2.13.0
+ github.com/go-git/go-git/v5 v5.12.0
+ github.com/gomarkdown/markdown v0.0.0-20240419095408-642f0ee99ae2
github.com/google/go-cmp v0.6.0
github.com/valyala/quicktemplate v1.7.0
golang.org/x/sync v0.7.0
@@ -20,7 +22,6 @@ require (
github.com/emirpasic/gods v1.18.1 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
- github.com/go-git/go-git/v5 v5.12.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
diff --git a/go.sum b/go.sum
index ba2d937..69c34b7 100644
--- a/go.sum
+++ b/go.sum
@@ -15,6 +15,10 @@ github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
github.com/andybalholm/brotli v1.0.3/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
+github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
+github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
+github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
+github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU=
@@ -26,17 +30,25 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
+github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU=
+github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
+github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE=
+github.com/gliderlabs/ssh v0.3.7/go.mod h1:zpHEXBstFnQYtGnB8k8kQLol82umzn/2/snG7alWVD8=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU=
github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow=
+github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4=
+github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII=
github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys=
github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
+github.com/gomarkdown/markdown v0.0.0-20240419095408-642f0ee99ae2 h1:yEt5djSYb4iNtmV9iJGVday+i4e9u6Mrn5iP64HH5QM=
+github.com/gomarkdown/markdown v0.0.0-20240419095408-642f0ee99ae2/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
@@ -48,12 +60,22 @@ github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF
github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
github.com/klauspost/compress v1.13.5/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
+github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
+github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
+github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
+github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
+github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI=
+github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M=
github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4=
github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI=
+github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+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/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
@@ -62,6 +84,8 @@ github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
+github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
+github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.30.0/go.mod h1:2rsYD01CKFrjjsvFxx75KlEUNpWNBY9JWD3K/7o2Cus=
@@ -119,6 +143,8 @@ golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuX
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
+golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8=
+golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
@@ -126,6 +152,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
+golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
+golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
@@ -135,8 +163,11 @@ golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
+gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/main.go b/main.go
index 644b96c..76da07b 100644
--- a/main.go
+++ b/main.go
@@ -58,9 +58,11 @@ func run(ctx context.Context) error {
//handlers
gitHandler := handler.NewGitHandler(gitService)
+ aboutHandler := handler.NewAboutHandler(config.RootReadme)
mux.Handle("/static/", staticHandler)
mux.HandleFunc("/config", handler.ConfigFile(*configPath))
+ mux.HandleFunc("/about", aboutHandler.About)
mux.HandleFunc("/", gitHandler.List)
serverTask := worker.NewServerTask(&http.Server{Handler: mux, Addr: "0.0.0.0:8080"})
diff --git a/pkg/config/config.go b/pkg/config/config.go
index 776c698..9b6acce 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -16,7 +16,8 @@ type (
}
Configuration struct {
- Scan *Scan
+ Scan *Scan
+ RootReadme string
}
)
@@ -33,6 +34,11 @@ func Parse(r io.Reader) (*Configuration, error) {
return nil, err
}
+ err = setRootReadme(block, &config.RootReadme)
+ if err != nil {
+ return nil, err
+ }
+
return config, nil
}
@@ -42,9 +48,15 @@ func defaultConfiguration() *Configuration {
Public: true,
Path: "",
},
+ RootReadme: "",
}
}
+func setRootReadme(block scfg.Block, readme *string) error {
+ scanDir := block.Get("root-readme")
+ return setString(scanDir, readme)
+}
+
func setScan(block scfg.Block, scan *Scan) error {
scanDir := block.Get("scan")
err := setString(scanDir, &scan.Path)
diff --git a/pkg/handler/about.go b/pkg/handler/about.go
new file mode 100644
index 0000000..3ab2de8
--- /dev/null
+++ b/pkg/handler/about.go
@@ -0,0 +1,51 @@
+package handler
+
+import (
+ "io"
+ "log/slog"
+ "net/http"
+ "os"
+
+ "github.com/gomarkdown/markdown"
+ "github.com/gomarkdown/markdown/html"
+ "github.com/gomarkdown/markdown/parser"
+
+ "git.gabrielgio.me/cerrado/templates"
+)
+
+type AboutHandler struct {
+ readmePath string
+}
+
+func NewAboutHandler(readmePath string) *AboutHandler {
+ return &AboutHandler{readmePath}
+}
+
+func (g *AboutHandler) About(w http.ResponseWriter, _ *http.Request) {
+ f, err := os.Open(g.readmePath)
+ if err != nil {
+ slog.Error("Error loading readme file", "error", err)
+ return
+ }
+
+ bs, err := io.ReadAll(f)
+ if err != nil {
+ slog.Error("Error reading readme file bytes", "error", err)
+ return
+ }
+
+ extensions := parser.CommonExtensions | parser.AutoHeadingIDs | parser.NoEmptyLineBeforeBlock
+ p := parser.NewWithExtensions(extensions)
+ doc := p.Parse(bs)
+
+ htmlFlags := html.CommonFlags | html.HrefTargetBlank
+ opts := html.RendererOptions{Flags: htmlFlags}
+ renderer := html.NewRenderer(opts)
+
+ bs = markdown.Render(doc, renderer)
+
+ gitList := &templates.HelloPage{
+ Body: bs,
+ }
+ templates.WritePageTemplate(w, gitList)
+}
diff --git a/pkg/handler/status.go b/pkg/handler/status.go
index 1ca7f70..9baac2c 100644
--- a/pkg/handler/status.go
+++ b/pkg/handler/status.go
@@ -54,7 +54,7 @@ func ConfigFile(configPath string) func(http.ResponseWriter, *http.Request) {
}
hello := &templates.HelloPage{
- Body: code.String(),
+ Body: code.Bytes(),
}
templates.WritePageTemplate(w, hello)
diff --git a/pkg/u/util.go b/pkg/u/util.go
new file mode 100644
index 0000000..9706539
--- /dev/null
+++ b/pkg/u/util.go
@@ -0,0 +1,5 @@
+package u
+
+func Ptr[T any](v T) *T {
+ return &v
+}
diff --git a/templates/base.qtpl b/templates/base.qtpl
index 6654f42..444afc6 100644
--- a/templates/base.qtpl
+++ b/templates/base.qtpl
@@ -32,11 +32,12 @@ Page prints a page implementing Page interface.
</head>
<body>
<nav class="container navbar navbar-expand-sm">
- <ul class="navbar-nav">
- <li class="nav-link" href="/git">git</li>
- <li class="nav-link" href="/list">list</li>
- <li class="nav-link" href="/about">about</li>
- </ul>
+ <div class="navbar-nav">
+ <a class="nav-link" href="/git">git</a>
+ <a class="nav-link" href="/list">list</a>
+ <a class="nav-link" href="/about">about</a>
+ <a class="nav-link" href="/config">config</a>
+ </div>
</nav>
<div class="container">
{%= p.Content() %}
diff --git a/templates/base.qtpl.go b/templates/base.qtpl.go
index 2573b99..1d30cd8 100644
--- a/templates/base.qtpl.go
+++ b/templates/base.qtpl.go
@@ -74,116 +74,84 @@ func StreamPageTemplate(qw422016 *qt422016.Writer, p Page) {
</head>
<body>
<nav class="container navbar navbar-expand-sm">
- <ul class="navbar-nav">
- <li class="nav-link" href="/git">git</li>
- <li class="nav-link" href="/list">list</li>
- <li class="nav-link" href="/about">about</li>
- </ul>
+ <div class="navbar-nav">
+ <a class="nav-link" href="/git">git</a>
+ <a class="nav-link" href="/list">list</a>
+ <a class="nav-link" href="/about">about</a>
+ <a class="nav-link" href="/config">config</a>
+ </div>
</nav>
<div class="container">
`)
-//line base.qtpl:42
+//line base.qtpl:43
p.StreamContent(qw422016)
-//line base.qtpl:42
+//line base.qtpl:43
qw422016.N().S(`
</div>
</body>
`)
-//line base.qtpl:45
+//line base.qtpl:46
p.StreamScript(qw422016)
-//line base.qtpl:45
+//line base.qtpl:46
qw422016.N().S(`
</html>
`)
-//line base.qtpl:47
+//line base.qtpl:48
}
-//line base.qtpl:47
+//line base.qtpl:48
func WritePageTemplate(qq422016 qtio422016.Writer, p Page) {
-//line base.qtpl:47
+//line base.qtpl:48
qw422016 := qt422016.AcquireWriter(qq422016)
-//line base.qtpl:47
+//line base.qtpl:48
StreamPageTemplate(qw422016, p)
-//line base.qtpl:47
+//line base.qtpl:48
qt422016.ReleaseWriter(qw422016)
-//line base.qtpl:47
+//line base.qtpl:48
}
-//line base.qtpl:47
+//line base.qtpl:48
func PageTemplate(p Page) string {
-//line base.qtpl:47
+//line base.qtpl:48
qb422016 := qt422016.AcquireByteBuffer()
-//line base.qtpl:47
+//line base.qtpl:48
WritePageTemplate(qb422016, p)
-//line base.qtpl:47
+//line base.qtpl:48
qs422016 := string(qb422016.B)
-//line base.qtpl:47
+//line base.qtpl:48
qt422016.ReleaseByteBuffer(qb422016)
-//line base.qtpl:47
+//line base.qtpl:48
return qs422016
-//line base.qtpl:47
+//line base.qtpl:48
}
-//line base.qtpl:49
-type BasePage struct{}
-
-//line base.qtpl:50
-func (p *BasePage) StreamTitle(qw422016 *qt422016.Writer) {
-//line base.qtpl:50
- qw422016.N().S(`Empty`)
-//line base.qtpl:50
-}
-
-//line base.qtpl:50
-func (p *BasePage) WriteTitle(qq422016 qtio422016.Writer) {
-//line base.qtpl:50
- qw422016 := qt422016.AcquireWriter(qq422016)
-//line base.qtpl:50
- p.StreamTitle(qw422016)
-//line base.qtpl:50
- qt422016.ReleaseWriter(qw422016)
-//line base.qtpl:50
-}
-
-//line base.qtpl:50
-func (p *BasePage) Title() string {
-//line base.qtpl:50
- qb422016 := qt422016.AcquireByteBuffer()
//line base.qtpl:50
- p.WriteTitle(qb422016)
-//line base.qtpl:50
- qs422016 := string(qb422016.B)
-//line base.qtpl:50
- qt422016.ReleaseByteBuffer(qb422016)
-//line base.qtpl:50
- return qs422016
-//line base.qtpl:50
-}
+type BasePage struct{}
//line base.qtpl:51
-func (p *BasePage) StreamBody(qw422016 *qt422016.Writer) {
+func (p *BasePage) StreamTitle(qw422016 *qt422016.Writer) {
//line base.qtpl:51
- qw422016.N().S(`HelloWorld`)
+ qw422016.N().S(`Empty`)
//line base.qtpl:51
}
//line base.qtpl:51
-func (p *BasePage) WriteBody(qq422016 qtio422016.Writer) {
+func (p *BasePage) WriteTitle(qq422016 qtio422016.Writer) {
//line base.qtpl:51
qw422016 := qt422016.AcquireWriter(qq422016)
//line base.qtpl:51
- p.StreamBody(qw422016)
+ p.StreamTitle(qw422016)
//line base.qtpl:51
qt422016.ReleaseWriter(qw422016)
//line base.qtpl:51
}
//line base.qtpl:51
-func (p *BasePage) Body() string {
+func (p *BasePage) Title() string {
//line base.qtpl:51
qb422016 := qt422016.AcquireByteBuffer()
//line base.qtpl:51
- p.WriteBody(qb422016)
+ p.WriteTitle(qb422016)
//line base.qtpl:51
qs422016 := string(qb422016.B)
//line base.qtpl:51
@@ -194,27 +162,29 @@ func (p *BasePage) Body() string {
}
//line base.qtpl:52
-func (p *BasePage) StreamScript(qw422016 *qt422016.Writer) {
+func (p *BasePage) StreamBody(qw422016 *qt422016.Writer) {
+//line base.qtpl:52
+ qw422016.N().S(`HelloWorld`)
//line base.qtpl:52
}
//line base.qtpl:52
-func (p *BasePage) WriteScript(qq422016 qtio422016.Writer) {
+func (p *BasePage) WriteBody(qq422016 qtio422016.Writer) {
//line base.qtpl:52
qw422016 := qt422016.AcquireWriter(qq422016)
//line base.qtpl:52
- p.StreamScript(qw422016)
+ p.StreamBody(qw422016)
//line base.qtpl:52
qt422016.ReleaseWriter(qw422016)
//line base.qtpl:52
}
//line base.qtpl:52
-func (p *BasePage) Script() string {
+func (p *BasePage) Body() string {
//line base.qtpl:52
qb422016 := qt422016.AcquireByteBuffer()
//line base.qtpl:52
- p.WriteScript(qb422016)
+ p.WriteBody(qb422016)
//line base.qtpl:52
qs422016 := string(qb422016.B)
//line base.qtpl:52
@@ -223,3 +193,34 @@ func (p *BasePage) Script() string {
return qs422016
//line base.qtpl:52
}
+
+//line base.qtpl:53
+func (p *BasePage) StreamScript(qw422016 *qt422016.Writer) {
+//line base.qtpl:53
+}
+
+//line base.qtpl:53
+func (p *BasePage) WriteScript(qq422016 qtio422016.Writer) {
+//line base.qtpl:53
+ qw422016 := qt422016.AcquireWriter(qq422016)
+//line base.qtpl:53
+ p.StreamScript(qw422016)
+//line base.qtpl:53
+ qt422016.ReleaseWriter(qw422016)
+//line base.qtpl:53
+}
+
+//line base.qtpl:53
+func (p *BasePage) Script() string {
+//line base.qtpl:53
+ qb422016 := qt422016.AcquireByteBuffer()
+//line base.qtpl:53
+ p.WriteScript(qb422016)
+//line base.qtpl:53
+ qs422016 := string(qb422016.B)
+//line base.qtpl:53
+ qt422016.ReleaseByteBuffer(qb422016)
+//line base.qtpl:53
+ return qs422016
+//line base.qtpl:53
+}
diff --git a/templates/helloworld.qtpl b/templates/helloworld.qtpl
index 45c5595..1785bb5 100644
--- a/templates/helloworld.qtpl
+++ b/templates/helloworld.qtpl
@@ -1,13 +1,13 @@
{% code
type HelloPage struct {
- Body string
+ Body []byte
}
%}
{% func (p *HelloPage) Title() %}Hello{% endfunc %}
{% func (p *HelloPage) Content() %}
-{%s= p.Body %}
+{%z= p.Body %}
{% endfunc %}
{% func (p *HelloPage) Script() %}
diff --git a/templates/helloworld.qtpl.go b/templates/helloworld.qtpl.go
index 61c8f75..7e37f3b 100644
--- a/templates/helloworld.qtpl.go
+++ b/templates/helloworld.qtpl.go
@@ -19,7 +19,7 @@ var (
//line helloworld.qtpl:2
type HelloPage struct {
- Body string
+ Body []byte
}
//line helloworld.qtpl:7
@@ -61,7 +61,7 @@ func (p *HelloPage) StreamContent(qw422016 *qt422016.Writer) {
qw422016.N().S(`
`)
//line helloworld.qtpl:10
- qw422016.N().S(p.Body)
+ qw422016.N().Z(p.Body)
//line helloworld.qtpl:10
qw422016.N().S(`
`)