Merge pull request #78 from liangliangyy/dev

增加文章归档页面
sh_branch
车亮亮 8 years ago committed by GitHub
commit 72a71c1847
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -663,12 +663,22 @@ section[role="banner"] {
margin-bottom: 1.714285714rem;
}
.widget-area .textwidget ul {
.widget-area .textwidget ul,
.widget-area .textwidget ol {
list-style: disc outside;
margin: 0 0 24px;
margin: 0 0 1.714285714rem;
}
.widget-area .textwidget li > ul,
.widget-area .textwidget li > ol {
margin-bottom: 0;
}
.widget-area .textwidget ol {
list-style: decimal;
}
.widget-area .textwidget li {
margin-left: 36px;
margin-left: 2.571428571rem;
@ -923,7 +933,6 @@ article.sticky .featured-post {
font-size: 12px;
font-size: 0.857142857rem;
line-height: 2;
background-color: rgba(0, 0, 0, 0.04);
}
.entry-content pre,
@ -1572,6 +1581,34 @@ a.comment-edit-link:hover {
text-align: right;
}
.tagcloud ul {
list-style-type: none;
}
.tagcloud ul li {
display: inline-block;
}
.widget-area .widget.widget_tag_cloud li {
line-height: 1;
}
.template-front-page .widget-area .widget.widget_tag_cloud li {
margin: 0;
}
.widget-area .gallery-columns-2.gallery-size-full .gallery-icon img,
.widget-area .gallery-columns-3.gallery-size-full .gallery-icon img,
.widget-area .gallery-columns-4.gallery-size-full .gallery-icon img,
.widget-area .gallery-columns-5.gallery-size-full .gallery-icon img,
.widget-area .gallery-columns-6 .gallery-icon img,
.widget-area .gallery-columns-7 .gallery-icon img,
.widget-area .gallery-columns-8 .gallery-icon img,
.widget-area .gallery-columns-9 .gallery-icon img {
height: auto;
max-width: 80%;
}
/* =Plugins
----------------------------------------------- */

@ -9,6 +9,7 @@ import datetime
from accounts.models import BlogUser
from django.core.files.uploadedfile import SimpleUploadedFile
from django.conf import settings
from django.urls import reverse
import os
@ -86,6 +87,9 @@ class ArticleTest(TestCase):
s = load_articletags(article)
self.assertIsNotNone(s)
response = self.client.get(reverse('blog:archives'))
self.assertEqual(response.status_code, 200)
p = Paginator(Article.objects.all(), 2)
self.__check_pagination__(p, '', '')

@ -39,6 +39,7 @@ urlpatterns = [
path(r'tag/<slug:tag_name>.html', views.TagDetailView.as_view(), name='tag_detail'),
path(r'tag/<slug:tag_name>/<int:page>).html', views.TagDetailView.as_view(), name='tag_detail_page'),
path('archives.html', views.ArchivesView.as_view(), name='archives'),
path(r'upload', views.fileupload, name='upload'),
path(r'refresh', views.refresh_memcache, name='refresh')
]

@ -206,6 +206,20 @@ class TagDetailView(ArticleListView):
return super(TagDetailView, self).get_context_data(**kwargs)
class ArchivesView(ArticleListView):
page_type = '文章归档'
paginate_by = None
page_kwarg = None
template_name = 'blog/article_archives.html'
def get_queryset_data(self):
return Article.objects.filter(status='p').all()
def get_queryset_cache_key(self):
cache_key = 'archives'
return cache_key
@csrf_exempt
def fileupload(request):
if request.method == 'POST':

@ -1,6 +1,6 @@
appdirs==1.4.3
bottle==0.12.13
certifi==2017.11.5
certifi==2018.1.18
chardet==3.0.4
coverage==4.4.2
Django==2.0.1
@ -9,7 +9,7 @@ django-autoslug==1.9.3
django-compressor==2.2
django-debug-toolbar==1.9.1
django-haystack==2.6.1
django-ipware==1.1.6
django-ipware==2.0.1
django-pagedown==1.0.4
django-uuslug==1.1.8
idna==2.6
@ -17,7 +17,7 @@ jieba==0.39
jsonpickle==0.9.5
markdown2==2.3.5
mistune==0.8.3
olefile==0.44
olefile==0.45.1
packaging==16.8
Pillow==5.0.0
Pygments==2.2.0

@ -0,0 +1,59 @@
{% extends 'share_layout/base.html' %}
{% load blog_tags %}
{% load cache %}
{% block header %}
<title>文章归档 | {{ SITE_DESCRIPTION }}</title>
<meta name="description" content="{{ SITE_SEO_DESCRIPTION }}"/>
<meta name="keywords" content="{{ SITE_KEYWORDS }}"/>
<meta property="og:type" content="blog"/>
<meta property="og:title" content="{{ SITE_NAME }}"/>
<meta property="og:description" content="{{ SITE_DESCRIPTION }}"/>
<meta property="og:url" content="{{ SITE_BASE_URL }}"/>
<meta property="og:site_name" content="{{ SITE_NAME }}"/>
{% endblock %}
{% block content %}
<div id="primary" class="site-content">
<div id="content" role="main">
<header class="archive-header">
<p class="archive-title">文章归档</p>
</header><!-- .archive-header -->
<div class="entry-content">
{% regroup article_list by created_time.year as year_post_group %}
<ul>
{% for year in year_post_group %}
<li>{{ year.grouper }}
{% regroup year.list by created_time.month as month_post_group %}
<ul>
{% for month in month_post_group %}
<li>{{ month.grouper }}
<ul>
{% for article in month.list %}
<li><a href="{{ article.get_absolute_url }}">{{ article.title }}</a>
</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
</div>
</div><!-- #content -->
</div><!-- #primary -->
{% endblock %}
{% block sidebar %}
{% load_sidebar user %}
{% endblock %}

@ -22,7 +22,7 @@
{% if page_type and tag_name %}
<header class="archive-header">
<h1 class="archive-title">{{ page_type }}<span>{{ tag_name }}</span></h1>
<p class="archive-title">{{ page_type }}<span>{{ tag_name }}</span></p>
</header><!-- .archive-header -->
{% endif %}

@ -21,6 +21,10 @@
</li>
{% endfor %}
{% endif %}
<li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children">
<a href="{% url "blog:archives" %}">文章归档</a>
</li>
</ul>
</div>
</nav><!-- #site-navigation -->

@ -1,6 +1,6 @@
appdirs==1.4.3
bottle==0.12.13
certifi==2017.11.5
certifi==2018.1.18
chardet==3.0.4
coverage==4.4.2
Django==2.0.1
@ -9,7 +9,7 @@ django-autoslug==1.9.3
django-compressor==2.2
django-debug-toolbar==1.9.1
django-haystack==2.6.1
django-ipware==1.1.6
django-ipware==2.0.1
django-pagedown==1.0.4
django-uuslug==1.1.8
idna==2.6
@ -17,7 +17,7 @@ jieba==0.39
jsonpickle==0.9.5
markdown2==2.3.5
mistune==0.8.3
olefile==0.44
olefile==0.45.1
packaging==16.8
Pillow==5.0.0
Pygments==2.2.0

Loading…
Cancel
Save