2019-07-21 22:08:04 +08:00
|
|
|
{% load staticfiles %}
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="zh-cn">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<title>{{ doc.name }} - {{ project.name }} - MrDoc</title>
|
|
|
|
<link href="{% static 'layui/css/layui.css' %}" rel="stylesheet">
|
|
|
|
<link rel="stylesheet" href="{% static 'editor.md/css/editormd.css' %}" />
|
|
|
|
<link rel="stylesheet" href="{% static 'prism/prism.css' %}" />
|
|
|
|
<link rel="stylesheet" href="{% static 'katex/katex.min.css' %}" />
|
2019-07-24 14:38:06 +08:00
|
|
|
<link rel="stylesheet" href="{% static 'share.js/css/share.min.css' %}" />
|
2019-12-01 20:44:16 +08:00
|
|
|
<link rel="icon" href="{% static 'favicon_16.png' %}"/>
|
|
|
|
<link href="{% static 'mrdoc.css' %}" rel="stylesheet">
|
2019-07-21 22:08:04 +08:00
|
|
|
<style>
|
|
|
|
.doc-content ul li{
|
|
|
|
list-style:disc;
|
|
|
|
}
|
|
|
|
.doc-content ul > li > ul > li{
|
|
|
|
list-style-type: circle;
|
|
|
|
}
|
|
|
|
.doc-content ol li{
|
|
|
|
list-style-type: decimal;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class="doc">
|
|
|
|
<!-- 左侧目录栏 -->
|
|
|
|
<div class="doc-summary">
|
2019-07-24 17:46:31 +08:00
|
|
|
<form action="{% url 'pro_index' pro_id=project.id %}" method="get">
|
2019-07-21 22:08:04 +08:00
|
|
|
<div id="doc-search-input">
|
2019-07-24 17:46:31 +08:00
|
|
|
<input type="text" name="kw" placeholder="输入并回车搜索" value="" class="layui-input doc-search-input">
|
2019-07-21 22:08:04 +08:00
|
|
|
</div>
|
2019-07-24 17:46:31 +08:00
|
|
|
</form>
|
2019-07-21 22:08:04 +08:00
|
|
|
<div class="project-title">
|
|
|
|
<a href="{% url 'pro_index' pro_id=project.id %}">{{ project.name }}</a>
|
|
|
|
</div>
|
|
|
|
<hr>
|
|
|
|
{% load doc_filter %}
|
|
|
|
<nav>
|
|
|
|
<ul class="summary">
|
2019-07-23 17:08:03 +08:00
|
|
|
<!-- 一级目录 -->
|
2019-07-21 22:08:04 +08:00
|
|
|
{% for docs in project_docs %}
|
2019-07-23 17:08:03 +08:00
|
|
|
<li>
|
|
|
|
<a href="{% url 'doc' pro_id=docs.top_doc doc_id=docs.id %}">{{ docs.name }}</a>
|
2019-07-21 22:08:04 +08:00
|
|
|
{% if docs.id|get_next_doc %}
|
2019-07-23 17:08:03 +08:00
|
|
|
{# <i class="layui-icon layui-icon-down tagger-on"></i>#}
|
2019-07-21 22:08:04 +08:00
|
|
|
<ul class="sub-menu">
|
2019-07-23 17:08:03 +08:00
|
|
|
<!-- 二级目录 -->
|
2019-07-21 22:08:04 +08:00
|
|
|
{% for node in docs.id|get_next_doc %}
|
|
|
|
<li><a href="{% url 'doc' pro_id=node.top_doc doc_id=node.id %}">{{ node.name }}</a>
|
|
|
|
{% if node.id|get_next_doc %}
|
|
|
|
<ul>
|
2019-07-23 17:08:03 +08:00
|
|
|
<!-- 三级目录 -->
|
2019-07-21 22:08:04 +08:00
|
|
|
{% for doc in node.id|get_next_doc %}
|
|
|
|
<li><a href="{% url 'doc' pro_id=doc.top_doc doc_id=doc.id %}">{{ doc.name }}</a></li>
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
{% endif %}
|
|
|
|
</li>
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
{% endif %}
|
|
|
|
</li>
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
<div class="bq">
|
|
|
|
<a href="" class="mrdoc-link">本文档使用MrDoc发布</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- 左侧目录栏结束 -->
|
2019-12-01 20:44:16 +08:00
|
|
|
|
2019-07-21 22:08:04 +08:00
|
|
|
<!-- 右侧文档栏 -->
|
|
|
|
<div class="doc-body">
|
|
|
|
<!-- 文档导航 -->
|
|
|
|
<div class="doc-header" role="navigation">
|
|
|
|
<a class="btn pull-right" aria-label="" href="{% url 'pro_list' %}">
|
|
|
|
<i class="fa fa-home"></i> 返回首页
|
|
|
|
</a>
|
2019-07-22 17:09:13 +08:00
|
|
|
<a class="btn pull-left js-toolbar-action" aria-label="" href="javascript:void(0);" title="切换侧边栏">
|
2019-07-21 22:08:04 +08:00
|
|
|
<i class="fa fa-align-justify"></i>
|
|
|
|
</a>
|
|
|
|
|
2019-07-24 13:57:35 +08:00
|
|
|
<a class="btn pull-left font-small" href="javascript:void(0);" title="缩小字体">
|
2019-07-21 22:08:04 +08:00
|
|
|
<i class="fa fa-font">-</i>
|
|
|
|
</a>
|
2019-07-22 17:09:13 +08:00
|
|
|
<div class="dropdown pull-left font-settings ">
|
2019-07-24 13:57:35 +08:00
|
|
|
<a class="btn toggle-dropdown font-large" href="javascript:void(0);" title="放大字体">
|
2019-07-21 22:08:04 +08:00
|
|
|
<i class="fa fa-font">+</i>
|
|
|
|
</a>
|
|
|
|
</div>
|
2019-07-24 13:57:35 +08:00
|
|
|
<a class="btn pull-left font-switch" href="javascript:void(0);" title="切换字体类型">
|
2019-07-22 17:09:13 +08:00
|
|
|
<i class="fa fa-text-height"></i>
|
|
|
|
</a>
|
2019-07-21 22:08:04 +08:00
|
|
|
{% if request.user == doc.create_user %}
|
|
|
|
<a class="btn pull-left" aria-label="" href="{% url 'modify_doc' doc_id=doc.id %}">
|
|
|
|
<i class="fa fa-edit"></i> 修改文档
|
|
|
|
</a>
|
2019-07-27 23:20:28 +08:00
|
|
|
<a class="btn pull-left" aria-label="" href="{% url 'create_doc' %}" target="_blank">
|
|
|
|
<i class="fa fa-edit"></i> 新建文档
|
|
|
|
</a>
|
2019-07-21 22:08:04 +08:00
|
|
|
{% endif %}
|
|
|
|
</div>
|
|
|
|
<!-- 文档主体 -->
|
|
|
|
<div class="doc-body-content">
|
|
|
|
<div class="doc-body-content-div">
|
|
|
|
<!-- 文档内容 -->
|
|
|
|
<div class="doc-content">
|
2019-12-01 20:44:16 +08:00
|
|
|
<!-- 标题 -->
|
2019-07-21 22:08:04 +08:00
|
|
|
<div class="doc-info">
|
2019-07-24 17:46:31 +08:00
|
|
|
{% if doc %}
|
2019-07-21 22:08:04 +08:00
|
|
|
<h1>{{ doc.name }}</h1>
|
|
|
|
<hr>
|
2019-12-01 20:44:16 +08:00
|
|
|
<p style="color: #666;">
|
2019-07-24 14:38:06 +08:00
|
|
|
<i class="layui-icon layui-icon-date"></i> {{ doc.create_time }}
|
|
|
|
<i class="layui-icon layui-icon-user"></i> {{ doc.create_user.username }}
|
|
|
|
</p>
|
2019-07-24 17:46:31 +08:00
|
|
|
{% else %}
|
|
|
|
<h1>共有{{ search_result.count }}个搜索结果</h1>
|
|
|
|
<hr>
|
|
|
|
{% endif %}
|
2019-12-01 20:44:16 +08:00
|
|
|
<!-- 广告代码开始 -->
|
|
|
|
{% if ad_code %}
|
|
|
|
<div class="ad-code">
|
|
|
|
{{ ad_code | safe }}
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
|
|
|
<!-- 广告代码结束 -->
|
2019-07-21 22:08:04 +08:00
|
|
|
</div>
|
2019-12-01 20:44:16 +08:00
|
|
|
<!-- 标题结束 -->
|
|
|
|
<!-- 正文开始 -->
|
2019-07-21 22:08:04 +08:00
|
|
|
<div class="markdown-body" id="content">
|
2019-07-24 17:46:31 +08:00
|
|
|
{% if doc %}
|
2019-07-21 22:08:04 +08:00
|
|
|
{# {{ doc.content | safe }}#}
|
2019-07-24 17:46:31 +08:00
|
|
|
<style>
|
|
|
|
ul.markdown-toc-list li,ul.markdown-toc-list > li > ul li{
|
|
|
|
list-style: none;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<textarea id="" style="display: none;">{{ doc.pre_content }}</textarea>
|
|
|
|
{% else %}
|
|
|
|
{% for result in search_result %}
|
|
|
|
<div>
|
|
|
|
<h2><a href="{% url 'doc' pro_id=project.id doc_id=result.id %}">{{ result.name }}</a></h2>
|
|
|
|
<p>{{ result.pre_content|truncatechars:300 }}</p>
|
|
|
|
</div>
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
2019-07-21 22:08:04 +08:00
|
|
|
</div>
|
2019-12-01 20:44:16 +08:00
|
|
|
<!-- 正文结束 -->
|
2019-07-21 22:08:04 +08:00
|
|
|
</div>
|
|
|
|
<!-- 文档目录 -->
|
|
|
|
<div class="doc-cata">
|
|
|
|
<div id="toc-container"></div>
|
|
|
|
</div>
|
2019-07-24 14:38:06 +08:00
|
|
|
<!-- 社交分享 -->
|
|
|
|
<div class="share-div" style="margin-top: 10px;padding:10px;text-align: center;background-color: #fafafa">
|
|
|
|
分享到:<span class="social-share"></span>
|
|
|
|
</div>
|
2019-07-21 22:08:04 +08:00
|
|
|
</div>
|
2019-07-24 14:38:06 +08:00
|
|
|
|
2019-07-21 22:08:04 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- 右侧文档栏结束 -->
|
|
|
|
<div class="toTop"><i class="layui-icon layui-icon-top" style="font-size: 50px;"></i></div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script src="https://cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
|
|
|
|
<script src="{% static 'layui/layui.all.js' %}"></script>
|
|
|
|
<script src="{% static 'prism/prism.js' %}"></script>
|
|
|
|
<script src="{% static 'editor.md/lib/marked.min.js' %}"></script>
|
|
|
|
<script src="{% static 'editor.md/lib/prettify.min.js' %}"></script>
|
|
|
|
<script src="{% static 'editor.md/lib/raphael.min.js' %}"></script>
|
|
|
|
<script src="{% static 'editor.md/lib/underscore.min.js' %}"></script>
|
|
|
|
<script src="{% static 'editor.md/lib/sequence-diagram.min.js' %}"></script>
|
|
|
|
<script src="{% static 'editor.md/lib/flowchart.min.js' %}"></script>
|
|
|
|
<script src="{% static 'editor.md/lib/jquery.flowchart.min.js' %}"></script>
|
|
|
|
<script src="{% static 'editor.md/editormd.min.js' %}"></script>
|
2019-07-24 14:38:06 +08:00
|
|
|
<script src="{% static 'share.js/js/social-share.min.js' %}"></script>
|
2019-07-21 22:08:04 +08:00
|
|
|
{% block custom_script %}
|
|
|
|
<script>
|
|
|
|
$.ajaxSetup({
|
|
|
|
data: {csrfmiddlewaretoken: '{{ csrf_token }}' },
|
|
|
|
});
|
2019-12-01 20:44:16 +08:00
|
|
|
//解析Markdown为HTML
|
|
|
|
editormd.markdownToHTML("content", {
|
|
|
|
htmlDecode : "style,script,iframe",
|
|
|
|
emoji : true,
|
|
|
|
taskList : true,
|
|
|
|
tex : true, // 科学公式
|
|
|
|
flowChart : true, // 流程图
|
|
|
|
sequenceDiagram : true, // 默认不解析
|
|
|
|
tocm : true, //目录
|
|
|
|
//tocContainer : "#toc-container"
|
|
|
|
});
|
2019-07-21 22:08:04 +08:00
|
|
|
//为当前页面的目录链接添加样式
|
|
|
|
$("nav li a").each(function (i) {
|
|
|
|
var $me = $(this);
|
|
|
|
var lochref = $.trim(window.location.href);
|
|
|
|
var mehref = $.trim($me.get(0).href);
|
|
|
|
if (lochref.indexOf(mehref) != -1) {
|
2019-07-23 13:05:27 +08:00
|
|
|
//console.log($me,lochref,mehref)
|
2019-07-21 22:08:04 +08:00
|
|
|
$me.parent().addClass("active");
|
|
|
|
} else {
|
|
|
|
//console.log(lochref,mehref)
|
|
|
|
$me.parent().removeClass("active");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
2019-07-24 13:57:35 +08:00
|
|
|
<!-- 页面初始化字体设置 -->
|
|
|
|
<script>
|
|
|
|
font_stauts = window.localStorage.getItem('font-sans')
|
|
|
|
//font_size = window.localStorage.getItem('font-size')
|
|
|
|
if(font_stauts == 'serif'){
|
|
|
|
$(".doc-content").toggleClass("switch-font")
|
|
|
|
$("#content").toggleClass("switch-font")
|
|
|
|
}
|
|
|
|
if(window.localStorage.getItem('font-size')){
|
|
|
|
font_size = window.localStorage.getItem('font-size')
|
|
|
|
console.log(font_size)
|
|
|
|
//$('.doc-info h1').css({'font-size':font_size+'rem'})
|
|
|
|
$('#content').css({'font-size':font_size+'rem'})
|
|
|
|
}else{
|
|
|
|
window.localStorage.setItem('font-size',0.8)
|
|
|
|
}
|
|
|
|
</script>
|
2019-07-21 22:08:04 +08:00
|
|
|
<!-- 返回顶部 -->
|
|
|
|
<script type="text/javascript">
|
|
|
|
$(document).ready(function() {
|
|
|
|
// 初始时,“返回顶部”标签隐藏
|
|
|
|
$(".toTop").hide();
|
|
|
|
$(window).scroll(function() {
|
|
|
|
// 若滚动的高度,超出指定的高度后,“返回顶部”的标签出现。
|
|
|
|
if($(document).scrollTop() >= 150) {
|
|
|
|
$(".toTop").show();
|
|
|
|
} else {
|
|
|
|
$(".toTop").hide();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
// 绑定点击事件,实现返回顶部的效果
|
|
|
|
$(".toTop").click(function() {
|
|
|
|
$(document).scrollTop(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
<!-- 切换隐藏侧边栏 -->
|
|
|
|
<script>
|
|
|
|
// 切换侧边栏
|
|
|
|
$(function(){
|
|
|
|
$(".js-toolbar-action").click(toggleSidebar);
|
|
|
|
});
|
|
|
|
//切换侧边栏显示隐藏
|
|
|
|
function toggleSidebar(){
|
|
|
|
console.log("切换侧边栏")
|
|
|
|
$("body").toggleClass("big-page");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
</script>
|
2019-07-22 17:09:13 +08:00
|
|
|
<!-- 切换内容字体 -->
|
|
|
|
<script>
|
|
|
|
//切换文档内容字体类型
|
|
|
|
$(function(){
|
|
|
|
$('.font-switch').click(switchFont);
|
|
|
|
});
|
|
|
|
function switchFont(){
|
2019-07-24 13:57:35 +08:00
|
|
|
if(font_stauts == 'serif'){
|
|
|
|
$(".doc-content").toggleClass("switch-font")
|
|
|
|
$("#content").toggleClass("switch-font")
|
|
|
|
window.localStorage.setItem('font-sans','sans')
|
|
|
|
}else{
|
|
|
|
$(".doc-content").toggleClass("switch-font")
|
|
|
|
$("#content").toggleClass("switch-font")
|
|
|
|
window.localStorage.setItem('font-sans','serif')
|
|
|
|
}
|
|
|
|
};
|
|
|
|
//放大字体
|
|
|
|
$(function(){
|
|
|
|
$('.font-large').click(largeFont);
|
|
|
|
});
|
|
|
|
function largeFont(){
|
|
|
|
var font_size = window.localStorage.getItem('font-size')
|
|
|
|
console.log(font_size)
|
|
|
|
if(parseFloat(font_size) < 1.4){
|
|
|
|
size = parseFloat(font_size) + 0.2
|
|
|
|
//$('.doc-info h1').css({'font-size':size+'rem'})
|
|
|
|
$('#content').css({'font-size':size+'rem'})
|
|
|
|
window.localStorage.setItem('font-size',size)
|
|
|
|
}else{
|
|
|
|
console.log("xxx")
|
|
|
|
}
|
|
|
|
};
|
|
|
|
//缩小字体
|
|
|
|
$(function(){
|
|
|
|
$('.font-small').click(smallFont);
|
|
|
|
});
|
|
|
|
function smallFont(){
|
|
|
|
var font_size = window.localStorage.getItem('font-size')
|
2019-07-24 14:38:06 +08:00
|
|
|
//console.log(font_size)
|
2019-07-24 13:57:35 +08:00
|
|
|
if(parseFloat(font_size) >= 0.6){
|
|
|
|
size = parseFloat(font_size) - 0.2
|
|
|
|
//$('.doc-info h1').css({'font-size':size+'rem'})
|
|
|
|
$('#content').css({'font-size':size+'rem'})
|
|
|
|
window.localStorage.setItem('font-size',size)
|
|
|
|
}else{
|
|
|
|
console.log("xxx")
|
|
|
|
}
|
2019-07-22 17:09:13 +08:00
|
|
|
};
|
|
|
|
</script>
|
2019-12-01 20:44:16 +08:00
|
|
|
<!-- 统计代码开始 -->
|
|
|
|
{{ static | safe }}
|
|
|
|
<!-- 统计代码结束 -->
|
2019-07-21 22:08:04 +08:00
|
|
|
{% endblock %}
|
|
|
|
</body>
|
|
|
|
</html>
|