euscanwww/api: clean and "document" euscan API
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
This commit is contained in:
parent
204c53b66f
commit
0ae3305a64
@ -108,8 +108,8 @@ class PackagesHandler(AnonymousBaseHandler):
|
||||
herd = get_object_or_404(Herd, herd=kwargs['herd'])
|
||||
packages = Package.objects.filter(herds__id=herd.id)
|
||||
data = { 'herd' : herd, 'packages' : packages }
|
||||
elif 'maintainer' in kwargs:
|
||||
maintainer = get_object_or_404(Maintainer, id=kwargs['maintainer'])
|
||||
elif 'maintainer_id' in kwargs:
|
||||
maintainer = get_object_or_404(Maintainer, id=kwargs['maintainer_id'])
|
||||
packages = Package.objects.filter(maintainers__id=maintainer.id)
|
||||
data = { 'maintainer' : maintainer, 'packages' : packages }
|
||||
|
||||
|
@ -12,15 +12,16 @@ packages_handler = Resource(handler=PackagesHandler)
|
||||
package_handler = Resource(handler=PackageHandler)
|
||||
|
||||
urlpatterns = patterns('api.views',
|
||||
(r'^1.0/statistics\.(?P<emitter_format>.+)$', statistics_handler),
|
||||
(r'^1.0/herds\.(?P<emitter_format>.+)$', herds_handler),
|
||||
(r'^1.0/categories\.(?P<emitter_format>.+)$', categories_handler),
|
||||
(r'^1.0/maintainers\.(?P<emitter_format>.+)$', maintainers_handler),
|
||||
url(r'^1.0/statistics\.(?P<emitter_format>.+)$', statistics_handler, name='api.views.statistics'),
|
||||
url(r'^1.0/herds\.(?P<emitter_format>.+)$', herds_handler, name='api.views.herds'),
|
||||
url(r'^1.0/categories\.(?P<emitter_format>.+)$', categories_handler, name='api.views.categories'),
|
||||
url(r'^1.0/maintainers\.(?P<emitter_format>.+)$', maintainers_handler, name='api.views.maintainers'),
|
||||
|
||||
(r'^1.0/packages/by-maintainer/(?P<maintainer_id>\d+)\.(?P<emitter_format>.+)$', packages_handler),
|
||||
(r'^1.0/packages/by-herd/(?P<herd>[\@\{\}\w+.-]*)\.(?P<emitter_format>.+)?$', packages_handler),
|
||||
(r'^1.0/packages/by-category/(?P<category>[\w+][\w+.-]*)\.(?P<emitter_format>.+)?$', packages_handler),
|
||||
(r'^1.0/package/(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)\.(?P<emitter_format>.+)$', package_handler),
|
||||
url(r'^1.0/packages/by-maintainer/(?P<maintainer_id>\d+)\.(?P<emitter_format>.+)$', packages_handler, name='api.views.packages'),
|
||||
url(r'^1.0/packages/by-herd/(?P<herd>[\@\{\}\w+.-]*)\.(?P<emitter_format>.+)?$', packages_handler, name='api.views.packages'),
|
||||
url(r'^1.0/packages/by-category/(?P<category>[\w+][\w+.-]*)\.(?P<emitter_format>.+)?$', packages_handler, name='api.views.packages'),
|
||||
|
||||
(r'^1.0/api\.(?P<emitter_format>.+)$', root_handler),
|
||||
url(r'^1.0/package/(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)\.(?P<emitter_format>.+)$', package_handler, name='api.views.package'),
|
||||
|
||||
url(r'^1.0/api\.(?P<emitter_format>.+)$', root_handler, name='api.views.root'),
|
||||
)
|
||||
|
@ -32,6 +32,7 @@ urlpatterns = patterns('euscan.views',
|
||||
(r'^$', 'index'),
|
||||
url(r'^feed/$', GlobalFeed(), name='global_feed'),
|
||||
(r'^about/$', 'about'),
|
||||
(r'^about/api$', 'api'),
|
||||
(r'^statistics/$', 'statistics'),
|
||||
(r'^statistics/charts/(?P<chart>[\w\-]+).png$', 'chart'),
|
||||
(r'^world/$', 'world'),
|
||||
|
@ -123,6 +123,10 @@ def world_scan(request):
|
||||
def about(request):
|
||||
return {}
|
||||
|
||||
@render_to("euscan/api.html")
|
||||
def api(request):
|
||||
return {}
|
||||
|
||||
@render_to("euscan/statistics.html")
|
||||
def statistics(request):
|
||||
return {}
|
||||
|
@ -46,6 +46,7 @@
|
||||
</li>
|
||||
{% endblock %}
|
||||
<li>---</li>
|
||||
<li><a href="{% url euscan.views.api %}">API</a></li>
|
||||
<li><a href="{% url euscan.views.about %}">About</a></li>
|
||||
{% endblock %}
|
||||
</ul>
|
||||
|
22
euscanwww/templates/euscan/api.html
Normal file
22
euscanwww/templates/euscan/api.html
Normal file
@ -0,0 +1,22 @@
|
||||
{% extends "_base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h2>API</h2>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li><a href="{% url api.views.root 'json' %}">/api/1.0/api.json</a></li>
|
||||
<li><a href="{% url api.views.statistics 'json' %}">/api/1.0/statistics.json</a></li>
|
||||
<li><a href="{% url api.views.maintainers 'json' %}">/api/1.0/maintainers.json</a></li>
|
||||
<li><a href="{% url api.views.herds 'json' %}">/api/1.0/herds.json</a></li>
|
||||
<li><a href="{% url api.views.categories 'json' %}">/api/1.0/categories.json</a></li>
|
||||
<li>/api/1.0/packages/by-maintainer/<maintainer-id>.json</li>
|
||||
<li>/api/1.0/packages/by-category/<category>.json</li>
|
||||
<li>/api/1.0/packages/by-herds/<herd>.json</li>
|
||||
<li>/api/1.0/package/<category>/<package>.json</li>
|
||||
</ul>
|
||||
|
||||
Formats: xml, yaml and json
|
||||
</p>
|
||||
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user