Compare commits

..

No commits in common. "760130ccc2159c67aa1f29a1896f6b6c2cdfbfce" and "209a28501cf1112255575e741808b4a00d1a0fe9" have entirely different histories.

29 changed files with 44 additions and 171 deletions

View File

@ -14,39 +14,9 @@ templ ArticleCardWithThumbnail(title, thumbnailUrl, url, datePosted, sourceName
</div> </div>
</div> </div>
<div class="content"> <div class="content">
{ datePosted } { datePosted }<br/>
<br/>
{ sourceName } { sourceName }
</div> </div>
</div> </div>
</div> </div>
} }
// Creates a card container.
// Accepts children
templ Card() {
<div class="card">
{ children... }
</div>
}
// Creates a image card container.
// Accepts children
templ CardImage() {
<div class="card-image">
{ children... }
</div>
}
//
templ CardImageSize(size string) {
<figure class={ "image", size }>
{ children... }
</figure>
}
templ CardContentContainer() {
<div class="card-content">
{ children... }
</div>
}

View File

@ -0,0 +1 @@
package example

View File

@ -1,9 +0,0 @@
package html
templ Img(src string) {
<img src={ src } />
}
templ ImgAlt(src, alt string) {
<img src={ src } alt={ alt }/>
}

View File

@ -1,10 +0,0 @@
package bulma
// Creates a image wrapper.
// This accepts children.
// Use html.Img() to load a image as a child
templ Image(image string) {
<figure class={ "image", image }>
{ children... }
</figure>
}

View File

@ -1,4 +1,4 @@
package layout package bulma
// Creates a <section> object thats good to break up a page of content. // Creates a <section> object thats good to break up a page of content.
templ Section(title, subtitle string) { templ Section(title, subtitle string) {

View File

@ -20,12 +20,7 @@ func (h *Handler) ArticlesList(c echo.Context) error {
return RenderError(c, err) return RenderError(c, err)
} }
vm := models.ListArticlesViewModel{ vm := models.ListArticlesViewModel{}
HeaderMetaTags: models.HeaderMetaTags{
Title: "Articles",
Type: "Page",
},
}
for _, article := range resp.Payload { for _, article := range resp.Payload {
source, err := h.api.Sources.GetById(GetJwtToken(c), article.SourceID) source, err := h.api.Sources.GetById(GetJwtToken(c), article.SourceID)
@ -41,5 +36,5 @@ func (h *Handler) ArticlesList(c echo.Context) error {
} }
return Render(c, http.StatusOK, articles.List(vm)) return Render(c, http.StatusOK, articles.ListArticlesTable(vm))
} }

View File

@ -3,27 +3,14 @@ package handlers
import ( import (
"net/http" "net/http"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/models"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/views/home" "git.jamestombleson.com/jtom38/newsbot-portal/internal/views/home"
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
) )
func (h *Handler) HomeIndex(c echo.Context) error { func (h *Handler) HomeIndex(c echo.Context) error {
return Render(c, http.StatusOK, home.Index(models.HomeIndexViewModel{ return Render(c, http.StatusOK, home.Index())
HeaderMetaTags: models.HeaderMetaTags{
Title: "Newsbot",
Description: "Welcome to your news",
Url: "",
Type: "Page",
},
}))
} }
func (h *Handler) HomeAbout(c echo.Context) error { func (h *Handler) HomeAbout(c echo.Context) error {
return Render(c, http.StatusOK, home.About(models.HomeAboutViewModel{ return Render(c, http.StatusOK, home.About())
HeaderMetaTags: models.HeaderMetaTags{ }
Title: "About",
Type: "Page",
},
}))
}

View File

@ -11,12 +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(models.UsersLoginViewModel{ return Render(c, http.StatusOK, users.LoginNew())
HeaderMetaTags: models.HeaderMetaTags{
Title: "Login",
Type: "Page",
},
}))
} }
func (h *Handler) UserAfterLogin(c echo.Context) error { func (h *Handler) UserAfterLogin(c echo.Context) error {

View File

@ -3,12 +3,10 @@ package models
import "git.jamestombleson.com/jtom38/newsbot-api/domain" import "git.jamestombleson.com/jtom38/newsbot-api/domain"
type ListArticlesViewModel struct { type ListArticlesViewModel struct {
HeaderMetaTags
Items []ListArticleSourceModel Items []ListArticleSourceModel
} }
type ListArticleSourceModel struct { type ListArticleSourceModel struct {
HeaderMetaTags
Article domain.ArticleDto Article domain.ArticleDto
Source domain.SourceDto Source domain.SourceDto
} }

View File

@ -1,7 +1,6 @@
package models package models
type DebugCookiesViewModel struct { type DebugCookiesViewModel struct {
HeaderMetaTags
Username string Username string
Token string Token string
RefreshToken string RefreshToken string

View File

@ -1,9 +0,0 @@
package models
type HomeIndexViewModel struct {
HeaderMetaTags
}
type HomeAboutViewModel struct {
HeaderMetaTags
}

View File

@ -4,11 +4,3 @@ type LayoutIsLoggedInViewModel struct {
IsLoggedIn bool IsLoggedIn bool
Username string Username string
} }
type HeaderMetaTags struct {
Title string
Url string
Image string
Description string
Type string
}

View File

@ -3,12 +3,11 @@ package models
import "git.jamestombleson.com/jtom38/newsbot-api/domain" import "git.jamestombleson.com/jtom38/newsbot-api/domain"
type ListAllSourcesViewModel struct { type ListAllSourcesViewModel struct {
HeaderMetaTags
IsError bool IsError bool
Message string Message string
Items []domain.SourceDto Items []domain.SourceDto
} }
type AddSourcePayloadModel struct { type AddSourcePayloadModel struct {
HeaderMetaTags
} }

View File

@ -1,9 +1,5 @@
package models package models
type UsersLoginViewModel struct {
HeaderMetaTags
}
type AfterLoginViewModel struct { type AfterLoginViewModel struct {
Message string Message string
Success bool Success bool

View File

@ -7,7 +7,7 @@ import (
) )
templ List(model models.ListArticlesViewModel) { templ List(model models.ListArticlesViewModel) {
@layout.WithTemplate(model.HeaderMetaTags) { @layout.WithTemplate() {
@filterBar() @filterBar()
for _, item := range model.Items { for _, item := range model.Items {
@bulma.ArticleCardWithThumbnail(item.Article.Title, item.Article.Thumbnail, item.Article.Url, item.Article.PubDate.String(), item.Source.DisplayName) @bulma.ArticleCardWithThumbnail(item.Article.Title, item.Article.Thumbnail, item.Article.Url, item.Article.PubDate.String(), item.Source.DisplayName)

View File

@ -7,13 +7,12 @@ import (
) )
templ ListArticlesTable(model models.ListArticlesViewModel) { templ ListArticlesTable(model models.ListArticlesViewModel) {
@layout.WithTemplate(model.HeaderMetaTags) { @layout.WithTemplate() {
@bulma.Table() { @bulma.Table() {
@bulma.TableHeader() { @bulma.TableHeader() {
@bulma.TableRow() { @bulma.TableRow() {
@bulma.TableHeaderData("Title") @bulma.TableHeaderData("Title")
@bulma.TableHeaderData("Source") @bulma.TableHeaderData("Source")
@bulma.TableHeaderDataToolTip("Pub", "Date Published")
@bulma.TableHeaderData("View") @bulma.TableHeaderData("View")
} }
} }
@ -21,7 +20,6 @@ templ ListArticlesTable(model models.ListArticlesViewModel) {
@bulma.TableRow() { @bulma.TableRow() {
@bulma.TableData(item.Article.Title) @bulma.TableData(item.Article.Title)
@bulma.TableData(item.Source.DisplayName) @bulma.TableData(item.Source.DisplayName)
@bulma.TableData(item.Article.PubDate.String())
@bulma.TableDataChildren() { @bulma.TableDataChildren() {
@bulma.Button() { @bulma.Button() {
@bulma.ANewTab(item.Article.Url, "View") @bulma.ANewTab(item.Article.Url, "View")

View File

@ -4,7 +4,7 @@ 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"
templ Cookies(vm models.DebugCookiesViewModel) { templ Cookies(vm models.DebugCookiesViewModel) {
@layout.WithTemplate(vm.HeaderMetaTags) { @layout.WithTemplate() {
<p> <p>
Token: { vm.Token } Token: { vm.Token }
</p> </p>

View File

@ -2,10 +2,9 @@ package home
import "git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout" import "git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout"
import "git.jamestombleson.com/jtom38/newsbot-portal/components/bulma" import "git.jamestombleson.com/jtom38/newsbot-portal/components/bulma"
import "git.jamestombleson.com/jtom38/newsbot-portal/internal/models"
templ About(vm models.HomeAboutViewModel) { templ About() {
@layout.WithTemplate(vm.HeaderMetaTags){ @layout.WithTemplate(){
@bulma.Title("About this project") @bulma.Title("About this project")
@bulma.Block() { @bulma.Block() {
Newsbot started a small project to send out notifications to discord servers. Newsbot started a small project to send out notifications to discord servers.

View File

@ -3,12 +3,11 @@ package home
import ( import (
b "git.jamestombleson.com/jtom38/newsbot-portal/components/bulma" b "git.jamestombleson.com/jtom38/newsbot-portal/components/bulma"
bl "git.jamestombleson.com/jtom38/newsbot-portal/components/bulma/layout" bl "git.jamestombleson.com/jtom38/newsbot-portal/components/bulma/layout"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/models"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout" "git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout"
) )
templ Index(vm models.HomeIndexViewModel) { templ Index() {
@layout.WithTemplate(vm.HeaderMetaTags) { @layout.WithTemplate() {
@bl.Hero("Welcome to Newsbot!", "Your new home for your news.") @bl.Hero("Welcome to Newsbot!", "Your new home for your news.")
@b.Block() { @b.Block() {
News bot is a self hostable solution to aggregating your news. News bot is a self hostable solution to aggregating your news.

View File

@ -1,12 +1,7 @@
package layout package layout
import "git.jamestombleson.com/jtom38/newsbot-portal/internal/models"
templ Error(err error) { templ Error(err error) {
@WithTemplate(models.HeaderMetaTags{ @WithTemplate() {
Title: "Error",
Description: err.Error(),
}) {
<h1 class="title">Error</h1> <h1 class="title">Error</h1>
<h2 class="subtitle">{ err.Error() } </h2> <h2 class="subtitle">{ err.Error() } </h2>
} }

View File

@ -1,18 +1,17 @@
package layout package layout
import "git.jamestombleson.com/jtom38/newsbot-portal/components/bulma" import "git.jamestombleson.com/jtom38/newsbot-portal/components/bulma"
import "git.jamestombleson.com/jtom38/newsbot-portal/internal/models"
templ header(meta models.HeaderMetaTags) { templ header() {
@bulma.UseBulmaCdn() @bulma.UseBulmaCdn()
<link rel="stylesheet" href="/css/main.css"/> <link rel="stylesheet" href="/css/main.css"/>
<script src="https://unpkg.com/htmx.org@1.9.11" integrity="sha384-0gxUXCCR8yv9FM2b+U3FDbsKthCI66oH5IA9fHppQq9DDMHuMauqq1ZHBpJxQ0J0" crossorigin="anonymous"></script> <script src="https://unpkg.com/htmx.org@1.9.11" integrity="sha384-0gxUXCCR8yv9FM2b+U3FDbsKthCI66oH5IA9fHppQq9DDMHuMauqq1ZHBpJxQ0J0" crossorigin="anonymous"></script>
<meta charset="utf-8"/> <meta charset="utf-8"/>
<meta property="og:title" content={ meta.Title }/> <meta property="og:title" content=""/>
<meta property="og:url" content={ meta.Url }/> <meta property="og:url" content=""/>
<meta property="og:image" content={ meta.Image }/> <meta property="og:image" content=""/>
<meta property="og:description" content={ meta.Image }/> <meta property="og:description" content=""/>
<meta property="og:type" content={ meta.Type }/> <meta property="og:type" content=""/>
<style type="text/css"> <style type="text/css">
.pin-bottom { .pin-bottom {
position: absolute; position: absolute;

View File

@ -1,24 +1,18 @@
package layout package layout
import ( templ WithTemplate() {
"git.jamestombleson.com/jtom38/newsbot-portal/components/bulma"
bl "git.jamestombleson.com/jtom38/newsbot-portal/components/bulma/layout"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/models"
)
templ WithTemplate(meta models.HeaderMetaTags) {
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
@header(meta) @header()
</head> </head>
<body> <body>
@navBar() @navBar()
<br/> <br/>
@bl.Container(bulma.BreakpointDefault) { <div class="container is-widescreen">
{ children... } { children... }
@footer() @footer()
} </div>
</body> </body>
</html> </html>
} }

View File

@ -15,7 +15,7 @@ var (
) )
templ Add(model models.AddSourcePayloadModel) { templ Add(model models.AddSourcePayloadModel) {
@layout.WithTemplate(model.HeaderMetaTags) { @layout.WithTemplate() {
@bl.Hero("New Source", "") @bl.Hero("New Source", "")
@bulma.Block() { @bulma.Block() {
At this time only direct RSS links are allowed to be provided. At this time only direct RSS links are allowed to be provided.

View File

@ -8,7 +8,7 @@ import (
) )
templ ListAll(model models.ListAllSourcesViewModel) { templ ListAll(model models.ListAllSourcesViewModel) {
@layout.WithTemplate(model.HeaderMetaTags) { @layout.WithTemplate() {
@bulma.Button() { @bulma.Button() {
@bh.ALink("/sources/add", "New Source") @bh.ALink("/sources/add", "New Source")
} }

View File

@ -3,7 +3,6 @@ package users
import ( import (
"git.jamestombleson.com/jtom38/newsbot-portal/components/bulma/form" "git.jamestombleson.com/jtom38/newsbot-portal/components/bulma/form"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout" "git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/models"
) )
var ( var (
@ -12,8 +11,8 @@ var (
} }
) )
templ LoginNew(vm models.UsersLoginViewModel) { templ LoginNew() {
@layout.WithTemplate(vm.HeaderMetaTags) { @layout.WithTemplate() {
@form.New(p) { @form.New(p) {
@form.Field() { @form.Field() {
@form.Label("Username") @form.Label("Username")

View File

@ -1,10 +1,9 @@
package users package users
import "git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout" import "git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout"
import "git.jamestombleson.com/jtom38/newsbot-portal/internal/models"
templ Login(vm models.UsersLoginViewModel) { templ Login() {
@layout.WithTemplate(vm.HeaderMetaTags) { @layout.WithTemplate() {
<form hx-post="/users/login"> <form hx-post="/users/login">
<div class="field"> <div class="field">
<label class="label">Username</label> <label class="label">Username</label>

View File

@ -1,16 +1,10 @@
package users package users
import ( import "git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout"
bl "git.jamestombleson.com/jtom38/newsbot-portal/components/bulma/layout" import bl "git.jamestombleson.com/jtom38/newsbot-portal/components/bulma/layout"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/models"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout"
)
templ Logout() { templ Logout() {
@layout.WithTemplate(models.HeaderMetaTags{ @layout.WithTemplate(){
Title: "Logged Out", @bl.Hero("You are out of here!", "Please login again when you are ready.")
Type: "Page", }
}) { }
@bl.Hero("You are out of here!", "Please login again when you are ready.")
}
}

View File

@ -4,16 +4,13 @@ import (
"git.jamestombleson.com/jtom38/newsbot-portal/components/bulma" "git.jamestombleson.com/jtom38/newsbot-portal/components/bulma"
bh "git.jamestombleson.com/jtom38/newsbot-portal/components/bulma/html" bh "git.jamestombleson.com/jtom38/newsbot-portal/components/bulma/html"
bl "git.jamestombleson.com/jtom38/newsbot-portal/components/bulma/layout" bl "git.jamestombleson.com/jtom38/newsbot-portal/components/bulma/layout"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/models"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout" "git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout"
) )
templ Profile() { templ Profile() {
@layout.WithTemplate(models.HeaderMetaTags{ @layout.WithTemplate() {
Title: "Profile",
Type: "Page",
}) {
@bl.Hero("Profile", "Here you can update your profile 😀") @bl.Hero("Profile", "Here you can update your profile 😀")
@bulma.H2("Sessions", false) @bulma.H2("Sessions", false)
@bulma.Button() { @bulma.Button() {
@bh.ALink("/users/forcelogout", "Terminate all active sessions") @bh.ALink("/users/forcelogout", "Terminate all active sessions")

View File

@ -2,17 +2,13 @@ package users
import ( import (
"git.jamestombleson.com/jtom38/newsbot-portal/components/bulma/form" "git.jamestombleson.com/jtom38/newsbot-portal/components/bulma/form"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/models"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout" "git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout"
) )
templ SignUp() { templ SignUp() {
@layout.WithTemplate(models.HeaderMetaTags{ @layout.WithTemplate() {
Title: "Signup",
Type: "Page",
}) {
@form.New(form.NewParam{HxPost: "/users/signup"}) { @form.New(form.NewParam{HxPost: "/users/signup"}) {
@form.Field() { @form.Field(){
@form.Label("Username") @form.Label("Username")
@form.Control() { @form.Control() {
@form.TextInput("username", form.InputTypeText, "username or email address") @form.TextInput("username", form.InputTypeText, "username or email address")