remove list_punted.py which is now rolled into the others
[iron-blogger] / README
1 == Iron Blogger Setup Instructions ==
2
3 Author: Benjamin Mako Hill
4
5 Thanks to Tony Yet from Iron Blogger Guangzhou who acted as the "guinea
6 pig" and whose experience in the installation helped provide the impetus
7 for writing this documentation.
8
9 === Things You'll Need ===
10
11 - Wordpress blog, set up on some server that you have admin rights to.
12 - GNU Ledger (http://ledger-cli.org/)
13 - Python YAML
14 - A mailing list or mailing alias. Each week you will send an email with
15   the results and that email should go to all the participants. Iron
16   Blogger doesn't automatically email everybody but you can create an
17   list on librelist.org, Google Groups, or on your own system with GNU
18   Mailman (for example). I just use a simple Postfix email alias but
19   other folks do different things.
20 - Git (http://git-scm.com/)
21
22 You can install the dependencies on Debian or Ubuntu with:
23
24   apt-get install ledger python-yaml git
25
26 === Setting it up ===
27
28 Iron blogger runs in two places:
29
30 1. The server that hosts your installation of Wordpress and installation
31    of Planet.
32 2. The administrator's client systems where the administrator will run
33    the scripts from. On my system, this is just my laptop.
34
35 === 1. Setting up the server ===
36
37 First, you will need to set up a  Wordpress installation. You can
38 download one from: https://wordpress.org/
39
40 Please follow the instructions there on how to set one up. 
41
42 Once you have installed wordpress, you need to turn on XML-RPC. You can
43 do that by checking the box in the Settings -> Writing -> XML-RPC
44 setting in the Wordpress administrative interface.
45
46 ==== Installing and setting up planet ====
47
48 Second, you need to install the Planet software which will show you an
49 aggregator of all of the blogs of people who are participating in a
50 single feed. Planet just sorts of regenerates from a "cronjob"
51 periodically.
52
53 You can put Planet anywhere, but I put it in a subdirectory of my
54 Wordpress directory. My wordpress site is set up to be
55 http://iron-blogger.mako.cc so planet will show up as
56 http://iron-blogger.mako.cc/planet
57
58 You can download the latest version of the planet code from:
59
60   http://www.planetplanet.org/
61
62 The will will be something like "planet-2.0.tar.bz2" and you can upack
63 it with "tar -jxvf FILENAME".
64
65 The key file in planet is a file called "config.ini". You will see that
66 the Iron Blogger client code will generate this automatically so don't
67 edit this file by hand
68
69 You will need to create an output directory and a templates directory. I
70 do this just by copying the examples directory with a command like: cp
71 -R examples/output out; cp -R examples templates; cp
72 examples/fancy/index.html.tmpl templates
73
74 Planet updates automatically. What I did was create a little shell
75 scripts with the following content (I created it in
76 "~/bin/update_planet.sh", but make sure you do "chmod +x" to make it
77 executable). Also make sure that you change the location (e.g.,
78 "/var/www/iron-blogger/planet") to the full path of your planet
79 installation on your server:
80
81   #!/bin/sh
82   cd /var/www/iron-blogger/planet
83   python ./planet.py ./config.ini 2>/dev/null
84
85 I then added a cronjob so that it runs every half hour. Make sure your
86 user is part of the crontab group or add them with "sudo adduser tony23
87 crontab". Once your userhas permission, you can type crontab -e and then
88 add the following line which will cause planet to update on the 14th and
89 44th minute of every hour:
90
91   14,44 * * * *   /home/mako/bin/update_planet.sh
92
93 Once planet is running, it will be at WORD_PRESSLOCATION/planet/out.
94
95 If you want it to be at just "/planet" you need to add an Apache alias
96 to your Apache configuration file that is something like this (except
97 with your location in the second part):
98
99   Alias /planet /var/www/iron-blogger/planet/out/
100
101 === 2. Setting up the administrators client system ===
102
103 First, you'll need to clone the repository into some safe place on your system:
104
105   git clone git://projects.mako.cc/iron-blogger
106
107 Iron Blogger asssumes you are running bit and will even commit things to
108 your git repository for you in certain situations (e.g., when you run
109 the weekly updates). As you make these changes, it's a good idea to keep
110 committ things to git with "git commit -a" or something similar.
111
112 ==== Configuration Files ====
113
114 The following files are configuration files that you will need to blank
115 out and then customize completing for your system:
116
117 1. bloggers.yml
118
119 This file contains the list of the bloggers. Find an example of someone
120 and copy and paste. The "start" date should be the Monday of the first
121 week that the person is active.
122
123 The list can contain multiple blogs and feeds. Every user is introduced
124 with a little nickname which, in our system, is usually that person's
125 user id.
126
127 As you set it up, this only needs to be a single person.
128
129 2. email_list
130
131 This files doesn't "do" anything. I just use it as a list of the people
132 who are using the system. That said, I like to keep a separate list of
133 who is participating.
134
135 3. ledger
136
137 The ledger file is the file you will end up modifying quite a lot in
138 order to keep up with who owes what, who had paid what, how much you
139 have spent at meetups, etc. The way it works is like a basic ledger
140 program but its data is all stored in a text file.
141
142 If you have not used GNU Ledger before, figuring out exactly how it
143 works can be a little tricky. In order to modify the file, however, you
144 should only need copy and paste from my material. To start with, move
145 the existing ledger file (from Iron Blogger Boston) to a new file with a
146 commad like "mv ledger ledger.boston.example".
147
148 Now, create a new file, called "ledger" in that directory that contains
149 a little bit of test data for your installation. Unfortunately, if you
150 just give it an empty file with no debts, the software will not work.
151 So, add a fictional debt and a payment (one of *each*). Once things get
152 up and running, you can remove this, just by removing the basic lines
153 from the line.
154
155 An example of a fictional line would be as follows (although you'd want
156 to replace "mako" with the name of someone who is listed in your
157 bloggers.yml file):
158
159 2011-11-14 Week 1
160   User:andresmh    -5
161   Pool:Owed:mako
162 2011-11-14 Payment
163   Pool:Owed:mako    -5
164   Pool:Paid
165
166 In a ledger, money must always come from where and go somewhere. There
167 are two entries in there.
168
169 The first entry is a debt: money is going from the User:mako account
170 into the Pool:Owed:mako account. As a result, User:mako is now at "$-5"
171 while the Pool:Owed is now positive $5.
172
173 The second entry is a payment: money is going from the Pool:Owed:mako
174 account into the Pool:Paid account. Think of it this way. In the first
175 bit, Mako owes the pools. After he pays, money is still in the pool, but
176 its in the part of the pool that has been paid up.
177
178 The person who runs Iron Blogger is basically the bank. Everything in
179 Pool:Paid is money that you have been given. Anything in Pool:Owed is
180 money that people owed the pool but which you have not received yet.
181
182 Once you have this set up, you can test it by running the ledger command
183 which you hopefully installed earlier. Try running "ledger -f ledger
184 balance Pool:Owed" to find the balance owed. In this command, the first
185 ledger is the program GNU Ledger while the "-f ledger" tell is to read
186 the ledger file in the local directory as its input.
187
188 4. out/
189
190 The Iron Blogger code was a subdirectory called "out" where it will
191 store intermediary data as it works. Just do "mkdir out" in your main
192 directory on the client.
193
194 ==== Things you will need to modify ====
195
196 1.
197
198 These two files should be edited so that they contain details about your
199 name/administrator, email address, etc:
200
201 templates/config.ini
202 templates/email.txt 
203
204 2.
205
206 You must modify this line in the file "config.py" that it points to the
207 Monday that starts the week that your version of Iron Blogger is
208 starting:
209
210 START = datetime.datetime(2011, 10, 24, 6)
211
212 Also edit config.py to include details on your wordpress setup. Here are
213 my details that include the PAGE_ID of the participants page:
214
215 XMLRPC_ENDPOINT = 'http://iron-blogger.mako.cc/xmlrpc.php'
216 USER            = 'mako'
217 BLOG_ID         = 1
218 PAGE_ID         = 12
219
220 The file will automatically keep the page of participants up to date.
221 You can see the page on our system here:
222
223 http://iron-blogger.mako.cc/participants/
224
225 The XMLRPC_ENDPOINT should be just your Wordpress URL followed by
226 xmlrpc.php. The USER should be your Wordpress user. The BLOG_ID should
227 be 1 and the PAGE_ID for the Parcipants page should be visible in your
228 Wordpress administrative interface.
229
230 5.
231
232 You'll also want to edit the "update-bloggers" script. You should only
233 need to change this line that copies the planet configuration over to
234 your server.
235
236   rsync $HERE/../iron-blogger-planet/config.ini epicenter:/var/www/iron-blogger/planet/
237
238 You will to change it so that the second part ("epicenter:/LOCATION")
239 points to your server in the way that you get to it with SSH (i.e., not
240 the web server location) and the full path to the directory on that
241 server where you have planet code setup. If you do not have rsync set
242 up, you should be able replace rsync with "scp" and have it work just
243 fine.
244
245 Once you've done this, you should be able to test this by typing
246 "./update-bloggers" in the terminal from your iron-blogger directory on
247 your client. If it's working correctly, it will ask you for a password
248 which will be your Wordpress password. The script will update the
249 participants page in Wordpress, generate a new "config.ini" file for
250 Planet, and copy it to your server.
251
252 === Adding bloggers and running weekly updates ===
253
254 To add a new blogger, you need to:
255
256 1. Edit "bloggers.yml' to add the metadata about the person
257 2. Run: ./scan-feeds.py
258 3. Run: "./update-bloggers" which will update the participants page and
259    the planet configuration.
260
261 When it's successful, it won't return anything.
262
263 Each week, you can run a weekly update. The updates don't happen
264 automatically which means the person running the system will need to do
265 it each week. If you miss a week, that's OK. You can run updates at any
266 time so, for example, you could run updates for the previous week, the
267 week before, and the week before that, all at the same time.
268
269 To run a weekly update, you need to:
270
271 1. Run ./scan-feeds.py
272 2. Run: ./weekly-update.py -n '2012-01-01'
273
274 The date, in quotes, should be the Monday that *starts* the week that
275 you are running it on. The "-n" in step 2 will mean to not make changes,
276 will not post to your iron-blogger website, and will not send out an
277 email. It will print out a list on the terminal.
278
279 If it all looks good, you can send it by running that command again with
280 step 3:
281
282 3. ./weekly-update.py '2012-01-01'
283
284 That command will ask for your Wordpress password again and will send
285 out an email to which ever address is in templates/email.txt. It will
286 show all the fines and will also commit the latest charges in the ledger
287 into git.
288
289 === Punting and Unpunting ===
290
291 By default, the code is set to "punt" people when they have a debt that
292 reaches $30 (or whatever 6 times the fine size (set by FINE_SIZE in
293 config.py). The weekly-update.py file will do this automatically. Their
294 debt dissappears. The idea is that people cannot just keep oweing more
295 and more. When people pay their $30, they are "unpunted" meaning that
296 they are back in the club.
297
298 Unpunting requires two changes:
299
300 1. Go to bloggers.yml and remove the line that says "end" associated
301    with the bloggers name.
302 2. Go to the ledger file and restore their debt (essentially, add $30
303    back into the Pool:Owed), and record their payment normally. The
304    following example shows how to do that:
305
306 2012-02-13 Unpunt
307   Pool:Owed:mako  30
308   User:mako
309 2012-02-13 Payment
310   Pool:Owed:mako    -30
311   Pool:Paid
312

Benjamin Mako Hill || Want to submit a patch?