Documentation ¶
Index ¶
- func AllowedExtension(ext string) bool
- func PendingFromProbe(filename string) (*radio.PendingSong, error)
- func Route(ctx context.Context, s State) func(chi.Router)
- type ChatInput
- type FaveDownloadEntry
- type FavesInput
- type HelpInput
- type HomeInput
- type LastPlayedInput
- type NewsEntryComment
- type NewsEntryInput
- type NewsEntryPost
- type NewsInput
- type NewsInputPost
- type QueueInput
- type ScheduleInput
- type SearchInput
- type StaffInput
- type State
- func (s State) GetChat(w http.ResponseWriter, r *http.Request)
- func (s State) GetFaves(w http.ResponseWriter, r *http.Request)
- func (s State) GetHelp(w http.ResponseWriter, r *http.Request)
- func (s State) GetHome(w http.ResponseWriter, r *http.Request)
- func (s State) GetLastPlayed(w http.ResponseWriter, r *http.Request)
- func (s State) GetNews(w http.ResponseWriter, r *http.Request)
- func (s State) GetNewsEntry(w http.ResponseWriter, r *http.Request)
- func (s State) GetQueue(w http.ResponseWriter, r *http.Request)
- func (s State) GetSchedule(w http.ResponseWriter, r *http.Request)
- func (s State) GetSearch(w http.ResponseWriter, r *http.Request)
- func (s State) GetStaff(w http.ResponseWriter, r *http.Request)
- func (s State) GetSubmit(w http.ResponseWriter, r *http.Request)
- func (s State) PostFaves(w http.ResponseWriter, r *http.Request)
- func (s State) PostNewsEntry(w http.ResponseWriter, r *http.Request)
- func (s State) PostSubmit(w http.ResponseWriter, r *http.Request)
- type SubmissionForm
- type SubmitInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllowedExtension ¶
AllowedExtension returns if ext is an allowed extension for the uploaded audio files
func PendingFromProbe ¶
func PendingFromProbe(filename string) (*radio.PendingSong, error)
PendingFromProbe runs ffprobe on the given filename and constructs a PendingSong with the information found
Types ¶
type ChatInput ¶
type ChatInput struct {
middleware.Input
}
func NewChatInput ¶
func (ChatInput) TemplateBundle ¶
type FaveDownloadEntry ¶
type FaveDownloadEntry struct { ID *radio.TrackID `json:"tracks_id"` Metadata string `json:"meta"` LastRequested *int64 `json:"lastrequested"` LastPlayed *int64 `json:"lastplayed"` RequestCount *int `json:"requestcount"` }
func NewFaveDownload ¶
func NewFaveDownload(songs []radio.Song) []FaveDownloadEntry
func NewFaveDownloadEntry ¶
func NewFaveDownloadEntry(song radio.Song) FaveDownloadEntry
type FavesInput ¶
type FavesInput struct { middleware.Input Nickname string DownloadURL string Faves []radio.Song Page *shared.Pagination }
func NewFavesInput ¶
func NewFavesInput(ss radio.SongStorage, r *http.Request) (*FavesInput, error)
func (FavesInput) TemplateBundle ¶
func (FavesInput) TemplateBundle() string
type HelpInput ¶
type HelpInput struct {
middleware.Input
}
func NewHelpInput ¶
func (HelpInput) TemplateBundle ¶
type HomeInput ¶
type HomeInput struct { middleware.Input Queue []radio.QueueEntry LastPlayed []radio.Song News []NewsInputPost }
func NewHomeInput ¶
func (HomeInput) TemplateBundle ¶
type LastPlayedInput ¶
type LastPlayedInput struct { middleware.Input Songs []radio.Song Page *shared.Pagination }
func NewLastPlayedInput ¶
func NewLastPlayedInput(s radio.SongStorageService, r *http.Request) (*LastPlayedInput, error)
func (LastPlayedInput) TemplateBundle ¶
func (LastPlayedInput) TemplateBundle() string
type NewsEntryComment ¶
type NewsEntryInput ¶
type NewsEntryInput struct { middleware.Input Post NewsEntryPost }
func NewNewsEntryInput ¶
func NewNewsEntryInput(cache *shared.NewsCache, ns radio.NewsStorage, r *http.Request) (*NewsEntryInput, error)
func (NewsEntryInput) TemplateBundle ¶
func (NewsEntryInput) TemplateBundle() string
type NewsEntryPost ¶
type NewsInput ¶
type NewsInput struct { middleware.Input News []NewsInputPost NewsTotal int Page *shared.Pagination }
func NewNewsInput ¶
func (NewsInput) TemplateBundle ¶
type NewsInputPost ¶
type NewsInputPost struct { ID radio.NewsPostID Title string Header template.HTML User radio.User CreatedAt time.Time UpdatedAt *time.Time }
func AsNewsInputPost ¶
type QueueInput ¶
type QueueInput struct { middleware.Input Queue []radio.QueueEntry }
func NewQueueInput ¶
func NewQueueInput(s radio.StreamerService, r *http.Request) (*QueueInput, error)
func (QueueInput) TemplateBundle ¶
func (QueueInput) TemplateBundle() string
type ScheduleInput ¶
type ScheduleInput struct { middleware.Input Schedule []*radio.ScheduleEntry }
func NewScheduleInput ¶
func NewScheduleInput(ss radio.ScheduleStorageService, r *http.Request) (*ScheduleInput, error)
func (ScheduleInput) TemplateBundle ¶
func (ScheduleInput) TemplateBundle() string
type SearchInput ¶
type SearchInput struct { middleware.Input Query string Songs []radio.Song CanRequest bool RequestCooldown time.Duration Page *shared.Pagination }
func NewSearchInput ¶
func NewSearchInput(s radio.SearchService, rs radio.RequestStorage, r *http.Request, requestDelay time.Duration) (*SearchInput, error)
func (SearchInput) TemplateBundle ¶
func (SearchInput) TemplateBundle() string
type StaffInput ¶
type StaffInput struct { middleware.Input Users []radio.User }
func NewStaffInput ¶
func NewStaffInput(us radio.UserStorageService, r *http.Request) (*StaffInput, error)
func (StaffInput) Roles ¶
func (si StaffInput) Roles() []string
func (StaffInput) TemplateBundle ¶
func (StaffInput) TemplateBundle() string
type State ¶
type State struct { config.Config Daypass secret.Secret News *shared.NewsCache Templates templates.Executor Manager radio.ManagerService Streamer radio.StreamerService Storage radio.StorageService Search radio.SearchService }
func NewState ¶
func NewState( ctx context.Context, cfg config.Config, dp secret.Secret, newsCache *shared.NewsCache, exec templates.Executor, manager radio.ManagerService, streamer radio.StreamerService, storage radio.StorageService, search radio.SearchService) State
func (State) GetLastPlayed ¶
func (s State) GetLastPlayed(w http.ResponseWriter, r *http.Request)
func (State) GetNewsEntry ¶
func (s State) GetNewsEntry(w http.ResponseWriter, r *http.Request)
func (State) GetSchedule ¶
func (s State) GetSchedule(w http.ResponseWriter, r *http.Request)
func (State) PostNewsEntry ¶
func (s State) PostNewsEntry(w http.ResponseWriter, r *http.Request)
func (State) PostSubmit ¶
func (s State) PostSubmit(w http.ResponseWriter, r *http.Request)
type SubmissionForm ¶
type SubmissionForm struct { Token string // csrf token? // Success indicates if the upload was a success Success bool // IsDaypass is true if Daypass was valid IsDaypass bool // Errors is populated when any errors were found with the uploaded form // this is populated with their form field names as indicated below in addition to // the following possible keys: // "postprocessing": something failed after successful form parsing but before we saved all the data // "cooldown": indicates the user was not permitted to upload yet, they need to wait longer Errors map[string]string // form fields OriginalFilename string // name="track" The filename of the uploaded file Daypass string // name="daypass" Comment string // name="comment" Replacement *radio.TrackID // name="replacement" // File is the on-disk filename for the uploaded file File string // Song we managed to populate by analyzing the uploaded file Song *radio.PendingSong }
SubmissionForm is the form struct passed to the submit page templates as .Form
func NewSubmissionForm ¶
func NewSubmissionForm(tempdir string, mr *multipart.Reader) (*SubmissionForm, error)
ParseForm parses a multipart form into the SubmissionForm
Go has standard library support to do this simpler, but it doesn't let you set limits on individual fields, so we're parsing each field ourselves so we can limit their length.
Fields supported:
"track": audio file being submitted "comment": comment to be shown on the pending admin panel "daypass": daypass to bypass upload limits "replacement": an TrackID (number) indicating what song to replace in the database with this
Any other fields cause an error to be returned and all form parsing to stop.
func (SubmissionForm) TemplateBundle ¶
func (SubmissionForm) TemplateBundle() string
func (SubmissionForm) TemplateName ¶
func (SubmissionForm) TemplateName() string
func (*SubmissionForm) Validate ¶
func (sf *SubmissionForm) Validate(ts radio.TrackStorage, dp secret.Secret) bool
Validate checks if required fields are filled in the SubmissionForm and if a daypass was supplied if it was a valid one. Populates sf.Errors with any errors that occur and what input field caused it.
type SubmitInput ¶
type SubmitInput struct { middleware.Input Form SubmissionForm Stats radio.SubmissionStats }
func NewSubmitInput ¶
func NewSubmitInput(storage radio.SubmissionStorageService, r *http.Request, form *SubmissionForm) (*SubmitInput, error)
func (SubmitInput) TemplateBundle ¶
func (SubmitInput) TemplateBundle() string