[docs]
@final
@deprecated(
"The Cotton Candy theme has been deprecated since Betty 0.4.9, and will be removed in Betty 0.5. Instead use Raspberry Mint (`raspberry-mint`)."
)
class CottonCandy(
ShorthandPluginBase,
Theme,
CssProvider,
ConfigurableExtension[CottonCandyConfiguration],
Jinja2Provider,
EntryPointProvider,
):
"""
The Cotton Candy theme.
"""
_plugin_id = "cotton-candy"
_plugin_label = static("Cotton Candy")
_plugin_description = _("Cotton Candy is Betty's legacy theme.")
[docs]
@private
def __init__(
self,
project: Project,
public_css_paths: Sequence[str],
*,
configuration: CottonCandyConfiguration,
):
super().__init__(project, configuration=configuration)
self._public_css_paths = public_css_paths
[docs]
@override
@classmethod
async def new_for_project(cls, project: Project) -> Self:
url_generator = await project.url_generator
return cls(
project,
[url_generator.generate("betty-static:///css/cotton-candy.css")],
configuration=cls.new_default_configuration(),
)
[docs]
@override
async def bootstrap(self) -> None:
await super().bootstrap()
try:
await self._assert_configuration()
except BaseException:
await self.shutdown()
raise
async def _assert_configuration(self) -> None:
await self.configuration.featured_entities.validate(
self.project.entity_type_repository
)
[docs]
@override
def register_event_handlers(self, registry: EventHandlerRegistry) -> None:
registry.add_handler(GenerateSiteEvent, _generate_logo, _generate_search_index)
[docs]
@override
@classmethod
def depends_on(cls) -> set[PluginIdentifier[Extension]]:
return {Webpack}
[docs]
@override
@classmethod
def comes_after(cls) -> set[PluginIdentifier[Extension]]:
return {Maps, Trees}
[docs]
@override
@classmethod
def assets_directory_path(cls) -> Path:
return Path(__file__).parent / "assets"
[docs]
@override
@classmethod
def webpack_entry_point_directory_path(cls) -> Path:
return Path(__file__).parent / "webpack"
[docs]
@override
def webpack_entry_point_cache_keys(self) -> Sequence[str]:
return (
self.project.configuration.root_path,
self._configuration.primary_inactive_color.hex,
self._configuration.primary_active_color.hex,
self._configuration.link_inactive_color.hex,
self._configuration.link_active_color.hex,
)
@override
@property
def public_css_paths(self) -> Sequence[str]:
return self._public_css_paths
[docs]
@override
@classmethod
def new_default_configuration(cls) -> CottonCandyConfiguration:
return CottonCandyConfiguration()
@override
@property
def filters(self) -> Filters:
return jinja2_filters(self._project)