aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorla-ninpre <aaoth@aaoth.xyz>2025-12-10 22:48:14 +0300
committerla-ninpre <aaoth@aaoth.xyz>2025-12-10 22:48:14 +0300
commitf3fcd25e29d1a8c4d355eb650091e2920def658e (patch)
tree7f537b44a47359e5437e67251b3a5d4de1bb642c /main.go
downloadhtml-journal-f3fcd25e29d1a8c4d355eb650091e2920def658e.tar.gz
html-journal-f3fcd25e29d1a8c4d355eb650091e2920def658e.zip
init
Diffstat (limited to 'main.go')
-rw-r--r--main.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..9f2f622
--- /dev/null
+++ b/main.go
@@ -0,0 +1,37 @@
+// read html journal from file and output an atom feed
+package main
+
+import (
+ "encoding/xml"
+ "log"
+ "net/url"
+ "os"
+
+ "git.sr.ht/~la_ninpre/html-journal/atom"
+ "git.sr.ht/~la_ninpre/html-journal/journal"
+)
+
+func main() {
+ if len(os.Args) < 3 {
+ log.Fatalf("usage: %s file url", os.Args[0])
+ }
+ if _, err := url.Parse(os.Args[2]); err != nil {
+ log.Printf("malformed url: %v", err)
+ }
+ f, err := os.Open(os.Args[1])
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer f.Close()
+ j, err := journal.Parse(f)
+ if err != nil {
+ log.Fatal(err)
+ }
+ fx := atom.FeedFromJournal(os.Args[2], j)
+ dat, err := xml.MarshalIndent(fx, "", " ")
+ if err != nil {
+ log.Fatal(err)
+ }
+ os.Stdout.Write([]byte(xml.Header))
+ os.Stdout.Write(dat)
+}