summaryrefslogtreecommitdiff
path: root/sfeedrc.5
blob: 91f82cea3377b7aa72f5fa6c671a79795b1c4e7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
.Dd January 18, 2023
.Dt SFEEDRC 5
.Os
.Sh NAME
.Nm sfeedrc
.Nd sfeed_update(1) configuration file
.Sh DESCRIPTION
.Nm
is the configuration file for
.Xr sfeed_update 1 .
.Sh VARIABLES
.Bl -tag -width Ds
.It Va sfeedpath
can be set for the directory to store the TAB-separated feed files.
The default is
.Pa $HOME/.sfeed/feeds .
.It Va maxjobs
can be used to change the amount of concurrent
.Fn feed
jobs.
The default is 8.
.El
.Sh FUNCTIONS
.Bl -tag -width Ds
.It Fn feeds
This function is the required "main" entry-point function called from
.Xr sfeed_update 1 .
.It Fn feed "name" "feedurl" "basesiteurl" "encoding"
Inside the
.Fn feeds
function feeds can be defined by calling the
.Fn feed
function, its arguments are:
.Bl -tag -width Ds
.It Fa name
Name of the feed, this is also used as the filename for the TAB-separated
feed file.
The feed name cannot contain the '/' character because it is a path separator,
they will be replaced with '_'.
.It Fa feedurl
URL to fetch the RSS/Atom data from, usually a HTTP or HTTPS URL.
.It Op Fa basesiteurl
Base URL of the feed links.
This argument allows to fix relative item links.
.Pp
According to the RSS and Atom specification feeds should always have absolute
URLs, however this is not always the case in practise.
.It Op Fa encoding
Feeds are decoded from this name to UTF-8, the name should be a usable
character-set for the
.Xr iconv 1
tool.
.El
.El
.Sh OVERRIDE FUNCTIONS
Because
.Xr sfeed_update 1
is a shellscript each function can be overridden to change its behaviour,
notable functions are:
.Bl -tag -width Ds
.It Fn fetch "name" "url" "feedfile"
Fetch feed from URL and write the data to stdout, its arguments are:
.Bl -tag -width Ds
.It Fa name
Specified name in configuration file (useful for logging).
.It Fa url
URL to fetch.
.It Fa feedfile
Used feedfile (useful for comparing modification times).
.El
.Pp
By default the tool
.Xr curl 1
is used.
.It Fn convertencoding "name" "from" "to"
Convert data from stdin from one text-encoding to another and write it to
stdout,
its arguments are:
.Bl -tag -width Ds
.It Fa name
Feed name.
.It Fa from
From text-encoding.
.It Fa to
To text-encoding.
.El
.Pp
By default the tool
.Xr iconv 1
is used.
.It Fn parse "name" "feedurl" "basesiteurl"
Read RSS/Atom XML data from stdin, convert and write it as
.Xr sfeed 5
data to stdout.
.Bl -tag -width Ds
.It Fa name
Name of the feed.
.It Fa feedurl
URL of the feed.
.It Fa basesiteurl
Base URL of the feed links.
This argument allows to fix relative item links.
.El
.It Fn filter "name"
Filter
.Xr sfeed 5
data from stdin and write it to stdout, its arguments are:
.Bl -tag -width Ds
.It Fa name
Feed name.
.El
.It Fn merge "name" "oldfile" "newfile"
Merge
.Xr sfeed 5
data of oldfile with newfile and write it to stdout, its arguments are:
.Bl -tag -width Ds
.It Fa name
Feed name.
.It Fa oldfile
Old file.
.It Fa newfile
New file.
.El
.It Fn order "name"
Sort
.Xr sfeed 5
data from stdin and write it to stdout, its arguments are:
.Bl -tag -width Ds
.It Fa name
Feed name.
.El
.El
.Sh EXAMPLES
An example configuration file is included named sfeedrc.example and also
shown below:
.Bd -literal
#sfeedpath="$HOME/.sfeed/feeds"

# list of feeds to fetch:
feeds() {
	# feed <name> <feedurl> [basesiteurl] [encoding]
	feed "codemadness" "https://www.codemadness.org/atom_content.xml"
	feed "explosm" "http://feeds.feedburner.com/Explosm"
	feed "golang github releases" "https://github.com/golang/go/releases.atom"
	feed "linux kernel" "https://www.kernel.org/feeds/kdist.xml" "https://www.kernel.org"
	feed "reddit openbsd" "https://old.reddit.com/r/openbsd/.rss"
	feed "slashdot" "http://rss.slashdot.org/Slashdot/slashdot" "http://slashdot.org"
	feed "tweakers" "http://feeds.feedburner.com/tweakers/mixed" "http://tweakers.net" "iso-8859-1"
	# get youtube Atom feed: curl -s -L 'https://www.youtube.com/user/gocoding/videos' | sfeed_web | cut -f 1
	feed "youtube golang" "https://www.youtube.com/feeds/videos.xml?channel_id=UCO3LEtymiLrgvpb59cNsb8A"
	feed "xkcd" "https://xkcd.com/atom.xml" "https://xkcd.com"
}
.Ed
.Pp
To change the default
.Xr curl 1
options for fetching the data, the
.Fn fetch
function can be overridden and added at the top of the
.Nm
file:
.Bd -literal
# fetch(name, url, feedfile)
fetch() {
	# allow for 1 redirect, hide User-Agent, timeout is 15 seconds.
	curl -L --max-redirs 1 -H "User-Agent:" -f -s -m 15 \e
		"$2" 2>/dev/null
}
.Ed
.Sh SEE ALSO
.Xr curl 1 ,
.Xr iconv 1 ,
.Xr sfeed_update 1 ,
.Xr sh 1
.Sh AUTHORS
.An Hiltjo Posthuma Aq Mt hiltjo@codemadness.org