Compare commits

...

5 Commits

20 changed files with 3520 additions and 2 deletions

21
.fresh.yaml Normal file
View File

@@ -0,0 +1,21 @@
version: "1"
root: .
main_path: ""
tmp_path: ./tmp
build_name: runner-build
build_args: ""
run_args: ""
build_log: runner-build-errors.log
valid_ext: .go, .tpl, .tmpl, .html
no_rebuild_ext: .tpl, .tmpl, .html
ignore: assets/**/*, assets, tmp/*, public/**/*, public, node_modules/**/*, node_modules
build_delay: "600"
colors: true
log_color_main: cyan
log_color_build: yellow
log_color_runner: green
log_color_watcher: magenta
log_color_app: ""
delve: false
delve_args: ""
debug: false

18
.gitignore vendored
View File

@@ -16,8 +16,24 @@
*.out
# Dependency directories (remove the comment below to include it)
# vendor/
vendor/
# Temporary directory created by fresh
tmp/
# Go workspace file
go.work
# Compiled Go binary
colossus
# Compiled CSS/JS
public/css/
public/js/
# NPM dependencies for Grunt
node_modules/
# Local data
data/

65
Gruntfile.js Normal file
View File

@@ -0,0 +1,65 @@
module.exports = function(grunt) {
var pkg = grunt.file.readJSON('package.json')
// Project configuration.
grunt.initConfig({
sass: {
dist: {
options: {
style: 'compressed'
},
files: [{
expand: true,
cwd: 'assets/sass',
src: ['*.sass'],
dest: 'public/css',
ext: '.css'
}]
}
},
coffee: {
options: {
sourceMap: true,
style: 'compressed'
},
files: {
expand: true,
flatten: true,
cwd: 'assets/coffee',
src: ['*.coffee'],
dest: 'public/js',
ext: '.js'
}
},
watch: {
css: {
files: ['assets/sass/*.sass'],
tasks: ['sass'],
options: {
atBegin: true,
spawn: false
}
},
js: {
files: ['assets/coffee/*.coffee'],
tasks: ['coffee'],
options: {
atBegin: true,
spawn: false
}
}
}
});
// Load task plugins
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-coffee');
grunt.loadNpmTasks('grunt-contrib-watch');
// Default task(s).
grunt.registerTask('default', ['sass', 'coffee']);
};

View File

@@ -1,4 +1,4 @@
Copyright (c) <year> <owner>
Copyright (c) 2022 Bit Goblin
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

43
assets/sass/nardah.sass Normal file
View File

@@ -0,0 +1,43 @@
$nav-height: 65px
body
margin: 0
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

34
colossus.go Normal file
View File

@@ -0,0 +1,34 @@
package main
import (
"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/
f.Use(flamego.Static(
flamego.StaticOptions{
Directory: "public",
},
))
// initialize template engine
f.Use(template.Templater(template.Options{
Directory: "./views",
}))
// register route handlers
routes.InitRoutes(f)
f.Run()
}

0
data/.gitkeep Normal file
View File

19
go.mod Normal file
View File

@@ -0,0 +1,19 @@
module git.metaunix.net/BitGoblin/colossus
go 1.18
require (
github.com/alecthomas/participle/v2 v2.0.0-beta.5 // indirect
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
)

32
go.sum Normal file
View File

@@ -0,0 +1,32 @@
github.com/alecthomas/participle/v2 v2.0.0-beta.5 h1:y6dsSYVb1G5eK6mgmy+BgI3Mw35a3WghArZ/Hbebrjo=
github.com/alecthomas/participle/v2 v2.0.0-beta.5/go.mod h1:RC764t6n4L8D8ITAJv0qdokritYSNR3wV5cVwmIEaMM=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
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
View 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
View 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{})
}

3128
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

26
package.json Normal file
View File

@@ -0,0 +1,26 @@
{
"name": "colossus",
"version": "0.1.0",
"description": "Self-hosted database for organizing PC hardware benchmarking results",
"main": "index.js",
"scripts": {
"grunt": "grunt",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://git.metaunix.net/BitGoblin/colossus.git"
},
"keywords": [
"benchmarking"
],
"author": "Gregory Ballantine <gballantine@bitgoblin.tech>",
"license": "BSD-2-Clause",
"devDependencies": {
"grunt": "^1.5.3",
"grunt-contrib-coffee": "^2.1.0",
"grunt-contrib-sass": "^2.0.0",
"grunt-contrib-watch": "^1.1.0",
"sass": "^1.56.1"
}
}

16
routes/hardware.go Normal file
View 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
View 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
View 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)
}

29
views/index.html Normal file
View File

@@ -0,0 +1,29 @@
{{ template "layout_header" . }}
<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" . }}

4
views/layout/footer.html Normal file
View File

@@ -0,0 +1,4 @@
{{ define "layout_footer" }}
</body>
</html>
{{ end }}

16
views/layout/header.html Normal file
View File

@@ -0,0 +1,16 @@
{{ define "layout_header" }}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ .title }}</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css">
<link rel="stylesheet" href="/css/nardah.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
</head>
<body>
{{ template "navbar" . }}
{{ end }}

11
views/layout/navbar.html Normal file
View File

@@ -0,0 +1,11 @@
{{ define "navbar" }}
<nav id="main-nav">
<ul class="nav-left">
<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 }}