部分界面样式修改

车亮亮 9 years ago
parent 97c7bb65af
commit 672b3a52da

@ -65,6 +65,7 @@ TEMPLATES = [
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'blog.context_processors.seo_processor',
],
},
},
@ -129,5 +130,5 @@ TIME_FORMAT = '%Y-%m-%d %H:%M:%S'
DATE_TIME_FORMAT = '%Y-%m-%d %H:%M:%S'
SITE_NAME = 'Django Blog'
SITE_DESCRIPTION = 'The Simple blog creating by Django and Bootstrap.'
SITE_DESCRIPTION = '大巧无工,重剑无锋.'
ARTICLE_SUB_LENGTH = 300

@ -0,0 +1,23 @@
#!/usr/bin/env python
# encoding: utf-8
"""
@version: ??
@author: liangliangyy
@license: MIT Licence
@contact: liangliangyy@gmail.com
@site: https://www.lylinux.org/
@software: PyCharm
@file: context_processors.py
@time: 2016/11/6 下午4:23
"""
from .models import Category, Article, Tag
from django.conf import settings
def seo_processor(requests):
return {
'SITE_NAME': settings.SITE_NAME,
'SITE_DESCRIPTION': settings.SITE_DESCRIPTION
}

@ -36,7 +36,7 @@ class Article(models.Model):
def getCategoryNameTree(self):
names = []
names.append((settings.SITE_NAME, 'http://127.0.0.1:8000'))
def parse(category):
names.append((category.name,category.get_absolute_url()))

@ -3,8 +3,8 @@
*/
body {
font-family: Georgia, "Times New Roman", Times, serif;
color: #555;
font-family: Georgia, "Times New Roman", Times, serif;
color: #555;
}
h1, .h1,
@ -13,154 +13,164 @@ h3, .h3,
h4, .h4,
h5, .h5,
h6, .h6 {
margin-top: 0;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: normal;
color: #333;
margin-top: 0;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: normal;
color: #333;
}
/*
* Override Bootstrap's default container.
*/
@media (min-width: 1200px) {
.container {
width: 970px;
}
.container {
width: 970px;
}
}
/*
* Masthead for nav
*/
.blog-masthead {
background-color: #428bca;
-webkit-box-shadow: inset 0 -2px 5px rgba(0,0,0,.1);
box-shadow: inset 0 -2px 5px rgba(0,0,0,.1);
background-color: #428bca;
-webkit-box-shadow: inset 0 -2px 5px rgba(0, 0, 0, .1);
box-shadow: inset 0 -2px 5px rgba(0, 0, 0, .1);
}
/* Nav links */
.blog-nav-item {
position: relative;
display: inline-block;
padding: 10px;
font-weight: 500;
color: #cdddeb;
position: relative;
display: inline-block;
padding: 10px;
font-weight: 500;
color: #cdddeb;
}
.blog-nav-item:hover,
.blog-nav-item:focus {
color: #fff;
text-decoration: none;
color: #fff;
text-decoration: none;
}
/* Active state gets a caret at the bottom */
.blog-nav .active {
color: #fff;
color: #fff;
}
.blog-nav .active:after {
position: absolute;
bottom: 0;
left: 50%;
width: 0;
height: 0;
margin-left: -5px;
vertical-align: middle;
content: " ";
border-right: 5px solid transparent;
border-bottom: 5px solid;
border-left: 5px solid transparent;
position: absolute;
bottom: 0;
left: 50%;
width: 0;
height: 0;
margin-left: -5px;
vertical-align: middle;
content: " ";
border-right: 5px solid transparent;
border-bottom: 5px solid;
border-left: 5px solid transparent;
}
/*
* Blog name and description
*/
.blog-header {
padding-top: 20px;
padding-bottom: 20px;
padding-top: 20px;
padding-bottom: 20px;
}
.blog-title {
margin-top: 30px;
margin-bottom: 0;
font-size: 60px;
font-weight: normal;
margin-top: 30px;
margin-bottom: 0;
font-size: 60px;
font-weight: normal;
}
.blog-description {
font-size: 20px;
color: #999;
font-size: 20px;
color: #999;
}
/*
* Main column and sidebar layout
*/
.blog-main {
font-size: 18px;
line-height: 1.5;
font-size: 18px;
line-height: 1.5;
}
/* Sidebar modules for boxing content */
.sidebar-module {
padding: 15px;
margin: 0 -15px 15px;
padding: 15px;
margin: 0 -15px 15px;
}
.sidebar-module-inset {
padding: 15px;
background-color: #f5f5f5;
border-radius: 4px;
padding: 15px;
background-color: #f5f5f5;
border-radius: 4px;
}
.sidebar-module-inset p:last-child,
.sidebar-module-inset ul:last-child,
.sidebar-module-inset ol:last-child {
margin-bottom: 0;
margin-bottom: 0;
}
/* Pagination */
.pager {
margin-bottom: 60px;
text-align: left;
margin-bottom: 60px;
text-align: left;
}
.pager > li > a {
width: 140px;
padding: 10px 20px;
text-align: center;
border-radius: 30px;
width: 140px;
padding: 10px 20px;
text-align: center;
border-radius: 30px;
}
/*
* Blog posts
*/
.blog-post {
margin-bottom: 60px;
margin-bottom: 60px;
}
.blog-post-title {
margin-bottom: 5px;
font-size: 40px;
margin-bottom: 5px;
font-size: 40px;
}
.blog-post-meta {
margin-bottom: 20px;
color: #999;
margin-bottom: 20px;
color: #999;
}
/*
* Footer
*/
.blog-footer {
padding: 40px 0;
color: #999;
text-align: center;
background-color: #f9f9f9;
border-top: 1px solid #e5e5e5;
padding: 40px 0;
color: #999;
text-align: center;
background-color: #f9f9f9;
border-top: 1px solid #e5e5e5;
}
.blog-footer p:last-child {
margin-bottom: 0;
margin-bottom: 0;
}
.blog-read-more {
margin-top: 40px;
margin-bottom: auto;
color: #00CCFF;
border-bottom: 4px double #ededed;
}

@ -43,6 +43,9 @@ def custom_markdown(content):
@register.inclusion_tag('categorytree.html')
def parseCategoryName(article):
names = article.getCategoryNameTree()
names.append((settings.SITE_NAME, 'http://127.0.0.1:8000'))
names = names[::-1]
print(names)
return {'names': names}

@ -36,11 +36,6 @@ class IndexView(ArticleListView):
return article_list
def get_context_data(self, **kwargs):
# 增加额外的数据,这里返回一个文章分类,以字典的形式
kwargs['category_list'] = Category.objects.all().order_by('name')
return super(IndexView, self).get_context_data(**kwargs)
class ArticleDetailView(DetailView):
template_name = 'articledetail.html'
@ -67,11 +62,20 @@ class CategoryDetailView(ArticleListView):
article_list = Article.objects.filter(category__name=categoryname, status='p')
return article_list
def get_context_data(self, **kwargs):
# 增加额外的数据,这里返回一个文章分类,以字典的形式
kwargs['page_description'] = self.page_description
return super(CategoryDetailView, self).get_context_data(**kwargs)
class AuthorDetailView(ArticleListView):
def get_queryset(self):
author_name = self.kwargs['author_name']
self.page_description = '分类目录归档: %s ' % author_name
self.page_description = '作者文章归档: %s ' % author_name
article_list = Article.objects.filter(author__username=author_name)
return article_list
def get_context_data(self, **kwargs):
kwargs['page_description'] = self.page_description
return super(AuthorDetailView, self).get_context_data(**kwargs)

@ -51,10 +51,12 @@
<div class="blog-header">
<h1 class="blog-title">
<a href="{% url 'blog:index' %}">
The Django Blog
{{ SITE_NAME }}
</a>
</h1>
<p class="lead blog-description">The Simple blog creating by Django and Bootstrap.</p>
<p class="lead blog-description">
{{ SITE_DESCRIPTION }}
</p>
</div>
{% block content %}
{% endblock %}

@ -7,6 +7,7 @@
<div class="col-sm-8 blog-main">
{% for article in article_list %}
<div class="blog-post">
<a href="{{ article.get_absolute_url }}" class="blog-post-title">{{ article.title }}</a>
@ -20,6 +21,11 @@
by <a href="{{ article.author.get_absolute_url }}">{{ article.author }}</a></p>
{{ article.body|custom_markdown }}
<p class="blog-read-more">
<a href="{{ article.get_absolute_url }}">
Read more
</a>
</p>
</div><!-- /.blog-post -->
{% endfor %}

Loading…
Cancel
Save