Skip to content

Commit 29714c9

Browse files
committed
修复文章页面线上错误bug
1 parent b504766 commit 29714c9

7 files changed

Lines changed: 45 additions & 38 deletions

File tree

DjangoBlog/feeds.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from django.conf import settings
1919
from django.utils.feedgenerator import Rss201rev2Feed
2020
from DjangoBlog.common_markdown import common_markdown
21-
from django.utils.safestring import mark_safe
2221
from django.contrib.auth import get_user_model
2322
from django.contrib.auth.models import User
2423
from django.contrib.sites.models import Site
@@ -45,7 +44,7 @@ def item_title(self, item):
4544
return item.title
4645

4746
def item_description(self, item):
48-
return mark_safe(common_markdown.get_markdown(item.body))
47+
return common_markdown.get_markdown(item.body)
4948

5049
def feed_copyright(self):
5150
# print(Site.objects.get_current().name)

blog/models.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from uuslug import slugify
66
from DjangoBlog.spider_notify import sipder_notify
77

8+
89
class Article(models.Model):
910
"""文章"""
1011
STATUS_CHOICES = (
@@ -71,11 +72,11 @@ def save(self, *args, **kwargs):
7172
if not self.slug or self.slug == 'no-slug' or not self.id:
7273
# Only set the slug when the object is created.
7374
self.slug = slugify(self.title)
74-
try:
75-
notify = sipder_notify()
76-
notify.notify(self.get_absolute_url())
77-
except Exception as e:
78-
print(e)
75+
try:
76+
notify = sipder_notify()
77+
notify.notify(self.get_absolute_url())
78+
except Exception as e:
79+
print(e)
7980
super().save(*args, **kwargs)
8081

8182
def viewed(self):

blog/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class ArticleListView(ListView):
5555

5656
class IndexView(ArticleListView):
5757
def get_queryset(self):
58-
article_list = Article.objects.filter(status='p')
58+
article_list = Article.objects.filter(type='a',status='p')
5959

6060
# for article in article_list:
6161
# article.body = article.body[0:settings.ARTICLE_SUB_LENGTH]
@@ -228,7 +228,7 @@ def fileupload(request):
228228
@login_required
229229
def refresh_memcache(request):
230230
try:
231-
result = os.popen(' service memcache restart ').readline()
231+
result = os.popen(' service memcached restart ').readline()
232232
return HttpResponse(result)
233233
except Exception as e:
234234
return HttpResponse(e);

templates/blog/article_detail.html

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,21 @@
2222
<div id="content" role="main">
2323
{% load_article_detail article False user %}
2424

25-
26-
<nav class="nav-single">
27-
<h3 class="assistive-text">文章导航</h3>
28-
{% if next_article %}
29-
30-
<span class="nav-previous"><a href="{{ next_article.get_absolute_url }}" rel="prev"><span
31-
class="meta-nav">&larr;</span> {{ next_article.title }}</a></span>
32-
{% endif %}
33-
{% if prev_article %}
34-
<span class="nav-next"><a href="{{ prev_article.get_absolute_url }}"
35-
rel="next">{{ prev_article.title }} <span
36-
class="meta-nav">&rarr;</span></a></span>
37-
{% endif %}
38-
</nav><!-- .nav-single -->
25+
{% if article.type == 'a' %}
26+
<nav class="nav-single">
27+
<h3 class="assistive-text">文章导航</h3>
28+
{% if next_article %}
29+
30+
<span class="nav-previous"><a href="{{ next_article.get_absolute_url }}" rel="prev"><span
31+
class="meta-nav">&larr;</span> {{ next_article.title }}</a></span>
32+
{% endif %}
33+
{% if prev_article %}
34+
<span class="nav-next"><a href="{{ prev_article.get_absolute_url }}"
35+
rel="next">{{ prev_article.title }} <span
36+
class="meta-nav">&rarr;</span></a></span>
37+
{% endif %}
38+
</nav><!-- .nav-single -->
39+
{% endif %}
3940

4041
</div><!-- #content -->
4142
{% if article.comment_status == "o" %}

templates/blog/tags/article_info.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% load blog_tags %}
22
<article id="post-{{ article.pk }} "
3-
class="post-3815 post type-post status-publish format-standard hentry category-python tag-python"
4-
itemscope itemtype="http://schema.org/Article">
3+
class="post-3815 post type-post status-publish format-standard hentry"
4+
itemscope itemtype="http://schema.org/Article">
55
<header class="entry-header">
66

77
<h1 class="entry-title" itemprop="name">
@@ -30,8 +30,10 @@ <h1 class="entry-title" itemprop="name">
3030
</div>
3131
</div><!-- .comments-link -->
3232
<br/>
33-
{% if not isindex %}
34-
{% load_breadcrumb article %}
33+
{% if article.type == 'a' %}
34+
{% if not isindex %}
35+
{% load_breadcrumb article %}
36+
{% endif %}
3537
{% endif %}
3638
</header><!-- .entry-header -->
3739

@@ -45,5 +47,7 @@ <h1 class="entry-title" itemprop="name">
4547
{% endif %}
4648

4749
</div><!-- .entry-content -->
50+
4851
{% load_article_metas article user %}
52+
4953
</article><!-- #post -->

templates/blog/tags/article_meta_info.html

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@
88
datetime="{{ article.created_time }}">
99
{% datetimeformat article.created_time %}</time>
1010
</a>
11-
。属于<a href="{{ article.category.get_absolute_url }}" rel="category tag">{{ article.category.name }}</a>分类,
12-
{% if article.tags.all %}
13-
被贴了
11+
{% if article.type == 'a' %}
12+
。属于<a href="{{ article.category.get_absolute_url }}" rel="category tag">{{ article.category.name }}</a>分类,
13+
{% if article.tags.all %}
14+
被贴了
1415

15-
{% for t in article.tags.all %}
16-
<a href="{{ t.get_absolute_url }}" rel="tag">{{ t.name }}</a>
17-
{% if t != article.tags.all.last %}
18-
19-
{% endif %}
20-
{% endfor %}
16+
{% for t in article.tags.all %}
17+
<a href="{{ t.get_absolute_url }}" rel="tag">{{ t.name }}</a>
18+
{% if t != article.tags.all.last %}
19+
20+
{% endif %}
21+
{% endfor %}
2122

22-
标签。
23+
标签。
24+
{% endif %}
2325
{% endif %}
2426
<span class="by-author">作者是<span class="author vcard"><a class="url fn n"
2527
href="{{ article.author.get_absolute_url }}"

templates/share_layout/footer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<footer id="colophon" role="contentinfo">
22
<div class="site-info">
33
Copyright&copy;&nbsp;2017&nbsp;
4-
<a href="{{ SITE_BASE_URL }}" target="blank">逝去日子的博客</a>
4+
<a href="{{ SITE_BASE_URL }}" target="blank">{{ SITE_NAME }}</a>
55
&nbsp;|&nbsp;
66
<a href="{{ SITE_BASE_URL }}sitemap.xml" title="SiteMap" target="_blank">
77
SiteMap

0 commit comments

Comments
 (0)