package view

import "hauru.club/x/okrzeja/web/view"

Package view implements interactive UI layer of the Okrzeja application with reusable components and javascript libraries for hypermedia-based applications: HTMX (https://htmx.org) and Alpine.js (https://alpinejs.dev).

Index

Functions

func Account

func Account(props AccountProps) g.Node

Account holds navigation tiles for user's account.

func Activities

func Activities(entries ActivityEntries) g.Node

Activities component shows list of activities with proper title and subtitle.

func Admin

func Admin(props AdminProps) g.Node

Admin component renders admin panel for administrative tasks.

func AdminAddBatchOfUsers

func AdminAddBatchOfUsers() g.Node

AdminAddBatchOfUsers wraps AdminAddBatchOfUsersForm with header element which consists of title and explanation what how to use this component.

func AdminAddBatchOfUsersForm

func AdminAddBatchOfUsersForm() g.Node

AdminAddBatchOfUsersForm allows admins to add batch of users at once.

Form input is being edited dynamically on the browser side with the client-side JavaScript and then submitted to the Okrzeja server with the HTMX.

func AdminBatchOfUsersFormSuccess

func AdminBatchOfUsersFormSuccess(props AdminBatchOfUsersFormSuccessProps) g.Node

AdminBatchOfUsersFormSuccess is displayed when admin user successfully registers batch of users.

func AdminConfigForm

func AdminConfigForm(c Config) g.Node

AdminConfigForm renders form with fields related to the system's dynamic configuration. It allows admin to change configuration variables and see effects taken place immediately after change.

func AdminLoadMoreUsers

func AdminLoadMoreUsers(lastID, search string) g.Node

AdminLoadMoreUsers is component that loads more users accounts for admin panel when revealed. It loads admin accounts that were created before account of user with given ID.

func AdminResetPasswordForm

func AdminResetPasswordForm(password, id string) g.Node

AdminResetPasswordForm renders form for password reset targeted for user with given id. Given password is applied as new password that can be copied into clipboard and it will be sent with the form as new password for the given user.

func AdminSuccessfulPasswordChange

func AdminSuccessfulPasswordChange(id string) g.Node

AdminSuccessfulPasswordChange is message box that can be rendered after successful password change procedure in the admin panel.

func AdminUserActions

func AdminUserActions(id string) g.Node

AdminUserOptions holds available administrative actions for user that can be performed by administrator in the admin panel.

func AdminUserSummary

func AdminUserSummary(props AdminUserSummaryProps) g.Node

AdminUserSummary is admin panel component which shows informations about single user and possible administrative actions.

func DefaultLayout

func DefaultLayout(p LayoutProps) g.Node

DefaultLayout is default layour wrapper for page with custom content.

func Editor

func Editor(content string) g.Node

Editor is textarea-based code editor component.

func EditorLayout

func EditorLayout(props EditorLayoutProps) g.Node

EditorLayout is layout for page with code editor.

func Error

func Error(props ErrorProps) g.Node

Error renders HTML error view component with error message and corresponding HTTP error code.

func FieldsNewDirectory

func FieldsNewDirectory() g.Node

FieldsNewDirectory holds article with new directory input fields for new file form.

func FieldsNewFile

func FieldsNewFile() g.Node

FieldsNewFile holds article with new file input fields for new file form.

func File

func File(props FileProps) g.Node

File is component for viewing file properties.

func FileCreated

func FileCreated(props FileCreatedProps) g.Node

FileCreated view renders message about successfully created file.

func FileName

func FileName(props FileNameProps) g.Node

FileName view component for inspecting and changing name of the particular file.

func FormNewFile

func FormNewFile(id string) g.Node

FormNewFile is form for submitting new file.

func HeroFormLayout

func HeroFormLayout(props HeroFormLayoutProps) g.Node

HeroFormLayout is special layout for custom forms with inputs on one side and hero image on the other side.

func Index

func Index(signedIn bool, csrfToken string) g.Node

Index is layout for main index page.

func LoginForm

func LoginForm() g.Node

LoginForm allows users to sign in into the system.

func Logout

func Logout(username string) g.Node

Logout view component. It redirects user to the index page soon after load.

func RegisterForm

func RegisterForm() g.Node

RegisterForm view component.

func RegisterSuccess

func RegisterSuccess() g.Node

RegisterSuccess is article web component shown after successful registration.

func Settings

func Settings(userID string) g.Node

Settings is component which allows users to adjust their account's settings.

func SettingsChangePasswordForm

func SettingsChangePasswordForm(userID string) g.Node

SettingsChangePasswordForm allows users to change their passwords with assumption that they know their older password.

func SettingsChangePasswordSuccess

func SettingsChangePasswordSuccess(userID string) g.Node

SettingsChangePasswordSuccess shows message about successful password changer requested by the user itself.

func Website

func Website(username string) g.Node

Website is component for presenting website link for user with given username inside list of websites.

func Websites

func Websites(usernames []string) g.Node

func WebsitesLoadMore

func WebsitesLoadMore(last, search string) g.Node

WebsitesLoadMore is component that loads more users websites links when revealed. It loads websites for accounts that were created before account with given last username.

Types

type AccountProps

type AccountProps struct {
	// Username of session's owner.
	Username string

	// UserID is unique user's ID.
	UserID string

	// RootID is unique identifier of root directory.
	RootID string

	// IsAdmin is true if user requesting this view is considered
	// an admin account.
	IsAdmin bool
}

AccountProps holds properties for Account page view.

type ActivityDetail

type ActivityDetail struct {
	// Key for detail.
	Key string

	// Value of detail associated with key.
	Value string
}

ActivityDetail holds single details entry for details component.

type ActivityEntries

type ActivityEntries []ActivityProps

ActivityEntries renders list of activities and prepare loader for more for more activities if there is need.

func (ActivityEntries) Render

func (ae ActivityEntries) Render(w io.Writer) error

Render renders list of activities in the given writer.

type ActivityProps

type ActivityProps struct {
	// Title of the activity.
	Title string

	// Type is the type of the activity.
	Type string

	// ID of activity.
	ID string

	// OwnerID is unique identifier of owner of this activity.
	OwnerID string

	// CreatedAt points to the point in time when given activity
	// was created.
	CreatedAt time.Time

	// Details holds debug key/values associated with given activity.
	Details []ActivityDetail

	// FileID is unique file's identifier. This field is optional, if filled with
	// human readable ID, it points to the file associated with given activity. It
	// can be filled for activities related to creation, edits etc. of files.
	FileID string
}

ActivityProps holds properties for single activity component in the Activity account section.

type AdminBatchOfUsersFormSuccessProps

type AdminBatchOfUsersFormSuccessProps struct {
	CSVEncodedReport string
}

AdminBatchOfUsersFormSuccessProps holds properties for rendering AdminBatchOfUsersFormSuccess.

type AdminProps

type AdminProps struct {
	Config Config
	Users  []UserModelForAdminPanel
}

AdminProps holds properties for Admin page view.

type AdminUserSummaryProps

type AdminUserSummaryProps struct {
	// ID is unique user identifier.
	ID string

	// Username of the user.
	Username string

	// CreatedAt is time when user account was created.
	CreatedAt time.Time
}

AdminUserSummaryProps holds properties for AdminUserSummary component.

type Config

type Config struct {
	RegisterForm bool
}

Config holds dynamic configuration variables for view components.

type EditorLayoutProps

type EditorLayoutProps struct {
	CSRFSignature string
	ParentID      string
	EditorProps
}

EditorLayoutProps holds properties of EditorLayout.

type EditorProps

type EditorProps struct {
	ID       string
	FileName string
	Content  string
}

EditorProps holds properties for Editor component.

type ErrorProps

type ErrorProps struct {
	// Code is HTTP error code.
	Code int

	// Title of error.
	Title string

	// Body is error message.
	Body string
}

ErrorProps holds properties for error view.

type FileChildProps

type FileChildProps struct {
	// ID is unique id of the file.
	ID string

	// Name of the file.
	Name string

	// MIME is MIME-type of the file.
	MIME string
}

FileChildProps holds properties for a file which is children of directory file.

type FileCreatedProps

type FileCreatedProps struct {
	// ID is unique id of the file.
	ID string

	// ParentID is unique id of the parent directory.
	ParentID string
}

FileCreatedProps holds properties for FileCreated page view.

type FileNameProps

type FileNameProps struct {
	ID   string
	Name string
}

FileNameProps holds properties for FileName component.

type FileProps

type FileProps struct {
	// ID is unique id of the file.
	ID string

	// ParentID is unique id of the parent directory. Empty string means
	// that this file hasn't any parent (it must be a root directory then).
	ParentID string

	// Name of the file.
	Name string

	// MIME is MIME-type of the file.
	MIME string

	// Content of the file. Directory's content is always nil.
	Content []byte

	// Children of file. This slice is empty, if file is not a directory.
	Children []FileChildProps
}

FileProps holds properties of a file.

func (FileProps) IsDirectory

func (f FileProps) IsDirectory() bool

type HeroFormLayoutProps

type HeroFormLayoutProps struct {
	Title     string
	SignedIn  bool
	CSRFToken string
	Content   g.Node
}

HeroFormLayoutProps holds arguments for login layout.

type LayoutProps

type LayoutProps struct {
	Title     string
	SignedIn  bool
	CSRFToken string
	Content   g.Node
}

LayoutProps holds arguments for rendering layout.

type UserModelForAdminPanel

type UserModelForAdminPanel struct {
	Username  string
	ID        string
	CreatedAt time.Time
}

UserModelForAdminPanel holds required properties, for Admin view, to show list of users to edit.

Source Files

activities.go admin.go editor.go files.go htmx.go icons.go index.go login.go register.go settings.go vcs.go view.go websites.go

Directories

PathSynopsis
web/view/alpinePackage alpine implements HTML gomponents attributes for alpinejs, lightweight JavaScript framework.
Version
v0.0.0-20231010043146-4292577f982b (latest)
Published
Oct 10, 2023
Platform
linux/amd64
Imports
12 packages
Last checked
1 day ago

Tools for package owners.