Skip to content
This repository was archived by the owner on May 23, 2020. It is now read-only.

Commit c759c7d

Browse files
committed
Released v.3.6
1 parent 95d243c commit c759c7d

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

blog/templates/blog/blog_detail.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
{% block content %}
3333
<div class="post" id="printable">
34-
<h2><a href="{% url "detail_post_page" slug=object.slug %}">{{ object.title }}</a></h2>
34+
<h2><a href="{% url "detail_post_page" slug=object.slug %}">{{ object.title }}</a>{% if object.publish == False %} <i class="badge">DRAF</i>{% endif %}</h2>
3535
<div class="meta">
3636
By: <a href="{% url 'author_posts_page' username=object.author.user.username %}" style="text-transform:uppercase">{{ object.author }}</a> &#9679;
3737
at {{ object.created }} &#9679; and modified at {{ object.modified }}<br />
@@ -120,4 +120,14 @@ <h3 class="panel-title">Related Posts</h3>
120120
{% disqus_show_comments %}
121121
<!-- disqus_dev -->
122122
</div>
123+
124+
<link rel="stylesheet" href="{% static 'assets/css/highlight.css' %}">
125+
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/highlight.min.js"></script>
126+
<script type="text/javascript">
127+
$(document).ready(function() {
128+
$('pre').each(function(i, block) {
129+
hljs.highlightBlock(block);
130+
});
131+
});
132+
</script>
123133
{% endblock %}

blog/views.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,17 @@ def visitorCounter(self):
9090
pass
9191
return Visitor.objects.filter(post=self.object).count()
9292

93+
def dispatch(self, request, *args, **kwargs):
94+
obj = self.get_object()
95+
if obj.publish == False and \
96+
request.user.is_anonymous() or \
97+
request.user != obj.author.user:
98+
return redirect('homepage')
99+
else:
100+
return super(DetailPostView, self).dispatch(
101+
request, *args, **kwargs
102+
)
103+
93104
def get_context_data(self, **kwargs):
94105
context_data = super(DetailPostView, self).get_context_data(**kwargs)
95106
related_posts = Post.objects.filter(

static/assets/css/highlight.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.hljs{display:block;background:white;padding:0.5em;color:#333333;overflow-x:auto}
2+
.hljs-comment,.hljs-meta{color:#969896}
3+
.hljs-string,.hljs-variable,.hljs-template-variable,.hljs-strong,.hljs-emphasis,.hljs-quote{color:#df5000}
4+
.hljs-keyword,.hljs-selector-tag,.hljs-type{color:#a71d5d}
5+
.hljs-literal,.hljs-symbol,.hljs-bullet,.hljs-attribute{color:#0086b3}
6+
.hljs-section,.hljs-name{color:#63a35c}
7+
.hljs-tag{color:#333333}
8+
.hljs-title,.hljs-attr,.hljs-selector-id,.hljs-selector-class,.hljs-selector-attr,.hljs-selector-pseudo{color:#3C5BDA}
9+
.hljs-addition{color:#55a532;background-color:#eaffea}
10+
.hljs-deletion{color:#bd2c00;background-color:#ffecec}
11+
.hljs-link{text-decoration:underline}

0 commit comments

Comments
 (0)