Commit dc44eac6 by Ernie Park

Merge

parents 3aa5df6a d561504c
......@@ -13,7 +13,7 @@ def strip_dict(d):
(type(d[k]) == float or type(d[k]) == int) ])
return d
class LoncapaProblem():
class LoncapaProblem(object):
def get_state(self):
''' Stored per-user session data neeeded to:
1) Recreate the problem
......
class XModule:
class XModule(object):
''' Implements a generic learning module.
Initialized on access with __init__, first time with state=None, and
then with state
......
{% load i18n simplewiki_utils %}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="{{ LANGUAGE_CODE }}">
<head>
<title>{{ wiki_title }}</title>
<link rel="stylesheet" media="screen,print" href="/static/simplewiki/css/base.css" />
<link rel="stylesheet" media="print" href="/static/simplewiki/css/base_print.css" />
<link rel="stylesheet" href="/static/simplewiki/css/autosuggest_inquisitor.css" />
<link rel="stylesheet" href="/static/css/local.css" type="text/css" media="all" />
<link href="/static/css/jquery-ui-1.8.16.custom.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="/static/simplewiki/js/bsn.AutoSuggest_c_2.0.js"></script>
<script type="text/javascript" src="/static/js/schematic.js"></script>
<script type="text/javascript" src="/static/lib/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="/static/js/video_player.js"></script>
<script type="text/javascript">
function set_related_article_id(s) {
document.getElementById('wiki_related_input_id').value = s.id;
document.getElementById('wiki_related_input_submit').disabled=false;
}
var x = window.onload;
window.onload = function(){
var options = {
script: "{% url search_related wiki_article.get_url %}/?self={{wiki_article.pk }}&",
json: true,
varname: "query",
maxresults: 35,
callback: set_related_article_id,
noresults: "{% trans "Nothing found!" %}"
};
var as = new AutoSuggest('wiki_related_input', options);
if (typeof x == 'function')
x();
}
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {inlineMath: [ ['$','$'], ["\\(","\\)"]],
displayMath: [ ['$$','$$'], ["\\[","\\]"]]}
});
</script> <script type="text/javascript" src="/static/lib/mathjax/MathJax.js?config=TeX-AMS_HTML-full"></script>
<script>
$(function(){
$.ajaxSetup ({
// Disable caching of AJAX responses
cache: false
});
$(".div_wiki_circuit").each(function(d,e) {
id = $(this).attr("id");
name = id.substring(17);
//alert(name);
$("#"+id).load("/edit_circuit/"+name);
f=this;
});
update_schematics();});
</script>
{% block wiki_head %}
{% endblock %}
</head>
<body>
<style>
#coursenav_wiki {
background-color: #031634;
border-bottom-color: #023063;
border-collapse: separate;
border-left-color: #023063;
border-right-color: #023063;
border-top-color: #023063;
color: #023063;
display: block;
font-family: Helvetica, Arial, sans-serif;
font-size: 13px;
font-style: normal;
font-weight: normal;
height: 19px;
margin-bottom: 8px;
margin-left: 0px;
margin-right: 8px;
margin-top: 4px;
padding-bottom: 8px;
padding-left: 0px;
padding-right: 8px;
padding-top: 4px;
text-align: right;
}
a.navwiki {
background-color: transparent;
border-bottom-color: #ADCC80;
border-collapse: separate;
border-left-color: #ADCC80;
border-right-color: #ADCC80;
border-top-color: #ADCC80;
color: #ADCC80;
cursor: auto;
display: inline;
font-family: Helvetica, Arial, sans-serif;
font-size: 13px;
font-style: normal;
font-weight: normal;
height: 0px;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
margin-top: 0px;
padding-bottom: 0px;
padding-left: 0px;
padding-right: 0px;
padding-top: 0px;
text-align: right;
text-decoration: none;
width: 0px;
}
#footer_wiki {
background-color: #031634;
background-image: url(/static/css/images/css/bottomWrapper-bg.jpg);
background-position: 50% 0%;
background-repeat: repeat-x;
color: #ADCC80;
display: block;
font-family: Helvetica, Arial, sans-serif;
font-size: 13px;
font-style: normal;
font-weight: normal;
height: 140px;
text-align: center;
}
a.footwiki {
background-color: transparent;
background-image: none;
background-position: 0% 0%;
background-repeat: repeat;
color: #ADCC80;
cursor: auto;
display: inline;
font-family: Helvetica, Arial, sans-serif;
font-size: 13px;
font-style: normal;
font-weight: normal;
height: 0px;
letter-spacing: normal;
line-height: 20px;
text-align: center;
text-decoration: none;
}
</style>
<div id="coursenav_wiki" width="100%">
<a class="navwiki" href="/book">Textbook</a>
<span class="ui-icon ui-icon-bullet" style="display:inline-block;"></span>
<a class="navwiki" href="/courseware">Courseware</a>
<span class="ui-icon ui-icon-bullet" style="display:inline-block;"></span>
<a class="navwiki" href="/discussion">Discussion</a>
<span class="ui-icon ui-icon-bullet" style="display:inline-block;"></span>
<a class="navwiki" href="/wiki"><b>Wiki</b></a>
<span class="ui-icon ui-icon-bullet" style="display:inline-block;"></span>
<a class="navwiki" href="/profile">Profile</a>
<span class="ui-icon ui-icon-bullet" style="display:inline-block;"></span>
<a class="navwiki" href="/s/help.html">Help</a> <span class="ui-icon ui-icon-bullet" style="display:inline-block;"></span>
<a class="navwiki" href="/logout">Log out</a>
</div>
<h1>{% block wiki_page_title %}{% endblock %}</h1>
<hr />
{% block wiki_panel %}
<div id="wiki_panel">
<div class="wiki_box">
<div class="wiki_box_header">
<div class="wiki_box_corner"></div>
<div class="wiki_box_bar"></div>
</div>
<div class="wiki_box_contents" style="position: relative;">
<div style="border: 2px outset #CCC; width: 250px; padding: 10px; background-color: #FFF; position: absolute; right: 100px; top: -80px; display: none; color: #000;" id="wiki_create_form">
{% with "this.wiki_article_name.value.replace(/([^a-zA-Z0-9\-])/g, '')+'/_create/'" as theaction %}
<form method="GET" onsubmit="this.action='{% url wiki_view "" %}{{ wiki_article.get_url }}/' + {{ theaction }};">
{% endwith %}
<h2>{% trans "Create article" %}</h2>
<p>
<label for="id_wiki_article_name">{% trans "Title of article" %}</label>
<input type="text" name="wiki_article_name" id="id_wiki_article_name" /><br/>
<label for="id_wiki_article_is_child">{% trans "Create as a child of current article"%}</label>
<input type="checkbox" name="wiki_article_is_child" id="id_wiki_artcile_is_child" disabled="true" checked={%if wiki_article%}"yes"{%else%}"no"{%endif%}>
</p>
<p>
<input type="button" class="button" value="{% trans "Cancel" %}" style="display: inline-block; margin-right: 2px;" onclick="document.getElementById('wiki_create_form').style.display='none';" />
<input type="submit" class="button" value="{% trans "Next" %} &gt;" style="display: inline-block; margin-right: 2px; font-weight: bold;" />
</p>
</form>
</div>
<p>
{% if wiki_article %}
<input type="button" onclick="javascript:location.href='{% url wiki_view wiki_article.get_url %}'" value="View" style="width: 100%;" /><br />
<input type="button" onclick="javascript:location.href='{% url wiki_edit wiki_article.get_url %}'" value="Edit" style="width: 100%;"{% if not wiki_write %} disabled="true"{%endif%} /><br />
<input type="button" onclick="javascript:location.href='{% url wiki_history wiki_article.get_url 1 %}'" value="History" style="width: 100%;" />
{% endif %}
<input type="button" onclick="document.getElementById('wiki_create_form').style.display='block';" value="{% trans "Create article" %}" style="width: 100%; margin-bottom: 2px;" class="button" />
<input type="button" onclick="javascript:location.href='{% url wiki_random wiki_article.get_url %}'" value="{% trans "Random article" %}" style="width: 100%; margin-bottom: 2px;" class="button" />
</p>
{% if wiki_article %}
{% if wiki_article.locked %}
<p><strong>{% trans "This article has been locked" %}</strong></p>
{% endif %}
<p>
<i>{% trans "Last modified" %}: {{ wiki_article.modified_on|date }}, {{ wiki_article.modified_on|time }}</i>
</p>
{% endif %}
</div>
<div class="wiki_box_footer">
<div class="wiki_box_corner"></div>
<div class="wiki_box_bar"></div>
</div>
</div>
</div>
{% endblock %}
{% block wiki_body %}
{% endblock %}
<br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <div id="footer_wiki"> <p style="padding-top:20px"> Copyright (c). 2011. MIT. <a class="footwiki" href=http://creativecommons.org/licenses/by-sa/3.0/>Some rights reserved.</a> <!-- Template based on a design from http://www.dotemplate.com/ -- Donated $10 (pmitros) so we don't need to include credit. --> </p> </div>
</body>
</html>
{% extends "simplewiki_base.html" %}
{% load i18n simplewiki_utils %}
{% block wiki_page_title %}
Create article
{% endblock %}
{% block wiki_body %}
<form method="POST" id="wiki_revision">{% csrf_token %}
<table id="wiki_revision_table">
{{ wiki_form }}
<tr>
<td colspan="2" align="right">
<input type="submit" value="{% trans "Create article" %}" /></td>
</tr>
</table>
</form>
{% endblock %}
{% extends "simplewiki_base.html" %}
{% load i18n simplewiki_utils %}
{% block wiki_page_title %}
{{wiki_article.title}}
{% endblock %}
{% block wiki_body %}
<form method="POST" id="wiki_revision">{% csrf_token %}
<table id="wiki_revision_table">
{{ wiki_form }}
<tr>
<td colspan="2" align="right">
<input type="submit" value="{% trans "Edit article" %}" /></td>
</tr>
</table>
</form>
{% endblock %}
{% extends "simplewiki_base.html" %}
{% load i18n simplewiki_utils %}
{% block wiki_page_title %}
Oops...
{% endblock %}
{% block wiki_body %}
<div class="wiki_error">
{{ wiki_error|safe }}
{% if wiki_err_notfound %}
{% if wiki_url %}
<p>
The page you requested could not be found.
Click <a href="{% url wiki_create wiki_url %}">here</a> to create it.
</p>
{% else %}
<p>
Or maybe rather: Congratulations! It seems that there's no root
article, which is probably because you just installed simple-wiki
and your installation is working. Now you can create the root article.
Click <a href="{% url wiki_create "" %}">here</a> to create it.
</p>
{% endif %}
{% else %}
{% if wiki_err_noparent %}
<p>
You cannot create this page, because its parent
does not exist. Click <a href="{% url wiki_create wiki_url_parent %}">here</a>
to create it.
</p>
{% else %}
{% if wiki_err_keyword %}
<p>
The page you're trying to create <b>{{wiki_url}}</b> starts with <b>_</b>, which is reserved for internal use.
</p>
{% else %}
{% if wiki_err_locked %}
<p>
The article you are trying to modify is locked.
</p>
{% else %}
{% if wiki_err_noread %}
<p>
You do not have access to read this article.
</p>
{% else %}
{% if wiki_err_nowrite %}
<p>
You do not have access to edit this article.
</p>
{% else %}
{% if wiki_err_noanon %}
<p>
Anonymous attachments are not allowed. Try logging in.
</p>
{% else %}
{% if wiki_err_create %}
<p>
You do not have access to create this article.
</p>
{% else %}
{% if wiki_err_encode %}
<p>
The url you requested could not be handled by the wiki.
Probably you used a bad character in the URL.
Only use digits, English letters, underscore and dash. For instance
/wiki/An_Article-1
</p>
{% else %}
<p>
An error has occured.
</p>
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
</div>
{% endblock %}
{% extends "simplewiki_base.html" %}
{% load i18n simplewiki_utils %}
{% block wiki_page_title %}
{{ wiki_article.title }}
{% endblock %}
{% block wiki_body %}
<form method="POST">{% csrf_token %}
<table id="wiki_history_table">
<thead>
<tr>
<th id="revision">Revision</th>
<th id="comment">Comment</th>
<th id="diff">Diff</th>
<th id="modified">Modified</th>
</tr>
</thead>
<tbody>
{% for revision in wiki_history %}
<tr style="border-top: 1px" {%cycle '' 'class="dark"'%}>
<td width="15px">
<input type="radio" name="revision" id="{{ revision.id }}" value="{{ revision.id }}"{%ifequal wiki_article.current_revision.id revision.id%} checked{%endifequal%} />
<label for="{{ revision.id }}">
{{ revision }}
{% if revision.previous_revision %}
{% ifnotequal revision.counter revision.previous_revision.counter|add:1 %}
<br/>(based on {{ revision.previous_revision }})
{% endifnotequal %}
{% endif %}
</label>
</td>
<td>{% if revision.revision_text %}{{ revision.revision_text}}{% else %}<i>None</i>{% endif %}</td>
<td class="diff">{% for x in revision.get_diff %}{{x|escape}}<br />{% endfor %}</td>
<td>{{ revision.get_user}}
<br/>
{{ revision.revision_date|date}} {{ revision.revision_date|time}}
</td>
</tr>
{% endfor %}
</tbody>
{% if wiki_prev_page or wiki_next_page %}
<tfoot>
<tr>
<td colspan="4">
{% if wiki_prev_page %}
<a href="{% url wiki_history wiki_article.get_url wiki_prev_page %}">{% trans "Previous page" %}</a>
{% endif %}
{% if wiki_next_page %}
<a href="{% url wiki_history wiki_article.get_url wiki_next_page %}">{% trans "Next page" %}</a>
{% endif %}
</td>
</tr>
</tfoot>
{% endif %}
</table>
<input type="submit" value="Change revision"{% if not wiki_write %} disabled="true"{% endif %} />
</form>
{% endblock %}
{% extends "simplewiki_base.html" %}
{% load i18n simplewiki_utils %}
{% block wiki_page_title %}
{% if wiki_search_query %}
{% trans "Search results for" %} '{{ wiki_search_query|escape }}'
{% else %}
{% trans "Displaying all articles" %}
{% endif %}
{% endblock %}
{% block wiki_body %}
{% for article in wiki_search_results %}
{% if article.get_url %}
<a href="{% url wiki_view article.get_url %}">{{ article.get_url }}</a><br/>
{% else %}
<a href="{% url wiki_view '' %}">/</a><br/>
{% endif %}
{% empty %}
{% trans "No articles were found!" %}
{% endfor %}
{% endblock %}
{% load i18n simplewiki_utils %}
{% if started %}
<script type="text/javascript">
parent.document.getElementById("wiki_attach_progress_container").style.display='block';
</script>
{% else %}
{% if finished %}
<script type="text/javascript">
parent.document.getElementById("wiki_attach_progress_container").style.display='none';
parent.location.reload();
</script>
{% else %}
{% if overwrite_warning %}
<script type="text/javascript">
if (confirm('{% trans "Warning: The filename already exists? Really overwrite" %} {{ filename }}?'))
parent.document.getElementById("wiki_attach_overwrite").checked=true;
parent.document.getElementById("wiki_attach_overwrite").form.submit();
</script>
{% else %}
{% if too_big %}
<script type="text/javascript">
alert('File is too big. Maximum: {{max_size|filesizeformat}}\nYour file was: {{file.size|filesizeformat}}');
</script>
{% else %}
<script type="text/javascript">
parent.document.getElementById("wiki_attach_progress").style.width='{{progress_width}}%';
</script>
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% extends "simplewiki_base.html" %}
{% load i18n simplewiki_utils %}
{% block wiki_page_title %}
{{ wiki_article.title }}
{% endblock %}
{% block wiki_body %}
<div id="wiki_article">
{{ wiki_article.current_revision.contents_parsed|safe }}
</div>
{% endblock %}
......@@ -3,7 +3,8 @@ import types
from django.core.urlresolvers import get_callable
from django.http import Http404, HttpResponse, HttpResponseRedirect, HttpResponseServerError, HttpResponseForbidden, HttpResponseNotAllowed
from django.utils import simplejson
from django.shortcuts import get_object_or_404, render_to_response
from djangomako.shortcuts import render_to_response, render_to_string
from django.shortcuts import get_object_or_404
from django.template import RequestContext, Context, loader
from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse
......@@ -11,6 +12,14 @@ from django.contrib.auth.decorators import login_required
from django.db.models import Q
from django.conf import settings
from django.shortcuts import redirect
from django.core.context_processors import csrf
from django.template import Context
from django.http import HttpResponse
import djangomako.middleware
from mako.template import Template
from mako.lookup import TemplateLookup
from models import *
from settings import *
......@@ -26,11 +35,12 @@ def view(request, wiki_url):
perm_err = check_permissions(request, article, check_read=True)
if perm_err:
return perm_err
c = RequestContext(request, {'wiki_article': article,
d = {'wiki_article': article,
'wiki_write': article.can_write_l(request.user),
'wiki_attachments_write': article.can_attach(request.user),
} )
return render_to_response('simplewiki_view.html', c)
}
return render_to_response('simplewiki_view.html', d)
def root_redirect(request):
"""
......@@ -62,9 +72,9 @@ def create(request, wiki_url):
url_path = get_url_path(wiki_url)
if url_path != [] and url_path[0].startswith('_'):
c = RequestContext(request, {'wiki_err_keyword': True,
'wiki_url': '/'.join(url_path) })
return render_to_response('simplewiki_error.html', c)
d = {'wiki_err_keyword': True,
'wiki_url': '/'.join(url_path) }
return render_to_response('simplewiki_error.html', d)
# Lookup path
try:
......@@ -76,9 +86,9 @@ def create(request, wiki_url):
path = Article.get_url_reverse(url_path[:-1], root)
if not path:
c = RequestContext(request, {'wiki_err_noparent': True,
'wiki_url_parent': '/'.join(url_path[:-1]) })
return render_to_response('simplewiki_error.html', c)
d = {'wiki_err_noparent': True,
'wiki_url_parent': '/'.join(url_path[:-1]) }
return render_to_response('simplewiki_error.html', d)
perm_err = check_permissions(request, path[-1], check_locked=False, check_write=True)
if perm_err:
......@@ -119,11 +129,12 @@ def create(request, wiki_url):
f = CreateArticleForm(initial={'title':request.GET.get('wiki_article_name', url_path[-1]),
'contents':_('Headline\n===\n\n')})
c = RequestContext(request, {'wiki_form': f,
d = {'wiki_form': f,
'wiki_write': True,
})
}
d.update(csrf(request))
return render_to_response('simplewiki_create.html', c)
return render_to_response('simplewiki_create.html', d)
def edit(request, wiki_url):
if not request.user.is_authenticated():
......@@ -160,13 +171,14 @@ def edit(request, wiki_url):
return HttpResponseRedirect(reverse('wiki_view', args=(article.get_url(),)))
else:
f = EditForm({'contents': article.current_revision.contents, 'title': article.title})
c = RequestContext(request, {'wiki_form': f,
d = {'wiki_form': f,
'wiki_write': True,
'wiki_article': article,
'wiki_attachments_write': article.can_attach(request.user),
})
}
d.update(csrf(request))
return render_to_response('simplewiki_edit.html', c)
return render_to_response('simplewiki_edit.html', d)
def history(request, wiki_url, page=1):
if not request.user.is_authenticated():
......@@ -211,15 +223,16 @@ def history(request, wiki_url, page=1):
next_page = p + 1 if page_count > p else None
prev_page = p - 1 if p > 1 else None
c = RequestContext(request, {'wiki_page': p,
d = {'wiki_page': p,
'wiki_next_page': next_page,
'wiki_prev_page': prev_page,
'wiki_write': article.can_write_l(request.user),
'wiki_attachments_write': article.can_attach(request.user),
'wiki_article': article,
'wiki_history': history[beginItem:beginItem+page_size],})
'wiki_history': history[beginItem:beginItem+page_size],}
d.update(csrf(request))
return render_to_response('simplewiki_history.html', c)
return render_to_response('simplewiki_history.html', d)
def search_articles(request, wiki_url):
if not request.user.is_authenticated():
......@@ -251,9 +264,9 @@ def search_articles(request, wiki_url):
if results.count() == 1:
return HttpResponseRedirect(reverse('wiki_view', args=(results[0].get_url(),)))
else:
c = RequestContext(request, {'wiki_search_results': results,
'wiki_search_query': querystring})
return render_to_response('simplewiki_searchresults.html', c)
d = {'wiki_search_results': results,
'wiki_search_query': querystring}
return render_to_response('simplewiki_searchresults.html', d)
return view(request, wiki_url)
......@@ -344,15 +357,14 @@ def random_article(request, wiki_url):
def encode_err(request, url):
return render_to_response('simplewiki_error.html',
RequestContext(request, {'wiki_err_encode': True}))
{'wiki_err_encode': True})
def not_found(request, wiki_url):
if not request.user.is_authenticated():
return redirect('/')
"""Generate a NOT FOUND message for some URL"""
return render_to_response('simplewiki_error.html',
RequestContext(request, {'wiki_err_notfound': True,
'wiki_url': wiki_url}))
return render_to_response('simplewiki_error.html', {'wiki_err_notfound': True,
'wiki_url': wiki_url})
def get_url_path(url):
"""Return a list of all actual elements of a url, safely ignoring
......@@ -392,15 +404,15 @@ def check_permissions(request, article, check_read=False, check_write=False, che
locked_err = check_locked and article.locked
if read_err or write_err or locked_err:
c = RequestContext(request, {'wiki_article': article,
d = {'wiki_article': article,
'wiki_err_noread': read_err,
'wiki_err_nowrite': write_err,
'wiki_err_locked': locked_err,})
'wiki_err_locked': locked_err,}
# TODO: Make this a little less jarring by just displaying an error
# on the current page? (no such redirect happens for an anon upload yet)
# benjaoming: I think this is the nicest way of displaying an error, but
# these errors shouldn't occur, but rather be prevented on the other pages.
return render_to_response('simplewiki_error.html', c)
return render_to_response('simplewiki_error.html', d)
else:
return None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment