aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobby <[email protected]>2022-09-20 20:20:21 -0400
committerBobby <[email protected]>2022-09-20 20:20:21 -0400
commit2dc46b1911f65fdba0df4b9f541ed77f2d713c3e (patch)
tree7caac43d0dd0000c485786134c177c880ca07f28
parent35a023cb2b6a9704c1065c206a3916d6a7225e28 (diff)
downloadthatcomputerscientist-2dc46b1911f65fdba0df4b9f541ed77f2d713c3e.tar.xz
thatcomputerscientist-2dc46b1911f65fdba0df4b9f541ed77f2d713c3e.zip
Aesthetic changes
-rw-r--r--blog/context_processors.py10
-rw-r--r--static/css/main.css6
-rw-r--r--templates/blog/partials/base.html25
-rw-r--r--templates/blog/partials/sb2.html37
-rw-r--r--thatcomputerscientist/settings.py2
5 files changed, 72 insertions, 8 deletions
diff --git a/blog/context_processors.py b/blog/context_processors.py
index c6031f3f..605fc0c5 100644
--- a/blog/context_processors.py
+++ b/blog/context_processors.py
@@ -1,5 +1,13 @@
-from .models import Post
+from .models import Post, Category
def recent_posts(request):
recent_posts = Post.objects.filter(is_public=True).order_by('-date')[:5]
return {'recent_posts': recent_posts}
+
+def categories(request):
+ categories = Category.objects.all()
+ return {'categories': categories}
+
+def archives(request):
+ archives = Post.objects.filter(is_public=True).dates('date', 'month', order='DESC')
+ return {'archives': archives}
diff --git a/static/css/main.css b/static/css/main.css
index 86a2b9c8..3fd33257 100644
--- a/static/css/main.css
+++ b/static/css/main.css
@@ -30,10 +30,6 @@ body {
background-color: #bad9ff;
}
-.sidebar-bg-light-red {
- background-color: #fff6f6;
-}
-
.sidebar-border {
border: 1px solid #191919;
}
@@ -190,7 +186,7 @@ nav > ul > li {
/* Float to the top right corner */
position: absolute;
top: 2.5em;
- right: 3em;
+ right: 23.85rem;
}
.table {
diff --git a/templates/blog/partials/base.html b/templates/blog/partials/base.html
index 40fee5b3..588f7302 100644
--- a/templates/blog/partials/base.html
+++ b/templates/blog/partials/base.html
@@ -22,8 +22,9 @@
{% block content %}
{% endblock %}
</div>
- <div class="sidebar sidebar-bg-light-red sidebar-lg">
- <h2>Recent Posts</h2>
+ <div class="sidebar sidebar-lg" style="border-left: dotted 1px black;">
+ <h3 style="margin-bottom: 0px;"><em>Recent Posts</em></h3>
+ <hr>
<ul>
{% for post in recent_posts %}
<li>
@@ -32,6 +33,26 @@
</li>
{% endfor %}
</ul>
+ <br>
+ <h3 style="margin-bottom: 0px;"><em>Archives</em></h3>
+ <hr>
+ <ul>
+ {% for archive in archives %}
+ <li>
+ <a href="#">{{ archive | date:"F Y" }}</a>
+ </li>
+ {% endfor %}
+ </ul>
+ <br>
+ <h3 style="margin-bottom: 0px;"><em>Categories</em></h3>
+ <hr>
+ <ul>
+ {% for category in categories %}
+ <li>
+ <a href="#">{{ category.name }}</a>
+ </li>
+ {% endfor %}
+ </ul>
</div>
</body>
</html>
diff --git a/templates/blog/partials/sb2.html b/templates/blog/partials/sb2.html
new file mode 100644
index 00000000..c3aa04f6
--- /dev/null
+++ b/templates/blog/partials/sb2.html
@@ -0,0 +1,37 @@
+<div class="content">
+ {% block content %}
+ {% endblock %}
+ </div>
+ {% if not request.path.includes('blog-admin') %}
+ <div class="sidebar sidebar-bg-light-red sidebar-lg">
+ <h3>Recent Posts</h3>
+ <hr>
+ <ul>
+ {% for post in recent_posts %}
+ <li>
+ <a href="{% url 'blog:post' post.slug %}">{{ post.title }}</a>
+ by <em><a href="#">{{ post.author.username }}</a></em> on {{ post.date|date:"F j, Y" }}.
+ </li>
+ {% endfor %}
+ </ul>
+ <br>
+ <h3>Archives</h3>
+ <hr>
+ <ul>
+ {% for archive in archives %}
+ <li>
+ <a href="#">{{ archive | date:"F Y" }}</a>
+ </li>
+ {% endfor %}
+ </ul>
+ <br>
+ <h3>Categories</h3>
+ <hr>
+ <ul>
+ {% for category in categories %}
+ <li>
+ <a href="#">{{ category.name }}</a>
+ </li>
+ {% endfor %}
+ </ul>
+ </div> \ No newline at end of file
diff --git a/thatcomputerscientist/settings.py b/thatcomputerscientist/settings.py
index 27582970..68ce13bc 100644
--- a/thatcomputerscientist/settings.py
+++ b/thatcomputerscientist/settings.py
@@ -89,6 +89,8 @@ TEMPLATES = [
]
TEMPLATES[0]['OPTIONS']['context_processors'].append('blog.context_processors.recent_posts')
+TEMPLATES[0]['OPTIONS']['context_processors'].append('blog.context_processors.categories')
+TEMPLATES[0]['OPTIONS']['context_processors'].append('blog.context_processors.archives')
WSGI_APPLICATION = 'thatcomputerscientist.wsgi.application'