|
|
@ -24,6 +24,8 @@ import ( |
|
|
|
"github.com/barasher/go-exiftool" |
|
|
|
"github.com/disintegration/imaging" |
|
|
|
"github.com/gabriel-vasile/mimetype" |
|
|
|
"github.com/k0kubun/go-ansi" |
|
|
|
"github.com/schollz/progressbar/v3" |
|
|
|
"github.com/sirupsen/logrus" |
|
|
|
"github.com/urfave/cli/v2" |
|
|
|
) |
|
|
@ -235,14 +237,12 @@ Example: |
|
|
|
|
|
|
|
ch := make(chan error, 2) |
|
|
|
go func() { |
|
|
|
logrus.Debug("distribuis commencing generation...") |
|
|
|
|
|
|
|
if err := distribusify(c, root, ignore); err != nil { |
|
|
|
ch <- err |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
logrus.Debug("distribusi finished generation!") |
|
|
|
fmt.Printf("done!") |
|
|
|
|
|
|
|
ch <- nil |
|
|
|
return |
|
|
@ -285,6 +285,8 @@ Example: |
|
|
|
func distribusify(c *cli.Context, root string, ignore []string) error { |
|
|
|
var allDirs []string |
|
|
|
|
|
|
|
progress := mkProgressBar() |
|
|
|
|
|
|
|
if err := filepath.Walk(root, func(fpath string, finfo os.FileInfo, err error) error { |
|
|
|
|
|
|
|
skip, err := shouldSkip(c, fpath, ignore) |
|
|
@ -368,6 +370,7 @@ func distribusify(c *cli.Context, root string, ignore []string) error { |
|
|
|
} |
|
|
|
|
|
|
|
html = append(html, div) |
|
|
|
progress.Add(1) |
|
|
|
} |
|
|
|
|
|
|
|
for _, file := range files { |
|
|
@ -400,6 +403,7 @@ func distribusify(c *cli.Context, root string, ignore []string) error { |
|
|
|
} |
|
|
|
|
|
|
|
html = append(html, div) |
|
|
|
progress.Add(1) |
|
|
|
} |
|
|
|
|
|
|
|
if err := writeIndex(absPath, html, c.String("css")); err != nil { |
|
|
@ -499,9 +503,9 @@ func getCaption(c *cli.Context, fpath string) (string, error) { |
|
|
|
} |
|
|
|
|
|
|
|
if caption != "" { |
|
|
|
logrus.Debug("retrieved caption %s from %s", caption, fpath) |
|
|
|
logrus.Debugf("retrieved caption %s from %s", caption, fpath) |
|
|
|
} else { |
|
|
|
logrus.Debug("no comment retrieved for %s", fpath) |
|
|
|
logrus.Debugf("no comment retrieved for %s", fpath) |
|
|
|
} |
|
|
|
|
|
|
|
return caption, nil |
|
|
@ -686,7 +690,7 @@ func serveHTTP(fpath string) error { |
|
|
|
fs := http.FileServer(http.Dir(fpath)) |
|
|
|
http.Handle("/", fs) |
|
|
|
|
|
|
|
logrus.Infof("distribusi live @ http://localhost%s", port) |
|
|
|
logrus.Infof("distribusi serving from http://localhost%s", port) |
|
|
|
|
|
|
|
if err := http.ListenAndServe(port, nil); err != nil { |
|
|
|
return err |
|
|
@ -754,3 +758,15 @@ func getLogFile() (*os.File, error) { |
|
|
|
|
|
|
|
return file, nil |
|
|
|
} |
|
|
|
|
|
|
|
// mkProgressBar creates a progress bar.
|
|
|
|
func mkProgressBar() *progressbar.ProgressBar { |
|
|
|
bar := progressbar.NewOptions(-1, |
|
|
|
progressbar.OptionSetDescription("distribusifying... this may take some time..."), |
|
|
|
progressbar.OptionSetWriter(ansi.NewAnsiStdout()), |
|
|
|
progressbar.OptionEnableColorCodes(true), |
|
|
|
progressbar.OptionShowCount(), |
|
|
|
progressbar.OptionSpinnerType(9), |
|
|
|
) |
|
|
|
return bar |
|
|
|
} |
|
|
|