Add platform support for serving pages

... along with instructions on how to get the ACE editor.
This commit is contained in:
Nicolas Setton
2017-09-02 14:24:26 -04:00
parent fc6ccd2717
commit 0bd8d17a43
6 changed files with 67 additions and 0 deletions

View File

@@ -6,10 +6,24 @@ Prototype server for creating interactive "try SPARK / try Ada" webpages
To setup, do this:
```sh
# This is to create the virtualenv and install Python stuff
virtualenv env
source env/bin/activate
pip install -r REQUIREMENTS.txt
# This is to initialize the django database
./manage.py makemigrations
./manage.py migrate
# This is to get the ACE editor
cd compile_server/app/static
git clone https://github.com/ajaxorg/ace-builds.git
```
To enter the environment, to this
```sh
source env/bin/activate
```
To enter some examples in the database, do this:

0
compile_server/app/static/.gitignore vendored Normal file
View File

Submodule compile_server/app/static/ace-builds added at 673da62ea0

View File

@@ -0,0 +1,40 @@
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Editor</title>
<style type="text/css" media="screen">
body {
overflow: hidden;
}
#editor {
margin: 0;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
</style>
</head>
<body>
<pre id="editor">function foo(items) {
var i;
for (i = 0; i &lt; items.length; i++) {
alert("Ace Rocks " + items[i]);
}
}</pre>
<script src="{% static "ace-builds/src/ace.js" %}" type="text/javascript" charset="utf-8"></script>
<script>
var editor = ace.edit("editor");
editor.setTheme("ace/theme/twilight");
editor.session.setMode("ace/mode/javascript");
</script>
</body>
</html>

View File

@@ -77,3 +77,9 @@ def example(request, name):
'description': e.description,
'resources': resources}
return Response(result)
def code_page(request, example_name):
# TODO: move to a separate file
context = {'example_name': example_name}
return render(request, 'code_page.html', context)

View File

@@ -38,4 +38,10 @@ urlpatterns = [
# Get the details on one example
url(r'^example/([^\/]+)$', views.example),
# HTML urls
# Get the code viewer on one example
url(r'^code_page/([^\/]+)$', views.code_page),
]