Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
newpanjing committed Aug 24, 2019
1 parent d02ec17 commit 17e9a5e
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 5 deletions.
10 changes: 7 additions & 3 deletions article/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,16 @@ def save_model(self, request, obj, form, change):
@admin.register(Article)
class ArticleAdmin(admin.ModelAdmin):
list_display = ('id', 'sid', 'title_url', 'comment_count', 'category', 'user', 'hits', 'tags', 'top', 'createDate')
list_filter = ('createDate', 'category', 'user', 'title')
list_filter = ('category', 'user')
search_fields = ('title',)
list_display_links = ('id', 'sid', 'title_url')
list_editable = ('top', 'category')
list_editable = ('top',)
list_per_page = 10

def delete_model(self, request, obj):
cache.delete(cache.CACHE_HOME_KEY)
super(ArticleAdmin, self).delete_model(request, obj)

def save_model(self, request, obj, form, change):
obj.user = request.user
subject = get_subject(obj.content)
Expand All @@ -75,7 +79,7 @@ def save_model(self, request, obj, form, change):
obj.tags = tags

# 如果没有封面就生成
if obj.image.name == '':
if obj.image.name == '' or not obj.image.name:
total = Cover.objects.count()
c = Cover.objects.all()[random.randint(0, total - 1)]
url = draw.draw(text=obj.title, url=c.image.url, font_size=c.font_size, color=c.color, x=c.x, y=c.y)
Expand Down
3 changes: 3 additions & 0 deletions myblog/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ def detail(request, id):
'markdown.extensions.toc',
])

if '[TOC]' in article.content:
article.content = article.content.replace('[TOC]', '')

sid = short_id.get_short_id()
request.session['sid'] = sid

Expand Down
3 changes: 3 additions & 0 deletions static/css/markdown.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion static/css/markdown.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions static/css/markdown.less
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,7 @@
table td:first-child, table th:first-child {
border-left: none;
}
.codehilite{
margin: 10px auto;
}
}
4 changes: 4 additions & 0 deletions static/css/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion static/css/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,12 @@ header .top {
a {
font-size: 12px;
font-weight: 400;
&:hover{
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
display: block;

&:hover {
color: @basic-color;
}
}
Expand Down

0 comments on commit 17e9a5e

Please sign in to comment.