ajax_post
bug_creator 3 years ago
parent c261121201
commit 63940d2790

@ -718,9 +718,9 @@ def new_answer_md(question_id):
is_anonymous = True
else:
is_anonymous = False
if title == "":
flash("Title cannot be None!")
return render_template('new_posting/new_mdpost.html', form=form)
# if title == "":
# flash("Title cannot be None!")
# return render_template('new_posting/new_mdanswer.html', form=form)
body_html = request.form['test-editormd-html-code']
post = Post(title=title,
body=body,
@ -736,7 +736,7 @@ def new_answer_md(question_id):
else:
flash("You have just posted a posting", 'success')
return redirect(url_for('.view_question',question_id=question_id))
return render_template('new_posting/new_mdpost.html', form=form)
return render_template('new_posting/new_mdanswer.html', form=form)
@main.route('/questions/<question_id>', methods=['GET', 'POST'])
def view_question(question_id):

@ -0,0 +1,80 @@
{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% block title %}New Post (Markdown) {% endblock %}
{%block styles%}
{{super()}}
<link rel="stylesheet" href="{{url_for('static',filename='editormd/css/editormd.min.css')}}">
{%endblock%}
{%block scripts%}
{{super()}}
<script src="{{ url_for('static',filename='editormd/examples/js/jquery.min.js') }}"></script>
<script src="{{ url_for('static',filename='editormd/editormd.min.js') }}"></script>
<script>
window.onload = function(){
document.getElementById('title').addEventListener('keydown',function(e){
if(e.keyCode!=13) return;
e.preventDefault();
this.value += '';
});
};
</script>
<script>
var testEditor;
$(function(){
testEditor=editormd("test-editormd",{
placeholder:'This editor supports Markdown editing, write on the left, preview on the right',
{#width:'1130px',#}
height:'600px',
syncScrolling : "single",
path:"{{url_for('static',filename='editormd/lib/')}}",
saveHTMLToTextarea: true,
emoji: true,
taskList: true,
toolbarIcons : function() { //自定义工具栏
return ["undo","redo","search","|","bold","del","italic","quote",
"uppercase","lowercase","|","h1","h2","h3","h4","h5","h6","|",
"list-ul","list-ol","hr","|","link","reference-link","image",
"table","code","preformatted-text","code-block","datetime",
"emoji","pagebreak","|","clear","watch","preview"]
},
});
})
</script>
{%endblock%}
{% block page_content %}
<div>
{% if current_user.can(Permission.WRITE) %}
<form method="post">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
{{form.hidden_tag()}}
<div id="test-editormd" class="form-control col-md-12" style="width: 100%">
{{form.body(class="form-control",style="display:none;",id="ts")}}
</div>
<div style="text-align: right;margin-bottom: 20px" >
<div class="checkbox" style="display: inline-block;">
<label>
<input name="anonymous" type="checkbox"> anonymous
</label>
</div>
<button type="submit" class="btn btn-primary" style="width: 120px;margin-left: 20px">submit</button>
</div>
</form>
{% endif %}
</div>
{% endblock %}
Loading…
Cancel
Save