diff --git a/.air.toml b/.air.toml new file mode 100644 index 0000000..3164658 --- /dev/null +++ b/.air.toml @@ -0,0 +1,53 @@ +# Config file for [Air](https://github.com/cosmtrek/air) in TOML format + +# Working directory +# . or absolute path, please note that the directories following must be under root. +root = "." +tmp_dir = "tmp" + +[build] +# Just plain old shell command. You could use `make` as well. +cmd = "go build -o ./tmp/main ./cmd/web/" +# Binary file yields from `cmd`. +bin = "tmp main" +# Customize binary. +full_bin = "STRIPE_SECRET= STRIPE_KEY= ./tmp/main" +# Watch these filename extensions. +include_ext = ["go", "tpl", "tmpl", "html", "gohtml"] +# Ignore these filename extensions or directories. +exclude_dir = ["assets", "tmp", "vendor", "frontend/node_modules"] +# Watch these directories if you specified. +include_dir = [] +# Exclude files. +exclude_file = [] +# Exclude specific regular expressions. +exclude_regex = [] +# Exclude unchanged files. +exclude_unchanged = true +# Follow symlink for directories +follow_symlink = true +# This log file places in your tmp_dir. +log = "air.log" +# It's not necessary to trigger build each time file changes if it's too frequent. +delay = 1000 # ms +# Stop running old binary when build errors occur. +stop_on_error = true +# Send Interrupt signal before killing process (windows does not support this feature) +send_interrupt = true +# Delay after sending Interrupt signal +kill_delay = 500 # ms + +[log] +# Show log time +time = false + +[color] +# Customize each part's color. If no color found, use the raw app log. +main = "magenta" +watcher = "cyan" +build = "yellow" +runner = "green" + +[misc] +# Delete tmp directory on exit +clean_on_exit = true diff --git a/cmd/web/handlers.go b/cmd/web/handlers.go index 5417b96..7f3abc1 100644 --- a/cmd/web/handlers.go +++ b/cmd/web/handlers.go @@ -1,7 +1,11 @@ package main -import "net/http" +import ( + "net/http" +) func (app *application) VirtualTerminal(w http.ResponseWriter, r *http.Request) { - return + if err := app.renderTemplate(w, r, "terminal", nil); err != nil { + app.errorLog.Println(err) + } } diff --git a/cmd/web/render.go b/cmd/web/render.go index f39ccc8..7ef929d 100644 --- a/cmd/web/render.go +++ b/cmd/web/render.go @@ -40,7 +40,7 @@ func (app *application) renderTemplate( ) error { var t *template.Template var err error - templateToRender := fmt.Sprintf("templates/%s.page.tmpl", page) + templateToRender := fmt.Sprintf("templates/%s.page.gohtml", page) _, templateInMap := app.templateCache[templateToRender] @@ -79,15 +79,15 @@ func (app *application) parseTemplate( // build partials if len(partials) > 0 { for i, x := range partials { - partials[i] = fmt.Sprintf("tempaltes/%s.partial.tmpl", x) + partials[i] = fmt.Sprintf("tempaltes/%s.partial.gohtml", x) } - t, err = template.New(fmt.Sprintf("%s.page.tmpl", page)). + t, err = template.New(fmt.Sprintf("%s.page.gohtml", page)). Funcs(functions). - ParseFS(templateFS, "templates/base.layout.tmpl", strings.Join(partials, ","), templateToRender) + ParseFS(templateFS, "templates/base.layout.gohtml", strings.Join(partials, ","), templateToRender) } else { - t, err = template.New(fmt.Sprintf("%s.page.tmpl", page)). + t, err = template.New(fmt.Sprintf("%s.page.gohtml", page)). Funcs(functions). - ParseFS(templateFS, "templates/base.layout.tmpl", templateToRender) + ParseFS(templateFS, "templates/base.layout.gohtml", templateToRender) } if err != nil { app.errorLog.Println(err) diff --git a/cmd/web/templates/base.layout.gohtml b/cmd/web/templates/base.layout.gohtml new file mode 100644 index 0000000..046e196 --- /dev/null +++ b/cmd/web/templates/base.layout.gohtml @@ -0,0 +1,30 @@ +{{ define "base" }} + + + + + + Bootstrap demo + + + {{ block "title" . }} + {{ end }} + + + +
+
+
{{ block "content" . }} {{ end }}
+
+
+ + {{ block "js" . }} + {{ end }} + + +{{ end }} diff --git a/cmd/web/templates/base.layout.tmpl b/cmd/web/templates/base.layout.tmpl deleted file mode 100644 index 8a1465c..0000000 --- a/cmd/web/templates/base.layout.tmpl +++ /dev/null @@ -1,3 +0,0 @@ -{{define "base"}} - -{{end}} diff --git a/cmd/web/templates/terminal.page.gohtml b/cmd/web/templates/terminal.page.gohtml new file mode 100644 index 0000000..9c3cd01 --- /dev/null +++ b/cmd/web/templates/terminal.page.gohtml @@ -0,0 +1,9 @@ +{{ template "base" . }} +{{ define "title" }} +Virtual Terminal +{{ end }} +{{ define "content" }} +

Virtual Terminal

+{{ end }} +{{ define "js" }} +{{ end }}