summary |
shortlog | log |
commit |
commitdiff |
tree
first ⋅ prev ⋅ next
W. Trevor King [Sat, 20 Sep 2014 20:17:50 +0000 (13:17 -0700)]
nmhive.py: Add GET/POST /mid/<message_id>
So the bookmarklet can get and set tags on a given message. This
currently just uses an in-memory store, but eventually we'll drop
notmuch in on the backend.
W. Trevor King [Sat, 20 Sep 2014 19:35:23 +0000 (12:35 -0700)]
index.html: Avoid interpreting nmbug.js as text/xml
When loaded from file:///.../index.html, Firefox seems to assume
nmbug.js is text/xml. If you're serving nmbug.js from an actual
server, this shouldn't be a problem, but the explicit override makes
local testing easier.
W. Trevor King [Sat, 20 Sep 2014 18:46:55 +0000 (11:46 -0700)]
index.html: Supply nmbug.js as a bookmarklet
Distribute the bookmarklet as a link, so folks can just drag it up
onto their bookmark toolbar.
We're trying to avoid external dependencies, so I don't want to force
folks to load nmbug.js whenever they run the bookmarklet. Instead,
load_bookmarklet fetches nmbug.js, adds a bit of wrapping code to
create the bookmarklet, and injects that as the nmbug link's href.
W. Trevor King [Sat, 20 Sep 2014 20:00:23 +0000 (13:00 -0700)]
nmbug.js: Extract the Gmane article id and convert to a Message-ID
Using some JavaScript gymnastics to look through the available frames
for an article.gmane.org/ URL. For example, we might be on a page
like:
http://thread.gmane.org/gmane.mail.notmuch.general/19055/focus=19056
which is composed of the following frames [1]:
http://news.gmane.org/group/gmane.mail.notmuch.general/thread=19055/force_load=t/focus=19056
http://article.gmane.org/gmane.mail.notmuch.general/19056
http://news.gmane.org/navbar.php?group=gmane.mail.notmuch.general&article=19056&next=19057&prev=19054&newsrc=,19056
Or we might be on the article page directly. There are also permalink
pages (with 'permalink' instead of 'article' available from the
blog-link view), but I'm not worrying about them yet.
[1]: for (var i = 0; i < window.frames.length; i++) {
console.log(window.frames[i].document.URL);
}
W. Trevor King [Sat, 20 Sep 2014 19:51:37 +0000 (12:51 -0700)]
nmhive.py: Add GET /gmane/<group>/<int:article>
Gmane's download endpoint [1] doesn't allow cross-origin requests, and
article.gmane.org -> download.gmane.org is a cross-origin request [2].
Work around that with this proxy endpoint, which uses Flask-Cors [3]
to accept all origins. The bookmarklet can figure out the current
message's group and article id, and hit this endpoint. Then nmhive
will use Gmane's download endpoint to fetch the message as an mbox,
after which we can use Python's stdlib to extract the Message-ID from
the mbox, and return the extracted Message-ID to the bookmarklet.
Later on we can also add local caching and rate-limiting here, so we
don't bother Gmane more than necessary (the downloads are somewhat
expensive [1]).
[1]: http://gmane.org/export.php
[2]: https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy#Definition_of_an_origin
[3]: https://pypi.python.org/pypi/Flask-Cors/
W. Trevor King [Sat, 20 Sep 2014 18:46:37 +0000 (11:46 -0700)]
nmbug.js: Sketch out the bookmarklet framework
We'll have a generic nmbug.show() to handle the UI for tagging a given
message (using its Message-ID). To get that Message-ID, we'll have a
list of potential handlers. When the bookmarklet fires (run()), we'll
iterate through the handlers unril handler.regexp matches
document.URL. For the first match, we'll run handler.handle, which
will do whatever it needs to figure out the Message-ID, and then
launch nmbug.show (passed in via 'callback') with the extracted id.
W. Trevor King [Sat, 20 Sep 2014 18:42:49 +0000 (11:42 -0700)]
README.rst: Start outlining the project