diff --git a/CHANGES.md b/CHANGES.md index f499d17..12a8872 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,14 @@ ## 版本更新记录 +### v0.2.12 + +- 优化Markdown编辑器的扩展工具栏按钮,未选择文本时点击“楷”按钮,光标移动到span标签中间; +- 优化文集内点击新建文档操作体验,在文集内点击【新建】按钮,跳转到文档新建页面后自动选择所属文集; +- 优化新建文档页面的布局,使之更适合在中等屏幕下的操作; +- 当Django的Debug设置为True时,后台会显示站点目前处于Debug调试模式; +- 添加站点地图sitemap功能; + + ### v0.2.11 2020-02-24 - 修复:删除文档导致其子文档找不到父级文档从而产生异常的Bug; diff --git a/MrDoc/settings.py b/MrDoc/settings.py index 6771ffc..70a0f56 100644 --- a/MrDoc/settings.py +++ b/MrDoc/settings.py @@ -25,7 +25,7 @@ SECRET_KEY = '5&71mt9@^58zdg*_!t(x6g14q*@84d%ptr%%s6e0l50zs0we3d' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False -VERSIONS = '0.2.11' +VERSIONS = '0.2.12' ALLOWED_HOSTS = ['*'] @@ -41,6 +41,7 @@ INSTALLED_APPS = [ 'django.contrib.staticfiles', 'app_admin', 'app_doc', + 'django.contrib.sitemaps', ] MIDDLEWARE = [ diff --git a/MrDoc/urls.py b/MrDoc/urls.py index 8f5ede4..5318c52 100644 --- a/MrDoc/urls.py +++ b/MrDoc/urls.py @@ -17,6 +17,8 @@ from django.contrib import admin from django.urls import path,include,re_path from django.views.static import serve from django.conf import settings +from django.contrib.sitemaps import views +from app_doc.sitemaps import all_sitemaps as sitemaps urlpatterns = [ path('admin/', admin.site.urls), @@ -24,4 +26,7 @@ urlpatterns = [ path('user/',include('app_admin.urls'),), re_path('^static/(?P.*)$',serve,{'document_root':settings.STATIC_ROOT}),# 静态文件 re_path('^media/(?P.*)$',serve,{'document_root':settings.MEDIA_ROOT}),# 媒体文件 + path('sitemap.xml', views.index, {'sitemaps': sitemaps,'template_name':'sitemap/sitemap-index.xml'},name='sitemap',), # 站点地图索引 + path('sitemap-
.xml', views.sitemap, {'sitemaps': sitemaps,'template_name':'sitemap/sitemap.xml'}, # 站点地图 + name='django.contrib.sitemaps.views.sitemap') ] diff --git a/README.md b/README.md index 6a6433c..7e0d606 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ 州的先生(zmister.com)自用并完全开源、基于Python编写的文档写作系统。 -当前版本为:**v0.2.11**,版本发布时间为**2020-02-24**,更新记录详见:[CHANGES.md](./CHANGES.md) +当前版本为:**v0.2.12**,版本发布时间为**2020-02-27**,更新记录详见:[CHANGES.md](./CHANGES.md) MrDoc拥有以下特点: diff --git a/app_doc/models.py b/app_doc/models.py index 73d0d06..584c16f 100644 --- a/app_doc/models.py +++ b/app_doc/models.py @@ -19,6 +19,13 @@ class Project(models.Model): verbose_name = '文集' verbose_name_plural = verbose_name + def get_absolute_url(self): + from django.urls import reverse + return reverse("pro_index", + kwargs={ + "pro_id":self.pk} + ) + # 文档模型 class Doc(models.Model): name = models.CharField(verbose_name="文档标题",max_length=50) @@ -41,6 +48,14 @@ class Doc(models.Model): verbose_name_plural = verbose_name # ordering = ['-create_time','sort'] + def get_absolute_url(self): + from django.urls import reverse + return reverse("doc", + kwargs={ + "pro_id": str(self.top_doc), + "doc_id":self.pk} + ) + # 文档模板模型 class DocTemp(models.Model): name = models.CharField(verbose_name="模板名称",max_length=50) diff --git a/app_doc/sitemaps.py b/app_doc/sitemaps.py new file mode 100644 index 0000000..9f71ebc --- /dev/null +++ b/app_doc/sitemaps.py @@ -0,0 +1,56 @@ +# coding:utf-8 +# @文件: sitemaps.py +# @创建者:州的先生 +# #日期:2020/2/26 +# 博客地址:zmister.com + +from django.contrib.sitemaps import Sitemap,GenericSitemap +from django.urls import reverse +from app_doc.models import Doc,Project + +# 首页地图 +class HomeSitemap(Sitemap): + priority = 0.5 + changefreq = 'daily' + + def items(self): + return ['pro_list'] + + def location(self, item): + return reverse(item) + +# 文集地图 +class ProjectSitemap(Sitemap): + changefreq = "daily" + priority = 0.8 + + def items(self): + return Project.objects.filter(role=0) + +# 文档地图 +class DocSitemap(Sitemap): + changefreq = "daily" + priority = 0.8 + + def __init__(self,pro): + self.pro = pro + + def items(self): + return Doc.objects.filter(status=1,top_doc=self.pro) + + def lastmod(self,obj): + return obj.modify_time + +all_sitemaps = {} +all_sitemaps['home'] = HomeSitemap() +for project in Project.objects.filter(role=0): + + info_dict = { + 'queryset': Doc.objects.filter(status=1,top_doc=project.id), + } + # sitemap = GenericSitemap(info_dict,priority=0.6) + sitemap = DocSitemap(pro=project.id) + + # dict key is provided as 'section' in sitemap index view + all_sitemaps[str(project.id)] = sitemap +# print(all_sitemaps) \ No newline at end of file diff --git a/app_doc/views.py b/app_doc/views.py index dc5e73d..dd2f6fc 100644 --- a/app_doc/views.py +++ b/app_doc/views.py @@ -285,6 +285,7 @@ def doc(request,pro_id,doc_id): def create_doc(request): if request.method == 'GET': try: + pid = request.GET.get('pid',-999) # doc_list = Doc.objects.filter(create_user=request.user) project_list = Project.objects.filter(create_user=request.user) doctemp_list = DocTemp.objects.filter(create_user=request.user).values('id','name','create_time') diff --git a/static/mrdoc.css b/static/mrdoc.css index 3396f80..4ca3fcd 100644 --- a/static/mrdoc.css +++ b/static/mrdoc.css @@ -70,7 +70,6 @@ } /* Gap filler */ - .tooltip-item::after { content: ''; position: absolute; @@ -88,7 +87,6 @@ } /* 文集简介提示工具 */ - .tooltip-content { position: absolute; z-index: 9999; @@ -121,7 +119,6 @@ } /* 箭头 */ - .tooltip-content::after { content: ''; bottom: 100%; /* 箭头在头部 */ @@ -147,7 +144,7 @@ } .doc-form-label{ margin-left: 10px; - margin-right: 10px; + /*margin-right: 10px;*/ } /* 文档浏览页 */ body, html { diff --git a/static/xml-sitemap-feed/styles/sitemap-index.xsl b/static/xml-sitemap-feed/styles/sitemap-index.xsl new file mode 100644 index 0000000..27bf2bd --- /dev/null +++ b/static/xml-sitemap-feed/styles/sitemap-index.xsl @@ -0,0 +1,47 @@ + + + + + + + XML站点地图源 - 索引 + + + + +

XML站点地图源 - 索引

+ +
+ + + + + + + + + + high + + + + + +
#XML 站点地图上次修改时间
+ + ()
+
+ + + +
+
diff --git a/static/xml-sitemap-feed/styles/sitemap.xsl b/static/xml-sitemap-feed/styles/sitemap.xsl new file mode 100644 index 0000000..a4c7816 --- /dev/null +++ b/static/xml-sitemap-feed/styles/sitemap.xsl @@ -0,0 +1,50 @@ + + + + + + + XML站点地图源 + + + + +

XML站点地图源

+ +
+ + + + + + + + + + + + high + + + + + + + +
#URL# ImagesPriorityLast Modified
()
+
+ + + +
+
diff --git a/template/app_admin/admin_base.html b/template/app_admin/admin_base.html index bb54703..647fecd 100644 --- a/template/app_admin/admin_base.html +++ b/template/app_admin/admin_base.html @@ -67,7 +67,12 @@
-
{% block content %}{% endblock %}
+
+ {% if debug %} +
当前站点处于Debug调试模式
+ {% endif %} + {% block content %}{% endblock %} +
+ + + + + + + +
diff --git a/template/app_doc/create_base.html b/template/app_doc/create_base.html index 8244ec1..4cdf9b6 100644 --- a/template/app_doc/create_base.html +++ b/template/app_doc/create_base.html @@ -92,7 +92,7 @@ cm.replaceSelection('' + selection + ""); // 如果当前没有选中的文本,将光标移到要输入的位置 if(selection === "") { - cm.setCursor(cursor.line, cursor.ch + 1); + cm.setCursor(cursor.line, cursor.ch + 29); } // this == 当前editormd实例 //console.log("testIcon =>", this, cm, icon, cursor, selection); diff --git a/template/app_doc/create_doc.html b/template/app_doc/create_doc.html index cc21a37..eb0cf79 100644 --- a/template/app_doc/create_doc.html +++ b/template/app_doc/create_doc.html @@ -7,16 +7,16 @@
-
- +
+
-

+
- +
-
- +
+
-
-
+
@@ -81,6 +88,7 @@ {% block custom_script %}