diff options
author | Adam Mathes <adam@trenchant.org> | 2017-10-01 10:21:54 -0700 |
---|---|---|
committer | Adam Mathes <adam@trenchant.org> | 2017-10-01 10:21:54 -0700 |
commit | 6bd3b789c843bba009b9d42bd0f6fc2893692082 (patch) | |
tree | a3934e0264a2bc4a5ca4cee590ac668b55e4566e /post | |
parent | ffb1ad446af8b1951ff0721736acad79628a716d (diff) | |
download | snkt-6bd3b789c843bba009b9d42bd0f6fc2893692082.tar.gz snkt-6bd3b789c843bba009b9d42bd0f6fc2893692082.tar.bz2 snkt-6bd3b789c843bba009b9d42bd0f6fc2893692082.zip |
add ContainsTag convenience function, clean up TODOs
Diffstat (limited to 'post')
-rw-r--r-- | post/post.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/post/post.go b/post/post.go index 25c9883..5d24af9 100644 --- a/post/post.go +++ b/post/post.go @@ -114,15 +114,14 @@ func (p *Post) Read(fi os.FileInfo) { p.ContentType = "image" p.Unparsed = "" p.parseExif() - // parse as image case "mp4", "mpeg": p.ContentType = "video" p.Unparsed = "" - // parse as image + // TODO: parse video headers case "mp3": p.ContentType = "audio" p.Unparsed = "" - // parse as image + // TODO: mp3/id3 extraction default: p.ContentType = "text" p.Raw, err = ioutil.ReadFile(path.Join(config.Config.TxtDir, p.FileInfo.Name())) @@ -143,7 +142,7 @@ func (p *Post) AbsoluteFilePath() string { Try to extract metadata from EXIF */ func (p *Post) parseExif() { - // TODO: exif parsing? + // TODO: full exif parsing / metadata propogation f,_ := os.Open(p.AbsoluteFilePath()) x,_ := exif.Decode(f) tm,_ := x.DateTime() @@ -345,3 +344,12 @@ func (posts Posts) Limit(limit int) Posts { return posts[0:limit] } } + +func (p *Post) ContainsTag(tag string) bool { + for _,t := range p.Tags { + if t == tag { + return true + } + } + return false +} |