diff --git a/components/bulma/card.templ b/components/bulma/card.templ
index 9b226a2..402b1dd 100644
--- a/components/bulma/card.templ
+++ b/components/bulma/card.templ
@@ -14,9 +14,39 @@ templ ArticleCardWithThumbnail(title, thumbnailUrl, url, datePosted, sourceName
- { datePosted }
+ { datePosted }
+
{ sourceName }
}
+
+// Creates a card container.
+// Accepts children
+templ Card() {
+
+ { children... }
+
+}
+
+// Creates a image card container.
+// Accepts children
+templ CardImage() {
+
+ { children... }
+
+}
+
+//
+templ CardImageSize(size string) {
+
+}
+
+templ CardContentContainer() {
+
+ { children... }
+
+}
diff --git a/components/bulma/example/layout.templ b/components/bulma/example/layout.templ
deleted file mode 100644
index f7ec372..0000000
--- a/components/bulma/example/layout.templ
+++ /dev/null
@@ -1 +0,0 @@
-package example
diff --git a/components/bulma/html/img.templ b/components/bulma/html/img.templ
new file mode 100644
index 0000000..4de354b
--- /dev/null
+++ b/components/bulma/html/img.templ
@@ -0,0 +1,9 @@
+package html
+
+templ Img(src string) {
+
+}
+
+templ ImgAlt(src, alt string) {
+
+}
\ No newline at end of file
diff --git a/components/bulma/image.templ b/components/bulma/image.templ
new file mode 100644
index 0000000..94cc76e
--- /dev/null
+++ b/components/bulma/image.templ
@@ -0,0 +1,10 @@
+package bulma
+
+// Creates a image wrapper.
+// This accepts children.
+// Use html.Img() to load a image as a child
+templ Image(image string) {
+
+}
\ No newline at end of file
diff --git a/components/bulma/layout/section.templ b/components/bulma/layout/section.templ
index 4775db4..a25bef5 100644
--- a/components/bulma/layout/section.templ
+++ b/components/bulma/layout/section.templ
@@ -1,4 +1,4 @@
-package bulma
+package layout
// Creates a object thats good to break up a page of content.
templ Section(title, subtitle string) {
diff --git a/internal/handlers/articles.go b/internal/handlers/articles.go
index fd4a15d..e0dc757 100644
--- a/internal/handlers/articles.go
+++ b/internal/handlers/articles.go
@@ -20,7 +20,12 @@ func (h *Handler) ArticlesList(c echo.Context) error {
return RenderError(c, err)
}
- vm := models.ListArticlesViewModel{}
+ vm := models.ListArticlesViewModel{
+ HeaderMetaTags: models.HeaderMetaTags{
+ Title: "Articles",
+ Type: "Page",
+ },
+ }
for _, article := range resp.Payload {
source, err := h.api.Sources.GetById(GetJwtToken(c), article.SourceID)
@@ -36,5 +41,5 @@ func (h *Handler) ArticlesList(c echo.Context) error {
}
- return Render(c, http.StatusOK, articles.ListArticlesTable(vm))
+ return Render(c, http.StatusOK, articles.List(vm))
}
diff --git a/internal/handlers/home.go b/internal/handlers/home.go
index b47879f..3af0ed3 100644
--- a/internal/handlers/home.go
+++ b/internal/handlers/home.go
@@ -3,14 +3,27 @@ package handlers
import (
"net/http"
+ "git.jamestombleson.com/jtom38/newsbot-portal/internal/models"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/views/home"
"github.com/labstack/echo/v4"
)
func (h *Handler) HomeIndex(c echo.Context) error {
- return Render(c, http.StatusOK, home.Index())
+ return Render(c, http.StatusOK, home.Index(models.HomeIndexViewModel{
+ HeaderMetaTags: models.HeaderMetaTags{
+ Title: "Newsbot",
+ Description: "Welcome to your news",
+ Url: "",
+ Type: "Page",
+ },
+ }))
}
func (h *Handler) HomeAbout(c echo.Context) error {
- return Render(c, http.StatusOK, home.About())
-}
\ No newline at end of file
+ return Render(c, http.StatusOK, home.About(models.HomeAboutViewModel{
+ HeaderMetaTags: models.HeaderMetaTags{
+ Title: "About",
+ Type: "Page",
+ },
+ }))
+}
diff --git a/internal/handlers/users.go b/internal/handlers/users.go
index cc05b12..cd34f0a 100644
--- a/internal/handlers/users.go
+++ b/internal/handlers/users.go
@@ -11,7 +11,12 @@ import (
)
func (h *Handler) UserLogin(c echo.Context) error {
- return Render(c, http.StatusOK, users.LoginNew())
+ return Render(c, http.StatusOK, users.LoginNew(models.UsersLoginViewModel{
+ HeaderMetaTags: models.HeaderMetaTags{
+ Title: "Login",
+ Type: "Page",
+ },
+ }))
}
func (h *Handler) UserAfterLogin(c echo.Context) error {
diff --git a/internal/models/articles.go b/internal/models/articles.go
index d934049..520ad71 100644
--- a/internal/models/articles.go
+++ b/internal/models/articles.go
@@ -3,10 +3,12 @@ package models
import "git.jamestombleson.com/jtom38/newsbot-api/domain"
type ListArticlesViewModel struct {
+ HeaderMetaTags
Items []ListArticleSourceModel
}
type ListArticleSourceModel struct {
+ HeaderMetaTags
Article domain.ArticleDto
Source domain.SourceDto
}
diff --git a/internal/models/debug.go b/internal/models/debug.go
index 0621d83..a5aa388 100644
--- a/internal/models/debug.go
+++ b/internal/models/debug.go
@@ -1,6 +1,7 @@
package models
type DebugCookiesViewModel struct {
+ HeaderMetaTags
Username string
Token string
RefreshToken string
diff --git a/internal/models/home.go b/internal/models/home.go
new file mode 100644
index 0000000..87f3ee3
--- /dev/null
+++ b/internal/models/home.go
@@ -0,0 +1,9 @@
+package models
+
+type HomeIndexViewModel struct {
+ HeaderMetaTags
+}
+
+type HomeAboutViewModel struct {
+ HeaderMetaTags
+}
\ No newline at end of file
diff --git a/internal/models/layout.go b/internal/models/layout.go
index efdc03d..c8d51d7 100644
--- a/internal/models/layout.go
+++ b/internal/models/layout.go
@@ -4,3 +4,11 @@ type LayoutIsLoggedInViewModel struct {
IsLoggedIn bool
Username string
}
+
+type HeaderMetaTags struct {
+ Title string
+ Url string
+ Image string
+ Description string
+ Type string
+}
diff --git a/internal/models/sources.go b/internal/models/sources.go
index aee1894..d5cffc1 100644
--- a/internal/models/sources.go
+++ b/internal/models/sources.go
@@ -3,11 +3,12 @@ package models
import "git.jamestombleson.com/jtom38/newsbot-api/domain"
type ListAllSourcesViewModel struct {
+ HeaderMetaTags
IsError bool
Message string
Items []domain.SourceDto
}
type AddSourcePayloadModel struct {
-
+ HeaderMetaTags
}
\ No newline at end of file
diff --git a/internal/models/users.go b/internal/models/users.go
index a06736a..84715fc 100644
--- a/internal/models/users.go
+++ b/internal/models/users.go
@@ -1,5 +1,9 @@
package models
+type UsersLoginViewModel struct {
+ HeaderMetaTags
+}
+
type AfterLoginViewModel struct {
Message string
Success bool
diff --git a/internal/views/articles/list.templ b/internal/views/articles/list.templ
index 1d9497c..51b059e 100644
--- a/internal/views/articles/list.templ
+++ b/internal/views/articles/list.templ
@@ -7,7 +7,7 @@ import (
)
templ List(model models.ListArticlesViewModel) {
- @layout.WithTemplate() {
+ @layout.WithTemplate(model.HeaderMetaTags) {
@filterBar()
for _, item := range model.Items {
@bulma.ArticleCardWithThumbnail(item.Article.Title, item.Article.Thumbnail, item.Article.Url, item.Article.PubDate.String(), item.Source.DisplayName)
diff --git a/internal/views/articles/table.templ b/internal/views/articles/table.templ
index 08aeabf..1f52d9d 100644
--- a/internal/views/articles/table.templ
+++ b/internal/views/articles/table.templ
@@ -7,12 +7,13 @@ import (
)
templ ListArticlesTable(model models.ListArticlesViewModel) {
- @layout.WithTemplate() {
+ @layout.WithTemplate(model.HeaderMetaTags) {
@bulma.Table() {
@bulma.TableHeader() {
@bulma.TableRow() {
@bulma.TableHeaderData("Title")
@bulma.TableHeaderData("Source")
+ @bulma.TableHeaderDataToolTip("Pub", "Date Published")
@bulma.TableHeaderData("View")
}
}
@@ -20,6 +21,7 @@ templ ListArticlesTable(model models.ListArticlesViewModel) {
@bulma.TableRow() {
@bulma.TableData(item.Article.Title)
@bulma.TableData(item.Source.DisplayName)
+ @bulma.TableData(item.Article.PubDate.String())
@bulma.TableDataChildren() {
@bulma.Button() {
@bulma.ANewTab(item.Article.Url, "View")
diff --git a/internal/views/debug/cookies.templ b/internal/views/debug/cookies.templ
index 0f7d5e1..7b24bca 100644
--- a/internal/views/debug/cookies.templ
+++ b/internal/views/debug/cookies.templ
@@ -4,7 +4,7 @@ import "git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout"
import "git.jamestombleson.com/jtom38/newsbot-portal/internal/models"
templ Cookies(vm models.DebugCookiesViewModel) {
- @layout.WithTemplate() {
+ @layout.WithTemplate(vm.HeaderMetaTags) {
Token: { vm.Token }
diff --git a/internal/views/home/about.templ b/internal/views/home/about.templ
index b580198..92d96bf 100644
--- a/internal/views/home/about.templ
+++ b/internal/views/home/about.templ
@@ -2,9 +2,10 @@ package home
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/internal/models"
-templ About() {
- @layout.WithTemplate(){
+templ About(vm models.HomeAboutViewModel) {
+ @layout.WithTemplate(vm.HeaderMetaTags){
@bulma.Title("About this project")
@bulma.Block() {
Newsbot started a small project to send out notifications to discord servers.
diff --git a/internal/views/home/index.templ b/internal/views/home/index.templ
index c614456..29ee09a 100644
--- a/internal/views/home/index.templ
+++ b/internal/views/home/index.templ
@@ -3,11 +3,12 @@ package home
import (
b "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"
"git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout"
)
-templ Index() {
- @layout.WithTemplate() {
+templ Index(vm models.HomeIndexViewModel) {
+ @layout.WithTemplate(vm.HeaderMetaTags) {
@bl.Hero("Welcome to Newsbot!", "Your new home for your news.")
@b.Block() {
News bot is a self hostable solution to aggregating your news.
diff --git a/internal/views/layout/error.templ b/internal/views/layout/error.templ
index e1b00d6..4247b8b 100644
--- a/internal/views/layout/error.templ
+++ b/internal/views/layout/error.templ
@@ -1,7 +1,12 @@
package layout
+import "git.jamestombleson.com/jtom38/newsbot-portal/internal/models"
+
templ Error(err error) {
- @WithTemplate() {
+ @WithTemplate(models.HeaderMetaTags{
+ Title: "Error",
+ Description: err.Error(),
+ }) {
Error
{ err.Error() }
}
diff --git a/internal/views/layout/header.templ b/internal/views/layout/header.templ
index 0da3df2..1bd026b 100644
--- a/internal/views/layout/header.templ
+++ b/internal/views/layout/header.templ
@@ -1,17 +1,18 @@
package layout
import "git.jamestombleson.com/jtom38/newsbot-portal/components/bulma"
+import "git.jamestombleson.com/jtom38/newsbot-portal/internal/models"
-templ header() {
+templ header(meta models.HeaderMetaTags) {
@bulma.UseBulmaCdn()
-
-
-
-
-
+
+
+
+
+