Minor changes

This commit is contained in:
Eduard Urbach 2016-10-21 22:10:05 +09:00
parent 8d4cc6439a
commit c8a3ec4b04
7 changed files with 37 additions and 7 deletions

5
.gitignore vendored
View File

@ -27,4 +27,7 @@ _testmain.go
*.out
# external packages folder
vendor/
vendor/
# debugger
debug

2
pages/anime.pug Normal file
View File

@ -0,0 +1,2 @@
h1 {{.Title.Romaji}}
p {{.Description}}

8
pages/layout.pug Normal file
View 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 }}

View File

@ -4,26 +4,36 @@ import (
"fmt"
"time"
web "github.com/kataras/iris"
"github.com/kataras/go-template/pug"
"github.com/kataras/iris"
)
func main() {
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.Write(ctx.Request.URI().String())
})
web.Get("/anime/:id", func(ctx *web.Context) {
iris.Get("/anime/:id", func(ctx *iris.Context) {
start := time.Now()
id, _ := ctx.ParamInt("id")
anime := GetAnime(id)
ctx.Write(anime.Title.Romaji + "\n")
ctx.Write(anime.Description)
ctx.MustRender("anime.pug", anime)
fmt.Println(time.Since(start))
})
web.Listen(":8082")
iris.Listen(":8082")
}

1
styles/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.css

3
styles/base.styl Normal file
View File

@ -0,0 +1,3 @@
body
background-color rgb(128, 128, 128)
color white

3
styles/layout.styl Normal file
View File

@ -0,0 +1,3 @@
*
padding 0
margin 0