EcosystemPage.vala 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. using Astralis;
  2. using Invercargill;
  3. using Invercargill.DataStructures;
  4. using Inversion;
  5. using Spry;
  6. /**
  7. * EcosystemPage - Overview of the framework ecosystem
  8. *
  9. * Showcases Astralis, Inversion, and Spry working together
  10. */
  11. public class EcosystemPage : PageComponent {
  12. public const string ROUTE = "/ecosystem";
  13. public override string markup { get {
  14. return """
  15. <div sid="ecosystem-page" class="section">
  16. <div class="container">
  17. <!-- Header -->
  18. <div class="section-header">
  19. <h1>The Ecosystem</h1>
  20. <p>Three powerful libraries working together to make web development in Vala a joy</p>
  21. </div>
  22. <!-- Ecosystem Overview -->
  23. <div class="ecosystem-grid">
  24. <!-- Astralis -->
  25. <div class="ecosystem-card astralis">
  26. <h3>
  27. <div class="ecosystem-logo">A</div>
  28. Astralis
  29. </h3>
  30. <p>The high-performance web server foundation. Astralis provides the HTTP server, routing, compression, and static file serving that powers Spry applications.</p>
  31. <div style="margin-top: var(--space-4);">
  32. <span class="tag">HTTP Server</span>
  33. <span class="tag">Routing</span>
  34. <span class="tag">Compression</span>
  35. <span class="tag">Fast Resources</span>
  36. <span class="tag">Middleware</span>
  37. </div>
  38. <div class="code-block" style="margin-top: var(--space-6);">
  39. <div class="code-header">
  40. <div class="code-dots">
  41. <div class="code-dot red"></div>
  42. <div class="code-dot yellow"></div>
  43. <div class="code-dot green"></div>
  44. </div>
  45. <span class="code-lang">Vala</span>
  46. </div>
  47. <pre><code>var app = new WebApplication(8080);
  48. app.use_compression();
  49. app.add_endpoint<MyEndpoint>(
  50. new EndpointRoute("/api")
  51. );
  52. app.run();</code></pre>
  53. </div>
  54. </div>
  55. <!-- Inversion -->
  56. <div class="ecosystem-card inversion">
  57. <h3>
  58. <div class="ecosystem-logo">I</div>
  59. Inversion
  60. </h3>
  61. <p>A lightweight dependency injection container. Inversion manages your services, stores, and component lifecycles with elegant IoC patterns.</p>
  62. <div style="margin-top: var(--space-4);">
  63. <span class="tag">IoC Container</span>
  64. <span class="tag">DI</span>
  65. <span class="tag">Lifecycles</span>
  66. <span class="tag">Factories</span>
  67. <span class="tag">Modules</span>
  68. </div>
  69. <div class="code-block" style="margin-top: var(--space-6);">
  70. <div class="code-header">
  71. <div class="code-dots">
  72. <div class="code-dot red"></div>
  73. <div class="code-dot yellow"></div>
  74. <div class="code-dot green"></div>
  75. </div>
  76. <span class="code-lang">Vala</span>
  77. </div>
  78. <pre><code>// Register services
  79. container.add_singleton<Database>();
  80. container.add_scoped<UserSession>();
  81. container.add_transient<EmailService>();
  82. // Inject anywhere
  83. var db = inject<Database>();</code></pre>
  84. </div>
  85. </div>
  86. <!-- Spry -->
  87. <div class="ecosystem-card spry">
  88. <h3>
  89. <div class="ecosystem-logo">S</div>
  90. Spry
  91. </h3>
  92. <p>The component-based web framework. Spry brings reactive templates, HTMX integration, and a delightful developer experience to Vala web development.</p>
  93. <div style="margin-top: var(--space-4);">
  94. <span class="tag">Components</span>
  95. <span class="tag">HTMX</span>
  96. <span class="tag">Templates</span>
  97. <span class="tag">Outlets</span>
  98. <span class="tag">Actions</span>
  99. </div>
  100. <div class="code-block" style="margin-top: var(--space-6);">
  101. <div class="code-header">
  102. <div class="code-dots">
  103. <div class="code-dot red"></div>
  104. <div class="code-dot yellow"></div>
  105. <div class="code-dot green"></div>
  106. </div>
  107. <span class="code-lang">Vala</span>
  108. </div>
  109. <pre><code>class MyComponent : Component {
  110. public override string markup {
  111. owned get {
  112. return "<div sid='root'>
  113. <button spry-action=':Click'>
  114. Click me!
  115. </button>
  116. </div>";
  117. }
  118. }
  119. }</code></pre>
  120. </div>
  121. </div>
  122. </div>
  123. <!-- How They Work Together -->
  124. <section class="demo-section" style="margin-top: var(--space-12);">
  125. <h2>🔗 How They Work Together</h2>
  126. <p>The three libraries form a complete stack for building web applications:</p>
  127. <div class="features-grid" style="margin-top: var(--space-6);">
  128. <div class="feature-card">
  129. <div class="feature-icon blue">1</div>
  130. <h3>Astralis Handles HTTP</h3>
  131. <p>Receives requests, routes them to the right handler, and sends responses with compression.</p>
  132. </div>
  133. <div class="feature-card">
  134. <div class="feature-icon green">2</div>
  135. <h3>Inversion Manages Dependencies</h3>
  136. <p>Creates and injects services, stores, and components with the right lifecycle.</p>
  137. </div>
  138. <div class="feature-card">
  139. <div class="feature-icon purple">3</div>
  140. <h3>Spry Renders UI</h3>
  141. <p>Components handle requests, render templates, and respond with HTML for HTMX.</p>
  142. </div>
  143. </div>
  144. </section>
  145. <!-- Architecture Diagram -->
  146. <section class="demo-section" style="margin-top: var(--space-8);">
  147. <h2>🏗 Architecture Overview</h2>
  148. <div class="code-block">
  149. <div class="code-header">
  150. <div class="code-dots">
  151. <div class="code-dot red"></div>
  152. <div class="code-dot yellow"></div>
  153. <div class="code-dot green"></div>
  154. </div>
  155. <span class="code-lang">Request Flow</span>
  156. </div>
  157. <pre><code>┌─────────────────────────────────────────────────────────────┐
  158. │ Browser │
  159. │ (HTMX + HTML) │
  160. └─────────────────────────┬───────────────────────────────────┘
  161. │ HTTP Request
  162. ┌─────────────────────────────────────────────────────────────┐
  163. │ Astralis │
  164. │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
  165. │ │ Server │→ │ Router │→ │ Compression │ │
  166. │ └─────────────┘ └─────────────┘ └─────────────┘ │
  167. └─────────────────────────┬───────────────────────────────────┘
  168. ┌─────────────────────────────────────────────────────────────┐
  169. │ Inversion │
  170. │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
  171. │ │ Container │→ │ Factories │→ │ Scopes │ │
  172. │ └─────────────┘ └─────────────┘ └─────────────┘ │
  173. │ ↓ inject() into components │
  174. └─────────────────────────┬───────────────────────────────────┘
  175. ┌─────────────────────────────────────────────────────────────┐
  176. │ Spry │
  177. │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
  178. │ │ Components │→ │ Templates │→ │ Actions │ │
  179. │ └─────────────┘ └─────────────┘ └─────────────┘ │
  180. │ ↓ HTML Response with HTMX attributes │
  181. └─────────────────────────────────────────────────────────────┘</code></pre>
  182. </div>
  183. </section>
  184. <!-- CTA -->
  185. <div class="text-center" style="margin-top: var(--space-12);">
  186. <h2>Experience the Power</h2>
  187. <p style="margin-bottom: var(--space-6);">See the ecosystem in action with our interactive demo.</p>
  188. <div class="hero-actions" style="justify-content: center;">
  189. <a href="/demo" class="btn btn-primary">Try Live Demo</a>
  190. <a href="/features" class="btn btn-secondary">View Features</a>
  191. </div>
  192. </div>
  193. </div>
  194. </div>
  195. """;
  196. }}
  197. }