]> Sergey Matveev's repositories - sgblog.git/blob - README.texi
37840b3db52257ed6e2dc954c3224ea5efb47a24
[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
11
12 SGBlog is minimalistic and simple Git-backed CGI/inetd
13 @url{https://en.wikipedia.org/wiki/Blog, blogging} and
14 @url{https://en.wikipedia.org/wiki/Phlog, phlogging} engine
15 with email-backed comments support, written on @url{https://golang.org/, Go}.
16
17 Its main competitive features:
18
19 @itemize
20 @item Single binary, responsible for both blog and phlog
21 @item @url{https://git-scm.com/, Git} DVCS as a storage for posts and comments
22 @item Single small @url{https://hjson.github.io/, Hjson} configuration file
23 @item Uses @url{https://en.wikipedia.org/wiki/Common_Gateway_Interface, CGI}
24     interface (simplicity, remember?) for dealing with HTTP-server
25 @item Uses @url{https://en.wikipedia.org/wiki/Inetd, inetd} interface
26     for working as @url{https://en.wikipedia.org/wiki/Gopher_(protocol), Gopher}
27     server
28 @item Supports on the fly generation of
29     @url{https://en.wikipedia.org/wiki/Atom_(feed), Atom} feeds
30 @item Single binary for email-backed comments posting
31 @item If access is granted, then everyone can easily create an offline
32     copy of your blog/phlog!
33 @end itemize
34
35 All of that, except for comments and phlog, could be achieved with some
36 Git viewer like @url{https://git.zx2c4.com/cgit/about/, cgit}. But
37 SGBlog also is able to:
38
39 @itemize
40 @item Convert URLs to clickable links
41 @item Convert SHA1-like hashes to blog links itself
42 @item Include relative @code{<link rel>} links for ease of navigation in
43     some browsers
44 @item @url{https://en.wikipedia.org/wiki/Gzip, gzip} compress both HTML
45     pages and Atom feeds
46 @item Respect @url{https://en.wikipedia.org/wiki/HTTP_ETag, ETag}
47     caching for both of them above
48 @end itemize
49
50 @url{http://blog.stargrave.org/example/, Here} is an example blog.
51
52 SGBlog is free software, licenced under
53 @url{https://www.gnu.org/licenses/agpl-3.0.html, GNU AGPLv3}:
54 see the file COPYING for copying conditions.
55
56 @menu
57 * Comments::
58 * Installation::
59 * Configuration::
60 @end menu
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=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 Technically comments are stored in concatenated
83 @url{https://en.wikipedia.org/wiki/Netstring, netstring}. Only
84 @code{text/plain} or @code{multipart/signed+text/plain} email messages
85 are accepted and only with UTF-8, US-ASCII, ISO-8859-1 character sets.
86 Sane people won't send HTML email anyway, but this is just a precaution.
87
88 @node Installation
89 @unnumbered Installation
90
91 SGBlog's is written on Go and uses its modules. Hopefully you can
92 install it just by running:
93
94 @example
95 $ go get go.stargrave.org/sgblog/cmd/sgblog
96 $ go get go.stargrave.org/sgblog/cmd/sgblog-comment-add # if you need commenting
97 @end example
98
99 Unfortunately by default it uses HTTPS and Go's third party servers
100 (@code{sum.golang.org}, @code{proxy.golang.org}) that trust neither
101 @code{CACert.org}'s CA (used previously) nor @code{ca.cypherpunks.ru}
102 CA. So either disable their usage and trust that certificate:
103 @code{GOPRIVATE=go.stargrave.org/sgblog}, or clone its source code
104 manually and build in place:
105 @url{git://git.stargrave.org/sgblog.git},
106 @url{https://git.stargrave.org/git/sgblog.git}.
107
108 For enabling blog availability you have to use HTTP server with CGI
109 interface. Example part of @url{http://www.lighttpd.net/, lighttpd}'s
110 configuration:
111
112 @example
113 $HTTP["host"] == "blog.example.com" @{
114   server.document-root = www_dir + "/blog.example.com"
115   $HTTP["url"] =~ "^/example" @{
116     alias.url += ("/example" => "/path/to/sgblog")
117     cgi.assign = ("sgblog" => "/path/to/sgblog")
118     setenv.add-environment = (
119       "SGBLOG_CFG" => "/path/to/example.hjson",
120     )
121   @}
122 @}
123 @end example
124
125 And be sure that you have read access to the Git repository, for example
126 by placing @code{lighttpd} user into @code{git} group.
127
128 Example @command{inetd} configuration (for phlog):
129
130 @example
131 gopher stream tcp  nowait lighttpd /path/to/sgblog sgblog -gopher /path/to/gopher.hjson
132 gopher stream tcp6 nowait lighttpd /path/to/sgblog sgblog -gopher /path/to/gopher.hjson
133 @end example
134
135 For comments workability you have to configure your SMTP server to feed
136 incoming messages to @command{sgblog-comment-add} utility. For example,
137 Postfix'es @file{/etc/aliases} can contain:
138
139 @example
140 comment: "| /path/to/sgblog-comment-add -git-dir /path/to/blog.git -committer-email comment@@blog.example.com"
141 @end example
142
143 to run that utility for all @code{comment@@} address messages.
144 You must have enough permission to be able to write to Git repository,
145 but Postfix by default runs all that commands from a @code{nobody} user.
146 So possibly you will need to @code{setuid} that executable give
147 permission for @code{nobody} running:
148
149 @example
150 -rwsr-x--- git:nobody sgblog-comment-add
151 @end example
152
153 And also do not forget about @code{lighttpd} user's (possibly in
154 @code{git} group) read permission permissions. Make sure
155 @command{sgblog-comment-add} runs with correctly set @code{-umask} (027
156 by default) for newly created Git objects/files.
157
158 @node Configuration
159 @unnumbered Configuration
160
161 SGBlog is configured via Hjson configuration file. More or less
162 self-describing blog configuration looks like that and contains many
163 optional fields:
164
165 @example
166 @{
167   GitPath: /home/sgblog/blog.git
168   Branch: refs/heads/example
169   Title: "Example blog"
170
171   BaseURL: http://blog.example.com
172   URLPrefix: /example
173
174   AtomId: "urn:uuid:54e6e53f-c615-48f1-812c-6f6b094ebbdd"
175   AtomAuthor: John Doe
176
177   # URL to CSS file, optional
178   CSS: /style.css
179   # Email address of the webmaster, optional
180   Webmaster: "webmaster@@example.com"
181   # URL to about page, optional
182   AboutURL: /
183   # Optional list of optional Git URLs for corresponding <link rel="vcs-git">
184   GitURLs: [
185     git://git.example.com/blog.git
186     https://git.example.com/git/blog.git
187   ]
188
189   # If that ref is set, then comments will be loaded from it
190   CommentsNotesRef: refs/notes/comments
191   # Display link for comment writing, if email is set
192   CommentsEmail: something@@example.com
193 @}
194 @end example
195
196 Gopher configuration can use the same file, but it requires much less
197 options:
198
199 @example
200 @{
201   GitPath: /home/sgblog/blog.git
202   Branch: refs/heads/example
203   Title: "Example blog"
204
205   GopherDomain: phlog.example.com
206
207   AboutURL: http://blog.example.com/
208
209   # Both are optional
210   CommentsNotesRef: refs/notes/comments
211   CommentsEmail: something@@example.com
212 @}
213 @end example
214
215 @bye