1
1
from django.shortcuts import render_to_response
2
2
from django.template import RequestContext
3
3
from settings import WIDELANDS_SVN_DIR
4
from templatetags.wl_markdown import do_wl_markdown
9
5
def mainpage(request):
10
return render_to_response('mainpage.html',
11
context_instance=RequestContext(request))
6
return render_to_response('mainpage.html', context_instance=RequestContext(request))
14
9
from forms import RegistrationWithCaptchaForm
15
10
from django.http import HttpResponseRedirect
16
11
from django.core.urlresolvers import reverse
18
from registration.backends.default import DefaultBackend
20
13
def register(request):
22
15
Overwritten view from registration to include a captcha.
26
19
remote_ip = request.META['REMOTE_ADDR']
27
20
if request.method == 'POST':
28
form = RegistrationWithCaptchaForm(remote_ip,data=request.POST,
21
form = RegistrationWithCaptchaForm(remote_ip,data=request.POST, files=request.FILES)
30
22
if form.is_valid():
31
new_user = DefaultBackend().register(request, **form.cleaned_data)
23
new_user = form.save()
32
24
return HttpResponseRedirect(reverse('registration_complete'))
34
26
form = RegistrationWithCaptchaForm(remote_ip)
36
28
context = RequestContext(request)
37
29
return render_to_response("registration/registration_form.html",
38
30
{ 'registration_form': form },
39
31
context_instance=context)
41
def developers(request):
43
This reads out the authors file in the SVN directory, and returns it
44
as a wl_markdown_object. This replaces the wiki developers list
46
data = open(WIDELANDS_SVN_DIR + "txts/developers", "r").readlines()[4:]
49
line = line.strip('"_ \n\r').rstrip('" _ \n\r')
52
txt = ''.join(newdata)
53
txt,_ = re.subn(r'<\/?rt.*?>', "", txt)
54
txt,_ = re.subn(r'<br.*?>', "", txt)
55
b = { "24": "\n\n## ",
65
txt,_ = re.subn(r'<p * font-size=(\d+).*?>(.*?)</p>',
67
(b[m.group(1)], m.group(2), e[m.group(1)]), txt)
68
txt,_ = re.subn(r'<p.*?>(.*?)</p>',
69
lambda m: ("- %s\n" % m.group(1) if len(m.group(1).strip()) else "")
72
txt = do_wl_markdown(txt.decode('utf-8'),custom=False)
75
return render_to_response("mainpage/developers.html",
77
context_instance=RequestContext(request)
82
34
def changelog(request):
84
This reads out the changelog in the SVN directory, and returns it
36
This reads out the changelog in the SVN directory, and returns it
85
37
as a wl_markdown_object. This replaces the wiki changelog
87
39
data = open(WIDELANDS_SVN_DIR + "ChangeLog", "r").read()
88
return render_to_response("mainpage/changelog.html",
90
context_instance=RequestContext(request)
40
return render_to_response("mainpage/changelog.html",
42
context_instance=RequestContext(request)