mirror of
https://github.com/cf-sonr/motr.git
synced 2026-01-11 18:58:54 +00:00
build: transition to a headless backend by removing UI rendering
This commit is contained in:
@@ -1,141 +0,0 @@
|
||||
package cookies
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
// CookieKey is a type alias for string.
|
||||
type CookieKey string
|
||||
|
||||
const (
|
||||
// SessionID is the key for the session ID cookie.
|
||||
SessionID CookieKey = "session.id"
|
||||
|
||||
// SessionChallenge is the key for the session challenge cookie.
|
||||
SessionChallenge CookieKey = "session.challenge"
|
||||
|
||||
// SessionRole is the key for the session role cookie.
|
||||
SessionRole CookieKey = "session.role"
|
||||
|
||||
// SessionTTL is the key for the session TTL cookie.
|
||||
SessionTTL CookieKey = "session.ttl"
|
||||
|
||||
// SessionUser is the key for the session user cookie.
|
||||
SessionUser CookieKey = "session.user"
|
||||
|
||||
// SessionUserHandle is the key for the session user handle cookie.
|
||||
SessionUserHandle CookieKey = "session.user.handle"
|
||||
|
||||
// SessionVaultAddress is the key for the session vault address cookie.
|
||||
SessionVaultAddress CookieKey = "session.vault.address"
|
||||
|
||||
// SessionVaultCID is the key for the session vault CID cookie.
|
||||
SessionVaultCID CookieKey = "session.vault.cid"
|
||||
|
||||
// SessionVaultSchema is the key for the session vault schema cookie.
|
||||
SessionVaultSchema CookieKey = "session.vault.schema"
|
||||
|
||||
// User is the key for the User cookie.
|
||||
User CookieKey = "user"
|
||||
|
||||
// UserHandle is the key for the User Handle cookie.
|
||||
UserHandle CookieKey = "user.handle"
|
||||
|
||||
// VaultAddress is the key for the Vault address cookie.
|
||||
VaultAddress CookieKey = "vault.address"
|
||||
|
||||
// VaultCID is the key for the Vault CID cookie.
|
||||
VaultCID CookieKey = "vault.cid"
|
||||
|
||||
// VaultSchema is the key for the Vault schema cookie.
|
||||
VaultSchema CookieKey = "vault.schema"
|
||||
)
|
||||
|
||||
// String returns the string representation of the CookieKey.
|
||||
func (c CookieKey) String() string {
|
||||
return string(c)
|
||||
}
|
||||
|
||||
// ╭───────────────────────────────────────────────────────────╮
|
||||
// │ Utility Methods │
|
||||
// ╰───────────────────────────────────────────────────────────╯
|
||||
|
||||
// Exists returns true if the request has the cookie Key.
|
||||
func (k CookieKey) Exists(c echo.Context) bool {
|
||||
ck, err := c.Cookie(k.String())
|
||||
return err == nil && ck != nil
|
||||
}
|
||||
|
||||
// MustEqual returns true if the request has the cookie Key.
|
||||
func (k CookieKey) MustEqual(c echo.Context, value string) bool {
|
||||
v, err := k.Read(c)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return v == value
|
||||
}
|
||||
|
||||
// Read returns the cookie value for the Key.
|
||||
func (k CookieKey) Read(c echo.Context) (string, error) {
|
||||
cookie, err := c.Cookie(k.String())
|
||||
if err != nil {
|
||||
// Cookie not found or other error
|
||||
return "", err
|
||||
}
|
||||
if cookie == nil || cookie.Value == "" {
|
||||
// Cookie is empty
|
||||
return "", http.ErrNoCookie
|
||||
}
|
||||
return cookie.Value, nil
|
||||
}
|
||||
|
||||
// ReadBytes returns the cookie value for the Key.
|
||||
func (k CookieKey) ReadBytes(c echo.Context) ([]byte, error) {
|
||||
cookie, err := c.Cookie(k.String())
|
||||
if err != nil {
|
||||
// Cookie not found or other error
|
||||
return nil, err
|
||||
}
|
||||
if cookie == nil || cookie.Value == "" {
|
||||
// Cookie is empty
|
||||
return nil, http.ErrNoCookie
|
||||
}
|
||||
return base64.RawURLEncoding.DecodeString(cookie.Value)
|
||||
}
|
||||
|
||||
// ReadUnsafe returns the cookie value for the Key.
|
||||
func (k CookieKey) ReadUnsafe(c echo.Context) string {
|
||||
ck, err := c.Cookie(k.String())
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return ck.Value
|
||||
}
|
||||
|
||||
// Write sets the cooie value for the Key.
|
||||
func (k CookieKey) Write(c echo.Context, value string) {
|
||||
cookie := &http.Cookie{
|
||||
Name: k.String(),
|
||||
Value: value,
|
||||
Expires: time.Now().Add(24 * time.Hour),
|
||||
HttpOnly: true,
|
||||
Path: "/",
|
||||
}
|
||||
c.SetCookie(cookie)
|
||||
}
|
||||
|
||||
// WriteBytes sets the cookie value for the Key.
|
||||
func (k CookieKey) WriteBytes(c echo.Context, value []byte) {
|
||||
cookie := &http.Cookie{
|
||||
Name: k.String(),
|
||||
Value: base64.RawURLEncoding.EncodeToString(value),
|
||||
Expires: time.Now().Add(24 * time.Hour),
|
||||
HttpOnly: true,
|
||||
Path: "/",
|
||||
}
|
||||
c.SetCookie(cookie)
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
//go:build js && wasm
|
||||
// +build js,wasm
|
||||
|
||||
package headers
|
||||
|
||||
import "github.com/labstack/echo/v4"
|
||||
|
||||
type HeaderKey string
|
||||
|
||||
const (
|
||||
Authorization HeaderKey = "Authorization"
|
||||
|
||||
// User Agent
|
||||
Architecture HeaderKey = "Sec-CH-UA-Arch"
|
||||
Bitness HeaderKey = "Sec-CH-UA-Bitness"
|
||||
FullVersionList HeaderKey = "Sec-CH-UA-Full-Version-List"
|
||||
Mobile HeaderKey = "Sec-CH-UA-Mobile"
|
||||
Model HeaderKey = "Sec-CH-UA-Model"
|
||||
Platform HeaderKey = "Sec-CH-UA-Platform"
|
||||
PlatformVersion HeaderKey = "Sec-CH-UA-Platform-Version"
|
||||
UserAgent HeaderKey = "Sec-CH-UA"
|
||||
|
||||
// Sonr Injected
|
||||
SonrAPIURL HeaderKey = "X-Sonr-API"
|
||||
SonrgRPCURL HeaderKey = "X-Sonr-GRPC"
|
||||
SonrRPCURL HeaderKey = "X-Sonr-RPC"
|
||||
SonrWSURL HeaderKey = "X-Sonr-WS"
|
||||
)
|
||||
|
||||
func (h HeaderKey) String() string {
|
||||
return string(h)
|
||||
}
|
||||
|
||||
// ╭───────────────────────────────────────────────────────────╮
|
||||
// │ Utility Methods │
|
||||
// ╰───────────────────────────────────────────────────────────╯
|
||||
|
||||
// MustEqual returns true if the request has the header Key.
|
||||
func (k HeaderKey) MustEqual(c echo.Context, value string) bool {
|
||||
return c.Response().Header().Get(k.String()) == value
|
||||
}
|
||||
|
||||
// Exists returns true if the request has the header Key.
|
||||
func (k HeaderKey) Exists(c echo.Context) bool {
|
||||
return c.Response().Header().Get(k.String()) != ""
|
||||
}
|
||||
|
||||
// Read returns the header value for the Key.
|
||||
func (k HeaderKey) Read(c echo.Context) string {
|
||||
return c.Response().Header().Get(k.String())
|
||||
}
|
||||
|
||||
// Write sets the header value for the Key.
|
||||
func (k HeaderKey) Write(c echo.Context, value string) {
|
||||
c.Response().Header().Set(k.String(), value)
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
package metadata
|
||||
|
||||
import "github.com/labstack/echo/v4"
|
||||
|
||||
func GetMetadata(c echo.Context) Metadata {
|
||||
return DefaultMetadata()
|
||||
}
|
||||
|
||||
func GetMetaComponent(c echo.Context) templ.Component {
|
||||
return MetaComponent(GetMetadata(c))
|
||||
}
|
||||
|
||||
func DefaultMetadata() Metadata {
|
||||
return Metadata{
|
||||
Title: "Motr",
|
||||
Author: "Sonr",
|
||||
Favicon: "https://cdn.sonr.id/favicon.png",
|
||||
Robots: "index, follow",
|
||||
Googlebot: "index, follow",
|
||||
Google: "nositelinkssearchbox",
|
||||
Description: "Sonr is a decentralized social network that allows you to create your own personalized digital identity.",
|
||||
Keywords: "Sonr, social network, decentralized, identity, decentralized social network, decentralized identity, self-sovereign identity, self-sovereign, self-sovereign social network, self-sovereign identity network, sso, sso network, sso identity, sso social network, digital identity, digital social network",
|
||||
CanonicalURL: "https://sonr.io",
|
||||
OGImage: "https://cdn.sonr.id/og.png",
|
||||
OGURL: "https://sonr.io",
|
||||
OGSiteName: "Sonr",
|
||||
TwitterSite: "@sonr_io",
|
||||
TwitterCreator: "@sonr_io",
|
||||
TwitterImage: "https://cdn.sonr.id/og.png",
|
||||
}
|
||||
}
|
||||
|
||||
type Metadata struct {
|
||||
Title string
|
||||
Author string
|
||||
Favicon string
|
||||
Robots string
|
||||
Googlebot string
|
||||
Google string
|
||||
Description string
|
||||
Keywords string
|
||||
CanonicalURL string
|
||||
OGImage string
|
||||
OGURL string
|
||||
OGSiteName string
|
||||
TwitterSite string
|
||||
TwitterCreator string
|
||||
TwitterImage string
|
||||
}
|
||||
|
||||
templ DefaultMetaComponent() {
|
||||
<title>Motr</title>
|
||||
<link rel="icon" type="image/png" href="https://cdn.sonr.id/favicon.png"/>
|
||||
<meta name="description" content="Sonr is a decentralized social network that allows you to create your own personalized digital identity."/>
|
||||
<meta name="keywords" content="Sonr, social network, decentralized, identity, decentralized social network, decentralized identity, self-sovereign identity, self-sovereign, self-sovereign social network, self-sovereign identity network, sso, sso network, sso identity, sso social network, digital identity, digital social network"/>
|
||||
<meta name="author" content="Sonr"/>
|
||||
<meta name="robots" content="index, follow"/>
|
||||
<meta name="googlebot" content="index, follow"/>
|
||||
<meta name="google" content="nositelinkssearchbox"/>
|
||||
<meta property="og:title" content="Motr"/>
|
||||
<meta property="og:description" content="Sonr is a decentralized social network that allows you to create your own personalized digital identity."/>
|
||||
<meta property="og:image" content="https://cdn.sonr.id/og.png"/>
|
||||
<meta property="og:url" content="https://sonr.io"/>
|
||||
<meta property="og:site_name" content="Sonr"/>
|
||||
<meta property="og:type" content="website"/>
|
||||
<meta property="og:locale" content="en_US"/>
|
||||
<meta name="twitter:card" content="summary_large_image"/>
|
||||
<meta name="twitter:site" content="@sonr_io"/>
|
||||
<meta name="twitter:creator" content="@sonr_io"/>
|
||||
<meta name="twitter:title" content="Motr"/>
|
||||
<meta name="twitter:description" content="Sonr is a decentralized social network that allows you to create your own personalized digital identity."/>
|
||||
<meta name="twitter:image" content="https://cdn.sonr.id/og.png"/>
|
||||
}
|
||||
|
||||
templ MetaComponent(m Metadata) {
|
||||
<title>{ m.Title }</title>
|
||||
<link rel="icon" type="image/png" href={ m.Favicon }/>
|
||||
<meta name="description" content={ m.Description }/>
|
||||
<meta name="keywords" content={ m.Keywords }/>
|
||||
<meta name="author" content={ m.Author }/>
|
||||
<meta name="robots" content={ m.Robots }/>
|
||||
<meta name="googlebot" content={ m.Googlebot }/>
|
||||
<meta name="google" content={ m.Google }/>
|
||||
<meta property="og:title" content={ m.Title }/>
|
||||
<meta property="og:description" content={ m.Description }/>
|
||||
<meta property="og:image" content={ m.OGImage }/>
|
||||
<meta property="og:url" content={ m.OGURL }/>
|
||||
<meta property="og:site_name" content={ m.OGSiteName }/>
|
||||
<meta property="og:type" content="website"/>
|
||||
<meta property="og:locale" content="en_US"/>
|
||||
<meta name="twitter:card" content="summary_large_image"/>
|
||||
<meta name="twitter:site" content={ m.TwitterSite }/>
|
||||
<meta name="twitter:creator" content={ m.TwitterCreator }/>
|
||||
<meta name="twitter:title" content={ m.Title }/>
|
||||
<meta name="twitter:description" content={ m.Description }/>
|
||||
<meta name="twitter:image" content={ m.TwitterImage }/>
|
||||
}
|
||||
@@ -1,351 +0,0 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.857
|
||||
package metadata
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
import "github.com/a-h/templ"
|
||||
import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
import "github.com/labstack/echo/v4"
|
||||
|
||||
func GetMetadata(c echo.Context) Metadata {
|
||||
return DefaultMetadata()
|
||||
}
|
||||
|
||||
func GetMetaComponent(c echo.Context) templ.Component {
|
||||
return MetaComponent(GetMetadata(c))
|
||||
}
|
||||
|
||||
func DefaultMetadata() Metadata {
|
||||
return Metadata{
|
||||
Title: "Motr",
|
||||
Author: "Sonr",
|
||||
Favicon: "https://cdn.sonr.id/favicon.png",
|
||||
Robots: "index, follow",
|
||||
Googlebot: "index, follow",
|
||||
Google: "nositelinkssearchbox",
|
||||
Description: "Sonr is a decentralized social network that allows you to create your own personalized digital identity.",
|
||||
Keywords: "Sonr, social network, decentralized, identity, decentralized social network, decentralized identity, self-sovereign identity, self-sovereign, self-sovereign social network, self-sovereign identity network, sso, sso network, sso identity, sso social network, digital identity, digital social network",
|
||||
CanonicalURL: "https://sonr.io",
|
||||
OGImage: "https://cdn.sonr.id/og.png",
|
||||
OGURL: "https://sonr.io",
|
||||
OGSiteName: "Sonr",
|
||||
TwitterSite: "@sonr_io",
|
||||
TwitterCreator: "@sonr_io",
|
||||
TwitterImage: "https://cdn.sonr.id/og.png",
|
||||
}
|
||||
}
|
||||
|
||||
type Metadata struct {
|
||||
Title string
|
||||
Author string
|
||||
Favicon string
|
||||
Robots string
|
||||
Googlebot string
|
||||
Google string
|
||||
Description string
|
||||
Keywords string
|
||||
CanonicalURL string
|
||||
OGImage string
|
||||
OGURL string
|
||||
OGSiteName string
|
||||
TwitterSite string
|
||||
TwitterCreator string
|
||||
TwitterImage string
|
||||
}
|
||||
|
||||
func DefaultMetaComponent() templ.Component {
|
||||
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
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var1 == nil {
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<title>Motr</title><link rel=\"icon\" type=\"image/png\" href=\"https://cdn.sonr.id/favicon.png\"><meta name=\"description\" content=\"Sonr is a decentralized social network that allows you to create your own personalized digital identity.\"><meta name=\"keywords\" content=\"Sonr, social network, decentralized, identity, decentralized social network, decentralized identity, self-sovereign identity, self-sovereign, self-sovereign social network, self-sovereign identity network, sso, sso network, sso identity, sso social network, digital identity, digital social network\"><meta name=\"author\" content=\"Sonr\"><meta name=\"robots\" content=\"index, follow\"><meta name=\"googlebot\" content=\"index, follow\"><meta name=\"google\" content=\"nositelinkssearchbox\"><meta property=\"og:title\" content=\"Motr\"><meta property=\"og:description\" content=\"Sonr is a decentralized social network that allows you to create your own personalized digital identity.\"><meta property=\"og:image\" content=\"https://cdn.sonr.id/og.png\"><meta property=\"og:url\" content=\"https://sonr.io\"><meta property=\"og:site_name\" content=\"Sonr\"><meta property=\"og:type\" content=\"website\"><meta property=\"og:locale\" content=\"en_US\"><meta name=\"twitter:card\" content=\"summary_large_image\"><meta name=\"twitter:site\" content=\"@sonr_io\"><meta name=\"twitter:creator\" content=\"@sonr_io\"><meta name=\"twitter:title\" content=\"Motr\"><meta name=\"twitter:description\" content=\"Sonr is a decentralized social network that allows you to create your own personalized digital identity.\"><meta name=\"twitter:image\" content=\"https://cdn.sonr.id/og.png\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func MetaComponent(m Metadata) templ.Component {
|
||||
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
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var2 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var2 == nil {
|
||||
templ_7745c5c3_Var2 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<title>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(m.Title)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 76, Col: 17}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "</title><link rel=\"icon\" type=\"image/png\" href=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(m.Favicon)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 77, Col: 51}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "\"><meta name=\"description\" content=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var5 string
|
||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(m.Description)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 78, Col: 49}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "\"><meta name=\"keywords\" content=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var6 string
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(m.Keywords)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 79, Col: 43}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "\"><meta name=\"author\" content=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var7 string
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(m.Author)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 80, Col: 39}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "\"><meta name=\"robots\" content=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var8 string
|
||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(m.Robots)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 81, Col: 39}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "\"><meta name=\"googlebot\" content=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var9 string
|
||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(m.Googlebot)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 82, Col: 45}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "\"><meta name=\"google\" content=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var10 string
|
||||
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(m.Google)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 83, Col: 39}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "\"><meta property=\"og:title\" content=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var11 string
|
||||
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(m.Title)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 84, Col: 44}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "\"><meta property=\"og:description\" content=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var12 string
|
||||
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(m.Description)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 85, Col: 56}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "\"><meta property=\"og:image\" content=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var13 string
|
||||
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(m.OGImage)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 86, Col: 46}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "\"><meta property=\"og:url\" content=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var14 string
|
||||
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(m.OGURL)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 87, Col: 42}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "\"><meta property=\"og:site_name\" content=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var15 string
|
||||
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(m.OGSiteName)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 88, Col: 53}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "\"><meta property=\"og:type\" content=\"website\"><meta property=\"og:locale\" content=\"en_US\"><meta name=\"twitter:card\" content=\"summary_large_image\"><meta name=\"twitter:site\" content=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var16 string
|
||||
templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(m.TwitterSite)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 92, Col: 50}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "\"><meta name=\"twitter:creator\" content=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var17 string
|
||||
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(m.TwitterCreator)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 93, Col: 56}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "\"><meta name=\"twitter:title\" content=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var18 string
|
||||
templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(m.Title)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 94, Col: 45}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "\"><meta name=\"twitter:description\" content=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var19 string
|
||||
templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(m.Description)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 95, Col: 57}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "\"><meta name=\"twitter:image\" content=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var20 string
|
||||
templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(m.TwitterImage)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/metadata/metadata.templ`, Line: 96, Col: 52}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
@@ -1,41 +0,0 @@
|
||||
package render
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/a-h/templ"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
type (
|
||||
EchoView func(c echo.Context) error
|
||||
EchoViewFunc func(c echo.Context, b templ.Component) error
|
||||
EchoPartialView func(c echo.Context) templ.Component
|
||||
)
|
||||
|
||||
func Page(cmp templ.Component) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
return Component(c, cmp)
|
||||
}
|
||||
}
|
||||
|
||||
func Component(c echo.Context, cmp templ.Component) error {
|
||||
// Create a buffer to store the rendered HTML
|
||||
buf := &bytes.Buffer{}
|
||||
// Render the component to the buffer
|
||||
err := cmp.Render(c.Request().Context(), buf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Set the content type
|
||||
c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML)
|
||||
|
||||
// Write the buffered content to the response
|
||||
_, err = c.Response().Write(buf.Bytes())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c.Response().WriteHeader(200)
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user