templates

package
v0.29.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2026 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FragmentContent FragmentKey = "content"

	ImgProxyKey  contextKey = "imgproxy_key"
	ImgProxySalt contextKey = "imgproxy_salt"
)
View Source
const DefaultNotificationTimeout = 5 * time.Second

Variables

View Source
var (
	// ContentID points to the element containing the main content of the page.
	ContentID = ID("content")
	// ErrorID points to an element that can be used to display error messages to the user.
	ErrorID = ID("error")
	// ModalContainerID points to an element that holds a modal.
	ModalContainerID = ID("modals")
	// ModalID points to an element that can be used to render a modal.
	ModalID = ID("modal")
	// NotificationsID points to an element that can be used for displaying notifications to the user.
	NotificationsID = ID("notifications")
)

Functions

func About added in v0.21.0

func About() templ.Component

func AccountSettings

func AccountSettings(user *models.User) templ.Component

func AddCategory

func AddCategory(path, inputName string, category models.Category) templ.Component

AddCategory renders a new category item to the list of categories of a subscription.

func AddFeedSubscription

func AddFeedSubscription(request *models.AddFeedSubscriptionRequest) templ.Component

AddFeedSubscription is a page for adding a new subscription to a feed.

func AddGroupSubscription

func AddGroupSubscription(request *models.GroupSubscriptionRequest) templ.Component

AddGroupSubscription is a page for adding a new group subscription.

func AddSearchSubscription

func AddSearchSubscription(request *models.SearchSubscriptionRequest) templ.Component

AddSearchSubscription is a page for adding a new search subscription.

func CategoryManagement

func CategoryManagement(path, inputName string, suggested []models.Category, existing []models.Category) templ.Component

func Content

func Content(data *models.ViewComponent) templ.Component

Content renders the given template wrapped with appropriate header/footer navigation. Used for most user content pages.

func DeactivateAccountModal

func DeactivateAccountModal() templ.Component

func DisplaySettings

func DisplaySettings(user *models.User) templ.Component

func Dock

func Dock(pageURL string, attributes templ.Attributes) templ.Component

func Document

func Document(data []byte) templ.Component

Document renders the given raw HTML data as full-page prose content. Used primarily for hosted markdown documents (i.e., privacy policy, terms of service, etc.)

func EditEmailSubscription added in v0.26.0

func EditEmailSubscription(request *models.EditEmailSubscriptionRequest) templ.Component

func EditGroupSubscription

func EditGroupSubscription(request *models.GroupSubscriptionRequest) templ.Component

EditGroupSubscription is a page for editing a group subscription.

func EditSearchSubscription

func EditSearchSubscription(request *models.SearchSubscriptionRequest) templ.Component

EditSearchSubscription is a page for editing a search subscription.

func EditSubscription

func EditSubscription(request *models.EditSubscriptionRequest) templ.Component

func ErrorMessage added in v0.19.0

func ErrorMessage(msg *models.UserMessage) templ.Component

ErrorMessage displays a user-facing error message in a prominent way on a page, with navigation links for returning home or emailing support.

func ExportSubscriptions

func ExportSubscriptions() templ.Component

ExportSubscriptions renders a form for exporting all subscriptions as an OPML file.

func FavoritesGrid

func FavoritesGrid(subscriptions models.Subscriptions, articles models.Articles) templ.Component

FavoritesGrid renders subscription and article favorites in a grid layout.

func FilterControls

func FilterControls(path string, filters *models.ListFilters) templ.Component

func GetNotificationIDFromCtx

func GetNotificationIDFromCtx(ctx context.Context) string

func HelpPopover

func HelpPopover(id, anchor string) templ.Component

HelpPopover can be used to render a help icon, that when clicked, will open a popover displaying informational or help text.

func ImportResults

func ImportResults(results []*models.AddFeedSubscriptionResult) templ.Component

ImportResults is a partial template that displays the results of an import.

func ImportSubscriptions

func ImportSubscriptions() templ.Component

ImportPage is a page for importing subscriptions from an external source (e.g., an OPML file).

func IssueReportedConfirmation

func IssueReportedConfirmation(msg *models.UserMessage) templ.Component

IssueReportedConfirmation will show feedback to a user that the issue they reported has been recorded.

func Landing

func Landing() templ.Component

Landing is the landing page layout.

func ListArticles

func ListArticles(response *models.ListArticlesResponse) templ.Component

ListArticles renders the list of articles in a grid layout with filtering controls and an actions menu.

func ListCategoryFilters added in v0.27.0

func ListCategoryFilters(filters *models.CategoryFilters) templ.Component

func ListSubscriptions

func ListSubscriptions(response *models.ListSubscriptionsResponse) templ.Component

ListSubscriptions renders the list of subscriptions in a grid layout with filtering controls and an actions menu.

func Logo(classes ...string) templ.Component

func LogoSmall

func LogoSmall(classes ...string) templ.Component
func Modal(id string) templ.Component

Modal will render a modal with the given content.

func NewButton

func NewButton(options ...Option[element]) templ.Component

func NewDiv

func NewDiv(options ...Option[element]) templ.Component
func NewLink(options ...Option[element]) templ.Component
func NewMailtoLink(to string, options ...MailtoOption) templ.Component

NewMailtoLink creates a new html link with a `mailto:` href attribute.

func NewProxiedImage

func NewProxiedImage(img *types.ImageInfo, props string, options ...Option[element]) templ.Component

func NewUserHome

func NewUserHome() templ.Component

func NoSearchResults

func NoSearchResults() templ.Component

NoSearchResults renders an informational message for when no search results were returned.

func NotFound

func NotFound() templ.Component

NotFound renders a layout appropriate to use for a 404 response.

func Notification

func Notification(msg *models.UserMessage, timeout time.Duration) templ.Component

Notification renders a notification with the given user message.

func PaginateArticles

func PaginateArticles(response *models.ListArticlesResponse) templ.Component

PaginateArticles renders the given list of articles as cards with an optional element to trigger pagination to load more.

func PaginateSubscriptions

func PaginateSubscriptions(response *models.ListSubscriptionsResponse) templ.Component

PaginateSubscriptions renders the given list of subscriptions as cards with an optional element to trigger pagination to load more.

func RemoveSubscriptionModal

func RemoveSubscriptionModal(request *models.RemoveSubscriptionRequest) templ.Component

RemoveObjectModal renders a modal that will action an unsubscribe request when the user has confirmed.

func ReportObjectIssues

func ReportObjectIssues(objectType, id string, details *models.ReportObjectIssueRequest) templ.Component

func ReportPageIssue

func ReportPageIssue(details *models.ReportIssueRequest) templ.Component

ReportPageIssue renders a form for reporting issues with the app.

func SearchFilters

func SearchFilters(request *models.SearchRequest, attributes templ.Attributes) templ.Component

func SearchResults

func SearchResults(results *models.SearchResults) templ.Component

SearchResults renders the list of articles as cards with an optional element to trigger pagination for loading more.

func SearchResultsGrid

func SearchResultsGrid(results *models.SearchResults) templ.Component

SearchResultsGrid renders the given articles returned from the given search in a grid layout with an actions menu.

func SearchSubscriptionFilterSuggestions

func SearchSubscriptionFilterSuggestions(subscriptions models.Subscriptions) templ.Component

func SearchSuggestions

func SearchSuggestions(suggestions *models.SearchResults) templ.Component

SearchSuggestions will render suggestions for a given search.

func SettingsPage

func SettingsPage() templ.Component

func ShareObjectModal

func ShareObjectModal(id, title, link string) templ.Component

RemoveObjectModal renders a modal that will action an unsubscribe request when the user has confirmed.

func ShowSubscriptionEmail added in v0.26.0

func ShowSubscriptionEmail(email string) templ.Component

func ShowTailwindBreakpoints

func ShowTailwindBreakpoints() templ.Component
func SideBar(attributes templ.Attributes) templ.Component

func SimilarArticles

func SimilarArticles(articles models.Articles) templ.Component

SimilarArticles renders a page of articles that are the result of a search for similar articles to a given input set.

func ToggleFavorite

func ToggleFavorite(id string, objectType string, isFavorite bool) templ.Component

ToggleFavorite renders an updated favorite link based on the object's favorite status.

func UpdateHead added in v0.21.0

func UpdateHead(update templ.Component) templ.Component

func UpdateViewArticleFavorite

func UpdateViewArticleFavorite(id models.ItemID, isFavorite bool) templ.Component

UpdateViewArticleFavorite updates the favorite action when viewing an article.

func UpdatesToast

func UpdatesToast() templ.Component

UpdatesToast renders a toast notification to inform the user that updated content is available.

func UserAccountIssue

func UserAccountIssue() templ.Component

UserAccountIssuePage renders a full page with a message to the user indicating that their account has an issue that needs support to resolve. Usually, this will be displayed when a subscription plan payment has failed and requires manual intervention.

func UserAvatar

func UserAvatar(user *models.User, attributes templ.Attributes) templ.Component

func UserChooseSubscriptionPlan

func UserChooseSubscriptionPlan(user *models.User, planID string) templ.Component

UserChooseSubscriptionPlanPage renders a full page for the user to choose their subscription plan, with any previously selected option highlighted. This is displayed after a user account has been created (in Auth0) and redirects the user to Stripe for payment.

func Viewer added in v0.21.0

func Viewer() templ.Component

func ViewerResults added in v0.21.0

func ViewerResults(feed *feeds.Feed) templ.Component

Types

type Article added in v0.27.0

type Article struct {
	*models.Article
}

func NewArticleView added in v0.27.0

func NewArticleView(a *models.Article) *Article

NewArticleView wraps an Article object with additional methods for templates involving the article.

func (*Article) Card added in v0.27.0

func (a *Article) Card() templ.Component

Card renders an article as a card, for displaying in a list.

func (*Article) Content added in v0.27.0

func (a *Article) Content() templ.Component

ArticleContent renders the complete content of an article.

func (Article) FavoriteAttributes added in v0.27.0

func (a Article) FavoriteAttributes() templ.Attributes

func (*Article) MarkAttributes added in v0.27.0

func (a *Article) MarkAttributes() templ.Attributes

func (*Article) MenuActionMark added in v0.28.0

func (a *Article) MenuActionMark() templ.Component

MenuActionMark renders a menu action for marking an article.

func (*Article) ReportIssueAttributes added in v0.27.0

func (a *Article) ReportIssueAttributes() templ.Attributes

func (*Article) ShareAttributes added in v0.27.0

func (a *Article) ShareAttributes() templ.Attributes

func (*Article) SimilarArticlesAttributes added in v0.27.0

func (a *Article) SimilarArticlesAttributes() templ.Attributes

func (*Article) ViewAttributes added in v0.27.0

func (a *Article) ViewAttributes() templ.Attributes

ViewAttributes generates a templ.Attributes object containing htmx directives for viewing the article content.

func (*Article) ViewRemoteAttributes added in v0.27.0

func (a *Article) ViewRemoteAttributes() templ.Attributes

ViewRemoteAttributes generates a templ.Attributes object containing htmx directives for viewing the article remote content.

type Button

type Button struct {
	HTMLElement
}

type CategoryBadge added in v0.19.0

type CategoryBadge models.Category

CategoryBadge represents a Category as a badge in the UI.

func NewCategoryBadge added in v0.19.0

func NewCategoryBadge(category models.Category) CategoryBadge

NewCategoryBadge creates a new CategoryBadge from the given Category.

func (CategoryBadge) Render added in v0.19.0

func (c CategoryBadge) Render(classes ...string) templ.Component

Render will render the CategoryBadge.

type Component added in v0.19.0

type Component struct {
	Data templ.Component
}

func (*Component) Render added in v0.19.0

func (c *Component) Render(ctx context.Context, w io.Writer) error

type Div

type Div struct {
	HTMLElement
}

type FragmentKey

type FragmentKey string

type HTMLElement

type HTMLElement struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewHTMLElement

func NewHTMLElement() HTMLElement

func (*HTMLElement) AddClasses

func (e *HTMLElement) AddClasses(classes ...string)

func (*HTMLElement) GetClasses

func (e *HTMLElement) GetClasses() []string

func (*HTMLElement) GetID

func (e *HTMLElement) GetID() string

func (*HTMLElement) GetTarget

func (e *HTMLElement) GetTarget() string

func (*HTMLElement) HasAttribute

func (e *HTMLElement) HasAttribute(key string) bool

func (*HTMLElement) MergeAttributes

func (e *HTMLElement) MergeAttributes(attributes templ.Attributes)

func (*HTMLElement) SetAttribute

func (e *HTMLElement) SetAttribute(key string, value any)

func (*HTMLElement) SetID

func (e *HTMLElement) SetID(id string)

type Home

type Home struct {
	User           *models.User
	Subscriptions  models.Subscriptions
	LatestArticles models.Articles
	TopCategories  models.CategoryCounts
	TopArticles    models.Articles
	RareCategories models.CategoryCounts
}

func (*Home) Template

func (page *Home) Template() templ.Component

content renders the home page content.

type ID

type ID string

ID represents an id attribute in a HTML element.

func (ID) String

func (a ID) String() string

String returns the id attribute as a string.

func (ID) Target

func (a ID) Target() string

Target returns the id attribute as a target (i.e., for htmx requests). This is the base id string with a "#" prefix.

type Link struct {
	HTMLElement
}
type MailtoLink struct {
	// contains filtered or unexported fields
}

MailtoLink represents a link that will open the user's mail client, with optionall pre-filled details).

type MailtoOption

type MailtoOption func(*MailtoLink)

MailtoOption is a functional option to apply to a mailto: link object.

func WithLinkOptions

func WithLinkOptions(options ...Option[element]) MailtoOption

WithLinkOptions option passes the given options to the underlying link object. It can be used for further customisation of the link.

func WithMailtoBody

func WithMailtoBody(body string) MailtoOption

WithMailtoBody option adds body text to the mailto: link.

func WithMailtoSubject

func WithMailtoSubject(subject string) MailtoOption

WithMailtoSubject option adds a subject to the mailto: link.

type Option

type Option[T any] func(T)

Option is a generic type for functional options.

func WithAttribute

func WithAttribute(key string, value any) Option[element]

func WithAttributes

func WithAttributes(attributes templ.Attributes) Option[element]

func WithClasses

func WithClasses(classes ...string) Option[element]

func WithHXInclude

func WithHXInclude(value string) Option[element]

func WithHXMethod

func WithHXMethod(method, path string) Option[element]

func WithHXParams

func WithHXParams(params string) Option[element]

func WithHXPushURL

func WithHXPushURL(value bool) Option[element]

func WithHXReplaceURL

func WithHXReplaceURL(value bool) Option[element]

func WithHXSwap

func WithHXSwap(value string) Option[element]

func WithHXTarget

func WithHXTarget(value string) Option[element]

func WithHXTrigger

func WithHXTrigger(trigger string) Option[element]

func WithHXVals

func WithHXVals(vals map[string]any) Option[element]

func WithHXValsJS

func WithHXValsJS(val string) Option[element]

func WithID

func WithID(id string) Option[element]

type Page

type Page struct {
	Component   templ.Component
	Title       string
	Description string
	OGMetadata  *opengraph.Metadata
}

func NewPage added in v0.21.0

func NewPage(template templ.Component, options ...PageOption) *Page

func (*Page) FullTemplate added in v0.21.0

func (p *Page) FullTemplate() templ.Component

Page renders a full HTML page with the given body content and title.

func (*Page) PartialTemplate added in v0.21.0

func (p *Page) PartialTemplate() templ.Component

type PageOption added in v0.21.0

type PageOption func(*Page)

func WithOGMetadata added in v0.21.0

func WithOGMetadata(metadata *opengraph.Metadata) PageOption

func WithPageDescription added in v0.21.0

func WithPageDescription(desc string) PageOption

func WithPageTitle added in v0.21.0

func WithPageTitle(title string) PageOption

type Partial added in v0.21.0

type Partial struct {
	Component templ.Component
}

func NewPartial added in v0.21.0

func NewPartial(template templ.Component) *Partial

func (*Partial) PartialTemplate added in v0.21.0

func (p *Partial) PartialTemplate() templ.Component

type ProxiedImage

type ProxiedImage struct {
	HTMLElement
}

type SideBarComponent

type SideBarComponent struct {
	// contains filtered or unexported fields
}

type Subscription added in v0.27.0

type Subscription struct {
	*models.Subscription
}

func NewSubscriptionView added in v0.27.0

func NewSubscriptionView(s *models.Subscription) *Subscription

NewSubscriptionView wraps a Subscription object with additional methods for templates involving the subscription.

func (*Subscription) Card added in v0.27.0

func (s *Subscription) Card() templ.Component

Card renders a subscription in a card format, suitable for showing together with other subscriptions in a list/grid.

func (*Subscription) EditAttributes added in v0.27.0

func (s *Subscription) EditAttributes() templ.Attributes

EditAttributes generates a templ.Attributes object containing htmx directives for editing a subscription.

func (*Subscription) FavoriteAttributes added in v0.27.0

func (s *Subscription) FavoriteAttributes() templ.Attributes

FavoriteAttributes generates a templ.Attributes object containing htmx directives for favoriting a subscription.

func (*Subscription) MarkAttributes added in v0.27.0

func (s *Subscription) MarkAttributes() templ.Attributes

MarkAttributes generates a templ.Attributes object containing htmx directives for marking a subscription.

func (*Subscription) ReportIssueAttributes added in v0.27.0

func (s *Subscription) ReportIssueAttributes() templ.Attributes

ReportIssueAttributes generates a templ.Attributes object containing directives for reporting an issue with the subscription.

func (*Subscription) UnsubscribeAttributes added in v0.27.0

func (s *Subscription) UnsubscribeAttributes() templ.Attributes

UnsubscribeAttributes generates a templ.Attributes object containing htmx directives for unsubscribing from a subscription.

func (*Subscription) ViewArticlesAttributes added in v0.27.0

func (s *Subscription) ViewArticlesAttributes() templ.Attributes

ViewAttributes generates a templ.Attributes object containing htmx directives for viewing a subscription.

func (*Subscription) ViewOriginAttributes added in v0.27.0

func (s *Subscription) ViewOriginAttributes() templ.Attributes

ViewOriginAttributes generates a templ.Attributes object containing htmx directives for viewing the subscription's origin URL.

type Template

type Template struct {
	IsHTMX               bool
	IsHTMXHistoryRestore bool
}

func NewTemplate

func NewTemplate(req *http.Request) Template

NewTemplate creates a new Template object from an HTTP Request and templ component.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL