"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "create/content.go" between
hugo-0.85.0.tar.gz and hugo-0.86.0.tar.gz

About: Hugo is a static site generator that takes a source directory of Markdown files and templates and uses these as input to create a complete website (written in Go).

content.go  (hugo-0.85.0):content.go  (hugo-0.86.0)
skipping to change at line 126 skipping to change at line 126
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr
return cmd.Run() return cmd.Run()
} }
return nil return nil
} }
func targetSite(sites *hugolib.HugoSites, fi hugofs.FileMetaInfo) *hugolib.Site { func targetSite(sites *hugolib.HugoSites, fi hugofs.FileMetaInfo) *hugolib.Site {
for _, s := range sites.Sites { for _, s := range sites.Sites {
if fi.Meta().Lang() == s.Language().Lang { if fi.Meta().Lang == s.Language().Lang {
return s return s
} }
} }
return sites.Sites[0] return sites.Sites[0]
} }
func newContentFromDir( func newContentFromDir(
archetypeDir string, archetypeDir string,
sites *hugolib.HugoSites, sites *hugolib.HugoSites,
targetFs afero.Fs, targetFs afero.Fs,
cm archetypeMap, name, targetPath string) error { cm archetypeMap, name, targetPath string) error {
for _, f := range cm.otherFiles { for _, f := range cm.otherFiles {
meta := f.Meta() meta := f.Meta()
filename := meta.Path() filename := meta.Path
// Just copy the file to destination. // Just copy the file to destination.
in, err := meta.Open() in, err := meta.Open()
if err != nil { if err != nil {
return errors.Wrap(err, "failed to open non-content file" ) return errors.Wrap(err, "failed to open non-content file" )
} }
targetFilename := filepath.Join(targetPath, strings.TrimPrefix(fi lename, archetypeDir)) targetFilename := filepath.Join(targetPath, strings.TrimPrefix(fi lename, archetypeDir))
targetDir := filepath.Dir(targetFilename) targetDir := filepath.Dir(targetFilename)
if err := targetFs.MkdirAll(targetDir, 0777); err != nil && !os.I sExist(err) { if err := targetFs.MkdirAll(targetDir, 0777); err != nil && !os.I sExist(err) {
skipping to change at line 169 skipping to change at line 169
_, err = io.Copy(out, in) _, err = io.Copy(out, in)
if err != nil { if err != nil {
return err return err
} }
in.Close() in.Close()
out.Close() out.Close()
} }
for _, f := range cm.contentFiles { for _, f := range cm.contentFiles {
filename := f.Meta().Path() filename := f.Meta().Path
s := targetSite(sites, f) s := targetSite(sites, f)
targetFilename := filepath.Join(targetPath, strings.TrimPrefix(fi lename, archetypeDir)) targetFilename := filepath.Join(targetPath, strings.TrimPrefix(fi lename, archetypeDir))
content, err := executeArcheTypeAsTemplate(s, name, archetypeDir, targetFilename, filename) content, err := executeArcheTypeAsTemplate(s, name, archetypeDir, targetFilename, filename)
if err != nil { if err != nil {
return errors.Wrap(err, "failed to execute archetype temp late") return errors.Wrap(err, "failed to execute archetype temp late")
} }
if err := helpers.SafeWriteToDisk(targetFilename, bytes.NewReader (content), targetFs); err != nil { if err := helpers.SafeWriteToDisk(targetFilename, bytes.NewReader (content), targetFs); err != nil {
return errors.Wrap(err, "failed to save results") return errors.Wrap(err, "failed to save results")
skipping to change at line 277 skipping to change at line 277
if strings.Contains(targetPath, "."+ss.Language().Lang+".") { if strings.Contains(targetPath, "."+ss.Language().Lang+".") {
s = ss s = ss
break break
} }
} }
var dirLang string var dirLang string
for _, dir := range sites.BaseFs.Content.Dirs { for _, dir := range sites.BaseFs.Content.Dirs {
meta := dir.Meta() meta := dir.Meta()
contentDir := meta.Filename() contentDir := meta.Filename
if !strings.HasSuffix(contentDir, helpers.FilePathSeparator) { if !strings.HasSuffix(contentDir, helpers.FilePathSeparator) {
contentDir += helpers.FilePathSeparator contentDir += helpers.FilePathSeparator
} }
if strings.HasPrefix(targetPath, contentDir) { if strings.HasPrefix(targetPath, contentDir) {
siteContentDir = contentDir siteContentDir = contentDir
dirLang = meta.Lang() dirLang = meta.Lang
break break
} }
} }
if s == nil && dirLang != "" { if s == nil && dirLang != "" {
for _, ss := range sites.Sites { for _, ss := range sites.Sites {
if ss.Lang() == dirLang { if ss.Lang() == dirLang {
s = ss s = ss
break break
} }
skipping to change at line 320 skipping to change at line 320
if siteContentDir == "" { if siteContentDir == "" {
} }
if siteContentDir != "" { if siteContentDir != "" {
pp := filepath.Join(siteContentDir, strings.TrimPrefix(targetPath , siteContentDir)) pp := filepath.Join(siteContentDir, strings.TrimPrefix(targetPath , siteContentDir))
return s.PathSpec.AbsPathify(pp), s return s.PathSpec.AbsPathify(pp), s
} else { } else {
var contentDir string var contentDir string
for _, dir := range sites.BaseFs.Content.Dirs { for _, dir := range sites.BaseFs.Content.Dirs {
contentDir = dir.Meta().Filename() contentDir = dir.Meta().Filename
if dir.Meta().Lang() == s.Lang() { if dir.Meta().Lang == s.Lang() {
break break
} }
} }
return s.PathSpec.AbsPathify(filepath.Join(contentDir, targetPath )), s return s.PathSpec.AbsPathify(filepath.Join(contentDir, targetPath )), s
} }
} }
// FindArchetype takes a given kind/archetype of content and returns the path // FindArchetype takes a given kind/archetype of content and returns the path
// to the archetype in the archetype filesystem, blank if none found. // to the archetype in the archetype filesystem, blank if none found.
func findArchetype(ps *helpers.PathSpec, kind, ext string) (outpath string, isDi r bool) { func findArchetype(ps *helpers.PathSpec, kind, ext string) (outpath string, isDi r bool) {
 End of changes. 6 change blocks. 
7 lines changed or deleted 7 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)