Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blog redesign #494

Draft
wants to merge 36 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ac244d8
🚚 change and refactor article urls
krmax44 Apr 18, 2024
9752b59
⚰️ remove unnecessary workaround
krmax44 Apr 18, 2024
1ad602c
💬 fix date help text regarding article url
krmax44 Apr 18, 2024
bbcda3c
🗃️ enfore uniqueness for blog articles based on year, month and slug
krmax44 Apr 18, 2024
5b1c8b7
♻️ remove unnecessary translation on some routes
krmax44 Apr 19, 2024
1f763b4
✨ add blog toolbar to all blog pages
krmax44 Apr 19, 2024
7f0be29
🗃️ make `start_publication` required
krmax44 Apr 19, 2024
df37118
🩹 fix unique constraint on blog articles, add helpful error message
krmax44 Apr 19, 2024
fbb04e9
🩹 limit img `sizes` ratio to two decimal places
krmax44 Apr 19, 2024
a678c3e
♻️ remove custom font utilities, use bootstrap ones
krmax44 Apr 22, 2024
ba49061
⚰️ remove color-contrast function
krmax44 Apr 22, 2024
4ef06bb
♻️ remove custom headline sizing, use default responsive bootstrap sizes
krmax44 Apr 22, 2024
a89008f
♻️ move "blog" styles to type/misc
krmax44 Apr 22, 2024
1c56028
🚧 switch to Inter variable font, add StixTwo serif font
krmax44 Apr 25, 2024
9ff4921
♻️ use bs5 font weight classes
krmax44 Apr 25, 2024
4a3633f
🚧 simplify blog preview items
krmax44 Apr 25, 2024
45ca553
🚧 work on blog styles
krmax44 Apr 25, 2024
b5e1eef
💄 enable tabular numbers only on tables
krmax44 May 13, 2024
bcb56ed
💄 use font weight hover effect on action link
krmax44 May 13, 2024
5bbd573
🔨 enable css sourcemaps for easier debugging
krmax44 May 13, 2024
87e3b2b
✨ redesign & cleanup article previews
krmax44 May 13, 2024
3f180e5
🐛 fix article redirect urls not working
krmax44 May 13, 2024
4a5aae0
🩹 fix overlapping issues with design container backdrop
krmax44 May 13, 2024
cca4bd8
✨ replace blog with investigations in the header
krmax44 May 13, 2024
e9e627f
🐛 fix update in migration
krmax44 May 13, 2024
e37e089
✨ add color and donation banner to category
krmax44 May 13, 2024
5f41e92
✨ display donation banner between article sections
krmax44 May 16, 2024
ebfc8d8
🗃️ ensure every article has at least one category
krmax44 May 16, 2024
eba656a
✨ find author's articles when searching for their name
krmax44 May 16, 2024
2b5faff
✨ add search by score to article search; new default sort
krmax44 May 16, 2024
540e099
🩹 fix article reverse url
krmax44 May 16, 2024
b483bd4
💬 rename Blog to Articles
krmax44 May 16, 2024
498d38f
✨ add short article url using
krmax44 May 16, 2024
8161fbb
🚧 work on article layout
krmax44 Jun 3, 2024
cc92547
🐛 fix blog urls precedence
krmax44 Jun 3, 2024
dd79628
🚧 more progress on blog article layout
krmax44 Jun 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 1 addition & 6 deletions fragdenstaat_de/fds_blog/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,7 @@ def queryset(self, request, queryset):


class CategoryAdmin(SortableAdminMixin, TranslatableAdmin):
fields = (
"title",
"description",
"slug",
"order",
)
fields = ("title", "description", "slug", "order", "color", "donation_banner")
list_display = ("title",)
search_fields = ("translations__title", "translations__description")

Expand Down
12 changes: 0 additions & 12 deletions fragdenstaat_de/fds_blog/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,6 @@ class BlogConfig(AppConfig):
verbose_name = "FragDenStaat Blog"

def ready(self):
"""
Remove when https://github.com/divio/django-filer/issues/1103
"""
from filer.fields.file import AdminFileWidget

AdminFileWidget.Media.js = (
"admin/js/vendor/jquery/jquery.js",
"admin/js/jquery.init.js",
) + AdminFileWidget.Media.js

AdminFileWidget.obj_for_value = obj_for_value

from froide.account import account_merged
from froide.helper.search import search_registry

Expand Down
17 changes: 11 additions & 6 deletions fragdenstaat_de/fds_blog/cms_toolbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@

class BlogToolbar(CMSToolbar):
def populate(self):
if not hasattr(self.request, "article"):
return

blog_menu = self.toolbar.get_or_create_menu("blog-menu", _("Blog"))
article = self.request.article
url = reverse("admin:fds_blog_article_change", args=(article.pk,))
blog_menu.add_modal_item(_("Edit article"), url=url)

if hasattr(self.request, "article"):
article = self.request.article
url = reverse("admin:fds_blog_article_change", args=(article.pk,))
blog_menu.add_modal_item(_("Edit article"), url=url)
else:
url = reverse("admin:fds_blog_article_changelist")
blog_menu.add_modal_item(_("Edit articles"), url=url)

url = reverse("admin:fds_blog_article_add")
blog_menu.add_modal_item(_("Create new article"), url=url)


toolbar_pool.register(BlogToolbar)
4 changes: 2 additions & 2 deletions fragdenstaat_de/fds_blog/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ArticleDocument(Document):
analyzer=analyzer,
)
start_publication = fields.DateField()
author = fields.ListField(fields.IntegerField())
author = fields.ListField(fields.TextField())
category = fields.ListField(fields.IntegerField())

content = fields.TextField(
Expand Down Expand Up @@ -86,7 +86,7 @@ def prepare_category(self, obj):

def prepare_author(self, obj):
authors = obj.authors.all()
return [o.id for o in authors]
return [o.get_full_name() for o in authors]


def index_article(article):
Expand Down
18 changes: 17 additions & 1 deletion fragdenstaat_de/fds_blog/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


class ArticleFilterset(BaseSearchFilterSet):
query_fields = ["title^5", "description^3", "content"]
query_fields = ["title^5", "description^3", "content", "author"]

category = django_filters.ModelChoiceFilter(
queryset=Category.objects.all(),
Expand All @@ -25,8 +25,24 @@ class ArticleFilterset(BaseSearchFilterSet):
method="filter_author",
)

sort = django_filters.ChoiceFilter(
choices=[
("-start_publication", _("Publication date (newest first)")),
("start_publication", _("Publication date (oldest first)")),
],
label=_("sort"),
empty_label=_("default sort"),
widget=BootstrapSelect,
method="add_sort",
)

def filter_category(self, qs, name, value):
return qs.filter(category=value.id)

def filter_author(self, qs, name, value):
return qs.filter(author=value.id)

def add_sort(self, qs, name, value):
if value:
return qs.add_sort(value)
return qs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Generated by Django 4.2.4 on 2024-04-18 21:20

import django.db.models.deletion
import django.db.models.functions.datetime
import django.utils.timezone
from django.db import migrations, models

import filer.fields.file


class Migration(migrations.Migration):
dependencies = [
("filer", "0015_alter_file_owner_alter_file_polymorphic_ctype_and_more"),
("fds_blog", "0014_article_audio_article_audio_duration"),
]

operations = [
migrations.AlterUniqueTogether(
name="article",
unique_together=set(),
),
migrations.AlterField(
model_name="article",
name="audio",
field=filer.fields.file.FilerFileField(
blank=True,
default=None,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="audio_articles",
to="filer.file",
verbose_name="audio file",
),
),
migrations.AlterField(
model_name="article",
name="creation_date",
field=models.DateTimeField(
db_index=True,
default=django.utils.timezone.now,
verbose_name="creation date",
),
),
migrations.AlterField(
model_name="article",
name="start_publication",
field=models.DateTimeField(
blank=True,
db_index=True,
help_text="Start date of publication. Used to build the entry's URL.",
null=True,
verbose_name="start publication",
),
),
migrations.AddConstraint(
model_name="article",
constraint=models.UniqueConstraint(
models.F("slug"),
django.db.models.functions.datetime.Extract(
"start_publication", "year"
),
django.db.models.functions.datetime.Extract(
"start_publication", "month"
),
name="unique_blog_url",
),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 4.2.4 on 2024-04-19 14:47

import django.utils.timezone
from django.db import migrations, models


def migrate_start_creation(apps, schema_editor):
Article = apps.get_model("fds_blog", "Article")

for article in Article.objects.filter(start_publication__isnull=True):
article.start_publication = article.creation_date
article.save()


class Migration(migrations.Migration):
dependencies = [
("fds_blog", "0015_alter_article_unique_together_alter_article_audio_and_more"),
]

operations = [
migrations.RunPython(migrate_start_creation),
migrations.AlterField(
model_name="article",
name="start_publication",
field=models.DateTimeField(
db_index=True,
default=django.utils.timezone.now,
help_text="Start date of publication. Used to build the entry's URL.",
verbose_name="start publication",
),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 4.2.4 on 2024-04-19 14:59

import django.db.models.functions.datetime
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("fds_blog", "0016_alter_article_start_publication"),
]

operations = [
migrations.RemoveConstraint(
model_name="article",
name="unique_blog_url",
),
migrations.AddConstraint(
model_name="article",
constraint=models.UniqueConstraint(
models.F("slug"),
models.F("language"),
django.db.models.functions.datetime.Extract(
"start_publication", "year"
),
django.db.models.functions.datetime.Extract(
"start_publication", "month"
),
name="unique_blog_url",
violation_error_message="An article with the same slug, month and year already exists. Please choose another slug.",
),
),
]
55 changes: 55 additions & 0 deletions fragdenstaat_de/fds_blog/migrations/0018_remove_slider_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Generated by Django 4.2.4 on 2024-05-13 16:09

from django.db import migrations, models


def migrate_slider_template(apps, schema_editor):
models = [
apps.get_model("fds_blog", "articlepreviewplugin"),
apps.get_model("fds_blog", "latestarticlesplugin"),
]

for model in models:
model.objects.filter(template="fds_blog/plugins/slider_articles.html").update(
template="fds_blog/plugins/featured_articles.html"
)


class Migration(migrations.Migration):
dependencies = [
("fds_blog", "0017_remove_article_unique_blog_url_and_more"),
]

operations = [
migrations.RunPython(migrate_slider_template),
migrations.AlterField(
model_name="articlepreviewplugin",
name="template",
field=models.CharField(
blank=True,
choices=[
("fds_blog/plugins/latest_articles.html", "Normal"),
("fds_blog/plugins/featured_articles.html", "Featured"),
("fds_blog/plugins/simple_articles.html", "Simple"),
],
help_text="template used to display the plugin",
max_length=250,
verbose_name="template",
),
),
migrations.AlterField(
model_name="latestarticlesplugin",
name="template",
field=models.CharField(
blank=True,
choices=[
("fds_blog/plugins/latest_articles.html", "Normal"),
("fds_blog/plugins/featured_articles.html", "Featured"),
("fds_blog/plugins/simple_articles.html", "Simple"),
],
help_text="template used to display the plugin",
max_length=250,
verbose_name="template",
),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Generated by Django 4.2.4 on 2024-05-13 17:49

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("djangocms_alias", "0004_alter_aliascontent_language"),
("fds_blog", "0018_remove_slider_template"),
]

operations = [
migrations.RemoveField(
model_name="article",
name="content_placeholder",
),
migrations.AddField(
model_name="category",
name="color",
field=models.CharField(
blank=True,
choices=[
("", "None"),
("callout", "Callout"),
("highlight", "Highlight"),
("body", "Default Body"),
("body-secondary", "Body Secondary"),
("body-tertiary", "Body Tertiary"),
("dark-subtle", "Dark Subtle"),
("light-subtle", "Light Subtle"),
("primary", "Primary"),
("primary-subtle", "Primary Subtle"),
("secondary", "Secondary"),
("secondary-subtle", "Secondary Subtle"),
("info", "Info"),
("info-subtle", "Info Subtle"),
("success", "Success"),
("success-subtle", "Success Subtle"),
("warning", "Warning"),
("warning-subtle", "Warning Subtle"),
("danger", "Danger"),
("danger-subtle", "Danger Subtle"),
("purple", "Purple"),
("pink", "Pink"),
("yellow", "Yellow"),
("cyan", "Cyan"),
("gray", "Gray"),
("gray-dark", "Gray Dark"),
("white", "White"),
("light", "Light"),
("dark", "Dark"),
("transparent", "Transparent"),
("gray-100", "Gray 100"),
("gray-200", "Gray 200"),
("gray-300", "Gray 300"),
("gray-400", "Gray 400"),
("gray-500", "Gray 500"),
("gray-600", "Gray 600"),
("gray-700", "Gray 700"),
("gray-800", "Gray 800"),
("gray-900", "Gray 900"),
("blue-10", "Blue 10"),
("blue-20", "Blue 20"),
("blue-30", "Blue 30"),
("blue-100", "Blue 100"),
("blue-200", "Blue 200"),
("blue-300", "Blue 300"),
("blue-400", "Blue 400"),
("blue-500", "Blue 500"),
("blue-600", "Blue 600"),
("blue-700", "Blue 700"),
("blue-800", "Blue 800"),
("yellow-100", "Yellow 100"),
("yellow-200", "Yellow 200"),
("yellow-300", "Yellow 300"),
],
default="",
help_text="Will be visible as the breadcrumb background.",
max_length=50,
verbose_name="Category color",
),
),
migrations.AddField(
model_name="category",
name="donation_banner",
field=models.ForeignKey(
default=None,
help_text="Inserted after a couple of paragraphs on the article page.",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="donation_banner",
to="djangocms_alias.alias",
verbose_name="Donation banner",
),
),
]