Skip to content

Commit

Permalink
Adds support up to Wagtail 5.2 (#286)
Browse files Browse the repository at this point in the history
* Adds Python3.12 and Wagtail 5.0, 5.1 and 5.2 to Tox and remove support for Wagtail <4.1

* Update requirements and tox

* fix typo in tox.ini

* Remove dependencies (django-social-share and django-colorful) since they are no longer actively maintained

---------

Co-authored-by: Marco Badan <[email protected]>
Co-authored-by: Carlos Salom Oliver <[email protected]>
  • Loading branch information
3 people authored May 22, 2024
1 parent 7bf3307 commit 9a20df4
Show file tree
Hide file tree
Showing 16 changed files with 91 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down
7 changes: 2 additions & 5 deletions docs/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ If you are already referencing one of these apps in your :code:`INSTALLED_APPS`
INSTALLED_APPS = (
...
'wagtail.contrib.legacy.richtext',
'wagtail.core',
'wagtail',
'wagtail.admin',
'wagtail.documents',
'wagtail.snippets',
Expand All @@ -41,7 +41,6 @@ If you are already referencing one of these apps in your :code:`INSTALLED_APPS`
'wagtail.contrib.routable_page',
'taggit',
'modelcluster',
'django_social_share',
'puput',
)
Expand Down Expand Up @@ -127,7 +126,7 @@ Installation on top of Wagtail
pip install --upgrade pip
pip install wheel
pip install wagtail django-colorful django-el-pagination django-social-share
pip install wagtail django-el-pagination
pip install --no-deps puput
wagtail start mysite
cd mysite
Expand All @@ -141,9 +140,7 @@ Installation on top of Wagtail
'wagtail.contrib.sitemaps',
'wagtail.contrib.routable_page',
'django_social_share',
'puput',
'colorful',
3. In the same file, also add the line :code:`PUPUT_AS_PLUGIN = True` to the very bottom

Expand Down
1 change: 0 additions & 1 deletion puput/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
# Third-party apps
"taggit",
"modelcluster",
"django_social_share",
# Puput apps
"puput",
"wagtailmarkdown",
Expand Down
4 changes: 2 additions & 2 deletions puput/abstracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from wagtail.fields import RichTextField
from modelcluster.contrib.taggit import ClusterTaggableManager
from wagtailmarkdown.fields import MarkdownField
from colorful.fields import RGBColorField

from .fields import ColorField
from .utils import get_image_model_path
import markdown

Expand All @@ -34,7 +34,7 @@ class BlogAbstract(models.Model):
related_name="+",
)

main_color = RGBColorField(_("Blog Main Color"), default="#4D6AE0")
main_color = ColorField(_("Blog Main Color"), default="#4D6AE0")

display_comments = models.BooleanField(default=False, verbose_name=_("Display comments"))
display_categories = models.BooleanField(default=True, verbose_name=_("Display categories"))
Expand Down
17 changes: 17 additions & 0 deletions puput/fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from django.db import models

from puput.widgets import ColorPickerWidget


class ColorField(models.CharField):
"""
A CharField which uses the HTML5 color picker widget.
"""

def __init__(self, *args, **kwargs):
kwargs["max_length"] = 255
super().__init__(*args, **kwargs)

def formfield(self, **kwargs):
kwargs["widget"] = ColorPickerWidget
return super().formfield(**kwargs)
4 changes: 2 additions & 2 deletions puput/migrations/0005_blogpage_main_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Generated by Django 1.11.4 on 2018-04-09 18:57
from __future__ import unicode_literals

import colorful.fields
import puput.fields
from django.db import migrations


Expand All @@ -16,6 +16,6 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='blogpage',
name='main_color',
field=colorful.fields.RGBColorField(default='#4D6AE0', verbose_name='Blog Main Color'),
field=puput.fields.ColorField(default='#4D6AE0', verbose_name='Blog Main Color'),
),
]
13 changes: 3 additions & 10 deletions puput/templates/puput/blog_page.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "puput/base.html" %}

{% load static i18n wagtailcore_tags wagtailimages_tags puput_tags social_share %}
{% load static i18n wagtailcore_tags wagtailimages_tags puput_tags %}

{% block title %}
{% if search_term %}
Expand Down Expand Up @@ -69,16 +69,9 @@
{{ entry.body|richtext|truncatewords_html:70 }}
{% endif %}
<div class="row">
{% canonical_url entry as share_url %}
<ul class="social-share col-md-9">
<li class="social-item">
{% post_to_facebook post_url '<span><i class="fa fa-facebook"></i></span>' %}
</li>
<li class="social-item">
{% post_to_twitter entry.title post_url '<span><i class="fa fa-twitter"></i></span>' %}
</li>
<li class="social-item">
{% post_to_linkendin post_url '<span><i class="fa fa-linkedin"></i></span>' %}
</li>
{% include 'puput/share_links.html' with share_url=share_url entry=entry only %}
</ul>
<div class="col-md-3">
<a class="blog_btn continue" href="{{ post_url }}">{% trans 'Continue reading' %} &raquo;</a>
Expand Down
2 changes: 2 additions & 0 deletions puput/templates/puput/entry_links.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{% load wagtailroutablepage_tags puput_tags %}

<ul class="links">
{% if entry.owner %}
<li>
<i class="fa fa-user"></i>
<a href="{% routablepageurl blog_page 'entries_by_author' entry.owner.username %}">
{{ entry.owner.username }}
</a>
</li>
{% endif %}
<li>
<i class="fa fa-calendar"></i>
{{ entry.date|date:"DATE_FORMAT" }}
Expand Down
14 changes: 3 additions & 11 deletions puput/templates/puput/entry_page.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "puput/base.html" %}
{% load i18n wagtailcore_tags wagtailimages_tags puput_tags social_share %}
{% load i18n wagtailcore_tags wagtailimages_tags puput_tags %}

{% block title %}
{{ self.title }} | {{ blog_page.title }}
Expand Down Expand Up @@ -62,17 +62,9 @@
<i class="fa fa-angle-left"></i> {% trans 'Return' %}
</a>
</div>
{% entry_url self blog_page as post_url %}
{% canonical_url self as share_url %}
<ul class="social-share-all text-right col-md-10">
<li class="social-item">
{% post_to_facebook post_url '<span><i class="fa fa-facebook"></i></span>' %}
</li>
<li class="social-item">
{% post_to_twitter self.title post_url '<span><i class="fa fa-twitter"></i></span>' %}
</li>
<li class="social-item">
{% post_to_linkendin post_url '<span><i class="fa fa-linkedin"></i></span>' %}
</li>
{% include 'puput/share_links.html' with share_url=share_url entry=self only %}
</ul>
</div>

Expand Down
21 changes: 21 additions & 0 deletions puput/templates/puput/share_links.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<li class="social-item">
<div class="facebook-this">
<a href="https://www.facebook.com/sharer/sharer.php?u={{ share_url }}" target="_blank">
<span><i class="fa fa-facebook"></i></span>
</a>
</div>
</li>
<li class="social-item">
<div class="tweet-this">
<a href="https://twitter.com/share?url={{ share_url }}&text={{ entry.title }}" class="meta-act-link meta-tweet" target="_blank">
<span><i class="fa fa-twitter"></i></span>
</a>
</div>
</li>
<li class="social-item">
<div class="linkedin-this">
<a class="box-social" href="https://www.linkedin.com/shareArticle?url={{ share_url }}&title={{ entry.title }}&summary={{ entry.search_description }}" target="_blank">
<span><i class="fa fa-linkedin"></i></span>
</a>
</div>
</li>
3 changes: 0 additions & 3 deletions puput/templates/puput/tags/post_to_linkedin.html

This file was deleted.

18 changes: 0 additions & 18 deletions puput/templatetags/puput_tags.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from django.template import Library
from django.urls import resolve
from django.template.defaultfilters import urlencode
from django.template.loader import render_to_string
from django_social_share.templatetags.social_share import _build_url
from el_pagination.templatetags.el_pagination_tags import show_pages, paginate

from ..conf import settings
Expand Down Expand Up @@ -109,19 +107,3 @@ def show_comments(context):
# Avoid to import endless_pagination in installed_apps and in the templates
register.tag("show_paginator", show_pages)
register.tag("paginate", paginate)


@register.simple_tag(takes_context=True)
def post_to_linkendin_url(context, obj_or_url=None):
request = context.get("request")
if request:
url = _build_url(request, obj_or_url)
context["linkendin_url"] = "https://www.linkedin.com/shareArticle?url={}".format(urlencode(url))
return context


@register.inclusion_tag("puput/tags/post_to_linkedin.html", takes_context=True)
def post_to_linkendin(context, obj_or_url=None, link_text="Post to LinkedIn"):
context = post_to_linkendin_url(context, obj_or_url)
context["link_text"] = link_text
return context
5 changes: 5 additions & 0 deletions puput/widgets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django import forms


class ColorPickerWidget(forms.TextInput):
input_type = "color"
10 changes: 5 additions & 5 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pytest==7.1.2
pytest-django==4.1.0
pytest==8.0.0
pytest-django==4.8.0
requests==2.32.0
model-bakery==1.5.0
ipdb==0.13.9
tox==3.27.1
model-bakery==1.17.0
ipdb==0.13.13
tox==4.12.1
14 changes: 6 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,10 @@ def get_metadata(package, field):
description='A Django blog app implemented in Wagtail.',
long_description=codecs.open(os.path.join(os.path.dirname(__file__), 'README.rst'), encoding='utf-8').read(),
install_requires=[
'Django>=3.2,<4.3',
'wagtail>=4.0,<5.1',
'wagtail>=5.2',
'django-el-pagination==4.0.0',
'django-social-share>=1.3.0',
'django-colorful>=1.3',
'django-taggit>=3.1.0,<4.1',
'wagtail-markdown==0.11.0'
'wagtail-markdown==0.11.1'
],
url='http://github.com/APSL/puput',
author=get_metadata('puput', 'author'),
Expand All @@ -40,17 +37,18 @@ def get_metadata(package, field):
classifiers=[
'Environment :: Web Environment',
'Framework :: Django',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.0',
'Framework :: Django :: 4.1',
'Framework :: Django :: 4.2',
'Framework :: Django :: 5.0',
'Framework :: Wagtail',
'Framework :: Wagtail :: 5',
'Intended Audience :: Developers',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Operating System :: OS Independent',
'Topic :: Software Development'
]
Expand Down
45 changes: 22 additions & 23 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
[tox]
envlist = py{38,39,310,311}-dj{32,40,41,42}, flake8, black
envlist =
py{38,39,310}-dj{42}-wt52
py311-dj{42,50}-wt52
py312-dj{42,50}-wt52
flake8
black

[gh-actions]
python =
3.8: py38-dj{32,40,41,42}, flake8, black
3.9: py39-dj{32,40,41,42}
3.10: py310-dj{32,40,41,42}
3.11: py311-dj{32,40,41,42}

3.8: py38-dj42-wt52
3.9: py38-dj42-wt52
3.10: py310-dj{42,50}-wt52
3.11: py311-dj{42,50}-wt52
3.12: py312-dj{42,50}-wt52, flake8, black

[flake8]
max-line-length = 120
Expand All @@ -21,29 +26,23 @@ commands =
pytest --create-db --no-migrations

deps =
pytest==7.1.2
pytest-django==4.1.0
requests==2.28.1
model-bakery==1.5.0
ipdb==0.13.9

pytest==8.0.0
pytest-django==4.8.0
requests==2.31.0
model-bakery==1.17.0
ipdb==0.13.13
django-el-pagination==4.0
django-social-share>=1.3.0
django-colorful>=1.3
tapioca-disqus==0.1.2

dj32: Django>=3.2,<3.3
dj40: Django>=4.0,<4.1
dj41: Django>=4.1,<4.2
dj42: Django>=4.2,<4.3

dj50: Django>=5.0,<5.1
wt52: wagtail>=5.2,<5.3

[testenv:flake8]
basepython = python3.10
deps = flake8==4.0.1
basepython = python3.12
deps = flake8==7.0.0
commands = flake8 puput tests --exclude=migrations

[testenv:black]
basepython = python3.10
deps = black==22.3.0
basepython = python3.12
deps = black==24.1.1
commands = black puput tests -l 120 --check --extend-exclude=/migrations/

0 comments on commit 9a20df4

Please sign in to comment.