]> Sergey Matveev's repositories - sgblog.git/blob - README.texi
twtxting
[sgblog.git] / README.texi
1 \input texinfo
2 @documentencoding UTF-8
3 @settitle SGBlog
4
5 @copying
6 Copyright @copyright{} 2020 @email{stargrave@@stargrave.org, Sergey Matveev}
7 @end copying
8
9 @node Top
10 @top SGBlog
11
12 SGBlog is minimalistic and simple Git-backed CGI/UCSPI
13 @url{https://en.wikipedia.org/wiki/Blog, blogging} (@code{http://}/@code{https://}),
14 @url{https://en.wikipedia.org/wiki/Phlog, phlogging} (@code{gopher://}),
15 @url{https://twtxt.readthedocs.io/en/latest/index.html, twtxting}, and
16 @url{https://en.wikipedia.org/wiki/Gemini_(protocol), gemlogging} (@code{gemini://})
17 engine with email-backed comments support,
18 written on @url{https://golang.org/, Go}.
19
20 Its main competitive features:
21
22 @itemize
23 @item Single binary, responsible for both blog, phlog and gemlog
24 @item @url{https://git-scm.com/, Git} DVCS as a storage for posts and comments
25 @item Single small @url{https://hjson.github.io/, Hjson} configuration file
26 @item Uses @url{https://en.wikipedia.org/wiki/Common_Gateway_Interface, CGI}
27     interface (simplicity, remember?) for dealing with HTTP-server
28 @item Uses
29     @url{https://en.wikipedia.org/wiki/Inetd, inetd}/@url{http://cr.yp.to/ucspi-tcp.html, UCSPI-TCP}
30     interface for working as
31     @url{https://en.wikipedia.org/wiki/Gopher_(protocol), Gopher} server
32 @item Topics (tags/categories) support
33 @item Supports on the fly generation of
34     @url{https://en.wikipedia.org/wiki/Atom_(feed), Atom} feeds
35     for posts, comments and per-post comments
36 @item Single binary for email-backed comments posting
37 @item If access is granted, then everyone can easily create an offline
38     copy of your blog/phlog/gemlog!
39 @end itemize
40
41 All of that, except for comments, topics and phlog/gemlog, could be achieved
42 with some Git viewer like @url{https://git.zx2c4.com/cgit/about/, cgit}.
43 But SGBlog also is able to:
44
45 @itemize
46 @item Convert URLs to clickable links
47 @item Convert SHA1-like hashes to blog links itself
48 @item Include relative @code{<link rel>} links for ease of navigation in
49     some browsers
50 @item @url{https://en.wikipedia.org/wiki/Gzip, gzip} compress both HTML
51     pages and Atom feeds
52 @item Respect @url{https://en.wikipedia.org/wiki/HTTP_ETag, ETag}
53     caching for both of them above
54 @end itemize
55
56 @url{http://blog.stargrave.org/example/, Here} is an example blog.
57
58 SGBlog is free software, licenced under
59 @url{https://www.gnu.org/licenses/agpl-3.0.html, GNU AGPLv3}:
60 see the file COPYING for copying conditions.
61
62 @node Comments
63 @unnumbered Comments
64
65 Comments are posted through the email interface, just by sending the
66 message to special address. For example:
67
68 @example
69 $ mutt "mailto:comment@@blog.example.com?subject=BlaBlaBla%20(576540a5b98517b46d0efc791bb90b9121bf147e)" <<EOF
70 This is the comments contents.
71 Could be multilined of course.
72 EOF
73 @end example
74
75 Comments are stored in Git as a @url{https://git-scm.com/docs/git-notes, note}.
76 Those objects could be updated without touching the base commit itself.
77
78 Each comment is just a plaintext with @code{From} and @code{Date}
79 headers. @code{From} is a name of email sender (with email address
80 stripped off).
81
82 Only @code{text/plain} or @code{multipart/signed+text/plain} email
83 messages are accepted and only with UTF-8, US-ASCII, ISO-8859-1
84 character sets. Sane people won't send HTML email anyway, but this is
85 just a precaution.
86
87 Comments are stored in @dfn{recfiles} --
88 @url{https://www.gnu.org/software/recutils/, GNU recutils}
89 human-editable plaintext database format. But they do not contain
90 records description:
91
92 @verbatim
93 %rec: Comment
94 %doc: SGBlog's comment
95 %mandatory: From Date Body
96 %type: Date date
97 @end verbatim
98
99 @node Topics
100 @unnumbered Topics
101
102 Each post can have any number of attached topics (also known as tags or
103 categories). They are whitespace separated single words kept in separate
104 @url{https://git-scm.com/docs/git-notes, note} namespace. You can
105 add/change comments with commands like:
106
107 @example
108 $ git notes --ref=topics add -m "linux hate" @@
109 $ git push origin mybranch refs/notes/topics
110 @end example
111
112 To reset incorrectly added topic:
113
114 @example
115 $ git update-ref refs/notes/topics refs/notes/topics^
116 @end example
117
118 @node Installation
119 @unnumbered Installation
120
121 SGBlog's is written on Go and uses its modules. Hopefully you can
122 install it just by running:
123
124 @example
125 $ go get go.stargrave.org/sgblog/cmd/sgblog
126 $ go get go.stargrave.org/sgblog/cmd/sgblog-comment-add # if you need commenting
127 @end example
128
129 Unfortunately by default it uses HTTPS and Go's third party servers
130 (@code{sum.golang.org}, @code{proxy.golang.org}) that trust neither
131 @code{CACert.org}'s CA (used previously) nor @code{ca.cypherpunks.ru}
132 CAs. So either disable their usage and trust that certificate:
133 @code{GOPRIVATE=go.stargrave.org/sgblog}, or clone its source code
134 manually and build in place:
135 @url{git://git.stargrave.org/sgblog.git},
136 @url{https://git.stargrave.org/sgblog.git}.
137
138 For enabling blog availability you have to use HTTP server with CGI
139 interface. Example part of @url{http://www.lighttpd.net/, lighttpd}'s
140 configuration:
141
142 @example
143 $HTTP["host"] == "blog.example.com" @{
144   server.document-root = www_dir + "/blog.example.com"
145   $HTTP["url"] =~ "^/example" @{
146     alias.url += ("/example" => "/path/to/sgblog")
147     cgi.assign = ("sgblog" => "/path/to/sgblog")
148     setenv.add-environment = (
149       "SGBLOG_CFG" => "/path/to/example.hjson",
150     )
151   @}
152 @}
153 @end example
154
155 And be sure that you have read access to the Git repository, for example
156 by placing @code{lighttpd} user into @code{git} group.
157
158 Example @command{inetd} configuration (for phlog):
159
160 @example
161 gopher stream tcp6 nowait lighttpd /path/to/sgblog sgblog -gopher /path/to/gopher.hjson
162 @end example
163
164 Example @command{UCSPI-TCP} service running under
165 @url{http://cr.yp.to/daemontools.html, daemontools}:
166
167 @example
168 # mkdir -p /var/service/.phlog-ipv6/log
169 # cd /var/service/.phlog-ipv6
170
171 # cat > run <<EOF
172 #!/bin/sh -e
173 uid=\`id -u lighttpd\`
174 gid=\`id -g git\`
175 addr=2001::123
176 exec tcpserver -DHR -u $uid -g $gid -l 0 $addr gopher \
177   sgblog -gopher /path/to/gopher.hjson
178 EOF
179
180 # cat > log/run <<EOF
181 #!/bin/sh -e
182 exec setuidgid whatever-user multilog t ./main
183 EOF
184
185 # chmod -R 755 /var/service/.phlog-ipv6
186 # mv /var/service/.phlog-ipv6 /var/service/phlog-ipv6
187 @end example
188
189 Gemlog uses Gemini protocol that requires TLS usage, that can be
190 achieved with @url{go.cypherpunks.ru/ucspi} tools:
191
192 @example
193 exec tcpserver -DRH -u $uid -g $gid -l 0 ::0 1965 \
194   tlss -key gemlog.key.pem -cert gemlog.pem \
195   sgblog -gemini /home/sgblog/gemlog.hjson 2>&1
196 @end example
197
198 For comments workability you have to configure your SMTP server to feed
199 incoming messages to @command{sgblog-comment-add} utility. For example,
200 Postfix'es @file{/etc/aliases} can contain:
201
202 @example
203 comment: "| /path/to/sgblog-comment-add -git-dir /path/to/blog.git -committer-email comment@@blog.example.com"
204 @end example
205
206 to run that utility for all @code{comment@@} address messages.
207 You must have enough permission to be able to write to Git repository,
208 but Postfix by default runs all that commands from a @code{nobody} user.
209 So possibly you will need to @code{setuid} that executable give
210 permission for @code{nobody} running:
211
212 @example
213 -rwsr-x--- git:nobody sgblog-comment-add
214 @end example
215
216 And also do not forget about @code{lighttpd} user's (possibly in
217 @code{git} group) read permission permissions. Make sure
218 @command{sgblog-comment-add} runs with correctly set @code{-umask} (027
219 by default) for newly created Git objects/files.
220
221 @node Configuration
222 @unnumbered Configuration
223
224 SGBlog is configured via Hjson configuration file. More or less
225 self-describing blog configuration looks like that and contains many
226 optional fields:
227
228 @example
229 @{
230   GitPath: /home/sgblog/blog.git
231   Branch: refs/heads/example
232   Title: "Example blog"
233
234   BaseURL: http://blog.example.com
235   URLPrefix: /example
236
237   AtomId: "urn:uuid:54e6e53f-c615-48f1-812c-6f6b094ebbdd"
238   AtomAuthor: John Doe
239
240   # URL to CSS file, optional
241   CSS: /style.css
242   # Email address of the webmaster, optional
243   Webmaster: "webmaster@@example.com"
244   # URL to about page, optional
245   AboutURL: /
246   # Optional list of optional Git URLs for corresponding <link rel="vcs-git">
247   GitURLs: [
248     git://git.example.com/blog.git
249     https://git.example.com/git/blog.git
250   ]
251
252   # If that ref is set, then comments will be loaded from it
253   CommentsNotesRef: refs/notes/comments
254   # Display link for comment writing, if email is set
255   CommentsEmail: something@@example.com
256
257   # If that ref is set, then topics will be loaded from it
258   TopicsNotesRef: refs/notes/topics
259   # Optional file for topics state caching
260   TopicsCachePath: /path/to/sgblog-topics-cache.gob
261 @}
262 @end example
263
264 Gopher configuration can use the same file, but it requires much less
265 options:
266
267 @example
268 @{
269   GitPath: /home/sgblog/blog.git
270   Branch: refs/heads/example
271   Title: "Example blog"
272
273   GopherDomain: phlog.example.com
274
275   AboutURL: http://blog.example.com/
276
277   # Both are optional
278   CommentsNotesRef: refs/notes/comments
279   CommentsEmail: something@@example.com
280
281   # Both are optional too
282   TopicsNotesRef: refs/notes/topics
283   TopicsCachePath: /path/to/sgblog-topics-cache.gob
284 @}
285 @end example
286
287 @bye