-linksexp -- Texinfo/XBEL/OPML/urls autogeneration from recfile bookmark.
+linksexp -- Texinfo/XBEL/OPML/SWG/urls autogeneration from recfile bookmark.
Given recfile (https://www.gnu.org/software/recutils/) bookmark file,
this program can generate (export links):
* either part of Texinfo source code output
* or XBEL (http://xbel.sourceforge.net/, https://en.wikipedia.org/wiki/XBEL)
* or OPML (http://dev.opml.org/, https://en.wikipedia.org/wiki/OPML)
+* or SWG (http://www.git.stargrave.org/?p=swg.git;a=blob;f=README)
* or "urls" file for newsboat (https://newsboat.org/)
-// linksexp -- Texinfo/XBEL/OPML/urls autogeneration from recfile bookmark
+// linksexp -- Texinfo/XBEL/OPML/SWG/urls autogeneration from recfile bookmark
// Copyright (C) 2021-2025 Sergey Matveev <stargrave@stargrave.org>
//
// This program is free software: you can redistribute it and/or modify
doXBEL := flag.Bool("xbel", false, "Make XBEL")
doOPML := flag.Bool("opml", false, "Make OPML")
doURLS := flag.Bool("urls", false, "Make newsboat urls")
+ doSWG := flag.Bool("swg", false, "Make SWG txtar")
flag.Parse()
r := recfile.NewReader(os.Stdin)
os.Exit(0)
}
+ if *doSWG {
+ swg(cats, data)
+ os.Exit(0)
+ }
+
fmt.Println("Updated:", time.Now().Format(time.RFC3339))
fmt.Println("@menu")
--- /dev/null
+// linksexp -- Texinfo/XBEL/OPML/SWG/urls autogeneration from recfile bookmark
+// Copyright (C) 2021-2025 Sergey Matveev <stargrave@stargrave.org>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, version 3 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+package main
+
+import (
+ "fmt"
+ "sort"
+ "strings"
+)
+
+func swg(cats []string, data map[string][]map[string][]string) {
+ fmt.Println("-- index --")
+ for _, cat := range cats {
+ fmt.Printf("[Links/%s] (%d items)\n", cat, len(data[cat]))
+ }
+ for cat, ents := range data {
+ fmt.Println("--", cat, "--")
+ for n, ent := range ents {
+ fmt.Printf("=> %s %d: %s\r\n", ent["url"][0], n, ent["title"][0])
+ if len(ent["note"]) > 0 {
+ for s := range strings.SplitSeq(ent["note"][0], "\n") {
+ if s == "" {
+ continue
+ }
+ fmt.Println(" ", s)
+ }
+ }
+ {
+ catsOther := make([]string, 0)
+ for _, c := range ent["cat"] {
+ if c != cat {
+ catsOther = append(catsOther, "[Links/"+c+"]")
+ }
+ }
+ sort.Strings(catsOther)
+ if len(catsOther) > 0 {
+ fmt.Println(" ", strings.Join(catsOther, " "))
+ }
+ }
+ switch feeds := ent["feed"]; len(feeds) {
+ case 0:
+ case 1:
+ fmt.Printf(" => %s feed\r\n", feeds[0])
+ default:
+ for i, feed := range feeds {
+ fmt.Printf(" => %s feed%d\r\n", feed, i)
+ }
+ }
+ }
+ }
+}