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 @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!
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:
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
44 @item @url{https://en.wikipedia.org/wiki/Gzip, gzip} compress both HTML
46 @item Respect @url{https://en.wikipedia.org/wiki/HTTP_ETag, ETag}
47 caching for both of them above
50 @url{http://blog.stargrave.org/example/, Here} is an example blog.
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.
65 Comments are posted through the email interface, just by sending the
66 message to special address. For example:
69 mutt "mailto:comment@@blog.example.com?subject=576540a5b98517b46d0efc791bb90b9121bf147e" <<EOF
70 This is the comments contents.
71 Could be multilined of course.
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.
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
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.
89 @unnumbered Installation
91 SGBlog's is written on Go and uses its modules. Hopefully you can
92 install it just by running:
95 $ go get go.stargrave.org/sgblog/cmd/sgblog
96 $ go get go.stargrave.org/sgblog/cmd/sgblog-comment-add # if you need commenting
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}.
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
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",
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.
128 Example @command{inetd} configuration (for phlog):
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
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:
140 comment: "| /path/to/sgblog-comment-add -git-dir /path/to/blog.git -committer-email comment@@blog.example.com"
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:
150 -rwsr-x--- git:nobody sgblog-comment-add
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.
159 @unnumbered Configuration
161 SGBlog is configured via Hjson configuration file. More or less
162 self-describing blog configuration looks like that and contains many
167 GitPath: /home/sgblog/blog.git
168 Branch: refs/heads/example
169 Title: "Example blog"
171 BaseURL: http://blog.example.com
174 AtomId: "urn:uuid:54e6e53f-c615-48f1-812c-6f6b094ebbdd"
177 # URL to CSS file, optional
179 # Email address of the webmaster, optional
180 Webmaster: "webmaster@@example.com"
181 # URL to about page, optional
183 # Optional list of optional Git URLs for corresponding <link rel="vcs-git">
185 git://git.example.com/blog.git
186 https://git.example.com/git/blog.git
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
196 Gopher configuration can use the same file, but it requires much less
201 GitPath: /home/sgblog/blog.git
202 Branch: refs/heads/example
203 Title: "Example blog"
205 GopherDomain: phlog.example.com
207 AboutURL: http://blog.example.com/
210 CommentsNotesRef: refs/notes/comments
211 CommentsEmail: something@@example.com