Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
AE UTBM
Sith
Commits
1f4c49ac
Commit
1f4c49ac
authored
Jan 11, 2016
by
Skia
Browse files
Make a previsualization button in page edit
parent
771056d6
Changes
3
Hide whitespace changes
Inline
Side-by-side
core/templates/core/base.html
View file @
1f4c49ac
...
...
@@ -6,6 +6,7 @@
<title>
{% block title %}Bienvenue sur le Sith de l'AE!{% endblock %}
</title>
<link
rel=
"stylesheet"
href=
"{% static 'core/style.css' %}"
>
<script
src=
"{% static 'core/script.js' %}"
></script>
<script
src=
"http://code.jquery.com/jquery-2.2.0.min.js"
></script>
{% endblock %}
</head>
...
...
core/templates/core/pagerev_edit.html
View file @
1f4c49ac
...
...
@@ -2,6 +2,17 @@
{% block head %}
{{ block.super }}
<script>
function
make_preview
()
{
$
.
ajax
({
url
:
"
{% url 'core:api_markdown' %}
"
,
method
:
"
GET
"
,
data
:
{
text
:
$
(
"
#id_content
"
).
val
()
}
}).
done
(
function
(
msg
)
{
$
(
"
#preview
"
).
html
(
msg
);
});
}
</script>
{% endblock %}
{% block page %}
...
...
@@ -9,9 +20,11 @@
<form
action=
"{% url 'core:page_edit' page_name=page.get_full_name %}"
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
{# TODO: NOW THAT WE HAVE JAVASCRIPT, MAKE A PREVISUALISATION BUTTON USING api/markdown?text=guyguyguy #}
<p><input
type=
"button"
value=
"Preview"
onclick=
"javascript:make_preview();"
/></p>
<p><input
type=
"submit"
value=
"Save!"
/></p>
</form>
<div
id=
"preview"
>
</div>
{% endblock %}
...
...
core/views/api.py
View file @
1f4c49ac
from
django.shortcuts
import
render
from
core.templatetags.renderer
import
markdown
from
django.http
import
HttpResponse
def
render_markdown
(
request
):
return
render
(
request
,
'core/api/markdown.html'
,
context
=
{
'text'
:
request
.
GET
[
'text'
]
}
)
return
HttpResponse
(
markdown
(
request
.
GET
[
'text'
]
)
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment