diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 713d057..18f47d3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/AUTHORS b/AUTHORS index f35c7cf..556aab7 100644 --- a/AUTHORS +++ b/AUTHORS @@ -13,3 +13,5 @@ * Yed Podtrzitko * Francisco Fernández * Pep Lluís Miró +* Wesley van Lee +* Marco Badan \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e4b0ec..f371653 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ Changelog ========= +Unreleased +---------- +* Add Wagtail 6.1 support. Drop Wagtail <=5.2 support. +* Add Django 5.0 support. + 2.0.0 (2023-07-04) ------------------ * Add Wagtail 5.0 support. Drop Wagtail <=4.0 support. @@ -93,7 +98,7 @@ Changelog * Fix header image. 1.0 (2018-04-10) ----------------- +------------------ * Add support for Django 2.0 and Wagtail 2.0. Drop Python 2.7 support. * Add code and block quote options to the entries text editor. * Improve default template visualisation. @@ -106,7 +111,7 @@ Changelog * Add German and Polish translations. 0.9.1 (2017-09-12) ------------------- +---------------- * Add missing migration. 0.9 (2017-08-03) @@ -125,7 +130,7 @@ Changelog * Minor template tweaks. 0.7 (2016-08-18) ----------------- +------------------ * Add initial travis support. * Add canonical url and social share tags in templates for SEO purposes. * Allow to place Puput's blog at any sitemap level. @@ -135,7 +140,7 @@ Changelog * Minor bug fixes. 0.6 (2016-05-18) ----------------- +------------------ * Fix issue when displaying entries without images. * Fix css issues. * Add django-compressor as project dependency. @@ -151,7 +156,7 @@ Changelog * Fix bug due a missing template tag. 0.5 (2016-02-12) ----------------- +------------------ * Altered URL structure in order to have blog as Wagtail root page. * Added Docker integration. * Archive list is now collapsible. diff --git a/docs/setup.rst b/docs/setup.rst index 70457c7..300c752 100644 --- a/docs/setup.rst +++ b/docs/setup.rst @@ -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', @@ -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', ) @@ -135,7 +134,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 @@ -149,9 +148,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 diff --git a/puput/__init__.py b/puput/__init__.py index 9b2e170..84dff05 100644 --- a/puput/__init__.py +++ b/puput/__init__.py @@ -15,13 +15,13 @@ "wagtail.sites", "wagtail.contrib.redirects", "wagtail.contrib.forms", + "wagtail.contrib.search_promotions", "wagtail.contrib.sitemaps", "wagtail.contrib.routable_page", "wagtail", # Third-party apps "taggit", "modelcluster", - "django_social_share", # Puput apps "puput", "wagtailmarkdown", diff --git a/puput/abstracts.py b/puput/abstracts.py index 2fb50e2..3b6edb9 100644 --- a/puput/abstracts.py +++ b/puput/abstracts.py @@ -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 @@ -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")) diff --git a/puput/fields.py b/puput/fields.py new file mode 100644 index 0000000..f702c63 --- /dev/null +++ b/puput/fields.py @@ -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) diff --git a/puput/migrations/0005_blogpage_main_color.py b/puput/migrations/0005_blogpage_main_color.py index 52f06b4..8c7e250 100644 --- a/puput/migrations/0005_blogpage_main_color.py +++ b/puput/migrations/0005_blogpage_main_color.py @@ -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 @@ -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'), ), ] diff --git a/puput/routes.py b/puput/routes.py index 871dc28..a91f4d0 100644 --- a/puput/routes.py +++ b/puput/routes.py @@ -8,7 +8,13 @@ from wagtail.contrib.routable_page.models import RoutablePageMixin, route from wagtail.models import Page -from wagtail.search.models import Query +import wagtail + +if wagtail.VERSION[:2] < (6, 0): + from wagtail.search.models import Query +else: + # https://docs.wagtail.org/en/stable/releases/6.0.html#query-model-moved-to-wagtail-contrib-search-promotions + from wagtail.contrib.search_promotions.models import Query from .utils import get_object_or_None diff --git a/puput/templates/puput/blog_page.html b/puput/templates/puput/blog_page.html index a0a7d69..ce8b75f 100644 --- a/puput/templates/puput/blog_page.html +++ b/puput/templates/puput/blog_page.html @@ -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 %} @@ -69,16 +69,9 @@ {{ entry.body|richtext|truncatewords_html:70 }} {% endif %}
+ {% canonical_url entry as share_url %}
{% trans 'Continue reading' %} » diff --git a/puput/templates/puput/entry_links.html b/puput/templates/puput/entry_links.html index dacea3a..3f44076 100644 --- a/puput/templates/puput/entry_links.html +++ b/puput/templates/puput/entry_links.html @@ -1,12 +1,14 @@ {% load wagtailroutablepage_tags puput_tags %}
- {% entry_url self blog_page as post_url %} + {% canonical_url self as share_url %}
diff --git a/puput/templates/puput/share_links.html b/puput/templates/puput/share_links.html new file mode 100644 index 0000000..ad0d97a --- /dev/null +++ b/puput/templates/puput/share_links.html @@ -0,0 +1,21 @@ +
  • +
    + + + +
    +
  • +
  • +
    + + + +
    +
  • +
  • +
    + + + +
    +
  • diff --git a/puput/templates/puput/tags/post_to_linkedin.html b/puput/templates/puput/tags/post_to_linkedin.html deleted file mode 100644 index 89e031d..0000000 --- a/puput/templates/puput/tags/post_to_linkedin.html +++ /dev/null @@ -1,3 +0,0 @@ -
    - {{link_text}} -
    \ No newline at end of file diff --git a/puput/templatetags/puput_tags.py b/puput/templatetags/puput_tags.py index 57fefa1..0940ea4 100644 --- a/puput/templatetags/puput_tags.py +++ b/puput/templatetags/puput_tags.py @@ -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 @@ -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 diff --git a/puput/widgets.py b/puput/widgets.py new file mode 100644 index 0000000..b3a3cff --- /dev/null +++ b/puput/widgets.py @@ -0,0 +1,5 @@ +from django import forms + + +class ColorPickerWidget(forms.TextInput): + input_type = "color" diff --git a/requirements-test.txt b/requirements-test.txt index b915c5f..4cf56f9 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,6 +1,6 @@ -pytest==7.1.2 -pytest-django==4.1.0 -requests==2.31.0 -model-bakery==1.5.0 -ipdb==0.13.9 -tox==3.27.1 +pytest==8.0.0 +pytest-django==4.8.0 +requests==2.32.0 +model-bakery==1.17.0 +ipdb==0.13.13 +tox==4.12.1 \ No newline at end of file diff --git a/setup.py b/setup.py index d3d604b..9f8dcb6 100644 --- a/setup.py +++ b/setup.py @@ -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,<7.0', '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'), @@ -40,10 +37,10 @@ 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', @@ -51,6 +48,7 @@ def get_metadata(package, field): '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' ] diff --git a/tox.ini b/tox.ini index 6762727..5a6850d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,13 +1,17 @@ [tox] -envlist = py{38,39,310,311}-dj{32,40,41,42}, flake8, black +envlist = + py{38,39}-dj{42}-{wt52,60,61} + py{310,311,312}-dj{42,50}-wt{52,60,61} + 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-wt{52,60,61} + 3.9: py39-dj42-wt{52,60,61} + 3.10: py310-dj{42,50}-wt{52,60,61} + 3.11: py311-dj{42,50}-wt{52,60,61} + 3.12: py312-dj{42,50}-wt{52,60,61}, flake8, black [flake8] max-line-length = 120 @@ -21,29 +25,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.32.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/