From d0382f6e6b681d84e6f048b725741bb9ee1a946c Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Wed, 28 Mar 2012 21:41:03 +0200 Subject: Add a /api information page --- templates/api.html | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ urls.py | 1 + views/pages.py | 8 ++++++++ 3 files changed, 68 insertions(+) create mode 100644 templates/api.html diff --git a/templates/api.html b/templates/api.html new file mode 100644 index 0000000..ba3abb4 --- /dev/null +++ b/templates/api.html @@ -0,0 +1,59 @@ +{% extends "base.html" %} + +{% block title %}{{ app_name }}{% endblock %} + +{% block additional_headers %} + +{% endblock %} + +{% block content %} +

REST API

+

+ HyperKitty comes with a small REST API allowing you to programatically retrieve + emails and information. +

+ +
+

Formats

+

+ This REST API can return the information into several formats. + The default format is html to allow human readibility.
+ To change the format, just add + ?format=<FORMAT> to the url +

+

The list of available formats is:

+ +
+ +
+

Emails /api/email/<list name>/<Message-ID>

+

+Using the address /api/email/<list name>/<Message-ID> you will be able to +retrieve the information known about a specific email on the specified mailing-list. +

+

For example: + /api/email/devel@fp.o/<1312985457.28933.34.camel@ankur.pc>/ + +

+
+
+

Threads /api/thread/<list name>/<ThreadID>

+

+

+

+Using the address /api/thread/<list name>/<Message-ID> you will be able to +retrieve the all the email for a specific thread on the specified mailing-list. +

+

For example: + /api/email/devel@fp.o/1/ + +

+
+{% endblock %} diff --git a/urls.py b/urls.py index c93a575..2b0b302 100644 --- a/urls.py +++ b/urls.py @@ -44,6 +44,7 @@ urlpatterns = patterns('', url(r'^mockup/tag\/(?P.*)$', 'views.mockup.search_tag'), # REST API + url(r'^api/$', 'views.pages.api'), url(r'^api/email\/(?P.*@.*)\/(?P.*)/', EmailResource.as_view()), url(r'^api/thread\/(?P.*@.*)\/(?P.*)/', ThreadResource.as_view()), # Uncomment the admin/doc line below to enable admin documentation: diff --git a/views/pages.py b/views/pages.py index b7f7651..edcc875 100644 --- a/views/pages.py +++ b/views/pages.py @@ -60,6 +60,14 @@ def index(request): return HttpResponse(t.render(c)) +def api(request): + t = loader.get_template('api.html') + c = RequestContext(request, { + 'app_name': settings.APP_NAME, + }) + return HttpResponse(t.render(c)) + + def archives(request, mlist_fqdn, year=None, month=None): # No year/month: past 32 days # year and month: find the 32 days for that month -- cgit