summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Yves Chibon <pingou@pingoured.fr>2012-03-28 21:41:03 +0200
committerPierre-Yves Chibon <pingou@pingoured.fr>2012-03-28 21:41:03 +0200
commitd0382f6e6b681d84e6f048b725741bb9ee1a946c (patch)
tree67749ad4e3ea7ec1ced2e709ef2580bac837c4d7
parent4650f5f405e8c71fa96e88cde546e096bb3a9811 (diff)
downloadhyperkitty-d0382f6e6b681d84e6f048b725741bb9ee1a946c.tar.gz
hyperkitty-d0382f6e6b681d84e6f048b725741bb9ee1a946c.tar.xz
hyperkitty-d0382f6e6b681d84e6f048b725741bb9ee1a946c.zip
Add a /api information page
-rw-r--r--templates/api.html59
-rw-r--r--urls.py1
-rw-r--r--views/pages.py8
3 files changed, 68 insertions, 0 deletions
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 %}
+ <link rel="stylesheet" type="text/css" media="all" href="{{ STATIC_URL }}css/thread.css" />
+{% endblock %}
+
+{% block content %}
+ <h2>REST API</h2>
+ <p>
+ HyperKitty comes with a small REST API allowing you to programatically retrieve
+ emails and information.
+ </p>
+
+ <div class="odd" style="padding-left: 1em">
+ <h3>Formats</h3>
+ <p>
+ This REST API can return the information into several formats.
+ The default format is html to allow human readibility.<br />
+ To change the format, just add
+ <span style="font-style:italic">?format=&lt;FORMAT&gt;</span> to the url
+ </p>
+ <p>The list of available formats is:</p>
+ <ul>
+ <li>json <a>(?format=json)</a></li>
+ <li>json-p <a>(?format=json-p)</a></li>
+ <li>txt <a>(?format=txt)</a></li>
+ <li>xml <a>(?format=xml)</a></li>
+ <li>html <a>(?format=html)</a></li>
+ <li>xhtml <a>(?format=xhtml)</a></li>
+ </ul>
+ </div>
+
+ <div class="even" style="padding-left: 1em">
+ <h3>Emails <a>/api/email/&lt;list name&gt;/&lt;Message-ID&gt;</a></h3>
+ <p>
+Using the address /api/email/&lt;list name&gt;/&lt;Message-ID&gt; you will be able to
+retrieve the information known about a specific email on the specified mailing-list.
+ </p>
+ <p> For example: <a href="/api/email/devel@fp.o/<1312985457.28933.34.camel@ankur.pc>/">
+ /api/email/devel@fp.o/&lt;1312985457.28933.34.camel@ankur.pc&gt;/
+ </a>
+ </p>
+ </div>
+ <div class="odd" style="padding-left: 1em">
+ <h3>Threads <a>/api/thread/&lt;list name&gt;/&lt;ThreadID&gt;</a></h3>
+ <p>
+ </p>
+ <p>
+Using the address /api/thread/&lt;list name&gt;/&lt;Message-ID&gt; you will be able to
+retrieve the all the email for a specific thread on the specified mailing-list.
+ </p>
+ <p> For example: <a href="/api/thread/devel@fp.o/1/">
+ /api/email/devel@fp.o/1/
+ </a>
+ </p>
+ </div>
+{% 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<tag>.*)$', 'views.mockup.search_tag'),
# REST API
+ url(r'^api/$', 'views.pages.api'),
url(r'^api/email\/(?P<mlist_fqdn>.*@.*)\/(?P<messageid>.*)/', EmailResource.as_view()),
url(r'^api/thread\/(?P<mlist_fqdn>.*@.*)\/(?P<threadid>.*)/', 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