From 771056d6e4f89cc11db27ea19391edec06fa837a Mon Sep 17 00:00:00 2001 From: Skia Date: Fri, 8 Jan 2016 17:11:38 +0100 Subject: [PATCH] Add a begining of API and CSS+JS (static files folder) --- core/static/core/script.js | 1 + core/static/core/style.css | 3 +++ core/templates/core/api/markdown.html | 4 ++++ core/templates/core/base.html | 6 +++++- core/templates/core/pagerev_edit.html | 5 +++++ core/urls.py | 3 +++ core/views/__init__.py | 1 + core/views/api.py | 4 ++++ 8 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 core/static/core/script.js create mode 100644 core/static/core/style.css create mode 100644 core/templates/core/api/markdown.html create mode 100644 core/views/api.py diff --git a/core/static/core/script.js b/core/static/core/script.js new file mode 100644 index 00000000..78828edb --- /dev/null +++ b/core/static/core/script.js @@ -0,0 +1 @@ +console.log('Guy'); diff --git a/core/static/core/style.css b/core/static/core/style.css new file mode 100644 index 00000000..5be8aa85 --- /dev/null +++ b/core/static/core/style.css @@ -0,0 +1,3 @@ +body { + background: #EEE; +} diff --git a/core/templates/core/api/markdown.html b/core/templates/core/api/markdown.html new file mode 100644 index 00000000..fafcdb01 --- /dev/null +++ b/core/templates/core/api/markdown.html @@ -0,0 +1,4 @@ +{% load renderer %} + +{{ text|markdown }} + diff --git a/core/templates/core/base.html b/core/templates/core/base.html index eeec42e9..2045959e 100644 --- a/core/templates/core/base.html +++ b/core/templates/core/base.html @@ -1,8 +1,12 @@ +{% load staticfiles %} - + {% block head %} {% block title %}Bienvenue sur le Sith de l'AE!{% endblock %} + + + {% endblock %} diff --git a/core/templates/core/pagerev_edit.html b/core/templates/core/pagerev_edit.html index fa0f8bc4..679e3e17 100644 --- a/core/templates/core/pagerev_edit.html +++ b/core/templates/core/pagerev_edit.html @@ -1,10 +1,15 @@ {% extends "core/page.html" %} +{% block head %} +{{ block.super }} +{% endblock %} + {% block page %}

Edit page

{% csrf_token %} {{ form.as_p }} + {# TODO: NOW THAT WE HAVE JAVASCRIPT, MAKE A PREVISUALISATION BUTTON USING api/markdown?text=guyguyguy #}

{% endblock %} diff --git a/core/urls.py b/core/urls.py index d65a8716..73a8a5ad 100644 --- a/core/urls.py +++ b/core/urls.py @@ -34,5 +34,8 @@ urlpatterns = [ url(r'^page/(?P[a-z0-9/\-_]*)/hist$', PageHistView.as_view(), name='page_hist'), url(r'^page/(?P[a-z0-9/\-_]*)/rev/(?P[0-9]+)/', PageRevView.as_view(), name='page_rev'), url(r'^page/(?P[a-z0-9/\-_]*)/$', PageView.as_view(), name='page'), + + # API + url(r'^api/markdown$', render_markdown, name='api_markdown'), ] diff --git a/core/views/__init__.py b/core/views/__init__.py index 14870a2b..b249f1ae 100644 --- a/core/views/__init__.py +++ b/core/views/__init__.py @@ -62,4 +62,5 @@ from .user import * from .page import * from .site import * from .group import * +from .api import * diff --git a/core/views/api.py b/core/views/api.py new file mode 100644 index 00000000..c7a9d8b2 --- /dev/null +++ b/core/views/api.py @@ -0,0 +1,4 @@ +from django.shortcuts import render + +def render_markdown(request): + return render(request, 'core/api/markdown.html', context={'text': request.GET['text']})