package libamuse

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

	"notabug.org/apiote/gott"

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

func renderAbout(args ...interface{}) interface{} {
	languages := args[2].([]language.Tag)
	renderer := args[3].(front.Renderer)
	args[1] = renderer.RenderAbout(languages)
	return gott.Tuple(args)
}

func ShowAbout(language, mimetype string) (string, error) {
	result, err := gott.
		NewResult(gott.Tuple{requestData{"", "", language, mimetype}, nil, nil, nil}).
		Bind(parseLanguage).
		Bind(createRenderer).
		Map(renderAbout).
		Finish()

	if err != nil {
		return "", err
	} else {
		return result.(gott.Tuple)[1].(string), nil
	}
}
