Compare commits
3 Commits
v0.0.1
..
b450ed7d2b
| Author | SHA1 | Date | |
|---|---|---|---|
| b450ed7d2b | |||
| b80b4150d5 | |||
| f6b2c852b9 |
+23
@@ -1,3 +1,26 @@
|
|||||||
|
# ---> Go
|
||||||
|
# If you prefer the allow list template instead of the deny list, see community template:
|
||||||
|
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
|
||||||
|
#
|
||||||
|
# Binaries for programs and plugins
|
||||||
|
*.exe
|
||||||
|
*.exe~
|
||||||
|
*.dll
|
||||||
|
*.so
|
||||||
|
*.dylib
|
||||||
|
|
||||||
|
# Test binary, built with `go test -c`
|
||||||
|
*.test
|
||||||
|
|
||||||
|
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||||
|
*.out
|
||||||
|
|
||||||
|
# Dependency directories (remove the comment below to include it)
|
||||||
|
vendor/
|
||||||
|
|
||||||
|
# Go workspace file
|
||||||
|
go.work
|
||||||
|
|
||||||
# Compiled binary
|
# Compiled binary
|
||||||
blt
|
blt
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
Copyright (c) 2023 Bit Goblin
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
NAME=blt
|
|
||||||
VERSION=0.0.1
|
|
||||||
|
|
||||||
.PHONY: build
|
|
||||||
## build: Compile the packages.
|
|
||||||
build:
|
|
||||||
@go build -o $(NAME) -ldflags "-X git.metaunix.net/bitgoblin/blt/app.Version=$(VERSION)"
|
|
||||||
|
|
||||||
.PHONY: run
|
|
||||||
## run: Build and Run in development mode.
|
|
||||||
run: build
|
|
||||||
@./$(NAME) -e development
|
|
||||||
|
|
||||||
.PHONY: run-prod
|
|
||||||
## run-prod: Build and Run in production mode.
|
|
||||||
run-prod: build
|
|
||||||
@./$(NAME) -e production
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
## clean: Clean project and previous builds.
|
|
||||||
clean:
|
|
||||||
@rm -f $(NAME)
|
|
||||||
|
|
||||||
.PHONY: deps
|
|
||||||
## deps: Download modules
|
|
||||||
deps:
|
|
||||||
@go mod download
|
|
||||||
|
|
||||||
.PHONY: test
|
|
||||||
## test: Run tests with verbose mode
|
|
||||||
test:
|
|
||||||
@go test -v ./tests/*
|
|
||||||
|
|
||||||
.PHONY: help
|
|
||||||
all: help
|
|
||||||
# help: show this help message
|
|
||||||
help: Makefile
|
|
||||||
@echo
|
|
||||||
@echo " Choose a command to run in "$(APP_NAME)":"
|
|
||||||
@echo
|
|
||||||
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
|
|
||||||
@echo
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package app
|
|
||||||
|
|
||||||
var (
|
|
||||||
Version string = "N/a"
|
|
||||||
)
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/flamego/flamego"
|
||||||
|
"github.com/flamego/template"
|
||||||
|
|
||||||
|
web "git.metaunix.net/bitgoblin/blt/src/web"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// initialize Flamego instance
|
||||||
|
f := flamego.Classic()
|
||||||
|
|
||||||
|
// enable templates
|
||||||
|
f.Use(template.Templater(template.Options{
|
||||||
|
Directory: "./views",
|
||||||
|
}))
|
||||||
|
|
||||||
|
// register routes
|
||||||
|
web.RegisterRoutes(f)
|
||||||
|
|
||||||
|
// start Flamego
|
||||||
|
f.Run()
|
||||||
|
}
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/flamego/flamego"
|
|
||||||
"github.com/flamego/template"
|
|
||||||
|
|
||||||
"git.metaunix.net/bitgoblin/blt/web"
|
|
||||||
"git.metaunix.net/bitgoblin/blt/web/middleware"
|
|
||||||
)
|
|
||||||
|
|
||||||
var Version string = "N/a"
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
// initial Flamego server object
|
|
||||||
f := flamego.Classic()
|
|
||||||
|
|
||||||
// initialize templating engine
|
|
||||||
f.Use(template.Templater())
|
|
||||||
|
|
||||||
// inject custom middleware
|
|
||||||
f.Use(middleware.CustomVars)
|
|
||||||
|
|
||||||
// register routes to server (moved to separate file for cleanliness)
|
|
||||||
web.RegisterRoutes(f)
|
|
||||||
|
|
||||||
// alert the user and start the server
|
|
||||||
log.Println("Server is running...")
|
|
||||||
log.Println(http.ListenAndServe("0.0.0.0:2830", f))
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package web
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/flamego/flamego"
|
||||||
|
|
||||||
|
"git.metaunix.net/bitgoblin/blt/src/web/routes"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RegisterRoutes(f *flamego.Flame) {
|
||||||
|
// top-level routes
|
||||||
|
f.Get("/", routes.GetTopIndex)
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package routes
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/flamego/template"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetTopIndex(t template.Template, data template.Data) {
|
||||||
|
data["title"] = "Dashboard"
|
||||||
|
t.HTML(http.StatusOK, "index")
|
||||||
|
}
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
{{ template "header" . }}
|
|
||||||
|
|
||||||
<p>This is the BLT dashboard.</p>
|
|
||||||
|
|
||||||
<p>BLT version {{ .app_version }}</p>
|
|
||||||
|
|
||||||
{{ template "footer" . }}
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{{ template "header" . }}
|
||||||
|
|
||||||
|
<p>This is a test!</p>
|
||||||
|
|
||||||
|
{{ template "footer" . }}
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package middleware
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/flamego/template"
|
|
||||||
|
|
||||||
"git.metaunix.net/bitgoblin/blt/app"
|
|
||||||
)
|
|
||||||
|
|
||||||
func CustomVars(data template.Data) {
|
|
||||||
data["app_version"] = app.Version
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package web
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/flamego/flamego"
|
|
||||||
|
|
||||||
"git.metaunix.net/bitgoblin/blt/web/routes"
|
|
||||||
)
|
|
||||||
|
|
||||||
func RegisterRoutes(f *flamego.Flame) {
|
|
||||||
// index routes
|
|
||||||
f.Get("/", routes.GetDashboard)
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package routes
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/flamego/template"
|
|
||||||
)
|
|
||||||
|
|
||||||
func GetDashboard(t template.Template, data template.Data) {
|
|
||||||
data["title"] = "Dashboard"
|
|
||||||
t.HTML(http.StatusOK, "index/dashboard")
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user