Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backend/news/+fix-dsgvo-lint-e501.internal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Wrap two long strings in the DSGVO control panel schema to satisfy ruff E501 (line length) under `make lint`. No behavior change. @sneridagh
1 change: 1 addition & 0 deletions backend/news/86.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `Subsite` content type to the Website distribution. A Subsite is a navigation root with its own navigation, breadcrumbs, header/footer logo and theme customizations. @sneridagh
Empty file.
12 changes: 12 additions & 0 deletions backend/src/kitconcept/website/content/subsite.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from plone.dexterity.content import Container
from plone.supermodel.model import Schema
from zope.interface import implementer


class ISubsite(Schema):
"""Subsite content type interface"""


@implementer(ISubsite)
class Subsite(Container):
"""Subsite content type"""
6 changes: 4 additions & 2 deletions backend/src/kitconcept/website/controlpanels/dsgvo.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ class IDSGVOSettings(Interface):
description=_(
"help_dsgvo_tracker_options",
default="JSON object with tracker configuration. "
'For Google Analytics: {"id": "G-XXXXXXX", "gaOptions": {"anonymizeIp": true}}. '
'For Google Analytics: {"id": "G-XXXXXXX", "gaOptions": '
'{"anonymizeIp": true}}. '
'For Matomo: {"id": 1, "urlBase": "https://matomo.example.com/"}.',
),
schema=TRACKER_OPTIONS_SCHEMA,
Expand All @@ -107,7 +108,8 @@ class IDSGVOSettings(Interface):
title=_("label_dsgvo_privacy_url", default="Privacy policy URL"),
description=_(
"help_dsgvo_privacy_url",
default="JSON object mapping language codes to privacy policy paths or URLs. "
default="JSON object mapping language codes to privacy "
"policy paths or URLs. "
'Example: {"en": "/en/privacy", "de": "/de/datenschutz"}.',
),
schema=PRIVACY_URL_SCHEMA,
Expand Down
5 changes: 5 additions & 0 deletions backend/src/kitconcept/website/permissions.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<configure zcml:condition="installed AccessControl.security">
<!-- -*- extra stuff goes here -*- -->

<permission
id="kitconcept.website.siteadminsonly"
title="kitconcept.website: Site Admins Only"
/>

</configure>

</configure>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<version>20260617001</version>
<version>20260909001</version>
<dependencies>
<!-- <dependency>kitconcept.solr:default</dependency> -->
<dependency>profile-kitconcept.contactblock:default</dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<repositorytool>
<policymap purge="false">
<type name="Subsite">
<policy name="at_edit_autoversion" />
<policy name="version_on_revert" />
</type>
</policymap>
</repositorytool>
11 changes: 11 additions & 0 deletions backend/src/kitconcept/website/profiles/default/rolemap.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<rolemap>
<permissions>
<permission acquire="False"
name="kitconcept.website: Site Admins Only"
>
<role name="Site Administrator" />
<role name="Manager" />
</permission>
</permissions>
</rolemap>
3 changes: 3 additions & 0 deletions backend/src/kitconcept/website/profiles/default/types.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
<object meta_type="Plone Types Tool"
name="portal_types"
>
<object meta_type="Dexterity FTI"
name="Subsite"
/>

</object>
65 changes: 65 additions & 0 deletions backend/src/kitconcept/website/profiles/default/types/Subsite.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
meta_type="Dexterity FTI"
name="Subsite"
i18n:domain="kitconcept.website"
>

<!-- Basic properties -->
<property name="title"
i18n:translate=""
>Subsite</property>
<property name="description"
i18n:translate=""
/>

<property name="allow_discussion">False</property>
<property name="factory">Subsite</property>
<property name="link_target" />


<!-- Hierarchy control -->
<property name="allowed_content_types">
<element value="Document" />
<element value="File" />
<element value="Image" />
<element value="Link" />
</property>
<property name="filter_content_types">True</property>
<property name="global_allow">True</property>


<!-- Schema, class and security -->
<property name="add_permission">kitconcept.website.siteadminsonly</property>
<property name="klass">kitconcept.website.content.subsite.Subsite</property>
<property name="model_file" />
<property name="model_source" />
<property name="schema">kitconcept.website.content.subsite.ISubsite</property>

<!-- Enabled behaviors -->
<property name="behaviors"
purge="true"
>
<element value="plone.basic" />
<element value="volto.preview_image_link" />
<element value="volto.kicker" />
<element value="plone.categorization" />
<element value="plone.publication" />
<element value="plone.ownership" />
<element value="plone.shortname" />
<element value="volto.navtitle" />
<element value="plone.excludefromnavigation" />
<element value="volto.blocks" />
<element value="voltolighttheme.header" />
<element value="voltolighttheme.theme" />
<element value="voltolighttheme.footer" />
<element value="kitconcept.footer" />
<element value="plone.constraintypes" />
<element value="plone.namefromtitle" />
<element value="plone.versioning" />
<element value="plone.locking" />
<element value="plone.translatable" />
<element value="plone.navigationroot" />

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a tangent, but looking at this made me realize we should probably add the kitconcept.seo fields to all content types in kitconcept-website

</property>

</object>
1 change: 1 addition & 0 deletions backend/src/kitconcept/website/upgrades/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
<include package=".v20260304001" />
<include package=".v20260611001" />
<include package=".v20260617001" />
<include package=".v20260909001" />

</configure>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
>

<genericsetup:upgradeSteps
profile="kitconcept.website:default"
source="20260617001"
destination="20260909001"
>
<genericsetup:upgradeDepends
title="Add Subsite content type."
import_steps="rolemap typeinfo repositorytool"
/>
</genericsetup:upgradeSteps>

</configure>
96 changes: 96 additions & 0 deletions backend/tests/content_types/test_ct_subsite.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
from kitconcept.website.content.subsite import ISubsite
from plone import api
from plone.dexterity.fti import DexterityFTI

import pytest


class TestContentTypeFTI:
portal_type: str = "Subsite"

@pytest.fixture(autouse=True)
def _setup(self, portal, get_fti):
self.portal = portal
self.fti: DexterityFTI = get_fti(self.portal_type)

@pytest.mark.parametrize(
"attr,expected",
[
("title", "Subsite"),
("global_allow", True),
("filter_content_types", True),
("add_permission", "kitconcept.website.siteadminsonly"),
("klass", "kitconcept.website.content.subsite.Subsite"),
("schema", "kitconcept.website.content.subsite.ISubsite"),
(
"allowed_content_types",
(
"Document",
"File",
"Image",
"Link",
),
),
],
)
def test_fti(self, attr: str, expected):
"""Test FTI values."""
fti = self.fti

assert isinstance(fti, DexterityFTI)
assert getattr(fti, attr) == expected

@pytest.mark.parametrize(
"idx,behavior",
enumerate((
"plone.basic",
"volto.preview_image_link",
"volto.kicker",
"plone.categorization",
"plone.publication",
"plone.ownership",
"plone.shortname",
"volto.navtitle",
"plone.excludefromnavigation",
"volto.blocks",
"voltolighttheme.header",
"voltolighttheme.theme",
"voltolighttheme.footer",
"kitconcept.footer",
"plone.constraintypes",
"plone.namefromtitle",
"plone.versioning",
"plone.locking",
"plone.translatable",
"plone.navigationroot",
)),
)
def test_behaviors(self, idx: int, behavior: str):
"""Test behaviors are present and in correct order."""
assert self.fti.behaviors[idx] == behavior


class TestContentTypeSubsite:
portal_type: str = "Subsite"

@pytest.fixture(autouse=True)
def _setup(self, portal):
self.portal = portal

def test_create(self):
"""A Subsite can be created and is a navigation root."""
from plone.base.interfaces import INavigationRoot

with api.env.adopt_roles(["Manager"]):
content = api.content.create(
container=self.portal,
type=self.portal_type,
title="My Subsite",
id="my-subsite",
)

assert content.portal_type == self.portal_type
assert ISubsite.providedBy(content)
# Own navigation and breadcrumbs starting on the subsite are driven
# by the plone.navigationroot behavior.
assert INavigationRoot.providedBy(content)
104 changes: 104 additions & 0 deletions frontend/acceptance/tests/subsite.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import type { Page } from '@playwright/test';

import { createContent } from './content';
import { login } from './login';
import { expect, test } from './test';

// A minimal valid 1x1 PNG, used as the Subsite logo.
const LOGO_PNG_BASE64 =
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==';

/**
* Returns the `src` of the header (banner) home logo currently rendered.
* VLT renders the logo as an <img> inside the "Home" link of the header.
*/
async function headerLogoSrc(page: Page) {
const logo = page
.getByRole('banner')
.getByRole('link', { name: 'Home' })
.getByRole('img')
.first();
await expect(logo).toBeVisible();
return logo.getAttribute('src');
}

test.describe('Subsite', () => {
test('renders its own header/footer logo, scoped to the subsite navigation root', async ({
page,
}) => {
await login(page);

const subsiteId = `acceptance-subsite-${Date.now()}`;

// A Subsite with its own logo, set on the shared VLT header behavior.
await createContent(page, {
contentType: 'Subsite',
contentId: subsiteId,
contentTitle: 'Acceptance Subsite',
transition: 'publish',
bodyModifier: (body) => ({
...body,
logo: {
'content-type': 'image/png',
data: LOGO_PNG_BASE64,
encoding: 'base64',
filename: 'subsite-logo.png',
},
// Give the subsite a title block so its view renders a heading.
blocks: {
'd3f1c443-583f-4e8e-a682-3bf25752a300': { '@type': 'title' },
'7624cf59-05d0-4055-8f55-5fd6597d84b0': { '@type': 'slate' },
},
blocks_layout: {
items: [
'd3f1c443-583f-4e8e-a682-3bf25752a300',
'7624cf59-05d0-4055-8f55-5fd6597d84b0',
],
},
}),
});

// A page inside the subsite, to prove the logo is inherited by descendants.
const childId = 'a-page';
await createContent(page, {
contentType: 'Document',
contentId: childId,
contentTitle: 'A Subsite Page',
path: subsiteId,
transition: 'publish',
});

// Baseline: the logo shown at the site root (not the subsite's).
const siteRootResponse = await page.goto('/', { waitUntil: 'networkidle' });
expect(siteRootResponse?.ok()).toBeTruthy();
const siteRootLogo = await headerLogoSrc(page);

// On the subsite itself, the header shows the subsite's own logo.
const subsiteResponse = await page.goto(`/${subsiteId}`, {
waitUntil: 'networkidle',
});
expect(subsiteResponse?.ok()).toBeTruthy();
await expect(
page.getByRole('heading', { name: 'Acceptance Subsite' }),
).toBeVisible();
const subsiteLogo = await headerLogoSrc(page);

// The subsite logo is its own, distinct from the site root logo. This is
// what proves the header resolves the logo from the nearest navigation
// root rather than always from the site root.
expect(subsiteLogo).toBeTruthy();
expect(subsiteLogo).not.toBe(siteRootLogo);

// A descendant page inherits the subsite's logo (nearest navigation root).
const childResponse = await page.goto(`/${subsiteId}/${childId}`, {
waitUntil: 'networkidle',
});
expect(childResponse?.ok()).toBeTruthy();
await expect(
page.getByRole('heading', { name: 'A Subsite Page' }),
).toBeVisible();
const childLogo = await headerLogoSrc(page);

expect(childLogo).toBe(subsiteLogo);
});
});
1 change: 1 addition & 0 deletions frontend/packages/kitconcept-website/news/86.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a Playwright acceptance test for the Subsite content type: it verifies a Subsite renders its own header logo (distinct from the site root) and that a descendant page inherits it, confirming the logo resolves from the nearest navigation root. @sneridagh
Loading