Add renderer information to --check

Now reports if the page will be rendered or not and by which render
engine.
This commit is contained in:
Noah Campbell 2013-09-18 10:27:56 -07:00
parent 67b2abaf09
commit c510140c0c
3 changed files with 25 additions and 21 deletions

View file

@ -11,7 +11,11 @@ func (s *Site) ShowPlan(out io.Writer) (err error) {
}
for _, p := range s.Pages {
fmt.Fprintf(out, "%s\n", p.FileName)
fmt.Fprintf(out, "%s", p.FileName)
if p.IsRenderable() {
fmt.Fprintf(out, " (renderer: markdown)")
}
fmt.Fprintf(out, "\n")
fmt.Fprintf(out, " canonical => ")
if s.Target == nil {
fmt.Fprintf(out, "%s\n", "!no target specified!")

View file

@ -17,7 +17,6 @@ type byteSource struct {
var fakeSource = []byteSource{
{"foo/bar/file.md", []byte(SIMPLE_PAGE)},
{"alias/test/file1.md", []byte(ALIAS_DOC_1)},
//{"slug/test/file1.md", []byte(SLUG_DOC_1)},
}
type inMemorySource struct {
@ -55,8 +54,8 @@ func TestDegenerateNoTarget(t *testing.T) {
Source: &inMemorySource{fakeSource},
}
must(s.CreatePages())
expected := "foo/bar/file.md\n canonical => !no target specified!\n" +
"alias/test/file1.md\n canonical => !no target specified!\n"
expected := "foo/bar/file.md (renderer: markdown)\n canonical => !no target specified!\n" +
"alias/test/file1.md (renderer: markdown)\n canonical => !no target specified!\n"
checkShowPlanExpected(t, s, expected)
}
@ -67,8 +66,8 @@ func TestFileTarget(t *testing.T) {
Alias: new(target.HTMLRedirectAlias),
}
must(s.CreatePages())
expected := "foo/bar/file.md\n canonical => foo/bar/file/index.html\n" +
"alias/test/file1.md\n" +
expected := "foo/bar/file.md (renderer: markdown)\n canonical => foo/bar/file/index.html\n" +
"alias/test/file1.md (renderer: markdown)\n" +
" canonical => alias/test/file1/index.html\n" +
" alias1/ => alias1/index.html\n" +
" alias-2/ => alias-2/index.html\n"
@ -82,8 +81,8 @@ func TestFileTargetUgly(t *testing.T) {
Alias: new(target.HTMLRedirectAlias),
}
s.CreatePages()
expected := "foo/bar/file.md\n canonical => foo/bar/file.html\n" +
"alias/test/file1.md\n" +
expected := "foo/bar/file.md (renderer: markdown)\n canonical => foo/bar/file.html\n" +
"alias/test/file1.md (renderer: markdown)\n" +
" canonical => alias/test/file1.html\n" +
" alias1/ => alias1/index.html\n" +
" alias-2/ => alias-2/index.html\n"
@ -98,8 +97,8 @@ func TestFileTargetPublishDir(t *testing.T) {
}
must(s.CreatePages())
expected := "foo/bar/file.md\n canonical => ../public/foo/bar/file/index.html\n" +
"alias/test/file1.md\n" +
expected := "foo/bar/file.md (renderer: markdown)\n canonical => ../public/foo/bar/file/index.html\n" +
"alias/test/file1.md (renderer: markdown)\n" +
" canonical => ../public/alias/test/file1/index.html\n" +
" alias1/ => ../public/alias1/index.html\n" +
" alias-2/ => ../public/alias-2/index.html\n"

View file

@ -8,26 +8,26 @@ import (
"testing"
)
var TEMPLATE_TITLE = "{{ .Title }}"
var PAGE_SIMPLE_TITLE = `---
const (
TEMPLATE_TITLE = "{{ .Title }}"
PAGE_SIMPLE_TITLE = `---
title: simple template
---
content`
var TEMPLATE_MISSING_FUNC = "{{ .Title | funcdoesnotexists }}"
var TEMPLATE_FUNC = "{{ .Title | urlize }}"
var TEMPLATE_CONTENT = "{{ .Content }}"
var TEMPLATE_DATE = "{{ .Date }}"
var INVALID_TEMPLATE_FORMAT_DATE = "{{ .Date.Format time.RFC3339 }}"
var TEMPLATE_WITH_URL = "<a href=\"foobar.jpg\">Going</a>"
var PAGE_URL_SPECIFIED = `---
TEMPLATE_MISSING_FUNC = "{{ .Title | funcdoesnotexists }}"
TEMPLATE_FUNC = "{{ .Title | urlize }}"
TEMPLATE_CONTENT = "{{ .Content }}"
TEMPLATE_DATE = "{{ .Date }}"
INVALID_TEMPLATE_FORMAT_DATE = "{{ .Date.Format time.RFC3339 }}"
TEMPLATE_WITH_URL = "<a href=\"foobar.jpg\">Going</a>"
PAGE_URL_SPECIFIED = `---
title: simple template
url: "mycategory/my-whatever-content/"
---
content`
var PAGE_WITH_MD = `---
PAGE_WITH_MD = `---
title: page with md
---
# heading 1
@ -35,6 +35,7 @@ text
## heading 2
more text
`
)
func pageMust(p *Page, err error) *Page {
if err != nil {