views

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: BSD-3-Clause Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package views holds the templ components and pages.

Index

Constants

View Source
const (
	// SettingsNotificationsPath saves the global notification preferences.
	SettingsNotificationsPath = SettingsPath + "/notifications"
	// PlacePrefsQuery is the query that opens the "Notification preferences"
	// dialog when a room or a conversation page loads: the links of the
	// settings page use it.
	PlacePrefsQuery = "prefs=1"
)

The paths of the notification preferences (SPEC §7.15).

View Source
const (
	PlacePrefsDialogID = "place-prefs-dialog"
	PlacePrefsFormID   = "place-prefs-form"
)

PlacePrefsDialogID is the id of the dialog "Notification preferences" of a room page and of a conversation page, and PlacePrefsFormID the id of its form, which the server patches.

View Source
const (
	// SettingsPath is the settings page of the logged-in user (SPEC §7.14).
	SettingsPath = "/me/settings"
	// SessionsPath is the old page of the sessions, which redirects to the
	// Sessions section of the settings page.
	SessionsPath = "/me/sessions"
	// SettingsSessionsPath is the Sessions section of the settings page.
	SettingsSessionsPath = SettingsPath + "#sessions"
	// SettingsProfilePath saves the display name.
	SettingsProfilePath = SettingsPath + "/profile"
	// SettingsAvatarPath uploads the avatar.
	SettingsAvatarPath = SettingsPath + "/avatar"
	// SettingsAvatarRemovePath removes the avatar.
	SettingsAvatarRemovePath = SettingsPath + "/avatar/remove"
	// SettingsPasswordPath changes the password.
	SettingsPasswordPath = SettingsPath + "/password"
	// SettingsAppearancePath saves the theme.
	SettingsAppearancePath = SettingsPath + "/appearance"
)

The paths of the settings page and of what it sends.

View Source
const (
	// SettingsSSHKeysPath adds an SSH key.
	SettingsSSHKeysPath = SettingsPath + "/ssh-keys"
	// SettingsSignInPath is the Sign-in section of the settings page.
	SettingsSignInPath = SettingsPath + "#signin"
)

The paths of the Sign-in section of the settings page.

View Source
const (
	// ThemeColorLight is the ground of the light palette.
	ThemeColorLight = "#fbf6ee"
	// ThemeColorDark is the ground of the dark palette.
	ThemeColorDark = "#1a1512"
)

The two colours of the theme-color elements: the ground of the light and of the dark palette (--c-ground in app.css; a test keeps them equal), which the browser draws behind its own bars on a phone.

View Source
const (
	// FaviconPlainPath is the favicon of a page with nothing waiting.
	FaviconPlainPath = "/static/favicon.svg"
	// FaviconDotPath is the favicon of a page with something waiting.
	FaviconDotPath = "/static/favicon-dot.svg"
)

The two favicons: the plain one, and the one with a dot, which says that something is waiting (SPEC §7.17). The stream swaps one for the other by patching the link element of the page; no script draws anything.

View Source
const CallAnswerQuery = "call"

CallAnswerQuery is the query a page of a conversation gets after its user answered a call: "call=video" or "call=audio". The page then opens the call, sending video or not as the value says (the choice is not stored by the server).

View Source
const (
	// FromPost says the post is shown on its own page.
	FromPost = "post"
)

The values of the form field "from" of the actions on a post: where the post is shown, so that the answer fits the page.

View Source
const FromRoomPrefix = "room-"

FromRoomPrefix starts the value of the form field "from" of a "Message" button in the member list of a room: FromRoomPrefix + the room's ID. It says where the message of a failure is shown.

View Source
const LoginCodePath = "/login/code"

LoginCodePath is the page and the form of the second step of the login.

View Source
const LoginCodeRestartPath = "/login/code/restart"

LoginCodeRestartPath is the "Start again" link of the second step.

View Source
const MaxVisualDepth = 6

MaxVisualDepth is the deepest level a comment is indented to. A comment deeper than that stays at this level and says whom it replies to (SPEC §7.3).

View Source
const MeStreamPath = "/me/stream"

MeStreamPath is the path of the stream of the pages that have no stream of their own: it keeps the counts and the room list of the sidebar live (SPEC D31).

View Source
const MessagesPath = "/messages"

MessagesPath is the path of the page that lists the conversations of the user; a POST to it starts a conversation.

View Source
const MessagesStreamPath = MeStreamPath + "?messages=1"

MessagesStreamPath is the path of the stream of the Messages page: the stream of the pages that have none (MeStreamPath), told to keep the list of conversations live too.

View Source
const NotificationsPath = "/notifications"

NotificationsPath is the path of the notifications page.

View Source
const NotificationsReadPath = "/notifications/read"

NotificationsReadPath is the path that marks all notifications as read.

View Source
const SettingsAppearanceMenuPath = SettingsAppearancePath + "?from=menu"

SettingsAppearanceMenuPath is the route that saves the theme, as the form of the user menu posts to it: the query from=menu makes the answer patch the menu and not the Appearance section, which is not on most pages.

View Source
const SettingsSSHCodePath = SettingsPath + "/ssh-code"

SettingsSSHCodePath turns the SSH code at login on or off.

Variables

This section is empty.

Functions

func AdminRoom

func AdminRoom(row AdminRoomRow) templ.Component

AdminRoom is the row of one room: its name, visibility, member count, creator and creation date, and the forms that rename it, delete it and show its members. The id of the row is room-<id>, so that other pages link to it. The server sends it alone as a Datastar patch after an action.

func AdminRoomPath

func AdminRoomPath(id uint64) string

AdminRoomPath returns the path of the row of a room on the admin rooms page, /admin/rooms/<id>. Its actions are AdminRoomPath + "/rename", "/delete", "/members" and "/members/<user>/remove".

func AdminRoomsPage

func AdminRoomsPage(d AdminRoomsData) templ.Component

AdminRoomsPage is the page of every room, with the forms that rename and delete a room and the list of its members. Only admins get it.

func AdminTabs

func AdminTabs(current string) templ.Component

AdminTabs is the segmented bar under the title that the admin pages share: Users, Rooms and Audit log. current is the tab of the page that is shown: "users", "rooms" or "audit".

func AdminUsersPage

func AdminUsersPage(d AdminUsersData) templ.Component

AdminUsersPage is the page of the users and of the invitation form. Only admins get it.

func AppearanceSection added in v1.2.0

func AppearanceSection(d AppearanceData) templ.Component

AppearanceSection is the Appearance section: the theme. The server sends it alone as a Datastar patch after a submit.

func Attachments

func Attachments(atts []app.AttachmentView) templ.Component

Attachments shows the files of a post or comment under its body: the images inline, scaled to the width of the column (the width and height attributes hold the size of the file, so that the page does not jump when it loads), each a link to the full file; then the other files as a list of links with their sizes.

func AuditEntityLabel added in v1.2.0

func AuditEntityLabel(entity string) string

AuditEntityLabel is the text of an entity type in the filter of the audit log: the events about accounts are "Accounts", every other type is shown as it is stored.

func AuditFilters

func AuditFilters(d AuditData) templ.Component

AuditFilters is the form of the filters. It is a plain GET form, so the result can be shared by its URL; with Datastar it fetches the events and patches the table in place.

func AuditPage

func AuditPage(d AuditData) templ.Component

AuditPage is the page of the audit log: the filter form and the events. Only admins get it.

func AuditPanel

func AuditPanel(d AuditData) templ.Component

AuditPanel is the message about the filters, the table of events and the links to the newer and older page. The server sends it alone as a Datastar patch when the filters or the page change.

func Avatar added in v1.2.0

func Avatar(id uint64, displayName, url string) templ.Component

Avatar draws the small avatar of a user next to their name: their picture when url is not empty, else their initials on a colour picked from their ID. The name is next to it in the page, so the picture has no text of its own.

func AvatarColourIndex added in v1.2.0

func AvatarColourIndex(id uint64) int

AvatarColourIndex is the number of the colour, 0 to 7, of the initials of the user with the ID: the same user always gets the same colour.

func AvatarSized added in v1.2.0

func AvatarSized(id uint64, displayName, url, size string) templ.Component

AvatarSized is Avatar in one of the sizes "sm" (24 px), "md" (36 px), "xl" (42 px, the author of a post) and "lg" (96 px).

func BoardAddColumn

func BoardAddColumn(d BoardData) templ.Component

BoardAddColumn is the form that adds a column at the right end of the board, for a member; empty for anyone else. It is not part of the columns, so that a live update does not clear the name that is being typed. A live update replaces it when the person joins or leaves the room.

func BoardColumns

func BoardColumns(d BoardData) templ.Component

BoardColumns are the columns of the board side by side, with their cards. The server sends it alone as a Datastar patch after every action on the board and, to every open board page, when the board changes. It holds no form that the person fills in over time (the card form has its own panel and the form that adds a column sits next to it), so that a live update never takes a typed text away.

func BoardColumnsPath

func BoardColumnsPath(roomID uint64) string

BoardColumnsPath returns the path that adds a column to the board of a room and, with GET, shows the columns alone (what the board asks for when a drag ends without a drop).

func BoardEditor

func BoardEditor(d BoardData) templ.Component

BoardEditor is the panel of the board where the form of a card opens, empty until then. It is outside the columns, so that a live update of the columns never closes the form or clears what is typed in it. The server sends it alone as a Datastar patch to open the form and to show its problems.

func BoardHeader

func BoardHeader(d BoardData) templ.Component

BoardHeader is the header of the board page: the name of the room, its visibility and the navigation back to the posts. A live update replaces it when the room is renamed.

func BoardMessage

func BoardMessage(message string) templ.Component

BoardMessage is the problem of the last action on the board, at the top of it. The server sends it alone as a Datastar patch when an action fails.

func BoardNote

func BoardNote(d BoardData) templ.Component

BoardNote tells a person who has not joined the room that the board is theirs to read only. It is empty for a member. A live update replaces it when the person joins or leaves.

func BoardPage

func BoardPage(d BoardData) templ.Component

BoardPage is the page of the board of a room, in the layout with the sidebar: the header with the way back to the posts, the note for a person who has not joined, the form of the card being edited, the columns with their cards, the form that adds a column, and the script of the drag and drop. The hidden form and link next to the columns are what that script uses to talk to the server through Datastar.

func BoardPath

func BoardPath(roomID uint64) string

BoardPath returns the path of the board of a room, /rooms/<id>/board. Its actions are BoardPath + "/columns" and "/tasks/<id>"; its stream is BoardPath + "/stream".

func BoardStreamPath

func BoardStreamPath(roomID uint64, version string) string

BoardStreamPath returns the path of the live stream of the board. version is the BoardVersion of the board the page showed; the stream sends the columns at once when the board changed since.

func BoardVersion

func BoardVersion(b app.BoardView) string

BoardVersion is a short text that changes when anything the board shows changes: the columns and the cards with their places, titles, assignees and due dates, and whether the viewer may change the board. The page tells it to its stream, which finds out what happened while the page was loading.

func CallAnsweredPath added in v1.2.0

func CallAnsweredPath(conversationID uint64, video bool) string

CallAnsweredPath returns the page a user is sent to when they answer a call: the conversation, which opens the call with what they chose to send.

func CallArea added in v1.2.0

func CallArea(d CallData) templ.Component

CallArea is the place of the call on the page of a direct conversation: empty while there is no call, "Calling Bob…" with Cancel while the user's call rings, and the call view while it is active. The stream patches it when the call starts, is answered and ends; the script call.js watches it, takes part in the call from the tab that started or answered it and keeps what it changed in the view (the marks, the buttons, the duration) when the server patches the area again.

func CallButtons added in v1.2.0

func CallButtons(d CallData) templ.Component

CallButtons are the buttons that start a call in the header actions of a direct conversation: Video call and Audio call. They give way to the state of the call while one rings or is active, and are not there at all when calls are off or the conversation is a group. The element is always there for a direct conversation, empty while a call is in progress, so that the stream can patch it. Each button is a form that works without JavaScript.

func CallEntry added in v1.2.0

func CallEntry(d MessageData) templ.Component

CallEntry is the entry that a finished call leaves in a direct conversation (SPEC §7.18): one quiet line in the middle of the list, with the icon of a video or an audio call, the text the user reads ("Video call · 12 min", "Declined video call", "Missed video call") and the time. The call the user missed is in the colour of a warning. It has nothing to reply to, edit or react to.

func CallKindText added in v1.2.0

func CallKindText(video bool) string

CallKindText is "Video call" or "Audio call".

func CallPath added in v1.2.0

func CallPath(conversationID uint64, action string) string

CallPath returns the path of the call of a direct conversation, or of one of its actions: CallPath(id, "") is the path that starts a call, and the actions are "answer", "decline", "cancel" and "hangup" (SPEC §7.18).

func CallRingingDialog added in v1.2.0

func CallRingingDialog(inv CallInviteData) templ.Component

CallRingingDialog is the dialog of a call that rings for the user: the avatar and name of the caller, whether it is a video or an audio call, and Answer with video, Answer with audio and Decline. Answering is a plain form post that takes the page to the conversation, which opens the call (the browser then asks for the camera and the microphone there); Decline is a Datastar form that removes the dialog. The data attributes are what notify.js reads: data-ring is present when the ringtone plays (SPEC §7.15), data-browser when the browser notification is wanted, data-notice is its text and data-url the page it opens.

func CallRingingSlot added in v1.2.0

func CallRingingSlot(inv *CallInviteData) templ.Component

CallRingingSlot is the slot of the ringing dialog, in the shell of every page of a logged-in user (id "call-ringing"). It is empty while nothing rings for the user, and holds the dialog while a call does. The user's stream patches it when a call starts to ring and when it stops (SPEC §7.18); a page made while a call rings has the dialog in it already. The script notify.js opens the dialog, plays the ringtone and shows the browser notification.

func CallSocketURL added in v1.2.0

func CallSocketURL(conversationID uint64) string

CallSocketURL returns the path of the signalling socket of the call of a conversation, /calls/<id>/ws.

func CommentPath

func CommentPath(rootID, id uint64) string

CommentPath returns the path that shows a comment in its thread, on the page of the top-level post: /posts/<root>#post-<id>.

func CommentsSection

func CommentsSection(d PostPageData) templ.Component

CommentsSection is the comments of the thread, or the note that there are none. A live update replaces it alone when the first comment arrives.

func ConversationActions added in v1.2.0

func ConversationActions(d PlacePrefsData, call CallData) templ.Component

ConversationActions is the row of actions at the right of the header of a conversation: the call buttons of a direct conversation (SPEC §7.18) and the "more" menu with the notification preferences. It is not part of the header, which the server patches when the group changes, so that a patch never takes the menu or the buttons away.

func ConversationBeforePath

func ConversationBeforePath(convID, before uint64) string

ConversationBeforePath returns the path of the page of the conversation that shows the messages older than before, for a browser without JavaScript.

func ConversationHeader

func ConversationHeader(d ConversationData) templ.Component

ConversationHeader is the header of a conversation: its title, who is in it and the message of the last action on the conversation. The server sends it alone as a Datastar patch when the conversation is renamed or its members change.

func ConversationList

func ConversationList(items []app.ConversationSummary, viewerID uint64) templ.Component

ConversationList is the conversations of the user, most recent first: the title, who wrote the last message and the start of it, when, and the unread mark. The server sends it alone as a Datastar patch when a conversation changes.

func ConversationMembers

func ConversationMembers(d MembersPanelData) templ.Component

ConversationMembers is the panel of a group: its members, the form that adds people by username, the rename form and the Leave button. The server sends it alone as a Datastar patch after an action on the group and when the group changes.

func ConversationMessagePath added in v1.2.0

func ConversationMessagePath(convID, msgID uint64) string

ConversationMessagePath returns the path of the page of the conversation that shows the message msgID and scrolls to it: the newest messages when it is among them, else the page that ends with it.

func ConversationOlderPath

func ConversationOlderPath(convID, before uint64) string

ConversationOlderPath returns the path that loads the messages older than before, as a Datastar patch.

func ConversationPage

func ConversationPage(d ConversationData) templ.Component

ConversationPage is the page of a conversation: its header, the messages oldest first with the newest at the bottom, the composer and, for a group, the members panel.

func ConversationPath

func ConversationPath(id uint64) string

ConversationPath returns the path of the page of a conversation, /messages/<id>. Its actions are ConversationPath + "/members", "/rename" and "/leave"; "/stream" is its live stream and "/older" loads older messages.

func ConversationPrefsPath added in v1.2.0

func ConversationPrefsPath(convID uint64) string

ConversationPrefsPath is where the dialog of a conversation posts to.

func ConversationReplyPath

func ConversationReplyPath(convID, msgID uint64) string

ConversationReplyPath returns the path of the page of the conversation with the composer set to reply to the message, for a browser without JavaScript.

func ConversationStreamPath

func ConversationStreamPath(convID, newest, before uint64) string

ConversationStreamPath returns the path of the live stream of the conversation. newest is the ID of the newest message the page showed (0 for none); before is the before of the page (0 for the newest messages), whose messages a stream does not keep up to date.

func CountLabel added in v1.2.0

func CountLabel(n int) string

CountLabel is the label of a count of unread things as the title shows it: empty for none, the number, or "99+".

func ErrorPage

func ErrorPage(status int, message string) templ.Component

ErrorPage is the page shown for an HTTP error (404, 500 and the like): the status code and a short message, in a card under the logo. The message is plain text, never the text of an error.

func Favicon added in v1.2.0

func Favicon(unread int) templ.Component

Favicon is the link element of the favicon: the plain one, or the one with a dot while unread is above 0. It has an id so that the stream can patch it when the count changes.

func FaviconPath added in v1.2.0

func FaviconPath(unread int) string

FaviconPath is the favicon for a page that has unread things waiting.

func Feed

func Feed(d FeedData) templ.Component

Feed is the feed of a room: the posts of the page, the empty message (shown by the stylesheet only while there is no post), and the end of the feed.

func FeedMore

func FeedMore(d FeedData) templ.Component

FeedMore is the end of the feed. When older posts exist it is the sentinel: when it scrolls into view, Datastar loads the next page (the server answers with the posts to append and a new sentinel); without JavaScript the link "Older posts" opens the older page. With no older posts it is empty.

func FeedNewLine added in v1.2.0

func FeedNewLine() templ.Component

FeedNewLine is the line "New since your last visit" (SPEC §7.17). The feed is newest first, so the line sits below the oldest post the person has not seen: what is above it is new.

func FeedPath

func FeedPath(roomID, before uint64) string

FeedPath returns the path that loads the posts older than before, in the feed of the room, as a Datastar patch.

func FeedPosts

func FeedPosts(d FeedData) templ.Component

FeedPosts is the posts of a page of the feed, newest first, one after the other.

func FilePath

func FilePath(a app.AttachmentView) string

FilePath returns the path that downloads an attachment, /files/<id>/<name>. The name only gives the download a good name; the ID decides.

func FormPost

func FormPost(path string) string

FormPost returns the Datastar action that sends the form it is on to path with a POST, as an ordinary form (not as signals). Put it on the form as data-on:submit. The path is escaped, so that it can sit inside the quotes of the expression.

func FormPostConfirm

func FormPostConfirm(path, message string) string

FormPostConfirm is FormPost behind a confirm dialog: the form is sent only when the person agrees. The message is escaped like the path.

func GroupMentionConfirm added in v1.2.0

func GroupMentionConfirm(d GroupMentionConfirmData) templ.Component

GroupMentionConfirm is the question that stands above the buttons of an editor or of the composer when the body holds a group mention that would notify more than 5 people (SPEC §7.15): "This will notify 14 people. Send anyway?", with Send, which sends the form again with the flag confirm_group_mention=1 (the Send button of the page works through Datastar, and without JavaScript the button posts to the same address), and Cancel, which closes the question. With a Count of 0 it is an empty place that the server patches the question into.

func GroupMentionConfirmID added in v1.2.0

func GroupMentionConfirmID(id string) string

GroupMentionConfirmID is the id of the place of the question of the editor or composer id.

func GroupMentionSendPath added in v1.2.0

func GroupMentionSendPath(action string) string

GroupMentionSendPath is the address the form with the action posts to when the person confirmed the group mention.

func Header(d SidebarData) templ.Component

Header is the content of the header of the pages of a logged-in user: the menu button that opens the drawer of rooms on a phone (hidden above 40 rem; its dot, and the word "unread" in its name, show while a room has unread posts or mentions, by CSS from the list of rooms itself, so that the patch of a single room keeps them right), the logo (a link to the home page), the search box (left out when HideSearch is set), the bell with the unread notifications, Messages with the conversations that have unread messages (both links, with the counts that the streams patch by their ids) and the user menu.

func Home

func Home(sb SidebarData) templ.Component

Home is the home page of a logged-in user: it greets the user by display name.

func IconAttach added in v1.2.0

func IconAttach() templ.Component

IconAttach is a paperclip: attach a file.

func IconBell added in v1.2.0

func IconBell() templ.Component

IconBell is a bell: notifications.

func IconBoard added in v1.2.0

func IconBoard() templ.Component

IconBoard is three columns of different heights: the board of a room.

func IconCalendar added in v1.2.0

func IconCalendar() templ.Component

IconCalendar is a calendar page: a due date.

func IconCheck added in v1.2.0

func IconCheck() templ.Component

IconCheck is a check mark.

func IconClose added in v1.2.0

func IconClose() templ.Component

IconClose is a cross: close or remove.

func IconFeed added in v1.2.0

func IconFeed() templ.Component

IconFeed is two stacked cards: the feed of a room.

func IconFile added in v1.2.0

func IconFile() templ.Component

IconFile is a page with a folded corner: a file.

func IconHangUp added in v1.2.0

func IconHangUp() templ.Component

IconHangUp is a handset turned down: hang up and decline.

func IconHeart added in v1.2.0

func IconHeart() templ.Component

IconHeart is a heart.

func IconLock added in v1.2.0

func IconLock() templ.Component

IconLock is a padlock: a private room.

func IconLogout added in v1.2.0

func IconLogout() templ.Component

IconLogout is an arrow leaving a frame: log out.

func IconMenu added in v1.2.0

func IconMenu() templ.Component

IconMenu is three bars: the menu of a phone.

func IconMessage added in v1.2.0

func IconMessage() templ.Component

IconMessage is a speech bubble: private messages.

func IconMic added in v1.2.0

func IconMic() templ.Component

IconMic is a microphone: the microphone that is on.

func IconMicOff added in v1.2.0

func IconMicOff() templ.Component

IconMicOff is a microphone crossed out: the microphone that is off.

func IconMonitor added in v1.2.0

func IconMonitor() templ.Component

IconMonitor is a screen: the theme of the system.

func IconMoon added in v1.2.0

func IconMoon() templ.Component

IconMoon is a crescent moon: the dark theme.

func IconMore added in v1.2.0

func IconMore() templ.Component

IconMore is three dots: more actions, filled.

func IconMuted added in v1.2.0

func IconMuted() templ.Component

IconMuted is a bell crossed out: a muted room or conversation.

func IconPaw added in v1.2.0

func IconPaw() templ.Component

IconPaw is a paw print: the mark of Clowder, filled.

func IconPhone added in v1.2.0

func IconPhone() templ.Component

IconPhone is a telephone handset: an audio call.

func IconPlus added in v1.2.0

func IconPlus() templ.Component

IconPlus is a plus sign.

func IconScreen added in v1.2.0

func IconScreen() templ.Component

IconScreen is a monitor with an arrow: share the screen.

func IconSearch added in v1.2.0

func IconSearch() templ.Component

IconSearch is a magnifying glass.

func IconSettings added in v1.2.0

func IconSettings() templ.Component

IconSettings is two sliders: settings.

func IconSliders added in v1.2.0

func IconSliders() templ.Component

IconSliders is two sliders: the choice of the devices.

func IconSun added in v1.2.0

func IconSun() templ.Component

IconSun is a sun: the light theme.

func IconTag added in v1.2.0

func IconTag() templ.Component

IconTag is a label with a hole: a tag.

func IconTask added in v1.2.0

func IconTask() templ.Component

IconTask is an empty box: a task that is open.

func IconTaskDone added in v1.2.0

func IconTaskDone() templ.Component

IconTaskDone is a box with a check mark: a task that is done.

func IconVideo added in v1.2.0

func IconVideo() templ.Component

IconVideo is a camera: a video call, and the camera that is on.

func IconVideoOff added in v1.2.0

func IconVideoOff() templ.Component

IconVideoOff is a camera crossed out: the camera that is off.

func Initials added in v1.2.0

func Initials(displayName string) string

Initials returns the letters shown for a user without an avatar: the first letter of the first word of the display name and of the last one, in upper case; the first letter alone for a name of one word; "?" for a name with no letters.

func InviteSection

func InviteSection(d InviteData) templ.Component

InviteSection is the form that makes an invitation and the box that shows its link. The server sends it alone as a Datastar patch with the link or the problems.

func Layout

func Layout(title string, unread int, sb *SidebarData) templ.Component

Layout is the HTML page every page is rendered in: the head with the title (which starts with "(n) " while unread is above 0, the number of unread notifications and conversations of the person, SPEC §7.17) and the favicon (with a dot while unread is above 0), the stylesheets (app.css, and code.css for the code blocks), the Datastar client and code.js (the toolbar of the code blocks) and the shell of the page (SPEC D57). With sb, the page of a logged-in person, the shell is the header (the logo, the search box, the bell, Messages and the user menu), the aside of the sidebar with the rooms and the main element for the children. Without it, the pages of people who are not logged in and the error pages, the shell is a main element with the logo above the card of the children. The html element carries data-theme when the context has a theme (WithTheme).

func LoginCodeForm added in v1.2.0

func LoginCodeForm(d LoginCodeData) templ.Component

LoginCodeForm is the form of the SSH code. The server sends it alone as a Datastar patch to show a wrong code; it replaces the element with the same id.

func LoginCodePage added in v1.2.0

func LoginCodePage(d LoginCodeData) templ.Component

LoginCodePage is the page of the second form of the login, which asks for the SSH code after the right password.

func LoginForm

func LoginForm(d LoginData) templ.Component

LoginForm is the login form. The server sends it alone as a Datastar patch to show the problems of a failed login; it replaces the element with the same id.

func LoginPage

func LoginPage(d LoginData) templ.Component

LoginPage is the page of the login form.

func Logo() templ.Component

Logo is the logo of Clowder: the cat head and the word "clowder" in the heading font, one link to the home page. The word is text, so the link has its name.

func LogoMark added in v1.2.0

func LogoMark() templ.Component

LogoMark is the cat head of Clowder, the mark of the logo and of the favicon: a head with two ears, two eyes and a nose. It is decorative (aria-hidden). app.css colours the head with the accent and the eyes and the nose with --logo-eye, the colour of the ground it sits on.

func MembersPanel

func MembersPanel(d RoomData) templ.Component

MembersPanel is the members of a room, each with a "Message" button (except the viewer) that starts a direct conversation, with the "Add member" form, for a member, and the Remove buttons, for an admin. The server sends it alone as a Datastar patch after an action on the members.

func MessageActionPath

func MessageActionPath(msgID uint64, action string) string

MessageActionPath returns the path of an action on a message, /messages/m/<id>/<action> with the action "edit" (the form, and the POST that saves it), "view", "delete", "react" or "reply".

func MessageAttachments

func MessageAttachments(atts []app.AttachmentView) templ.Component

MessageAttachments shows the files of a message under its text: the images inline, scaled to the width of the column, each a link to the full file; then the other files as a list of links with their sizes.

func MessageComposer

func MessageComposer(d ComposerData) templ.Component

MessageComposer is the place where a member writes a message: the form, or for a direct conversation with a disabled user the note that nothing can be sent.

func MessageComposerForm

func MessageComposerForm(d ComposerData) templ.Component

MessageComposerForm is the form of the composer: the quote of the message being replied to, the text (Enter sends, Shift+Enter makes a new line), the files and the Send button. The server sends it alone as a Datastar patch to show the problems of a failed submit, and, replacing the old one, a fresh, empty one after a message was sent.

func MessageContent

func MessageContent(d MessageData) templ.Component

MessageContent is a message without its list item: the author and time, "edited", the quote of the message it replies to, the text, the files, the reactions and the Reply, Edit and Delete buttons for the person who may. A deleted message is the placeholder "message deleted". The entry of a call is one quiet line (CallEntry). A live update of a message replaces only this part.

func MessageContentID

func MessageContentID(id uint64) string

MessageContentID is the id of the element that holds the content of a message (see MessageContent).

func MessageCount

func MessageCount(n int) templ.Component

MessageCount is the badge with the number of conversations that have unread messages, on the Messages link of the header. The element is always there, so that a patch finds it; it is empty, and not shown, when the count is 0.

func MessageEdit

func MessageEdit(d MessageEditData) templ.Component

MessageEdit is the content of a message replaced by its editor: the text in a field with Save and Cancel. A failed save shows its problem in it.

func MessageElementID

func MessageElementID(id uint64) string

MessageElementID is the id of the element of a message in the list.

func MessageFilePath

func MessageFilePath(a app.AttachmentView) string

MessageFilePath returns the path that downloads an attachment of a message, /messages/files/<id>/<name>. The name only gives the download a good name; the ID decides.

func MessageItem

func MessageItem(d MessageData) templ.Component

MessageItem is a message in the list: its content and, in a direct conversation, the place for "Seen" under an own message.

func MessageItemEditing

func MessageItemEditing(d MessageEditData) templ.Component

MessageItemEditing is a message of the list replaced by its editor, for the page of a browser without JavaScript.

func MessageItems

func MessageItems(items []MessageData) templ.Component

MessageItems is messages one after the other, as the list shows them.

func MessageQuote

func MessageQuote(q app.MessageQuote) templ.Component

MessageQuote is the message that a message replies to, above its text: the author and the start of the text, or "message deleted".

func MessageReactionPicker

func MessageReactionPicker(d MessageReactionsData) templ.Component

MessageReactionPicker is the add button of the reaction bar of a message and the picker it opens, as ReactionPicker is that of a post. Live changes of the reactions leave it alone.

func MessageReactions

func MessageReactions(d MessageReactionsData) templ.Component

MessageReactions are the chips of a message, as Reactions are those of a post. The server sends it alone as a Datastar patch after a reaction and, to every open page, when the reactions of a message change; the picker next to it is not part of it.

func MessageReplySlot

func MessageReplySlot(q *app.MessageQuote, convID uint64) templ.Component

MessageReplySlot is the place in the composer where the message being replied to shows as a quote with a cancel button, and holds the field "reply_to" that sends its ID. It is empty for a message that replies to nothing. The server sends it alone as a Datastar patch when the person asks to reply.

func MessageSearchBox added in v1.2.0

func MessageSearchBox(query string) templ.Component

MessageSearchBox is the search box of the Messages page: a plain GET form, so that a search is a link (SPEC §7.11, D56).

func MessageSearchPath added in v1.2.0

func MessageSearchPath(q string, before uint64) string

MessageSearchPath returns the path of the Messages page with a search: the text of the box and, for an older page of results, the before that asks for it. An empty query gives MessagesPath.

func MessageSearchResults added in v1.2.0

func MessageSearchResults(d MessageSearchData) templ.Component

MessageSearchResults is the results of a search of the messages in place of the list of conversations: the problem with the query, or the messages found with a link to each in its conversation, "No messages match." for none, the link that clears the search and the link to the older results.

func MessageSeen

func MessageSeen(id uint64, seen bool) templ.Component

MessageSeen is the place under an own message of a direct conversation where "Seen" shows, empty unless the other member read up to the message.

func MessagesOlder

func MessagesOlder(convID uint64, hasOlder bool, before uint64) templ.Component

MessagesOlder is the top of the list of messages. When older messages exist it is the sentinel: when it scrolls into view, Datastar loads the next, older page (the server answers with the messages to put on top and a new sentinel); without JavaScript the link "Older messages" opens the older page. With no older messages it is empty.

func MessagesPage

func MessagesPage(d ConversationsData) templ.Component

MessagesPage is the page of the conversations of the user, most recent first, with the form that starts one. Its stream keeps the list live.

func NewConversationForm

func NewConversationForm(d NewConversationData) templ.Component

NewConversationForm is the form that starts a conversation: the usernames of the people, separated by spaces or commas (one makes a direct conversation, several a group), and the optional name of a group. The server sends it alone as a Datastar patch to show the problems of a failed submit.

func NewSinceID added in v1.2.0

func NewSinceID(posts []app.Post, seen, viewerID uint64) uint64

NewSinceID is the ID of the post after which the feed draws the line "New since your last visit" (SPEC §7.17): the oldest top-level post of the page that the viewer has not seen. posts are the posts of the first page, newest first; seen is the viewer's mark before it moved; a post is unseen when its ID is above the mark, it is not deleted and someone else wrote it, which is what the sidebar counts. It is 0 when no post of the page is unseen. When every post of the page is unseen it is the last post of the page.

func NoticePath added in v1.2.0

func NoticePath(n app.Notice) string

NoticePath returns where a notice leads when it is clicked: the post or comment of a new post, a mention, a reply or an assignment, in its thread; the room of an addition; the conversation of a message.

func NoticePlaceKey added in v1.2.0

func NoticePlaceKey(n app.Notice) string

NoticePlaceKey is the PlaceKey of the place of a notice.

func NotificationCount

func NotificationCount(n int) templ.Component

NotificationCount is the badge with the number of unread notifications, on the bell of the header. The element is always there, so that a patch finds it; it is empty, and not shown, when the count is 0.

func NotificationElementID

func NotificationElementID(id uint64) string

NotificationElementID is the id of the element of a notification.

func NotificationItem

func NotificationItem(n app.Notification) templ.Component

NotificationItem is one notification: who did what in which room, when, a link to it and, if it was unread, the unread mark. The mark goes when the signal readUpTo reaches the ID of the notification.

func NotificationOthers added in v1.2.0

func NotificationOthers(n app.Notification) string

NotificationOthers is what follows the name of the actor of a reply that took in more people: " and 2 others", empty for none.

func NotificationPath

func NotificationPath(n app.Notification) string

NotificationPath returns where a notification leads: the post or comment of a mention, a reply or an assignment, in its thread; the room of a room addition.

func NotificationSentence

func NotificationSentence(n app.Notification) string

NotificationSentence is what the actor did, up to the room: "mentioned you in", "replied in", `assigned you "<task>" in` or "added you to". A reply says "replied in" whether it answers the user or comes from a followed thread (SPEC §7.15).

func NotificationsMessage

func NotificationsMessage(message string) templ.Component

NotificationsMessage is the place of the message about the last action of the page, such as a failed "Mark all as read"; empty it shows nothing.

func NotificationsOlderPath

func NotificationsOlderPath(before uint64) string

NotificationsOlderPath returns the path of the notifications older than the notification before.

func NotificationsPage

func NotificationsPage(d NotificationsData) templ.Component

NotificationsPage is the page of the notifications of the user, newest first. The unread marks are those of the notifications that were unread when the page opened; "Mark all as read" clears them through the signal readUpTo.

func NotificationsStreamPath

func NotificationsStreamPath(seen uint64, live bool) string

NotificationsStreamPath returns the path of the stream of the notifications page: MeStreamPath, with the ID of the newest notification the page shows when the page shows the newest ones, so that the stream puts newer ones on top. A page of older notifications keeps no list live, and takes seen 0 with live false.

func NotifyEvent added in v1.2.0

func NotifyEvent(n app.Notice) templ.Component

NotifyEvent is the element that tells the page script (notify.js) to ring for an event of the user's stream: who did what and where, never the body. The server appends it to #notify-events; the script reads it, decides with the other tabs which one rings, and removes it (SPEC §7.15). The decision whether the event rings is the server's: the element exists only for an event that rings, and carries the sound and whether a browser notification is wanted. The text is in data-notice and not data-text: Datastar runs every data-text attribute it meets as an expression, which stops it from setting up the other elements of the same patch.

func NotifyPlace added in v1.2.0

func NotifyPlace(place string) templ.Component

NotifyPlace marks the place the page shows (the room, or the conversation), so that the page script stays silent for events of the place the person is looking at. place is a PlaceKey.

func NotifyPrefsSection added in v1.2.0

func NotifyPrefsSection(d NotifyPrefsData) templ.Component

NotifyPrefsSection is the Notifications section of the settings: what notifies the user (all, mentions, nothing), the sound with its choice and a Play button each, the browser notifications, the replies, and the list of the rooms and conversations that have preferences of their own. The server sends it alone as a Datastar patch after a submit.

func OlderPostsPath

func OlderPostsPath(roomID, before uint64) string

OlderPostsPath returns the path of the page of the room that shows the posts older than before, for a browser without JavaScript.

func OnlineDot added in v1.2.0

func OnlineDot(online bool) templ.Component

OnlineDot is the small dot next to a member who is online (SPEC §7.15); it draws nothing for one who is not. It is drawn when the page loads and not updated live.

func PageBaseTitle added in v1.2.0

func PageBaseTitle(title string) string

PageBaseTitle is the title of a page without the count: the name of the page and the name of the site.

func PageHeader(d SidebarData) templ.Component

PageHeader is the header element of the pages of a logged-in user, with its content (Header). The streams patch it together with PageSidebar, by their ids.

func PageSidebar added in v1.2.0

func PageSidebar(d SidebarData) templ.Component

PageSidebar is the aside element of the pages of a logged-in user, with the rooms (Sidebar). It is a popover (SPEC D58): above 40 rem app.css draws it as the column beside the page, at 40 rem and below as a drawer from the left that the menu button of the header (Header) opens, with the close button in front of the rooms (hidden in the column). The close button has autofocus, which is what makes the browser move the focus into the drawer when it opens.

func PageTitle added in v1.2.0

func PageTitle(unread int, base string) templ.Component

PageTitle is the title element of a page: "(n) " when unread is above 0, then base, the name of the page with the name of the site. It has an id so that the stream can patch it when the count changes.

func PasswordSection added in v1.2.0

func PasswordSection(d PasswordData) templ.Component

PasswordSection is the Password section: the current password and the new one twice. The server sends it alone as a Datastar patch after a submit.

func PlaceKey added in v1.2.0

func PlaceKey(ref app.PlaceRef) string

PlaceKey returns the key of a place that the page script compares with the place of an event: "room:3" or "conversation:5".

func PlacePrefsButton added in v1.2.0

func PlacePrefsButton(d PlacePrefsData) templ.Component

PlacePrefsButton is the button that opens the dialog; the header of a room and of a conversation have one.

func PlacePrefsDialog added in v1.2.0

func PlacePrefsDialog(d PlacePrefsData) templ.Component

PlacePrefsDialog is the dialog "Notification preferences" of a room page and of a conversation page. It is drawn for a person who has preferences in the place (Action is not empty); a button in the header of the page opens it.

func PlacePrefsForm added in v1.2.0

func PlacePrefsForm(d PlacePrefsData) templ.Component

PlacePrefsForm is the form of the dialog. The server sends it alone as a Datastar patch after a submit, so that the dialog stays open.

func PlacePrefsSummary added in v1.2.0

func PlacePrefsSummary(p app.PlacePrefs) string

PlacePrefsSummary says in a few words what the preferences of a place are, for the list of the settings: "Muted", "Notify: mentions, sound off".

func PostCard

func PostCard(d PostCardData) templ.Component

PostCard is a post or a comment: author, time, "edited", the body, the tags as links to their search, the comment count of a post that links to its thread, and Reply, Edit and Delete for the person who may. A comment is indented to its depth (at most MaxVisualDepth) and, below that depth, says whom it replies to. A post or comment that was deleted but stays because it has replies is the placeholder "This post was deleted." or "This comment was deleted." The server sends it alone as a Datastar patch after an edit, a cancel or a failed action.

func PostCommentsPath

func PostCommentsPath(id uint64) string

PostCommentsPath returns the path of the comments of a post, the page of the post at its thread: /posts/<id>#comments.

func PostContent

func PostContent(d PostCardData) templ.Component

PostContent is the card of a post or comment without its article and its reply slot: the message above it, the author and time, the body, the attachments, the tags and the footer with the buttons. A live update of a post or comment replaces only this part, so that a reply editor open in the slot below it, or the editor that replaced the article, is left alone.

func PostEdit

func PostEdit(d PostEditData) templ.Component

PostEdit is a post or comment replaced by its editor, for the edit in place.

func PostEditor

func PostEditor(d PostEditorData) templ.Component

PostEditor is the composer of a post: a card with the body, then one row of controls (the Text / Markdown switch, the tags field with its suggestions, the attach button, Add task, Preview and the submit button), the tasks being added, the preview and the problems. The server sends it alone as a Datastar patch to show the problems of a failed submit; what the person typed is kept. The comments and the edit in place reuse it.

func PostMenu added in v1.2.0

func PostMenu(d PostCardData) templ.Component

PostMenu is the "more" menu of a post or comment: a details element without script, opened by the three dots, with Follow or Unfollow (posts), Edit and Delete for the person who may. It is left out when none of them is offered. The details element keeps its open state when a stream patches the card (data-preserve-attr) and closes when the person clicks outside it.

func PostPage

func PostPage(d PostPageData) templ.Component

PostPage is the page of a post, in the layout with the sidebar: the room it was written in, the post and its thread of comments. The page of a comment is the page of its post with that comment in focus.

func PostPath

func PostPath(id uint64) string

PostPath returns the path of the page of a post, /posts/<id>. Its actions are PostPath + "/edit", "/view" and "/delete".

func PostPreview

func PostPreview(d PostPreviewData) templ.Component

PostPreview is the preview box of an editor. The server sends it alone as a Datastar patch when the person asks for a preview.

func PostStreamPath

func PostStreamPath(rootID, newest uint64) string

PostStreamPath returns the path of the live stream of the thread of the top-level post rootID. newest is the ID of the newest item the page showed (PostPageData.NewestID).

func PostTasks

func PostTasks(roomID uint64, tasks []app.TaskCard) templ.Component

PostTasks is the list of the tasks of a post or comment under its body: the title, the column as a badge (the last column styled as done), the names of the assignees, the due date (red when overdue) and a link to the card on the board of the room.

func ProfileSection added in v1.2.0

func ProfileSection(d ProfileData) templ.Component

ProfileSection is the Profile section: the avatar, with the form that uploads one and the button that removes it, and the display name. The server sends it alone as a Datastar patch after a submit.

func ReactionPicker

func ReactionPicker(d ReactionsData) templ.Component

ReactionPicker is the add button of the reaction bar of a member and the picker it opens: the common emoji and a field for any other emoji. It is empty for anyone who has not joined the room. The server sends it alone as a Datastar patch after the person's own reaction (which closes it) or a mistake in the field (which opens it); live changes of the reactions leave it alone.

func Reactions

func Reactions(d ReactionsData) templ.Component

Reactions are the chips of a post or comment: one for each emoji with its count, highlighted when the person reacted, with the names of the people as its title; clicking a chip adds or removes the person's reaction. Anyone who has not joined the room sees the chips and cannot click them. The server sends it alone as a Datastar patch after a reaction and, to every open page, when the reactions of a post change; the picker next to it is not part of it, so that a live change does not close it or clear what the person typed.

func ReplySlot

func ReplySlot(parentID uint64, editor *PostEditorData) templ.Component

ReplySlot is the place under a post or comment where the reply editor opens, empty until then. The server sends it alone as a Datastar patch to open the editor.

func ResetForm added in v1.2.0

func ResetForm(d ResetData) templ.Component

ResetForm is the form of a reset link. The server sends it alone as a Datastar patch to show the problems of a failed submit.

func ResetPage added in v1.2.0

func ResetPage(d ResetData) templ.Component

ResetPage is the page of the form that sets a new password with a reset link.

func RoomComposer

func RoomComposer(d RoomData) templ.Component

RoomComposer is the place where a member writes a new post: the editor, or for anyone else the note to join the room. A live update replaces it when the viewer joins or leaves the room.

func RoomEditForm

func RoomEditForm(d RoomData) templ.Component

RoomEditForm is the rename form of a room, in a details element that opens after a failed submit. The server sends it alone as a Datastar patch to show the problems.

func RoomHeader

func RoomHeader(d RoomData) templ.Component

RoomHeader is the header of a room: its name, visibility, the links to its posts and its board, its description and member count, the join, leave and delete buttons, the message of the last action and the rename form. The server sends it alone as a Datastar patch when an action on the room fails.

func RoomMemberCount

func RoomMemberCount(d RoomData) templ.Component

RoomMemberCount is the number of members in the header of a room. A live update replaces it alone when someone joins or leaves.

func RoomNav

func RoomNav(roomID uint64, current RoomNavCurrent) templ.Component

RoomNav is the navigation between the pages of a room: its posts and its board. The page that is shown is marked as current.

func RoomNewForm

func RoomNewForm(d RoomNewData) templ.Component

RoomNewForm is the form that makes a room. The server sends it alone as a Datastar patch to show the problems of a failed submit.

func RoomNewPage

func RoomNewPage(d RoomNewData) templ.Component

RoomNewPage is the page of the form that makes a room.

func RoomPage

func RoomPage(d RoomData) templ.Component

RoomPage is the page of a room: the header, the editor of a new post (for a member; others are told to join), the feed and the members panel.

func RoomPath

func RoomPath(id uint64) string

RoomPath returns the path of the page of a room, /rooms/<id>. Its actions are RoomPath + "/join", "/leave", "/rename", "/delete" and "/members".

func RoomPrefsPath added in v1.2.0

func RoomPrefsPath(roomID uint64) string

RoomPrefsPath is where the dialog of a room posts to.

func RoomStreamPath

func RoomStreamPath(roomID, newest, before, newSince uint64) string

RoomStreamPath returns the path of the live stream of the room. newest is the ID of the newest post the page showed, 0 for none; before is the beforeID of the page of the feed (0 for the newest posts), which a stream does not keep up to date; newSince is the post after which the page draws the line "New since your last visit" (0 for none), which the stream draws again when it sends the feed.

func RoomsBrowsePage

func RoomsBrowsePage(d RoomsBrowseData) templ.Component

RoomsBrowsePage is the page that lists the visible rooms with a Join button for each room the person has not joined.

func RoomsPanel

func RoomsPanel(d RoomsBrowseData) templ.Component

RoomsPanel is the list of the visible rooms with the message of the last action above it. The server sends it alone as a Datastar patch when a join fails.

func SSHKeyRemovePath added in v1.2.0

func SSHKeyRemovePath(id uint64) string

SSHKeyRemovePath is the path that removes the SSH key with the id.

func SearchBar() templ.Component

SearchBar is the small search box of the sidebar, on every page but the search page. It is a plain GET form.

func SearchBox(query string) templ.Component

SearchBox is the search box of the search page. It is a plain GET form, so the result can be shared by its URL; with Datastar the results are fetched and patched in place after a short pause in the typing.

func SearchPage

func SearchPage(d SearchData) templ.Component

SearchPage is the page of the search: the box, the help, the filters as chips and the results.

func SearchPanel

func SearchPanel(d SearchData) templ.Component

SearchPanel is the message about the query, the help, the filters as chips, the results and the links to the newer and older page. The server sends it alone as a Datastar patch when the query or the page changes.

func SearchPath

func SearchPath(q string, page int) string

SearchPath returns the path of the search for the text of the box, with the page number: /search?q=design&page=2. The page 1 and lower is not written, and an empty query gives /search.

func SeenMessageID

func SeenMessageID(viewerID uint64, h app.ConversationHeader, messages []app.Message) uint64

SeenMessageID returns the ID of the message that "Seen" shows under in a direct conversation: the newest message of the viewer, not deleted, among messages that the other member has read. It is 0 for a group, when the other member has read none of them, and when none is the viewer's.

func SessionEndPath added in v1.1.0

func SessionEndPath(id uint64) string

SessionEndPath is the path that ends the session with the id.

func SessionsSection added in v1.2.0

func SessionsSection(sessions []app.SessionInfo) templ.Component

SessionsSection is the Sessions section: every browser and every app that is logged in, with when it was made and last used, the one that shows the page marked, and a button to end each of them. Ending the session of the page logs it out.

func SettingsPage added in v1.2.0

func SettingsPage(d SettingsData) templ.Component

SettingsPage is the settings page of the user: the sections Profile, Password, Appearance, Notifications, Sign-in and Sessions, each of which saves on its own.

func Sidebar(d SidebarData) templ.Component

Sidebar is the sidebar of the pages of a logged-in user: the rooms of the user with the counts of 20.2, and the links to browse and to make rooms. Everything else the old sidebar held is in the header (Header).

func SidebarRoom added in v1.2.0

func SidebarRoom(room app.Room, current uint64) templ.Component

SidebarRoom is the list item of one room in the sidebar: the link with the name, then what is waiting in it (SPEC §7.17). A room with unread posts is bold and shows their number ("99+" above 99); a room set to count only mentions is not bold and shows only the badge of the mentions; a muted room is dimmed and shows only the badge of the mentions. A mention badge appears whenever the room has unread mentions. The item has an id so that the stream can patch it alone when the counts of the room change.

func SignInSection added in v1.2.0

func SignInSection(d SignInData) templ.Component

SignInSection is the Sign-in section: the SSH keys with Remove, the form that adds one, and what the user needs to fetch a code (the command and the fingerprint of the host key) or the note that the server is off. The server sends it alone as a Datastar patch after a submit.

func SignUpForm

func SignUpForm(d SignUpData) templ.Component

SignUpForm is the sign-up form. The server sends it alone as a Datastar patch to show the problems of a failed submit.

func SignUpPage

func SignUpPage(d SignUpData) templ.Component

SignUpPage is the page of the sign-up form of an invitation.

func SizeText

func SizeText(n int64) string

SizeText writes a size in bytes for people: "512 B", "12 KB", "3.4 MB". The units are powers of 1024; a value of 10 or more has no decimals, a smaller one has one unless it is whole.

func SplitTitle added in v1.2.0

func SplitTitle(title string) (label, base string)

SplitTitle splits the title of a page into the label of its count of unread things ("3" or "99+"; empty when the title has none) and the rest, which is the name of the page with the name of the site. It is how a stream learns what the page shows from the title the page tells it.

func StaticURL added in v1.2.0

func StaticURL(ctx context.Context, path string) string

StaticURL is the address of a static file for the page rendered in ctx: path (such as "/static/app.css") with "?v=" and the version of the static files when ctx has one (WithStaticVersion), and path alone otherwise (a component rendered in a context that was not made by the server).

func TabTitle added in v1.2.0

func TabTitle(unread int, base string) string

TabTitle is the title of a page: "(n) " when n is above 0, then base. base is the name of the page with the suffix of the site, as PageTitle takes it.

func TagSearchPath

func TagSearchPath(tag string) string

TagSearchPath returns the path of the search for a tag, /search?q=%23tag.

func TagSuggestions

func TagSuggestions(editorID string, tags []string) templ.Component

TagSuggestions is the list of suggested tags under the tags field of an editor. The server sends it alone as a Datastar patch while the person types; a suggestion completes the tag being typed.

func TaskBoardPath

func TaskBoardPath(roomID, taskID uint64) string

TaskBoardPath returns the path of a task on the board of its room, which the board page opens at its card: /rooms/<room>/board#task-<id>.

func TaskRow

func TaskRow(editorID string, index int, row TaskRowData, options []AssigneeOption) templ.Component

TaskRow is one task row of the editor: the title, the people it is assigned to (a multiple choice of the options), the due date, the hidden ID of the task (0 for a new one) and the Remove button. The fields are named tasks[<index>][id], [title], [assignees] and [due]. The server sends a row alone as a Datastar patch when the Add task button asks for one.

func TaskRowsSelector

func TaskRowsSelector(editorID string) string

TaskRowsSelector is the selector of the list of task rows of the editor.

func ThemeColor added in v1.2.0

func ThemeColor() templ.Component

ThemeColor writes the theme-color elements of the head: one with the colour of the theme the person chose (Light or Dark), or, for System, one for each palette, chosen by prefers-color-scheme. The theme form patches nothing here; it replaces the elements through script (the answer of the theme form).

func ThemeMenu added in v1.2.0

func ThemeMenu(theme app.Theme) templ.Component

ThemeMenu is the small form of the user menu that picks the theme: System, Light or Dark, three buttons that post to the Appearance route of the settings (the query from=menu tells it to answer for the menu). The current choice has aria-pressed="true". The server sends it alone as a Datastar patch after the choice, which also sets data-theme on the page.

func Thread

func Thread(d PostPageData) templ.Component

Thread is the post of the page and its comments, one after the other in reading order, each indented to its depth. The server sends it alone as a Datastar patch when a comment is written or deleted: the new thread replaces the old one.

func UserMenu added in v1.2.0

func UserMenu(d SidebarData) templ.Component

UserMenu is the menu of the user, a details element without script: the avatar opens a panel with the name, Settings, the theme (ThemeMenu), Sessions, Admin (for admins only) and the logout form. The details element keeps its open state when a stream patches the header (data-preserve-attr).

func UsersPanel

func UsersPanel(d AdminUsersData) templ.Component

UsersPanel is the table of users with the message of the last action above it. The server sends it alone as a Datastar patch after an action on a user.

func WithRoomRead added in v1.2.0

func WithRoomRead(room app.Room) app.Room

WithRoomRead returns the room with its unread counts set to 0; see SidebarData.WithRoomRead.

func WithStaticVersion added in v1.2.0

func WithStaticVersion(ctx context.Context, version string) context.Context

WithStaticVersion returns ctx with the version of the embedded static files (the hash the server puts in /sw.js too). StaticURL then adds it to the address of every static file a page names, so that a page of a new release asks for new addresses: a browser or the service worker that kept the old files under the old addresses cannot answer them (SPEC D58).

func WithTheme added in v1.2.0

func WithTheme(ctx context.Context, theme string) context.Context

WithTheme returns ctx with the theme of the person who gets the page, which Layout writes as data-theme on the html element. Only "light" and "dark" are written; anything else, such as "system", leaves the attribute out and the browser's own setting decides.

Types

type AdminRoomRow

type AdminRoomRow struct {
	// Room is the room.
	Room app.Room
	// Creator is the display name of the user who made the room; empty when
	// that user is not known.
	Creator string
	// MembersOpen is true when the members list is open; Members are then the
	// members of the room.
	MembersOpen bool
	Members     []app.Member
	// Message is the problem of the last action on the room (rename, delete),
	// shown in the row; empty shows none.
	Message string
	// MembersMessage is the problem of the last action on the members, shown
	// above the list; empty shows none.
	MembersMessage string
	// Edit is the state of the rename form. Open is true after a failed
	// submit.
	Edit RoomEditData
}

AdminRoomRow is one room on the admin rooms page with the state of its forms.

type AdminRoomsData

type AdminRoomsData struct {
	// Sidebar is the sidebar of the page.
	Sidebar SidebarData
	// Rooms are all the rooms, ordered by name.
	Rooms []AdminRoomRow
}

AdminRoomsData is what the admin rooms page shows.

type AdminUsersData

type AdminUsersData struct {
	// Viewer is the admin who looks at the page.
	Viewer app.User
	// Sidebar is the sidebar of the page.
	Sidebar SidebarData
	// Users are all the users.
	Users []app.User
	// Message is the problem of the last action on a user, shown above the
	// table; empty shows none.
	Message string
	// Invite is the state of the invitation form and of its link.
	Invite InviteData
	// Reset is the reset link that was just made, shown once above the
	// table; its Link is empty when none was.
	Reset ResetLinkData
	// SSHServerOff is true when this Clowder runs no SSH server and some user
	// has the SSH code on: the page warns that those users log in with their
	// password only (SPEC §7.16).
	SSHServerOff bool
}

AdminUsersData is what the admin users page shows.

type AppearanceData added in v1.2.0

type AppearanceData struct {
	// Theme is the theme in use, which the radio button checks.
	Theme app.Theme
	// Errors are the problems of the last submit.
	Errors FormErrors
	// Saved is true right after a submit that worked.
	Saved bool
}

AppearanceData is what the Appearance section shows.

type AssigneeOption

type AssigneeOption struct {
	// ID is the ID of the user, the value of the option.
	ID uint64
	// Label is the text of the option.
	Label string
}

AssigneeOption is a person the assignee picker of a task row offers.

func AssigneeOptions

func AssigneeOptions(members []app.Member) []AssigneeOption

AssigneeOptions makes the options of the assignee picker from the members of a room, in their order.

type AuditData

type AuditData struct {
	// Sidebar is the sidebar of the page.
	Sidebar SidebarData
	// Filter is the state of the filter form.
	Filter AuditFilterForm
	// Rooms are all the rooms, for the room filter.
	Rooms []app.Room
	// MissingRoom is true when the room of the filter is not in Rooms (it was
	// deleted); the room filter then offers it by its ID.
	MissingRoom bool
	// Users are all the users, for the actor filter.
	Users []app.User
	// Entities and Actions are the values of the entity type and action
	// filters.
	Entities []string
	Actions  []string
	// Rows are the events of the page, newest first.
	Rows []AuditRow
	// Page is the number of the page, starting at 1.
	Page int
	// HasNext is true when an older page exists.
	HasNext bool
}

AuditData is what the audit log page shows.

type AuditDetail

type AuditDetail struct {
	// Key is the name of the field.
	Key string
	// Old and New are the values before and after the change. They are empty
	// for a row with a Text.
	Old string
	New string
	// Text is the whole content of a row that has no old and new value, such as
	// "body changed (42 characters)" or the user of a member event. When it is
	// not empty the row spans the Old and New columns.
	Text string
}

AuditDetail is one row of the details table of an audit event: a field and its old and new value, or a single text that spans both columns.

func AuditDetails

func AuditDetails(details map[string]any) []AuditDetail

AuditDetails makes the rows of the details table from the decoded Details of an event (SPEC §7.10), sorted by key. A field of the form {"old": ..., "new": ...} is a row with the two values. The body shape of a post or comment, {"bodyChanged": true, "length": n}, is the one row "body changed (n characters)": the text of a body is never in the details. Any other value is a row with a text.

type AuditFilterForm

type AuditFilterForm struct {
	// Room is the ID of the room to keep; 0 keeps every room.
	Room uint64
	// Actor is the ID of the user to keep; 0 keeps every user.
	Actor uint64
	// Entity is the entity type to keep; empty keeps every type.
	Entity string
	// Action is the action to keep; empty keeps every action.
	Action string
	// From and To are the first and the last day to keep, as 2006-01-02; empty
	// leaves that end open.
	From string
	To   string
	// Message is the problem with the filters, such as a date that is not a
	// date; empty shows none.
	Message string
}

AuditFilterForm is the state of the filter form of the audit log: the values of the query parameters of the page. The zero value filters nothing.

func (AuditFilterForm) AuditPath

func (f AuditFilterForm) AuditPath(page int) string

AuditPath returns the path of the audit log page with the filters and the page number, such as /admin/audit?actor=3&page=2.

func (AuditFilterForm) Query

func (f AuditFilterForm) Query(page int) string

Query returns the query string of the filters (without the "?") for the page of the log, with empty filters left out. Page 1 and lower is not written.

type AuditRow

type AuditRow struct {
	// Event is the event.
	Event app.AuditView
	// RoomName is the name of the room of the event: the current name while
	// the room exists, else the name it had in the event; empty when the event
	// does not tell.
	RoomName string
	// RoomExists is true when the room still exists, so that the row links to
	// it.
	RoomExists bool
}

AuditRow is one event of the audit log with what the page shows around it.

type BoardData

type BoardData struct {
	// Sidebar is the sidebar of the page.
	Sidebar SidebarData
	// Board is the board as the viewer sees it: its room, the columns with the
	// cards, and whether the viewer may change it.
	Board app.BoardView
	// Message is the problem of the last action on the board, shown above the
	// columns; empty shows none.
	Message string
	// Editor is the form of the card being edited; nil when none is open.
	Editor *BoardEditorData
}

BoardData is what the page of the board of a room shows.

type BoardEditorData

type BoardEditorData struct {
	// Task is the card being edited, as the board shows it.
	Task app.TaskCard
	// Title is the text in the title field.
	Title string
	// Assignees are the IDs of the people selected in the picker.
	Assignees []uint64
	// Due is the due date as the date field holds it ("2006-01-02"), or empty.
	Due string
	// ClearDue is true when the box that removes the due date is ticked.
	ClearDue bool
	// Options are the people the picker offers: the members of the room and
	// the former members who are assigned to the card.
	Options []AssigneeOption
	// Errors are the problems of the last submit; the fields are named title,
	// assignees and dueDate.
	Errors FormErrors
}

BoardEditorData is the form that edits one card. It lives in its own panel outside the columns, so that a live update of the columns never closes it or clears what is typed in it.

func NewBoardEditorData

func NewBoardEditorData(task app.TaskCard, members []app.Member) BoardEditorData

NewBoardEditorData makes the editor of a card, filled with what the card has now. members are the members of the room; people assigned to the card who are no longer members stay in the picker, marked as having left, so that a save keeps them (SPEC §7.6).

type CallData added in v1.2.0

type CallData struct {
	// ConversationID is the conversation.
	ConversationID uint64
	// Enabled is true for a direct conversation of a server whose calls are
	// on; only then the page has the buttons and the call area.
	Enabled bool
	// Open is the call that rings or is active; nil for none. The buttons give
	// way to it.
	Open *CallPanelData
}

CallData is what the page of a direct conversation shows of its calls: the buttons that start one, and the call that is in progress.

type CallInviteData added in v1.2.0

type CallInviteData struct {
	// CallID and ConversationID are the call and its direct conversation.
	CallID         uint64
	ConversationID uint64
	// Caller is the person who calls.
	Caller app.UserRef
	// Video is true when the caller started the call with video.
	Video bool
	// Ring is true when the ringtone plays (SPEC §7.15); Browser is true when
	// the browser notification is wanted.
	Ring    bool
	Browser bool
	// Text is the text of the browser notification.
	Text string
}

CallInviteData is what the ringing dialog shows: the call that rings for the user, and how it rings.

func CallInviteOf added in v1.2.0

func CallInviteOf(inv app.CallInvitation) *CallInviteData

CallInviteOf makes the data of the dialog out of an invitation.

type CallPanelData added in v1.2.0

type CallPanelData struct {
	// CallID is the call.
	CallID uint64
	// Video is true when the caller started the call with video.
	Video bool
	// Active is true once the callee answered; false while it rings.
	Active bool
	// Incoming is true when the user of the page is the callee.
	Incoming bool
	// Other is the other person of the call.
	Other app.UserRef
	// Elapsed is how long the call has been active, as the server read it.
	Elapsed time.Duration
	// Answer is what the user chose to send when they answered ("video" or
	// "audio"), from the query of the page; empty when they did not answer in
	// this page load. It makes the tab the one that takes part in the call.
	Answer string
}

CallPanelData is the call in progress, as the user of the page sees it.

type ComposerData

type ComposerData struct {
	// ConversationID is the conversation the composer writes in.
	ConversationID uint64
	// CanSend is false when the other user of a direct conversation is
	// disabled: the composer is replaced by a note.
	CanSend bool
	// Body is the text in the field, kept after a failed submit.
	Body string
	// Reply is the message the new one replies to; nil for none.
	Reply *app.MessageQuote
	// Errors are the problems of the last submit; the fields are named body,
	// attachments and replyTo.
	Errors FormErrors
	// ConfirmCount, when it is not 0, is the number of people a group mention
	// of the body would notify, and the composer asks "This will notify N
	// people. Send anyway?" (SPEC §7.15).
	ConfirmCount int
}

ComposerData is what the composer of a conversation shows.

type ConversationData

type ConversationData struct {
	// Sidebar is the sidebar of the page.
	Sidebar SidebarData
	// ViewerID is the ID of the person who looks at the page.
	ViewerID uint64
	// Header is the conversation.
	Header app.ConversationHeader
	// Messages are the messages of the page, oldest first.
	Messages []MessageData
	// HasOlder is true when older messages exist; NextBefore is the before
	// that asks for them.
	HasOlder   bool
	NextBefore uint64
	// Before is the before that asked for this page; 0 for the newest
	// messages.
	Before uint64
	// Composer is the composer.
	Composer ComposerData
	// Members is the members panel of a group.
	Members MembersPanelData
	// Edit is the editor of the message being edited; nil for none.
	Edit *MessageEditData
	// Notice is the problem of the last action on the conversation, shown in
	// the header; empty shows none.
	Notice string
	// Prefs is the dialog of the notification preferences of the viewer in
	// the conversation.
	Prefs PlacePrefsData
	// Focus is the message the page was opened for (a search result links to
	// it); 0 for none. The page scrolls to it and marks it.
	Focus uint64
	// Call is the calls of the conversation: the buttons and the call in
	// progress (SPEC §7.18). The zero value is a conversation without calls.
	Call CallData
}

ConversationData is what the page of a conversation shows.

func (ConversationData) NewestID

func (d ConversationData) NewestID() uint64

NewestID is the ID of the newest message of the page, 0 for none. The stream of the page is told it, to find out what was sent while the page was loading.

type ConversationsData

type ConversationsData struct {
	// Sidebar is the sidebar of the page.
	Sidebar SidebarData
	// ViewerID is the ID of the person who looks at the page.
	ViewerID uint64
	// Items are the conversations, the most recent first.
	Items []app.ConversationSummary
	// New is the state of the form that starts a conversation.
	New NewConversationData
	// Search is the search of the page, if any (SPEC §7.11, D56).
	Search MessageSearchData
}

ConversationsData is what the Messages page shows.

type FeedData

type FeedData struct {
	// RoomID is the ID of the room.
	RoomID uint64
	// Page holds the posts, newest first, and where the next page starts.
	Page app.FeedPage
	// Before is the beforeID that asked for this page; 0 for the first page.
	Before uint64
	// NewSince is the ID of the post after which the line "New since your last
	// visit" is drawn (see NewSinceID); 0 for no line. Only the first page of
	// the feed has one.
	NewSince uint64
}

FeedData is a page of the feed of a room.

func (FeedData) NewestID

func (d FeedData) NewestID() uint64

NewestID is the ID of the newest post of the page, 0 when it has none. The stream of the page is told it, to find out what was written while the page was loading.

type FormErrors

type FormErrors struct {
	// Form is a problem of the whole form, shown above its fields.
	Form string
	// Fields maps the name of an input to the message shown next to it.
	Fields map[string]string
}

FormErrors are the problems to show in a form after a failed submit. The zero value shows none.

type GroupMentionConfirmData added in v1.2.0

type GroupMentionConfirmData struct {
	// ID is the ID of the editor or composer the question belongs to.
	ID string
	// Count is the number of people the mention would notify; 0 shows nothing.
	Count int
	// SendPath is where Send posts to: the action of the form with the query
	// confirm_group_mention=1.
	SendPath string
}

GroupMentionConfirmData is what the question of a group mention shows.

func ComposerConfirm added in v1.2.0

func ComposerConfirm(conversationID uint64, n int) GroupMentionConfirmData

ComposerConfirm is the data of the question of the composer of the conversation: n people would be notified.

func (GroupMentionConfirmData) Question added in v1.2.0

func (d GroupMentionConfirmData) Question() string

Question is the text of the question: "This will notify 14 people. Send anyway?".

type InviteData

type InviteData struct {
	// Role is the role chosen in the form: "member" or "admin".
	Role string
	// Link is the full invitation link, <base URL>/invite/<token>; empty until
	// an invitation is made. It is shown once.
	Link string
	// ExpiresAt is when the invitation stops working.
	ExpiresAt time.Time
	// Errors are the problems of the last submit.
	Errors FormErrors
}

InviteData is what the invitation form shows.

type LoginCodeData added in v1.2.0

type LoginCodeData struct {
	// Command is the ssh command that fetches a code for the user of the
	// pending login, such as "ssh -p 2222 alice@chat.example.org"; empty when
	// this Clowder shows none.
	Command string
	// Errors are the problems of the last submit, under the field "code".
	Errors FormErrors
}

LoginCodeData is what the second form of the login shows: the code of the SSH server (SPEC §7.16).

type LoginData

type LoginData struct {
	// Username is the username typed in the last submit. The password is
	// never put back.
	Username string
	// Next is the local path to go to after the login, already checked; empty
	// means the home page.
	Next string
	// Errors are the problems of the last submit.
	Errors FormErrors
}

LoginData is what the login page and its form show.

type MembersPanelData

type MembersPanelData struct {
	// Header is the conversation.
	Header app.ConversationHeader
	// ViewerID is the ID of the person who looks at the page.
	ViewerID uint64
	// Online is the set of the members who are online when the page loads
	// (SPEC §7.15); the dots are not live.
	Online map[uint64]bool
	// AddUsers is the text in the field of the people to add.
	AddUsers string
	// RenameTo is the text in the name field when RenameOpen is set; the
	// current name otherwise.
	RenameTo string
	// RenameOpen says that RenameTo is what the person typed.
	RenameOpen bool
	// AddErrors and RenameErrors are the problems of the last add and rename.
	AddErrors, RenameErrors FormErrors
	// Message is the problem of the last action on the panel (leave); empty
	// shows none.
	Message string
}

MembersPanelData is what the members panel of a group shows.

type MessageData

type MessageData struct {
	// Message is the message.
	Message app.Message
	// HTML is the rendered body, which comes from internal/markdown; empty for
	// a message without text.
	HTML template.HTML
	// Own is true when the viewer wrote the message.
	Own bool
	// Direct is true in a direct conversation, where an own message has the
	// place for "Seen".
	Direct bool
	// Seen is true for the message "Seen" shows under.
	Seen bool
	// CanReply shows the Reply link: the viewer may send messages here.
	CanReply bool
	// Notice is the problem of the last action on the message (it may not be
	// edited or deleted), shown above it; empty shows none.
	Notice string
}

MessageData is what one message shows.

type MessageEditData

type MessageEditData struct {
	// Message is the message being edited.
	Message MessageData
	// Body is the text in the field.
	Body string
	// Errors are the problems of the last submit; the field is named body.
	Errors FormErrors
}

MessageEditData is a message replaced by its editor.

type MessageReactionsData

type MessageReactionsData struct {
	// Message is the message: its reactions, and whether the person may react.
	Message app.Message
	// Notice is the problem of the last reaction, shown above the bar; empty
	// shows none.
	Notice string
	// Problem is the message of the emoji field of the last reaction that was
	// not an emoji; the picker is open and shows it.
	Problem string
	// Typed is what the person typed in the emoji field, kept with Problem.
	Typed string
}

MessageReactionsData is what the reaction bar of a message shows.

type MessageSearchData added in v1.2.0

type MessageSearchData struct {
	// Active is true when the page shows a search: the text of the box is not
	// empty. The results then replace the list of conversations.
	Active bool
	// Query is the text of the search box, as typed.
	Query string
	// Message is the problem with the query, such as a filter that does not
	// work in messages; empty shows none.
	Message string
	// Results are the results of the page, newest first.
	Results []app.MessageSearchResult
	// HasMore is true when older results follow; NextBefore is the before that
	// asks for them.
	HasMore    bool
	NextBefore uint64
}

MessageSearchData is the search of the Messages page. The zero value is no search.

type NewConversationData

type NewConversationData struct {
	// Users and Name are the values of the last submit.
	Users string
	Name  string
	// Errors are the problems of the last submit; the fields are named users
	// and name.
	Errors FormErrors
}

NewConversationData is the form that starts a conversation.

type NotificationsData

type NotificationsData struct {
	// Sidebar is the sidebar of the page.
	Sidebar SidebarData
	// Items are the notifications of the page, newest first. Their Read is
	// what it was when the page was opened.
	Items []app.Notification
	// Before is the before of the page: 0 for the newest notifications.
	Before uint64
	// HasNext is true when older notifications exist; NextBefore is the
	// before that asks for them.
	HasNext    bool
	NextBefore uint64
	// Message is a problem to show, such as a failed "Mark all as read".
	Message string
}

NotificationsData is what the notifications page shows.

func (NotificationsData) NewestID

func (d NotificationsData) NewestID() uint64

NewestID is the ID of the newest notification of the page, 0 for none.

type NotifyPrefsData added in v1.2.0

type NotifyPrefsData struct {
	// Settings are the settings the form shows.
	Settings app.Settings
	// Places are the rooms and conversations that have preferences of their
	// own, each with the link to its dialog.
	Places []PlaceListItem
	// Errors are the problems of the last submit.
	Errors FormErrors
	// Saved is true right after a submit that worked.
	Saved bool
	// KeywordsTyped is what the person typed in the keywords field when the
	// submit failed, to put it back; nil when the field shows the saved list.
	KeywordsTyped *string
}

NotifyPrefsData is what the Notifications section of the settings shows.

func (NotifyPrefsData) KeywordsText added in v1.2.0

func (d NotifyPrefsData) KeywordsText() string

KeywordsText is the text of the keywords field: what was typed, or the saved keywords separated by commas.

type PasswordData added in v1.2.0

type PasswordData struct {
	// Errors are the problems of the last submit.
	Errors FormErrors
	// Saved is true right after a submit that worked.
	Saved bool
}

PasswordData is what the Password section shows. No password is ever put back into the form.

type PlaceListItem added in v1.2.0

type PlaceListItem struct {
	// Name is the name of the room, or the title of the conversation.
	Name string
	// Room is true for a room.
	Room bool
	// Path is the page of the place with the dialog open.
	Path string
	// Summary says in a few words what the preferences are.
	Summary string
}

PlaceListItem is a room or a conversation that has preferences of its own, as the Notifications section lists it.

type PlacePrefsData added in v1.2.0

type PlacePrefsData struct {
	// Prefs are the preferences the form shows.
	Prefs app.PlacePrefs
	// Title is the name of the place.
	Title string
	// Action is where the form posts to; empty for a viewer who has no
	// preferences here (the dialog is then not drawn).
	Action string
	// Errors are the problems of the last submit.
	Errors FormErrors
	// Saved is true right after a submit that worked.
	Saved bool
}

PlacePrefsData is what the dialog "Notification preferences" shows.

type PostCardData

type PostCardData struct {
	// Post is the post or comment.
	Post app.Post
	// From says where the post is shown (FromPost or empty): the delete form
	// takes the person to the room when the post page itself is gone.
	From string
	// Message is the problem of the last action on the post (edit, delete),
	// shown above it; empty shows none.
	Message string
	// Depth is how deep a comment is in its thread (1 for a reply to the post);
	// 0 for a post.
	Depth int
	// ParentAuthor is the author of the item a comment replies to; the zero
	// value when that is deleted. It is shown for a comment deeper than
	// MaxVisualDepth.
	ParentAuthor app.UserRef
	// Focus marks the comment that the page was opened for: highlighted and
	// scrolled into view.
	Focus bool
	// CanReply shows the Reply button (and holds the reply slot): the post is
	// shown on its own page to a member of its room.
	CanReply bool
	// Reply is the editor open in the reply slot under the item; nil for an
	// empty slot.
	Reply *PostEditorData
}

PostCardData is what one post or comment shows.

type PostEditData

type PostEditData struct {
	// Post is the post being edited.
	Post app.Post
	// Editor is the editor, filled for this post.
	Editor PostEditorData
	// Depth is how deep the post is, when it is a comment (see PostCardData).
	Depth int
}

PostEditData is the post replaced by its editor.

type PostEditorData

type PostEditorData struct {
	// ID tells the editors of a page apart: "new" for the new post, "edit-12"
	// for the edit of the post 12. The ids of its elements end with it.
	ID string
	// Action is the path the form posts to.
	Action string
	// Format is the value of the Text / Markdown switch: "markdown" or "text".
	Format string
	// Body is the text in the body field.
	Body string
	// Tags is the text in the tags field: tags separated by spaces or commas.
	Tags string
	// Errors are the problems of the last submit; the fields are named body,
	// format and tags.
	Errors FormErrors
	// SubmitLabel is the text of the submit button.
	SubmitLabel string
	// CancelPath is the path that restores what the editor replaced, which
	// Datastar fetches; empty for an editor that replaces nothing (it has no
	// Cancel link).
	CancelPath string
	// CancelHref is where the Cancel link goes without JavaScript.
	CancelHref string
	// CancelClose makes the Cancel link close the reply slot the editor is in,
	// in the browser, without asking the server (CancelHref is its target
	// without JavaScript).
	CancelClose bool
	// From says where the post is shown (FromPost), for an edit in place.
	From string
	// Attachments are the files the post has now, listed with a Remove box
	// each; nil for an editor that writes a new post.
	Attachments []app.AttachmentView
	// Removing holds the IDs of the attachments whose Remove box is ticked,
	// kept from a submit that failed.
	Removing map[uint64]bool
	// RoomID is the ID of the room the post is written in; the Add task button
	// asks the server for a row with the members of that room.
	RoomID uint64
	// Tasks are the task rows of the editor: the tasks of the post when it is
	// edited, or the rows typed in a submit that failed. The errors of the
	// rows are the message of the field "tasks".
	Tasks []TaskRowData
	// Assignable are the people the assignee pickers offer: the members of the
	// room and, when a post is edited, the former members who are assigned to
	// one of its tasks (see WithMembers).
	Assignable []AssigneeOption
	// ConfirmCount, when it is not 0, is the number of people a group mention
	// of the body would notify, and the editor asks "This will notify N
	// people. Send anyway?" (SPEC §7.15).
	ConfirmCount int
	// contains filtered or unexported fields
}

PostEditorData is what the post editor shows. The room page uses it for the new post, the post page for the edit in place and for the replies; the attachments and tasks of M6 and M9 add their fields here.

func EditPostEditorData

func EditPostEditorData(p app.Post, from string) PostEditorData

EditPostEditorData is the editor that edits the post, filled with its body, format and tags. from says where the post is shown (FromPost or empty).

func NewPostEditorData

func NewPostEditorData(roomID uint64) PostEditorData

NewPostEditorData is the empty editor that writes a post in the room.

func ReplyEditorData

func ReplyEditorData(parentID uint64) PostEditorData

ReplyEditorData is the empty editor that writes a comment under the post or comment parentID. It opens in the reply slot under that item.

func (PostEditorData) WithMembers

func (d PostEditorData) WithMembers(roomID uint64, members []app.Member) PostEditorData

WithMembers returns the editor for the room, with the members of the room offered in the assignee pickers. People assigned to the tasks of the post who are no longer members stay in the pickers, marked as having left, so that an edit can keep them (SPEC §7.6).

type PostPageData

type PostPageData struct {
	// Sidebar is the sidebar of the page; the room of the post is highlighted.
	Sidebar SidebarData
	// Post is the top-level post of the thread.
	Post app.Post
	// Comments are the comments of the thread, depth first.
	Comments []app.Comment
	// Focus is the ID of the comment the page was opened for; 0 for the post.
	Focus uint64
	// CanReply is true for a member of the room: the items have Reply buttons.
	// Anyone else is told to join the room.
	CanReply bool
	// ActiveID is the ID of the post or comment that Message, Editing and
	// Replying are about; 0 is the top-level post.
	ActiveID uint64
	// Message is the problem of the last action on the active item, shown above
	// it.
	Message string
	// Editing is true when the active item is replaced by its editor.
	Editing bool
	// Replying is true when the active item has the editor in Editor open in
	// its reply slot.
	Replying bool
	// Editor is the editor, used when Editing or Replying is true.
	Editor PostEditorData
}

PostPageData is what the page of a post shows.

func (PostPageData) CommentCard

func (d PostPageData) CommentCard(c app.Comment) PostCardData

CommentCard is the card of a comment of the thread.

func (PostPageData) NewestID

func (d PostPageData) NewestID() uint64

NewestID is the largest ID among the top-level post and the comments of the thread: the newest item the page shows. The stream of the page is told it, to find out what was written while the page was loading.

func (PostPageData) RootCard

func (d PostPageData) RootCard() PostCardData

RootCard is the card of the top-level post of the page.

type PostPreviewData

type PostPreviewData struct {
	// EditorID is the ID of the editor the box belongs to.
	EditorID string
	// HTML is the rendered body, which comes from internal/markdown; empty for
	// an empty body.
	HTML template.HTML
	// Message is the problem that stopped the preview (a body that is too
	// long); empty shows none.
	Message string
	// Hidden is true for the box before the first preview.
	Hidden bool
}

PostPreviewData is what the preview box of an editor shows.

type ProfileData added in v1.2.0

type ProfileData struct {
	// User is the logged-in user, with their avatar.
	User app.User
	// DisplayName is the value of the display name input: the user's name, or
	// what they typed in a submit that failed.
	DisplayName string
	// Errors are the problems of the last submit; the avatar's are under the
	// field "avatar", the name's under "displayName".
	Errors FormErrors
	// Saved is true right after a submit that worked.
	Saved bool
}

ProfileData is what the Profile section shows.

type ReactionsData

type ReactionsData struct {
	// Post is the post or comment: its reactions, and whether the person may
	// react.
	Post app.Post
	// From says where the post is shown (FromPost or empty), so that a plain
	// form post is sent back to the right page.
	From string
	// Message is the problem of the last reaction, shown above the bar (the
	// person may not react); empty shows none.
	Message string
	// Problem is the message of the emoji field of the last reaction that was
	// not an emoji; the picker is open and shows it (see ReactionPicker).
	Problem string
	// Typed is what the person typed in the emoji field, kept with Problem.
	Typed string
}

ReactionsData is what the reaction bar of a post or comment shows.

type ResetData added in v1.2.0

type ResetData struct {
	// Token is the token of the link, from the address.
	Token string
	// Errors are the problems of the last submit. The passwords are never
	// put back.
	Errors FormErrors
}

ResetData is what the page of a password reset link and its form show.

type ResetLinkData added in v1.2.0

type ResetLinkData struct {
	// Username is the username of the user the link is for.
	Username string
	// Link is the full link, <base URL>/reset/<token>; empty when none was
	// made. It is shown once.
	Link string
	// ExpiresAt is when the link stops working.
	ExpiresAt time.Time
}

ResetLinkData is the password reset link that an admin just made.

type RoomData

type RoomData struct {
	// Sidebar is the sidebar of the page.
	Sidebar SidebarData
	// Viewer is the person who looks at the page.
	Viewer app.User
	// Room is the room.
	Room app.Room
	// Members are the members of the room.
	Members []app.Member
	// Online is the set of the members who are online when the page loads
	// (SPEC §7.15); the dots are not live.
	Online map[uint64]bool
	// Candidates are the users the viewer can add; empty for a viewer who is
	// not a member.
	Candidates []app.User
	// Message is the problem of the last action on the room (join, leave,
	// delete), shown in the header; empty shows none.
	Message string
	// MembersMessage is the problem of the last action on the members, shown in
	// the members panel; empty shows none.
	MembersMessage string
	// Edit is the state of the rename form.
	Edit RoomEditData
	// Editor is the editor of a new post, shown to a member.
	Editor PostEditorData
	// Feed is the page of the feed that the page shows.
	Feed FeedData
	// Prefs is the dialog of the notification preferences of the viewer in
	// the room; it has no Action, and is not drawn, for a viewer who is not
	// a member.
	Prefs PlacePrefsData
}

RoomData is what the page of a room shows.

type RoomEditData

type RoomEditData struct {
	// Name and Description are the values in the form. Empty Name means the
	// current values of the room.
	Name        string
	Description string
	// Open is true when the form is shown open (after a failed submit).
	Open bool
	// Errors are the problems of the last submit.
	Errors FormErrors
}

RoomEditData is the state of the rename form.

type RoomNavCurrent

type RoomNavCurrent string

RoomNavCurrent says which page of a room the navigation marks as current.

const (
	// NavPosts is the page of the feed of the room.
	NavPosts RoomNavCurrent = "posts"
	// NavBoard is the page of the board of the room.
	NavBoard RoomNavCurrent = "board"
)

The pages of a room that the navigation links.

type RoomNewData

type RoomNewData struct {
	// Sidebar is the sidebar of the page.
	Sidebar SidebarData
	// Admin is true when the person is an admin and so chooses the
	// visibility; members always make private rooms.
	Admin bool
	// Name, Description and Visibility are the values of the last submit.
	Name        string
	Description string
	Visibility  string
	// Errors are the problems of the last submit.
	Errors FormErrors
}

RoomNewData is what the page of the new room form shows.

type RoomsBrowseData

type RoomsBrowseData struct {
	// Sidebar is the sidebar of the page.
	Sidebar SidebarData
	// Rooms are the visible rooms.
	Rooms []app.Room
	// Message is the problem of the last action, shown above the list; empty
	// shows none.
	Message string
}

RoomsBrowseData is what the page of the visible rooms shows.

type SSHKeyAddData added in v1.2.0

type SSHKeyAddData struct {
	// Name is the name typed in the form, kept after a failed submit.
	Name string
	// PublicKey is the key typed in the form, kept after a failed submit.
	PublicKey string
	// Errors are the problems of the last submit. Passwords are never put
	// back.
	Errors FormErrors
}

SSHKeyAddData is the Add form of the Sign-in section.

type SearchChip

type SearchChip struct {
	// Label is the filter as it is written in a query, such as "#design" or
	// "room:general".
	Label string
	// Path is the path of the search without this filter: the other words and
	// filters of the query, on the first page.
	Path string
}

SearchChip is a filter of the query, shown as a chip with a link that removes it.

func SearchChips

func SearchChips(q app.Query) []SearchChip

SearchChips returns the chips of the filters of a parsed query, in the order #tags, room, from, after, before, is:post, is:comment. The path of each chip is the search for the query without that filter.

type SearchData

type SearchData struct {
	// Sidebar is the sidebar of the page.
	Sidebar SidebarData
	// Query is the text of the search box, as typed.
	Query string
	// Message is the problem with the query, such as a date that is not a
	// date; empty shows none.
	Message string
	// Searched is true when the query was searched: it is not empty and has
	// no problem. Without it the page shows no results and no "Nothing
	// found.".
	Searched bool
	// Chips are the filters of the query.
	Chips []SearchChip
	// Results are the results of the page.
	Results []app.SearchResult
	// Page is the number of the page, starting at 1.
	Page int
	// HasNext is true when more results follow this page.
	HasNext bool
}

SearchData is what the search page shows. The zero value is the page of an empty query.

type SettingsData added in v1.2.0

type SettingsData struct {
	// Sidebar is the sidebar of the page.
	Sidebar SidebarData
	// Profile, Password, Appearance and Notifications are their sections.
	Profile       ProfileData
	Password      PasswordData
	Appearance    AppearanceData
	Notifications NotifyPrefsData
	// SignIn is the Sign-in section: the SSH keys and the SSH server.
	SignIn SignInData
	// Sessions are the live sessions of the user, the newest first.
	Sessions []app.SessionInfo
}

SettingsData is what the settings page shows.

type SidebarData

type SidebarData struct {
	// User is the logged-in user.
	User app.User
	// Rooms are the rooms the user is a member of, in the order to show.
	Rooms []app.Room
	// CurrentRoomID is the ID of the room whose page is shown, which the
	// sidebar highlights; 0 on every other page.
	CurrentRoomID uint64
	// Unread is the number of unread notifications of the user, shown on the
	// bell; the badge is left out when it is 0.
	Unread int
	// UnreadMessages is the number of conversations of the user with unread
	// messages, shown on the Messages link of the header; the badge is left out
	// when it is 0.
	UnreadMessages int
	// HideSearch leaves out the search box of the header. The search page
	// sets it: it has a box of its own.
	HideSearch bool
	// Theme is the theme of the user, which the theme form of the user menu
	// marks; empty means System.
	Theme app.Theme
	// Ringing is the call that rings for the user, which the ringing dialog
	// of the page shows (SPEC §7.18); nil while none does.
	Ringing *CallInviteData
}

SidebarData is what the shell of a logged-in page shows: the header and the sidebar of rooms.

func (SidebarData) UnreadTotal added in v1.2.0

func (d SidebarData) UnreadTotal() int

UnreadTotal is the number in the title of the tab: the unread notifications plus the conversations with unread messages that are not muted, the same numbers as the bell and the Messages link (SPEC §7.17).

func (SidebarData) WithRoomRead added in v1.2.0

func (d SidebarData) WithRoomRead(roomID uint64) SidebarData

WithRoomRead returns the data with the unread counts of the room roomID set to 0: the page of the room's feed (or its board) has just marked the room as read, and the room being looked at shows nothing waiting. The rooms are copied; the receiver is not changed.

type SignInData added in v1.2.0

type SignInData struct {
	// Keys are the SSH keys of the user, oldest first.
	Keys []app.SSHKey
	// Server is what the section shows of the SSH server.
	Server app.SSHServer
	// Add holds the Add form: the values kept from a submit that failed and
	// its problems under the fields "name", "publicKey" and
	// "currentPassword".
	Add SSHKeyAddData
	// RemoveKeyID is the key whose Remove form has the problems in
	// RemoveErrors; 0 for none.
	RemoveKeyID uint64
	// RemoveErrors are the problems of the last Remove, under the field
	// "currentPassword".
	RemoveErrors FormErrors
	// CodeRequired is true when the user turned on "Ask for an SSH code when
	// I log in".
	CodeRequired bool
	// Code holds the problems of the last submit of the switch, under the
	// fields "form" and "currentPassword".
	Code FormErrors
	// Saved is true right after a key was added or removed, or the switch was
	// used.
	Saved bool
}

SignInData is what the Sign-in section shows (SPEC §7.16).

type SignUpData

type SignUpData struct {
	// Token is the token of the invitation, from the link.
	Token string
	// Username and DisplayName are the values typed in the last submit. The
	// password is never put back.
	Username    string
	DisplayName string
	// Errors are the problems of the last submit.
	Errors FormErrors
}

SignUpData is what the sign-up page and its form show.

type TaskRowData

type TaskRowData struct {
	// ID is the ID of the task for a row that edits one; 0 for a new task.
	ID uint64
	// Title is the text in the title field.
	Title string
	// Assignees are the IDs of the people selected in the picker.
	Assignees []uint64
	// Due is the due date as the date field holds it ("2006-01-02"), or empty.
	Due string
}

TaskRowData is one task row of the editor.

Jump to

Keyboard shortcuts

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