-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use plone.distribution and add voltodemo with testdata (#35)
* Use plone.distribution and add voltodemo with testdata * use distribution when creating the site * update checkouts * Fix create_site * Fix system block style * Some more demo content * fix create_site (again) * add copy of footer to customize * remove company branding * Update setup for python 3.12 * Add classicdemo distribution * Add content to distribution * remove old import-data * make format * remove obsolete checkouts and fix isort * Add changenote * update demo content * remove checkouts after release * add more example content, partly from the old vlt demo page * content cleanup * hide home tab and fix zpretty * update create-site script * Fix making forms translatable * fix python-version check * shamelessly steal better create-site script from plone.edu * fix all references to images * flake8 * store form data (to be able to test form block)
- Loading branch information
Showing
190 changed files
with
26,571 additions
and
756 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,98 @@ | ||
from AccessControl.SecurityManagement import newSecurityManager | ||
from pathlib import Path | ||
from plone.distribution.api import site as site_api | ||
from Testing.makerequest import makerequest | ||
|
||
import json | ||
import logging | ||
import os | ||
import transaction | ||
|
||
|
||
logging.basicConfig(format="%(message)s") | ||
|
||
# Silence some loggers | ||
for logger_name in [ | ||
"GenericSetup.componentregistry", | ||
"Products.MimetypesRegistry.MimeTypesRegistry", | ||
]: | ||
logging.getLogger(logger_name).setLevel(logging.ERROR) | ||
|
||
logger = logging.getLogger("Plone Site Creation") | ||
logger.setLevel(logging.DEBUG) | ||
|
||
SCRIPT_DIR = Path().cwd() / "scripts" | ||
|
||
truthy = frozenset(("t", "true", "y", "yes", "on", "1")) | ||
|
||
|
||
def asbool(s): | ||
"""Return the boolean value ``True`` if the case-lowered value of string | ||
input ``s`` is a :term:`truthy string`. If ``s`` is already one of the | ||
boolean values ``True`` or ``False``, return it.""" | ||
if s is None: | ||
return False | ||
if isinstance(s, bool): | ||
return s | ||
s = str(s).strip() | ||
return s.lower() in truthy | ||
|
||
|
||
app = makerequest(globals()["app"]) | ||
|
||
request = app.REQUEST | ||
|
||
admin = app.acl_users.getUserById("admin") | ||
admin = admin.__of__(app.acl_users) | ||
newSecurityManager(None, admin) | ||
|
||
|
||
def get_answers_file() -> Path: | ||
filename = f"{ANSWERS}.json" | ||
return SCRIPT_DIR / filename | ||
|
||
|
||
def parse_answers(answers_file: Path, site_id: str = "") -> dict: | ||
answers = json.loads(answers_file.read_text()) | ||
if "distribution" not in answers: | ||
# This is a bug in plone.distribution and should be fixed there | ||
answers["distribution"] = DISTRIBUTION | ||
if site_id: | ||
answers["site_id"] = site_id | ||
return answers | ||
|
||
|
||
# VARS | ||
DISTRIBUTION = os.getenv("DISTRIBUTION", "voltodemo") | ||
SITE_ID = os.getenv("SITE_ID") # if set, this overrides the value in ANSWERS | ||
ANSWERS = os.getenv("ANSWERS", "default") | ||
DELETE_EXISTING = asbool(os.getenv("DELETE_EXISTING")) | ||
|
||
# Load site creation parameters | ||
answers_file = get_answers_file() | ||
answers = parse_answers(answers_file, SITE_ID) | ||
site_id = answers["site_id"] | ||
|
||
|
||
logger.info(f"Creating a new Plone site @ {site_id}") | ||
logger.info(f" - Using the {DISTRIBUTION} distribution and answers from {answers_file}") | ||
|
||
|
||
if site_id in app.objectIds() and DELETE_EXISTING: | ||
app.manage_delObjects([site_id]) | ||
transaction.commit() | ||
app._p_jar.sync() | ||
logger.info(f" - Deleted existing site with id {site_id}") | ||
else: | ||
logger.info( | ||
f" - Stopping site creation, as there is already a site with id {site_id}. " | ||
"Set DELETE_EXISTING=1 to delete the existing site before creating a new one." | ||
) | ||
|
||
if site_id not in app.objectIds(): | ||
site = site_api._create_site( | ||
context=app, distribution_name=DISTRIBUTION, answers=answers | ||
) | ||
transaction.commit() | ||
app._p_jar.sync() | ||
logger.info(" - Site created!") |
This file was deleted.
Oops, something went wrong.
This file contains 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,8 @@ | ||
{ | ||
"site_id": "Plone", | ||
"title": "Welcome to Plone 6", | ||
"description": "Site created with a new Plone Distribution", | ||
"default_language": "en", | ||
"portal_timezone": "Europe/Berlin", | ||
"setup_content": true | ||
} |
This file contains 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 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
Binary file added
BIN
+677 KB
...ent/blobs/00cef5f245a342958288ace545e3c097-preview_image/black-starry-night.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.79 MB
...ons/voltodemo/content/blobs/05bace45294c45d5ab93de883e7ce702-image/penguin2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+896 KB
...ons/voltodemo/content/blobs/0c351dd841c34c6da9c313b1bc551e34-image/penguin4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+677 KB
...ent/blobs/102f648399914851951ffa3fefc8665c-preview_image/black-starry-night.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+677 KB
...ent/blobs/2508797173824f0e9f82bb2e7cfe922d-preview_image/black-starry-night.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+677 KB
...ent/blobs/3906609d0456404ca7146f6aa1f12f32-preview_image/black-starry-night.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+677 KB
...ent/blobs/3ac4a2c6c4034a1686bc0ee2d2072fd6-preview_image/black-starry-night.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+677 KB
...ent/blobs/40a436ad604f4f80aeafe0977806760a-preview_image/black-starry-night.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+873 KB
...6cca02c5580d4f7c865af74835ceab9d-image/danielle-barnes-kGNaS3lYCso-unsplash.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+677 KB
...ent/blobs/7ab9c48ede33415fa2a66a99549c8f70-preview_image/black-starry-night.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...oltodemo/content/blobs/7adc12f0e7604982a6cdcb9437bccf66-preview_image/event.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+127 KB
...ons/voltodemo/content/blobs/7de78fea55354a29ad78b909efb07436-image/penguin3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+677 KB
...ent/blobs/8416628543f146ff9a18d281c03e2399-preview_image/black-starry-night.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+677 KB
...ent/blobs/928010d84e5d4df2b2282f3e179d6b1a-preview_image/black-starry-night.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+677 KB
...emo/content/blobs/970ec24c76784c66a06d8c8d8b6522b2-image/black-starry-night.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+677 KB
...ent/blobs/99c70917b6894af08dd306fdbc0eff6a-preview_image/black-starry-night.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+512 KB
...ons/voltodemo/content/blobs/9abc1a813bcf46388e565b277bd8c6bf-image/penguin1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added
BIN
+2.13 MB
...af85ff98cd6446eebcba56305ed89fed-image/sergio-martinez-rhNJJ4eD2zk-unsplash.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+677 KB
...ent/blobs/bd2b39d2745847db82ed197a4eb1effc-preview_image/black-starry-night.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+464 KB
.../voltodemo/content/blobs/eec82559bf3242a6be4d43bc2096f399-image/image-light.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.