about summary refs log tree commit diff stats
path: root/internal/atom/atom.go
blob: 19ad0d1940b8b54c91b577a564c1af56f6ebd537 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package atom

import (
	"encoding/xml"
	"time"

	"website/internal/config"
)

func MakeTagURI(config *config.Config, specific string) string {
	return "tag:" + config.OriginalDomain + "," + config.DomainStartDate + ":" + specific
}

type Link struct {
	XMLName xml.Name `xml:"link"`
	Rel     string   `xml:"rel,attr"`
	Type    string   `xml:"type,attr"`
	Href    string   `xml:"href,attr"`
}

func MakeLink(url string) Link {
	return Link{
		Rel:  "alternate",
		Type: "text/html",
		Href: url,
	}
}

type FeedContent struct {
	Content string `xml:",chardata"`
	Type    string `xml:"type,attr"`
}

type FeedEntry struct {
	XMLName xml.Name    `xml:"entry"`
	Title   string      `xml:"title"`
	Link    Link        `xml:"link"`
	ID      string      `xml:"id"`
	Updated time.Time   `xml:"updated"`
	Summary string      `xml:"summary,omitempty"`
	Content FeedContent `xml:"content"`
	Author  string      `xml:"author>name"`
}