Compare commits
No commits in common. "5a950af7a188c2f5f03c98696803ab68b9b0f490" and "8d83d6f5455839ff4c200e54297c83d961dfdd44" have entirely different histories.
5a950af7a1
...
8d83d6f545
@ -3,6 +3,7 @@ package handlers
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/a-h/templ"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"github.com/labstack/echo/v4/middleware"
|
"github.com/labstack/echo/v4/middleware"
|
||||||
|
|
||||||
@ -75,6 +76,39 @@ func NewServer(ctx context.Context, configs config.Configs, apiClient apiclient.
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This custom Render replaces Echo's echo.Context.Render() with templ's templ.Component.Render().
|
||||||
|
func Render(ctx echo.Context, statusCode int, t templ.Component) error {
|
||||||
|
ctx.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML)
|
||||||
|
ctx.Response().Writer.WriteHeader(statusCode)
|
||||||
|
return t.Render(ctx.Request().Context(), ctx.Response().Writer)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
func (s *Handler) WriteError(c echo.Context, errMessage error, HttpStatusCode int) error {
|
||||||
|
return c.JSON(HttpStatusCode, domain.BaseResponse{
|
||||||
|
Message: errMessage.Error(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Handler) WriteMessage(c echo.Context, msg string, HttpStatusCode int) error {
|
||||||
|
return c.JSON(HttpStatusCode, domain.BaseResponse{
|
||||||
|
Message: msg,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Handler) InternalServerErrorResponse(c echo.Context, msg string) error {
|
||||||
|
return c.JSON(http.StatusInternalServerError, domain.BaseResponse{
|
||||||
|
Message: msg,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Handler) UnauthorizedResponse(c echo.Context, msg string) error {
|
||||||
|
return c.JSON(http.StatusUnauthorized, domain.BaseResponse{
|
||||||
|
Message: msg,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// If the token is not valid then an json error will be returned.
|
// If the token is not valid then an json error will be returned.
|
||||||
// If the token has the wrong scope, a json error will be returned.
|
// If the token has the wrong scope, a json error will be returned.
|
||||||
// If the token passes all the checks, it is valid and is returned back to the caller.
|
// If the token passes all the checks, it is valid and is returned back to the caller.
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.jamestombleson.com/jtom38/newsbot-portal/internal/domain"
|
"git.jamestombleson.com/jtom38/newsbot-portal/internal/domain"
|
||||||
"github.com/a-h/templ"
|
|
||||||
"github.com/golang-jwt/jwt/v4"
|
"github.com/golang-jwt/jwt/v4"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
)
|
)
|
||||||
@ -61,18 +60,3 @@ func ValidateJwt(ctx echo.Context, sharedSecret, issuer string) (jwtToken, error
|
|||||||
|
|
||||||
return *claims, nil
|
return *claims, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Render(ctx echo.Context, statusCode int, t templ.Component) error {
|
|
||||||
ctx.Response().Writer.WriteHeader(statusCode)
|
|
||||||
ctx.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML)
|
|
||||||
|
|
||||||
// take the request context and make it a var
|
|
||||||
request := ctx.Request().Context()
|
|
||||||
//Check to see if we the echo context has the cookie we are looking for, if so, create a new context based on what we had and add the value
|
|
||||||
//darkMode, err := ctx.Cookie(domain.CookieSettingsDarkMode)
|
|
||||||
//if err == nil {
|
|
||||||
// request = context.WithValue(request, domain.CookieSettingsDarkMode, darkMode.Value)
|
|
||||||
//}
|
|
||||||
|
|
||||||
return t.Render(request, ctx.Response().Writer)
|
|
||||||
}
|
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
package articles
|
|
||||||
|
|
||||||
templ filterBar() {
|
|
||||||
<!-- Main container -->
|
|
||||||
<nav class="level">
|
|
||||||
<!-- Left side -->
|
|
||||||
<div class="level-left">
|
|
||||||
<div class="level-item">
|
|
||||||
<p class="subtitle is-5"><strong>123</strong> posts</p>
|
|
||||||
</div>
|
|
||||||
<div class="level-item">
|
|
||||||
<div class="field has-addons">
|
|
||||||
<p class="control">
|
|
||||||
<input class="input" type="text" placeholder="Find a post"/>
|
|
||||||
</p>
|
|
||||||
<p class="control">
|
|
||||||
<button class="button">Search</button>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- Right side -->
|
|
||||||
<div class="level-right">
|
|
||||||
<p class="level-item"><strong>All</strong></p>
|
|
||||||
<p class="level-item"><a>Published</a></p>
|
|
||||||
<p class="level-item"><a>Drafts</a></p>
|
|
||||||
<p class="level-item"><a>Deleted</a></p>
|
|
||||||
<p class="level-item"><a class="button is-success">New</a></p>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
}
|
|
@ -7,7 +7,6 @@ import (
|
|||||||
|
|
||||||
templ List(model models.ListArticlesViewModel) {
|
templ List(model models.ListArticlesViewModel) {
|
||||||
@layout.WithTemplate() {
|
@layout.WithTemplate() {
|
||||||
@filterBar()
|
|
||||||
for _, item := range model.Items {
|
for _, item := range model.Items {
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-image">
|
<div class="card-image">
|
||||||
|
@ -18,7 +18,7 @@ templ navBar() {
|
|||||||
</div>
|
</div>
|
||||||
<div id="navbarBasicExample" class="navbar-menu">
|
<div id="navbarBasicExample" class="navbar-menu">
|
||||||
<div class="navbar-start">
|
<div class="navbar-start">
|
||||||
<a class="navbar-item" href="/articles">Articles</a>
|
<a class="navbar-item" href="articles">Articles</a>
|
||||||
<a class="navbar-item">Documentation</a>
|
<a class="navbar-item">Documentation</a>
|
||||||
<!--
|
<!--
|
||||||
<div class="navbar-item has-dropdown is-hoverable">
|
<div class="navbar-item has-dropdown is-hoverable">
|
||||||
|
@ -8,7 +8,6 @@ templ WithTemplate() {
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@navBar()
|
@navBar()
|
||||||
<br/>
|
|
||||||
<div class="container is-widescreen">
|
<div class="container is-widescreen">
|
||||||
{ children... }
|
{ children... }
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user