diff --git a/apps/blog/apps.py b/apps/blog/apps.py
index 9560606..43ae0fd 100644
--- a/apps/blog/apps.py
+++ b/apps/blog/apps.py
@@ -3,3 +3,4 @@
class BlogConfig(AppConfig):
name = 'apps.blog'
+ default_auto_field = "django.db.models.BigAutoField"
diff --git a/apps/blog/views.py b/apps/blog/views.py
index 6ddabd6..afa9bd3 100644
--- a/apps/blog/views.py
+++ b/apps/blog/views.py
@@ -123,20 +123,6 @@ def get_queryset(self):
)
-class SubscriptionView(View):
- def post(self, request):
- form = EmailForm(request.POST)
- if form.is_valid():
- try:
- EmailSubscription.objects.create(
- email=form.cleaned_data['email'],
- lang=translation.get_language()
- )
- except: # duplicate email
- pass
- return HttpResponseRedirect(reverse('blog:posts'))
-
-
class SearchView(View):
def get(self, request):
lang_mapping = {'en': 'english', 'ru': 'russian'}
@@ -150,5 +136,4 @@ def get(self, request):
.filter(lang=lang, search=search_query)
.order_by('-created')
)
-
return render(request, 'blog/search.html', {'results': results, 'query': query})
diff --git a/apps/notes/apps.py b/apps/notes/apps.py
index f1d5f20..911ce17 100644
--- a/apps/notes/apps.py
+++ b/apps/notes/apps.py
@@ -3,3 +3,4 @@
class NotesConfig(AppConfig):
name = 'apps.notes'
+ default_auto_field = "django.db.models.BigAutoField"
diff --git a/notion/settings.py b/notion/settings.py
index 527d246..fc91f2d 100644
--- a/notion/settings.py
+++ b/notion/settings.py
@@ -54,6 +54,7 @@
HTML_MINIFY = True
ROOT_URLCONF = 'notion.urls'
+SITE_ID = 1
TEMPLATES = [
{
diff --git a/notion/urls.py b/notion/urls.py
index 2b0d7e7..dc77325 100644
--- a/notion/urls.py
+++ b/notion/urls.py
@@ -8,7 +8,6 @@
from django.conf import settings
from apps.blog.models import Post, Page
-from apps.blog.views import SubscriptionView
blog_dict = {
'queryset': Post.objects.filter(status=Post.PUBLISHED),
@@ -32,7 +31,6 @@
),
path('redactor/', include('redactor.urls')),
path('cpadmin/', admin.site.urls),
- path('subscribe/', SubscriptionView.as_view(), name='subscription'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += i18n_patterns(
diff --git a/requirements.txt b/requirements.txt
index 96dc7b5..dcd8ac7 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,11 +1,10 @@
-Django==3.2.18
-psycopg2==2.9.5
-django-environ==0.11.2
+Django
+psycopg2
+django-environ
https://github.com/adilkhash/django-redactor3/archive/master.zip
-redis==4.4.2
https://github.com/adilkhash/django-bootstrap-pagination/archive/master.zip
-requests==2.28.2
-Pillow==9.4.0
-django-assets==2.0
-cssmin==0.2.0
-django-htmlmin==0.11.0
+requests
+Pillow
+django-assets
+cssmin
+django-htmlmin
diff --git a/templates/base.html b/templates/base.html
index 2ad9356..b03f329 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -3,7 +3,7 @@
{% load assets %}
{% get_current_language as LANGUAGE_CODE %}
-
+
{% if not DEBUG %}
@@ -21,62 +21,97 @@
{% block title %}{% trans "Adil Khashtamov's personal blog — pragmatic programmer" %}{% endblock %}
- {% assets "css_all" %}
-
- {% endassets %}
+
+
+
+{# {% assets "css_all" %}#}
+{# #}
+{# {% endassets %}#}
-
+
{% block _head %}
{% endblock %}
-
-
-
-
-
-
+
- {% block content %}
- {% endblock %}
+
+
+ {% block content %}{% endblock %}
+
-
-
-
-
-
+
{% block _bottom %}{% endblock %}
{% if not DEBUG %}
@@ -109,9 +144,9 @@
{% endif %}
- {% assets "js_all" %}
-
- {% endassets %}
+{# {% assets "js_all" %}#}
+{# #}
+{# {% endassets %}#}
diff --git a/templates/blog/category_detail.html b/templates/blog/category_detail.html
index c51e76a..df4fa3b 100644
--- a/templates/blog/category_detail.html
+++ b/templates/blog/category_detail.html
@@ -1,25 +1,43 @@
{% extends 'base.html' %}
{% load i18n %}
-{% block title %}{{ object.title }} {% trans 'category' %}{% endblock %}
+{% load static %}
+{% block title %}{{ object.title }} {% trans "category" %}{% endblock %}
{% block content %}
-
-
-
-
{{ object.title }} {% trans 'category' %}
-
- {% regroup posts by created.year as groups %}
-
- {% for group in groups %}
-
{{ group.grouper }}
-
- {% endfor %}
+
+
{{ object.title }} {% trans "category" %}
+
+
+ {% regroup posts by created.year as year_groups %}
+ {% for year in year_groups %}
+
+
{{ year.grouper }}
+
+ {% for post in year.list %}
+
+
+
+
+
+ {{ post.created|date:"j N o" }}
+
+
•
+
+
+ {{ post.page_views }} {% trans "views" %}
+
+
+
+ {% endfor %}
+
-
+ {% endfor %}
-
{% endblock %}
diff --git a/templates/blog/index.html b/templates/blog/index.html
index f8d3c5d..81581a9 100644
--- a/templates/blog/index.html
+++ b/templates/blog/index.html
@@ -1,37 +1,84 @@
{% extends 'base.html' %}
{% load i18n %}
{% load static %}
-{% load bootstrap_pagination %}
{% load blog_tags %}
-
-{% block _head %}
- {#
#}
- {#
#}
-{% endblock %}
+{% block title %}{% trans "Blog" %}{% endblock %}
{% block content %}
-
-
-
-
- {% regroup object_list by month_year as articles %}
- {% for article in articles %}
-
- {{ article.grouper }}
-
-
- {% for post in article.list %}
- -
- {{ post.title }}
- {% if post.status == post.DRAFT %}
- ({% trans 'Draft' %}){% endif %}
-
- {% endfor %}
-
- {% endfor %}
+
{% trans "Latest Articles" %}
+
+
+
+ {% for post in object_list %}
+
+
+
+
+
+ {{ post.created|date:"j N o" }}
+
+
•
+
{{ post.category.title }}
+
•
+
+
+ {{ post.page_views }} {% trans "views" %}
+
+
+ {{ post.text|text_preview|striptags|truncatewords:50 }}
+
+ {% trans "Read more" %}
+
+ {% endfor %}
+
+
+
+ {% if is_paginated %}
+
+
+
+ {% endif %}
+
+
+ {% if popular_posts %}
+
+
{% trans "Popular Articles" %}
+
+ {% for post in popular_posts %}
+
+
+
+ {{ post.created|date:"j N o" }}
+
+
+ {% endfor %}
- {% include 'blog/_sidebar.html' %}
-
+ {% endif %}
{% endblock %}
diff --git a/templates/blog/post_detail.html b/templates/blog/post_detail.html
index 0d43042..f7435ae 100644
--- a/templates/blog/post_detail.html
+++ b/templates/blog/post_detail.html
@@ -19,72 +19,82 @@
{% endblock %}
{% block content %}
-
-
-
-
- {{ object.title }}
-
-
-
{{ object.created|date:"j N o" }},
{{ object.category.title }},
-
{{ object.page_views }} {% trans 'views' %},
-
- {% if alternate_posts %}
- {% for post in alternate_posts %}
-
-
-
- {{ post.alternate_post }}
-
-
- {% endfor %}
- {% endif %}
+
+
+
- {% if user.is_superuser %}
-
- {% trans 'Edit' %}
-
- {% if post.status == post.DRAFT %}
- {% trans 'Draft' %}
- {% endif %}
- {% endif %}
-
- {{ object.text|safe }}
-
+
+
+ {{ object.text|safe|inject_adsense_after_n_paragraph:2 }}
+
-
-
-
+
+ {% if related_articles %}
+
+
{% trans "Related Articles" %}
+
+ {% for article in related_articles %}
+
+
+
+ {{ article.created|date:"j N o" }}
+
+
+ {% endfor %}
+
+
+ {% endif %}
- {% if related_articles %}
-
-
-
{% trans 'Related posts' %}:
-
-
-
- {% endif %}
+
+ {% if lastest_notes %}
+
+
{% trans "Latest Notes" %}
+
+ {% for note in lastest_notes %}
+
+
+
+ {{ note.created|date:"j N o" }}
+
+
+ {% endfor %}
+
- {% include 'blog/_sidebar.html' %}
-
-
+ {% endif %}
+
{% endblock %}
diff --git a/templates/blog/search.html b/templates/blog/search.html
index 209cd27..d08e846 100644
--- a/templates/blog/search.html
+++ b/templates/blog/search.html
@@ -9,26 +9,46 @@
{% endblock %}
{% block content %}
-
-
-
- {% if not results %}
-
{% trans 'No articles found' %}
- {% else %}
-
{% trans 'Articles found' %}: {{ results|length }}
- {% for post in results %}
-
-
-
-
- {% endfor %}
- {% endif %}
+
+
+ {% blocktrans %}Results for «{{ query }}»{% endblocktrans %}
+
+
+ {% if not results %}
+
{% trans "No articles found" %}
+ {% else %}
+
{% trans "Articles found" %}: {{ results|length }}
+
+
+ {% for post in results %}
+
+
+
+
+
+ {{ post.created|date:"j N o" }}
+
+
•
+
{{ post.category.title }}
+
•
+
+
+ {{ post.page_views }} {% trans "views" %}
+
+
+
+ {{ post.text|text_preview|striptags|truncatewords:50 }}
+
+
+ {% endfor %}
-
+ {% endif %}
{% endblock %}
diff --git a/templates/notes/note_detail.html b/templates/notes/note_detail.html
index 7aa895d..39573fd 100644
--- a/templates/notes/note_detail.html
+++ b/templates/notes/note_detail.html
@@ -8,27 +8,33 @@
{% get_current_language as LANGUAGE_CODE %}
{% block content %}
-
-
-
-
- {{ object.title }}
-
-
-
{{ object.created|date:"j N o" }},
- {% if user.is_superuser %}
-
{% trans 'Edit' %}
- {% if object.status == object.DRAFT %}
-
{% trans 'Draft' %}
- {% endif %}
- {% endif %}
-
- {{ object.text|safe }}
-
+
+
+
-
+
+
+
+ {{ object.text|safe }}
+
+
{% endblock %}
diff --git a/templates/notes/notes.html b/templates/notes/notes.html
index 80dc1a7..8ca0ad8 100644
--- a/templates/notes/notes.html
+++ b/templates/notes/notes.html
@@ -2,32 +2,34 @@
{% load i18n %}
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
-{% block title %}{% trans 'Useful notes' %}{% endblock %}
+{% block title %}{% trans "Useful notes" %}{% endblock %}
{% block content %}
-
-
-
-
{% trans 'Useful notes' %}
+
+
{% trans "Useful notes" %}
- {% regroup object_list by theme.title as groups %}
- {% for group in groups %}
-
-
-
{{ group.grouper }}
-
-
- {% for note in group.list %}
-
- {{ note.title }}
-
- {% endfor %}
-
-
- {% endfor %}
+ {% regroup object_list by theme.title as groups %}
+ {% for group in groups %}
+
+
{{ group.grouper }}
+
+ {% for note in group.list %}
+
+
+
+
+
+ {{ note.created|date:"j N o" }}
+
+
+
+ {% endfor %}
+
-
-
+ {% endfor %}
-
{% endblock %}
\ No newline at end of file