Repository navigation
Add Subsite content type to Website distribution #59
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
backend/src/kitconcept/website/profiles/default/repositorytool.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
11
backend/src/kitconcept/website/profiles/default/rolemap.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
backend/src/kitconcept/website/profiles/default/types/Subsite.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" /> | ||
| </property> | ||
|
|
||
| </object> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
17 changes: 17 additions & 0 deletions
17
backend/src/kitconcept/website/upgrades/v20260909001/configure.zcml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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