admin

package
v0.0.0-...-fd00b2c Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateMusicFilename

func GenerateMusicFilename(song radio.Song) (string, error)

GenerateMusicFilename generates a filename that can be used to store the song.

func GenerateSongURL

func GenerateSongURL(ss secret.Secret, song radio.Song) string

func Route

func Route(ctx context.Context, s State) func(chi.Router)

Types

type HomeInput

type HomeInput struct {
	middleware.Input
	Daypass string
}

func NewHomeInput

func NewHomeInput(r *http.Request, dp secret.Secret) HomeInput

func (HomeInput) TemplateBundle

func (HomeInput) TemplateBundle() string

type PendingForm

type PendingForm struct {
	radio.PendingSong

	Errors map[string]string
}

func NewPendingForm

func NewPendingForm(song radio.PendingSong, form url.Values) (PendingForm, error)

NewPendingForm creates a PendingForm with song as a base and updating those values from the form values given.

func (PendingForm) TemplateBundle

func (PendingForm) TemplateBundle() string

func (PendingForm) TemplateName

func (PendingForm) TemplateName() string

func (*PendingForm) ToSong

func (pf *PendingForm) ToSong(user radio.User) radio.Song

func (*PendingForm) ToValues

func (pf *PendingForm) ToValues() url.Values

func (*PendingForm) Update

func (pf *PendingForm) Update(form url.Values)

func (*PendingForm) Validate

func (pf *PendingForm) Validate() bool

type PendingInput

type PendingInput struct {
	middleware.Input
	Submissions []PendingForm
}

func NewPendingInput

func NewPendingInput(r *http.Request) PendingInput

func (*PendingInput) Hydrate

func (pi *PendingInput) Hydrate(s radio.SubmissionStorage) error

Hydrate hydrates the PendingInput with information from the SubmissionStorage

func (PendingInput) TemplateBundle

func (PendingInput) TemplateBundle() string

type ProfileForm

type ProfileForm struct {
	radio.User
	// separate struct for password change handling
	Change ProfileFormChange
	// permissions are separate too because gorilla does not like maps
	Permissions []radio.UserPermission
	// errors that occured while parsing the form
	Error error
}

ProfileForm defines the form we use for the profile page

type ProfileFormChange

type ProfileFormChange struct {
	Password         string
	NewPassword      string
	RepeatedPassword string
}

type SongsForm

type SongsForm struct {
	Errors map[string]string

	// HasDelete indicates if we should show the delete button
	HasDelete bool
	// HasEdit indicates if we should allow editing of the form
	HasEdit bool
	Song    radio.Song
	SongURL string
}

func NewSongsForm

func NewSongsForm(ts radio.TrackStorage, user radio.User, values url.Values) (*SongsForm, error)

func (SongsForm) TemplateBundle

func (SongsForm) TemplateBundle() string

func (SongsForm) TemplateName

func (SongsForm) TemplateName() string

func (*SongsForm) Validate

func (sf *SongsForm) Validate() bool

type SongsInput

type SongsInput struct {
	middleware.Input

	Forms []SongsForm
	Query string
	Page  *shared.Pagination
}

func NewSongsInput

func NewSongsInput(s radio.SearchService, ss secret.Secret, r *http.Request) (*SongsInput, error)

func (SongsInput) TemplateBundle

func (SongsInput) TemplateBundle() string

type State

type State struct {
	config.Config

	Daypass          secret.Secret
	SongSecret       secret.Secret
	News             *shared.NewsCache
	Storage          radio.StorageService
	Search           radio.SearchService
	Templates        *templates.Site
	TemplateExecutor templates.Executor
	SessionManager   *scs.SessionManager
	Authentication   vmiddleware.Authentication
	FS               afero.Fs
}

func NewState

func NewState(
	_ context.Context,
	cfg config.Config,
	dp secret.Secret,
	songSecret secret.Secret,
	newsCache *shared.NewsCache,
	storage radio.StorageService,
	search radio.SearchService,
	siteTmpl *templates.Site,
	exec templates.Executor,
	sessionManager *scs.SessionManager,
	auth vmiddleware.Authentication,
	fs afero.Fs,
) State

func (*State) GetHome

func (s *State) GetHome(w http.ResponseWriter, r *http.Request)

func (*State) GetPending

func (s *State) GetPending(w http.ResponseWriter, r *http.Request)

func (*State) GetPendingSong

func (s *State) GetPendingSong(w http.ResponseWriter, r *http.Request)

func (*State) GetProfile

func (s *State) GetProfile(w http.ResponseWriter, r *http.Request)

GetProfile is mounted under /admin/profile and shows the currently logged in users profile

func (*State) GetSongs

func (s *State) GetSongs(w http.ResponseWriter, r *http.Request)

func (State) GetUsersList

func (s State) GetUsersList(w http.ResponseWriter, r *http.Request)

func (*State) PostPending

func (s *State) PostPending(w http.ResponseWriter, r *http.Request)

func (*State) PostProfile

func (s *State) PostProfile(w http.ResponseWriter, r *http.Request)

PostProfile implements the profile form POST parsing and handling

The expected form as input is defined in templates/partials/form_admin_profile

func (*State) PostSongs

func (s *State) PostSongs(w http.ResponseWriter, r *http.Request)

func (*State) PostStreamerStop

func (s *State) PostStreamerStop(w http.ResponseWriter, r *http.Request)

type UsersForm

type UsersForm struct {
	radio.User
}

type UsersInput

type UsersInput struct {
	middleware.Input

	Users []radio.User
}

func NewUsersInput

func NewUsersInput(us radio.UserStorage, r *http.Request) (*UsersInput, error)

func (UsersInput) TemplateBundle

func (UsersInput) TemplateBundle() string

Jump to

Keyboard shortcuts

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