mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Rename OutputType to OutputFormat
This commit is contained in:
parent
6bf010fed4
commit
4c2abe0015
14 changed files with 84 additions and 84 deletions
|
@ -176,8 +176,8 @@ func (h *HugoSites) assemble(config *BuildCfg) error {
|
|||
for _, s := range h.Sites {
|
||||
for _, p := range s.Pages {
|
||||
// May have been set in front matter
|
||||
if len(p.outputTypes) == 0 {
|
||||
p.outputTypes = s.defaultOutputDefinitions.ForKind(p.Kind)
|
||||
if len(p.outputFormats) == 0 {
|
||||
p.outputFormats = s.defaultOutputDefinitions.ForKind(p.Kind)
|
||||
}
|
||||
}
|
||||
s.assembleMenus()
|
||||
|
|
|
@ -198,10 +198,10 @@ type Page struct {
|
|||
|
||||
lang string
|
||||
|
||||
// The output types this page will be rendered to.
|
||||
outputTypes output.Types
|
||||
// The output formats this page will be rendered to.
|
||||
outputFormats output.Formats
|
||||
|
||||
// This is the PageOutput that represents the first item in outputTypes.
|
||||
// This is the PageOutput that represents the first item in outputFormats.
|
||||
// Use with care, as there are potential for inifinite loops.
|
||||
mainPageOutput *PageOutput
|
||||
|
||||
|
@ -792,7 +792,7 @@ func (p *Page) Extension() string {
|
|||
return p.extension
|
||||
}
|
||||
//
|
||||
// TODO(bep) return p.outputType.MediaType.Suffix
|
||||
// TODO(bep) return MediaType.Suffix
|
||||
|
||||
// TODO(bep) remove this config option =>
|
||||
return p.s.Cfg.GetString("defaultExtension")
|
||||
|
@ -952,13 +952,13 @@ func (p *Page) update(f interface{}) error {
|
|||
case "outputs":
|
||||
outputs := cast.ToStringSlice(v)
|
||||
if len(outputs) > 0 {
|
||||
// Output types are exlicitly set in front matter, use those.
|
||||
outTypes, err := output.GetTypes(outputs...)
|
||||
// Output formats are exlicitly set in front matter, use those.
|
||||
outFormats, err := output.GetTypes(outputs...)
|
||||
if err != nil {
|
||||
p.s.Log.ERROR.Printf("Failed to resolve output types: %s", err)
|
||||
p.s.Log.ERROR.Printf("Failed to resolve output formats: %s", err)
|
||||
} else {
|
||||
p.outputTypes = outTypes
|
||||
p.Params[loki] = outTypes
|
||||
p.outputFormats = outFormats
|
||||
p.Params[loki] = outFormats
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,11 +31,11 @@ type PageOutput struct {
|
|||
// Keep this to create URL/path variations, i.e. paginators.
|
||||
targetPathDescriptor targetPathDescriptor
|
||||
|
||||
outputType output.Type
|
||||
outputFormat output.Format
|
||||
}
|
||||
|
||||
func (p *PageOutput) targetPath(addends ...string) (string, error) {
|
||||
tp, err := p.createTargetPath(p.outputType, addends...)
|
||||
tp, err := p.createTargetPath(p.outputFormat, addends...)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -43,13 +43,13 @@ func (p *PageOutput) targetPath(addends ...string) (string, error) {
|
|||
|
||||
}
|
||||
|
||||
func newPageOutput(p *Page, createCopy bool, outputType output.Type) (*PageOutput, error) {
|
||||
func newPageOutput(p *Page, createCopy bool, f output.Format) (*PageOutput, error) {
|
||||
if createCopy {
|
||||
p.initURLs()
|
||||
p = p.copy()
|
||||
}
|
||||
|
||||
td, err := p.createTargetPathDescriptor(outputType)
|
||||
td, err := p.createTargetPathDescriptor(f)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -57,7 +57,7 @@ func newPageOutput(p *Page, createCopy bool, outputType output.Type) (*PageOutpu
|
|||
|
||||
return &PageOutput{
|
||||
Page: p,
|
||||
outputType: outputType,
|
||||
outputFormat: f,
|
||||
targetPathDescriptor: td,
|
||||
}, nil
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ func newPageOutput(p *Page, createCopy bool, outputType output.Type) (*PageOutpu
|
|||
// copy creates a copy of this PageOutput with the lazy sync.Once vars reset
|
||||
// so they will be evaluated again, for word count calculations etc.
|
||||
func (p *PageOutput) copy() *PageOutput {
|
||||
c, err := newPageOutput(p.Page, true, p.outputType)
|
||||
c, err := newPageOutput(p.Page, true, p.outputFormat)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ import (
|
|||
type targetPathDescriptor struct {
|
||||
PathSpec *helpers.PathSpec
|
||||
|
||||
Type output.Type
|
||||
Type output.Format
|
||||
Kind string
|
||||
|
||||
Sections []string
|
||||
|
@ -66,10 +66,10 @@ type targetPathDescriptor struct {
|
|||
UglyURLs bool
|
||||
}
|
||||
|
||||
// createTargetPathDescriptor adapts a Page and the given output.Type into
|
||||
// createTargetPathDescriptor adapts a Page and the given output.Format into
|
||||
// a targetPathDescriptor. This descriptor can then be used to create paths
|
||||
// and URLs for this Page.
|
||||
func (p *Page) createTargetPathDescriptor(t output.Type) (targetPathDescriptor, error) {
|
||||
func (p *Page) createTargetPathDescriptor(t output.Format) (targetPathDescriptor, error) {
|
||||
d := targetPathDescriptor{
|
||||
PathSpec: p.s.PathSpec,
|
||||
Type: t,
|
||||
|
@ -107,9 +107,9 @@ func (p *Page) createTargetPathDescriptor(t output.Type) (targetPathDescriptor,
|
|||
}
|
||||
|
||||
// createTargetPath creates the target filename for this Page for the given
|
||||
// output.Type. Some additional URL parts can also be provided, the typical
|
||||
// output.Format. Some additional URL parts can also be provided, the typical
|
||||
// use case being pagination.
|
||||
func (p *Page) createTargetPath(t output.Type, addends ...string) (string, error) {
|
||||
func (p *Page) createTargetPath(t output.Format, addends ...string) (string, error) {
|
||||
d, err := p.createTargetPathDescriptor(t)
|
||||
if err != nil {
|
||||
return "", nil
|
||||
|
@ -205,20 +205,20 @@ func createTargetPath(d targetPathDescriptor) string {
|
|||
|
||||
func (p *Page) createRelativePermalink() string {
|
||||
|
||||
if len(p.outputTypes) == 0 {
|
||||
if len(p.outputFormats) == 0 {
|
||||
panic(fmt.Sprintf("Page %q missing output format(s)", p.Title))
|
||||
}
|
||||
|
||||
// Choose the main output format. In most cases, this will be HTML.
|
||||
outputType := p.outputTypes[0]
|
||||
tp, err := p.createTargetPath(outputType)
|
||||
outFormat := p.outputFormats[0]
|
||||
tp, err := p.createTargetPath(outFormat)
|
||||
|
||||
if err != nil {
|
||||
p.s.Log.ERROR.Printf("Failed to create permalink for page %q: %s", p.FullFilePath(), err)
|
||||
return ""
|
||||
}
|
||||
|
||||
tp = strings.TrimSuffix(tp, outputType.BaseFilename())
|
||||
tp = strings.TrimSuffix(tp, outFormat.BaseFilename())
|
||||
|
||||
return p.s.PathSpec.URLizeFilename(tp)
|
||||
}
|
||||
|
|
|
@ -1661,7 +1661,7 @@ func (s *Site) kindFromSections(sections []string) string {
|
|||
}
|
||||
|
||||
func (s *Site) layouts(p *PageOutput) []string {
|
||||
return s.layoutHandler.For(p.layoutIdentifier, "", p.outputType)
|
||||
return s.layoutHandler.For(p.layoutIdentifier, "", p.outputFormat)
|
||||
}
|
||||
|
||||
func (s *Site) preparePages() error {
|
||||
|
@ -1806,7 +1806,7 @@ func (s *Site) renderAndWriteXML(name string, dest string, d interface{}, layout
|
|||
|
||||
}
|
||||
|
||||
func (s *Site) renderAndWritePage(tp output.Type, name string, dest string, d interface{}, layouts ...string) error {
|
||||
func (s *Site) renderAndWritePage(f output.Format, name string, dest string, d interface{}, layouts ...string) error {
|
||||
renderBuffer := bp.GetBuffer()
|
||||
defer bp.PutBuffer(renderBuffer)
|
||||
|
||||
|
@ -1878,7 +1878,7 @@ Your rendered home page is blank: /index.html is zero-length
|
|||
|
||||
}
|
||||
|
||||
if err = w.writeDestPage(tp, dest, outBuffer); err != nil {
|
||||
if err = w.writeDestPage(f, dest, outBuffer); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -2061,7 +2061,7 @@ func (s *Site) newNodePage(typ string) *Page {
|
|||
Data: make(map[string]interface{}),
|
||||
Site: &s.Info,
|
||||
s: s}
|
||||
p.outputTypes = p.s.defaultOutputDefinitions.ForKind(typ)
|
||||
p.outputFormats = p.s.defaultOutputDefinitions.ForKind(typ)
|
||||
p.layoutIdentifier = pageLayoutIdentifier{p}
|
||||
return p
|
||||
|
||||
|
|
|
@ -29,11 +29,11 @@ type siteOutputDefinition struct {
|
|||
// Comma separated list (for now).
|
||||
ExcludedKinds string
|
||||
|
||||
Outputs []output.Type
|
||||
Outputs []output.Format
|
||||
}
|
||||
|
||||
func (defs siteOutputDefinitions) ForKind(kind string) []output.Type {
|
||||
var result []output.Type
|
||||
func (defs siteOutputDefinitions) ForKind(kind string) []output.Format {
|
||||
var result []output.Format
|
||||
|
||||
for _, def := range defs {
|
||||
if def.ExcludedKinds == "" || !strings.Contains(def.ExcludedKinds, kind) {
|
||||
|
@ -49,7 +49,7 @@ func createSiteOutputDefinitions(cfg config.Provider) siteOutputDefinitions {
|
|||
var defs siteOutputDefinitions
|
||||
|
||||
// All have HTML
|
||||
defs = append(defs, siteOutputDefinition{ExcludedKinds: "", Outputs: []output.Type{output.HTMLType}})
|
||||
defs = append(defs, siteOutputDefinition{ExcludedKinds: "", Outputs: []output.Format{output.HTMLType}})
|
||||
|
||||
// TODO(bep) output deprecate rssURI
|
||||
rssBase := cfg.GetString("rssURI")
|
||||
|
@ -63,7 +63,7 @@ func createSiteOutputDefinitions(cfg config.Provider) siteOutputDefinitions {
|
|||
rssType.BaseName = rssBase
|
||||
|
||||
// Some have RSS
|
||||
defs = append(defs, siteOutputDefinition{ExcludedKinds: "page", Outputs: []output.Type{rssType}})
|
||||
defs = append(defs, siteOutputDefinition{ExcludedKinds: "page", Outputs: []output.Format{rssType}})
|
||||
|
||||
return defs
|
||||
}
|
||||
|
|
|
@ -32,10 +32,10 @@ func TestDefaultOutputDefinitions(t *testing.T) {
|
|||
tests := []struct {
|
||||
name string
|
||||
kind string
|
||||
want []output.Type
|
||||
want []output.Format
|
||||
}{
|
||||
{"RSS not for regular pages", KindPage, []output.Type{output.HTMLType}},
|
||||
{"Home Sweet Home", KindHome, []output.Type{output.HTMLType, output.RSSType}},
|
||||
{"RSS not for regular pages", KindPage, []output.Format{output.HTMLType}},
|
||||
{"Home Sweet Home", KindHome, []output.Format{output.HTMLType, output.RSSType}},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
@ -88,7 +88,7 @@ outputs: ["json"]
|
|||
|
||||
require.NotNil(t, home)
|
||||
|
||||
require.Len(t, home.outputTypes, 1)
|
||||
require.Len(t, home.outputFormats, 1)
|
||||
|
||||
// TODO(bep) output assert template/text
|
||||
|
||||
|
|
|
@ -65,10 +65,10 @@ func pageRenderer(s *Site, pages <-chan *Page, results chan<- error, wg *sync.Wa
|
|||
var mainPageOutput *PageOutput
|
||||
|
||||
for page := range pages {
|
||||
for i, outputType := range page.outputTypes {
|
||||
pageOutput, err := newPageOutput(page, i > 0, outputType)
|
||||
for i, outFormat := range page.outputFormats {
|
||||
pageOutput, err := newPageOutput(page, i > 0, outFormat)
|
||||
if err != nil {
|
||||
s.Log.ERROR.Printf("Failed to create output page for type %q for page %q: %s", outputType.Name, page, err)
|
||||
s.Log.ERROR.Printf("Failed to create output page for type %q for page %q: %s", outFormat.Name, page, err)
|
||||
continue
|
||||
}
|
||||
if i == 0 {
|
||||
|
@ -85,7 +85,7 @@ func pageRenderer(s *Site, pages <-chan *Page, results chan<- error, wg *sync.Wa
|
|||
layouts = s.layouts(pageOutput)
|
||||
}
|
||||
|
||||
switch pageOutput.outputType.Name {
|
||||
switch pageOutput.outputFormat.Name {
|
||||
|
||||
case "RSS":
|
||||
if err := s.renderRSS(pageOutput); err != nil {
|
||||
|
@ -94,13 +94,13 @@ func pageRenderer(s *Site, pages <-chan *Page, results chan<- error, wg *sync.Wa
|
|||
default:
|
||||
targetPath, err := pageOutput.targetPath()
|
||||
if err != nil {
|
||||
s.Log.ERROR.Printf("Failed to create target path for output %q for page %q: %s", outputType.Name, page, err)
|
||||
s.Log.ERROR.Printf("Failed to create target path for output %q for page %q: %s", outFormat.Name, page, err)
|
||||
continue
|
||||
}
|
||||
|
||||
s.Log.DEBUG.Printf("Render %s to %q with layouts %q", pageOutput.Kind, targetPath, layouts)
|
||||
|
||||
if err := s.renderAndWritePage(outputType, "page "+pageOutput.FullFilePath(), targetPath, pageOutput, layouts...); err != nil {
|
||||
if err := s.renderAndWritePage(outFormat, "page "+pageOutput.FullFilePath(), targetPath, pageOutput, layouts...); err != nil {
|
||||
results <- err
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ func (s *Site) renderPaginator(p *PageOutput) error {
|
|||
addend := fmt.Sprintf("/%s/%d", paginatePath, pageNumber)
|
||||
targetPath, _ := p.targetPath(addend)
|
||||
|
||||
if err := s.renderAndWritePage(p.outputType, pagerNode.Title,
|
||||
if err := s.renderAndWritePage(p.outputFormat, pagerNode.Title,
|
||||
targetPath, pagerNode, p.layouts()...); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import (
|
|||
)
|
||||
|
||||
// We may find some abstractions/interface(s) here once we star with
|
||||
// "Multiple Output Types".
|
||||
// "Multiple Output Formats".
|
||||
type siteWriter struct {
|
||||
langDir string
|
||||
publishDir string
|
||||
|
@ -40,8 +40,8 @@ type siteWriter struct {
|
|||
log *jww.Notepad
|
||||
}
|
||||
|
||||
func (w siteWriter) targetPathPage(tp output.Type, src string) (string, error) {
|
||||
dir, err := w.baseTargetPathPage(tp, src)
|
||||
func (w siteWriter) targetPathPage(f output.Format, src string) (string, error) {
|
||||
dir, err := w.baseTargetPathPage(f, src)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ func (w siteWriter) targetPathPage(tp output.Type, src string) (string, error) {
|
|||
return dir, nil
|
||||
}
|
||||
|
||||
func (w siteWriter) baseTargetPathPage(tp output.Type, src string) (string, error) {
|
||||
func (w siteWriter) baseTargetPathPage(f output.Format, src string) (string, error) {
|
||||
if src == helpers.FilePathSeparator {
|
||||
return "index.html", nil
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ func filename(f string) string {
|
|||
return f[:len(f)-len(ext)]
|
||||
}
|
||||
|
||||
func (w siteWriter) writeDestPage(tp output.Type, path string, reader io.Reader) error {
|
||||
func (w siteWriter) writeDestPage(f output.Format, path string, reader io.Reader) error {
|
||||
w.log.DEBUG.Println("creating page:", path)
|
||||
path, _ = w.targetPathFile(path)
|
||||
// TODO(bep) output remove this file ... targetPath, err := w.targetPathPage(tp, path)
|
||||
|
|
|
@ -127,9 +127,9 @@ func _TestTargetPathUglyURLs(t *testing.T) {
|
|||
w := siteWriter{log: newErrorLogger(), uglyURLs: true}
|
||||
|
||||
tests := []struct {
|
||||
outputType output.Type
|
||||
content string
|
||||
expected string
|
||||
outFormat output.Format
|
||||
content string
|
||||
expected string
|
||||
}{
|
||||
{output.HTMLType, "foo.html", "foo.html"},
|
||||
{output.HTMLType, "/", "index.html"},
|
||||
|
@ -139,7 +139,7 @@ func _TestTargetPathUglyURLs(t *testing.T) {
|
|||
}
|
||||
|
||||
for i, test := range tests {
|
||||
dest, err := w.targetPathPage(test.outputType, filepath.FromSlash(test.content))
|
||||
dest, err := w.targetPathPage(test.outFormat, filepath.FromSlash(test.content))
|
||||
if err != nil {
|
||||
t.Fatalf(" [%d] targetPathPage returned an unexpected err: %s", i, err)
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ indexes/indexes.NAME.SUFFIX indexes/indexes.SUFFIX
|
|||
`
|
||||
)
|
||||
|
||||
func (l *LayoutHandler) For(id LayoutIdentifier, layoutOverride string, tp Type) []string {
|
||||
func (l *LayoutHandler) For(id LayoutIdentifier, layoutOverride string, f Format) []string {
|
||||
var layouts []string
|
||||
|
||||
layout := id.PageLayout()
|
||||
|
@ -72,15 +72,15 @@ func (l *LayoutHandler) For(id LayoutIdentifier, layoutOverride string, tp Type)
|
|||
switch id.PageKind() {
|
||||
// TODO(bep) move the Kind constants some common place.
|
||||
case "home":
|
||||
layouts = resolveTemplate(layoutsHome, id, tp)
|
||||
layouts = resolveTemplate(layoutsHome, id, f)
|
||||
case "section":
|
||||
layouts = resolveTemplate(layoutsSection, id, tp)
|
||||
layouts = resolveTemplate(layoutsSection, id, f)
|
||||
case "taxonomy":
|
||||
layouts = resolveTemplate(layoutTaxonomy, id, tp)
|
||||
layouts = resolveTemplate(layoutTaxonomy, id, f)
|
||||
case "taxonomyTerm":
|
||||
layouts = resolveTemplate(layoutTaxonomyTerm, id, tp)
|
||||
layouts = resolveTemplate(layoutTaxonomyTerm, id, f)
|
||||
case "page":
|
||||
layouts = regularPageLayouts(id.PageType(), layout, tp)
|
||||
layouts = regularPageLayouts(id.PageType(), layout, f)
|
||||
}
|
||||
|
||||
if l.hasTheme {
|
||||
|
@ -112,10 +112,10 @@ func (l *LayoutHandler) For(id LayoutIdentifier, layoutOverride string, tp Type)
|
|||
return layouts
|
||||
}
|
||||
|
||||
func resolveTemplate(templ string, id LayoutIdentifier, tp Type) []string {
|
||||
func resolveTemplate(templ string, id LayoutIdentifier, f Format) []string {
|
||||
return strings.Fields(replaceKeyValues(templ,
|
||||
"SUFFIX", tp.MediaType.Suffix,
|
||||
"NAME", strings.ToLower(tp.Name),
|
||||
"SUFFIX", f.MediaType.Suffix,
|
||||
"NAME", strings.ToLower(f.Name),
|
||||
"SECTION", id.PageSection()))
|
||||
}
|
||||
|
||||
|
@ -124,13 +124,13 @@ func replaceKeyValues(s string, oldNew ...string) string {
|
|||
return replacer.Replace(s)
|
||||
}
|
||||
|
||||
func regularPageLayouts(types string, layout string, tp Type) (layouts []string) {
|
||||
func regularPageLayouts(types string, layout string, f Format) (layouts []string) {
|
||||
if layout == "" {
|
||||
layout = "single"
|
||||
}
|
||||
|
||||
suffix := tp.MediaType.Suffix
|
||||
name := strings.ToLower(tp.Name)
|
||||
suffix := f.MediaType.Suffix
|
||||
name := strings.ToLower(f.Name)
|
||||
|
||||
if types != "" {
|
||||
t := strings.Split(types, "/")
|
||||
|
|
|
@ -44,7 +44,7 @@ func (l testLayoutIdentifier) PageSection() string {
|
|||
return l.pageSection
|
||||
}
|
||||
|
||||
var ampType = Type{
|
||||
var ampType = Format{
|
||||
Name: "AMP",
|
||||
MediaType: media.HTMLType,
|
||||
BaseName: "index",
|
||||
|
@ -57,7 +57,7 @@ func TestLayout(t *testing.T) {
|
|||
li testLayoutIdentifier
|
||||
hasTheme bool
|
||||
layoutOverride string
|
||||
tp Type
|
||||
tp Format
|
||||
expect []string
|
||||
}{
|
||||
{"Home", testLayoutIdentifier{"home", "", "", ""}, true, "", ampType,
|
||||
|
|
|
@ -23,33 +23,33 @@ import (
|
|||
var (
|
||||
// An ordered list of built-in output formats
|
||||
// See https://www.ampproject.org/learn/overview/
|
||||
AMPType = Type{
|
||||
AMPType = Format{
|
||||
Name: "AMP",
|
||||
MediaType: media.HTMLType,
|
||||
BaseName: "index",
|
||||
Path: "amp",
|
||||
}
|
||||
|
||||
CSSType = Type{
|
||||
CSSType = Format{
|
||||
Name: "CSS",
|
||||
MediaType: media.CSSType,
|
||||
BaseName: "styles",
|
||||
}
|
||||
|
||||
HTMLType = Type{
|
||||
HTMLType = Format{
|
||||
Name: "HTML",
|
||||
MediaType: media.HTMLType,
|
||||
BaseName: "index",
|
||||
}
|
||||
|
||||
JSONType = Type{
|
||||
JSONType = Format{
|
||||
Name: "JSON",
|
||||
MediaType: media.JSONType,
|
||||
BaseName: "index",
|
||||
IsPlainText: true,
|
||||
}
|
||||
|
||||
RSSType = Type{
|
||||
RSSType = Format{
|
||||
Name: "RSS",
|
||||
MediaType: media.RSSType,
|
||||
BaseName: "index",
|
||||
|
@ -57,7 +57,7 @@ var (
|
|||
}
|
||||
)
|
||||
|
||||
var builtInTypes = map[string]Type{
|
||||
var builtInTypes = map[string]Format{
|
||||
strings.ToLower(AMPType.Name): AMPType,
|
||||
strings.ToLower(CSSType.Name): CSSType,
|
||||
strings.ToLower(HTMLType.Name): HTMLType,
|
||||
|
@ -65,11 +65,11 @@ var builtInTypes = map[string]Type{
|
|||
strings.ToLower(RSSType.Name): RSSType,
|
||||
}
|
||||
|
||||
type Types []Type
|
||||
type Formats []Format
|
||||
|
||||
// Type represents an output represenation, usually to a file on disk.
|
||||
type Type struct {
|
||||
// The Name is used as an identifier. Internal output types (i.e. HTML and RSS)
|
||||
// Format represents an output represenation, usually to a file on disk.
|
||||
type Format struct {
|
||||
// The Name is used as an identifier. Internal output formats (i.e. HTML and RSS)
|
||||
// can be overridden by providing a new definition for those types.
|
||||
Name string
|
||||
|
||||
|
@ -92,7 +92,7 @@ type Type struct {
|
|||
NoUgly bool
|
||||
}
|
||||
|
||||
func GetType(key string) (Type, bool) {
|
||||
func GetType(key string) (Format, bool) {
|
||||
found, ok := builtInTypes[key]
|
||||
if !ok {
|
||||
found, ok = builtInTypes[strings.ToLower(key)]
|
||||
|
@ -101,13 +101,13 @@ func GetType(key string) (Type, bool) {
|
|||
}
|
||||
|
||||
// TODO(bep) outputs rewamp on global config?
|
||||
func GetTypes(keys ...string) (Types, error) {
|
||||
var types []Type
|
||||
func GetTypes(keys ...string) (Formats, error) {
|
||||
var types []Format
|
||||
|
||||
for _, key := range keys {
|
||||
tpe, ok := GetType(key)
|
||||
if !ok {
|
||||
return types, fmt.Errorf("OutputType with key %q not found", key)
|
||||
return types, fmt.Errorf("OutputFormat with key %q not found", key)
|
||||
}
|
||||
types = append(types, tpe)
|
||||
}
|
||||
|
@ -115,6 +115,6 @@ func GetTypes(keys ...string) (Types, error) {
|
|||
return types, nil
|
||||
}
|
||||
|
||||
func (t Type) BaseFilename() string {
|
||||
func (t Format) BaseFilename() string {
|
||||
return t.BaseName + "." + t.MediaType.Suffix
|
||||
}
|
Loading…
Reference in a new issue