Compare commits

...

5 Commits

14 changed files with 141 additions and 8 deletions

View File

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

View File

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

View File

@ -0,0 +1,34 @@
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

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

View File

@ -0,0 +1,8 @@
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

@ -0,0 +1,9 @@
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

@ -0,0 +1,6 @@
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

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

View File

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

View File

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

View File

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

View File

@ -1,10 +1,19 @@
package sources
import "git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout"
import "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) {
@layout.WithTemplate() {
<form hx-post="/sources/add"></form>
<h2>New Source</h2>
<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,12 +1,17 @@
package sources
import "git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout"
import "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) {
@layout.WithTemplate() {
for _, item := range model.Items {
<a href={ templ.SafeURL(item.Url) } target="_blank" rel="noopener noreferrer">{ item.DisplayName } - { item.Source } </a>
@bulma.Button(bulma.ColorPrimary, false, false) {
@bulma.ANewTab(item.Url, item.DisplayName)
}
<br/>
}
}

View File

@ -0,0 +1,26 @@
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")
}
}
}