prago

package module
v0.0.0-...-b3c0717 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: MIT Imports: 63 Imported by: 0

README

Prago - simple Go framework

Prago is simple web framework fo Go language I am using for my projects.

https://www.odchazel.com

Documentation

Overview

Package prago is MVC framework for go

Index

Constants

This section is empty.

Variables

View Source
var ErrItemNotFound = errors.New("item not found")

ErrItemNotFound is returned when no item is found

View Source
var ErrWrongWhereFormat = errors.New("wrong where format")

ErrWrongWhereFormat is returned when where query has a bad format

Functions

func AddResourceCustomSearchFunction

func AddResourceCustomSearchFunction[T any](app *App, fn func(q string, userData UserData) []*T)

func Cached

func Cached[T any](app *App, name string, createFn func() T) chan T

func CreateItem

func CreateItem[T any](app *App, item *T) error

func CreateItemWithContext

func CreateItemWithContext[T any](ctx context.Context, app *App, item *T) error

func CreateWithLog

func CreateWithLog[T any](item *T, request *Request) error

func DeleteItem

func DeleteItem[T any](app *App, id int64) error

func DeleteItemWithContext

func DeleteItemWithContext[T any](ctx context.Context, app *App, id int64) error

func DeleteWithLog

func DeleteWithLog[T any](item *T, request *Request) error

func ForEach

func ForEach[T any](app *App, ctx context.Context, handler func(*T) error) error

func IsEmailValid

func IsEmailValid(email string) bool

func IsPhoneNumberValid

func IsPhoneNumberValid(phone string) bool

func ItemStatistic

func ItemStatistic[T any](app *App, name func(string) string, permission Permission, statHandler func(item *T) string)

func MultirelationArrayToString

func MultirelationArrayToString(in []int64) string

func MultirelationStringToArray

func MultirelationStringToArray(in string) (ret []int64)

func PreviewURLFunction

func PreviewURLFunction[T any](app *App, fn func(*T) string)

func Replace

func Replace[T any](ctx context.Context, app *App, item *T) error

func UpdateItem

func UpdateItem[T any](app *App, item *T) error

func UpdateItemWithContext

func UpdateItemWithContext[T any](ctx context.Context, app *App, item *T) error

func UpdateWithLog

func UpdateWithLog[T any](item *T, request *Request) error

func ValidateDelete

func ValidateDelete[T any](app *App, fn func(item *T, validation Validation, userData UserData))

func ValidateUpdate

func ValidateUpdate[T any](app *App, fn func(item *T, validation Validation, userData UserData))

Types

type API

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

func APIJSON

func APIJSON[T any](app *App, url string, handler func(*Request, *T) any) *API

func ResourceAPI

func ResourceAPI[T any](app *App, url string) *API

func (*API) Handler

func (api *API) Handler(handler func(*Request)) *API

func (*API) HandlerJSON

func (api *API) HandlerJSON(handler func(*Request) interface{}) *API

TODO: Deprecated

func (*API) Method

func (api *API) Method(method string) *API

func (*API) Permission

func (api *API) Permission(permission Permission) *API

type Accordion

type Accordion struct {
	Icon string
	Name string
	Text template.HTML
}

type Action

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

Action represents action

func ActionForm

func ActionForm(app *App, url string, formGenerator func(form *Form, request *Request), validator func(fv FormValidation, request *Request)) *Action

func ActionPlain

func ActionPlain(app *App, url string, handler func(*Request)) *Action

func ActionResourceForm

func ActionResourceForm[T any](app *App, url string, formGenerator func(form *Form, request *Request), validation func(fv FormValidation, request *Request)) *Action

func ActionResourceItemForm

func ActionResourceItemForm[T any](
	app *App,
	url string,
	formGenerator func(item *T, form *Form, request *Request),
	validation func(item *T, fv FormValidation, request *Request),
) *Action

func ActionResourceItemPlain

func ActionResourceItemPlain[T any](app *App, url string, fn func(*T, *Request)) *Action

func ActionResourceItemUI

func ActionResourceItemUI[T any](app *App, url string, contentSource func(item *T, request *Request) template.HTML) *Action

func ActionResourceMultipleItemsForm

func ActionResourceMultipleItemsForm[T any](
	app *App,
	url string,
	formGenerator func(items []*T, form *Form, request *Request),
	validation func(items []*T, fv FormValidation, request *Request),
) *Action

func ActionResourcePlain

func ActionResourcePlain[T any](app *App, url string, handler func(*Request)) *Action

func ActionResourceUI

func ActionResourceUI[T any](app *App, url string, content func(*Request) template.HTML) *Action

func ActionUI

func ActionUI(app *App, url string, content func(*Request) template.HTML) *Action

func PopupForm

func PopupForm(app *App, url string, formGenerator func(*Form, *Request), validation func(FormValidation, *Request)) *Action

func (*Action) Board

func (action *Action) Board(board *Board) *Action

func (*Action) Icon

func (action *Action) Icon(icon string) *Action

func (*Action) Method

func (action *Action) Method(method string) *Action

func (*Action) Name

func (action *Action) Name(name func(string) string) *Action

func (*Action) Permission

func (action *Action) Permission(permission Permission) *Action

type Activity

type Activity struct {
	ID           int64
	ResourceID   string
	User         int64
	ActivityType string
}

type Aggregation

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

func (*Aggregation) Count

func (agg *Aggregation) Count() *Aggregation

func (*Aggregation) Get

func (agg *Aggregation) Get() ([]int64, error)

func (*Aggregation) Max

func (agg *Aggregation) Max(fieldName string) *Aggregation

func (*Aggregation) Min

func (agg *Aggregation) Min(fieldName string) *Aggregation

func (*Aggregation) Sum

func (agg *Aggregation) Sum(fieldName string) *Aggregation

type App

type App struct {
	UsersResource *Resource

	FilesResource *Resource

	MainBoard *Board

	EmailSentHandler func(*Email)

	InitializationAfterServerStart func()
	// contains filtered or unexported fields
}

func New

func New(appName, version string) *App

New creates App structure for prago app

func NewTesting

func NewTesting(t *testing.T, initHandler func(app *App)) *App

func (*App) API

func (app *App) API(url string) *API

func (*App) AddCSS

func (app *App) AddCSS(fn func() string)

func (*App) AddCustomSearchFunction

func (app *App) AddCustomSearchFunction(fn func(q string, userData UserData) []*CustomSearchResult)

func (*App) AddDevStaticFiles

func (app *App) AddDevStaticFiles(path string)

AddDevStaticFiles adds path for public files for development and publish them in server's root

func (*App) AddEnumFieldType

func (app *App) AddEnumFieldType(name string, items [][2]string)

func (*App) AddEnumFieldTypeLocalized

func (app *App) AddEnumFieldTypeLocalized(name string, items []FieldTypeEnum)

func (*App) AddJavascript

func (app *App) AddJavascript(fn func() string)

func (*App) AddLessDevelopmentPaths

func (app *App) AddLessDevelopmentPaths(sourcePath, targetPath string)

AddLessDevelopmentPaths compiles less files in sourcePath into targetPath in development mode

func (*App) AddManagerOfRole

func (app *App) AddManagerOfRole(whoRole, whomRole string)

func (*App) AddPragoDevelopmentPath

func (app *App) AddPragoDevelopmentPath(path string)

func (*App) AddSassDevelopmentPaths

func (app *App) AddSassDevelopmentPaths(sourcePath, targetPath string)

func (*App) AddServerSetup

func (app *App) AddServerSetup(fn func(*http.Server))

func (*App) AddStaticFiles

func (app *App) AddStaticFiles(f fs.FS, pathPrefix string)

AddStaticFiles add filesystem of public files and publish them in server's root

func (*App) AddTemplatesDevelopmentPath

func (app *App) AddTemplatesDevelopmentPath(templates *PragoTemplates, watchPath string, matchPatterns ...string)

func (*App) AddTypeScriptDevelopmentPath

func (app *App) AddTypeScriptDevelopmentPath(path string)

AddTypeScriptDevelopmentPath automatically runs compilation of .tsc file in development mode

func (*App) AfterAction

func (app *App) AfterAction(fn func(p *Request))

AddAfterAction adds action which is executed after main router action is called

func (*App) BaseURL

func (app *App) BaseURL() string

func (*App) BeforeAction

func (app *App) BeforeAction(fn func(p *Request))

AddBeforeAction adds action which is executed before main router action is called

func (*App) ClearCache

func (app *App) ClearCache()

func (*App) DevelopmentMode

func (app *App) DevelopmentMode() bool

DevelopmentMode returns if app is running in development mode

func (*App) Email

func (app *App) Email() *Email

func (*App) FormFilter

func (app *App) FormFilter() *FormFilter

func (*App) GenerateCSRFToken

func (app *App) GenerateCSRFToken(userID int64) string

func (*App) GetAdminTemplates

func (app *App) GetAdminTemplates() *PragoTemplates

func (*App) GetAllUsers

func (app *App) GetAllUsers() (ret []UserData)

func (*App) GetAppInfo

func (app *App) GetAppInfo() AppInfo

func (*App) GetCDNVideoURL

func (app *App) GetCDNVideoURL(uuid string) string

func (*App) GetCachedUserEmail

func (app *App) GetCachedUserEmail(id int64) string

func (*App) GetDB

func (app *App) GetDB() *sql.DB

func (*App) GetFiles

func (app *App) GetFiles(ctx context.Context, ids string) []*File

func (*App) GetUserData

func (app *App) GetUserData(id int64) *userData

func (*App) GetVersionString

func (app *App) GetVersionString() string

func (*App) GoogleKey

func (app *App) GoogleKey() string

func (*App) Handle

func (app *App) Handle(method, path string, action func(p *Request), constraints ...routerConstraint)

Get creates new route for GET request

func (*App) HandleSimple

func (app *App) HandleSimple(handler *SimpleHandler)

func (*App) Help

func (app *App) Help(url string, name func(string) string, content func(request *Request) template.HTML)

func (*App) Icon

func (app *App) Icon(icon string) *App

func (*App) IconURL

func (app *App) IconURL() string

func (*App) InstallDatabase

func (app *App) InstallDatabase(rootPassword, codeName string) error

func (*App) ListenActivity

func (app *App) ListenActivity(handler func(Activity))

ListenActivity listens to all changes in app's administration

func (*App) Log

func (app *App) Log() *logger

Log returns logger structure

func (app *App) Logo(logo []byte) *App

Logo sets application public path to logo

func (*App) Mailing

func (app *App) Mailing(locale string, fn func(*MailingData)) error

func (*App) Name

func (app *App) Name(name func(string) string) *App

Name sets localized human name to app

func (*App) NewForm

func (app *App) NewForm(action string) *Form

NewForm creates new form

func (*App) NewServer

func (app *App) NewServer() server

TODO: remove after fixed tests in lazensky

func (*App) Notification

func (app *App) Notification(name string) *Notification

Notification creates notification

func (*App) Permission

func (app *App) Permission(permission Permission) *App

Permission adds permission to admin

func (*App) RandomizationString

func (app *App) RandomizationString() string

func (*App) Role

func (app *App) Role(role string, permissions []Permission) *App

Role adds role to admin

func (*App) Run

func (app *App) Run()

func (*App) SetAfterRequestServedHandler

func (app *App) SetAfterRequestServedHandler(fn func(*Request))

func (*App) SetIcons

func (app *App) SetIcons(iconsFS embed.FS, prefix string)

func (*App) SetLogHandler

func (app *App) SetLogHandler(fn func(string, string))

func (*App) Setting

func (app *App) Setting(id string, permission Permission) *Setting

func (*App) Table

func (app *App) Table() *Table

func (*App) TestUserData

func (app *App) TestUserData(role string) UserData

func (*App) UploadFile

func (app *App) UploadFile(fileHeader *multipart.FileHeader, request *Request, description string) (*File, error)

func (*App) UploadFileFromURL

func (app *App) UploadFileFromURL(ctx context.Context, fileURL string, userID int64, description string) (*File, error)

type AppInfo

type AppInfo struct {
	CodeName string
	Name     func(string) string
	Version  string
}

type Board

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

func (*Board) Child

func (parent *Board) Child(url string, name func(string) string, icon string) *Board

func (*Board) Dashboard

func (board *Board) Dashboard(name func(string) string) *Dashboard

type Button

type Button struct {
	Icon     string
	Name     string
	URL      string
	Selected bool
}

func (*Button) SafeURL

func (b *Button) SafeURL() template.URL

type CustomSearchResult

type CustomSearchResult struct {
	URL      string
	Prename  string
	Name     string
	Priority int64
}

type DBConnectConfig

type DBConnectConfig struct {
	Name     string `json:"name"`
	User     string `json:"user"`
	Password string `json:"password"`
}

func GetDBConnectConfig

func GetDBConnectConfig(codeName string) (*DBConnectConfig, error)

type Dashboard

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

func (*Dashboard) AddFormItemOptions

func (dashboard *Dashboard) AddFormItemOptions(id, name string, options [][2]string)

func (*Dashboard) Figure

func (dashboard *Dashboard) Figure(name func(string) string, permission Permission) *dashboardFigure

func (*Dashboard) Table

func (group *Dashboard) Table(tableFn func(*Request) *Table, permission Permission) *dashboardTable

func (*Dashboard) Timeline

func (dashboard *Dashboard) Timeline(name func(string) string, permission Permission) *Timeline

type DashboardFormItem

type DashboardFormItem struct {
	ID       string
	Name     string
	Template string
	Value    string
	Options  [][2]string
}

type Email

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

func (*Email) Attachement

func (email *Email) Attachement(filename string, content []byte) *Email

func (*Email) From

func (email *Email) From(name, emailAddress string) *Email

func (*Email) HTMLContent

func (email *Email) HTMLContent(content string) *Email

func (*Email) Send

func (email *Email) Send() error

func (*Email) Subject

func (email *Email) Subject(subject string) *Email

func (*Email) TextContent

func (email *Email) TextContent(content string) *Email

func (*Email) To

func (email *Email) To(name, emailAddress string) *Email

type Field

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

func (*Field) DBDescription

func (field *Field) DBDescription(description string) *Field

func (*Field) Description

func (field *Field) Description(description func(string) string) *Field

func (*Field) FixStringValue

func (field *Field) FixStringValue(fn func(string) string) *Field

func (*Field) FormContentGenerator

func (field *Field) FormContentGenerator(fn func(item *FormItem) template.HTML) *Field

func (*Field) FormFilter

func (field *Field) FormFilter(filter *FormFilter) *Field

func (*Field) GetManuallySetPluralName

func (field *Field) GetManuallySetPluralName(locale string) string

func (*Field) HelpURL

func (field *Field) HelpURL(url string) *Field

func (*Field) IsSearchable

func (field *Field) IsSearchable(isSearchable bool) *Field

func (*Field) Name

func (field *Field) Name(name func(string) string) *Field

func (*Field) SuggestionURL

func (field *Field) SuggestionURL(suggestionURL string) *Field

func (*Field) TextOver

func (field *Field) TextOver(textOver func(string) string) *Field

func (*Field) Validation

func (field *Field) Validation(fn func(fieldVal any, userData UserData) error)

func (*Field) ViewContentGenerator

func (field *Field) ViewContentGenerator(fn func(val any) template.HTML) *Field

type FieldTypeEnum

type FieldTypeEnum struct {
	ID   string
	Name func(string) string
}

type File

type File struct {
	ID          int64  `prago-order-desc:"true"`
	UID         string `prago-unique:"true" prago-type:"cdnfile"`
	Name        string `prago-can-edit:"nobody"`
	Description string `prago-type:"text"`
	User        int64  `prago-type:"relation" prago-can-edit:"nobody"`
	Width       int64  `prago-can-edit:"nobody"`
	Height      int64  `prago-can-edit:"nobody"`
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

File is structure representing files in admin

func (*File) GetExactSize

func (f *File) GetExactSize(width, height int) string

func (*File) GetGiant

func (f *File) GetGiant() string

func (*File) GetLarge

func (f *File) GetLarge() string

func (*File) GetMedium

func (f *File) GetMedium() string

func (*File) GetOriginal

func (f *File) GetOriginal() string

func (*File) GetSmall

func (f *File) GetSmall() string

func (*File) IsImage

func (f *File) IsImage() bool

type Form

type Form struct {
	Action                 string
	Icon                   string
	Title                  string
	Description            string
	Items                  []*FormItem
	Valid                  bool
	CSRFToken              string
	HTMLAfter              template.HTML
	AutosubmitFirstTime    bool
	AutosubmitOnDataChange bool
	ScriptPaths            []string
	// contains filtered or unexported fields
}

Form represents admin form

func (*Form) AddCAPTCHAInput

func (f *Form) AddCAPTCHAInput(name, description string) *FormItem

AddCAPTCHAInput to form

func (*Form) AddCSRFToken

func (form *Form) AddCSRFToken(request *Request) *Form

func (*Form) AddCheckbox

func (f *Form) AddCheckbox(name, description string) *FormItem

AddCheckbox to form

func (*Form) AddDatePicker

func (f *Form) AddDatePicker(name, description string) *FormItem

AddDatePicker to form

func (*Form) AddDateTimePicker

func (f *Form) AddDateTimePicker(name, description string) *FormItem

func (*Form) AddDeleteSubmit

func (f *Form) AddDeleteSubmit(description string) *FormItem

AddDeleteSubmit to form

func (*Form) AddEmailInput

func (f *Form) AddEmailInput(name, description string) *FormItem

AddEmailInput to form

func (*Form) AddFileInput

func (f *Form) AddFileInput(name, description string) *FormItem

AddFileInput to form

func (*Form) AddHidden

func (f *Form) AddHidden(name string) *FormItem

AddHidden to form

func (*Form) AddItem

func (f *Form) AddItem(item *FormItem)

AddItem adds form item

func (*Form) AddNumberInput

func (f *Form) AddNumberInput(name, description string) *FormItem

func (*Form) AddPasswordInput

func (f *Form) AddPasswordInput(name, description string) *FormItem

AddPasswordInput to form

func (*Form) AddRadio

func (f *Form) AddRadio(name, description string, values [][2]string) *FormItem

func (*Form) AddRelation

func (f *Form) AddRelation(name, description string, relatedResourceID string) *FormItem

func (*Form) AddRelationMultiple

func (f *Form) AddRelationMultiple(name, description string, relatedResourceID string) *FormItem

func (*Form) AddSelect

func (f *Form) AddSelect(name, description string, values [][2]string) *FormItem

AddSelect to form

func (*Form) AddSubmit

func (f *Form) AddSubmit(description string) *FormItem

AddSubmit to form

func (*Form) AddTextInput

func (f *Form) AddTextInput(name, description string) *FormItem

AddTextInput to form

func (*Form) AddTextareaInput

func (f *Form) AddTextareaInput(name, description string) *FormItem

AddTextareaInput to form

func (*Form) BindData

func (f *Form) BindData(params url.Values)

BindData to form

func (*Form) GetBoxHeader

func (form *Form) GetBoxHeader() *boxHeader

type FormFilter

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

func (*FormFilter) Is

func (filter *FormFilter) Is(name string, value interface{}) *FormFilter

func (*FormFilter) Where

func (filter *FormFilter) Where(condition string, values ...interface{}) *FormFilter

type FormItem

type FormItem struct {
	ID                 string
	Icon               string
	Name               string
	Description        string
	DescriptionsBefore []string
	DescriptionsAfter  []string
	Placeholder        string
	Required           bool
	Focused            bool
	Readonly           bool
	HiddenName         bool
	Hidden             bool
	Template           string
	Value              string
	Data               interface{}

	Content template.HTML

	TextOver string

	UUID string

	Autocomplete string
	InputMode    string

	HelpURL string

	FileMultiple bool
	FileAccept   string

	FormFilterID string

	SuggestionURL string
	// contains filtered or unexported fields
}

FormItem represents item of form

func (*FormItem) AddFromFilter

func (f *FormItem) AddFromFilter(formFilter *FormFilter)

func (*FormItem) AddUUID

func (f *FormItem) AddUUID()

AddUUID to form

func (*FormItem) GetContent

func (fi *FormItem) GetContent() template.HTML

type FormTaskActivity

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

func (*FormTaskActivity) Description

func (fta *FormTaskActivity) Description(description string)

func (*FormTaskActivity) Progress

func (fta *FormTaskActivity) Progress(finishedSoFar, total int64)

func (*FormTaskActivity) TableCells

func (fta *FormTaskActivity) TableCells(cells ...*TableCell)

type FormTaskView

type FormTaskView struct {
	Description  string
	Progress     float64
	ProgressText string
	Finished     bool
	TableRows    template.HTML
}

type FormValidation

type FormValidation interface {
	AddError(err string)
	AddOK(err string)
	AddItemError(key, err string)
	Valid() bool
	Redirect(string)
	AfterContent(template.HTML)
	RunTask(*Request, func(*FormTaskActivity) error)
	Data(any)
}

type ImagePickerImage

type ImagePickerImage struct {
	UUID             string
	ImageName        string
	ImageDescription string
	ViewURL          string
	EditURL          string
	ThumbURL         string

	Metadata [][2]string
}

type ImagePickerResponse

type ImagePickerResponse struct {
	Items []*ImagePickerImage
}

type MailingData

type MailingData struct {
	App     *App
	BaseURL string
	LogoURL string
	AppName string

	FromEmail string
	FromName  string

	Tos []*MailingRecipient

	Subject string

	PreName  string
	Name     string
	PostName string

	Images []*File

	Description template.HTML

	Text template.HTML

	Sections []*MailingDataSection

	Button *Button

	FooterDescription template.HTML
}

func (*MailingData) AddRecipient

func (md *MailingData) AddRecipient(name, email string) *MailingData

func (*MailingData) AddSection

func (md *MailingData) AddSection(name, text string) *MailingDataSection

type MailingDataSection

type MailingDataSection struct {
	Name string
	Text string
}

type MailingRecipient

type MailingRecipient struct {
	Name  string
	Email string
}

type Notification

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

NotificationItem represents item for notification

func (*Notification) Flash

func (n *Notification) Flash(request *Request) error

func (*Notification) Push

func (n *Notification) Push(userID int64)

func (*Notification) SetDescription

func (n *Notification) SetDescription(description string) *Notification

SetDescription sets description to notification item

func (*Notification) SetImage

func (n *Notification) SetImage(image string) *Notification

func (*Notification) SetPreName

func (n *Notification) SetPreName(preName string) *Notification

SetPreName sets prefix name to notification item

func (*Notification) SetPrimaryAction

func (n *Notification) SetPrimaryAction(name string, fn func()) *Notification

func (*Notification) SetProgress

func (n *Notification) SetProgress(progress *float64) *Notification

SetProgress sets description to notification item

func (*Notification) SetSecondaryAction

func (n *Notification) SetSecondaryAction(name string, fn func()) *Notification

func (*Notification) SetStyleFail

func (n *Notification) SetStyleFail() *Notification

SetTypeFail sets notification item type to fail

func (*Notification) SetStyleSuccess

func (n *Notification) SetStyleSuccess() *Notification

SetTypeSuccess sets notification item type to success

func (*Notification) SetURL

func (n *Notification) SetURL(url string) *Notification

type PageDataSimple

type PageDataSimple struct {
	Request *Request

	BackButton *Button

	PreName  string
	Name     string
	PostName string

	Sections []*SimpleSection

	Description template.HTML
	Text        template.HTML

	Form func(*Form)

	PrimaryButton *Button

	AnalyticsCode template.HTML

	FooterText template.HTML
}

type Permission

type Permission string

Permission for access

type PragoTemplates

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

func NewPragoTemplates

func NewPragoTemplates() *PragoTemplates

func (*PragoTemplates) Execute

func (templates *PragoTemplates) Execute(wr io.Writer, name string, data interface{}) error

func (*PragoTemplates) ExecuteToHTML

func (templates *PragoTemplates) ExecuteToHTML(templateName string, data interface{}) template.HTML

func (*PragoTemplates) ExecuteToString

func (templates *PragoTemplates) ExecuteToString(templateName string, data interface{}) string

func (*PragoTemplates) Function

func (templates *PragoTemplates) Function(name string, f interface{})

func (*PragoTemplates) SetFilesystem

func (templates *PragoTemplates) SetFilesystem(fsys fs.FS, patterns ...string) error

type Preview

type Preview struct {
	ID          int64
	Image       string
	ImageID     string
	URL         string
	Name        string
	Description string
}

type QueryData

type QueryData[T any] struct {
	// contains filtered or unexported fields
}

func Query

func Query[T any](app *App) *QueryData[T]

func (*QueryData[T]) Aggregation

func (q *QueryData[T]) Aggregation() *Aggregation

func (*QueryData[T]) Context

func (q *QueryData[T]) Context(ctx context.Context) *QueryData[T]

func (*QueryData[T]) Count

func (q *QueryData[T]) Count() (int64, error)

func (*QueryData[T]) Debug

func (q *QueryData[T]) Debug() *QueryData[T]

func (*QueryData[T]) First

func (q *QueryData[T]) First() *T

func (*QueryData[T]) ID

func (q *QueryData[T]) ID(id any) *T

func (*QueryData[T]) In

func (q *QueryData[T]) In(name string, value any) *QueryData[T]

func (*QueryData[T]) Is

func (q *QueryData[T]) Is(name string, value interface{}) *QueryData[T]

func (*QueryData[T]) Limit

func (q *QueryData[T]) Limit(limit int64) *QueryData[T]

func (*QueryData[T]) List

func (q *QueryData[T]) List() []*T

func (*QueryData[T]) Offset

func (q *QueryData[T]) Offset(offset int64) *QueryData[T]

func (*QueryData[T]) Order

func (q *QueryData[T]) Order(order string) *QueryData[T]

func (*QueryData[T]) OrderDesc

func (q *QueryData[T]) OrderDesc(order string) *QueryData[T]

func (*QueryData[T]) Where

func (q *QueryData[T]) Where(condition string, values ...interface{}) *QueryData[T]

type Request

type Request struct {
	Written        bool
	ResponseStatus int
	//ResponseTemplates    *PragoTemplates
	ResponseTemplateName string
	// contains filtered or unexported fields
}

Request represents structure for http request

func (*Request) AddFlashMessage

func (request *Request) AddFlashMessage(message string)

AddFlashMessage adds flash message to request

func (*Request) Authorize

func (request *Request) Authorize(permission Permission) bool

func (*Request) Duration

func (request *Request) Duration() time.Duration

func (*Request) Email

func (request *Request) Email() string

func (*Request) Locale

func (request *Request) Locale() string

func (*Request) Name

func (request *Request) Name() string

func (Request) Param

func (request Request) Param(name string) string

func (Request) Params

func (request Request) Params() url.Values

Params returns url.Values of request

func (*Request) Phone

func (request *Request) Phone() string

func (*Request) Redirect

func (request *Request) Redirect(url string)

Redirect redirects request to new url

func (Request) Request

func (request Request) Request() *http.Request

Request returns underlying http.Request

func (Request) Response

func (request Request) Response() http.ResponseWriter

Response returns underlying http.ResponseWriter

func (*Request) UserID

func (request *Request) UserID() int64

UserID returns id of logged in user, returns 0 if no user is logged

func (*Request) WriteHTML

func (request *Request) WriteHTML(statusCode int, templates *PragoTemplates, templateName string, data any)

WriteHTML renders HTML view with HTTP code

func (*Request) WriteJSON

func (request *Request) WriteJSON(statusCode int, data interface{})

WriteJSON renders JSON with HTTP code

type Resource

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

func NewResource

func NewResource[T any](app *App) *Resource

func (*Resource) Board

func (resource *Resource) Board(board *Board) *Resource

func (*Resource) Dashboard

func (resource *Resource) Dashboard(name func(string) string) *Dashboard

func (*Resource) DefaultValue

func (resource *Resource) DefaultValue(fieldName string, fn func(*Request) string)

func (*Resource) Field

func (resource *Resource) Field(name string) *Field

func (*Resource) Icon

func (resource *Resource) Icon(icon string) *Resource

func (*Resource) ItemsPerPage

func (resource *Resource) ItemsPerPage(itemsPerPage int64) *Resource

func (*Resource) Name

func (resource *Resource) Name(singularName, pluralName func(string) string) *Resource

func (*Resource) PermissionCreate

func (resource *Resource) PermissionCreate(permission Permission) *Resource

func (*Resource) PermissionDelete

func (resource *Resource) PermissionDelete(permission Permission) *Resource

func (*Resource) PermissionExport

func (resource *Resource) PermissionExport(permission Permission) *Resource

func (*Resource) PermissionUpdate

func (resource *Resource) PermissionUpdate(permission Permission) *Resource

func (*Resource) PermissionView

func (resource *Resource) PermissionView(permission Permission) *Resource

type Setting

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

func (*Setting) DefaultValue

func (setting *Setting) DefaultValue(defaultValue string) *Setting

func (*Setting) GetValue

func (setting *Setting) GetValue() string

func (*Setting) Name

func (setting *Setting) Name(name func(string) string) *Setting

func (*Setting) ValueChangeCallback

func (setting *Setting) ValueChangeCallback(fn func()) *Setting

type SimpleHandler

type SimpleHandler struct {
	URL string

	Handler        func(*PageDataSimple)
	FormValidation func(FormValidation, *Request)
}

type SimpleSection

type SimpleSection struct {
	Icon        string
	Name        string
	Description string
	Text        template.HTML
	LogoURL     string

	Table *Table

	PrimaryButton *Button
	Buttons       []*Button

	Accordions []*Accordion
}

type Suggestion

type Suggestion struct {
	ID          int64
	Image       string
	URL         string
	Name        string
	Description string
}

type Suggestions

type Suggestions struct {
	Message     string
	Suggestions []*Suggestion
	Button      *SuggestionsButton
}

type SuggestionsButton

type SuggestionsButton struct {
	Name    string
	FormURL string
}

type Table

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

func (*Table) AddFooterText

func (t *Table) AddFooterText(text string)

func (*Table) Cell

func (table *Table) Cell(item any) *TableCell

func (*Table) ExecuteHTML

func (t *Table) ExecuteHTML() template.HTML

TODO execute right into response

func (*Table) ExportXLSX

func (t *Table) ExportXLSX(writer io.Writer) error

func (*Table) Header

func (table *Table) Header(items ...string) *Table

func (*Table) Javascript

func (table *Table) Javascript(javascript template.JS) *Table

func (*Table) Row

func (table *Table) Row(items ...*TableCell) *Table

func (*Table) Table

func (table *Table) Table() *Table

type TableCell

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

func Cell

func Cell(item interface{}) *TableCell

func (*TableCell) AsyncDataURL

func (cell *TableCell) AsyncDataURL(url string) *TableCell

func (*TableCell) Button

func (cell *TableCell) Button(btn *TableCellButton) *TableCell

func (*TableCell) CSSClass

func (cell *TableCell) CSSClass(class string) *TableCell

func (*TableCell) Center

func (cell *TableCell) Center() *TableCell

func (*TableCell) Checkbox

func (cell *TableCell) Checkbox(name string, checked bool) *TableCell

func (*TableCell) Colspan

func (cell *TableCell) Colspan(i int64) *TableCell

func (*TableCell) DescriptionAfter

func (cell *TableCell) DescriptionAfter(description string) *TableCell

func (*TableCell) DescriptionBefore

func (cell *TableCell) DescriptionBefore(description string) *TableCell

func (*TableCell) Files

func (cell *TableCell) Files(app *App, fileIDs string) *TableCell

func (*TableCell) Green

func (cell *TableCell) Green() *TableCell

func (*TableCell) Header

func (cell *TableCell) Header() *TableCell

func (*TableCell) Nowrap

func (cell *TableCell) Nowrap() *TableCell

func (*TableCell) Orange

func (cell *TableCell) Orange() *TableCell

func (*TableCell) Pre

func (cell *TableCell) Pre() *TableCell

func (*TableCell) Progress

func (cell *TableCell) Progress(progress float64) *TableCell

func (*TableCell) Red

func (cell *TableCell) Red() *TableCell

func (*TableCell) Right

func (cell *TableCell) Right() *TableCell

func (*TableCell) Rowspan

func (cell *TableCell) Rowspan(i int64) *TableCell

func (*TableCell) Style

func (cell *TableCell) Style(style template.CSS) *TableCell

func (*TableCell) TextAfter

func (cell *TableCell) TextAfter(text string) *TableCell

func (*TableCell) URL

func (cell *TableCell) URL(link string) *TableCell

type TableCellAsyncData

type TableCellAsyncData struct {
	DescriptionsBefore []string
	Text               string
	DescriptionsAfter  []string

	Green  bool
	Orange bool
	Red    bool
}

type TableCellButton

type TableCellButton struct {
	Name    string
	Icon    string
	URL     string
	OnClick template.JS
	Title   string
}

func (TableCellButton) GetTitle

func (btn TableCellButton) GetTitle() string

type TemporaryCacheData

type TemporaryCacheData[T any] struct {
	// contains filtered or unexported fields
}

func TemporaryCache

func TemporaryCache[T any](app *App) *TemporaryCacheData[T]

func (TemporaryCacheData[T]) GetItemByID

func (tc TemporaryCacheData[T]) GetItemByID(id int64) *T

type Timeline

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

func (*Timeline) DataSource

func (timeline *Timeline) DataSource(dataSource func(request *TimelineDataRequest) float64) *TimelineDataSource

func (*Timeline) GetLegend

func (timeline *Timeline) GetLegend(locale string) *timelineLegend

type TimelineDataRequest

type TimelineDataRequest struct {
	From    time.Time
	To      time.Time
	Context context.Context
}

type TimelineDataSource

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

func (*TimelineDataSource) Name

func (tds *TimelineDataSource) Name(name func(string) string) *TimelineDataSource

func (*TimelineDataSource) Stringer

func (tds *TimelineDataSource) Stringer(stringer func(float64) string) *TimelineDataSource

type UserData

type UserData interface {
	Name() string
	Locale() string
	Email() string
	Phone() string
	Authorize(Permission) bool
	UserID() int64
}

type Validation

type Validation interface {
	AddError(err string)
	AddItemError(key, err string)
	Valid() bool
}

type ValidationError

type ValidationError struct {
	OK    bool
	Field string
	Text  string
}

func TestValidationDelete

func TestValidationDelete[T any](app *App, item *T, user UserData) ([]ValidationError, bool)

func TestValidationUpdate

func TestValidationUpdate[T any](app *App, item *T, user UserData) ([]ValidationError, bool)

type Writer

type Writer[T any] struct {
	// contains filtered or unexported fields
}

func NewWriter

func NewWriter[T any](app *App, templates *PragoTemplates, templateName string) *Writer[T]

func (*Writer[T]) After

func (w *Writer[T]) After(fn func(*Request, *T)) *Writer[T]

func (*Writer[T]) Before

func (w *Writer[T]) Before(fn func(*Request, *T)) *Writer[T]

func (*Writer[T]) GET

func (w *Writer[T]) GET(path string, handler func(*Request, *T), constraints ...routerConstraint)

func (*Writer[T]) POST

func (w *Writer[T]) POST(path string, handler func(*Request, *T), constraints ...routerConstraint)

Source Files

Directories

Path Synopsis
pragobleve module

Jump to

Keyboard shortcuts

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