hugolib: Remove unused code

This commit is contained in:
Bjørn Erik Pedersen 2016-03-14 15:41:03 +01:00
parent c21dc16dbe
commit dea185aa9b
8 changed files with 9 additions and 90 deletions

View file

@ -182,12 +182,6 @@ menu:
Front Matter with Menu with Identifier`, title, menu, identifier))
}
type testMenuState struct {
site *Site
oldMenu interface{}
oldBaseURL interface{}
}
// Issue 817 - identifier should trump everything
func TestPageMenuWithIdentifier(t *testing.T) {

View file

@ -73,7 +73,6 @@ type Page struct {
plain string // TODO should be []byte
plainWords []string
plainInit sync.Once
plainSecondaryInit sync.Once
renderingConfig *helpers.Blackfriday
renderingConfigInit sync.Once
pageMenus PageMenus
@ -813,10 +812,6 @@ func (p *Page) guessMarkupType() string {
return helpers.GuessType(p.Source.Ext())
}
func (p *Page) detectFrontMatter() (f *parser.FrontmatterType) {
return parser.DetectFrontMatter(rune(p.frontmatter[0]))
}
func (p *Page) parse(reader io.Reader) error {
psr, err := parser.ReadFrom(reader)
if err != nil {

View file

@ -99,11 +99,6 @@ Content of the file goes Here
"date": "2012-08-06"
}
Some text
`
SIMPLE_PAGE_JSON_COMPACT = `
{"title":"foobar","customData":{"foo":"bar"},"date":"2012-08-06"}
Text
`
SIMPLE_PAGE_NOLAYOUT = `---

View file

@ -34,21 +34,6 @@ var pagePNTestSources = []pagePNTestObject{
{"/section2/testpage5.md", 1, "2012-04-06"},
}
func preparePagePNTestPages(t *testing.T) Pages {
var pages Pages
for _, s := range pagePNTestSources {
p, err := NewPage(s.path)
if err != nil {
t.Fatalf("failed to prepare test page %s", s.path)
}
p.Weight = s.weight
p.Date = cast.ToTime(s.date)
p.PublishDate = cast.ToTime(s.date)
pages = append(pages, p)
}
return pages
}
func TestPrev(t *testing.T) {
pages := preparePageGroupTestPages(t)
assert.Equal(t, pages.Prev(pages[0]), pages[4])

View file

@ -87,7 +87,6 @@ type Site struct {
targets targetList
targetListInit sync.Once
RunMode runmode
params map[string]interface{}
draftCount int
futureCount int
Data map[string]interface{}
@ -769,14 +768,6 @@ func (s *Site) Render() (err error) {
return
}
func (s *Site) checkDescriptions() {
for _, p := range s.Pages {
if len(p.Description) < 60 {
jww.FEEDBACK.Println(p.Source.Path() + " ")
}
}
}
func (s *Site) Initialise() (err error) {
return s.initialize()
}
@ -861,11 +852,6 @@ func (s *Site) checkDirectories() (err error) {
return
}
type pageResult struct {
page *Page
err error
}
// ReReadFile resets file to be read from disk again
func (s *Site) ReReadFile(absFilePath string) (*source.File, error) {
jww.INFO.Println("rereading", absFilePath)

View file

@ -42,15 +42,6 @@ var fakeSource = []source.ByteSource{
},
}
func stringInSlice(a string, list []string) bool {
for _, b := range list {
if b == a {
return true
}
}
return false
}
func checkShowPlanExpected(t *testing.T, s *Site, expected string) {
out := new(bytes.Buffer)

View file

@ -41,18 +41,11 @@ title: simple template
---
content`
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_REL = "<a href=\"foobar.jpg\">Going</a>"
TEMPLATE_WITH_URL_ABS = "<a href=\"/foobar.jpg\">Going</a>"
PAGE_URL_SPECIFIED = `---
title: simple template
url: "mycategory/my-whatever-content/"
---
content`
TEMPLATE_MISSING_FUNC = "{{ .Title | funcdoesnotexists }}"
TEMPLATE_FUNC = "{{ .Title | urlize }}"
TEMPLATE_CONTENT = "{{ .Content }}"
TEMPLATE_DATE = "{{ .Date }}"
TEMPLATE_WITH_URL_ABS = "<a href=\"/foobar.jpg\">Going</a>"
PAGE_WITH_MD = `---
title: page with md
@ -149,18 +142,6 @@ func NopCloser(w io.Writer) io.WriteCloser {
return nopCloser{w}
}
func matchRender(t *testing.T, s *Site, p *Page, tmplName string, expected string) {
content := new(bytes.Buffer)
err := s.renderThing(p, tmplName, NopCloser(content))
if err != nil {
t.Fatalf("Unable to render template.")
}
if string(content.Bytes()) != expected {
t.Fatalf("Content did not match expected: %s. got: %s", expected, content)
}
}
func TestRenderThing(t *testing.T) {
tests := []struct {
content string
@ -209,15 +190,14 @@ func HTML(in string) string {
func TestRenderThingOrDefault(t *testing.T) {
tests := []struct {
content string
missing bool
template string
expected string
}{
{PAGE_SIMPLE_TITLE, true, TEMPLATE_TITLE, HTML("simple template")},
{PAGE_SIMPLE_TITLE, true, TEMPLATE_FUNC, HTML("simple-template")},
{PAGE_SIMPLE_TITLE, false, TEMPLATE_TITLE, HTML("simple template")},
{PAGE_SIMPLE_TITLE, false, TEMPLATE_FUNC, HTML("simple-template")},
{true, TEMPLATE_TITLE, HTML("simple template")},
{true, TEMPLATE_FUNC, HTML("simple-template")},
{false, TEMPLATE_TITLE, HTML("simple template")},
{false, TEMPLATE_FUNC, HTML("simple-template")},
}
hugofs.DestinationFS = new(afero.MemMapFs)

View file

@ -43,13 +43,6 @@ func must(err error) {
}
}
func mustReturn(ret *Page, err error) *Page {
if err != nil {
panic(err)
}
return ret
}
type InMemoryAliasTarget struct {
target.HTMLRedirectAlias
files map[string][]byte