-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
560 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
root = "." | ||
testdata_dir = "testdata" | ||
tmp_dir = "bin" | ||
|
||
[build] | ||
args_bin = [] | ||
bin = "./bin/aio serve" | ||
cmd = "make build" | ||
delay = 1000 | ||
exclude_dir = ["assets", "tmp", "vendor", "testdata"] | ||
exclude_file = [] | ||
exclude_regex = ["_test.go"] | ||
exclude_unchanged = false | ||
follow_symlink = false | ||
full_bin = "" | ||
include_dir = [] | ||
include_ext = ["go", "tpl", "tmpl", "html"] | ||
include_file = [] | ||
kill_delay = "0s" | ||
log = "build-errors.log" | ||
poll = false | ||
poll_interval = 0 | ||
post_cmd = [] | ||
pre_cmd = [] | ||
rerun = false | ||
rerun_delay = 500 | ||
send_interrupt = false | ||
stop_on_error = false | ||
|
||
[color] | ||
app = "" | ||
build = "yellow" | ||
main = "magenta" | ||
runner = "green" | ||
watcher = "cyan" | ||
|
||
[log] | ||
main_only = false | ||
time = false | ||
|
||
[misc] | ||
clean_on_exit = false | ||
|
||
[screen] | ||
clear_on_rebuild = false | ||
keep_scroll = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
package serve | ||
|
||
import ( | ||
"github.com/davesavic/aio/views/layout" | ||
"github.com/davesavic/aio/views/page" | ||
templEngine "github.com/davesavic/aio/services/templ" | ||
view "github.com/davesavic/aio/view" | ||
"github.com/gin-gonic/gin" | ||
"net/http" | ||
) | ||
|
||
func Run() error { | ||
r := gin.New() | ||
r.HTMLRender = templEngine.NewRenderer() | ||
r.Use(gin.Recovery()) | ||
r.Use(gin.Logger()) | ||
r.GET("/", func(context *gin.Context) { | ||
layout.UnauthorisedLayout( | ||
"Login", | ||
page.LoginPage(), | ||
).Render(context, context.Writer) | ||
|
||
r.GET("/", func(c *gin.Context) { | ||
c.HTML(http.StatusOK, "landing", view.LandingPage()) | ||
}) | ||
|
||
return r.Run() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package templ | ||
|
||
import ( | ||
"context" | ||
"github.com/a-h/templ" | ||
"github.com/gin-gonic/gin/render" | ||
"net/http" | ||
) | ||
|
||
type Render struct { | ||
Code int | ||
Component templ.Component | ||
} | ||
|
||
func (t Render) Render(w http.ResponseWriter) error { | ||
t.WriteContentType(w) | ||
w.WriteHeader(t.Code) | ||
if t.Component != nil { | ||
return t.Component.Render(context.Background(), w) | ||
} | ||
return nil | ||
} | ||
|
||
func (t Render) WriteContentType(w http.ResponseWriter) { | ||
w.Header().Set("Content-Type", "text/html; charset=utf-8") | ||
} | ||
|
||
func (t Render) Instance(_ string, data interface{}) render.Render { | ||
if templData, ok := data.(templ.Component); ok { | ||
return &Render{ | ||
Code: http.StatusOK, | ||
Component: templData, | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func NewRenderer() render.HTMLRender { | ||
return Render{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package view | ||
|
||
templ Button(text string, action func() string) { | ||
<a href={ templ.SafeURL(action()) } class="rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"> | ||
{text} | ||
</a> | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package view | ||
|
||
templ LandingPage() { | ||
@UnauthorisedLayout("Landing page") { | ||
@UnauthorisedHeader() | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package view | ||
|
||
templ UnauthorisedLayout(title string) { | ||
<html> | ||
<head> | ||
<script src="https://unpkg.com/[email protected]" integrity="sha384-D1Kt99CQMDuVetoL1lrYwg5t+9QdHe7NLX/SoJYkXDFfX37iInKRy5xLSi8nO7UC" crossorigin="anonymous"></script> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<script src="https://cdn.tailwindcss.com"></script> | ||
<title>{title}</title> | ||
</head> | ||
<body> | ||
{ children... } | ||
</body> | ||
</html> | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package view | ||
|
||
type LinkVariant string | ||
|
||
const ( | ||
LinkVariantPrimary LinkVariant = "primary" | ||
LinkVariantSecondary LinkVariant = "secondary" | ||
) | ||
|
||
templ Link(href string, text string, variant LinkVariant) { | ||
<a href={ templ.SafeURL(href) } class="rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"> | ||
{text} | ||
</a> | ||
} |
Oops, something went wrong.