MrDoc/template/app_doc/doc.html

167 lines
6.1 KiB
HTML
Raw Normal View History

2019-12-15 15:45:05 +08:00
<!-- 继承自模板app_doc/docs_base.html -->
{% extends 'app_doc/docs_base.html' %}
<!-- 引入静态文件 -->
{% load staticfiles %}
2020-02-17 23:02:53 +08:00
{% block keyword %}{{ doc.name }},{{ project.name }},{% endblock %}
{% block description %}{{doc.pre_content | slice:"0:100"}}{% endblock %}
2019-12-15 15:45:05 +08:00
{% block title %}{{ doc.name }} - {{ project.name }}{% endblock %}
2019-12-15 15:45:05 +08:00
{% block head_toolbar %}
2020-08-07 21:36:37 +08:00
{% if request.user == doc.create_user or request.user == project.create_user %}
<span class="btn pull-left">|</span>
2019-12-15 15:45:05 +08:00
<a class="btn pull-left" aria-label="" href="{% url 'modify_doc' doc_id=doc.id %}">
<i class="fa fa-edit"></i> <span class="layui-hide-xs">修改</span>
2019-12-15 15:45:05 +08:00
</a>
<a class="btn pull-left" aria-label="" href="{% url 'create_doc' %}?pid={{project.id}}" target="_blank">
<i class="fa fa-plus-square"></i> <span class="layui-hide-xs">添加</span>
</a>
<a class="btn pull-left" aria-label="" href="{% url 'manage_doc' %}" target="_blank">
<i class="fa fa-cubes"></i> <span class="layui-hide-xs">管理</span>
</a>
{% elif colla_user > 0 %}
<span class="btn pull-left">|</span>
{% if colla_user_role == 1 %}
<a class="btn pull-left" aria-label="" href="{% url 'modify_doc' doc_id=doc.id %}">
<i class="fa fa-edit"></i> <span class="layui-hide-xs">修改</span>
</a>
{% endif %}
<a class="btn pull-left" aria-label="" href="{% url 'create_doc' %}?pid={{project.id}}" target="_blank">
<i class="fa fa-plus-square"></i> <span class="layui-hide-xs">添加</span>
2019-12-15 15:45:05 +08:00
</a>
2020-03-21 16:52:11 +08:00
{% endif %}
<!-- 文档目录 -->
2020-08-07 21:36:37 +08:00
<div id="toc-container" class='sidebar'></div>
2020-08-30 13:51:26 +08:00
2019-12-15 15:45:05 +08:00
{% endblock %}
2019-12-15 15:45:05 +08:00
{% block content_head %}
<h1>{{ doc.name }}</h1><hr>
2020-08-30 13:51:26 +08:00
<!-- <p style="" class="project-doc-content-head">
<i class="fa fa-user"></i> 作者:{{ doc.create_user.username }}
2019-12-15 15:45:05 +08:00
&nbsp;&nbsp;&nbsp;&nbsp;<i class="fa fa-edit"></i> 最后修改于:{{ doc.modify_time }}
2020-08-30 13:51:26 +08:00
</p> -->
2019-12-15 15:45:05 +08:00
{% endblock %}
2019-12-15 15:45:05 +08:00
{% block page_content %}
<textarea style="display: none;">{{ doc.pre_content }}</textarea>
2020-01-15 21:03:44 +08:00
{% endblock %}
2020-07-31 20:23:23 +08:00
{% block doc_bottom_block %}
2020-08-30 13:51:26 +08:00
<div class="layui-row" style="margin-bottom: 10px;padding-left: 20px;">
{% if doc_tags.count > 0 %}
<i class="fa fa-tag"></i>
{% for tag in doc_tags %}
<a href="{% url 'tag_docs' tag.tag.id %}" style="font-size: 12px;line-height: 14px;height: 16px;padding: 0 5px;margin-left: 0;">{{tag.tag.name}}</a>
{% endfor %}
{% endif %}
</div>
<div class="layui-row layui-col-space20" style="padding-left: 20px;">
<span>
<i class="fa fa-user"></i> {{ doc.create_user.username }}
</span>
<span tooltip="更新于:{{doc.modify_time}}">
<i class="fa fa-clock-o"></i> {{ doc.modify_time }}
</span>
<button id="share" class="doc-bottom-btn" tooltip="分享本文档">
<i class="fa fa-share-alt" ></i> 分享
</button>
{% if request.user == doc.create_user or request.user.is_superuser %}
<button class="doc-bottom-btn" tooltip="下载文档Markdown" id="download_doc">
<i class="fa fa-download"></i> 下载
</button>
{% endif %}
</div>
2020-07-31 20:23:23 +08:00
{% endblock %}
2020-01-15 21:03:44 +08:00
{% block doc_previous_next %}
{% load doc_filter %}
2020-07-20 21:38:29 +08:00
<div class="layui-row" style="margin-top: 10px;padding:10px;display:flex;justify-content:space-around;">
<!-- <hr> -->
2020-01-15 21:03:44 +08:00
<div>
{% if doc.id|get_doc_previous == None %}
<button class="layui-btn layui-btn-disabled layui-btn-sm layui-btn-radius"><i class="layui-icon layui-icon-prev "></i>上一篇</button>
2020-01-15 21:03:44 +08:00
{% else %}
<a href="{% url 'doc' doc.top_doc doc.id|get_doc_previous %}" class="layui-btn layui-btn-primary layui-btn-sm layui-btn-radius"><i class="layui-icon layui-icon-prev "></i>上一篇</a>
2020-01-15 21:03:44 +08:00
{% endif %}
</div>
<div>
{% if doc.id|get_doc_next == None %}
<button class="layui-btn layui-btn-disabled layui-btn-sm layui-btn-radius">下一篇<i class="layui-icon layui-icon-next"></i></button>
2020-01-15 21:03:44 +08:00
{% else %}
<a href="{% url 'doc' doc.top_doc doc.id|get_doc_next %}" class="layui-btn layui-btn-primary layui-btn-sm layui-btn-radius">下一篇<i class="layui-icon layui-icon-next"></i></a>
2020-01-15 21:03:44 +08:00
{% endif %}
</div>
</div>
{% endblock %}
2020-08-07 21:36:37 +08:00
{% block right_widget %}
<div class="tocMenu" style="display: none;">目录</div>
{% endblock %}
{% block custom_script %}
2020-07-31 20:23:23 +08:00
<!-- 下载选项卡模板 -->
<div id="download_div" style="display: none;">
<div class="layui-row" style="margin: 10px;">
<a class="" download='{{doc.name}}.md' href="{% url 'download_doc_md' doc.id %}" target="_blank">
<i class="fa fa-download"></i> 下载Markdown文件
</a>
</div>
</div>
2020-08-07 21:36:37 +08:00
<script src="{% static 'toc/doctoc.js' %}"></script>
2020-06-13 09:21:28 +08:00
<script src="{% static 'viewerjs/viewer.js' %}"></script>
<script>
var layer = layui.layer;
2020-06-07 09:50:32 +08:00
// 手机屏幕上默认最小化目录
2020-08-30 13:51:26 +08:00
if(window.outerWidth < 1300){
2020-06-07 09:50:32 +08:00
console.log('最小化目录');
2020-08-07 21:36:37 +08:00
// setTimeout(function(){
$(".sidebar").toggleClass("doc-toc-hide");
// },300)
2020-06-07 09:50:32 +08:00
}
2020-08-07 21:36:37 +08:00
// 切换文档目录显示与否
$(".tocMenu").click(function() {
console.log("隐藏文档目录")
$(".sidebar").toggleClass("doc-toc-hide");
});
//修改a标签链接新窗口打开
$('#content').on('click','a',function(e){
e.target.target = '_blank';
});
2020-06-13 09:21:28 +08:00
// 图片放大显示
var img_options = {
url: 'data-original',
fullscreen:false,//全屏
rotatable:false,//旋转
scalable:false,//翻转
button:false,//关闭按钮
toolbar:false,
title:false,
};
var viewer = new Viewer(document.getElementById('content'), img_options);
2020-07-31 20:23:23 +08:00
// 显示文档下载弹出框
$("#download_doc").click(function(r){
var layer = layui.layer;
layer.open({
type: 1,
title: false,
closeBtn: 0,
area: ['350px','150px'],
shadeClose: true,
content: $('#download_div')
});
});
</script>
2020-06-13 09:21:28 +08:00
2019-12-15 15:45:05 +08:00
{% endblock %}