Minor changes
This commit is contained in:
parent
8d4cc6439a
commit
c8a3ec4b04
3
.gitignore
vendored
3
.gitignore
vendored
@ -28,3 +28,6 @@ _testmain.go
|
|||||||
|
|
||||||
# external packages folder
|
# external packages folder
|
||||||
vendor/
|
vendor/
|
||||||
|
|
||||||
|
# debugger
|
||||||
|
debug
|
2
pages/anime.pug
Normal file
2
pages/anime.pug
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
h1 {{.Title.Romaji}}
|
||||||
|
p {{.Description}}
|
8
pages/layout.pug
Normal file
8
pages/layout.pug
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
doctype html
|
||||||
|
html
|
||||||
|
head
|
||||||
|
title Test
|
||||||
|
link(href='/styles/base.css', rel='stylesheet')
|
||||||
|
link(href='/styles/layout.css', rel='stylesheet')
|
||||||
|
body
|
||||||
|
{{ yield }}
|
22
src/main.go
22
src/main.go
@ -4,26 +4,36 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
web "github.com/kataras/iris"
|
"github.com/kataras/go-template/pug"
|
||||||
|
"github.com/kataras/iris"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
InitDatabase()
|
InitDatabase()
|
||||||
|
|
||||||
web.Get("/", func(ctx *web.Context) {
|
iris.Config.Gzip = true
|
||||||
|
iris.Config.IsDevelopment = true
|
||||||
|
|
||||||
|
cfg := pug.DefaultConfig()
|
||||||
|
cfg.Layout = "layout.pug"
|
||||||
|
|
||||||
|
iris.UseTemplate(pug.New(cfg)).Directory("pages", ".pug")
|
||||||
|
|
||||||
|
iris.Static("/styles", "./styles", 1)
|
||||||
|
|
||||||
|
iris.Get("/", func(ctx *iris.Context) {
|
||||||
ctx.Response.Header.Set("Content-Type", "text/html;charset=utf-8")
|
ctx.Response.Header.Set("Content-Type", "text/html;charset=utf-8")
|
||||||
ctx.Write(ctx.Request.URI().String())
|
ctx.Write(ctx.Request.URI().String())
|
||||||
})
|
})
|
||||||
|
|
||||||
web.Get("/anime/:id", func(ctx *web.Context) {
|
iris.Get("/anime/:id", func(ctx *iris.Context) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
id, _ := ctx.ParamInt("id")
|
id, _ := ctx.ParamInt("id")
|
||||||
anime := GetAnime(id)
|
anime := GetAnime(id)
|
||||||
|
|
||||||
ctx.Write(anime.Title.Romaji + "\n")
|
ctx.MustRender("anime.pug", anime)
|
||||||
ctx.Write(anime.Description)
|
|
||||||
fmt.Println(time.Since(start))
|
fmt.Println(time.Since(start))
|
||||||
})
|
})
|
||||||
|
|
||||||
web.Listen(":8082")
|
iris.Listen(":8082")
|
||||||
}
|
}
|
||||||
|
1
styles/.gitignore
vendored
Normal file
1
styles/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.css
|
3
styles/base.styl
Normal file
3
styles/base.styl
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
body
|
||||||
|
background-color rgb(128, 128, 128)
|
||||||
|
color white
|
3
styles/layout.styl
Normal file
3
styles/layout.styl
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
*
|
||||||
|
padding 0
|
||||||
|
margin 0
|
Loading…
Reference in New Issue
Block a user