提交 7442b1bc 编写于 作者: checklate's avatar checklate

博客预览页优化,使用editormd

上级 75d16b37
......@@ -129,7 +129,7 @@ def post(id):
per_page=current_app.config['FLASKY_COMMENTS_PER_PAGE'],
error_out=False)
comments = pagination.items
return render_template('post.html', posts=[post], form=form,
return render_template('post.html', post=post, form=form,
comments=comments, pagination=pagination)
@main.route('/add/post', methods=['GET', 'POST'])
......
......@@ -68,6 +68,8 @@
{% block scripts %}
{{ super() }}
{{ moment.include_moment() }}
<!-- editormd CSS文件 -->
<link rel="stylesheet" href="{{ url_for('static',filename='editormd/css/editormd.css') }}"/>
<script src="{{ url_for('static',filename='js/jquery.min.js') }}"></script>
<script src="{{ url_for('static',filename='editormd/editormd.min.js') }}"></script>
<script type="text/javascript">
......
......@@ -3,5 +3,55 @@
{% block title %}Flasky - Post{% endblock %}
{% block page_content %}
{% include '_posts.html' %}
<div class="post">
<div id="text_editormd">
<textarea style="display:none;" placeholder="markdown语言">{{ post.body }}</textarea>
</div>
<div class="post-footer">
<a href="{{ url_for('.post', id=post.id) }}">
<span class="label label-default">Permalink</span>
</a>
{% if current_user == post.author %}
<a href="{{ url_for('.edit', id=post.id) }}">
<span class="label label-primary">Edit</span>
</a>
{% elif current_user.is_administrator() %}
<a href="{{ url_for('.edit', id=post.id) }}">
<span class="label label-danger">Edit [Admin]</span>
</a>
{% endif %}
</div>
</div>
{% endblock %}
{% block scripts %}
{{ super() }}
<!-- editormd JS相关文件 -->
<script src="{{ url_for('static', filename='js/jquery.min.js')}}"></script>
<script src="{{ url_for('static',filename='editormd/lib/marked.min.js') }}"></script>
<script src="{{ url_for('static',filename='editormd/lib/prettify.min.js') }}"></script>
<script src="{{ url_for('static',filename='editormd/lib/raphael.min.js') }}"></script>
<script src="{{ url_for('static',filename='editormd/lib/underscore.min.js') }}"></script>
<script src="{{ url_for('static',filename='editormd/lib/sequence-diagram.min.js') }}"></script>
<script src="{{ url_for('static',filename='editormd/lib/flowchart.min.js') }}"></script>
<script src="{{ url_for('static',filename='editormd/lib/jquery.flowchart.min.js') }}"></script>
<script src="{{ url_for('static',filename='editormd/editormd.min.js') }}"></script>
<!-- editormd CSS文件 -->
<link id="theme-style" rel="stylesheet" href="{{url_for('static', filename='css/prettify.css')}}">
<link rel="stylesheet" href="{{ url_for('static',filename='editormd/css/editormd.css') }}"/>
<script type="text/javascript">
var textEditor;
$(function(){
textEditor = editormd.markdownToHTML("text_editormd",{
width:"100%",
height:700,
path: "{{ url_for('static',filename='editormd/lib/') }}",
preview: true,
watch:true,
editor:false,
});
});
</script>
{% endblock %}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册