Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to use templ instead of html/template #133

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@ root = true
[*]
end_of_line = lf
insert_final_newline = true

[*.css]
indent_style = space
indent_size = 2

[*.go]
indent_style = tab
indent_size = 4

[*.tmpl,*.html]
[*.{css,tmpl,templ,html,yaml,yml}]
indent_style = space
indent_size = 2
10 changes: 10 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ jobs:
run: |
go install golang.org/x/tools/cmd/goimports@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
go install github.com/a-h/templ/cmd/templ@latest
export PATH="$HOME/go/bin:$PATH"

- name: Run templ
run: templ generate

- name: Run pre-commit
uses: pre-commit/action@v3.0.1

Expand All @@ -38,6 +42,12 @@ jobs:
with:
go-version-file: "go.mod"

- name: templ generate
run: |
go install github.com/a-h/templ/cmd/templ@latest
export PATH="$HOME/go/bin:$PATH"
templ generate

- run: go build ./cmd/mineshspc

- uses: actions/upload-artifact@v4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*_templ.go
config.yaml
credentials.json
token.json
Expand Down
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ repos:
- repo: https://github.com/tekwizely/pre-commit-golang
rev: v1.0.0-rc.1
hooks:
- id: go-imports-repo
- id: go-imports
args:
- "-local"
- "github.com/ColoradoSchoolOfMines/mineshspc.com"
- "-w"
- id: go-vet-repo-mod
- id: go-staticcheck-repo-mod
exclude: _templ\.go$
- id: go-vet-mod
- id: go-staticcheck-mod
146 changes: 142 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 17 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,36 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
templ = {
url = "github:a-h/templ/v0.2.697";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, flake-utils }:
outputs = { self, nixpkgs, flake-utils, templ }:
(flake-utils.lib.eachDefaultSystem (system:
let pkgs = import nixpkgs { inherit system; };
let
pkgs = import nixpkgs {
inherit system;
overlays =
[ (final: prev: { inherit (templ.packages.${system}) templ; }) ];
};
in rec {
packages.mineshspc = pkgs.buildGo122Module {
pname = "mineshspc.com";
version = "unstable-2024-05-21";
src = self;
subPackages = [ "cmd/mineshspc" ];
vendorHash = "sha256-QjNH3O5/Hpu0OuVLUMN//f4d2j4wsDiUEfGLXH/Yf04=";
vendorHash = "sha256-iVuCWgtuYJ8ai7pSHO1bU9EaC9gEoWvtkEQUb6sUu+o=";

preBuild = ''
${pkgs.templ}/bin/templ generate
'';
};
packages.default = packages.mineshspc;

devShells.default = pkgs.mkShell {
packages = with pkgs; [ go gopls gotools pre-commit ];
packages = with pkgs; [ go gopls gotools pre-commit pkgs.templ ];
};
}));
}
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ go 1.22
toolchain go1.22.0

require (
github.com/a-h/templ v0.2.697
github.com/beeper/libserv v0.0.0-20231231202820-c7303abfc32c
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/mattn/go-sqlite3 v1.14.22
github.com/rs/zerolog v1.32.0
Expand All @@ -25,7 +27,6 @@ require (
github.com/rs/xid v1.5.0 // indirect
github.com/sendgrid/rest v2.6.9+incompatible // indirect
golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8 // indirect
golang.org/x/net v0.24.0 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
)
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU=
github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU=
github.com/a-h/templ v0.2.697 h1:OILxtWvD0NRJaoCOiZCopRDPW8paroKlGsrAiHLykNE=
github.com/a-h/templ v0.2.697/go.mod h1:5cqsugkq9IerRNucNsI4DEamdHPsoGMQy99DzydLhM8=
github.com/beeper/libserv v0.0.0-20231231202820-c7303abfc32c h1:WqjRVgUO039eiISCjsZC4F9onOEV93DJAk6v33rsZzY=
github.com/beeper/libserv v0.0.0-20231231202820-c7303abfc32c/go.mod h1:b9FFm9y4mEm36G8ytVmS1vkNzJa0KepmcdVY+qf7qRU=
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
Expand All @@ -8,6 +12,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8Yc
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg=
github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
Expand Down
Loading