Compare commits
5 Commits
6cc21192b1
...
435dfbda40
Author | SHA1 | Date | |
---|---|---|---|
435dfbda40 | |||
b6a6bb0043 | |||
d1f72aa0f1 | |||
bb135917cf | |||
0206d84894 |
@ -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.Use(ValidateJwtMiddleware(configs.JwtSecret))
|
|
||||||
users.GET("/logout", s.UsersLogout)
|
users.GET("/logout", s.UsersLogout)
|
||||||
|
users.Use(ValidateJwtMiddleware(configs.JwtSecret))
|
||||||
users.GET("/profile", s.UserProfile)
|
users.GET("/profile", s.UserProfile)
|
||||||
|
|
||||||
s.Router = router
|
s.Router = router
|
||||||
|
@ -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.Login())
|
return Render(c, http.StatusOK, users.LoginNew())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) UserAfterLogin(c echo.Context) error {
|
func (h *Handler) UserAfterLogin(c echo.Context) error {
|
||||||
|
34
internal/views/bulma/button.templ
Normal file
34
internal/views/bulma/button.templ
Normal 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>
|
||||||
|
}
|
8
internal/views/bulma/form/control.templ
Normal file
8
internal/views/bulma/form/control.templ
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package form
|
||||||
|
|
||||||
|
// Div container to add a input field to.
|
||||||
|
templ Control() {
|
||||||
|
<div class="control">
|
||||||
|
{ children... }
|
||||||
|
</div>
|
||||||
|
}
|
8
internal/views/bulma/form/field.templ
Normal file
8
internal/views/bulma/form/field.templ
Normal 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>
|
||||||
|
}
|
9
internal/views/bulma/form/input.templ
Normal file
9
internal/views/bulma/form/input.templ
Normal 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 }/>
|
||||||
|
}
|
||||||
|
}
|
6
internal/views/bulma/form/label.templ
Normal file
6
internal/views/bulma/form/label.templ
Normal 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>
|
||||||
|
}
|
7
internal/views/bulma/form/new.templ
Normal file
7
internal/views/bulma/form/new.templ
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package form
|
||||||
|
|
||||||
|
templ New(postUrl string) {
|
||||||
|
<form hx-post={ postUrl }>
|
||||||
|
{ children... }
|
||||||
|
</form>
|
||||||
|
}
|
5
internal/views/bulma/form/submit.templ
Normal file
5
internal/views/bulma/form/submit.templ
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package form
|
||||||
|
|
||||||
|
templ Submit(text, color string) {
|
||||||
|
<button type="submit" class={ "button", color }>{ text }</button>
|
||||||
|
}
|
6
internal/views/bulma/form/util.go
Normal file
6
internal/views/bulma/form/util.go
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
package form
|
||||||
|
|
||||||
|
const (
|
||||||
|
InputTypeText = "text"
|
||||||
|
InputTypePassword = "password"
|
||||||
|
)
|
10
internal/views/bulma/util.go
Normal file
10
internal/views/bulma/util.go
Normal 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"
|
||||||
|
)
|
@ -1,10 +1,19 @@
|
|||||||
package sources
|
package sources
|
||||||
|
|
||||||
import "git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout"
|
import (
|
||||||
import "git.jamestombleson.com/jtom38/newsbot-portal/internal/models"
|
"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() {
|
||||||
<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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,17 @@
|
|||||||
package sources
|
package sources
|
||||||
|
|
||||||
import "git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout"
|
import (
|
||||||
import "git.jamestombleson.com/jtom38/newsbot-portal/internal/models"
|
"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 {
|
||||||
<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/>
|
<br/>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
26
internal/views/users/login copy.templ
Normal file
26
internal/views/users/login copy.templ
Normal 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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user