aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Mathes <adam@trenchant.org>2017-02-13 21:27:59 -0800
committerAdam Mathes <adam@trenchant.org>2017-02-13 21:27:59 -0800
commit00609adb8f9c1fdecbafc1098e5ae0635b24cf34 (patch)
treeeb4a069b54b017021a65162c7317c7f861ddd7eb
parent6e8d2d1c35d93d331c0cbb01d06d6ea3f43e42a9 (diff)
downloadsnkt-00609adb8f9c1fdecbafc1098e5ae0635b24cf34.tar.gz
snkt-00609adb8f9c1fdecbafc1098e5ae0635b24cf34.tar.bz2
snkt-00609adb8f9c1fdecbafc1098e5ae0635b24cf34.zip
add ignored_files configuration setting
-rw-r--r--config/config.go12
-rw-r--r--site/site.go16
2 files changed, 24 insertions, 4 deletions
diff --git a/config/config.go b/config/config.go
index c8b702b..c02d163 100644
--- a/config/config.go
+++ b/config/config.go
@@ -26,6 +26,8 @@ type Settings struct {
PreviewServer string `yaml:"preview_server,omitempty"`
PreviewDir string `yaml:"preview_dir,omitempty"`
+ FileBlacklist []string `yaml:"ignore_files,omitempty"`
+
Verbose bool `yaml:"verbose,omitempty"`
}
@@ -79,3 +81,13 @@ func addDefaults() {
Config.PreviewDir = Config.HtmlDir
}
}
+
+// IgnoredFile returns true if `filename` is in the ignored_files config
+func IgnoredFile(filename string) bool {
+ for _, badFile := range Config.FileBlacklist {
+ if filename == badFile {
+ return true
+ }
+ }
+ return false
+}
diff --git a/site/site.go b/site/site.go
index 78eb2f0..a897f4e 100644
--- a/site/site.go
+++ b/site/site.go
@@ -5,6 +5,7 @@ import (
"adammathes.com/snkt/config"
"adammathes.com/snkt/post"
"adammathes.com/snkt/render"
+ "adammathes.com/snkt/vlog"
"io/ioutil"
"log"
"path"
@@ -53,7 +54,7 @@ func (s *Site) Read() {
}
/*
-ReadPosts reads all files from the Config.TxtDir, parses them and stores in s.Posts
+ReadPosts reads all files from the Config.TxtDir, parses them and stores in s.Posts
*/
func (s *Site) ReadPosts() {
// TODO: filter this as needed
@@ -63,15 +64,22 @@ func (s *Site) ReadPosts() {
}
for _, file := range files {
+
+ if config.IgnoredFile(file.Name()) {
+ vlog.Printf("ignoring file: %s\n", file.Name())
+ continue
+ }
+
p := post.NewPost(s)
p.Read(file)
// Ignore post-dated posts unless overriden in config
if !config.Config.ShowFuture && p.InFuture {
- log.Printf("Skipping future dated post: %s\n", p.SourceFile)
- } else {
- s.Posts = append(s.Posts, p)
+ vlog.Printf("Skipping future dated post: %s\n", p.SourceFile)
+ continue
}
+
+ s.Posts = append(s.Posts, p)
}
// Sort the posts by date, earliest first