]> Sergey Matveev's repositories - sgblog.git/blob - README.texi
Fix tabs issues in comments
[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     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!
34 @end itemize
35
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:
39
40 @itemize
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
44     some browsers
45 @item @url{https://en.wikipedia.org/wiki/Gzip, gzip} compress both HTML
46     pages and Atom feeds
47 @item Respect @url{https://en.wikipedia.org/wiki/HTTP_ETag, ETag}
48     caching for both of them above
49 @end itemize
50
51 @url{http://blog.stargrave.org/example/, Here} is an example blog.
52
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.
56
57 @menu
58 * Comments::
59 * Installation::
60 * Configuration::
61 @end menu
62
63 @node Comments
64 @unnumbered Comments
65
66 Comments are posted through the email interface, just by sending the
67 message to special address. For example:
68
69 @example
70 mutt "mailto:comment@@blog.example.com?subject=576540a5b98517b46d0efc791bb90b9121bf147e" <<EOF
71 This is the comments contents.
72 Could be multilined of course.
73 EOF
74 @end example
75
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.
78
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
81 stripped off).
82
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.
88
89 @node Installation
90 @unnumbered Installation
91
92 SGBlog's is written on Go and uses its modules. Hopefully you can
93 install it just by running:
94
95 @example
96 $ go get go.stargrave.org/sgblog/cmd/sgblog
97 $ go get go.stargrave.org/sgblog/cmd/sgblog-comment-add # if you need commenting
98 @end example
99
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}.
108
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
111 configuration:
112
113 @example
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",
121     )
122   @}
123 @}
124 @end example
125
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.
128
129 Example @command{inetd} configuration (for phlog):
130
131 @example
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
134 @end example
135
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:
139
140 @example
141 comment: "| /path/to/sgblog-comment-add -git-dir /path/to/blog.git -committer-email comment@@blog.example.com"
142 @end example
143
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:
149
150 @example
151 -rwsr-x--- git:nobody sgblog-comment-add
152 @end example
153
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.
158
159 @node Configuration
160 @unnumbered Configuration
161
162 SGBlog is configured via Hjson configuration file. More or less
163 self-describing blog configuration looks like that and contains many
164 optional fields:
165
166 @example
167 @{
168   GitPath: /home/sgblog/blog.git
169   Branch: refs/heads/example
170   Title: "Example blog"
171
172   BaseURL: http://blog.example.com
173   URLPrefix: /example
174
175   AtomId: "urn:uuid:54e6e53f-c615-48f1-812c-6f6b094ebbdd"
176   AtomAuthor: John Doe
177
178   # URL to CSS file, optional
179   CSS: /style.css
180   # Email address of the webmaster, optional
181   Webmaster: "webmaster@@example.com"
182   # URL to about page, optional
183   AboutURL: /
184   # Optional list of optional Git URLs for corresponding <link rel="vcs-git">
185   GitURLs: [
186     git://git.example.com/blog.git
187     https://git.example.com/git/blog.git
188   ]
189
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
194 @}
195 @end example
196
197 Gopher configuration can use the same file, but it requires much less
198 options:
199
200 @example
201 @{
202   GitPath: /home/sgblog/blog.git
203   Branch: refs/heads/example
204   Title: "Example blog"
205
206   GopherDomain: phlog.example.com
207
208   AboutURL: http://blog.example.com/
209
210   # Both are optional
211   CommentsNotesRef: refs/notes/comments
212   CommentsEmail: something@@example.com
213 @}
214 @end example
215
216 @bye