Compare commits

..

No commits in common. "bb8d056e4e60fb25bdaccb62ebfc05b7b0c41b56" 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 class="content">
{ datePosted }
<br/>
{ datePosted }<br/>
{ sourceName }
</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.
templ Section(title, subtitle string) {

View File

@ -20,12 +20,7 @@ func (h *Handler) ArticlesList(c echo.Context) error {
return RenderError(c, err)
}
vm := models.ListArticlesViewModel{
HeaderMetaTags: models.HeaderMetaTags{
Title: "Articles",
Type: "Page",
},
}
vm := models.ListArticlesViewModel{}
for _, article := range resp.Payload {
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 (
"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(models.HomeIndexViewModel{
HeaderMetaTags: models.HeaderMetaTags{
Title: "Newsbot",
Description: "Welcome to your news",
Url: "",
Type: "Page",
},
}))
return Render(c, http.StatusOK, home.Index())
}
func (h *Handler) HomeAbout(c echo.Context) error {
return Render(c, http.StatusOK, home.About(models.HomeAboutViewModel{
HeaderMetaTags: models.HeaderMetaTags{
Title: "About",
Type: "Page",
},
}))
return Render(c, http.StatusOK, home.About())
}

View File

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

View File

@ -3,12 +3,10 @@ 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
}

View File

@ -1,7 +1,6 @@
package models
type DebugCookiesViewModel struct {
HeaderMetaTags
Username string
Token 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
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"
type ListAllSourcesViewModel struct {
HeaderMetaTags
IsError bool
Message string
Items []domain.SourceDto
}
type AddSourcePayloadModel struct {
HeaderMetaTags
}

View File

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

View File

@ -7,7 +7,7 @@ import (
)
templ List(model models.ListArticlesViewModel) {
@layout.WithTemplate(model.HeaderMetaTags) {
@layout.WithTemplate() {
@filterBar()
for _, item := range model.Items {
@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) {
@layout.WithTemplate(model.HeaderMetaTags) {
@layout.WithTemplate() {
@bulma.Table() {
@bulma.TableHeader() {
@bulma.TableRow() {
@bulma.TableHeaderData("Title")
@bulma.TableHeaderData("Source")
@bulma.TableHeaderDataToolTip("Pub", "Date Published")
@bulma.TableHeaderData("View")
}
}
@ -21,7 +20,6 @@ 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")

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"
templ Cookies(vm models.DebugCookiesViewModel) {
@layout.WithTemplate(vm.HeaderMetaTags) {
@layout.WithTemplate() {
<p>
Token: { vm.Token }
</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/components/bulma"
import "git.jamestombleson.com/jtom38/newsbot-portal/internal/models"
templ About(vm models.HomeAboutViewModel) {
@layout.WithTemplate(vm.HeaderMetaTags){
templ About() {
@layout.WithTemplate(){
@bulma.Title("About this project")
@bulma.Block() {
Newsbot started a small project to send out notifications to discord servers.

View File

@ -3,12 +3,11 @@ 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(vm models.HomeIndexViewModel) {
@layout.WithTemplate(vm.HeaderMetaTags) {
templ Index() {
@layout.WithTemplate() {
@bl.Hero("Welcome to Newsbot!", "Your new home for your news.")
@b.Block() {
News bot is a self hostable solution to aggregating your news.

View File

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

View File

@ -1,18 +1,17 @@
package layout
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()
<link rel="stylesheet" href="/css/main.css"/>
<script src="https://unpkg.com/htmx.org@1.9.11" integrity="sha384-0gxUXCCR8yv9FM2b+U3FDbsKthCI66oH5IA9fHppQq9DDMHuMauqq1ZHBpJxQ0J0" crossorigin="anonymous"></script>
<meta charset="utf-8"/>
<meta property="og:title" content={ meta.Title }/>
<meta property="og:url" content={ meta.Url }/>
<meta property="og:image" content={ meta.Image }/>
<meta property="og:description" content={ meta.Image }/>
<meta property="og:type" content={ meta.Type }/>
<meta property="og:title" content=""/>
<meta property="og:url" content=""/>
<meta property="og:image" content=""/>
<meta property="og:description" content=""/>
<meta property="og:type" content=""/>
<style type="text/css">
.pin-bottom {
position: absolute;

View File

@ -1,24 +1,18 @@
package layout
import (
"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) {
templ WithTemplate() {
<!DOCTYPE html>
<html lang="en">
<head>
@header(meta)
@header()
</head>
<body>
@navBar()
<br/>
@bl.Container(bulma.BreakpointDefault) {
<div class="container is-widescreen">
{ children... }
@footer()
}
</div>
</body>
</html>
}

View File

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

View File

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

View File

@ -3,7 +3,6 @@ package users
import (
"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/models"
)
var (
@ -12,8 +11,8 @@ var (
}
)
templ LoginNew(vm models.UsersLoginViewModel) {
@layout.WithTemplate(vm.HeaderMetaTags) {
templ LoginNew() {
@layout.WithTemplate() {
@form.New(p) {
@form.Field() {
@form.Label("Username")

View File

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

View File

@ -1,16 +1,10 @@
package users
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"
)
import "git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout"
import bl "git.jamestombleson.com/jtom38/newsbot-portal/components/bulma/layout"
templ Logout() {
@layout.WithTemplate(models.HeaderMetaTags{
Title: "Logged Out",
Type: "Page",
}) {
@layout.WithTemplate(){
@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"
bh "git.jamestombleson.com/jtom38/newsbot-portal/components/bulma/html"
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 Profile() {
@layout.WithTemplate(models.HeaderMetaTags{
Title: "Profile",
Type: "Page",
}) {
@layout.WithTemplate() {
@bl.Hero("Profile", "Here you can update your profile 😀")
@bulma.H2("Sessions", false)
@bulma.Button() {
@bh.ALink("/users/forcelogout", "Terminate all active sessions")

View File

@ -2,15 +2,11 @@ package users
import (
"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"
)
templ SignUp() {
@layout.WithTemplate(models.HeaderMetaTags{
Title: "Signup",
Type: "Page",
}) {
@layout.WithTemplate() {
@form.New(form.NewParam{HxPost: "/users/signup"}) {
@form.Field(){
@form.Label("Username")