mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-12 13:46:51 +00:00
improve landing page
This commit is contained in:
parent
96710d033a
commit
56704a4062
5 changed files with 123 additions and 7 deletions
BIN
assets/img/logo.png
Normal file
BIN
assets/img/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 95 KiB |
|
|
@ -4,11 +4,20 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
|
|
||||||
|
"github.com/rjNemo/rentease/config"
|
||||||
"github.com/rjNemo/rentease/internal/views"
|
"github.com/rjNemo/rentease/internal/views"
|
||||||
)
|
)
|
||||||
|
|
||||||
func handleHomePage() echo.HandlerFunc {
|
func handleHomePage(hc *config.Host) echo.HandlerFunc {
|
||||||
return func(ctx echo.Context) error {
|
return func(ctx echo.Context) error {
|
||||||
return renderTempl(ctx, http.StatusOK, views.Index())
|
return renderTempl(ctx, http.StatusOK, views.Index(&views.HostViewModel{
|
||||||
|
Name: hc.Name,
|
||||||
|
Address: hc.Address,
|
||||||
|
ZipCode: hc.ZipCode,
|
||||||
|
City: hc.City,
|
||||||
|
PhoneNumber: hc.PhoneNumber,
|
||||||
|
Email: hc.Email,
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package server
|
package server
|
||||||
|
|
||||||
func (s Server) MountHandlers() {
|
func (s Server) MountHandlers() {
|
||||||
s.Router.GET("/", handleHomePage())
|
s.Router.GET("/", handleHomePage(s.hc))
|
||||||
s.Router.GET("/bookings", handleListBookingPage(s.bs, s.hc))
|
s.Router.GET("/bookings", handleListBookingPage(s.bs, s.hc))
|
||||||
s.Router.GET("/bookings/new", handleNewBookingPage())
|
s.Router.GET("/bookings/new", handleNewBookingPage())
|
||||||
s.Router.POST("/bookings/new", handleCreateBooking(s.bs))
|
s.Router.POST("/bookings/new", handleCreateBooking(s.bs))
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,27 @@
|
||||||
package views
|
package views
|
||||||
|
|
||||||
templ Index() {
|
type HostViewModel struct {
|
||||||
|
Name string
|
||||||
|
Address string
|
||||||
|
ZipCode string
|
||||||
|
City string
|
||||||
|
PhoneNumber string
|
||||||
|
Email string
|
||||||
|
}
|
||||||
|
|
||||||
|
templ Index(host *HostViewModel) {
|
||||||
@BaseLayout() {
|
@BaseLayout() {
|
||||||
<a role="button" href="/bookings/new">New Booking </a>
|
<article>
|
||||||
|
<header>{ host.Name }</header>
|
||||||
|
<div class="grid">
|
||||||
|
<img src="/static/img/logo.png" width="150px"/>
|
||||||
|
<ul>
|
||||||
|
<li>{ host.Address }</li>
|
||||||
|
<li>{ host.ZipCode }, { host.City }</li>
|
||||||
|
<li>{ host.PhoneNumber }</li>
|
||||||
|
<li>{ host.Email }</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,16 @@ import "context"
|
||||||
import "io"
|
import "io"
|
||||||
import "bytes"
|
import "bytes"
|
||||||
|
|
||||||
func Index() templ.Component {
|
type HostViewModel struct {
|
||||||
|
Name string
|
||||||
|
Address string
|
||||||
|
ZipCode string
|
||||||
|
City string
|
||||||
|
PhoneNumber string
|
||||||
|
Email string
|
||||||
|
}
|
||||||
|
|
||||||
|
func Index(host *HostViewModel) templ.Component {
|
||||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||||
if !templ_7745c5c3_IsBuffer {
|
if !templ_7745c5c3_IsBuffer {
|
||||||
|
|
@ -29,7 +38,85 @@ func Index() templ.Component {
|
||||||
templ_7745c5c3_Buffer = templ.GetBuffer()
|
templ_7745c5c3_Buffer = templ.GetBuffer()
|
||||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<a role=\"button\" href=\"/bookings/new\">New Booking </a>")
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<article><header>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var3 string
|
||||||
|
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(host.Name)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/index.templ`, Line: 14, Col: 22}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</header><div class=\"grid\"><img src=\"/static/img/logo.png\" width=\"150px\"><ul><li>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var4 string
|
||||||
|
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(host.Address)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/index.templ`, Line: 18, Col: 23}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</li><li>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var5 string
|
||||||
|
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(host.ZipCode)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/index.templ`, Line: 19, Col: 23}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(", ")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var6 string
|
||||||
|
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(host.City)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/index.templ`, Line: 19, Col: 38}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</li><li>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var7 string
|
||||||
|
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(host.PhoneNumber)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/index.templ`, Line: 20, Col: 27}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</li><li>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var8 string
|
||||||
|
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(host.Email)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/index.templ`, Line: 21, Col: 21}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</li></ul></div></article>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue