Main.vala 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using Astralis;
  2. using Invercargill;
  3. using Inversion;
  4. using Spry;
  5. /**
  6. * Main.vala - Spry Framework Website
  7. *
  8. * A modern, techy website showcasing the Spry framework and its ecosystem:
  9. * - Astralis: High-performance web server framework
  10. * - Inversion: Dependency injection container
  11. * - Spry: Component-based HTMX web framework
  12. *
  13. * Features:
  14. * - Clean, eye-catching design with purple/blue/green theme
  15. * - Interactive particle demo showcasing real-time HTMX updates
  16. * - Responsive layout with modern CSS
  17. * - Free/Libre open source spirit
  18. */
  19. void main(string[] args) {
  20. int port = args.length > 1 ? int.parse(args[1]) : 8080;
  21. print("═══════════════════════════════════════════════════════════════\n");
  22. print(" 🚀 Spry Framework Website\n");
  23. print("═══════════════════════════════════════════════════════════════\n");
  24. print(" Port: %d\n", port);
  25. print("═══════════════════════════════════════════════════════════════\n");
  26. print(" Pages:\n");
  27. print(" / - Home\n");
  28. print(" /features - Features\n");
  29. print(" /ecosystem - Ecosystem (Astralis, Inversion, Spry)\n");
  30. print(" /demo - Interactive Demo\n");
  31. print(" /freedom - Free/Libre Philosophy\n");
  32. print("═══════════════════════════════════════════════════════════════\n");
  33. print("\nPress Ctrl+C to stop the server\n\n");
  34. try {
  35. var application = new WebApplication(port);
  36. // Enable compression
  37. application.use_compression();
  38. // Add Spry module for component actions
  39. application.add_module<SpryModule>();
  40. // Register stores as singletons
  41. application.add_singleton<AuroraState>();
  42. // Configure templates
  43. var spry_cfg = application.configure_with<SpryConfigurator>();
  44. spry_cfg.add_template<SiteLayoutTemplate>("");
  45. // Register page components
  46. application.add_transient<HomePage>();
  47. application.add_endpoint<HomePage>(new EndpointRoute(HomePage.ROUTE));
  48. application.add_transient<FeaturesPage>();
  49. application.add_endpoint<FeaturesPage>(new EndpointRoute(FeaturesPage.ROUTE));
  50. application.add_transient<EcosystemPage>();
  51. application.add_endpoint<EcosystemPage>(new EndpointRoute(EcosystemPage.ROUTE));
  52. application.add_transient<DemoPage>();
  53. application.add_endpoint<DemoPage>(new EndpointRoute(DemoPage.ROUTE));
  54. application.add_transient<FreedomPage>();
  55. application.add_endpoint<FreedomPage>(new EndpointRoute(FreedomPage.ROUTE));
  56. // Register interactive components (for spry-action)
  57. application.add_transient<AuroraWaveComponent>();
  58. application.add_transient<AuroraCanvasEndpoint>();
  59. application.add_transient<AuroraStatsEndpoint>();
  60. application.add_transient<FeatureCardComponent>();
  61. application.add_transient<CodeBlockComponent>();
  62. application.add_transient<StatCardComponent>();
  63. // Register CSS as FastResources
  64. application.add_startup_endpoint<FastResource>(new EndpointRoute("/styles/main.css"), () => {
  65. try {
  66. return new FastResource.from_string(Styles.MAIN_CSS)
  67. .with_content_type("text/css; charset=utf-8")
  68. .with_default_compressors();
  69. } catch (Error e) {
  70. error("Failed to create main CSS resource: %s", e.message);
  71. }
  72. });
  73. application.run();
  74. } catch (Error e) {
  75. printerr("Error: %s\n", e.message);
  76. Process.exit(1);
  77. }
  78. }