diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 9e1cd66..f944b82 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -20,7 +20,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: 3.11 + python-version: 3.12 - name: Install dependencies run: | @@ -45,7 +45,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: 3.11 + python-version: 3.12 - name: Install dependencies run: | @@ -86,4 +86,4 @@ jobs: body: | Release for ${{ github.ref_name }} draft: false - artifacts: dist/* \ No newline at end of file + artifacts: dist/* diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 194380b..dd45881 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -15,7 +15,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: 3.12 - name: Install dependencies run: | @@ -31,7 +31,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: ["3.8", "3.11"] + python-version: ["3.8", "3.11", "3.12"] steps: - name: Checkout code uses: actions/checkout@v3 diff --git a/external_link/static/js/newtab.js b/external_link/static/js/newtab.js index 5877b88..47654e3 100644 --- a/external_link/static/js/newtab.js +++ b/external_link/static/js/newtab.js @@ -147,7 +147,7 @@ function createAndHandleLinkForm(editorState, entityKey, onComplete) { var urlPattern = new RegExp('^(https?:\\/\\/)?'+ // validate protocol '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // validate domain name '((\\d{1,3}\\.){3}\\d{1,3}))'+ // validate OR ip (v4) address - '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // validate port and path + '(\\:\\d+)?(\\/[-a-z\\d%_.@~+]*)*'+ // validate port and path '(\\?[;&a-z\\d%_.~+=-]*)?'+ // validate query string '(\\#[-a-z\\d_]*)?$','i'); // validate fragment locator return !!urlPattern.test(urlString); diff --git a/pyproject.toml b/pyproject.toml index 8019479..4dd7a8b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ exclude = ["sandbox*", "docs*", "tests*"] [project] name = "wagtail-external-link-richtext" -version = "1.1.3" +version = "1.1.4" description = "A feature for the richtext fields in Wagtail" readme = "README.md" authors = [{name = "Ruben Hesselink", email = "ruben@fourdigits.nl" }] @@ -26,7 +26,8 @@ classifiers = [ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11" + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12" ] keywords = ["richtext", "external", "link", "wagtail", "newtab", "django"] dependencies = [ @@ -51,4 +52,4 @@ src_paths = ["test_project", "sandbox", "external_link"] [tool.pytest.ini_options] DJANGO_SETTINGS_MODULE = "test_project.settings.dev" -python_files = ["tests.py", "*_test.py", "testing/python/*.py"] \ No newline at end of file +python_files = ["tests.py", "*_test.py", "testing/python/*.py"] diff --git a/sandbox/example_project/settings/base.py b/sandbox/example_project/settings/base.py index 860c0ea..df43f43 100644 --- a/sandbox/example_project/settings/base.py +++ b/sandbox/example_project/settings/base.py @@ -169,4 +169,4 @@ # Add external link to richtext features RICHTEXT_FEATURES = [ "new_tab_link", -] \ No newline at end of file +] diff --git a/sandbox/example_project/urls.py b/sandbox/example_project/urls.py index 358613c..1768475 100644 --- a/sandbox/example_project/urls.py +++ b/sandbox/example_project/urls.py @@ -1,9 +1,8 @@ from django.conf import settings -from django.urls import include, path from django.contrib import admin - -from wagtail.admin import urls as wagtailadmin_urls +from django.urls import include, path from wagtail import urls as wagtail_urls +from wagtail.admin import urls as wagtailadmin_urls from wagtail.documents import urls as wagtaildocs_urls urlpatterns = [ diff --git a/sandbox/home/migrations/0002_homepage_body.py b/sandbox/home/migrations/0002_homepage_body.py index ef5dad7..1259ac9 100644 --- a/sandbox/home/migrations/0002_homepage_body.py +++ b/sandbox/home/migrations/0002_homepage_body.py @@ -1,20 +1,20 @@ # Generated by Django 3.2.20 on 2023-07-05 10:55 -from django.db import migrations import wagtail.fields +from django.db import migrations class Migration(migrations.Migration): dependencies = [ - ('home', '0001_initial'), + ("home", "0001_initial"), ] operations = [ migrations.AddField( - model_name='homepage', - name='body', - field=wagtail.fields.RichTextField(default='Test'), + model_name="homepage", + name="body", + field=wagtail.fields.RichTextField(default="Test"), preserve_default=False, ), ] diff --git a/sandbox/home/models.py b/sandbox/home/models.py index 57323f4..80014d5 100644 --- a/sandbox/home/models.py +++ b/sandbox/home/models.py @@ -1,12 +1,9 @@ from django.db import models - -from wagtail.models import Page -from wagtail.fields import RichTextField from wagtail.admin.panels import FieldPanel +from wagtail.fields import RichTextField +from wagtail.models import Page class HomePage(Page): body = RichTextField() - content_panels = Page.content_panels + [ - FieldPanel("body") - ] + content_panels = Page.content_panels + [FieldPanel("body")] diff --git a/sandbox/requirements.txt b/sandbox/requirements.txt index 0e2771c..a3f15e5 100644 --- a/sandbox/requirements.txt +++ b/sandbox/requirements.txt @@ -1,3 +1,3 @@ Django>=4.0,<4.1 wagtail>=3.0,<3.1 -wagtail-external-link-richtext \ No newline at end of file +wagtail-external-link-richtext diff --git a/test_project/test_app/migrations/0001_initial.py b/test_project/test_app/migrations/0001_initial.py index 3e7d367..1863c13 100644 --- a/test_project/test_app/migrations/0001_initial.py +++ b/test_project/test_app/migrations/0001_initial.py @@ -1,8 +1,8 @@ # Generated by Django 4.0.10 on 2023-07-06 07:05 -from django.db import migrations, models import django.db.models.deletion import wagtail.fields +from django.db import migrations, models class Migration(migrations.Migration): @@ -10,19 +10,29 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('wagtailcore', '0069_log_entry_jsonfield'), + ("wagtailcore", "0069_log_entry_jsonfield"), ] operations = [ migrations.CreateModel( - name='TestPage', + name="TestPage", fields=[ - ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')), - ('body', wagtail.fields.RichTextField()), + ( + "page_ptr", + models.OneToOneField( + auto_created=True, + on_delete=django.db.models.deletion.CASCADE, + parent_link=True, + primary_key=True, + serialize=False, + to="wagtailcore.page", + ), + ), + ("body", wagtail.fields.RichTextField()), ], options={ - 'abstract': False, + "abstract": False, }, - bases=('wagtailcore.page',), + bases=("wagtailcore.page",), ), ] diff --git a/test_project/test_app/tests.py b/test_project/test_app/tests.py index f27711b..b1a5532 100644 --- a/test_project/test_app/tests.py +++ b/test_project/test_app/tests.py @@ -61,11 +61,22 @@ def test_to_database_format(): } ) actual_database_html = converter.to_database_format(contentstate_json) - expected_database_html = ( + expected_database_html_v1 = ( "

' 'Four Digits

' ) - assert actual_database_html == expected_database_html + # From wagtail6.1 the order of the attributes is not guaranteed + expected_database_html_v2 = ( + "

' + 'Four Digits

' + ) + assert actual_database_html in { + expected_database_html_v1, + expected_database_html_v2, + } diff --git a/test_project/urls.py b/test_project/urls.py index 9340108..1768475 100644 --- a/test_project/urls.py +++ b/test_project/urls.py @@ -1,12 +1,10 @@ from django.conf import settings -from django.urls import include, path from django.contrib import admin - -from wagtail.admin import urls as wagtailadmin_urls +from django.urls import include, path from wagtail import urls as wagtail_urls +from wagtail.admin import urls as wagtailadmin_urls from wagtail.documents import urls as wagtaildocs_urls - urlpatterns = [ path("django-admin/", admin.site.urls), path("admin/", include(wagtailadmin_urls)), diff --git a/tox.ini b/tox.ini index fd1fdb1..b4579e7 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,8 @@ [tox] envlist = py38-django32-wagtail{30,40} - py311-django{32,40,41}-wagtail{41,42,50} + py311-django{32,40,41}-wagtail{41,42,52} + py312-django{42,50}-wagtail{52,61} [testenv] @@ -12,13 +13,15 @@ ignore_errors = True deps = django32: django>=3.2,<3.3 django40: django>=4.0,<4.1 - django41: django>=4.1,<4.2 + django42: django>=4.2,<4.3 + django50: django>=5.0,<5.1 djangomain: git+https://github.com/django/django.git@main#egg=Django wagtail30: wagtail>=3.0,<3.1 wagtail40: wagtail>=4.0,<4.1 wagtail41: wagtail>=4.1,<4.2 wagtail42: wagtail>=4.2,<4.3 - wagtail50: wagtail>=5.0,<5.1 + wagtail52: wagtail>=5.2,<5.3 + wagtail61: wagtail>=6.1,<6.2 commands = - pytest \ No newline at end of file + pytest