From 0bd8d17a43a5467be8c23e6617b1426bb5049288 Mon Sep 17 00:00:00 2001 From: Nicolas Setton Date: Sat, 2 Sep 2017 14:24:26 -0400 Subject: [PATCH] Add platform support for serving pages ... along with instructions on how to get the ACE editor. --- README.md | 14 ++++++++ compile_server/app/static/.gitignore | 0 compile_server/app/static/ace-builds | 1 + compile_server/app/templates/code_page.html | 40 +++++++++++++++++++++ compile_server/app/views.py | 6 ++++ compile_server/urls.py | 6 ++++ 6 files changed, 67 insertions(+) create mode 100644 compile_server/app/static/.gitignore create mode 160000 compile_server/app/static/ace-builds create mode 100644 compile_server/app/templates/code_page.html diff --git a/README.md b/README.md index 2bc56fd..09fa9e3 100644 --- a/README.md +++ b/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: diff --git a/compile_server/app/static/.gitignore b/compile_server/app/static/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/compile_server/app/static/ace-builds b/compile_server/app/static/ace-builds new file mode 160000 index 0000000..673da62 --- /dev/null +++ b/compile_server/app/static/ace-builds @@ -0,0 +1 @@ +Subproject commit 673da62ea06f971c30a660095ceaead16d9356ae diff --git a/compile_server/app/templates/code_page.html b/compile_server/app/templates/code_page.html new file mode 100644 index 0000000..96cf6e8 --- /dev/null +++ b/compile_server/app/templates/code_page.html @@ -0,0 +1,40 @@ +{% load static %} + + + + + + Editor + + + + +
function foo(items) {
+    var i;
+    for (i = 0; i < items.length; i++) {
+        alert("Ace Rocks " + items[i]);
+    }
+}
+ + + + + + + diff --git a/compile_server/app/views.py b/compile_server/app/views.py index db81023..2b7a3f0 100644 --- a/compile_server/app/views.py +++ b/compile_server/app/views.py @@ -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) diff --git a/compile_server/urls.py b/compile_server/urls.py index fff971f..8593384 100644 --- a/compile_server/urls.py +++ b/compile_server/urls.py @@ -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), + ]