Compare commits

..

No commits in common. "435dfbda40a29022fd293a2bb0b251a33779612a" and "6cc21192b122c3b15968a22ad753483cdf03000e" have entirely different histories.

14 changed files with 8 additions and 141 deletions

View File

@ -71,8 +71,8 @@ func NewServer(ctx context.Context, configs config.Configs, apiClient apiclient.
users.POST("/login", s.UserAfterLogin) users.POST("/login", s.UserAfterLogin)
users.GET("/signup", s.UserSignUp) users.GET("/signup", s.UserSignUp)
users.POST("/signup", s.UserAfterSignUp) users.POST("/signup", s.UserAfterSignUp)
users.GET("/logout", s.UsersLogout)
users.Use(ValidateJwtMiddleware(configs.JwtSecret)) users.Use(ValidateJwtMiddleware(configs.JwtSecret))
users.GET("/logout", s.UsersLogout)
users.GET("/profile", s.UserProfile) users.GET("/profile", s.UserProfile)
s.Router = router s.Router = router

View File

@ -11,7 +11,7 @@ import (
) )
func (h *Handler) UserLogin(c echo.Context) error { func (h *Handler) UserLogin(c echo.Context) error {
return Render(c, http.StatusOK, users.LoginNew()) return Render(c, http.StatusOK, users.Login())
} }
func (h *Handler) UserAfterLogin(c echo.Context) error { func (h *Handler) UserAfterLogin(c echo.Context) error {

View File

@ -1,34 +0,0 @@
package bulma
templ Button(color string, isLight, isDark bool) {
if isLight {
<button type="button" class={ "button", "is-light", color }>
{ children... }
</button>
}
if isDark {
<button type="button" class={ "button", "is-dark", color }>
{ children... }
</button>
}
if !isLight && !isDark {
<button type="button" class={ "button", color }>
{ children... }
</button>
}
}
templ ButtonNewTab(url, text string) {
<button type="button" class="button">
<a href={ templ.SafeURL(url) } target="_blank" rel="noopener noreferrer">{ text }</a>
</button>
}
templ ALink(url, title string) {
<a href={ templ.SafeURL(url) }>{ title }</a>
}
templ ANewTab(url, text string) {
<a href={ templ.SafeURL(url) } target="_blank" rel="noopener noreferrer">{ text }</a>
}

View File

@ -1,8 +0,0 @@
package form
// Div container to add a input field to.
templ Control() {
<div class="control">
{ children... }
</div>
}

View File

@ -1,8 +0,0 @@
package form
// This creates a field that you can add a Label, Control or Input object.
templ Field() {
<div class="field">
{ children... }
</div>
}

View File

@ -1,9 +0,0 @@
package form
templ Input(color, id, fieldType string) {
if color == "" {
<input class={ "input" } id={ id } type={ fieldType }/>
} else {
<input class={ "input", color } id={ id } type={ fieldType }/>
}
}

View File

@ -1,6 +0,0 @@
package form
// This will create a small bit of text to add context to the form.
templ Label(text string) {
<label class="label">{ text }</label>
}

View File

@ -1,7 +0,0 @@
package form
templ New(postUrl string) {
<form hx-post={ postUrl }>
{ children... }
</form>
}

View File

@ -1,5 +0,0 @@
package form
templ Submit(text, color string) {
<button type="submit" class={ "button", color }>{ text }</button>
}

View File

@ -1,6 +0,0 @@
package form
const (
InputTypeText = "text"
InputTypePassword = "password"
)

View File

@ -1,10 +0,0 @@
package bulma
const (
ColorPrimary = "is-primary"
ColorInfo = "is-info"
ColorLink = "is-link"
ColorWarning = "is-warning"
ColorSuccess = "is-success"
ColorError = "is-error"
)

View File

@ -1,19 +1,10 @@
package sources package sources
import ( import "git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/models" import "git.jamestombleson.com/jtom38/newsbot-portal/internal/models"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/views/bulma"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/views/bulma/form"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout"
)
templ Add(model models.AddSourcePayloadModel) { templ Add(model models.AddSourcePayloadModel) {
@layout.WithTemplate() { @layout.WithTemplate() {
<h2>New Source</h2> <form hx-post="/sources/add"></form>
<p>At this time only direct RSS links are allowed to be provided</p>
@form.New("/sources/add") {
@form.Input("", "url", "text")
@form.Submit("Submit", bulma.ColorPrimary)
}
} }
} }

View File

@ -1,17 +1,12 @@
package sources package sources
import ( import "git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/models" import "git.jamestombleson.com/jtom38/newsbot-portal/internal/models"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/views/bulma"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout"
)
templ ListAll(model models.ListAllSourcesViewModel) { templ ListAll(model models.ListAllSourcesViewModel) {
@layout.WithTemplate() { @layout.WithTemplate() {
for _, item := range model.Items { for _, item := range model.Items {
@bulma.Button(bulma.ColorPrimary, false, false) { <a href={ templ.SafeURL(item.Url) } target="_blank" rel="noopener noreferrer">{ item.DisplayName } - { item.Source } </a>
@bulma.ANewTab(item.Url, item.DisplayName)
}
<br/> <br/>
} }
} }

View File

@ -1,26 +0,0 @@
package users
import (
"git.jamestombleson.com/jtom38/newsbot-portal/internal/views/bulma/form"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout"
)
templ LoginNew() {
@layout.WithTemplate() {
@form.New("/users/login") {
@form.Field() {
@form.Label("Username")
@form.Control() {
@form.Input("", "username", "text")
}
}
@form.Field(){
@form.Label("Password")
@form.Control(){
@form.Input("", "password", form.InputTypePassword)
}
}
@form.Submit("Submit", "is-primary")
}
}
}