package views import ( "fmt" "git.32bit.cafe/32bitcafe/guestbook/internal/forms" "git.32bit.cafe/32bitcafe/guestbook/internal/models" "time" ) func wUrl(w models.Website) string { return fmt.Sprintf("/websites/%s", shortIdToSlug(w.ShortId)) } templ wSidebar(website models.Website) { {{ dashUrl := wUrl(website) + "/dashboard" }} {{ gbUrl := wUrl(website) + "/guestbook" }} } templ websiteCreateForm(csrfToken string, form forms.WebsiteCreateForm) {
Website Settings
{{ err, exists := form.FieldErrors["ws_name"] }} if exists { } The display name for your website
{{ err, exists = form.FieldErrors["ws_url"] }} if exists { } The full URL where your website can be accessed
{{ err, exists = form.FieldErrors["ws_author"] }} if exists { } Your name or the website owner's name
} templ WebsiteList(title string, data CommonData, websites []models.Website) { @base(title, data) {

My Websites

Add Website
if len(websites) == 0 {

No Websites yet.

Create your first website to get started with webweav.ing tools.

Create Your First Website } else { }
} } templ WebsiteDashboard(title string, data CommonData, website models.Website) { @base(title, data) {
@wSidebar(website)
{{ gbUrl := fmt.Sprintf("https://%s/websites/%s/guestbook", data.RootUrl, shortIdToSlug(website.ShortId)) }}

Embed your Guestbook

There are two ways to add your guestbook to your website: using our JavaScript component (recommended) or with an iframe.

Method 1: JavaScript Component (Recommended)

Step 1: Download and upload the component

Download this JavaScript WebComponent and upload it to your website's JavaScript folder.

Step 2: Include in your HTML head

Add this script tag to your <head> section:
									
										<head>
										<script type="module" src="js/guestbook.js"></script>
										</head>
									
								

Step 3: Add the custom elements

Place these elements where you want your guestbook to appear:
									
										{ fmt.Sprintf(`
`, gbUrl, gbUrl) }
									
								

Method 2: iframe (Alternative)

Use this method if your web host doesn't allow CORS requests

If your hosting provider blocks cross-origin requests, you can embed the guestbook using an iframe instead:

iframe embedding code:
										
											{ fmt.Sprintf(``, gbUrl, gbUrl) }
										
									
} } templ websiteSettingsForm(data CommonData, website models.Website, form forms.WebsiteSettingsForm) { Website Settings
{{ err, exists := form.FieldErrors["ws_name"] }} if exists { } if form.SiteName != "" { } else { } The display name for your website
{{ err, exists = form.FieldErrors["ws_url"] }} if exists { } if form.SiteUrl != "" { } else { } The full URL where your website can be accessed
{{ err, exists = form.FieldErrors["ws_author"] }} if exists { } if form.AuthorName != "" { } else { } Your name or the website owner's name
} templ guestbookSettingsForm(data CommonData, website models.Website, gb models.Guestbook, form forms.WebsiteSettingsForm) { Guestbook Settings
Guestbook Visibility
if !website.Guestbook.CanComment() { {{ localtime := gb.Settings.ReenableCommenting.In(data.CurrentUser.Settings.LocalTimezone) }} } Control when users can post new comments
Enable Widgets
Allow embedding guestbook on external websites
} templ SettingsForm(data CommonData, website models.Website, form forms.WebsiteSettingsForm, msg string) { {{ putUrl := fmt.Sprintf("/websites/%s/settings", shortIdToSlug(website.ShortId)) }} {{ gb := website.Guestbook }}

{ msg }

@websiteSettingsForm(data, website, form)
@guestbookSettingsForm(data, website, gb, form)
} templ DeleteForm(data CommonData, website models.Website, form forms.WebsiteDeleteForm) { {{ putUrl := fmt.Sprintf("/websites/%s", shortIdToSlug(website.ShortId)) }}
Delete Website {{ err, exists := form.FieldErrors["delete"] }}
if exists { } Type { website.Name } exactly as shown to confirm deletion
} templ WebsiteDashboardSettings(data CommonData, website models.Website, form forms.WebsiteSettingsForm) { {{ title := fmt.Sprintf("%s - Settings", website.Name) }} @base(title, data) {
@wSidebar(website)
@SettingsForm(data, website, form, "")
@DeleteForm(data, website, forms.WebsiteDeleteForm{})
} } templ WebsiteDashboardComingSoon(title string, data CommonData, website models.Website) { @base(title, data) {
@wSidebar(website)

Coming Soon

} } templ WebsiteCreate(title string, data CommonData, form forms.WebsiteCreateForm) { @base(title, data) {
@websiteCreateForm(data.CSRFToken, form)
} }