1 // linksexp -- Texinfo/XBEL/OPML/urls autogeneration from recfile bookmark
2 // Copyright (C) 2021-2024 Sergey Matveev <stargrave@stargrave.org>
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, version 3 of the License.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program. If not, see <http://www.gnu.org/licenses/>.
24 Href string `xml:"href,attr"`
28 Owner string `xml:"owner,attr"`
29 Link Link `xml:"link"`
32 type Bookmark struct {
33 Href string `xml:"href,attr"`
34 Title string `xml:"title"`
35 Feeds []Feed `xml:"info>metadata,omitempty"`
39 Title string `xml:"title"`
40 Bookmarks []Bookmark `xml:"bookmark"`
44 XMLName xml.Name `xml:"xbel"`
45 Version string `xml:"version,attr"`
46 Folders []Folder `xml:"folder"`
49 func xbel(cats []string, data map[string][]map[string][]string) {
50 folders := make([]Folder, 0, len(cats))
51 for _, cat := range cats {
53 bs := make([]Bookmark, 0, len(ents))
54 for _, ent := range ents {
55 b := Bookmark{Href: ent["URL"][0], Title: ent["Title"][0]}
56 for _, url := range ent["Feed"] {
57 b.Feeds = append(b.Feeds, Feed{Owner: "webfeed", Link: Link{url}})
61 folders = append(folders, Folder{Title: cat, Bookmarks: bs})
63 x := XBEL{Version: "1.0", Folders: folders}
64 out, err := xml.MarshalIndent(&x, "", " ")
68 os.Stdout.WriteString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
69 os.Stdout.WriteString("<!DOCTYPE xbel>\n")