improve UI with classless css library and other various modifications
This commit is contained in:
		
							parent
							
								
									f239b17255
								
							
						
					
					
						commit
						025f273f48
					
				@ -98,7 +98,8 @@ func (app *application) postUserLogout(w http.ResponseWriter, r *http.Request) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	app.sessionManager.Remove(r.Context(), "authenticatedUserId")
 | 
						app.sessionManager.Remove(r.Context(), "authenticatedUserId")
 | 
				
			||||||
	app.sessionManager.Put(r.Context(), "flash", "You've been logged out successfully!")
 | 
						app.sessionManager.Put(r.Context(), "flash", "You've been logged out successfully!")
 | 
				
			||||||
	http.Redirect(w, r, "/", http.StatusSeeOther)
 | 
						w.Header().Add("HX-Redirect", "/")
 | 
				
			||||||
 | 
						// http.Redirect(w, r, "/", http.StatusSeeOther)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// func (app *application) getUsersList(w http.ResponseWriter, r *http.Request) {
 | 
					// func (app *application) getUsersList(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										1
									
								
								ui/static/css/classless.min.css
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								ui/static/css/classless.min.css
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@ -1,12 +1,12 @@
 | 
				
			|||||||
html {
 | 
					/* html {
 | 
				
			||||||
  background: lightgray;
 | 
					  background: lightgray;
 | 
				
			||||||
}
 | 
					} */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
body {
 | 
					body {
 | 
				
			||||||
  max-width: 1024px;
 | 
					  max-width: 1024px;
 | 
				
			||||||
  margin: 1rem auto;
 | 
					  margin: 1rem auto;
 | 
				
			||||||
  padding: 1rem;
 | 
					  padding: 1rem;
 | 
				
			||||||
  background: white;
 | 
					  /* background: white; */
 | 
				
			||||||
  font-size: 1.2rem;
 | 
					  font-size: 1.2rem;
 | 
				
			||||||
  line-height: 1.5;
 | 
					  line-height: 1.5;
 | 
				
			||||||
  font-family: Arial, Helvetica, sans-serif;
 | 
					  font-family: Arial, Helvetica, sans-serif;
 | 
				
			||||||
@ -41,8 +41,8 @@ nav button {
 | 
				
			|||||||
  background: none;
 | 
					  background: none;
 | 
				
			||||||
  font-family: unset;
 | 
					  font-family: unset;
 | 
				
			||||||
  font-size: unset;
 | 
					  font-size: unset;
 | 
				
			||||||
  color: blue;
 | 
					  /* color: blue; */
 | 
				
			||||||
  text-decoration: underline;
 | 
					  /* text-decoration: underline; */
 | 
				
			||||||
  cursor: pointer;
 | 
					  cursor: pointer;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -75,5 +75,5 @@ footer {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
a {
 | 
					a {
 | 
				
			||||||
  color: blue;
 | 
					  /* color: blue; */
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -2,6 +2,8 @@ package views
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import "git.32bit.cafe/32bitcafe/guestbook/internal/models"
 | 
					import "git.32bit.cafe/32bitcafe/guestbook/internal/models"
 | 
				
			||||||
import "strconv"
 | 
					import "strconv"
 | 
				
			||||||
 | 
					import "fmt"
 | 
				
			||||||
 | 
					import "strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type CommonData struct {
 | 
					type CommonData struct {
 | 
				
			||||||
    CurrentYear int
 | 
					    CurrentYear int
 | 
				
			||||||
@ -21,6 +23,13 @@ func slugToShortId(slug string) uint64 {
 | 
				
			|||||||
    return id
 | 
					    return id
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func externalUrl(url string) string {
 | 
				
			||||||
 | 
					    if !strings.HasPrefix(url, "http") {
 | 
				
			||||||
 | 
					        return "http://" + url
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return url
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
templ commonHeader() {
 | 
					templ commonHeader() {
 | 
				
			||||||
    <header>
 | 
					    <header>
 | 
				
			||||||
        <h1><a href="/">webweav.ing</a></h1>
 | 
					        <h1><a href="/">webweav.ing</a></h1>
 | 
				
			||||||
@ -28,6 +37,7 @@ templ commonHeader() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
templ topNav(data CommonData) {
 | 
					templ topNav(data CommonData) {
 | 
				
			||||||
 | 
					    {{ hxHeaders := fmt.Sprintf("{\"X-CSRF-Token\": \"%s\"}", data.CSRFToken) }}
 | 
				
			||||||
    <nav>
 | 
					    <nav>
 | 
				
			||||||
        <div>
 | 
					        <div>
 | 
				
			||||||
            if data.IsAuthenticated {
 | 
					            if data.IsAuthenticated {
 | 
				
			||||||
@ -39,10 +49,7 @@ templ topNav(data CommonData) {
 | 
				
			|||||||
                <a href="/guestbooks">All Guestbooks</a> |
 | 
					                <a href="/guestbooks">All Guestbooks</a> |
 | 
				
			||||||
                <a href="/websites">My Websites</a> | 
 | 
					                <a href="/websites">My Websites</a> | 
 | 
				
			||||||
                <a href="/users/settings">Settings</a> | 
 | 
					                <a href="/users/settings">Settings</a> | 
 | 
				
			||||||
                <form action="/users/logout" method="post">
 | 
					                <a href="#" hx-post="/users/logout" hx-headers={ hxHeaders }>Logout</a>
 | 
				
			||||||
                    <input type="hidden" name="csrf_token" value={ data.CSRFToken }>
 | 
					 | 
				
			||||||
                    <button>Logout</button>
 | 
					 | 
				
			||||||
                </form>
 | 
					 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                <a href="/users/register">Create an Account</a> | 
 | 
					                <a href="/users/register">Create an Account</a> | 
 | 
				
			||||||
                <a href="/users/login">Login</a>
 | 
					                <a href="/users/login">Login</a>
 | 
				
			||||||
@ -54,8 +61,7 @@ templ topNav(data CommonData) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
templ commonFooter() {
 | 
					templ commonFooter() {
 | 
				
			||||||
    <footer>
 | 
					    <footer>
 | 
				
			||||||
        <p>Generated with Templ</p>
 | 
					        <p>A <a href="https://32bit.cafe">32bit.cafe</a> Project</p>
 | 
				
			||||||
        <p>A <a href="https://32bit.cafe">32-bit cafe</a> Project</p>
 | 
					 | 
				
			||||||
    </footer>
 | 
					    </footer>
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -66,6 +72,7 @@ templ base(title string, data CommonData) {
 | 
				
			|||||||
            <title>{ title } - webweav.ing</title>
 | 
					            <title>{ title } - webweav.ing</title>
 | 
				
			||||||
            <meta charset="UTF-8">
 | 
					            <meta charset="UTF-8">
 | 
				
			||||||
            <meta name="viewport" content="width=device-width, initial-scale=1">
 | 
					            <meta name="viewport" content="width=device-width, initial-scale=1">
 | 
				
			||||||
 | 
					            <link href="/static/css/classless.min.css" rel="stylesheet">
 | 
				
			||||||
            <link href="/static/css/style.css" rel="stylesheet">
 | 
					            <link href="/static/css/style.css" rel="stylesheet">
 | 
				
			||||||
            <script src="/static/js/htmx.min.js"></script>
 | 
					            <script src="/static/js/htmx.min.js"></script>
 | 
				
			||||||
        </head>
 | 
					        </head>
 | 
				
			||||||
 | 
				
			|||||||
@ -10,6 +10,8 @@ import templruntime "github.com/a-h/templ/runtime"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import "git.32bit.cafe/32bitcafe/guestbook/internal/models"
 | 
					import "git.32bit.cafe/32bitcafe/guestbook/internal/models"
 | 
				
			||||||
import "strconv"
 | 
					import "strconv"
 | 
				
			||||||
 | 
					import "fmt"
 | 
				
			||||||
 | 
					import "strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type CommonData struct {
 | 
					type CommonData struct {
 | 
				
			||||||
	CurrentYear     int
 | 
						CurrentYear     int
 | 
				
			||||||
@ -29,6 +31,13 @@ func slugToShortId(slug string) uint64 {
 | 
				
			|||||||
	return id
 | 
						return id
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func externalUrl(url string) string {
 | 
				
			||||||
 | 
						if !strings.HasPrefix(url, "http") {
 | 
				
			||||||
 | 
							return "http://" + url
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return url
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func commonHeader() templ.Component {
 | 
					func commonHeader() templ.Component {
 | 
				
			||||||
	return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
 | 
						return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
 | 
				
			||||||
		templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
 | 
							templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
 | 
				
			||||||
@ -79,6 +88,7 @@ func topNav(data CommonData) templ.Component {
 | 
				
			|||||||
			templ_7745c5c3_Var2 = templ.NopComponent
 | 
								templ_7745c5c3_Var2 = templ.NopComponent
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		ctx = templ.ClearChildren(ctx)
 | 
							ctx = templ.ClearChildren(ctx)
 | 
				
			||||||
 | 
							hxHeaders := fmt.Sprintf("{\"X-CSRF-Token\": \"%s\"}", data.CSRFToken)
 | 
				
			||||||
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<nav><div>")
 | 
							templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<nav><div>")
 | 
				
			||||||
		if templ_7745c5c3_Err != nil {
 | 
							if templ_7745c5c3_Err != nil {
 | 
				
			||||||
			return templ_7745c5c3_Err
 | 
								return templ_7745c5c3_Err
 | 
				
			||||||
@ -91,7 +101,7 @@ func topNav(data CommonData) templ.Component {
 | 
				
			|||||||
			var templ_7745c5c3_Var3 string
 | 
								var templ_7745c5c3_Var3 string
 | 
				
			||||||
			templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(data.CurrentUser.Username)
 | 
								templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(data.CurrentUser.Username)
 | 
				
			||||||
			if templ_7745c5c3_Err != nil {
 | 
								if templ_7745c5c3_Err != nil {
 | 
				
			||||||
				return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/common.templ`, Line: 34, Col: 52}
 | 
									return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/common.templ`, Line: 44, Col: 52}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
 | 
								_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
 | 
				
			||||||
			if templ_7745c5c3_Err != nil {
 | 
								if templ_7745c5c3_Err != nil {
 | 
				
			||||||
@ -103,20 +113,20 @@ func topNav(data CommonData) templ.Component {
 | 
				
			|||||||
			return templ_7745c5c3_Err
 | 
								return templ_7745c5c3_Err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if data.IsAuthenticated {
 | 
							if data.IsAuthenticated {
 | 
				
			||||||
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "<a href=\"/guestbooks\">All Guestbooks</a> | <a href=\"/websites\">My Websites</a> |  <a href=\"/users/settings\">Settings</a> | <form action=\"/users/logout\" method=\"post\"><input type=\"hidden\" name=\"csrf_token\" value=\"")
 | 
								templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "<a href=\"/guestbooks\">All Guestbooks</a> | <a href=\"/websites\">My Websites</a> |  <a href=\"/users/settings\">Settings</a> |  <a href=\"#\" hx-post=\"/users/logout\" hx-headers=\"")
 | 
				
			||||||
			if templ_7745c5c3_Err != nil {
 | 
								if templ_7745c5c3_Err != nil {
 | 
				
			||||||
				return templ_7745c5c3_Err
 | 
									return templ_7745c5c3_Err
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			var templ_7745c5c3_Var4 string
 | 
								var templ_7745c5c3_Var4 string
 | 
				
			||||||
			templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(data.CSRFToken)
 | 
								templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(hxHeaders)
 | 
				
			||||||
			if templ_7745c5c3_Err != nil {
 | 
								if templ_7745c5c3_Err != nil {
 | 
				
			||||||
				return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/common.templ`, Line: 43, Col: 81}
 | 
									return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/common.templ`, Line: 52, Col: 74}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
 | 
								_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
 | 
				
			||||||
			if templ_7745c5c3_Err != nil {
 | 
								if templ_7745c5c3_Err != nil {
 | 
				
			||||||
				return templ_7745c5c3_Err
 | 
									return templ_7745c5c3_Err
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "\"> <button>Logout</button></form>")
 | 
								templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "\">Logout</a>")
 | 
				
			||||||
			if templ_7745c5c3_Err != nil {
 | 
								if templ_7745c5c3_Err != nil {
 | 
				
			||||||
				return templ_7745c5c3_Err
 | 
									return templ_7745c5c3_Err
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@ -155,7 +165,7 @@ func commonFooter() templ.Component {
 | 
				
			|||||||
			templ_7745c5c3_Var5 = templ.NopComponent
 | 
								templ_7745c5c3_Var5 = templ.NopComponent
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		ctx = templ.ClearChildren(ctx)
 | 
							ctx = templ.ClearChildren(ctx)
 | 
				
			||||||
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "<footer><p>Generated with Templ</p><p>A <a href=\"https://32bit.cafe\">32-bit cafe</a> Project</p></footer>")
 | 
							templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "<footer><p>A <a href=\"https://32bit.cafe\">32bit.cafe</a> Project</p></footer>")
 | 
				
			||||||
		if templ_7745c5c3_Err != nil {
 | 
							if templ_7745c5c3_Err != nil {
 | 
				
			||||||
			return templ_7745c5c3_Err
 | 
								return templ_7745c5c3_Err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@ -191,13 +201,13 @@ func base(title string, data CommonData) templ.Component {
 | 
				
			|||||||
		var templ_7745c5c3_Var7 string
 | 
							var templ_7745c5c3_Var7 string
 | 
				
			||||||
		templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(title)
 | 
							templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(title)
 | 
				
			||||||
		if templ_7745c5c3_Err != nil {
 | 
							if templ_7745c5c3_Err != nil {
 | 
				
			||||||
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/common.templ`, Line: 66, Col: 26}
 | 
								return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/common.templ`, Line: 72, Col: 26}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
 | 
							_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
 | 
				
			||||||
		if templ_7745c5c3_Err != nil {
 | 
							if templ_7745c5c3_Err != nil {
 | 
				
			||||||
			return templ_7745c5c3_Err
 | 
								return templ_7745c5c3_Err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, " - webweav.ing</title><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><link href=\"/static/css/style.css\" rel=\"stylesheet\"><script src=\"/static/js/htmx.min.js\"></script></head><body>")
 | 
							templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, " - webweav.ing</title><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><link href=\"/static/css/classless.min.css\" rel=\"stylesheet\"><link href=\"/static/css/style.css\" rel=\"stylesheet\"><script src=\"/static/js/htmx.min.js\"></script></head><body>")
 | 
				
			||||||
		if templ_7745c5c3_Err != nil {
 | 
							if templ_7745c5c3_Err != nil {
 | 
				
			||||||
			return templ_7745c5c3_Err
 | 
								return templ_7745c5c3_Err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@ -221,7 +231,7 @@ func base(title string, data CommonData) templ.Component {
 | 
				
			|||||||
			var templ_7745c5c3_Var8 string
 | 
								var templ_7745c5c3_Var8 string
 | 
				
			||||||
			templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(data.Flash)
 | 
								templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(data.Flash)
 | 
				
			||||||
			if templ_7745c5c3_Err != nil {
 | 
								if templ_7745c5c3_Err != nil {
 | 
				
			||||||
				return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/common.templ`, Line: 77, Col: 51}
 | 
									return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/common.templ`, Line: 84, Col: 51}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
 | 
								_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
 | 
				
			||||||
			if templ_7745c5c3_Err != nil {
 | 
								if templ_7745c5c3_Err != nil {
 | 
				
			||||||
 | 
				
			|||||||
@ -2,13 +2,13 @@
 | 
				
			|||||||
<nav><div>
 | 
					<nav><div>
 | 
				
			||||||
Welcome, 
 | 
					Welcome, 
 | 
				
			||||||
</div><div>
 | 
					</div><div>
 | 
				
			||||||
<a href=\"/guestbooks\">All Guestbooks</a> | <a href=\"/websites\">My Websites</a> |  <a href=\"/users/settings\">Settings</a> | <form action=\"/users/logout\" method=\"post\"><input type=\"hidden\" name=\"csrf_token\" value=\"
 | 
					<a href=\"/guestbooks\">All Guestbooks</a> | <a href=\"/websites\">My Websites</a> |  <a href=\"/users/settings\">Settings</a> |  <a href=\"#\" hx-post=\"/users/logout\" hx-headers=\"
 | 
				
			||||||
\"> <button>Logout</button></form>
 | 
					\">Logout</a>
 | 
				
			||||||
<a href=\"/users/register\">Create an Account</a> |  <a href=\"/users/login\">Login</a>
 | 
					<a href=\"/users/register\">Create an Account</a> |  <a href=\"/users/login\">Login</a>
 | 
				
			||||||
</div></nav>
 | 
					</div></nav>
 | 
				
			||||||
<footer><p>Generated with Templ</p><p>A <a href=\"https://32bit.cafe\">32-bit cafe</a> Project</p></footer>
 | 
					<footer><p>A <a href=\"https://32bit.cafe\">32bit.cafe</a> Project</p></footer>
 | 
				
			||||||
<!doctype html><html lang=\"en\"><head><title>
 | 
					<!doctype html><html lang=\"en\"><head><title>
 | 
				
			||||||
 - webweav.ing</title><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><link href=\"/static/css/style.css\" rel=\"stylesheet\"><script src=\"/static/js/htmx.min.js\"></script></head><body>
 | 
					 - webweav.ing</title><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><link href=\"/static/css/classless.min.css\" rel=\"stylesheet\"><link href=\"/static/css/style.css\" rel=\"stylesheet\"><script src=\"/static/js/htmx.min.js\"></script></head><body>
 | 
				
			||||||
<main>
 | 
					<main>
 | 
				
			||||||
<div class=\"flash\">
 | 
					<div class=\"flash\">
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 | 
				
			|||||||
@ -4,23 +4,13 @@ import "fmt"
 | 
				
			|||||||
import "git.32bit.cafe/32bitcafe/guestbook/internal/models"
 | 
					import "git.32bit.cafe/32bitcafe/guestbook/internal/models"
 | 
				
			||||||
import "git.32bit.cafe/32bitcafe/guestbook/internal/forms"
 | 
					import "git.32bit.cafe/32bitcafe/guestbook/internal/forms"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func gbUrl(gb models.Guestbook) string {
 | 
					 | 
				
			||||||
    return fmt.Sprintf("/guestbooks/%s", shortIdToSlug(gb.ShortId))
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
templ gbCreateForm(csrf_token string) {
 | 
					 | 
				
			||||||
    <input type="hidden" name="csrf_token" value={ csrf_token }>
 | 
					 | 
				
			||||||
    <label for="siteurl">Site URL: </label>
 | 
					 | 
				
			||||||
    <input type="text" name="siteurl" id="siteurl" required />
 | 
					 | 
				
			||||||
    <button type="submit">Submit</button>
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
templ GuestbookDashboardCommentsView(title string, data CommonData, website models.Website, guestbook models.Guestbook, comments []models.GuestbookComment) {
 | 
					templ GuestbookDashboardCommentsView(title string, data CommonData, website models.Website, guestbook models.Guestbook, comments []models.GuestbookComment) {
 | 
				
			||||||
    @base(title, data) {
 | 
					    @base(title, data) {
 | 
				
			||||||
        <div id="dashboard">
 | 
					        <div id="dashboard">
 | 
				
			||||||
            @wSidebar(website)
 | 
					            @wSidebar(website)
 | 
				
			||||||
            <div>
 | 
					            <div>
 | 
				
			||||||
                <h1>Comments on { website.SiteUrl }</h1>
 | 
					                <h1>Comments on { website.SiteUrl }</h1>
 | 
				
			||||||
 | 
					                <hr>
 | 
				
			||||||
                if len(comments) == 0 {
 | 
					                if len(comments) == 0 {
 | 
				
			||||||
                    <p>No comments yet!</p>
 | 
					                    <p>No comments yet!</p>
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@ -32,6 +22,42 @@ templ GuestbookDashboardCommentsView(title string, data CommonData, website mode
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					templ GuestbookDashboardCommentView(data CommonData, w models.Website, c models.GuestbookComment) {
 | 
				
			||||||
 | 
					    {{ commentUrl := fmt.Sprintf("%s/dashboard/guestbook/comments/%s", wUrl(w), shortIdToSlug(c.ShortId)) }}
 | 
				
			||||||
 | 
					    {{ hxHeaders := fmt.Sprintf("{\"X-CSRF-Token\": \"%s\"}", data.CSRFToken) }}
 | 
				
			||||||
 | 
					    <div class="comment">
 | 
				
			||||||
 | 
					        <div>
 | 
				
			||||||
 | 
					            if c.Deleted.IsZero() {
 | 
				
			||||||
 | 
					                <button class="danger" hx-delete={ commentUrl } hx-target="closest div.comment" hx-headers={ hxHeaders }>Delete</button>
 | 
				
			||||||
 | 
					                <button class="outline" hx-put={ commentUrl } hx-target="closest div.comment" hx-headers={ hxHeaders }>
 | 
				
			||||||
 | 
					                    if !c.IsPublished {
 | 
				
			||||||
 | 
					                        Publish
 | 
				
			||||||
 | 
					                    } else {
 | 
				
			||||||
 | 
					                        Hide
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                </button> 
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					        <div>
 | 
				
			||||||
 | 
					            <strong>{ c.AuthorName }</strong>
 | 
				
			||||||
 | 
					            if len(c.AuthorEmail) > 0 {
 | 
				
			||||||
 | 
					                {{ email := "mailto:" + c.AuthorEmail}}
 | 
				
			||||||
 | 
					                | <a href={ templ.URL(email) } target="_blank">{ c.AuthorEmail }</a>
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if len(c.AuthorSite) > 0 {
 | 
				
			||||||
 | 
					                | <a href={ templ.URL(externalUrl(c.AuthorSite))} target="_blank">{ c.AuthorSite }</a>
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            <p>
 | 
				
			||||||
 | 
					                { c.Created.Format("01-02-2006 03:04PM") }
 | 
				
			||||||
 | 
					            </p>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					        <p>
 | 
				
			||||||
 | 
					            { c.CommentText }
 | 
				
			||||||
 | 
					        </p>
 | 
				
			||||||
 | 
					        <hr>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
templ commentForm(form forms.CommentCreateForm) {
 | 
					templ commentForm(form forms.CommentCreateForm) {
 | 
				
			||||||
    <div>
 | 
					    <div>
 | 
				
			||||||
        <label for="authorname">Name: </label>
 | 
					        <label for="authorname">Name: </label>
 | 
				
			||||||
@ -70,21 +96,6 @@ templ commentForm(form forms.CommentCreateForm) {
 | 
				
			|||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
templ GuestbookCommentList(comments []models.GuestbookComment) {
 | 
					 | 
				
			||||||
    if len(comments) == 0 {
 | 
					 | 
				
			||||||
        <p>No comments yet!</p>
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    for _, c := range comments {
 | 
					 | 
				
			||||||
        <div>
 | 
					 | 
				
			||||||
            <strong>{ c.AuthorName }</strong>
 | 
					 | 
				
			||||||
            { c.Created.Format("01-02-2006 03:04PM") }
 | 
					 | 
				
			||||||
            <p>
 | 
					 | 
				
			||||||
                { c.CommentText }
 | 
					 | 
				
			||||||
            </p>
 | 
					 | 
				
			||||||
        </div>
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
templ GuestbookView(title string, data CommonData, website models.Website, guestbook models.Guestbook, comments []models.GuestbookComment, form forms.CommentCreateForm) {
 | 
					templ GuestbookView(title string, data CommonData, website models.Website, guestbook models.Guestbook, comments []models.GuestbookComment, form forms.CommentCreateForm) {
 | 
				
			||||||
    {{ postUrl := fmt.Sprintf("/websites/%s/guestbook/comments/create", shortIdToSlug(website.ShortId)) }}
 | 
					    {{ postUrl := fmt.Sprintf("/websites/%s/guestbook/comments/create", shortIdToSlug(website.ShortId)) }}
 | 
				
			||||||
    if data.IsHtmx {
 | 
					    if data.IsHtmx {
 | 
				
			||||||
@ -93,18 +104,30 @@ templ GuestbookView(title string, data CommonData, website models.Website, guest
 | 
				
			|||||||
        <html>
 | 
					        <html>
 | 
				
			||||||
            <head>
 | 
					            <head>
 | 
				
			||||||
            <title>{ title }</title>
 | 
					            <title>{ title }</title>
 | 
				
			||||||
 | 
					            <link href="/static/css/classless.min.css" rel="stylesheet">
 | 
				
			||||||
            </head>
 | 
					            </head>
 | 
				
			||||||
            <body>
 | 
					            <body>
 | 
				
			||||||
                <main>
 | 
					                <main>
 | 
				
			||||||
                    <div>
 | 
					                    <div>
 | 
				
			||||||
                        <h1>Guestbook for { website.SiteUrl }</h1>
 | 
					                        <h1>Guestbook for { website.Name }</h1>
 | 
				
			||||||
                        <form action={ templ.URL(postUrl) } method="post">
 | 
					                        <form action={ templ.URL(postUrl) } method="post">
 | 
				
			||||||
                            <input type="hidden" name="csrf_token" value={data.CSRFToken}>
 | 
					                            <input type="hidden" name="csrf_token" value={data.CSRFToken}>
 | 
				
			||||||
                            @commentForm(form)
 | 
					                            @commentForm(form)
 | 
				
			||||||
                        </form>
 | 
					                        </form>
 | 
				
			||||||
                    </div>
 | 
					                    </div>
 | 
				
			||||||
                    <div id="comments">
 | 
					                    <div id="comments">
 | 
				
			||||||
                        @GuestbookCommentList(comments)
 | 
					                        if len(comments) == 0 {
 | 
				
			||||||
 | 
					                            <p>No comments yet!</p>
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        for _, c := range comments {
 | 
				
			||||||
 | 
					                            <div>
 | 
				
			||||||
 | 
					                                <h3>{ c.AuthorName }</h3>
 | 
				
			||||||
 | 
					                                { c.Created.Format("01-02-2006 03:04PM") }
 | 
				
			||||||
 | 
					                                <p>
 | 
				
			||||||
 | 
					                                    { c.CommentText }
 | 
				
			||||||
 | 
					                                </p>
 | 
				
			||||||
 | 
					                            </div>
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
                    </div>
 | 
					                    </div>
 | 
				
			||||||
                    </main>
 | 
					                    </main>
 | 
				
			||||||
                </body>
 | 
					                </body>
 | 
				
			||||||
@ -127,38 +150,6 @@ templ CreateGuestbookComment(title string, data CommonData, website models.Websi
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
templ GuestbookCommentView(c models.GuestbookComment) {
 | 
					 | 
				
			||||||
    <div>
 | 
					 | 
				
			||||||
        <strong>{ c.AuthorName }</strong>
 | 
					 | 
				
			||||||
        { c.Created.Format("01-02-2006 03:04PM") }
 | 
					 | 
				
			||||||
        <p>
 | 
					 | 
				
			||||||
            { c.CommentText }
 | 
					 | 
				
			||||||
        </p>
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
templ GuestbookDashboardCommentView(data CommonData, w models.Website, c models.GuestbookComment) {
 | 
					 | 
				
			||||||
    {{ commentUrl := fmt.Sprintf("%s/dashboard/guestbook/comments/%s", wUrl(w), shortIdToSlug(c.ShortId)) }}
 | 
					 | 
				
			||||||
    {{ hxHeaders := fmt.Sprintf("{\"X-CSRF-Token\": \"%s\"}", data.CSRFToken) }}
 | 
					 | 
				
			||||||
    <div>
 | 
					 | 
				
			||||||
        <strong>{ c.AuthorName }</strong>
 | 
					 | 
				
			||||||
        { c.Created.Format("01-02-2006 03:04PM") }
 | 
					 | 
				
			||||||
        if c.Deleted.IsZero() {
 | 
					 | 
				
			||||||
            <a href="#" hx-delete={ commentUrl } hx-target="closest div" hx-headers={ hxHeaders }>Delete</a>
 | 
					 | 
				
			||||||
            <a href="#" hx-put={ commentUrl } hx-target="closest div" hx-headers={ hxHeaders }>
 | 
					 | 
				
			||||||
                if !c.IsPublished {
 | 
					 | 
				
			||||||
                    Publish
 | 
					 | 
				
			||||||
                } else {
 | 
					 | 
				
			||||||
                    Hide
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            </a> 
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        <p>
 | 
					 | 
				
			||||||
            { c.CommentText }
 | 
					 | 
				
			||||||
        </p>
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
templ AllGuestbooksView(data CommonData, websites []models.Website) {
 | 
					templ AllGuestbooksView(data CommonData, websites []models.Website) {
 | 
				
			||||||
    @base("All Guestbooks", data) {
 | 
					    @base("All Guestbooks", data) {
 | 
				
			||||||
        <div>
 | 
					        <div>
 | 
				
			||||||
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -1,10 +1,28 @@
 | 
				
			|||||||
<input type=\"hidden\" name=\"csrf_token\" value=\"
 | 
					 | 
				
			||||||
\"> <label for=\"siteurl\">Site URL: </label> <input type=\"text\" name=\"siteurl\" id=\"siteurl\" required> <button type=\"submit\">Submit</button>
 | 
					 | 
				
			||||||
<div id=\"dashboard\">
 | 
					<div id=\"dashboard\">
 | 
				
			||||||
<div><h1>Comments on 
 | 
					<div><h1>Comments on 
 | 
				
			||||||
</h1>
 | 
					</h1><hr>
 | 
				
			||||||
<p>No comments yet!</p>
 | 
					<p>No comments yet!</p>
 | 
				
			||||||
</div></div>
 | 
					</div></div>
 | 
				
			||||||
 | 
					<div class=\"comment\"><div>
 | 
				
			||||||
 | 
					<button class=\"danger\" hx-delete=\"
 | 
				
			||||||
 | 
					\" hx-target=\"closest div.comment\" hx-headers=\"
 | 
				
			||||||
 | 
					\">Delete</button> <button class=\"outline\" hx-put=\"
 | 
				
			||||||
 | 
					\" hx-target=\"closest div.comment\" hx-headers=\"
 | 
				
			||||||
 | 
					\">
 | 
				
			||||||
 | 
					Publish
 | 
				
			||||||
 | 
					Hide
 | 
				
			||||||
 | 
					</button>
 | 
				
			||||||
 | 
					</div><div><strong>
 | 
				
			||||||
 | 
					</strong> 
 | 
				
			||||||
 | 
					| <a href=\"
 | 
				
			||||||
 | 
					\" target=\"_blank\">
 | 
				
			||||||
 | 
					</a> 
 | 
				
			||||||
 | 
					| <a href=\"
 | 
				
			||||||
 | 
					\" target=\"_blank\">
 | 
				
			||||||
 | 
					</a>
 | 
				
			||||||
 | 
					<p>
 | 
				
			||||||
 | 
					</p></div><p>
 | 
				
			||||||
 | 
					</p><hr></div>
 | 
				
			||||||
<div><label for=\"authorname\">Name: </label>
 | 
					<div><label for=\"authorname\">Name: </label>
 | 
				
			||||||
<label class=\"error\">
 | 
					<label class=\"error\">
 | 
				
			||||||
</label> 
 | 
					</label> 
 | 
				
			||||||
@ -18,17 +36,17 @@
 | 
				
			|||||||
<label class=\"error\">
 | 
					<label class=\"error\">
 | 
				
			||||||
</label> 
 | 
					</label> 
 | 
				
			||||||
<textarea name=\"content\" id=\"content\"></textarea></div><div><input type=\"submit\" value=\"Submit\"></div>
 | 
					<textarea name=\"content\" id=\"content\"></textarea></div><div><input type=\"submit\" value=\"Submit\"></div>
 | 
				
			||||||
<p>No comments yet!</p>
 | 
					 | 
				
			||||||
<div><strong>
 | 
					 | 
				
			||||||
</strong> 
 | 
					 | 
				
			||||||
<p>
 | 
					 | 
				
			||||||
</p></div>
 | 
					 | 
				
			||||||
<html><head><title>
 | 
					<html><head><title>
 | 
				
			||||||
</title></head><body><main><div><h1>Guestbook for 
 | 
					</title><link href=\"/static/css/classless.min.css\" rel=\"stylesheet\"></head><body><main><div><h1>Guestbook for 
 | 
				
			||||||
</h1><form action=\"
 | 
					</h1><form action=\"
 | 
				
			||||||
\" method=\"post\"><input type=\"hidden\" name=\"csrf_token\" value=\"
 | 
					\" method=\"post\"><input type=\"hidden\" name=\"csrf_token\" value=\"
 | 
				
			||||||
\">
 | 
					\">
 | 
				
			||||||
</form></div><div id=\"comments\">
 | 
					</form></div><div id=\"comments\">
 | 
				
			||||||
 | 
					<p>No comments yet!</p>
 | 
				
			||||||
 | 
					<div><h3>
 | 
				
			||||||
 | 
					</h3>
 | 
				
			||||||
 | 
					<p>
 | 
				
			||||||
 | 
					</p></div>
 | 
				
			||||||
</div></main></body></html>
 | 
					</div></main></body></html>
 | 
				
			||||||
<form hx-post=\"
 | 
					<form hx-post=\"
 | 
				
			||||||
\" hx-target=\"closest div\">
 | 
					\" hx-target=\"closest div\">
 | 
				
			||||||
@ -36,23 +54,6 @@
 | 
				
			|||||||
<form action=\"
 | 
					<form action=\"
 | 
				
			||||||
\" method=\"post\">
 | 
					\" method=\"post\">
 | 
				
			||||||
</form>
 | 
					</form>
 | 
				
			||||||
<div><strong>
 | 
					 | 
				
			||||||
</strong> 
 | 
					 | 
				
			||||||
<p>
 | 
					 | 
				
			||||||
</p></div>
 | 
					 | 
				
			||||||
<div><strong>
 | 
					 | 
				
			||||||
</strong> 
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
<a href=\"#\" hx-delete=\"
 | 
					 | 
				
			||||||
\" hx-target=\"closest div\" hx-headers=\"
 | 
					 | 
				
			||||||
\">Delete</a> <a href=\"#\" hx-put=\"
 | 
					 | 
				
			||||||
\" hx-target=\"closest div\" hx-headers=\"
 | 
					 | 
				
			||||||
\">
 | 
					 | 
				
			||||||
Publish
 | 
					 | 
				
			||||||
Hide
 | 
					 | 
				
			||||||
</a>
 | 
					 | 
				
			||||||
<p>
 | 
					 | 
				
			||||||
</p></div>
 | 
					 | 
				
			||||||
<div><h1>All Guestbooks</h1><p>This page exists only for testing the service.</p><ul>
 | 
					<div><h1>All Guestbooks</h1><p>This page exists only for testing the service.</p><ul>
 | 
				
			||||||
<li>
 | 
					<li>
 | 
				
			||||||
<a href=\"
 | 
					<a href=\"
 | 
				
			||||||
 | 
				
			|||||||
@ -16,7 +16,7 @@ templ wSidebar(website models.Website) {
 | 
				
			|||||||
            <h2>{ website.Name}</h2>
 | 
					            <h2>{ website.Name}</h2>
 | 
				
			||||||
            <ul>
 | 
					            <ul>
 | 
				
			||||||
                <li><a href={ templ.URL(dashUrl) }>Dashboard</a></li>
 | 
					                <li><a href={ templ.URL(dashUrl) }>Dashboard</a></li>
 | 
				
			||||||
                <li><a href={ templ.URL(website.SiteUrl) }>View Website</a></li>
 | 
					                <li><a href={ templ.URL(externalUrl(website.SiteUrl)) } target="_blank">View Website</a></li>
 | 
				
			||||||
            </ul>
 | 
					            </ul>
 | 
				
			||||||
            <h3>Guestbook</h3>
 | 
					            <h3>Guestbook</h3>
 | 
				
			||||||
            <ul>
 | 
					            <ul>
 | 
				
			||||||
 | 
				
			|||||||
@ -65,12 +65,12 @@ func wSidebar(website models.Website) templ.Component {
 | 
				
			|||||||
		if templ_7745c5c3_Err != nil {
 | 
							if templ_7745c5c3_Err != nil {
 | 
				
			||||||
			return templ_7745c5c3_Err
 | 
								return templ_7745c5c3_Err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		var templ_7745c5c3_Var4 templ.SafeURL = templ.URL(website.SiteUrl)
 | 
							var templ_7745c5c3_Var4 templ.SafeURL = templ.URL(externalUrl(website.SiteUrl))
 | 
				
			||||||
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var4)))
 | 
							_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var4)))
 | 
				
			||||||
		if templ_7745c5c3_Err != nil {
 | 
							if templ_7745c5c3_Err != nil {
 | 
				
			||||||
			return templ_7745c5c3_Err
 | 
								return templ_7745c5c3_Err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "\">View Website</a></li></ul><h3>Guestbook</h3><ul><li><a href=\"")
 | 
							templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "\" target=\"_blank\">View Website</a></li></ul><h3>Guestbook</h3><ul><li><a href=\"")
 | 
				
			||||||
		if templ_7745c5c3_Err != nil {
 | 
							if templ_7745c5c3_Err != nil {
 | 
				
			||||||
			return templ_7745c5c3_Err
 | 
								return templ_7745c5c3_Err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,7 @@
 | 
				
			|||||||
<nav><div><h2>
 | 
					<nav><div><h2>
 | 
				
			||||||
</h2><ul><li><a href=\"
 | 
					</h2><ul><li><a href=\"
 | 
				
			||||||
\">Dashboard</a></li><li><a href=\"
 | 
					\">Dashboard</a></li><li><a href=\"
 | 
				
			||||||
\">View Website</a></li></ul><h3>Guestbook</h3><ul><li><a href=\"
 | 
					\" target=\"_blank\">View Website</a></li></ul><h3>Guestbook</h3><ul><li><a href=\"
 | 
				
			||||||
\" target=\"_blank\">View Guestbook</a></li></ul><ul><li><a href=\"
 | 
					\" target=\"_blank\">View Guestbook</a></li></ul><ul><li><a href=\"
 | 
				
			||||||
\">Manage messages</a></li><li><a href=\"
 | 
					\">Manage messages</a></li><li><a href=\"
 | 
				
			||||||
\">Review message queue</a></li><li><a href=\"
 | 
					\">Review message queue</a></li><li><a href=\"
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user