diff options
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -46,6 +46,12 @@ type post struct { Time time.Time Link string Content string + Images []*image // list of urls +} + +type image struct { + Source string + Caption string } func (p *post) String() string { @@ -61,6 +67,12 @@ func (p *post) String() string { // time format: Mon Jan 2 15:04:05 -0700 MST 2006 s = strings.Replace(template, "{{time}}", p.Time.Format("Mon, 2 Jan 2006 15:04:05 MST"), 2) s = strings.Replace(s, "{{content}}", p.Content, 1) + var imgs string + for i := range p.Images { + imgs += `<a href="` + p.Images[i].Source + `"><img src="` + p.Images[i].Source + `" title="` + p.Images[i].Caption + `"></a>` + } + s = strings.Replace(s, "{{images}}", imgs, 1) + return s } |