| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using InvercargillSqlInversion;
- using Inversion;
- namespace Spry {
- /**
- * Inversion module that registers Spry's user store: the `spry_users` and
- * `spry_user_permissions` schema (M0001 + M0002 migrations), the
- * entity/projection
- * mappings, and the scoped {@link Spry.Authentication.UserService}.
- *
- * Register this module with the application container alongside
- * `StatumModule`; it registers no endpoints. The Spry CSS framework and
- * its themes are embedded as default Statum resources (see
- * {@link Spry.Resources}), served from `/_statum/resource/spry.css` and
- * `/_statum/resource/spry-theme-*.css`. Ready-made actions are bound
- * separately via {@link SpryAuth.register_actions} or
- * `StatumConfigurator.action`.
- */
- public class SpryModule : Object, Module {
- public void register_components(Container container) throws Error {
- // Sql table setup
- var sql = container.configure_with<DatabaseConfigurator>();
- sql.add_migration<Authentication.Migrations.M0001_Initial>();
- sql.add_migration<Authentication.Migrations.M0002_SessionsValidAfter>();
- sql.add_entity<Authentication.UserEntity>(Authentication.UserEntity.entity_mapping);
- sql.add_entity<Authentication.UserPermissionEntity>(Authentication.UserPermissionEntity.entity_mapping);
- sql.add_projection<Authentication.UserProjection>(Authentication.UserProjection.projection_mapping);
- // Service setup
- container.register_scoped<Authentication.UserService>();
- // Embed the Spry CSS framework as default resources (generated at
- // build time by statum-mkres, precompressed). Apps get the core
- // stylesheet and every theme for free and may activate a theme
- // with a second <link pstm-res-src="spry-theme-*.css"> plus
- // data-theme on <html>.
- container.register_startup<Resources.SpryCss>().as<Statum.StatumResource>();
- container.register_startup<Resources.SpryThemeAiry>().as<Statum.StatumResource>();
- container.register_startup<Resources.SpryThemeDwarf>().as<Statum.StatumResource>();
- container.register_startup<Resources.SpryThemeFormal>().as<Statum.StatumResource>();
- container.register_startup<Resources.SpryThemeGlassy>().as<Statum.StatumResource>();
- container.register_startup<Resources.SpryThemeH2o>().as<Statum.StatumResource>();
- container.register_startup<Resources.SpryThemeLivingSky>().as<Statum.StatumResource>();
- container.register_startup<Resources.SpryThemeModern>().as<Statum.StatumResource>();
- }
- }
- }
|