all repos — flounder @ adce4038a08103cb7a2c2c7a0f093b16fe16b647

A small site builder for the Gemini protocol

feed.go (view raw)

 1package main
 2
 3import (
 4	"bufio"
 5	"fmt"
 6	"github.com/mmcdole/gofeed"
 7	"os"
 8	"path"
 9)
10
11const followingPath = "following.txt"
12const followingFile = "following.gmi"
13
14// TODO also get gemini, gemfeed
15
16func getAllFeeds(user string) error {
17	// Open file
18	file, err := os.Open(path.Join(getUserDirectory(user), followingPath))
19	if err != nil {
20		return err
21	}
22	defer file.Close()
23
24	scanner := bufio.NewScanner(file)
25	for scanner.Scan() {
26		feedURL := scanner.Text()
27		// if scheme is gemini and filetype is gemini... gemtext
28		// if scheme is gemini and filetype is xml/rss... fetch data  and parse
29		fp := gofeed.NewParser()
30		fp.ParseURL(feedURL)
31	}
32	if err := scanner.Err(); err != nil {
33		return err
34	}
35	data := struct {
36		DayContent []struct {
37			date      string
38			feed      *gofeed.Feed
39			feedItems []gofeed.Item
40		}
41	}{}
42	fmt.Println(data)
43	// convert to gemini template
44	// write template to file
45	return nil
46}