修复文章页面线上错误bug

车亮亮 9 years ago
parent b504766519
commit 29714c9278

@ -18,7 +18,6 @@ from blog.models import Article
from django.conf import settings
from django.utils.feedgenerator import Rss201rev2Feed
from DjangoBlog.common_markdown import common_markdown
from django.utils.safestring import mark_safe
from django.contrib.auth import get_user_model
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
@ -45,7 +44,7 @@ class DjangoBlogFeed(Feed):
return item.title
def item_description(self, item):
return mark_safe(common_markdown.get_markdown(item.body))
return common_markdown.get_markdown(item.body)
def feed_copyright(self):
# print(Site.objects.get_current().name)

@ -5,6 +5,7 @@ from django.conf import settings
from uuslug import slugify
from DjangoBlog.spider_notify import sipder_notify
class Article(models.Model):
"""文章"""
STATUS_CHOICES = (
@ -71,11 +72,11 @@ class Article(models.Model):
if not self.slug or self.slug == 'no-slug' or not self.id:
# Only set the slug when the object is created.
self.slug = slugify(self.title)
try:
notify = sipder_notify()
notify.notify(self.get_absolute_url())
except Exception as e:
print(e)
try:
notify = sipder_notify()
notify.notify(self.get_absolute_url())
except Exception as e:
print(e)
super().save(*args, **kwargs)
def viewed(self):

@ -55,7 +55,7 @@ class ArticleListView(ListView):
class IndexView(ArticleListView):
def get_queryset(self):
article_list = Article.objects.filter(status='p')
article_list = Article.objects.filter(type='a',status='p')
# for article in article_list:
# article.body = article.body[0:settings.ARTICLE_SUB_LENGTH]
@ -228,7 +228,7 @@ def fileupload(request):
@login_required
def refresh_memcache(request):
try:
result = os.popen(' service memcache restart ').readline()
result = os.popen(' service memcached restart ').readline()
return HttpResponse(result)
except Exception as e:
return HttpResponse(e);

@ -22,20 +22,21 @@
<div id="content" role="main">
{% load_article_detail article False user %}
<nav class="nav-single">
<h3 class="assistive-text">文章导航</h3>
{% if next_article %}
<span class="nav-previous"><a href="{{ next_article.get_absolute_url }}" rel="prev"><span
class="meta-nav">&larr;</span> {{ next_article.title }}</a></span>
{% endif %}
{% if prev_article %}
<span class="nav-next"><a href="{{ prev_article.get_absolute_url }}"
rel="next">{{ prev_article.title }} <span
class="meta-nav">&rarr;</span></a></span>
{% endif %}
</nav><!-- .nav-single -->
{% if article.type == 'a' %}
<nav class="nav-single">
<h3 class="assistive-text">文章导航</h3>
{% if next_article %}
<span class="nav-previous"><a href="{{ next_article.get_absolute_url }}" rel="prev"><span
class="meta-nav">&larr;</span> {{ next_article.title }}</a></span>
{% endif %}
{% if prev_article %}
<span class="nav-next"><a href="{{ prev_article.get_absolute_url }}"
rel="next">{{ prev_article.title }} <span
class="meta-nav">&rarr;</span></a></span>
{% endif %}
</nav><!-- .nav-single -->
{% endif %}
</div><!-- #content -->
{% if article.comment_status == "o" %}

@ -1,7 +1,7 @@
{% load blog_tags %}
<article id="post-{{ article.pk }} "
class="post-3815 post type-post status-publish format-standard hentry category-python tag-python"
itemscope itemtype="http://schema.org/Article">
class="post-3815 post type-post status-publish format-standard hentry"
itemscope itemtype="http://schema.org/Article">
<header class="entry-header">
<h1 class="entry-title" itemprop="name">
@ -30,8 +30,10 @@
</div>
</div><!-- .comments-link -->
<br/>
{% if not isindex %}
{% load_breadcrumb article %}
{% if article.type == 'a' %}
{% if not isindex %}
{% load_breadcrumb article %}
{% endif %}
{% endif %}
</header><!-- .entry-header -->
@ -45,5 +47,7 @@
{% endif %}
</div><!-- .entry-content -->
{% load_article_metas article user %}
</article><!-- #post -->

@ -8,18 +8,20 @@
datetime="{{ article.created_time }}">
{% datetimeformat article.created_time %}</time>
</a>
属于<a href="{{ article.category.get_absolute_url }}" rel="category tag">{{ article.category.name }}</a>分类
{% if article.tags.all %}
被贴了
{% if article.type == 'a' %}
属于<a href="{{ article.category.get_absolute_url }}" rel="category tag">{{ article.category.name }}</a>分类
{% if article.tags.all %}
被贴了
{% for t in article.tags.all %}
<a href="{{ t.get_absolute_url }}" rel="tag">{{ t.name }}</a>
{% if t != article.tags.all.last %}
{% endif %}
{% endfor %}
{% for t in article.tags.all %}
<a href="{{ t.get_absolute_url }}" rel="tag">{{ t.name }}</a>
{% if t != article.tags.all.last %}
{% endif %}
{% endfor %}
标签
标签
{% endif %}
{% endif %}
<span class="by-author">作者是<span class="author vcard"><a class="url fn n"
href="{{ article.author.get_absolute_url }}"

@ -1,7 +1,7 @@
<footer id="colophon" role="contentinfo">
<div class="site-info">
Copyright&copy;&nbsp;2017&nbsp;
<a href="{{ SITE_BASE_URL }}" target="blank">逝去日子的博客</a>
<a href="{{ SITE_BASE_URL }}" target="blank">{{ SITE_NAME }}</a>
&nbsp;|&nbsp;
<a href="{{ SITE_BASE_URL }}sitemap.xml" title="SiteMap" target="_blank">
SiteMap

Loading…
Cancel
Save