Skip to content

Add basic badges from shields.io #711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 1, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions readthedocs/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ def queue_info(request):

return HttpResponse(resp)

def badge(request, project_slug, version_slug):
version = get_object_or_404(Version, project__slug=project_slug,
slug=version_slug)
last_build = version.builds.filter(type='html').order_by('-date')[0]

color = 'green'
if not last_build.success:
color = 'red'
url = 'http://img.shields.io/badge/Docs-%s-%s.svg' % (version.slug, color)
import requests
response = requests.get(url, stream=True)
return HttpResponse(response.content, mimetype="image/svg+xml")

def live_builds(request):
builds = Build.objects.filter(state='building')[:5]
WEBSOCKET_HOST = getattr(settings, 'WEBSOCKET_HOST', 'localhost:8088')
Expand Down
3 changes: 3 additions & 0 deletions readthedocs/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@
url(r'^wipe/(?P<project_slug>[-\w]+)/(?P<version_slug>[\w]{1}[-\w\.]+)/$',
'core.views.wipe_version',
name='wipe_version'),
url(r'^badge/(?P<project_slug>[-\w]+)/(?P<version_slug>[\w]{1}[-\w\.]+)/$',
'core.views.badge',
name='badge'),
url(r'^profiles/create/', 'profiles.views.create_profile',
{'form_class': UserProfileForm},
name='profiles_profile_create'),
Expand Down