-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: prepare tests, restructure templates and http mux
- Loading branch information
Showing
22 changed files
with
278 additions
and
166 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
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
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,7 +1,9 @@ | ||
package components | ||
|
||
templ PortalPartial(portals []templ.Component) { | ||
import "github.com/kodehat/portkey/internal/models" | ||
|
||
templ PortalPartial(portals []models.Portal) { | ||
for _, portal := range portals { | ||
@portal | ||
@HomePortal(portal) | ||
} | ||
} |
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,33 +1,35 @@ | ||
package components | ||
|
||
templ HomePortal(link string, emoji string, title string, external bool) { | ||
import "github.com/kodehat/portkey/internal/models" | ||
|
||
templ HomePortal(portal models.Portal) { | ||
<span class="text-3xl md:text-4xl lg:text-5xl font-normal md:font-light inline-flex items-center"> | ||
if emoji != "" { | ||
{ emoji } | ||
if portal.Emoji != "" { | ||
{ portal.Emoji } | ||
} | ||
<a | ||
if external { | ||
if portal.External { | ||
target="_blank" | ||
rel="nofollow" | ||
} | ||
href={ templ.SafeURL(link) } | ||
href={ templ.SafeURL(portal.Link) } | ||
class="mx-4 whitespace-nowrap no-underline border-b-2 border-solid border-slate-700 dark:border-slate-300 hover:text-slate-800 dark:hover:text-slate-300" | ||
>{ title }</a> | ||
>{ portal.Title }</a> | ||
</span> | ||
} | ||
|
||
templ FooterPortal(link string, emoji string, title string, external bool) { | ||
templ FooterPortal(portal models.Portal) { | ||
<span class="mx-2 inline-flex items-center"> | ||
if emoji != "" { | ||
{ emoji } | ||
if portal.Emoji != "" { | ||
{ portal.Emoji } | ||
} | ||
<a | ||
if external { | ||
if portal.External { | ||
target="_blank" | ||
rel="nofollow" | ||
} | ||
href={ templ.SafeURL(link) } | ||
href={ templ.SafeURL(portal.Link) } | ||
class="ml-1 no-underline border-b-2 border-solid border-slate-700 dark:border-slate-300 hover:text-slate-800 dark:hover:text-slate-300" | ||
>{ title }</a> | ||
>{ portal.Title }</a> | ||
</span> | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
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,10 @@ | ||
package server | ||
|
||
import "net/http" | ||
|
||
func healthHandler() http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
w.WriteHeader(http.StatusOK) | ||
w.Write([]byte("ok")) | ||
} | ||
} |
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,21 @@ | ||
package server | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/a-h/templ" | ||
"github.com/kodehat/portkey/internal/components" | ||
"github.com/kodehat/portkey/internal/config" | ||
) | ||
|
||
func homeHandler() http.HandlerFunc { | ||
home := components.HomePage() | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
if r.URL.Path != "/" { | ||
w.WriteHeader(http.StatusNotFound) | ||
templ.Handler(components.ContentLayout("404 Not Found", config.C, components.NotFound())).ServeHTTP(w, r) | ||
return | ||
} | ||
templ.Handler(components.HomeLayout("Home", config.C, home)).ServeHTTP(w, r) | ||
} | ||
} |
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
Oops, something went wrong.