summaryrefslogtreecommitdiff
path: root/README.md
blob: 1079751fa84d7fbb094e4423ee19cbaaf2f3e2c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
    phrollo: a phlogroll in a shellscript    
=============================================

`phrollo` is a simple tool to manage a phlog roll. It uses a simple
configuration file and outputs the relevant selectors to be added to a
gophermap. The list of selectors of updated phlogs is sorted in
decreasing order of update time (meaning that more recent updates appear
at the top of the list). `phrollo` also prints on stderr an updaterd
config file, to be used for future calls.

`phrollo` detects updates by using `shasum -a 256`, i.e. by computing 
a hash of the resource and comparing it with the hash obtained when the 
resource was last seen. 

   Usage   
===========

Either :
```
./phrollo status.txt
```
or:

```
 cat status.txt | ./phrollo
```

will print the sorted list of gopher selectors on stdout, and the
updated config file on stderr.
 
IMPORTANT: The next time `phrollo` is run, it must be given the last
config file generated, so be sure to redirect stderr appropriately. A
fully working example is given below.


   Configuration file   
========================

The format of the `phrollo` config file is as follows:

DATE \t DESCRIPTION \t URI \t HOST \t PORT \t SHASUM

where:

  - DATE: is the last time the phlog was updated, or an empty string for
    a new phlog;
  - DESCRIPTION: is the description of the phlog (e.g., the name of the
    author)
  - URI: is the path of the phlog
  - HOST: well, the host
  - PORT: normally 70
  - SHASUM: the shasum of the phlog at the time of the latest change, or
    an empty string for a new phlog

   Example   
=============

Let us construct an initial `phrollo` config file containing all the
phlogs we would like to follow. Since `phrollo` has never seen any of
those phlogs, both DATE and SHASUM will be ignored. We will indicated 
them with a "-" dash. Notice that fields are separated by actual TABs:

```
-	Slugmax	/~slugmax/cgi-bin/slerm	zaibatsu.circumlunar.space	70	-
-	RPDO	/Phlog	1436.ninja	70	-
-	Alex Shroeder	/	alexschroeder.ch	70	-
-	Solderpunk	/~solderpunk/phlog	zaibatsu.circumlunar.space	70	-
-	Tomasino	/phlog	gopher.black	70	-
-	KatolaZ	/~katolaz/phlog	republic.circumlunar.space	70	-
```

Now we can feed this file to `phrollo`:

```
cat config.txt | ./phrollo 2> config_updated.txt > gophermap
```

and we will get the following output in `gophermap`:

```
1(20190126) Alex Shroeder	/	alexschroeder.ch	70
1(20190126) KatolaZ	/~katolaz/phlog	republic.circumlunar.space	70
1(20190126) RPDO	/Phlog	1436.ninja	70
1(20190126) Slugmax	/~slugmax/cgi-bin/slerm	zaibatsu.circumlunar.space	70
1(20190126) Solderpunk	/~solderpunk/phlog	zaibatsu.circumlunar.space	70
1(20190126) Tomasino	/phlog	gopher.black	70
```

which is a list of selectors corresponding to the phlogs specified in
the config file, and the updated config file in config_updated.txt:

```
20190126	Tomasino	/phlog	gopher.black	70	bd141abfc29522e3e2b5d00f1a656212201ae5def60de90a7ce847cddeb6d0db
20190126	Solderpunk	/~solderpunk/phlog	zaibatsu.circumlunar.space	70	4df8feff5237db12a4fb1c43d95f254dc26b0e35e3b008d53cc5004ad2c6acb9
20190126	Slugmax	/~slugmax/cgi-bin/slerm	zaibatsu.circumlunar.space	70	bfd0e14e2c5b08fff6b968804dd253e488c5e0bfd9d80cec4ca7599928fac53f
20190126	RPDO	/Phlog	1436.ninja	70	d61e34dfc71a10f5b45c6ccf7f6d96e4f976832efdd179e71a0981695b317dc9
20190126	KatolaZ	/~katolaz/phlog	republic.circumlunar.space	70	af9b99199b344b027addeb09ba71621123bf799605b6190a65be145221bcefde
20190126	Alex Shroeder	/	alexschroeder.ch	70	36d66161d096c5c729a6433c411fad9da978931cdfab40e9bd57787aa0e0b1f6
```

Then, we can run `phrollo` again using the latest updated config file
to detect updates and generate the new gophermap. It is possible to
automate the update procedure by something like:

```
#!/bin/sh

cp config.txt config.txt."$(date +%Y%m%d)"
cat config.txt | ./phrollo 2> config.txt.new  > gophermap.new

[ $? -eq 0 ] && {
	mv config.txt.new config.txt
	mv gophermap.new gophermap
} 

```