mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
hugolib: Un-export internal Site-methods
These are obviously internal and for the most part undocumented, creating lots of GoLint warnings. See #1160 See #2014
This commit is contained in:
parent
16ad628114
commit
1c3c148b38
10 changed files with 114 additions and 113 deletions
|
@ -39,7 +39,7 @@ type defaultHandler struct{ basicFileHandler }
|
|||
|
||||
func (h defaultHandler) Extensions() []string { return []string{"*"} }
|
||||
func (h defaultHandler) FileConvert(f *source.File, s *Site) HandledResult {
|
||||
s.WriteDestFile(f.Path(), f.Contents)
|
||||
s.writeDestFile(f.Path(), f.Contents)
|
||||
return HandledResult{file: f}
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,6 @@ type cssHandler struct{ basicFileHandler }
|
|||
func (h cssHandler) Extensions() []string { return []string{"css"} }
|
||||
func (h cssHandler) FileConvert(f *source.File, s *Site) HandledResult {
|
||||
x := cssmin.Minify(f.Bytes())
|
||||
s.WriteDestFile(f.Path(), helpers.BytesToReader(x))
|
||||
s.writeDestFile(f.Path(), helpers.BytesToReader(x))
|
||||
return HandledResult{file: f}
|
||||
}
|
||||
|
|
|
@ -695,11 +695,11 @@ func testSiteSetup(s *Site, t *testing.T) {
|
|||
s.Menus = Menus{}
|
||||
s.initializeSiteInfo()
|
||||
|
||||
if err := s.CreatePages(); err != nil {
|
||||
if err := s.createPages(); err != nil {
|
||||
t.Fatalf("Unable to create pages: %s", err)
|
||||
}
|
||||
|
||||
if err := s.BuildSiteMeta(); err != nil {
|
||||
if err := s.buildSiteMeta(); err != nil {
|
||||
t.Fatalf("Unable to build site metadata: %s", err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,23 +46,23 @@ func TestRobotsTXTOutput(t *testing.T) {
|
|||
|
||||
s.prepTemplates("robots.txt", robotTxtTemplate)
|
||||
|
||||
if err := s.CreatePages(); err != nil {
|
||||
if err := s.createPages(); err != nil {
|
||||
t.Fatalf("Unable to create pages: %s", err)
|
||||
}
|
||||
|
||||
if err := s.BuildSiteMeta(); err != nil {
|
||||
if err := s.buildSiteMeta(); err != nil {
|
||||
t.Fatalf("Unable to build site metadata: %s", err)
|
||||
}
|
||||
|
||||
if err := s.RenderHomePage(); err != nil {
|
||||
if err := s.renderHomePage(); err != nil {
|
||||
t.Fatalf("Unable to RenderHomePage: %s", err)
|
||||
}
|
||||
|
||||
if err := s.RenderSitemap(); err != nil {
|
||||
if err := s.renderSitemap(); err != nil {
|
||||
t.Fatalf("Unable to RenderSitemap: %s", err)
|
||||
}
|
||||
|
||||
if err := s.RenderRobotsTXT(); err != nil {
|
||||
if err := s.renderRobotsTXT(); err != nil {
|
||||
t.Fatalf("Unable to RenderRobotsTXT :%s", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -59,15 +59,15 @@ func TestRSSOutput(t *testing.T) {
|
|||
s.initializeSiteInfo()
|
||||
s.prepTemplates("rss.xml", rssTemplate)
|
||||
|
||||
if err := s.CreatePages(); err != nil {
|
||||
if err := s.createPages(); err != nil {
|
||||
t.Fatalf("Unable to create pages: %s", err)
|
||||
}
|
||||
|
||||
if err := s.BuildSiteMeta(); err != nil {
|
||||
if err := s.buildSiteMeta(); err != nil {
|
||||
t.Fatalf("Unable to build site metadata: %s", err)
|
||||
}
|
||||
|
||||
if err := s.RenderHomePage(); err != nil {
|
||||
if err := s.renderHomePage(); err != nil {
|
||||
t.Fatalf("Unable to RenderHomePage: %s", err)
|
||||
}
|
||||
|
||||
|
|
139
hugolib/site.go
139
hugolib/site.go
|
@ -29,6 +29,8 @@ import (
|
|||
|
||||
"sync/atomic"
|
||||
|
||||
"path"
|
||||
|
||||
"bitbucket.org/pkg/inflect"
|
||||
"github.com/spf13/afero"
|
||||
"github.com/spf13/cast"
|
||||
|
@ -44,7 +46,6 @@ import (
|
|||
"github.com/spf13/nitro"
|
||||
"github.com/spf13/viper"
|
||||
"gopkg.in/fsnotify.v1"
|
||||
"path"
|
||||
)
|
||||
|
||||
var _ = transform.AbsURL
|
||||
|
@ -356,7 +357,7 @@ type runmode struct {
|
|||
Watching bool
|
||||
}
|
||||
|
||||
func (s *Site) Running() bool {
|
||||
func (s *Site) running() bool {
|
||||
return s.RunMode.Watching
|
||||
}
|
||||
|
||||
|
@ -433,7 +434,7 @@ func (s *Site) ReBuild(events []fsnotify.Event) error {
|
|||
}
|
||||
|
||||
if len(dataChanged) > 0 {
|
||||
s.ReadDataFromSourceFS()
|
||||
s.readDataFromSourceFS()
|
||||
}
|
||||
|
||||
// we reuse the state, so have to do some cleanup before we can rebuild.
|
||||
|
@ -487,7 +488,7 @@ func (s *Site) ReBuild(events []fsnotify.Event) error {
|
|||
if ev.Op&fsnotify.Remove == fsnotify.Remove {
|
||||
//remove the file & a create will follow
|
||||
path, _ := helpers.GetRelativePath(ev.Name, s.absContentDir())
|
||||
s.RemovePageByPath(path)
|
||||
s.removePageByPath(path)
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -498,12 +499,12 @@ func (s *Site) ReBuild(events []fsnotify.Event) error {
|
|||
// If the file is still on disk, it's only been updated, if it's not, it's been moved
|
||||
if ex, err := afero.Exists(hugofs.Source(), ev.Name); !ex || err != nil {
|
||||
path, _ := helpers.GetRelativePath(ev.Name, s.absContentDir())
|
||||
s.RemovePageByPath(path)
|
||||
s.removePageByPath(path)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
file, err := s.ReReadFile(ev.Name)
|
||||
file, err := s.reReadFile(ev.Name)
|
||||
if err != nil {
|
||||
errs <- err
|
||||
}
|
||||
|
@ -534,7 +535,7 @@ func (s *Site) ReBuild(events []fsnotify.Event) error {
|
|||
|
||||
if len(sourceChanged) > 0 {
|
||||
s.setupPrevNext()
|
||||
if err = s.BuildSiteMeta(); err != nil {
|
||||
if err = s.buildSiteMeta(); err != nil {
|
||||
return err
|
||||
}
|
||||
s.timerStep("build taxonomies")
|
||||
|
@ -654,7 +655,7 @@ func readData(f *source.File) (interface{}, error) {
|
|||
}
|
||||
}
|
||||
|
||||
func (s *Site) ReadDataFromSourceFS() error {
|
||||
func (s *Site) readDataFromSourceFS() error {
|
||||
dataSources := make([]source.Input, 0, 2)
|
||||
dataSources = append(dataSources, &source.Filesystem{Base: s.absDataDir()})
|
||||
|
||||
|
@ -678,15 +679,15 @@ func (s *Site) Process() (err error) {
|
|||
s.Tmpl.PrintErrors()
|
||||
s.timerStep("initialize & template prep")
|
||||
|
||||
if err = s.ReadDataFromSourceFS(); err != nil {
|
||||
if err = s.readDataFromSourceFS(); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if err = s.CreatePages(); err != nil {
|
||||
if err = s.createPages(); err != nil {
|
||||
return
|
||||
}
|
||||
s.setupPrevNext()
|
||||
if err = s.BuildSiteMeta(); err != nil {
|
||||
if err = s.buildSiteMeta(); err != nil {
|
||||
return
|
||||
}
|
||||
s.timerStep("build taxonomies")
|
||||
|
@ -706,34 +707,34 @@ func (s *Site) setupPrevNext() {
|
|||
}
|
||||
|
||||
func (s *Site) Render() (err error) {
|
||||
if err = s.RenderAliases(); err != nil {
|
||||
if err = s.renderAliases(); err != nil {
|
||||
return
|
||||
}
|
||||
s.timerStep("render and write aliases")
|
||||
if err = s.RenderTaxonomiesLists(); err != nil {
|
||||
if err = s.renderTaxonomiesLists(); err != nil {
|
||||
return
|
||||
}
|
||||
s.timerStep("render and write taxonomies")
|
||||
s.RenderListsOfTaxonomyTerms()
|
||||
s.renderListsOfTaxonomyTerms()
|
||||
s.timerStep("render & write taxonomy lists")
|
||||
if err = s.RenderSectionLists(); err != nil {
|
||||
if err = s.renderSectionLists(); err != nil {
|
||||
return
|
||||
}
|
||||
s.timerStep("render and write lists")
|
||||
if err = s.RenderPages(); err != nil {
|
||||
if err = s.renderPages(); err != nil {
|
||||
return
|
||||
}
|
||||
s.timerStep("render and write pages")
|
||||
if err = s.RenderHomePage(); err != nil {
|
||||
if err = s.renderHomePage(); err != nil {
|
||||
return
|
||||
}
|
||||
s.timerStep("render and write homepage")
|
||||
if err = s.RenderSitemap(); err != nil {
|
||||
if err = s.renderSitemap(); err != nil {
|
||||
return
|
||||
}
|
||||
s.timerStep("render and write Sitemap")
|
||||
|
||||
if err = s.RenderRobotsTXT(); err != nil {
|
||||
if err = s.renderRobotsTXT(); err != nil {
|
||||
return
|
||||
}
|
||||
s.timerStep("render and write robots.txt")
|
||||
|
@ -825,8 +826,8 @@ func (s *Site) checkDirectories() (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// ReReadFile resets file to be read from disk again
|
||||
func (s *Site) ReReadFile(absFilePath string) (*source.File, error) {
|
||||
// reReadFile resets file to be read from disk again
|
||||
func (s *Site) reReadFile(absFilePath string) (*source.File, error) {
|
||||
jww.INFO.Println("rereading", absFilePath)
|
||||
var file *source.File
|
||||
|
||||
|
@ -844,7 +845,7 @@ func (s *Site) ReReadFile(absFilePath string) (*source.File, error) {
|
|||
return file, nil
|
||||
}
|
||||
|
||||
func (s *Site) ReadPagesFromSource() chan error {
|
||||
func (s *Site) readPagesFromSource() chan error {
|
||||
if s.Source == nil {
|
||||
panic(fmt.Sprintf("s.Source not set %s", s.absContentDir()))
|
||||
}
|
||||
|
@ -882,7 +883,7 @@ func (s *Site) ReadPagesFromSource() chan error {
|
|||
return errs
|
||||
}
|
||||
|
||||
func (s *Site) ConvertSource() chan error {
|
||||
func (s *Site) convertSource() chan error {
|
||||
errs := make(chan error)
|
||||
results := make(chan HandledResult)
|
||||
pageChan := make(chan *Page)
|
||||
|
@ -914,11 +915,11 @@ func (s *Site) ConvertSource() chan error {
|
|||
return errs
|
||||
}
|
||||
|
||||
func (s *Site) CreatePages() error {
|
||||
readErrs := <-s.ReadPagesFromSource()
|
||||
func (s *Site) createPages() error {
|
||||
readErrs := <-s.readPagesFromSource()
|
||||
s.timerStep("read pages from source")
|
||||
|
||||
renderErrs := <-s.ConvertSource()
|
||||
renderErrs := <-s.convertSource()
|
||||
s.timerStep("convert source")
|
||||
|
||||
if renderErrs == nil && readErrs == nil {
|
||||
|
@ -990,7 +991,7 @@ func converterCollator(s *Site, results <-chan HandledResult, errs chan<- error)
|
|||
errs <- fmt.Errorf("Errors rendering pages: %s", strings.Join(errMsgs, "\n"))
|
||||
}
|
||||
|
||||
func (s *Site) AddPage(page *Page) {
|
||||
func (s *Site) addPage(page *Page) {
|
||||
if page.ShouldBuild() {
|
||||
s.Pages = append(s.Pages, page)
|
||||
}
|
||||
|
@ -1004,7 +1005,7 @@ func (s *Site) AddPage(page *Page) {
|
|||
}
|
||||
}
|
||||
|
||||
func (s *Site) RemovePageByPath(path string) {
|
||||
func (s *Site) removePageByPath(path string) {
|
||||
if i := s.Pages.FindPagePosByFilePath(path); i >= 0 {
|
||||
page := s.Pages[i]
|
||||
|
||||
|
@ -1020,7 +1021,7 @@ func (s *Site) RemovePageByPath(path string) {
|
|||
}
|
||||
}
|
||||
|
||||
func (s *Site) RemovePage(page *Page) {
|
||||
func (s *Site) removePage(page *Page) {
|
||||
if i := s.Pages.FindPagePos(page); i >= 0 {
|
||||
if page.IsDraft() {
|
||||
s.draftCount--
|
||||
|
@ -1034,13 +1035,13 @@ func (s *Site) RemovePage(page *Page) {
|
|||
}
|
||||
}
|
||||
|
||||
func (s *Site) ReplacePage(page *Page) {
|
||||
func (s *Site) replacePage(page *Page) {
|
||||
// will find existing page that matches filepath and remove it
|
||||
s.RemovePage(page)
|
||||
s.AddPage(page)
|
||||
s.removePage(page)
|
||||
s.addPage(page)
|
||||
}
|
||||
|
||||
func (s *Site) ReplaceFile(sf *source.File) {
|
||||
func (s *Site) replaceFile(sf *source.File) {
|
||||
for i, f := range s.Files {
|
||||
if f.Path() == sf.Path() {
|
||||
s.Files[i] = sf
|
||||
|
@ -1061,10 +1062,10 @@ func incrementalReadCollator(s *Site, results <-chan HandledResult, pageChan cha
|
|||
}
|
||||
|
||||
if r.page == nil {
|
||||
s.ReplaceFile(r.file)
|
||||
s.replaceFile(r.file)
|
||||
fileConvChan <- r.file
|
||||
} else {
|
||||
s.ReplacePage(r.page)
|
||||
s.replacePage(r.page)
|
||||
pageChan <- r.page
|
||||
}
|
||||
}
|
||||
|
@ -1091,7 +1092,7 @@ func readCollator(s *Site, results <-chan HandledResult, errs chan<- error) {
|
|||
if r.page == nil {
|
||||
s.Files = append(s.Files, r.file)
|
||||
} else {
|
||||
s.AddPage(r.page)
|
||||
s.addPage(r.page)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1103,7 +1104,7 @@ func readCollator(s *Site, results <-chan HandledResult, errs chan<- error) {
|
|||
errs <- fmt.Errorf("Errors reading pages: %s", strings.Join(errMsgs, "\n"))
|
||||
}
|
||||
|
||||
func (s *Site) BuildSiteMeta() (err error) {
|
||||
func (s *Site) buildSiteMeta() (err error) {
|
||||
s.assembleMenus()
|
||||
|
||||
if len(s.Pages) == 0 {
|
||||
|
@ -1319,8 +1320,8 @@ func (s *Site) possibleTaxonomies() (taxonomies []string) {
|
|||
return
|
||||
}
|
||||
|
||||
// RenderAliases renders shell pages that simply have a redirect in the header
|
||||
func (s *Site) RenderAliases() error {
|
||||
// renderAliases renders shell pages that simply have a redirect in the header.
|
||||
func (s *Site) renderAliases() error {
|
||||
for _, p := range s.Pages {
|
||||
if len(p.Aliases) == 0 {
|
||||
continue
|
||||
|
@ -1332,7 +1333,7 @@ func (s *Site) RenderAliases() error {
|
|||
}
|
||||
|
||||
for _, a := range p.Aliases {
|
||||
if err := s.WriteDestAlias(a, plink); err != nil {
|
||||
if err := s.writeDestAlias(a, plink); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -1340,8 +1341,8 @@ func (s *Site) RenderAliases() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// RenderPages renders pages each corresponding to a markdown file
|
||||
func (s *Site) RenderPages() error {
|
||||
// renderPages renders pages each corresponding to a markdown file.
|
||||
func (s *Site) renderPages() error {
|
||||
|
||||
results := make(chan error)
|
||||
pages := make(chan *Page)
|
||||
|
@ -1457,9 +1458,9 @@ type taxRenderInfo struct {
|
|||
plural string
|
||||
}
|
||||
|
||||
// RenderTaxonomiesLists renders the listing pages based on the meta data
|
||||
// renderTaxonomiesLists renders the listing pages based on the meta data
|
||||
// each unique term within a taxonomy will have a page created
|
||||
func (s *Site) RenderTaxonomiesLists() error {
|
||||
func (s *Site) renderTaxonomiesLists() error {
|
||||
wg := &sync.WaitGroup{}
|
||||
|
||||
taxes := make(chan taxRenderInfo)
|
||||
|
@ -1497,7 +1498,7 @@ func (s *Site) RenderTaxonomiesLists() error {
|
|||
|
||||
func (s *Site) newTaxonomyNode(t taxRenderInfo) (*Node, string) {
|
||||
key := t.key
|
||||
n := s.NewNode()
|
||||
n := s.newNode()
|
||||
if s.Info.preserveTaxonomyNames {
|
||||
key = helpers.MakePathSanitized(key)
|
||||
// keep as is in the title
|
||||
|
@ -1548,7 +1549,7 @@ func taxonomyRenderer(s *Site, taxes <-chan taxRenderInfo, results chan<- error,
|
|||
paginatePath := viper.GetString("paginatePath")
|
||||
|
||||
// write alias for page 1
|
||||
s.WriteDestAlias(helpers.PaginateAliasPath(base, 1), s.permalink(base))
|
||||
s.writeDestAlias(helpers.PaginateAliasPath(base, 1), s.permalink(base))
|
||||
|
||||
pagers := n.paginator.Pagers()
|
||||
|
||||
|
@ -1589,11 +1590,11 @@ func taxonomyRenderer(s *Site, taxes <-chan taxRenderInfo, results chan<- error,
|
|||
}
|
||||
}
|
||||
|
||||
// RenderListsOfTaxonomyTerms renders a page per taxonomy that lists the terms for that taxonomy
|
||||
func (s *Site) RenderListsOfTaxonomyTerms() (err error) {
|
||||
// renderListsOfTaxonomyTerms renders a page per taxonomy that lists the terms for that taxonomy
|
||||
func (s *Site) renderListsOfTaxonomyTerms() (err error) {
|
||||
taxonomies := viper.GetStringMapString("Taxonomies")
|
||||
for singular, plural := range taxonomies {
|
||||
n := s.NewNode()
|
||||
n := s.newNode()
|
||||
n.Title = strings.Title(plural)
|
||||
s.setURLs(n, plural)
|
||||
n.Data["Singular"] = singular
|
||||
|
@ -1615,7 +1616,7 @@ func (s *Site) RenderListsOfTaxonomyTerms() (err error) {
|
|||
}
|
||||
|
||||
func (s *Site) newSectionListNode(sectionName, section string, data WeightedPages) *Node {
|
||||
n := s.NewNode()
|
||||
n := s.newNode()
|
||||
sectionName = helpers.FirstUpper(sectionName)
|
||||
if viper.GetBool("PluralizeListTitles") {
|
||||
n.Title = inflect.Pluralize(sectionName)
|
||||
|
@ -1630,8 +1631,8 @@ func (s *Site) newSectionListNode(sectionName, section string, data WeightedPage
|
|||
return n
|
||||
}
|
||||
|
||||
// RenderSectionLists renders a page for each section
|
||||
func (s *Site) RenderSectionLists() error {
|
||||
// renderSectionLists renders a page for each section
|
||||
func (s *Site) renderSectionLists() error {
|
||||
for section, data := range s.Sections {
|
||||
// section keys can be lower case (depending on site.pathifyTaxonomyKeys)
|
||||
// extract the original casing from the first page to get sensible titles.
|
||||
|
@ -1656,7 +1657,7 @@ func (s *Site) RenderSectionLists() error {
|
|||
paginatePath := viper.GetString("paginatePath")
|
||||
|
||||
// write alias for page 1
|
||||
s.WriteDestAlias(helpers.PaginateAliasPath(section, 1), s.permalink(section))
|
||||
s.writeDestAlias(helpers.PaginateAliasPath(section, 1), s.permalink(section))
|
||||
|
||||
pagers := n.paginator.Pagers()
|
||||
|
||||
|
@ -1696,7 +1697,7 @@ func (s *Site) RenderSectionLists() error {
|
|||
}
|
||||
|
||||
func (s *Site) newHomeNode() *Node {
|
||||
n := s.NewNode()
|
||||
n := s.newNode()
|
||||
n.Title = n.Site.Title
|
||||
n.IsHome = true
|
||||
s.setURLs(n, "/")
|
||||
|
@ -1708,7 +1709,7 @@ func (s *Site) newHomeNode() *Node {
|
|||
return n
|
||||
}
|
||||
|
||||
func (s *Site) RenderHomePage() error {
|
||||
func (s *Site) renderHomePage() error {
|
||||
n := s.newHomeNode()
|
||||
layouts := s.appendThemeTemplates([]string{"index.html", "_default/list.html"})
|
||||
|
||||
|
@ -1721,7 +1722,7 @@ func (s *Site) RenderHomePage() error {
|
|||
paginatePath := viper.GetString("paginatePath")
|
||||
|
||||
// write alias for page 1
|
||||
s.WriteDestAlias(helpers.PaginateAliasPath("", 1), s.permalink("/"))
|
||||
s.writeDestAlias(helpers.PaginateAliasPath("", 1), s.permalink("/"))
|
||||
|
||||
pagers := n.paginator.Pagers()
|
||||
|
||||
|
@ -1782,14 +1783,14 @@ func (s *Site) RenderHomePage() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *Site) RenderSitemap() error {
|
||||
func (s *Site) renderSitemap() error {
|
||||
if viper.GetBool("DisableSitemap") {
|
||||
return nil
|
||||
}
|
||||
|
||||
sitemapDefault := parseSitemap(viper.GetStringMap("Sitemap"))
|
||||
|
||||
n := s.NewNode()
|
||||
n := s.newNode()
|
||||
|
||||
// Prepend homepage to the list of pages
|
||||
pages := make(Pages, 0)
|
||||
|
@ -1830,12 +1831,12 @@ func (s *Site) RenderSitemap() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *Site) RenderRobotsTXT() error {
|
||||
func (s *Site) renderRobotsTXT() error {
|
||||
if !viper.GetBool("EnableRobotsTXT") {
|
||||
return nil
|
||||
}
|
||||
|
||||
n := s.NewNode()
|
||||
n := s.newNode()
|
||||
n.Data["Pages"] = s.Pages
|
||||
|
||||
rLayouts := []string{"robots.txt", "_default/robots.txt", "_internal/_default/robots.txt"}
|
||||
|
@ -1844,7 +1845,7 @@ func (s *Site) RenderRobotsTXT() error {
|
|||
err := s.render("robots", n, outBuffer, s.appendThemeTemplates(rLayouts)...)
|
||||
|
||||
if err == nil {
|
||||
err = s.WriteDestFile("robots.txt", outBuffer)
|
||||
err = s.writeDestFile("robots.txt", outBuffer)
|
||||
}
|
||||
|
||||
return err
|
||||
|
@ -1879,7 +1880,7 @@ func (s *Site) permalinkStr(plink string) string {
|
|||
return helpers.MakePermalink(viper.GetString("BaseURL"), helpers.URLizeAndPrep(plink)).String()
|
||||
}
|
||||
|
||||
func (s *Site) NewNode() *Node {
|
||||
func (s *Site) newNode() *Node {
|
||||
return &Node{
|
||||
Data: make(map[string]interface{}),
|
||||
Site: &s.Info,
|
||||
|
@ -1916,7 +1917,7 @@ func (s *Site) renderAndWriteXML(name string, dest string, d interface{}, layout
|
|||
transformer.Apply(outBuffer, renderBuffer, path)
|
||||
|
||||
if err == nil {
|
||||
err = s.WriteDestFile(dest, outBuffer)
|
||||
err = s.writeDestFile(dest, outBuffer)
|
||||
}
|
||||
|
||||
return err
|
||||
|
@ -1947,7 +1948,7 @@ func (s *Site) renderAndWritePage(name string, dest string, d interface{}, layou
|
|||
transformLinks = append(transformLinks, transform.AbsURL)
|
||||
}
|
||||
|
||||
if s.Running() && viper.GetBool("watch") && !viper.GetBool("DisableLiveReload") {
|
||||
if s.running() && viper.GetBool("watch") && !viper.GetBool("DisableLiveReload") {
|
||||
transformLinks = append(transformLinks, transform.LiveReloadInject)
|
||||
}
|
||||
|
||||
|
@ -1985,7 +1986,7 @@ func (s *Site) renderAndWritePage(name string, dest string, d interface{}, layou
|
|||
}
|
||||
|
||||
if err == nil {
|
||||
if err = s.WriteDestPage(dest, pageTarget, outBuffer); err != nil {
|
||||
if err = s.writeDestPage(dest, pageTarget, outBuffer); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -2002,7 +2003,7 @@ func (s *Site) render(name string, d interface{}, w io.Writer, layouts ...string
|
|||
if err := s.renderThing(d, layout, w); err != nil {
|
||||
// Behavior here should be dependent on if running in server or watch mode.
|
||||
distinctErrorLogger.Printf("Error while rendering %s: %v", name, err)
|
||||
if !s.Running() && !testMode {
|
||||
if !s.running() && !testMode {
|
||||
// TODO(bep) check if this can be propagated
|
||||
os.Exit(-1)
|
||||
} else if testMode {
|
||||
|
@ -2078,17 +2079,17 @@ func (s *Site) initTargetList() {
|
|||
})
|
||||
}
|
||||
|
||||
func (s *Site) WriteDestFile(path string, reader io.Reader) (err error) {
|
||||
func (s *Site) writeDestFile(path string, reader io.Reader) (err error) {
|
||||
jww.DEBUG.Println("creating file:", path)
|
||||
return s.fileTarget().Publish(path, reader)
|
||||
}
|
||||
|
||||
func (s *Site) WriteDestPage(path string, publisher target.Publisher, reader io.Reader) (err error) {
|
||||
func (s *Site) writeDestPage(path string, publisher target.Publisher, reader io.Reader) (err error) {
|
||||
jww.DEBUG.Println("creating page:", path)
|
||||
return publisher.Publish(path, reader)
|
||||
}
|
||||
|
||||
func (s *Site) WriteDestAlias(path string, permalink string) (err error) {
|
||||
func (s *Site) writeDestAlias(path string, permalink string) (err error) {
|
||||
jww.DEBUG.Println("creating alias:", path)
|
||||
return s.aliasTarget().Publish(path, permalink)
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ func TestDegenerateNoTarget(t *testing.T) {
|
|||
s := &Site{
|
||||
Source: &source.InMemorySource{ByteSource: fakeSource},
|
||||
}
|
||||
must(s.CreatePages())
|
||||
must(s.createPages())
|
||||
expected := "foo/bar/file.md (renderer: markdown)\n canonical => !no target specified!\n\n" +
|
||||
"alias/test/file1.md (renderer: markdown)\n canonical => !no target specified!\n\n" +
|
||||
"section/somecontent.html (renderer: n/a)\n canonical => !no target specified!\n\n"
|
||||
|
@ -90,7 +90,7 @@ func TestFileTarget(t *testing.T) {
|
|||
}
|
||||
s.aliasTarget()
|
||||
s.pageTarget()
|
||||
must(s.CreatePages())
|
||||
must(s.createPages())
|
||||
expected := "foo/bar/file.md (renderer: markdown)\n canonical => foo/bar/file/index.html\n\n" +
|
||||
"alias/test/file1.md (renderer: markdown)\n" +
|
||||
" canonical => alias/test/file1/index.html\n" +
|
||||
|
@ -113,7 +113,7 @@ func TestPageTargetUgly(t *testing.T) {
|
|||
}
|
||||
s.aliasTarget()
|
||||
|
||||
s.CreatePages()
|
||||
s.createPages()
|
||||
expected := "foo/bar/file.md (renderer: markdown)\n canonical => foo/bar/file.html\n\n" +
|
||||
"alias/test/file1.md (renderer: markdown)\n" +
|
||||
" canonical => alias/test/file1.html\n" +
|
||||
|
@ -137,7 +137,7 @@ func TestFileTargetPublishDir(t *testing.T) {
|
|||
Source: &source.InMemorySource{ByteSource: fakeSource},
|
||||
}
|
||||
|
||||
must(s.CreatePages())
|
||||
must(s.createPages())
|
||||
expected := "foo/bar/file.md (renderer: markdown)\n canonical => ../public/foo/bar/file/index.html\n\n" +
|
||||
"alias/test/file1.md (renderer: markdown)\n" +
|
||||
" canonical => ../public/alias/test/file1/index.html\n" +
|
||||
|
|
|
@ -80,7 +80,7 @@ func TestReadPagesFromSourceWithEmptySource(t *testing.T) {
|
|||
d := time.Second * 2
|
||||
ticker := time.NewTicker(d)
|
||||
select {
|
||||
case err = <-s.ReadPagesFromSource():
|
||||
case err = <-s.readPagesFromSource():
|
||||
break
|
||||
case <-ticker.C:
|
||||
err = fmt.Errorf("ReadPagesFromSource() never returns in %s", d.String())
|
||||
|
@ -92,15 +92,15 @@ func TestReadPagesFromSourceWithEmptySource(t *testing.T) {
|
|||
}
|
||||
|
||||
func createAndRenderPages(t *testing.T, s *Site) {
|
||||
if err := s.CreatePages(); err != nil {
|
||||
if err := s.createPages(); err != nil {
|
||||
t.Fatalf("Unable to create pages: %s", err)
|
||||
}
|
||||
|
||||
if err := s.BuildSiteMeta(); err != nil {
|
||||
if err := s.buildSiteMeta(); err != nil {
|
||||
t.Fatalf("Unable to build site metadata: %s", err)
|
||||
}
|
||||
|
||||
if err := s.RenderPages(); err != nil {
|
||||
if err := s.renderPages(); err != nil {
|
||||
t.Fatalf("Unable to render pages. %s", err)
|
||||
}
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ func TestDraftAndFutureRender(t *testing.T) {
|
|||
|
||||
s.initializeSiteInfo()
|
||||
|
||||
if err := s.CreatePages(); err != nil {
|
||||
if err := s.createPages(); err != nil {
|
||||
t.Fatalf("Unable to create pages: %s", err)
|
||||
}
|
||||
return s
|
||||
|
@ -433,8 +433,8 @@ func doTestShouldAlwaysHaveUglyURLs(t *testing.T, uglyURLs bool) {
|
|||
"sitemap.xml", "<root>SITEMAP</root>")
|
||||
|
||||
createAndRenderPages(t, s)
|
||||
s.RenderHomePage()
|
||||
s.RenderSitemap()
|
||||
s.renderHomePage()
|
||||
s.renderSitemap()
|
||||
|
||||
var expectedPagePath string
|
||||
if uglyURLs {
|
||||
|
@ -522,7 +522,7 @@ func doTestSectionNaming(t *testing.T, canonify, uglify, pluralize bool) {
|
|||
"_default/list.html", "{{ .Title }}")
|
||||
|
||||
createAndRenderPages(t, s)
|
||||
s.RenderSectionLists()
|
||||
s.renderSectionLists()
|
||||
|
||||
tests := []struct {
|
||||
doc string
|
||||
|
@ -640,15 +640,15 @@ func TestAbsURLify(t *testing.T) {
|
|||
|
||||
s.prepTemplates("blue/single.html", templateWithURLAbs)
|
||||
|
||||
if err := s.CreatePages(); err != nil {
|
||||
if err := s.createPages(); err != nil {
|
||||
t.Fatalf("Unable to create pages: %s", err)
|
||||
}
|
||||
|
||||
if err := s.BuildSiteMeta(); err != nil {
|
||||
if err := s.buildSiteMeta(); err != nil {
|
||||
t.Fatalf("Unable to build site metadata: %s", err)
|
||||
}
|
||||
|
||||
if err := s.RenderPages(); err != nil {
|
||||
if err := s.renderPages(); err != nil {
|
||||
t.Fatalf("Unable to render pages. %s", err)
|
||||
}
|
||||
|
||||
|
@ -737,11 +737,11 @@ func TestOrderedPages(t *testing.T) {
|
|||
}
|
||||
s.initializeSiteInfo()
|
||||
|
||||
if err := s.CreatePages(); err != nil {
|
||||
if err := s.createPages(); err != nil {
|
||||
t.Fatalf("Unable to create pages: %s", err)
|
||||
}
|
||||
|
||||
if err := s.BuildSiteMeta(); err != nil {
|
||||
if err := s.buildSiteMeta(); err != nil {
|
||||
t.Fatalf("Unable to build site metadata: %s", err)
|
||||
}
|
||||
|
||||
|
@ -811,11 +811,11 @@ func TestGroupedPages(t *testing.T) {
|
|||
}
|
||||
s.initializeSiteInfo()
|
||||
|
||||
if err := s.CreatePages(); err != nil {
|
||||
if err := s.createPages(); err != nil {
|
||||
t.Fatalf("Unable to create pages: %s", err)
|
||||
}
|
||||
|
||||
if err := s.BuildSiteMeta(); err != nil {
|
||||
if err := s.buildSiteMeta(); err != nil {
|
||||
t.Fatalf("Unable to build site metadata: %s", err)
|
||||
}
|
||||
|
||||
|
@ -1001,11 +1001,11 @@ func TestWeightedTaxonomies(t *testing.T) {
|
|||
}
|
||||
s.initializeSiteInfo()
|
||||
|
||||
if err := s.CreatePages(); err != nil {
|
||||
if err := s.createPages(); err != nil {
|
||||
t.Fatalf("Unable to create pages: %s", err)
|
||||
}
|
||||
|
||||
if err := s.BuildSiteMeta(); err != nil {
|
||||
if err := s.buildSiteMeta(); err != nil {
|
||||
t.Fatalf("Unable to build site metadata: %s", err)
|
||||
}
|
||||
|
||||
|
@ -1075,7 +1075,7 @@ func setupLinkingMockSite(t *testing.T) *Site {
|
|||
|
||||
site.initializeSiteInfo()
|
||||
|
||||
if err := site.CreatePages(); err != nil {
|
||||
if err := site.createPages(); err != nil {
|
||||
t.Fatalf("Unable to create pages: %s", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -97,18 +97,18 @@ func TestPageCount(t *testing.T) {
|
|||
s.initializeSiteInfo()
|
||||
s.prepTemplates("indexes/blue.html", indexTemplate)
|
||||
|
||||
if err := s.CreatePages(); err != nil {
|
||||
if err := s.createPages(); err != nil {
|
||||
t.Errorf("Unable to create pages: %s", err)
|
||||
}
|
||||
if err := s.BuildSiteMeta(); err != nil {
|
||||
if err := s.buildSiteMeta(); err != nil {
|
||||
t.Errorf("Unable to build site metadata: %s", err)
|
||||
}
|
||||
|
||||
if err := s.RenderSectionLists(); err != nil {
|
||||
if err := s.renderSectionLists(); err != nil {
|
||||
t.Errorf("Unable to render section lists: %s", err)
|
||||
}
|
||||
|
||||
if err := s.RenderAliases(); err != nil {
|
||||
if err := s.renderAliases(); err != nil {
|
||||
t.Errorf("Unable to render site lists: %s", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ func TestSiteInfoParams(t *testing.T) {
|
|||
|
||||
buf := new(bytes.Buffer)
|
||||
|
||||
err := s.renderThing(s.NewNode(), "template", buf)
|
||||
err := s.renderThing(s.newNode(), "template", buf)
|
||||
if err != nil {
|
||||
t.Errorf("Unable to render template: %s", err)
|
||||
}
|
||||
|
|
|
@ -51,23 +51,23 @@ func TestSitemapOutput(t *testing.T) {
|
|||
|
||||
s.prepTemplates("sitemap.xml", SITEMAP_TEMPLATE)
|
||||
|
||||
if err := s.CreatePages(); err != nil {
|
||||
if err := s.createPages(); err != nil {
|
||||
t.Fatalf("Unable to create pages: %s", err)
|
||||
}
|
||||
|
||||
if err := s.BuildSiteMeta(); err != nil {
|
||||
if err := s.buildSiteMeta(); err != nil {
|
||||
t.Fatalf("Unable to build site metadata: %s", err)
|
||||
}
|
||||
|
||||
if err := s.RenderHomePage(); err != nil {
|
||||
if err := s.renderHomePage(); err != nil {
|
||||
t.Fatalf("Unable to RenderHomePage: %s", err)
|
||||
}
|
||||
|
||||
if err := s.RenderSitemap(); err != nil {
|
||||
if err := s.renderSitemap(); err != nil {
|
||||
t.Fatalf("Unable to RenderSitemap: %s", err)
|
||||
}
|
||||
|
||||
if err := s.RenderRobotsTXT(); err != nil {
|
||||
if err := s.renderRobotsTXT(); err != nil {
|
||||
t.Fatalf("Unable to RenderRobotsTXT :%s", err)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue