Skip to content

Commit f80441e

Browse files
committed
Added django.me functionality.
1 parent b137dfd commit f80441e

File tree

6 files changed

+149
-1
lines changed

6 files changed

+149
-1
lines changed

pip_requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ github2
1515
httplib2
1616
distutils2
1717
django-sentry
18+
Unipath
19+
django
1820
-e git+http://github.com/nathanborror/django-basic-apps.git#egg=basic
1921
-e hg+http://bitbucket.org/andrewgodwin/south/#egg=south
2022
-e git+http://github.com/alex/django-taggit.git#egg=taggit
2123
-e git+http://github.com/ericflo/django-pagination.git#egg=pagination
2224
-e git+http://github.com/nathanborror/django-registration.git#egg=django-registration
2325
-e git+https://github.com/toastdriven/django-tastypie.git#egg=tastypie
24-
django==1.3

readthedocs/core/djangome_urls.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from django.conf import settings
2+
from django.conf.urls.defaults import *
3+
from django.views.generic import RedirectView
4+
5+
from urls import urlpatterns as main_patterns
6+
7+
ALL_VERSIONS_RE = '(?P<version>.+)'
8+
9+
urlpatterns = patterns('',
10+
url('^(?P<term>[\w\-\.]+)$',
11+
'djangome.views.redirect_to_term',
12+
{'version': 'latest'},
13+
),
14+
url('^(?P<term>[\w\-\.]+)/stats$',
15+
'djangome.views.show_term',
16+
{'version': 'latest'},
17+
),
18+
url('^%s/(?P<term>[\w\-\.]+)$' % ALL_VERSIONS_RE,
19+
'djangome.views.redirect_to_term',
20+
name = 'redirect_to_term'
21+
),
22+
url('^%s/(?P<term>[\w\-\.]+)/stats$' % ALL_VERSIONS_RE,
23+
'djangome.views.show_term',
24+
name = 'show_term'
25+
),
26+
)
27+
urlpatterns += main_patterns

readthedocs/core/middleware.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ def process_request(self, request):
6464
request.subdomain = True
6565
request.slug = subdomain
6666
request.urlconf = 'core.subdomain_urls'
67+
if len(domain_parts) == 3:
68+
subdomain = domain_parts[0]
69+
if not (subdomain.lower() == 'www') and 'rtfd.org' in host:
70+
request.slug = subdomain
71+
request.urlconf = 'core.djangome_urls'
6772
if 'readthedocs.org' not in host \
6873
and 'localhost' not in host \
6974
and 'testserver' not in host:
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{% extends "base.html" %}
2+
3+
{% block title %}Choose a redirect for "{{ djangome_term }}"{% endblock %}
4+
5+
{% block content %}
6+
<h3> Choose a redirect for <kbd>{{ djangome_term }}</kbd></h3>
7+
{% load url from future %}
8+
{% if winners %}
9+
<ul class="winners">
10+
{% for choice in winners %}
11+
<li><a href="?url={{ choice|urlencode }}">{{ choice }}</a></li>
12+
{% endfor %}
13+
</ul>
14+
{% endif %}
15+
{% if losers %}
16+
<ul class="losers">
17+
{% for choice in losers %}
18+
<li><a href="?url={{ choice|urlencode }}">{{ choice }}</a></li>
19+
{% endfor %}
20+
</ul>
21+
{% endif %}
22+
<form action="{% url "redirect_to_term" version=version term=djangome_term %}" method="get">
23+
{% if form.errors %}<p class="err">{{ form.url.errors.as_text }}</p>{% endif %}
24+
<p>
25+
{{ form.url.label_tag }}
26+
{{ form.url }}
27+
<input type="submit" value="Save &amp; go &rarr;">
28+
</p>
29+
</form>
30+
{% endblock %}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{% extends "base.html" %}
2+
3+
{% block title %}One-offs{% endblock %}
4+
5+
{% block content %}
6+
{% load url from future %}
7+
<table>
8+
<thead>
9+
<tr>
10+
<th>Version</th>
11+
<th>Term</th>
12+
<th>Target</th>
13+
</tr>
14+
</thead>
15+
<tbody>
16+
{% for version, term, target in oneoffs %}
17+
<tr>
18+
<td><code>{{ version|default:"-" }}</code></td>
19+
<td><code>{{ term }}</code></td>
20+
<td><a href="{{ target }}">{{ target }}</a></td>
21+
<td>
22+
<form action="{% url "manage_oneoffs" %}" method="post" accept-charset="utf-8">
23+
<input type="hidden" name="version" value="{{ version|default:"" }}">
24+
<input type="hidden" name="term" value="{{ term }}">
25+
<input type="hidden" name="target" value="{{ target }}">
26+
<input type="submit" name="action" value="kill">
27+
</form>
28+
</td>
29+
</tr>
30+
{% endfor %}
31+
<form action="{% url "manage_oneoffs" %}" method="post" accept-charset="utf-8">
32+
<tr>
33+
<td><input type="text" name="version" value="" id="version"></td>
34+
<td><input type="text" name="term" value="" id="term"></td>
35+
<td><input type="text" name="target" value="" id="target"></td>
36+
<td><input type="submit" name="action" value="add"></td>
37+
</tr>
38+
</form>
39+
</tbody>
40+
</table>
41+
{% endblock %}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{% extends "base.html" %}
2+
3+
{% block title %}Statistics for "{{ term }}"{% endblock %}
4+
{% block pagetitle %}Statistics for <kbd>{{ term }}</kbd>:{% endblock %}
5+
6+
{% block content %}
7+
{% load url from future %}
8+
<table>
9+
<thead>
10+
<tr>
11+
<th>URL</th>
12+
<th>Clicks</th>
13+
</tr>
14+
</thead>
15+
<tbody>
16+
{% for score, url in urls %}
17+
<tr>
18+
<td>{{ url }}</td>
19+
<td>
20+
{{ score }}
21+
{% if can_edit %}
22+
<form action="{% url "redirect_to_term" version=version term=term %}" method="get">
23+
<input type="hidden" name="url" value="{{ url }}">
24+
<input type="hidden" name="return_to" value="{% url "show_term" version=version term=term %}">
25+
<input type="submit" name="incr" value="++">
26+
</form>
27+
{% endif %}
28+
</td>
29+
</tr>
30+
{% endfor %}
31+
{% if can_edit %}
32+
<form action="{% url "redirect_to_term" version=version term=term %}" method="get">
33+
<tr>
34+
<td>
35+
<input type="text" name="url" value="http://docs.djangoproject.com/" size="120">
36+
<input type="hidden" name="return_to" value="{% url "show_term" version=version term=term %}">
37+
</td>
38+
<td><input type="submit" value="Add"></td>
39+
</tr>
40+
</form>
41+
{% endif %}
42+
</tbody>
43+
</table>
44+
{% endblock %}

0 commit comments

Comments
 (0)