2019-12-15 15:45:05 +08:00
|
|
|
|
<!-- 继承自模板:app_doc/docs_base.html -->
|
|
|
|
|
{% extends 'app_doc/docs_base.html' %}
|
|
|
|
|
<!-- 引入静态文件 -->
|
2020-10-18 08:05:41 +08:00
|
|
|
|
{% load static %}
|
2020-12-02 21:25:59 +08:00
|
|
|
|
{% load i18n %}
|
2019-07-21 22:08:04 +08:00
|
|
|
|
|
2019-12-15 15:45:05 +08:00
|
|
|
|
{% block title %}{{ project.name }}{% endblock %}
|
2019-12-08 18:59:49 +08:00
|
|
|
|
|
2019-12-15 15:45:05 +08:00
|
|
|
|
{% block head_toolbar %}
|
2020-04-03 21:05:27 +08:00
|
|
|
|
{% if request.user == project.create_user or colla_user > 0 %}
|
|
|
|
|
<span class="btn pull-left">|</span>
|
|
|
|
|
<a class="btn pull-left" href="{% url 'create_doc' %}?pid={{project.id}}" target="_blank">
|
2020-12-02 21:25:59 +08:00
|
|
|
|
<i class="fa fa-plus-square"></i> <span class="layui-hide-xs">{% trans "添加" %}</span>
|
2019-12-15 15:45:05 +08:00
|
|
|
|
</a>
|
|
|
|
|
{% endif %}
|
2020-04-11 22:14:27 +08:00
|
|
|
|
{% if request.user == project.create_user %}
|
|
|
|
|
<a class="btn pull-left" href="{% url 'manage_project' %}" target="_blank">
|
2020-12-02 21:25:59 +08:00
|
|
|
|
<i class="fa fa-cubes"></i> <span class="layui-hide-xs">{% trans "管理" %}</span>
|
2020-04-11 22:14:27 +08:00
|
|
|
|
</a>
|
|
|
|
|
{% endif %}
|
2019-12-15 15:45:05 +08:00
|
|
|
|
{% endblock %}
|
2019-12-08 18:59:49 +08:00
|
|
|
|
|
2019-12-15 15:45:05 +08:00
|
|
|
|
{% block content_head %}
|
|
|
|
|
<h1>{{ project.name }}</h1><hr>
|
2020-06-21 21:44:10 +08:00
|
|
|
|
<p style="" class="project-doc-content-head">
|
2020-12-02 21:25:59 +08:00
|
|
|
|
<i class="fa fa-user"></i> {% trans "创建人:" %}{% if project.create_user.first_name != '' %} {{project.create_user.first_name}} {% else %} {{project.create_user}}{% endif %}
|
|
|
|
|
<i class="fa fa-timer"></i> {% trans "创建于:" %}{{ project.create_time }}
|
2020-04-20 07:51:25 +08:00
|
|
|
|
</p>
|
2019-12-15 15:45:05 +08:00
|
|
|
|
{% endblock %}
|
2019-07-24 14:38:06 +08:00
|
|
|
|
|
2019-12-15 15:45:05 +08:00
|
|
|
|
{% block page_content %}
|
|
|
|
|
<!-- 引入文档过滤器 -->
|
|
|
|
|
{% load doc_filter %}
|
2020-10-28 21:28:07 +08:00
|
|
|
|
<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
|
|
|
|
|
<ul class="layui-tab-title">
|
2020-12-02 21:25:59 +08:00
|
|
|
|
<li class="layui-this">{% trans "简介" %}</li>
|
|
|
|
|
<li>{% trans "目录大纲" %}</li>
|
|
|
|
|
<li>{% trans "最新文档" %}</li>
|
2020-10-28 21:28:07 +08:00
|
|
|
|
{% if enable_project_report %}
|
2020-12-02 21:25:59 +08:00
|
|
|
|
<li>{% trans "文集下载" %}</li>
|
2020-10-28 21:28:07 +08:00
|
|
|
|
{% endif %}
|
|
|
|
|
</ul>
|
2020-10-28 22:06:03 +08:00
|
|
|
|
<div class="layui-tab-content" style="padding: 0;">
|
2020-10-28 21:28:07 +08:00
|
|
|
|
<!-- 文集简介 -->
|
|
|
|
|
<div class="layui-tab-item layui-show">
|
2020-12-06 09:06:28 +08:00
|
|
|
|
<div id="project-desc">
|
|
|
|
|
<textarea style="display: none;">{% if project.intro == '' or project.intro is None %}{% trans "暂无文集简介" %}{% else %}{{project.intro}}{% endif %}
|
|
|
|
|
</textarea></div>
|
2020-10-28 21:28:07 +08:00
|
|
|
|
</div>
|
|
|
|
|
<!-- 目录大纲 -->
|
|
|
|
|
<div class="layui-tab-item">
|
|
|
|
|
<ul class="summary" id="doc-tree"></ul>
|
|
|
|
|
</div>
|
|
|
|
|
<!-- 最新文档 -->
|
|
|
|
|
<div class="layui-tab-item">
|
|
|
|
|
{% for doc in new_docs %}
|
|
|
|
|
<div>
|
|
|
|
|
<h3><a style="color:#333;" href="{% url 'doc' project.id doc.id %}">{{doc.name}}</a></h3>
|
2020-11-05 22:27:37 +08:00
|
|
|
|
<p style="color:#999;font-size:12px;">
|
|
|
|
|
{% if doc.pre_content|length > 200 %}
|
|
|
|
|
{{ doc.pre_content|truncatechars:200 }}……
|
|
|
|
|
{% else %}
|
|
|
|
|
{{ doc.pre_content }}
|
|
|
|
|
{% endif %}
|
|
|
|
|
</p>
|
2020-10-28 21:28:07 +08:00
|
|
|
|
<p style="color:#999;font-size:12px;"><i class="fa fa-user"></i> {% if doc.create_user.first_name != '' %} {{doc.create_user.first_name}} {% else %} {{doc.create_user}}{% endif %} - <i class="fa fa-clock-o"></i> {{doc.modify_time}}</p>
|
|
|
|
|
</div>
|
|
|
|
|
<hr>
|
|
|
|
|
{% endfor %}
|
|
|
|
|
</div>
|
|
|
|
|
<!-- 文集下载 -->
|
|
|
|
|
{% if enable_project_report %}
|
|
|
|
|
<div class="layui-tab-item">
|
|
|
|
|
<p style="margin-bottom: 0px;">
|
|
|
|
|
<span class="layui-breadcrumb" lay-separator="|">
|
|
|
|
|
{% if allow_download %}
|
|
|
|
|
{% if allow_download.allow_epub == 1 %}
|
|
|
|
|
<a href="javascript:void(0);" onclick="reportFile('{{project.id}}','epub')"><i class="fa fa-download"></i> <u>EPUB电子书</u></a>
|
|
|
|
|
{% endif %}
|
|
|
|
|
{% if allow_download.allow_pdf == 1 %}
|
|
|
|
|
<a href="javascript:void(0);" onclick="reportFile('{{project.id}}','pdf')"><i class="fa fa-download"></i> <u>PDF电子书</u></a>
|
|
|
|
|
{% endif %}
|
|
|
|
|
{% if allow_download.allow_pdf == 0 and allow_download.allow_epub == 0 %}
|
2020-12-02 21:25:59 +08:00
|
|
|
|
<a>{% trans "文集作者未开放此文集的任何格式下载!" %}</a>
|
2020-10-28 21:28:07 +08:00
|
|
|
|
{% endif %}
|
|
|
|
|
{% else %}
|
2020-12-02 21:25:59 +08:00
|
|
|
|
<a>{% trans "文集作者未开放此文集的任何格式下载!" %}</a>
|
2020-10-28 21:28:07 +08:00
|
|
|
|
{% endif %}
|
|
|
|
|
</span>
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
{% endif %}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2020-03-07 09:30:11 +08:00
|
|
|
|
|
|
|
|
|
{% if enable_project_report %}
|
2020-06-21 21:44:10 +08:00
|
|
|
|
<script>
|
|
|
|
|
// 下载文件
|
2020-03-07 09:30:11 +08:00
|
|
|
|
reportFile = function(pro_id,types){
|
2020-05-02 18:16:57 +08:00
|
|
|
|
layer.load(1)
|
2020-03-07 09:30:11 +08:00
|
|
|
|
var data = {'pro_id':pro_id,'types':types};
|
|
|
|
|
$.post("{% url 'report_file' %}",data,function(r){
|
2020-05-02 18:16:57 +08:00
|
|
|
|
layer.closeAll('loading');
|
2020-03-07 09:30:11 +08:00
|
|
|
|
if(r.status){
|
|
|
|
|
//文件下载提示
|
|
|
|
|
downloadFile(r.data)
|
|
|
|
|
}else{
|
2020-05-02 18:16:57 +08:00
|
|
|
|
layer.msg(r.data)
|
2020-03-07 09:30:11 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
//下载文件弹出框
|
|
|
|
|
downloadFile = function(download_link){
|
|
|
|
|
layer.open({
|
|
|
|
|
type:1,
|
|
|
|
|
title:"下载导出文档",
|
|
|
|
|
area:"300px",
|
|
|
|
|
id:"downloadMd",
|
2020-05-02 18:16:57 +08:00
|
|
|
|
content:'<p style="text-align:center;color:red;">请尽快下载,避免失效!</p><br><a class="layui-btn layui-btn-normal layui-btn-fluid download-md-link" href="'+ download_link + '" download="" >点击下载文件</a>',
|
2020-03-07 09:30:11 +08:00
|
|
|
|
//btn:['确定','取消'], //添加按钮
|
|
|
|
|
//btnAlign:'c', //按钮居中
|
|
|
|
|
success: function (layero, index) {
|
|
|
|
|
$(layero).find('.download-md-link').click(function () {
|
|
|
|
|
layer.close(index);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
{% endif %}
|
2020-10-28 21:28:07 +08:00
|
|
|
|
|
2020-06-21 21:44:10 +08:00
|
|
|
|
{% endblock %}
|
|
|
|
|
|
2020-08-30 13:51:26 +08:00
|
|
|
|
{% block doc_bottom_block %}
|
|
|
|
|
<button id="share" class="doc-bottom-btn" tooltip="分享本文档" style="padding-left: 20px;">
|
2020-12-02 21:25:59 +08:00
|
|
|
|
<i class="fa fa-share-alt" ></i> {% trans "分享" %}
|
2020-08-30 13:51:26 +08:00
|
|
|
|
</button>
|
|
|
|
|
{% endblock %}
|
|
|
|
|
|
2020-06-21 21:44:10 +08:00
|
|
|
|
{% block custom_script %}
|
2020-10-28 22:06:03 +08:00
|
|
|
|
<link rel="stylesheet" href="{% static 'vditor/dist/index.css' %}?version={{mrdoc_version}}" />
|
2020-10-29 18:57:21 +08:00
|
|
|
|
<style>
|
|
|
|
|
.vditor-reset{
|
|
|
|
|
font-size: inherit;
|
|
|
|
|
font-family:inherit;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
2020-11-26 22:43:22 +08:00
|
|
|
|
<script src="{% static 'vditor/dist/index.min.js' %}"></script>
|
2020-06-21 21:44:10 +08:00
|
|
|
|
<script>
|
2020-11-29 14:03:39 +08:00
|
|
|
|
// 生成文集简介中的文档大纲
|
|
|
|
|
$.ajaxSetup({
|
|
|
|
|
data: {csrfmiddlewaretoken: '{{ csrf_token }}' },
|
|
|
|
|
});
|
2020-06-21 21:44:10 +08:00
|
|
|
|
var tree = layui.tree;
|
2020-11-23 22:02:22 +08:00
|
|
|
|
var layer = layui.layer;
|
2020-06-21 21:44:10 +08:00
|
|
|
|
getDocTree = function(){
|
|
|
|
|
layer.load(1)
|
|
|
|
|
$.post("{% url 'get_pro_doc_tree' %}",{'pro_id':'{{project.id}}'},function(r){
|
|
|
|
|
if(r.status){
|
|
|
|
|
var toc_str = ""
|
|
|
|
|
layui.each(r.data,function(index,item){
|
|
|
|
|
toc_str += "<li>"
|
|
|
|
|
if(item['children'] != undefined){ // 存在二级文档
|
|
|
|
|
li = '<a href="/project-'+'{{project.id}}'+'/doc-'+item.id+'/" title="'+item.title+'">'+item.title+'</a>' +'<ul class="sub-menu">'
|
|
|
|
|
toc_str += li
|
|
|
|
|
layui.each(item['children'],function(index,item){// 遍历二级文档
|
|
|
|
|
toc_str += '<li>'
|
|
|
|
|
if(item['children'] != undefined){ //存在三级文档
|
|
|
|
|
li = '<a href="/project-'+'{{project.id}}'+'/doc-'+item.id+'/" title="'+item.title+'">'+item.title+'</a>' +'<ul class="sub-menu">'
|
|
|
|
|
toc_str += li
|
|
|
|
|
layui.each(item['children'],function(index,item){ // 遍历三级文档
|
|
|
|
|
li = '<li><a href="/project-'+'{{project.id}}'+'/doc-'+item.id+'/" title="'+item.title+'">'+item.title+'</a></li>'
|
|
|
|
|
toc_str += li
|
|
|
|
|
})
|
|
|
|
|
toc_str += '</ul>'
|
|
|
|
|
}else{// 不存在三级文档
|
|
|
|
|
li = '<a href="/project-'+'{{project.id}}'+'/doc-'+item.id+'/" title="'+item.title+'">'+item.title+'</a>'
|
|
|
|
|
toc_str += li
|
|
|
|
|
}
|
|
|
|
|
toc_str += '</li>'
|
|
|
|
|
})
|
|
|
|
|
toc_str += '</ul>'
|
|
|
|
|
}else{//不存在二级文档
|
|
|
|
|
li = '<a href="/project-'+'{{project.id}}'+'/doc-'+item.id+'/" title="'+item.title+'">'+item.title+'</a>'
|
|
|
|
|
toc_str += li
|
|
|
|
|
}
|
|
|
|
|
toc_str += '</li>'
|
|
|
|
|
});
|
|
|
|
|
$("#doc-tree").append(toc_str);
|
|
|
|
|
}else{
|
|
|
|
|
layer.msg("获取文集文档大纲失败!")
|
|
|
|
|
}
|
|
|
|
|
layer.closeAll('loading')
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
getDocTree();
|
2020-10-28 22:06:03 +08:00
|
|
|
|
// 渲染文集简介Markdown
|
|
|
|
|
const renderDesc = () => {
|
2020-11-23 22:02:22 +08:00
|
|
|
|
layer.load(1);
|
2020-10-28 22:06:03 +08:00
|
|
|
|
const md_desc = $("#project-desc textarea").val()
|
|
|
|
|
Vditor.preview(document.getElementById('project-desc'),
|
|
|
|
|
md_desc, {
|
2020-10-29 22:56:42 +08:00
|
|
|
|
"cdn":"{% static 'vditor' %}",
|
2020-10-28 22:06:03 +08:00
|
|
|
|
speech: {
|
|
|
|
|
enable: true,
|
|
|
|
|
},
|
|
|
|
|
anchor: 1,
|
2020-11-23 22:02:22 +08:00
|
|
|
|
after:function(){
|
|
|
|
|
layer.closeAll('loading');
|
|
|
|
|
}
|
2020-10-28 22:06:03 +08:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
renderDesc();
|
2020-06-21 21:44:10 +08:00
|
|
|
|
</script>
|
2019-12-15 15:45:05 +08:00
|
|
|
|
{% endblock %}
|