Skip to content

Commit c300964

Browse files
committed
configuration changes
1 parent 699bb8e commit c300964

10 files changed

Lines changed: 212 additions & 96 deletions

File tree

templates/project/cookieplone.json

Lines changed: 51 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -3,87 +3,79 @@
33
"properties": {
44
"description": {
55
"type": "string",
6-
"title": "Description",
7-
"description": "A short description of your add-on.",
8-
"default": "A new Plone project for {{ cookiecutter.title }}",
6+
"title": "Project Description",
7+
"description": "Short summary of the project, used in package metadata and README.",
8+
"default": "A new project using Plone 6.",
99
"validator": "",
1010
"format": "computed"
1111
},
12-
"author": {
13-
"title": "Author",
14-
"default": "CodeSyntax",
15-
"type": "string",
16-
"format": "computed"
17-
},
18-
"email": {
19-
"title": "E-mail",
20-
"default": "plone@codesyntax.com",
12+
"hostname": {
2113
"type": "string",
14+
"title": "Project URL (without protocol)",
15+
"description": "The hostname where the project will be deployed (e.g. mysite.example.com).",
16+
"default": "{{ cookiecutter.project_slug }}.korpoweb.com",
17+
"validator": "cookieplone.validators.hostname",
2218
"format": "computed"
2319
},
24-
"hostname": {
20+
"author": {
2521
"type": "string",
26-
"title": "Hostname",
27-
"description": "Public URL of the server.",
28-
"default": "{{ cookiecutter.folder_name }}.korpoweb.com",
22+
"title": "Author",
23+
"description": "Name of the project author or organization.",
24+
"default": "CodeSyntax",
2925
"validator": "",
3026
"format": "computed"
3127
},
32-
"use_prerelease_versions": {
28+
"email": {
3329
"type": "string",
34-
"title": "Should we use prerelease versions?",
35-
"description": "Whether to include alpha, beta, and release candidate versions when resolving the Plone version.",
36-
"default": false,
30+
"title": "Author E-mail",
31+
"description": "Contact email for the project author.",
32+
"default": "plone@codesyntax.com",
3733
"validator": "",
3834
"format": "computed"
3935
},
40-
"plone_version": {
36+
37+
"language_code": {
4138
"type": "string",
42-
"title": "Plone Version",
43-
"description": "Plone backend version to use. Automatically resolved to the latest available release.",
44-
"default": "{{ false | latest_plone }}",
45-
"validator": "cookieplone.validators.plone_version"
39+
"title": "Language",
40+
"description": "Default language for the Plone site.",
41+
"default": "eu",
42+
"validator": "cookieplone.validators.language_code",
43+
"format": "computed"
44+
4645
},
4746
"github_organization": {
48-
"title": "GitHub Username or Organization",
49-
"default": "codesyntax",
5047
"type": "string",
48+
"title": "GitHub or GitLab username or organization slug from URL",
49+
"description": "Organization or username used to build the repository URL and container image paths.",
50+
"default": "codesyntax",
51+
"validator": "",
5152
"format": "computed"
52-
},
53-
"feature_headless": {
54-
"type": "boolean",
55-
"title": "Use Volto?",
56-
"description": "",
57-
"default": true,
58-
"validator": ""
59-
},
60-
"initialize_ci": {
61-
"type": "boolean",
62-
"title": "Add CI configuration?",
63-
"description": "",
64-
"default": false,
65-
"format": "computed"
66-
},
67-
"initialize_documentation": {
68-
"type": "boolean",
69-
"title": "Add documentation scaffold?",
70-
"description": "Generate a Sphinx-based documentation structure using the Plone documentation starter.",
71-
"default": true,
72-
"format": "computed"
53+
7354
},
7455
"container_registry": {
7556
"type": "string",
7657
"title": "Container Registry",
7758
"description": "Container registry where Docker images will be published.",
7859
"default": "gitlab",
60+
"validator": "",
7961
"format": "computed"
8062
},
8163
"devops_storage": {
8264
"type": "string",
8365
"title": "Which persistent storage to use in the deployment stack?",
8466
"description": "Backend storage strategy for the ZODB database in the deployment stack.",
8567
"default": "filestorage",
68+
"validator": "",
69+
"format": "computed"
70+
},
71+
"devops_cache": {
72+
"type": "boolean",
73+
"title": "Should we setup a caching server?",
74+
"description": "Include a Varnish caching layer in front of the backend.",
75+
"default": true,
76+
"validator": "",
8677
"format": "computed"
78+
8779
},
8880
"devops_ansible": {
8981
"type": "boolean",
@@ -92,6 +84,7 @@
9284
"default": false,
9385
"validator": "",
9486
"format": "computed"
87+
9588
},
9689
"devops_gha_deploy": {
9790
"type": "boolean",
@@ -100,42 +93,27 @@
10093
"default": false,
10194
"validator": "",
10295
"format": "computed"
96+
97+
},
98+
"initialize_documentation": {
99+
"type": "boolean",
100+
"title": "Would you like to add a documentation scaffold to your project?",
101+
"description": "Generate a Sphinx-based documentation structure using the Plone documentation starter.",
102+
"default": true,
103+
"validator": "",
104+
"format": "computed"
105+
103106
},
104107
"postgres": {
105108
"type": "boolean",
106109
"title": "Use Postgres?",
107110
"default": false
108111
},
109-
110112
"security_key": {
111113
"type": "string",
112114
"title": "Security Key",
113115
"default": "{{ random_ascii_string(32) }}",
114116
"format": "computed"
115-
},
116-
"volto_version": {
117-
"type": "string",
118-
"title": "Volto Version",
119-
"description": "Volto frontend version to use. Automatically resolved to the latest available release.",
120-
"default": "19.0.0",
121-
"validator": "cookieplone.validators.volto_version",
122-
"format": "computed"
123-
},
124-
"frontend_addon_name": {
125-
"type": "string",
126-
"title": "Volto Addon Name",
127-
"description": "Name of the Volto frontend add-on package (e.g. volto-myproject).",
128-
"default": "volto-{{ cookiecutter.python_package_name|replace('_', '-')|replace('.', '-') }}",
129-
"validator": "cookieplone.validators.npm_package_name",
130-
"format": "computed"
131-
},
132-
"language_code": {
133-
"type": "string",
134-
"title": "Language",
135-
"description": "Default language for the Plone site.",
136-
"default": "en",
137-
"validator": "cookieplone.validators.language_code",
138-
"format": "computed"
139117
}
140118
},
141119
"allOf": [

templates/project/{{ cookiecutter.__folder_name }}/database/Makefile.jinja renamed to templates/project/{{ cookiecutter.__folder_name }}/database/Makefile

File renamed without changes.

templates/project/{{ cookiecutter.__folder_name }}/database/docker-compose.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
services:
22

33
{%- if cookiecutter.postgres %}
4-
postgres: postgres:17 (tsvector ranking, no extensions needed)
5-
# For BM25: PG_IMAGE=tensorchord/vchord-suite:pg17-latest docker compose up -d
4+
postgres:
5+
# HINT:
6+
# - Using the postgres:17 image, you will have tsvector based search
7+
# - Using the tensorchord/vchord-suite:pg17-latest image, you will have BM25 ranking
68
image: ${PG_IMAGE:-postgres:17}
79
environment:
810
POSTGRES_USER: zodb
@@ -31,7 +33,7 @@ services:
3133
image: ghcr.io/bluedynamics/zodb-pgjsonb-thumborblobloader:0.4.2
3234
environment:
3335
PGTHUMBOR_DSN: "dbname=zodb user=zodb password=zodb host=postgres"
34-
THUMBOR_SECURITY_KEY: "secret"
36+
THUMBOR_SECURITY_KEY: "{{ cookiecutter.security_key }}"
3537
ALLOW_UNSAFE_URL: "True"
3638
PGTHUMBOR_PLONE_AUTH_URL: "http://plone.127.0.0.1.nip.io:8080/Plone"
3739
PGTHUMBOR_AUTH_CACHE_TTL: "60"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
VERSION=1.0.0
2+
# PG_IMAGE = postgres:17
3+
# PG_IMAGE = tensorchord/vchord-suite:pg17-latest

templates/project/{{ cookiecutter.__folder_name }}/deploy/docker-compose.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ services:
7878

7979
{%- if cookiecutter.postgres %}
8080
postgres:
81-
# Default: postgres:17 (tsvector ranking, no extensions needed)
82-
# For BM25: PG_IMAGE=tensorchord/vchord-suite:pg17-latest docker compose up -d
81+
# HINT:
82+
# - Using the postgres:17 image, you will have tsvector based search
83+
# - Using the tensorchord/vchord-suite:pg17-latest image, you will have BM25 ranking
84+
# You can set the value here or in the .env file
8385
image: ${PG_IMAGE:-postgres:17}
8486
environment:
8587
POSTGRES_USER: zodb
Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
{
22
"schema": {
33
"properties": {
4-
"domain": {
5-
"type": "string",
6-
"default": "{{ hostname }}",
4+
"postgres": {
5+
"type": "boolean",
6+
"title": "Use Postgres?",
7+
"default": false,
78
"format": "computed"
89
},
9-
"image_prefix": {
10+
"thumbor": {
11+
"type": "boolean",
12+
"title": "Should we use Thumbor for image scale generation?",
13+
"description": "",
14+
"default": false,
15+
"validator": ""
16+
},
17+
"security_key": {
1018
"type": "string",
11-
"default": "ghcr.io/codesyntax",
19+
"title": "Security Key",
20+
"default": "{{ random_ascii_string(32) }}",
1221
"format": "computed"
1322
}
1423
}
1524
}
16-
}
25+
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
"""Post generation hook."""
2+
3+
import json
4+
from collections import OrderedDict
5+
from pathlib import Path
6+
7+
from binaryornot.check import is_binary
8+
from cookieplone import generator
9+
from cookieplone.utils import console, npm, plone, post_gen
10+
from cookieplone.utils.subtemplates import run_subtemplates
11+
12+
context: OrderedDict = {{cookiecutter}}
13+
versions: dict | OrderedDict = {{versions}}
14+
15+
16+
POST_GEN_TO_REMOVE: dict[str, list[str]] = {
17+
"devops": [
18+
"devops/.env_dist",
19+
"devops/.gitignore",
20+
"devops/ansible.cfg",
21+
"devops/etc",
22+
"devops/inventory",
23+
"devops/Makefile",
24+
"devops/playbooks",
25+
"devops/requirements",
26+
"devops/tasks",
27+
"devops/README.md",
28+
],
29+
}
30+
31+
TEMPLATES_FOLDER: str = "templates"
32+
33+
34+
def modify_pyprojecttoml_dependency(context: OrderedDict, *args: tuple, **kwargs: dict):
35+
new_content = []
36+
with open(Path("backend") / "pyproject.toml") as fp:
37+
in_dependencies = False
38+
for line in fp.readlines():
39+
if in_dependencies and line == "]\n":
40+
in_dependencies = False
41+
new_content.append("]")
42+
elif in_dependencies:
43+
continue
44+
45+
elif not in_dependencies and line.startswith("dependencies = ["):
46+
new_content.append(line)
47+
new_content.append('"Plone",')
48+
if context.get("postgres", False):
49+
new_content.append('"zodb_pgjsonb",')
50+
new_content.append('"plone.pgcatalog",')
51+
if context.get("thumbor"):
52+
new_content.append('"plone-pgthumbor",')
53+
54+
if not context.get("feature_headless", False):
55+
new_content.append('"z3c.jbot",')
56+
57+
in_dependencies = True
58+
else:
59+
new_content.append(line)
60+
61+
with open(Path("backend") / "pyproject.toml", "w") as fp:
62+
fp.writelines(new_content)
63+
64+
65+
def action_handlers(context: OrderedDict) -> list[post_gen.PostGenAction]:
66+
"""Return action handlers."""
67+
68+
actions: list[post_gen.PostGenAction] = [
69+
{
70+
"handler": post_gen.remove_files_by_key(POST_GEN_TO_REMOVE, "devops"),
71+
"title": "Remove Ansible files",
72+
"enabled": True,
73+
},
74+
{
75+
"handler": modify_pyprojecttoml_dependency,
76+
"title": "Modify pyproject.toml dependencies",
77+
"enabled": True,
78+
},
79+
]
80+
return actions
81+
82+
83+
def main():
84+
"""Final fixes."""
85+
output_dir = Path().cwd()
86+
87+
# Action handlers
88+
post_gen.run_post_gen_actions(context, output_dir, action_handlers(context))
89+
90+
msg = """
91+
[bold blue]{{ cookiecutter.title }}[/bold blue]
92+
93+
Now, code it, create a git repository, push to your organization.
94+
95+
Sorry for the convenience,
96+
The Plone Community.
97+
"""
98+
console.panel(
99+
title="New project was generated",
100+
subtitle="",
101+
msg=msg,
102+
url="https://plone.org/",
103+
)
104+
105+
106+
if __name__ == "__main__":
107+
main()

templates/sub/project_settings/{{ cookiecutter.__folder_name }}/backend/Dockerfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
# syntax=docker/dockerfile:1
2-
ARG PYTHON_VERSION=3.12
2+
ARG PYTHON_VERSION={{ cookiecutter.__python_version }}
33
FROM plone/server-builder:uv-${PYTHON_VERSION} AS builder
44

5-
RUN apt-get update && apt-get install -y openssh-client git
6-
RUN mkdir -p ~/.ssh && echo "Host *\\n\\tStrictHostKeyChecking no\\n\\n" > ~/.ssh/config
7-
85
# Install project dependencies based on uv.lock and pyproject.toml
96
# We expect pyproject.toml to have an entry cointainer inside [dependency-groups]
107
RUN --mount=type=cache,target=/root/.cache \

0 commit comments

Comments
 (0)