You've already forked code_examples_server
mirror of
https://github.com/AdaCore/code_examples_server.git
synced 2026-02-12 12:45:18 -08:00
Add platform support for serving pages
... along with instructions on how to get the ACE editor.
This commit is contained in:
14
README.md
14
README.md
@@ -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
0
compile_server/app/static/.gitignore
vendored
Normal file
1
compile_server/app/static/ace-builds
Submodule
1
compile_server/app/static/ace-builds
Submodule
Submodule compile_server/app/static/ace-builds added at 673da62ea0
40
compile_server/app/templates/code_page.html
Normal file
40
compile_server/app/templates/code_page.html
Normal 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 < 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>
|
||||
@@ -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)
|
||||
|
||||
@@ -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),
|
||||
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user