Skip to content

Commit

Permalink
Merge pull request #526 from plone/erral-starter-subtemplate
Browse files Browse the repository at this point in the history
add a starter template
  • Loading branch information
MrTango authored Apr 11, 2024
2 parents 39de6b8 + dfda5ee commit b8a90b0
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ New features:
6.2 (2022-10-28)
----------------

- Add a starter subtemplate to initialize a Plone site with some sane default values
[erral]

- Improve namespace support #419
[mamico]

Expand Down
8 changes: 8 additions & 0 deletions bobtemplates/plone/bobregistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,11 @@ def plone_form():
reg.plonecli_alias = "form"
reg.depend_on = "plone_addon"
return reg


def plone_site_initialization():
reg = RegEntry()
reg.template = "bobtemplates.plone:site_initialization"
reg.plonecli_alias = "site_initialization"
reg.depend_on = "plone_addon"
return reg
16 changes: 16 additions & 0 deletions bobtemplates/plone/site_initialization.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from bobtemplates.plone.base import base_prepare_renderer
from bobtemplates.plone.base import git_commit
from bobtemplates.plone.base import git_support


def prepare_renderer(configurator):
"""Prepare rendering."""
configurator = base_prepare_renderer(configurator)

configurator.target_directory = configurator.variables["package_folder"]


def post_renderer(configurator):
"""Post rendering."""
if git_support(configurator):
git_commit(configurator, "Add Plone site initialization configuration")
24 changes: 24 additions & 0 deletions bobtemplates/plone/site_initialization/.mrbob.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[questions]
subtemplate_warning.question = Please commit your changes, before using a sub-template! Continue anyway? [N/y]
subtemplate_warning.required = True
subtemplate_warning.default = n
subtemplate_warning.pre_ask_question = bobtemplates.plone.base:git_clean_state_check
subtemplate_warning.post_ask_question = mrbob.hooks:validate_choices bobtemplates.plone.base:subtemplate_warning_post_question
subtemplate_warning.choices = y|n
subtemplate_warning.choices_delimiter = |

language.question = Enter the 2 letter language code for your site
language.help = Shold be something like 'en'
language.required = True
language.default = 'en'

site_name.question = Enter the name of your site
site_name.help = Should be something like 'My new site'
site_name.required = True
site_name.default = New Plone Site


[template]
post_ask = bobtemplates.plone.base:set_global_vars
pre_render = bobtemplates.plone.site_initialization:prepare_renderer
post_render = bobtemplates.plone.site_initialization:post_renderer
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<registry>
<records interface="plone.base.interfaces.controlpanel.IMailSchema" prefix="plone" purge="false">
<value key="email_from_name">{{{ site_name }}}</value>
</records>
</registry>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<registry>
<records interface="plone.base.interfaces.controlpanel.ISiteSchema" prefix="plone" purge="false">
<value key="site_title">{{{ site_name }}}</value>
</records>
</registry>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version='1.0' encoding='UTF-8'?>
<registry>
<records interface="plone.i18n.interfaces.ILanguageSchema" prefix="plone" purge="false">
<value key="available_languages">
<element>{{{ language }}}</element>
</value>
<value key="default_language">{{{ language }}}</value>
</records>
</registry>
2 changes: 1 addition & 1 deletion constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Pin Versions / Version Ranges if necessary.
setuptools==57.0.0
tox==4.11.3
isort>=5
isort>=5.12.0
flake8==5.0.4
flake8-html==0.4.2
black==22.8.0
Expand Down
Empty file.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"plone_vocabulary = bobtemplates.plone.bobregistry:plone_vocabulary",
"plone_controlpanel = bobtemplates.plone.bobregistry:plone_controlpanel",
"plone_form = bobtemplates.plone.bobregistry:plone_form",
"plone_site_initialization = bobtemplates.plone.bobregistry:plone_site_initialization",
]
},
)

0 comments on commit b8a90b0

Please sign in to comment.