SpryModule.vala 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using InvercargillSqlInversion;
  2. using Inversion;
  3. namespace Spry {
  4. /**
  5. * Inversion module that registers Spry's user store: the `spry_users` and
  6. * `spry_user_permissions` schema (M0001 + M0002 migrations), the
  7. * entity/projection
  8. * mappings, and the scoped {@link Spry.Authentication.UserService}.
  9. *
  10. * Register this module with the application container alongside
  11. * `StatumModule`; it registers no endpoints. The Spry CSS framework and
  12. * its themes are embedded as default Statum resources (see
  13. * {@link Spry.Resources}), served from `/_statum/resource/spry.css` and
  14. * `/_statum/resource/spry-theme-*.css`. Ready-made actions are bound
  15. * separately via {@link SpryAuth.register_actions} or
  16. * `StatumConfigurator.action`.
  17. */
  18. public class SpryModule : Object, Module {
  19. public void register_components(Container container) throws Error {
  20. // Sql table setup
  21. var sql = container.configure_with<DatabaseConfigurator>();
  22. sql.add_migration<Authentication.Migrations.M0001_Initial>();
  23. sql.add_migration<Authentication.Migrations.M0002_SessionsValidAfter>();
  24. sql.add_entity<Authentication.UserEntity>(Authentication.UserEntity.entity_mapping);
  25. sql.add_entity<Authentication.UserPermissionEntity>(Authentication.UserPermissionEntity.entity_mapping);
  26. sql.add_projection<Authentication.UserProjection>(Authentication.UserProjection.projection_mapping);
  27. // Service setup
  28. container.register_scoped<Authentication.UserService>();
  29. // Embed the Spry CSS framework as default resources (generated at
  30. // build time by statum-mkres, precompressed). Apps get the core
  31. // stylesheet and every theme for free and may activate a theme
  32. // with a second <link pstm-res-src="spry-theme-*.css"> plus
  33. // data-theme on <html>.
  34. container.register_startup<Resources.SpryCss>().as<Statum.StatumResource>();
  35. container.register_startup<Resources.SpryThemeAiry>().as<Statum.StatumResource>();
  36. container.register_startup<Resources.SpryThemeDwarf>().as<Statum.StatumResource>();
  37. container.register_startup<Resources.SpryThemeFormal>().as<Statum.StatumResource>();
  38. container.register_startup<Resources.SpryThemeGlassy>().as<Statum.StatumResource>();
  39. container.register_startup<Resources.SpryThemeH2o>().as<Statum.StatumResource>();
  40. container.register_startup<Resources.SpryThemeLivingSky>().as<Statum.StatumResource>();
  41. container.register_startup<Resources.SpryThemeModern>().as<Statum.StatumResource>();
  42. }
  43. }
  44. }