lewp-rs icon indicating copy to clipboard operation
lewp-rs copied to clipboard

Generate your HTML5 website technically optimized and always valid without losing the algorithmic comfort and flexibility.


Version Downloads MIT or Apache-2.0 License

Say goodbye to the web template hell. Generate your HTML5 website technically optimized and always valid. Without mixing languages.

This is the adjusted Rust implementation of the PHP version of lewp.

If you have questions, want to contribute or have any other type of request, your invited to create an issue.

❓What is lewp?

Lewp is a collection of structs and traits that simplify modularized website creation and reusage of code without sacrificing the comfort of programming, speed and optimized serving of the resulting site.

πŸ₯… Project goals

  1. Simplfying the creation of web pages without mixing programming languages or putting logic into your HTML (like it is done in templates)

  2. Creating modularized websites with truly isolated and reusable components/modules, eg. automatically namespaced CSS and JavaScript (not implemented yet)

  3. Providing a file hierarchy that is consistently throughout your project and can be shared between different projects

  4. Getting the best of both worlds, server side and client side rendering

  5. Minimization of page loading times (especially FCP and TTI)

  6. Removing initial setup HTML boilerplate code creation by the developer (the base skeleton with html, head and required meta, body tags are created by lewp)

  7. Applying SEO best practices already in development setup as much as possible

πŸ“¦ Features

  • [x] Build your HTML website fully from Rust source
  • [x] No additional fancy markup or language, just a clean API
  • [x] Never touch confusing templates again
  • [x] Always serve correct, minimized HTML5
  • [x] Develop your Website as fully isolated modules

❓Why lewp?

Many frameworks already exist that support developers in creating websites and -apps in various languages, eg. Laravel, Symfony, or Django etc. They usually follow the MVC pattern. You can create a controller for every route and add a model as well as a view for this, all in separate folders. So far, nothing new, a well known and proven concept. However, several problems can arise regarding e.g. code quality, re-usability as well as best practices of SEO and much more. The architecture of these frameworks can lead developers to become inconsistent considering their code structure. Because the files are spread over the whole project, the reusability of code can easily suffer. In addition to that, the usage of templating systems like Twig can make the developer create invalid HTML code without recognizing it or create problems relating to for example page loading times (which is a crucial factor), the critical rendering path or avoiding "extra whitespace between HTML tags to avoid browser rendering quirks under some circumstances". In the latter (a cite from the Twig documentation), Twig has a property to prevent this, but you need to explicitly enable it and "its performance is directly related to the text size you are working on". Developing in these environments can run the risk of spreading those problems over your whole project, making it almost impossible to recover from without rewriting your code base.

So the idea was to create a library that minimizes the impact of the stated problems without making compromises on the comfort of programming.

lewp generates a highly optimized HTML web page and provides automatic handling of your CSS code (and your JavaScript soon) if you want to. Have a look at the examples folder for more information about how to use it.

❗ lewp is not a webserver. It is a library that supports you in structuring your algorithms bringing them perfectly in line with your view, without letting your code get messy! It perfectly integrates with frameworks like rocket or actix-web.

🚌 Roadmap

  • [x] Skeleton to create website with by creating the DOM
  • [x] A webpage can have Modules
    • [x] Each module is surrounded by a wrapper div
  • [x] A page is created with isolated modules (HTML only)
  • [x] Modules can have Modules, infinite loops are prevented
    • [x] Submodules have RuntimeInformation available
  • [x] <head> modules only
  • [x] The wrapping div tag can be disabled (recommended only for <head> modules)
  • [x] File hierarchy for CSS and JS is defined
    • [ ] Prevent / in IDs
    • [x] Prevent usage of .. in paths or IDs
  • [ ] CSS integration
    • [x] Combining files is implemented
    • [x] Minimization of CSS is implemented
    • [x] Modules without CSS are skipped
    • [x] CSS links are automatically inserted into the HTML <head> tag if files are available
    • [ ] CSS can be split up into "render critical" (will be inlined on rendering) and "non render critical" parts
    • [x] A CSS register is implemented that can be used as shared global querying instance for CSS files
  • [x] Modules are isolated (HTML, CSS)
  • [x] Page specific CSS is possible
  • [x] Provide an API for generic resources
  • [ ] Added html5-picture support
    • [ ] Conversion of pictures on startup is possible
    • [ ] Usage of <picture> tags within lewp
  • [ ] JavaScript integration
    • [ ] Combining files is implemented
    • [ ] Minimization is implemented
  • [ ] Modules are now fully isolated (HTML, CSS, JavaScript)
  • [ ] Compiling resources into binary is possible
    • [ ] JavaScript
    • [ ] CSS
    • [ ] Resources implementing fh::Component
  • [ ] Add attributes to the container wrapping the module
  • [ ] Provide an API for localization (l10n)
  • [ ] Modules can have isolated folders for temporary files
  • [ ] HTML can be streamed
  • [ ] Configuration using .toml files
    • [ ] Modules
    • [ ] Pages

🀠 Contributing

Unless explicitly stated, any contribution intentionally submitted for inclusion in this project, as defined in the Apache-2.0 license, shall be dual licensed as below, without any additional terms or conditions.

Please have a look at CONTRIBUTING.md for guidelines and conventions.

βš– License

Licensed under either of

  • Apache License, Version 2.0 (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)

at your option.