Added django.me functionality.

rtd2
Eric Holscher 2011-04-06 22:17:52 -07:00
parent b137dfd2d5
commit f80441e426
6 changed files with 149 additions and 1 deletions

View File

@ -15,10 +15,11 @@ github2
httplib2
distutils2
django-sentry
Unipath
django
-e git+http://github.com/nathanborror/django-basic-apps.git#egg=basic
-e hg+http://bitbucket.org/andrewgodwin/south/#egg=south
-e git+http://github.com/alex/django-taggit.git#egg=taggit
-e git+http://github.com/ericflo/django-pagination.git#egg=pagination
-e git+http://github.com/nathanborror/django-registration.git#egg=django-registration
-e git+https://github.com/toastdriven/django-tastypie.git#egg=tastypie
django==1.3

View File

@ -0,0 +1,27 @@
from django.conf import settings
from django.conf.urls.defaults import *
from django.views.generic import RedirectView
from urls import urlpatterns as main_patterns
ALL_VERSIONS_RE = '(?P<version>.+)'
urlpatterns = patterns('',
url('^(?P<term>[\w\-\.]+)$',
'djangome.views.redirect_to_term',
{'version': 'latest'},
),
url('^(?P<term>[\w\-\.]+)/stats$',
'djangome.views.show_term',
{'version': 'latest'},
),
url('^%s/(?P<term>[\w\-\.]+)$' % ALL_VERSIONS_RE,
'djangome.views.redirect_to_term',
name = 'redirect_to_term'
),
url('^%s/(?P<term>[\w\-\.]+)/stats$' % ALL_VERSIONS_RE,
'djangome.views.show_term',
name = 'show_term'
),
)
urlpatterns += main_patterns

View File

@ -64,6 +64,11 @@ class SubdomainMiddleware(object):
request.subdomain = True
request.slug = subdomain
request.urlconf = 'core.subdomain_urls'
if len(domain_parts) == 3:
subdomain = domain_parts[0]
if not (subdomain.lower() == 'www') and 'rtfd.org' in host:
request.slug = subdomain
request.urlconf = 'core.djangome_urls'
if 'readthedocs.org' not in host \
and 'localhost' not in host \
and 'testserver' not in host:

View File

@ -0,0 +1,30 @@
{% extends "base.html" %}
{% block title %}Choose a redirect for "{{ djangome_term }}"{% endblock %}
{% block content %}
<h3> Choose a redirect for <kbd>{{ djangome_term }}</kbd></h3>
{% load url from future %}
{% if winners %}
<ul class="winners">
{% for choice in winners %}
<li><a href="?url={{ choice|urlencode }}">{{ choice }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% if losers %}
<ul class="losers">
{% for choice in losers %}
<li><a href="?url={{ choice|urlencode }}">{{ choice }}</a></li>
{% endfor %}
</ul>
{% endif %}
<form action="{% url "redirect_to_term" version=version term=djangome_term %}" method="get">
{% if form.errors %}<p class="err">{{ form.url.errors.as_text }}</p>{% endif %}
<p>
{{ form.url.label_tag }}
{{ form.url }}
<input type="submit" value="Save &amp; go &rarr;">
</p>
</form>
{% endblock %}

View File

@ -0,0 +1,41 @@
{% extends "base.html" %}
{% block title %}One-offs{% endblock %}
{% block content %}
{% load url from future %}
<table>
<thead>
<tr>
<th>Version</th>
<th>Term</th>
<th>Target</th>
</tr>
</thead>
<tbody>
{% for version, term, target in oneoffs %}
<tr>
<td><code>{{ version|default:"-" }}</code></td>
<td><code>{{ term }}</code></td>
<td><a href="{{ target }}">{{ target }}</a></td>
<td>
<form action="{% url "manage_oneoffs" %}" method="post" accept-charset="utf-8">
<input type="hidden" name="version" value="{{ version|default:"" }}">
<input type="hidden" name="term" value="{{ term }}">
<input type="hidden" name="target" value="{{ target }}">
<input type="submit" name="action" value="kill">
</form>
</td>
</tr>
{% endfor %}
<form action="{% url "manage_oneoffs" %}" method="post" accept-charset="utf-8">
<tr>
<td><input type="text" name="version" value="" id="version"></td>
<td><input type="text" name="term" value="" id="term"></td>
<td><input type="text" name="target" value="" id="target"></td>
<td><input type="submit" name="action" value="add"></td>
</tr>
</form>
</tbody>
</table>
{% endblock %}

View File

@ -0,0 +1,44 @@
{% extends "base.html" %}
{% block title %}Statistics for "{{ term }}"{% endblock %}
{% block pagetitle %}Statistics for <kbd>{{ term }}</kbd>:{% endblock %}
{% block content %}
{% load url from future %}
<table>
<thead>
<tr>
<th>URL</th>
<th>Clicks</th>
</tr>
</thead>
<tbody>
{% for score, url in urls %}
<tr>
<td>{{ url }}</td>
<td>
{{ score }}
{% if can_edit %}
<form action="{% url "redirect_to_term" version=version term=term %}" method="get">
<input type="hidden" name="url" value="{{ url }}">
<input type="hidden" name="return_to" value="{% url "show_term" version=version term=term %}">
<input type="submit" name="incr" value="++">
</form>
{% endif %}
</td>
</tr>
{% endfor %}
{% if can_edit %}
<form action="{% url "redirect_to_term" version=version term=term %}" method="get">
<tr>
<td>
<input type="text" name="url" value="http://docs.djangoproject.com/" size="120">
<input type="hidden" name="return_to" value="{% url "show_term" version=version term=term %}">
</td>
<td><input type="submit" value="Add"></td>
</tr>
</form>
{% endif %}
</tbody>
</table>
{% endblock %}