func (a ByTitle) Len() int { return len(a) }
func (a ByTitle) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByTitle) Less(i, j int) bool {
- return strings.Compare(a[i]["Title"][0], a[j]["Title"][0]) < 0
+ return strings.Compare(a[i]["title"][0], a[j]["title"][0]) < 0
}
func main() {
if m["%rec"] != nil {
continue
}
- sort.Strings(m["Category"])
- cats := strings.Join(m["Category"], " ")
- for _, f := range m["Feed"] {
+ sort.Strings(m["cat"])
+ cats := strings.Join(m["cat"], " ")
+ for _, f := range m["feed"] {
if strings.HasPrefix(f, "gemini://") {
f = "https://gemini/" + f
}
if m["%rec"] != nil {
continue
}
- sort.Strings(m["Category"])
+ sort.Strings(m["cat"])
data = append(data, m)
}
sort.Sort(ByTitle(data))
if m["%rec"] != nil {
continue
}
- sort.Strings(m["Category"])
- if cs := m["Category"]; len(cs) == 0 {
+ sort.Strings(m["cat"])
+ if cs := m["cat"]; len(cs) == 0 {
data["Uncategorized"] = append(data["Uncategorized"], m)
} else {
for _, cat := range cs {
ents := data[cat]
for n, ent := range ents {
catsOther := make([]string, 0)
- for _, c := range ent["Category"] {
+ for _, c := range ent["cat"] {
if c != cat {
catsOther = append(catsOther, c)
}
}
var note string
- if len(ent["Note"]) > 0 {
- note = "(" + strings.Trim(ent["Note"][0], " \n") + ")"
+ if len(ent["note"]) > 0 {
+ note = "(" + strings.Trim(ent["note"][0], " \n") + ")"
}
fmt.Printf(
" @item %d @tab @url{%s,, %s} %s @tab %s @tab\n",
n,
- strings.ReplaceAll(ent["URL"][0], "@", "@@"),
- strings.ReplaceAll(ent["Title"][0], "@", "@@"),
+ strings.ReplaceAll(ent["url"][0], "@", "@@"),
+ strings.ReplaceAll(ent["title"][0], "@", "@@"),
note,
strings.Join(catsOther, ", "),
)
- switch feeds := ent["Feed"]; len(feeds) {
+ switch feeds := ent["feed"]; len(feeds) {
case 0:
fmt.Printf(" @emph{STATIC}\n")
case 1:
func opml(data []map[string][]string) {
outlines := make([]Outline, 0, len(data))
for _, ent := range data {
- for _, feed := range ent["Feed"] {
+ for _, feed := range ent["feed"] {
outlines = append(outlines, Outline{
Type: "rss",
- Text: ent["Title"][0],
- HtmlUrl: ent["URL"][0],
+ Text: ent["title"][0],
+ HtmlUrl: ent["url"][0],
XmlUrl: feed,
- Category: strings.Join(ent["Category"], ","),
+ Category: strings.Join(ent["cat"], ","),
})
}
}
ents := data[cat]
bs := make([]Bookmark, 0, len(ents))
for _, ent := range ents {
- b := Bookmark{Href: ent["URL"][0], Title: ent["Title"][0]}
- for _, url := range ent["Feed"] {
+ b := Bookmark{Href: ent["url"][0], Title: ent["title"][0]}
+ for _, url := range ent["feed"] {
b.Feeds = append(b.Feeds, Feed{Owner: "webfeed", Link: Link{url}})
}
bs = append(bs, b)