Compare commits
3 Commits
afd6ffc3f1
...
b9560f01e7
Author | SHA1 | Date | |
---|---|---|---|
b9560f01e7 | |||
64fc6fd8fc | |||
7c55247af0 |
4
.gitignore
vendored
4
.gitignore
vendored
@ -33,3 +33,7 @@ public/js/
|
||||
|
||||
# NPM dependencies for Grunt
|
||||
node_modules/
|
||||
|
||||
# Local data
|
||||
data/
|
||||
|
||||
|
@ -1,8 +1,43 @@
|
||||
html,
|
||||
$nav-height: 65px
|
||||
|
||||
body
|
||||
margin: 0
|
||||
padding: 0
|
||||
background: lightgrey
|
||||
padding: $nav-height 0 0
|
||||
background: white
|
||||
|
||||
#main-nav
|
||||
position: fixed
|
||||
top: 0
|
||||
left: 0
|
||||
width: 100%
|
||||
height: $nav-height
|
||||
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
|
||||
|
17
colossus.go
17
colossus.go
@ -1,14 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/flamego/flamego"
|
||||
"github.com/flamego/template"
|
||||
|
||||
"git.metaunix.net/BitGoblin/colossus/models"
|
||||
"git.metaunix.net/BitGoblin/colossus/routes"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// initialize database connection
|
||||
models.InitDB()
|
||||
|
||||
// start initialize Flamego router
|
||||
f := flamego.Classic()
|
||||
|
||||
// serve static files from ./public/
|
||||
@ -24,12 +28,7 @@ func main() {
|
||||
}))
|
||||
|
||||
// register route handlers
|
||||
f.Get("/", func(t template.Template, data template.Data) {
|
||||
data["title"] = "Dashboard"
|
||||
t.HTML(http.StatusOK, "index")
|
||||
})
|
||||
|
||||
fmt.Println("test!!?")
|
||||
routes.InitRoutes(f)
|
||||
|
||||
f.Run()
|
||||
}
|
||||
|
0
data/.gitkeep
Normal file
0
data/.gitkeep
Normal file
5
go.mod
5
go.mod
@ -7,8 +7,13 @@ require (
|
||||
github.com/fatih/color v1.13.0 // indirect
|
||||
github.com/flamego/flamego v1.7.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-isatty v0.0.14 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.15 // indirect
|
||||
github.com/pkg/errors v0.9.1 // 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
13
go.sum
@ -6,14 +6,27 @@ 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/template v1.1.0 h1:iYtCzY3TeYpsoQiGApFXw2qycKdMzimz2gkO/SlcksM=
|
||||
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/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.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||
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/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-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/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=
|
||||
|
12
models/component.go
Normal file
12
models/component.go
Normal file
@ -0,0 +1,12 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Component struct {
|
||||
gorm.Model
|
||||
Name string
|
||||
Manufacturer string
|
||||
Type string
|
||||
}
|
17
models/init.go
Normal file
17
models/init.go
Normal file
@ -0,0 +1,17 @@
|
||||
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{})
|
||||
}
|
16
routes/hardware.go
Normal file
16
routes/hardware.go
Normal file
@ -0,0 +1,16 @@
|
||||
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("/")
|
||||
}
|
18
routes/index.go
Normal file
18
routes/index.go
Normal file
@ -0,0 +1,18 @@
|
||||
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")
|
||||
}
|
11
routes/init.go
Normal file
11
routes/init.go
Normal file
@ -0,0 +1,11 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"github.com/flamego/flamego"
|
||||
)
|
||||
|
||||
func InitRoutes(f *flamego.Flame) {
|
||||
f.Get("/", getIndex)
|
||||
|
||||
f.Get("/hardware/add", getHardwareAdd)
|
||||
}
|
@ -1,5 +1,29 @@
|
||||
{{ template "layout_header" . }}
|
||||
|
||||
<p>This is a test.</p>
|
||||
<div id="main-wrapper" class="container">
|
||||
<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" . }}
|
||||
|
@ -1,11 +1,11 @@
|
||||
{{ define "navbar" }}
|
||||
<nav id="main-nav">
|
||||
<ul class="nav-left">
|
||||
<li>Goliath</li>
|
||||
<li><a href="/">Dashboard</a></li>
|
||||
<li><a href="/benchmark">Benchmarks</a></li>
|
||||
<li><a href="/hardware">Hardware</a></li>
|
||||
<li><a href="/game">Games</a></li>
|
||||
<li class="site-logo">Goliath</li>
|
||||
<li class="nav-link"><a href="/">Dashboard</a></li>
|
||||
<li class="nav-link"><a href="/benchmark">Benchmarks</a></li>
|
||||
<li class="nav-link"><a href="/hardware">Hardware</a></li>
|
||||
<li class="nav-link"><a href="/game">Games</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
{{ end }}
|
||||
|
Loading…
Reference in New Issue
Block a user