2 @documentencoding UTF-8
6 Copyright @copyright{} 2020 @email{stargrave@@stargrave.org, Sergey Matveev}
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}.
17 Its main competitive features:
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}
28 @item Supports on the fly generation of
29 @url{https://en.wikipedia.org/wiki/Atom_(feed), Atom} feeds
30 for posts, comments and per-post comments
31 @item Single binary for email-backed comments posting
32 @item If access is granted, then everyone can easily create an offline
33 copy of your blog/phlog!
36 All of that, except for comments and phlog, could be achieved with some
37 Git viewer like @url{https://git.zx2c4.com/cgit/about/, cgit}. But
38 SGBlog also is able to:
41 @item Convert URLs to clickable links
42 @item Convert SHA1-like hashes to blog links itself
43 @item Include relative @code{<link rel>} links for ease of navigation in
45 @item @url{https://en.wikipedia.org/wiki/Gzip, gzip} compress both HTML
47 @item Respect @url{https://en.wikipedia.org/wiki/HTTP_ETag, ETag}
48 caching for both of them above
51 @url{http://blog.stargrave.org/example/, Here} is an example blog.
53 SGBlog is free software, licenced under
54 @url{https://www.gnu.org/licenses/agpl-3.0.html, GNU AGPLv3}:
55 see the file COPYING for copying conditions.
66 Comments are posted through the email interface, just by sending the
67 message to special address. For example:
70 mutt "mailto:comment@@blog.example.com?subject=576540a5b98517b46d0efc791bb90b9121bf147e" <<EOF
71 This is the comments contents.
72 Could be multilined of course.
76 Comments are stored in Git as a @url{https://git-scm.com/docs/git-notes, note}.
77 Those objects could be updated without touching the base commit itself.
79 Each comment is just a plaintext with @code{From} and @code{Date}
80 headers. @code{From} is a name of email sender (with email address
83 Technically comments are stored in concatenated
84 @url{https://en.wikipedia.org/wiki/Netstring, netstring}. Only
85 @code{text/plain} or @code{multipart/signed+text/plain} email messages
86 are accepted and only with UTF-8, US-ASCII, ISO-8859-1 character sets.
87 Sane people won't send HTML email anyway, but this is just a precaution.
90 @unnumbered Installation
92 SGBlog's is written on Go and uses its modules. Hopefully you can
93 install it just by running:
96 $ go get go.stargrave.org/sgblog/cmd/sgblog
97 $ go get go.stargrave.org/sgblog/cmd/sgblog-comment-add # if you need commenting
100 Unfortunately by default it uses HTTPS and Go's third party servers
101 (@code{sum.golang.org}, @code{proxy.golang.org}) that trust neither
102 @code{CACert.org}'s CA (used previously) nor @code{ca.cypherpunks.ru}
103 CA. So either disable their usage and trust that certificate:
104 @code{GOPRIVATE=go.stargrave.org/sgblog}, or clone its source code
105 manually and build in place:
106 @url{git://git.stargrave.org/sgblog.git},
107 @url{https://git.stargrave.org/git/sgblog.git}.
109 For enabling blog availability you have to use HTTP server with CGI
110 interface. Example part of @url{http://www.lighttpd.net/, lighttpd}'s
114 $HTTP["host"] == "blog.example.com" @{
115 server.document-root = www_dir + "/blog.example.com"
116 $HTTP["url"] =~ "^/example" @{
117 alias.url += ("/example" => "/path/to/sgblog")
118 cgi.assign = ("sgblog" => "/path/to/sgblog")
119 setenv.add-environment = (
120 "SGBLOG_CFG" => "/path/to/example.hjson",
126 And be sure that you have read access to the Git repository, for example
127 by placing @code{lighttpd} user into @code{git} group.
129 Example @command{inetd} configuration (for phlog):
132 gopher stream tcp nowait lighttpd /path/to/sgblog sgblog -gopher /path/to/gopher.hjson
133 gopher stream tcp6 nowait lighttpd /path/to/sgblog sgblog -gopher /path/to/gopher.hjson
136 For comments workability you have to configure your SMTP server to feed
137 incoming messages to @command{sgblog-comment-add} utility. For example,
138 Postfix'es @file{/etc/aliases} can contain:
141 comment: "| /path/to/sgblog-comment-add -git-dir /path/to/blog.git -committer-email comment@@blog.example.com"
144 to run that utility for all @code{comment@@} address messages.
145 You must have enough permission to be able to write to Git repository,
146 but Postfix by default runs all that commands from a @code{nobody} user.
147 So possibly you will need to @code{setuid} that executable give
148 permission for @code{nobody} running:
151 -rwsr-x--- git:nobody sgblog-comment-add
154 And also do not forget about @code{lighttpd} user's (possibly in
155 @code{git} group) read permission permissions. Make sure
156 @command{sgblog-comment-add} runs with correctly set @code{-umask} (027
157 by default) for newly created Git objects/files.
160 @unnumbered Configuration
162 SGBlog is configured via Hjson configuration file. More or less
163 self-describing blog configuration looks like that and contains many
168 GitPath: /home/sgblog/blog.git
169 Branch: refs/heads/example
170 Title: "Example blog"
172 BaseURL: http://blog.example.com
175 AtomId: "urn:uuid:54e6e53f-c615-48f1-812c-6f6b094ebbdd"
178 # URL to CSS file, optional
180 # Email address of the webmaster, optional
181 Webmaster: "webmaster@@example.com"
182 # URL to about page, optional
184 # Optional list of optional Git URLs for corresponding <link rel="vcs-git">
186 git://git.example.com/blog.git
187 https://git.example.com/git/blog.git
190 # If that ref is set, then comments will be loaded from it
191 CommentsNotesRef: refs/notes/comments
192 # Display link for comment writing, if email is set
193 CommentsEmail: something@@example.com
197 Gopher configuration can use the same file, but it requires much less
202 GitPath: /home/sgblog/blog.git
203 Branch: refs/heads/example
204 Title: "Example blog"
206 GopherDomain: phlog.example.com
208 AboutURL: http://blog.example.com/
211 CommentsNotesRef: refs/notes/comments
212 CommentsEmail: something@@example.com