package front

import (
	"notabug.org/apiote/amuse/tmdb"

	"golang.org/x/text/language"
)

type NoSuchRendererError struct {
	mimetype string
}

func (e NoSuchRendererError) Error() string {
	return "No renderer for " + e.mimetype
}

type Renderer interface {
	RenderFilm(*tmdb.Film, []language.Tag) string
	RenderSearch(*tmdb.SearchResults, []language.Tag) string
	RenderIndex(string, []language.Tag) string
	RenderSerie(*tmdb.Serie, []language.Tag) string
	RenderPerson(*tmdb.Person, []language.Tag) string
	RenderAbout([]language.Tag) string
	RenderErrorPage(int, []language.Tag) string
}

func NewRenderer(mimetype string) (Renderer, error) {
	switch mimetype {
	case "text/html":
		return HtmlRenderer{}, nil
	case "application/capnproto":
		return CapnprotoRenderer{}, nil
	default:
		return nil, NoSuchRendererError{}
	}
}
