mirror of
https://git.sr.ht/~adnano/kiln
synced 2024-10-30 01:13:08 +00:00
dir: Make methods private
This commit is contained in:
parent
ef3d518d9a
commit
cf7a24bb6c
22
dir.go
22
dir.go
|
@ -47,12 +47,12 @@ func NewDir(path string) *Dir {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read reads from a directory and indexes the files and directories within it.
|
// read reads from a directory and indexes the files and directories within it.
|
||||||
func (d *Dir) Read(srcDir string, task *Task) error {
|
func (d *Dir) read(srcDir string, task *Task) error {
|
||||||
return d.read(srcDir, "", task)
|
return d._read(srcDir, "", task)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Dir) read(srcDir, path string, task *Task) error {
|
func (d *Dir) _read(srcDir, path string, task *Task) error {
|
||||||
entries, err := ioutil.ReadDir(pathpkg.Join(srcDir, path))
|
entries, err := ioutil.ReadDir(pathpkg.Join(srcDir, path))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -67,7 +67,7 @@ func (d *Dir) read(srcDir, path string, task *Task) error {
|
||||||
if entry.IsDir() {
|
if entry.IsDir() {
|
||||||
// Gather directory data
|
// Gather directory data
|
||||||
dir := NewDir(path)
|
dir := NewDir(path)
|
||||||
if err := dir.read(srcDir, path, task); err != nil {
|
if err := dir._read(srcDir, path, task); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
d.Dirs = append(d.Dirs, dir)
|
d.Dirs = append(d.Dirs, dir)
|
||||||
|
@ -140,8 +140,8 @@ func (d *Dir) read(srcDir, path string, task *Task) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process processes the directory's contents.
|
// process processes the directory's contents.
|
||||||
func (d *Dir) Process(cfg *Config, task *Task) error {
|
func (d *Dir) process(cfg *Config, task *Task) error {
|
||||||
if task.TemplateExt != "" {
|
if task.TemplateExt != "" {
|
||||||
// Create index
|
// Create index
|
||||||
if d.index != nil {
|
if d.index != nil {
|
||||||
|
@ -198,15 +198,15 @@ func (d *Dir) Process(cfg *Config, task *Task) error {
|
||||||
|
|
||||||
// Process subdirectories
|
// Process subdirectories
|
||||||
for _, d := range d.Dirs {
|
for _, d := range d.Dirs {
|
||||||
if err := d.Process(cfg, task); err != nil {
|
if err := d.process(cfg, task); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write writes the directory's contents to the provided destination path.
|
// write writes the directory's contents to the provided destination path.
|
||||||
func (d *Dir) Write(dstDir string, task *Task) error {
|
func (d *Dir) write(dstDir string, task *Task) error {
|
||||||
// Create the directory
|
// Create the directory
|
||||||
dirPath := pathpkg.Join(dstDir, d.Path)
|
dirPath := pathpkg.Join(dstDir, d.Path)
|
||||||
if err := os.MkdirAll(dirPath, 0755); err != nil {
|
if err := os.MkdirAll(dirPath, 0755); err != nil {
|
||||||
|
@ -250,7 +250,7 @@ func (d *Dir) Write(dstDir string, task *Task) error {
|
||||||
|
|
||||||
// Write subdirectories
|
// Write subdirectories
|
||||||
for _, dir := range d.Dirs {
|
for _, dir := range d.Dirs {
|
||||||
dir.Write(dstDir, task)
|
dir.write(dstDir, task)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
6
main.go
6
main.go
|
@ -83,16 +83,16 @@ func run(cfg *Config) error {
|
||||||
func runTask(cfg *Config, task *Task) error {
|
func runTask(cfg *Config, task *Task) error {
|
||||||
// Read content
|
// Read content
|
||||||
dir := NewDir("")
|
dir := NewDir("")
|
||||||
if err := dir.Read("content", task); err != nil {
|
if err := dir.read("content", task); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
dir.sort()
|
dir.sort()
|
||||||
// Process content
|
// Process content
|
||||||
if err := dir.Process(cfg, task); err != nil {
|
if err := dir.process(cfg, task); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Write content
|
// Write content
|
||||||
if err := dir.Write(task.OutputDir, task); err != nil {
|
if err := dir.write(task.OutputDir, task); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Copy static files
|
// Copy static files
|
||||||
|
|
Loading…
Reference in a new issue