Compare commits

..

No commits in common. "b9560f01e701390f64d0ab843969a5d895c13967" and "afd6ffc3f1b270b04a4bc64c1d90e99579c8579e" have entirely different histories.

13 changed files with 18 additions and 172 deletions

4
.gitignore vendored
View File

@ -33,7 +33,3 @@ public/js/
# NPM dependencies for Grunt # NPM dependencies for Grunt
node_modules/ node_modules/
# Local data
data/

View File

@ -1,43 +1,8 @@
$nav-height: 65px html,
body body
margin: 0 margin: 0
padding: $nav-height 0 0 padding: 0
background: white background: lightgrey
#main-nav #main-nav
position: fixed
top: 0
left: 0
width: 100%
height: $nav-height
background: cornflowerblue background: cornflowerblue
.nav-left,
.nav-right
list-style: none
li
display: inline-block
.nav-left
float: left
.nav-right
float: right
.site-logo,
.nav-link a
display: inline-block
padding: 15px 15px
color: black
font-size: 2rem
transition: all 230ms ease-in-out
&:hover
color: #333
.site-logo
padding-left: 25px
font-weight: bold
#main-wrapper
max-width: 1180px
margin-top: 15px
padding: 20px 27px

View File

@ -1,18 +1,14 @@
package main package main
import ( import (
"fmt"
"net/http"
"github.com/flamego/flamego" "github.com/flamego/flamego"
"github.com/flamego/template" "github.com/flamego/template"
"git.metaunix.net/BitGoblin/colossus/models"
"git.metaunix.net/BitGoblin/colossus/routes"
) )
func main() { func main() {
// initialize database connection
models.InitDB()
// start initialize Flamego router
f := flamego.Classic() f := flamego.Classic()
// serve static files from ./public/ // serve static files from ./public/
@ -28,7 +24,12 @@ func main() {
})) }))
// register route handlers // register route handlers
routes.InitRoutes(f) f.Get("/", func(t template.Template, data template.Data) {
data["title"] = "Dashboard"
t.HTML(http.StatusOK, "index")
})
fmt.Println("test!!?")
f.Run() f.Run()
} }

View File

5
go.mod
View File

@ -7,13 +7,8 @@ require (
github.com/fatih/color v1.13.0 // indirect github.com/fatih/color v1.13.0 // indirect
github.com/flamego/flamego v1.7.0 // indirect github.com/flamego/flamego v1.7.0 // indirect
github.com/flamego/template v1.1.0 // indirect github.com/flamego/template v1.1.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/mattn/go-colorable v0.1.9 // indirect github.com/mattn/go-colorable v0.1.9 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-sqlite3 v1.14.15 // indirect
github.com/pkg/errors v0.9.1 // indirect github.com/pkg/errors v0.9.1 // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
gorm.io/driver/sqlite v1.4.3 // indirect
gorm.io/gorm v1.24.2 // indirect
) )

13
go.sum
View File

@ -6,27 +6,14 @@ github.com/flamego/flamego v1.7.0 h1:c1Lu16PBAZKkpsjHw42vwotdoQnMMpUi60ITP41W12w
github.com/flamego/flamego v1.7.0/go.mod h1:dnVMBJyHKaxjcqRVN93taSK+YB/9p+Op1GdLIuA1hFQ= github.com/flamego/flamego v1.7.0/go.mod h1:dnVMBJyHKaxjcqRVN93taSK+YB/9p+Op1GdLIuA1hFQ=
github.com/flamego/template v1.1.0 h1:iYtCzY3TeYpsoQiGApFXw2qycKdMzimz2gkO/SlcksM= github.com/flamego/template v1.1.0 h1:iYtCzY3TeYpsoQiGApFXw2qycKdMzimz2gkO/SlcksM=
github.com/flamego/template v1.1.0/go.mod h1:bgnmEXNumarhQIUzFgn18CDG6u8cM6X09c7UOTwZcxM= github.com/flamego/template v1.1.0/go.mod h1:bgnmEXNumarhQIUzFgn18CDG6u8cM6X09c7UOTwZcxM=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.4 h1:tHnRBy1i5F2Dh8BAFxqFzxKqqvezXrL2OW1TnX+Mlas=
github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/mattn/go-colorable v0.1.9 h1:sqDoxXbdeALODt0DAeJCVp38ps9ZogZEAXjus69YV3U= github.com/mattn/go-colorable v0.1.9 h1:sqDoxXbdeALODt0DAeJCVp38ps9ZogZEAXjus69YV3U=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI=
github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gorm.io/driver/sqlite v1.4.3 h1:HBBcZSDnWi5BW3B3rwvVTc510KGkBkexlOg0QrmLUuU=
gorm.io/driver/sqlite v1.4.3/go.mod h1:0Aq3iPO+v9ZKbcdiz8gLWRw5VOPcBOPUQJFLq5e2ecI=
gorm.io/gorm v1.24.0/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
gorm.io/gorm v1.24.2 h1:9wR6CFD+G8nOusLdvkZelOEhpJVwwHzpQOUM+REd6U0=
gorm.io/gorm v1.24.2/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=

View File

@ -1,12 +0,0 @@
package models
import (
"gorm.io/gorm"
)
type Component struct {
gorm.Model
Name string
Manufacturer string
Type string
}

View File

@ -1,17 +0,0 @@
package models
import (
"gorm.io/gorm"
"gorm.io/driver/sqlite"
)
var (
DB *gorm.DB
)
func InitDB() {
DB, _ = gorm.Open(sqlite.Open("data/colossus.db"), &gorm.Config{})
// Migrate the schema
DB.AutoMigrate(&Component{})
}

View File

@ -1,16 +0,0 @@
package routes
import (
"github.com/flamego/flamego"
"git.metaunix.net/BitGoblin/colossus/models"
)
func getHardwareAdd(c flamego.Context) {
models.DB.Create(&models.Component{
Name: "PowerColor RX 570 4GB",
Manufacturer: "PowerColor",
Type: "Graphics Card",
})
c.Redirect("/")
}

View File

@ -1,18 +0,0 @@
package routes
import (
"net/http"
"github.com/flamego/template"
"git.metaunix.net/BitGoblin/colossus/models"
)
func getIndex(t template.Template, data template.Data) {
var hardware []models.Component
models.DB.Find(&hardware)
data["hardware"] = hardware
data["title"] = "Dashboard"
t.HTML(http.StatusOK, "index")
}

View File

@ -1,11 +0,0 @@
package routes
import (
"github.com/flamego/flamego"
)
func InitRoutes(f *flamego.Flame) {
f.Get("/", getIndex)
f.Get("/hardware/add", getHardwareAdd)
}

View File

@ -1,29 +1,5 @@
{{ template "layout_header" . }} {{ template "layout_header" . }}
<div id="main-wrapper" class="container"> <p>This is a test.</p>
<div class="row">
<div class="twelve columns">
<h1>Welcome to Colossus!</h1>
<p>Using Colossus you can easily keep track of your PC hardware benchmarking results and benchmark settings.</p>
</div>
</div>
<div class="row">
<div class="four columns">
<p><a href="/benchmark/add">Add benchmarking result</a></p>
</div>
<div class="four columns">
<p><a href="/hardware/add">Add new hardware</a></p>
<ul>
{{ range $i, $comp := .hardware }}
<li>{{ $comp.Name }}</li>
{{ end }}
</ul>
</div>
<div class="four columns">
<p><a href="/game/add">Add new game</a></p>
</div>
</div>
</div>
{{ template "layout_footer" . }} {{ template "layout_footer" . }}

View File

@ -1,11 +1,11 @@
{{ define "navbar" }} {{ define "navbar" }}
<nav id="main-nav"> <nav id="main-nav">
<ul class="nav-left"> <ul class="nav-left">
<li class="site-logo">Goliath</li> <li>Goliath</li>
<li class="nav-link"><a href="/">Dashboard</a></li> <li><a href="/">Dashboard</a></li>
<li class="nav-link"><a href="/benchmark">Benchmarks</a></li> <li><a href="/benchmark">Benchmarks</a></li>
<li class="nav-link"><a href="/hardware">Hardware</a></li> <li><a href="/hardware">Hardware</a></li>
<li class="nav-link"><a href="/game">Games</a></li> <li><a href="/game">Games</a></li>
</ul> </ul>
</nav> </nav>
{{ end }} {{ end }}