README.rst: Fix 'to get the [mid] is' wording
[nmhive.git] / README.rst
1 Nmhive is a webserver for nmbug_, allowing you to remotely query and
2 manage notmuch_ tags.  There is also a bookmarklet that provides a
3 convenient interface for managing tags while browsing Gmane_.
4
5 Dependencies
6 ============
7
8 * Flask_
9 * Flask-Cors_
10
11 The versions shouldn't matter too much, but I'm testing with Flask
12 0.10.1 and Flask-Cors 1.9.0.
13
14 Server setup
15 ============
16
17 Launch the server with something like::
18
19   $ nmhive.py -H 0.0.0.0 -p 5000
20    * Running on http://0.0.0.0:5000/
21   …
22
23 Use nmbug's usual ``NMBGIT`` and ``NMBPREFIX`` environment variables
24 to configure the nmbug repository used by nmhive.
25
26 You can kill the server whenever you like (e.g. via ``ctrl+c``)
27 without worrying about corrupting your local notmuch or nmbug
28 databases.
29
30 Then edit ``nmbug_server`` in ``nmbug.js`` to point at that interface.
31 Serve ``nmbug.js`` and ``index.html`` somewhere.  I serve them with
32 Nginx_, but you use whatever you like, including `Python's`__
33 `http.server`_ with something like::
34
35   $ python -m http.server 8000
36
37 __ Python_
38
39 Point your users to the served ``index.html`` so they can get the
40 bookmarklet and read the instructions for using it.
41
42 Endpoints
43 =========
44
45 The nmhive server provides the following endpoints for use by the
46 bookmarklet (or other tools):
47
48 ``GET /tags``
49   Returns the tags that are already stored in the nmbug database as a
50   JSON array.  Instead of requiring admins to configure a list of
51   available tags, we just assume all the tags are in use (and that no
52   non-standard tags are in use) under the ``NMBPREFIX``.
53
54 ``GET /mid/<message-id>``
55   Returns tags associated with a particular message as a JSON array.
56   If the given Message-ID isn't in the notmuch database, returns
57   a 404.
58
59 ``POST /mid/<message-id>``
60   Updates the tags associated with a particular message.  The posted
61   data should be a JSON array of tag-names with a prefix indicating
62   the desired change.  Use ``+`` to add a tag and ``-`` to remove a
63   tag.  For example::
64
65     $ curl -XPOST -H 'Content-Type: application/json' -d '["+obsolete", "-needs-review"]' http://localhost:5000/mid/e630b6763e9d0771718afee41ea15b29bb4a1de8.1409935538.git.wking@tremily.us
66     ["obsolete", "patch"]
67
68         Adding an already associated tag and removing an already
69         unassociated tag are both no-ops.  Returns the updated tags as a
70         JSON array.  If the given Message-ID isn't in the notmuch database,
71         returns a 404.
72
73 ``GET /gmane/<group>/<article>``
74   Returns the article's Message-ID at ``text/plain``.  For example,
75   get the ``Message-ID`` of `this article`__ with::
76
77     $ curl -XGET http://localhost:5000/gmane/gmane.mail.notmuch.general/19007
78     e630b6763e9d0771718afee41ea15b29bb4a1de8.1409935538.git.wking@tremily.us
79
80 __ `Gmane Python nmbug v4`_
81
82
83 .. _nmbug: http://notmuchmail.org/nmbug/
84 .. _notmuch: http://notmuchmail.org/
85 .. _Gmane: http://gmane.org/
86 .. _Flask: http://flask.pocoo.org/
87 .. _Flask-Cors: https://pypi.python.org/pypi/Flask-Cors/
88 .. _Nginx: http://nginx.org/
89 .. _Python: https://www.python.org/
90 .. _http.server: https://docs.python.org/3/library/http.server.html
91 .. _Gmane Python nmbug v4: http://article.gmane.org/gmane.mail.notmuch.general/19007